X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/0bca03736369e836cce9297509505c5972e775dd..a766986f6d443ba1d50e3af25f3306fa56e4518e:/src/cocoa/pen.mm?ds=inline diff --git a/src/cocoa/pen.mm b/src/cocoa/pen.mm index 6ebb658ccd..d94b138c1a 100644 --- a/src/cocoa/pen.mm +++ b/src/cocoa/pen.mm @@ -14,9 +14,10 @@ #ifndef WX_PRECOMP #include "wx/pen.h" #include "wx/bitmap.h" + #include "wx/colour.h" #endif //WX_PRECOMP -#include "wx/colour.h" +#include "wx/cocoa/ObjcRef.h" #import @@ -25,7 +26,6 @@ // ======================================================================== class WXDLLEXPORT wxPenRefData: public wxGDIRefData { - friend class WXDLLEXPORT wxPen; public: wxPenRefData(const wxColour& colour = wxNullColour, int width = 1, int style = wxSOLID, @@ -55,7 +55,7 @@ public: m_style = wxSTIPPLE; } WX_NSColor GetNSColor(); - int GetCocoaLineDash(const float **pattern); + int GetCocoaLineDash(const CGFloat **pattern); protected: void FreeCocoaNSColor(); void FreeCocoaDash(); @@ -69,36 +69,39 @@ protected: 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[]; + + friend class WXDLLIMPEXP_FWD_CORE wxPen; + 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 @@ -132,13 +135,13 @@ inline wxPenRefData::wxPenRefData(const wxPenRefData& data) m_nbDash = data.m_nbDash; m_dash = data.m_dash; m_stipple = data.m_stipple; - m_cocoaNSColor = [data.m_cocoaNSColor retain]; + m_cocoaNSColor = wxGCSafeRetain(data.m_cocoaNSColor); m_cocoaDash = NULL; } inline void wxPenRefData::FreeCocoaNSColor() { - [m_cocoaNSColor release]; + wxGCSafeRelease(m_cocoaNSColor); m_cocoaNSColor = nil; } @@ -155,7 +158,7 @@ inline WX_NSColor wxPenRefData::GetNSColor() switch( m_style ) { case wxTRANSPARENT: - m_cocoaNSColor = [[NSColor clearColor] retain]; + m_cocoaNSColor = wxGCSafeRetain([NSColor clearColor]); break; case wxSTIPPLE: // wxBitmap isn't implemented yet @@ -180,13 +183,14 @@ inline WX_NSColor wxPenRefData::GetNSColor() if(!colour_NSColor) colour_NSColor = [NSColor clearColor]; m_cocoaNSColor = [colour_NSColor copyWithZone:nil]; + [wxGCSafeRetain(m_cocoaNSColor) release]; // retain in GC. no change in RR. break; } } return m_cocoaNSColor; } -int wxPenRefData::GetCocoaLineDash(const float **pattern) +int wxPenRefData::GetCocoaLineDash(const CGFloat **pattern) { int count; switch( m_style ) @@ -217,7 +221,7 @@ int wxPenRefData::GetCocoaLineDash(const float **pattern) { if(!m_cocoaDash) { - m_cocoaDash = new float[count]; + m_cocoaDash = new CGFloat[count]; 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);