X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/6631a2a562fc35a0faf639ed287ea801fcef1176..fb8d7eb7a880f1f2e32d8830f9c5e12b2536e05f:/src/cocoa/brush.mm diff --git a/src/cocoa/brush.mm b/src/cocoa/brush.mm index 753c947cea..2a75f403f9 100644 --- a/src/cocoa/brush.mm +++ b/src/cocoa/brush.mm @@ -6,20 +6,25 @@ // Created: 2003/07/03 // RCS-ID: $Id$ // Copyright: (c) 2003 David Elliott -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// -#include "wx/setup.h" -#include "wx/utils.h" +#include "wx/wxprec.h" + #include "wx/brush.h" -#include "wx/colour.h" + +#ifndef WX_PRECOMP + #include "wx/utils.h" + #include "wx/colour.h" +#endif //WX_PRECOMP #import class WXDLLEXPORT wxBrushRefData: public wxGDIRefData { public: - wxBrushRefData(const wxColour& colour = wxNullColour, int style = wxSOLID); + wxBrushRefData(const wxColour& colour = wxNullColour, + wxBrushStyle style = wxBRUSHSTYLE_SOLID); wxBrushRefData(const wxBitmap& stipple); wxBrushRefData(const wxBrushRefData& data); virtual ~wxBrushRefData(); @@ -31,18 +36,18 @@ public: // accessors const wxColour& GetColour() const { return m_colour; } - int GetStyle() const { return m_style; } + wxBrushStyle GetStyle() const { return m_style; } wxBitmap *GetStipple() { return &m_stipple; } void SetColour(const wxColour& colour) { Free(); m_colour = colour; } - void SetStyle(int style) { Free(); m_style = style; } + void SetStyle(wxBrushStyle style) { Free(); m_style = style; } void SetStipple(const wxBitmap& stipple) { Free(); DoSetStipple(stipple); } private: void DoSetStipple(const wxBitmap& stipple); WX_NSColor m_cocoaNSColor; - int m_style; + wxBrushStyle m_style; wxBitmap m_stipple; wxColour m_colour; @@ -54,7 +59,7 @@ private: #define M_BRUSHDATA ((wxBrushRefData *)m_refData) IMPLEMENT_DYNAMIC_CLASS(wxBrush, wxGDIObject) -wxBrushRefData::wxBrushRefData(const wxColour& colour, int style) +wxBrushRefData::wxBrushRefData(const wxColour& colour, wxBrushStyle style) { m_cocoaNSColor = NULL; m_style = style; @@ -92,13 +97,14 @@ bool wxBrushRefData::operator==(const wxBrushRefData& data) const // don't compare our NSColor return m_style == data.m_style && m_colour == data.m_colour && - m_stipple == data.m_stipple; + m_stipple.IsSameAs(data.m_stipple); } void wxBrushRefData::DoSetStipple(const wxBitmap& stipple) { m_stipple = stipple; - m_style = stipple.GetMask() ? wxSTIPPLE_MASK_OPAQUE : wxSTIPPLE; + m_style = stipple.GetMask() ? wxBRUSHSTYLE_STIPPLE_MASK_OPAQUE + : wxBRUSHSTYLE_STIPPLE; } WX_NSColor wxBrushRefData::GetNSColor() @@ -139,29 +145,33 @@ WX_NSColor wxBrushRefData::GetNSColor() // Brushes wxBrush::wxBrush() { - m_refData = new wxBrushRefData; } wxBrush::~wxBrush() { } -wxBrush::wxBrush(const wxColour& col, int style) +wxBrush::wxBrush(const wxColour& col, wxBrushStyle style) { m_refData = new wxBrushRefData(col, style); } +wxBrush::wxBrush(const wxColour& col, int style) +{ + m_refData = new wxBrushRefData(col, (wxBrushStyle)style); +} + wxBrush::wxBrush(const wxBitmap& stipple) { m_refData = new wxBrushRefData(stipple); } -wxObjectRefData *wxBrush::CreateRefData() const +wxGDIRefData *wxBrush::CreateGDIRefData() const { return new wxBrushRefData; } -wxObjectRefData *wxBrush::CloneRefData(const wxObjectRefData *data) const +wxGDIRefData *wxBrush::CloneGDIRefData(const wxGDIRefData *data) const { return new wxBrushRefData(*(wxBrushRefData *)data); } @@ -178,7 +188,7 @@ void wxBrush::SetColour(unsigned char r, unsigned char g, unsigned char b) M_BRUSHDATA->SetColour(wxColour(r,g,b)); } -void wxBrush::SetStyle(int style) +void wxBrush::SetStyle(wxBrushStyle style) { AllocExclusive(); M_BRUSHDATA->SetStyle(style); @@ -192,25 +202,25 @@ void wxBrush::SetStipple(const wxBitmap& stipple) wxColour wxBrush::GetColour() const { - wxCHECK_MSG( Ok(), wxNullColour, _T("invalid brush") ); + wxCHECK_MSG( IsOk(), wxNullColour, wxT("invalid brush") ); return M_BRUSHDATA->GetColour(); } -int wxBrush::GetStyle() const +wxBrushStyle wxBrush::GetStyle() const { - wxCHECK_MSG( Ok(), 0, _T("invalid brush") ); + wxCHECK_MSG( IsOk(), wxBRUSHSTYLE_INVALID, wxT("invalid brush") ); return M_BRUSHDATA->GetStyle(); } wxBitmap *wxBrush::GetStipple() const { - wxCHECK_MSG( Ok(), 0, _T("invalid brush") ); + wxCHECK_MSG( IsOk(), 0, wxT("invalid brush") ); return M_BRUSHDATA->GetStipple(); } WX_NSColor wxBrush::GetNSColor() { - wxCHECK_MSG( Ok(), NULL, _T("invalid brush") ); + if(!m_refData) + return [NSColor clearColor]; return M_BRUSHDATA->GetNSColor(); } -