]>
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
, int style
= wxSOLID
)
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(int 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
, int style
)
69 m_refData
= new wxBrushRefData(colour
, style
);
72 wxBrush::wxBrush(const wxBitmap
&stippleBitmap
)
74 wxFAIL_MSG( wxT("brushes with stipple bitmaps not implemented") );
76 m_refData
= new wxBrushRefData(*wxBLACK
);
79 bool wxBrush::operator==(const wxBrush
& brush
) const
81 #warning "this is incorrect (MGL too)"
82 return m_refData
== brush
.m_refData
;
85 int wxBrush::GetStyle() const
87 if (m_refData
== NULL
)
89 wxFAIL_MSG( wxT("invalid brush") );
93 return M_BRUSHDATA
->m_style
;
96 wxColour
& wxBrush::GetColour() const
98 if (m_refData
== NULL
)
100 wxFAIL_MSG( wxT("invalid brush") );
104 return M_BRUSHDATA
->m_colour
;
107 wxBitmap
*wxBrush::GetStipple() const
109 wxFAIL_MSG( wxT("brushes with stipple bitmaps not implemented") );
110 return &wxNullBitmap
;
113 void wxBrush::SetColour(const wxColour
& col
)
116 M_BRUSHDATA
->m_colour
= col
;
119 void wxBrush::SetColour(unsigned char r
, unsigned char g
, unsigned char b
)
122 M_BRUSHDATA
->m_colour
.Set(r
, g
, b
);
125 void wxBrush::SetStyle(int style
)
128 M_BRUSHDATA
->SetStyle(style
);
131 void wxBrush::SetStipple(const wxBitmap
& WXUNUSED(stipple
))
133 wxFAIL_MSG( wxT("brushes with stipple bitmaps not implemented") );
136 wxGDIRefData
*wxBrush::CreateGDIRefData() const
138 return new wxBrushRefData
;
141 wxGDIRefData
*wxBrush::CloneGDIRefData(const wxGDIRefData
*data
) const
143 return new wxBrushRefData(*(wxBrushRefData
*)data
);