]>
git.saurik.com Git - wxWidgets.git/blob - src/dfb/brush.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/dfb/brush.cpp
3 // Purpose: wxBrush class implementation
4 // Author: Vaclav Slavik
7 // Copyright: (c) 2006 REA Elektronik GmbH
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
11 // For compilers that support precompilation, includes "wx.h".
12 #include "wx/wxprec.h"
21 #include "wx/colour.h"
25 //-----------------------------------------------------------------------------
27 //-----------------------------------------------------------------------------
29 class wxBrushRefData
: public wxGDIRefData
32 wxBrushRefData(const wxColour
& clr
= wxNullColour
, wxBrushStyle style
= wxBRUSHSTYLE_SOLID
)
38 wxBrushRefData(const wxBrushRefData
& data
)
40 m_colour
= data
.m_colour
;
41 m_style
= data
.m_style
;
44 virtual bool IsOk() const { return m_colour
.IsOk(); }
46 void SetStyle(wxBrushStyle style
)
48 if ( style
!= wxSOLID
&& style
!= wxTRANSPARENT
)
50 wxFAIL_MSG( wxT("only wxSOLID and wxTRANSPARENT styles are supported") );
61 //-----------------------------------------------------------------------------
63 #define M_BRUSHDATA ((wxBrushRefData *)m_refData)
65 IMPLEMENT_DYNAMIC_CLASS(wxBrush
, wxGDIObject
)
67 wxBrush::wxBrush(const wxColour
&colour
, wxBrushStyle style
)
69 m_refData
= new wxBrushRefData(colour
, style
);
72 #if FUTURE_WXWIN_COMPATIBILITY_3_0
73 wxBrush::wxBrush(const wxColour
& col
, int style
)
75 m_refData
= new wxBrushRefData(col
, (wxBrushStyle
)style
);
79 wxBrush::wxBrush(const wxBitmap
&stippleBitmap
)
81 wxFAIL_MSG( wxT("brushes with stipple bitmaps not implemented") );
83 m_refData
= new wxBrushRefData(*wxBLACK
);
86 bool wxBrush::operator==(const wxBrush
& brush
) const
88 #warning "this is incorrect (MGL too)"
89 return m_refData
== brush
.m_refData
;
92 wxBrushStyle
wxBrush::GetStyle() const
94 wxCHECK_MSG( Ok(), wxBRUSHSTYLE_INVALID
, _T("invalid brush") );
96 return M_BRUSHDATA
->m_style
;
99 wxColour
wxBrush::GetColour() const
101 wxCHECK_MSG( Ok(), wxNullColour
, _T("invalid brush") );
103 return M_BRUSHDATA
->m_colour
;
106 wxBitmap
*wxBrush::GetStipple() const
108 wxFAIL_MSG( wxT("brushes with stipple bitmaps not implemented") );
109 return &wxNullBitmap
;
112 void wxBrush::SetColour(const wxColour
& col
)
115 M_BRUSHDATA
->m_colour
= col
;
118 void wxBrush::SetColour(unsigned char r
, unsigned char g
, unsigned char b
)
121 M_BRUSHDATA
->m_colour
.Set(r
, g
, b
);
124 void wxBrush::SetStyle(wxBrushStyle style
)
127 M_BRUSHDATA
->SetStyle(style
);
130 void wxBrush::SetStipple(const wxBitmap
& WXUNUSED(stipple
))
132 wxFAIL_MSG( wxT("brushes with stipple bitmaps not implemented") );
135 wxGDIRefData
*wxBrush::CreateGDIRefData() const
137 return new wxBrushRefData
;
140 wxGDIRefData
*wxBrush::CloneGDIRefData(const wxGDIRefData
*data
) const
142 return new wxBrushRefData(*(wxBrushRefData
*)data
);