X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/f8855e47254a28f5141524b3aaaac03c2944e997..b7d3a622aa58729f92941c2b6710c5481b16f19e:/src/mgl/brush.cpp?ds=sidebyside diff --git a/src/mgl/brush.cpp b/src/mgl/brush.cpp index 039d7ef4f5..a00c6ec8b6 100644 --- a/src/mgl/brush.cpp +++ b/src/mgl/brush.cpp @@ -16,7 +16,7 @@ #include "wx/brush.h" #include "wx/mgl/private.h" -#include "wx/mgl/dcmemory.h" +#include "wx/dcmemory.h" // --------------------------------------------------------------------------- @@ -35,7 +35,7 @@ void wxBitmapToPixPattern(const wxBitmap& bitmap, if ( pix != NULL ) { - mem.SelectObject(bitmap); + mem.SelectObjectAsSource(bitmap); dc = mem.GetMGLDC(); wxCurrentDCSwitcher curDC(dc); dc->beginPixel(); @@ -50,7 +50,7 @@ void wxBitmapToPixPattern(const wxBitmap& bitmap, if ( mask && bitmap.GetMask() ) { - mem.SelectObject(*bitmap.GetMask()->GetBitmap()); + mem.SelectObjectAsSource(bitmap.GetMask()->GetBitmap()); dc = mem.GetMGLDC(); wxCurrentDCSwitcher curDC(dc); dc->beginPixel(); @@ -70,13 +70,22 @@ void wxBitmapToPixPattern(const wxBitmap& bitmap, // wxBrush //----------------------------------------------------------------------------- -class wxBrushRefData: public wxObjectRefData +class wxBrushRefData : public wxGDIRefData { public: wxBrushRefData(); wxBrushRefData(const wxBrushRefData& data); - int m_style; + virtual bool IsOk() const { return m_colour.IsOk(); } + + bool operator==(const wxBrushRefData& data) const + { + return (m_style == data.m_style && + m_stipple.IsSameAs(data.m_stipple) && + m_colour == data.m_colour); + } + + wxBrushStyle m_style; wxColour m_colour; wxBitmap m_stipple; pixpattern24_t m_pixPattern; @@ -117,18 +126,27 @@ wxBrushRefData::wxBrushRefData(const wxBrushRefData& data) IMPLEMENT_DYNAMIC_CLASS(wxBrush,wxGDIObject) -wxBrush::wxBrush(const wxColour &colour, int style) +wxBrush::wxBrush(const wxColour &colour, wxBrushStyle style) { m_refData = new wxBrushRefData(); M_BRUSHDATA->m_style = style; M_BRUSHDATA->m_colour = colour; } +#if FUTURE_WXWIN_COMPATIBILITY_3_0 +wxBrush::wxBrush(const wxColour& col, int style) +{ + m_refData = new wxBrushRefData; + M_BRUSHDATA->m_style = (wxBrushStyle)style; + M_BRUSHDATA->m_colour = colour; +} +#endif + wxBrush::wxBrush(const wxBitmap &stippleBitmap) { - wxCHECK_RET( stippleBitmap.Ok(), _T("invalid bitmap") ); + wxCHECK_RET( stippleBitmap.IsOk(), wxT("invalid bitmap") ); wxCHECK_RET( stippleBitmap.GetWidth() == 8 && stippleBitmap.GetHeight() == 8, - _T("stipple bitmap must be 8x8") ); + wxT("stipple bitmap must be 8x8") ); m_refData = new wxBrushRefData(); M_BRUSHDATA->m_colour = *wxBLACK; @@ -145,7 +163,11 @@ wxBrush::wxBrush(const wxBitmap &stippleBitmap) bool wxBrush::operator == (const wxBrush& brush) const { - return m_refData == brush.m_refData; + if (m_refData == brush.m_refData) return true; + + if (!m_refData || !brush.m_refData) return false; + + return *(wxBrushRefData*)m_refData == *(wxBrushRefData*)brush.m_refData; } bool wxBrush::operator != (const wxBrush& brush) const @@ -153,54 +175,37 @@ bool wxBrush::operator != (const wxBrush& brush) const return m_refData != brush.m_refData; } -bool wxBrush::Ok() const +wxBrushStyle wxBrush::GetStyle() const { - return ((m_refData) && M_BRUSHDATA->m_colour.Ok()); -} - -int wxBrush::GetStyle() const -{ - if (m_refData == NULL) - { - wxFAIL_MSG( wxT("invalid brush") ); - return 0; - } + wxCHECK_MSG( IsOk(), wxBRUSHSTYLE_INVALID, wxT("invalid brush") ); return M_BRUSHDATA->m_style; } -wxColour &wxBrush::GetColour() const +wxColour wxBrush::GetColour() const { - if (m_refData == NULL) - { - wxFAIL_MSG( wxT("invalid brush") ); - return wxNullColour; - } + wxCHECK_MSG( IsOk(), wxNullColour, wxT("invalid brush") ); return M_BRUSHDATA->m_colour; } wxBitmap *wxBrush::GetStipple() const { - if (m_refData == NULL) - { - wxFAIL_MSG( wxT("invalid brush") ); - return &wxNullBitmap; - } + wxCHECK_MSG( IsOk(), NULL, wxT("invalid brush") ); return &M_BRUSHDATA->m_stipple; } void* wxBrush::GetMaskPattern() const { - wxCHECK_MSG( Ok(), NULL, wxT("invalid brush") ); + wxCHECK_MSG( IsOk(), NULL, wxT("invalid brush") ); return (void*)&(M_BRUSHDATA->m_maskPattern); } void* wxBrush::GetPixPattern() const { - wxCHECK_MSG( Ok(), NULL, wxT("invalid brush") ); + wxCHECK_MSG( IsOk(), NULL, wxT("invalid brush") ); return (void*)&(M_BRUSHDATA->m_pixPattern); } @@ -217,7 +222,7 @@ void wxBrush::SetColour(unsigned char r, unsigned char g, unsigned char b) M_BRUSHDATA->m_colour.Set(r, g, b); } -void wxBrush::SetStyle( int style ) +void wxBrush::SetStyle( wxBrushStyle style ) { AllocExclusive(); M_BRUSHDATA->m_style = style; @@ -227,9 +232,9 @@ void wxBrush::SetStipple(const wxBitmap& stipple) { AllocExclusive(); - wxCHECK_RET( stipple.Ok(), _T("invalid bitmap") ); + wxCHECK_RET( stipple.IsOk(), wxT("invalid bitmap") ); wxCHECK_RET( stipple.GetWidth() == 8 && stipple.GetHeight() == 8, - _T("stipple bitmap must be 8x8") ); + wxT("stipple bitmap must be 8x8") ); M_BRUSHDATA->m_stipple = stipple; wxBitmapToPixPattern(stipple, &(M_BRUSHDATA->m_pixPattern), @@ -241,12 +246,12 @@ void wxBrush::SetStipple(const wxBitmap& stipple) M_BRUSHDATA->m_style = wxSTIPPLE; } -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); }