diff --git a/include/wx/cocoa/NSView.h b/include/wx/cocoa/NSView.h index 37e7016083..643f85886d 100644 --- a/include/wx/cocoa/NSView.h +++ b/include/wx/cocoa/NSView.h @@ -15,7 +15,12 @@ #include "wx/hashmap.h" #include "wx/cocoa/ObjcAssociate.h" +#if defined(__LP64__) || defined(NS_BUILD_32_LIKE_64) +typedef struct CGRect NSRect; +#else typedef struct _NSRect NSRect; +#endif + class wxWindow; WX_DECLARE_OBJC_HASHMAP(NSView); diff --git a/include/wx/cocoa/pen.h b/include/wx/cocoa/pen.h index 6f14b78318..5049cda035 100644 --- a/include/wx/cocoa/pen.h +++ b/include/wx/cocoa/pen.h @@ -61,7 +61,7 @@ public: wxBitmap *GetStipple() const; WX_NSColor GetNSColor(); - int GetCocoaLineDash(const float **pattern); + int GetCocoaLineDash(const CGFloat **pattern); }; #endif // __WX_COCOA_PEN_H__ diff --git a/include/wx/cocoa/region.h b/include/wx/cocoa/region.h index 20e7ce3d28..2789d24e0b 100644 --- a/include/wx/cocoa/region.h +++ b/include/wx/cocoa/region.h @@ -14,7 +14,11 @@ #include "wx/generic/region.h" +#if defined(__LP64__) || defined(NS_BUILD_32_LIKE_64) +typedef struct CGRect NSRect; +#else typedef struct _NSRect NSRect; +#endif class WXDLLEXPORT wxRegion : public wxRegionGeneric { diff --git a/include/wx/cocoa/toolbar.h b/include/wx/cocoa/toolbar.h index 6371c261de..45c60c4430 100644 --- a/include/wx/cocoa/toolbar.h +++ b/include/wx/cocoa/toolbar.h @@ -17,7 +17,12 @@ // ======================================================================== // wxToolBar // ======================================================================== +#if defined(__LP64__) || defined(NS_BUILD_32_LIKE_64) +typedef struct CGPoint NSPoint; +#else typedef struct _NSPoint NSPoint; +#endif + class wxToolBarTool; class wxToolBar : public wxToolBarBase diff --git a/include/wx/defs.h b/include/wx/defs.h index b3c051f344..c436cb05ef 100644 --- a/include/wx/defs.h +++ b/include/wx/defs.h @@ -2419,6 +2419,36 @@ typedef void* WXDisplay; #ifdef __WXCOCOA__ +/* Definitions of 32-bit/64-bit types + * These are typedef'd exactly the same way in newer OS X headers so + * redefinition when real headers are included should not be a problem. If + * it is, the types are being defined wrongly here. + * The purpose of these types is so they can be used from public wx headers. + * and also because the older (pre-Leopard) headers don't define them. + */ + +/* NOTE: We don't pollute namespace with CGFLOAT_MIN/MAX/IS_DOUBLE macros + * since they are unlikely to be needed in a public header. + */ +#if defined(__LP64__) && __LP64__ + typedef double CGFloat; +#else + typedef float CGFloat; +#endif + +#if (defined(__LP64__) && __LP64__) || (defined(NS_BUILD_32_LIKE_64) && NS_BUILD_32_LIKE_64) +typedef long NSInteger; +typedef unsigned long NSUInteger; +#else +typedef int NSInteger; +typedef unsigned int NSUInteger; +#endif + +/* Objective-C type declarations. + * These are to be used in public headers in lieu of NSSomething* because + * Objective-C class names are not available in C/C++ code. + */ + /* NOTE: This ought to work with other compilers too, but I'm being cautious */ #if (defined(__GNUC__) && defined(__APPLE__)) || defined(__MWERKS__) /* It's desirable to have type safety for Objective-C(++) code as it does diff --git a/src/cocoa/dc.mm b/src/cocoa/dc.mm index 7541eaf8c3..3726a8df86 100644 --- a/src/cocoa/dc.mm +++ b/src/cocoa/dc.mm @@ -43,7 +43,7 @@ wxCocoaDCStack wxDC::sm_cocoaDCStack; inline void CocoaSetPenForNSBezierPath(wxPen &pen, NSBezierPath *bezpath) { [pen.GetNSColor() set]; - const float *pattern; + const CGFloat *pattern; [bezpath setLineDash:pattern count:pen.GetCocoaLineDash(&pattern) phase:0.0]; [bezpath setLineWidth:pen.GetWidth()]; switch(pen.GetJoin()) diff --git a/src/cocoa/mdi.mm b/src/cocoa/mdi.mm index ef279856ca..63e1bfd0e0 100644 --- a/src/cocoa/mdi.mm +++ b/src/cocoa/mdi.mm @@ -232,10 +232,10 @@ void wxMDIParentFrame::WindowDidBecomeMain(NSNotification *notification) } if(!hashmap.empty()) { - int windowCount = 0; + NSInteger windowCount = 0; NSCountWindows(&windowCount); wxASSERT(windowCount>0); - int *windowList = new int[windowCount]; + NSInteger *windowList = new NSInteger[windowCount]; NSWindowList(windowCount, windowList); wxIntMDIChildFrameHashMap::iterator iter = hashmap.end(); for(int i=0; iGetNSColor() : nil); } -int wxPen::GetCocoaLineDash(const float **pattern) +int wxPen::GetCocoaLineDash(const CGFloat **pattern) { if(M_PENDATA) return M_PENDATA->GetCocoaLineDash(pattern); diff --git a/src/cocoa/window.mm b/src/cocoa/window.mm index 3343592ef3..2c09c9d0a3 100644 --- a/src/cocoa/window.mm +++ b/src/cocoa/window.mm @@ -39,6 +39,18 @@ #import #endif //def WXCOCOA_FILL_DUMMY_VIEW +/* NSComparisonResult is typedef'd as an enum pre-Leopard but typedef'd as + * NSInteger post-Leopard. Pre-Leopard the Cocoa toolkit expects a function + * returning int and not NSComparisonResult. Post-Leopard the Cocoa toolkit + * expects a function returning the new non-enum NSComparsionResult. + * Hence we create a typedef named CocoaWindowCompareFunctionResult. + */ +#if defined(NSINTEGER_DEFINED) +typedef NSComparisonResult CocoaWindowCompareFunctionResult; +#else +typedef int CocoaWindowCompareFunctionResult; +#endif + // A category for methods that are only present in Panther's SDK @interface NSView(wxNSViewPrePantherCompatibility) - (void)getRectsBeingDrawn:(const NSRect **)rects count:(int *)count; @@ -446,7 +458,7 @@ bool wxWindowCocoa::Cocoa_drawRect(const NSRect &rect) // Set m_updateRegion const NSRect *rects = ▭ // The bounding box of the region - int countRects = 1; + NSInteger countRects = 1; // Try replacing the larger rectangle with a list of smaller ones: if ([GetNSView() respondsToSelector:@selector(getRectsBeingDrawn:count:)]) [GetNSView() getRectsBeingDrawn:&rects count:&countRects]; @@ -951,7 +963,7 @@ bool wxWindow::SetFont(const wxFont& font) return true; } -static int CocoaRaiseWindowCompareFunction(id first, id second, void *target) +static CocoaWindowCompareFunctionResult CocoaRaiseWindowCompareFunction(id first, id second, void *target) { // first should be ordered higher if(first==target) @@ -972,7 +984,7 @@ void wxWindow::Raise() context: nsview]; } -static int CocoaLowerWindowCompareFunction(id first, id second, void *target) +static CocoaWindowCompareFunctionResult CocoaLowerWindowCompareFunction(id first, id second, void *target) { // first should be ordered lower if(first==target)