From: David Elliott Date: Fri, 6 Jul 2007 00:18:28 +0000 (+0000) Subject: Make wxCocoa compile in 64-bit mode. X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/4799f3baab3805e51cc1754b89d855d32e94c232?hp=f762ea32ed128e1ed5dc48002311cab67b7837d2 Make wxCocoa compile in 64-bit mode. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@47182 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/include/wx/cocoa/NSView.h b/include/wx/cocoa/NSView.h index e59dfdbbd2..39e64fe529 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 09ca34917b..e045df6523 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 b3ae230a05..1ffef246f7 100644 --- a/include/wx/defs.h +++ b/include/wx/defs.h @@ -2522,6 +2522,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 375bf3a3dd..832b6ba726 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 83874d9ad0..caca70f317 100644 --- a/src/cocoa/window.mm +++ b/src/cocoa/window.mm @@ -41,6 +41,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; @@ -458,7 +470,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]; @@ -1011,7 +1023,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) @@ -1032,7 +1044,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)