#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);
wxBitmap *GetStipple() const;
WX_NSColor GetNSColor();
- int GetCocoaLineDash(const float **pattern);
+ int GetCocoaLineDash(const CGFloat **pattern);
};
#endif // __WX_COCOA_PEN_H__
#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
{
// ========================================================================
// 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
#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
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())
}
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; i<windowCount && iter == hashmap.end(); i++)
m_style = wxSTIPPLE;
}
WX_NSColor GetNSColor();
- int GetCocoaLineDash(const float **pattern);
+ int GetCocoaLineDash(const CGFloat **pattern);
protected:
void FreeCocoaNSColor();
void FreeCocoaDash();
wxDash *m_dash;
wxBitmap m_stipple;
WX_NSColor m_cocoaNSColor;
- float *m_cocoaDash;
+ CGFloat *m_cocoaDash;
// Predefined dash patterns
static const int scm_countDot;
- static const float scm_patternDot[];
+ static const CGFloat scm_patternDot[];
static const int scm_countLongDash;
- static const float scm_patternLongDash[];
+ static const CGFloat scm_patternLongDash[];
static const int scm_countShortDash;
- static const float scm_patternShortDash[];
+ static const CGFloat scm_patternShortDash[];
static const int scm_countDotDash;
- static const float scm_patternDotDash[];
+ static const CGFloat scm_patternDotDash[];
private:
// Don't allow assignment
wxPenRefData& operator=(const wxPenRefData& data);
};
const int wxPenRefData::scm_countDot = 1;
-const float wxPenRefData::scm_patternDot[] = {
+const CGFloat wxPenRefData::scm_patternDot[] = {
1.0
};
const int wxPenRefData::scm_countLongDash = 1;
-const float wxPenRefData::scm_patternLongDash[] = {
+const CGFloat wxPenRefData::scm_patternLongDash[] = {
10.0
};
const int wxPenRefData::scm_countShortDash = 1;
-const float wxPenRefData::scm_patternShortDash[] = {
+const CGFloat wxPenRefData::scm_patternShortDash[] = {
5.0
};
const int wxPenRefData::scm_countDotDash = 4;
-const float wxPenRefData::scm_patternDotDash[] = {
+const CGFloat wxPenRefData::scm_patternDotDash[] = {
1.0
, 1.0
, 5.0
return m_cocoaNSColor;
}
-int wxPenRefData::GetCocoaLineDash(const float **pattern)
+int wxPenRefData::GetCocoaLineDash(const CGFloat **pattern)
{
int count;
switch( m_style )
{
if(!m_cocoaDash)
{
- m_cocoaDash = new float[count];
+ m_cocoaDash = new CGFloat[count];
for(int i=0; i<count; i++)
m_cocoaDash[i] = m_dash[i];
}
return (M_PENDATA ? M_PENDATA->GetNSColor() : nil);
}
-int wxPen::GetCocoaLineDash(const float **pattern)
+int wxPen::GetCocoaLineDash(const CGFloat **pattern)
{
if(M_PENDATA)
return M_PENDATA->GetCocoaLineDash(pattern);
#import <AppKit/NSBezierPath.h>
#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;
// 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];
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)
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)