]>
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
6 // Copyright: (c) 2006 REA Elektronik GmbH
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
10 // For compilers that support precompilation, includes "wx.h".
11 #include "wx/wxprec.h"
20 #include "wx/colour.h"
24 //-----------------------------------------------------------------------------
26 //-----------------------------------------------------------------------------
28 class wxBrushRefData
: public wxGDIRefData
31 wxBrushRefData(const wxColour
& clr
= wxNullColour
, wxBrushStyle style
= wxBRUSHSTYLE_SOLID
)
37 wxBrushRefData(const wxBrushRefData
& data
)
39 m_colour
= data
.m_colour
;
40 m_style
= data
.m_style
;
43 virtual bool IsOk() const { return m_colour
.IsOk(); }
45 void SetStyle(wxBrushStyle style
)
47 if ( style
!= wxSOLID
&& style
!= wxTRANSPARENT
)
49 wxFAIL_MSG( wxT("only wxSOLID and wxTRANSPARENT styles are supported") );
50 style
= wxBRUSHSTYLE_SOLID
;
60 //-----------------------------------------------------------------------------
62 #define M_BRUSHDATA ((wxBrushRefData *)m_refData)
64 IMPLEMENT_DYNAMIC_CLASS(wxBrush
, wxGDIObject
)
66 wxBrush::wxBrush(const wxColour
&colour
, wxBrushStyle style
)
68 m_refData
= new wxBrushRefData(colour
, style
);
71 #if FUTURE_WXWIN_COMPATIBILITY_3_0
72 wxBrush::wxBrush(const wxColour
& col
, int style
)
74 m_refData
= new wxBrushRefData(col
, (wxBrushStyle
)style
);
78 wxBrush::wxBrush(const wxBitmap
&stippleBitmap
)
80 wxFAIL_MSG( wxT("brushes with stipple bitmaps not implemented") );
82 m_refData
= new wxBrushRefData(*wxBLACK
);
85 bool wxBrush::operator==(const wxBrush
& brush
) const
87 #warning "this is incorrect"
88 return m_refData
== brush
.m_refData
;
91 wxBrushStyle
wxBrush::GetStyle() const
93 wxCHECK_MSG( IsOk(), wxBRUSHSTYLE_INVALID
, wxT("invalid brush") );
95 return M_BRUSHDATA
->m_style
;
98 wxColour
wxBrush::GetColour() const
100 wxCHECK_MSG( IsOk(), wxNullColour
, wxT("invalid brush") );
102 return M_BRUSHDATA
->m_colour
;
105 wxBitmap
*wxBrush::GetStipple() const
107 wxFAIL_MSG( wxT("brushes with stipple bitmaps not implemented") );
108 return &wxNullBitmap
;
111 void wxBrush::SetColour(const wxColour
& col
)
114 M_BRUSHDATA
->m_colour
= col
;
117 void wxBrush::SetColour(unsigned char r
, unsigned char g
, unsigned char b
)
120 M_BRUSHDATA
->m_colour
.Set(r
, g
, b
);
123 void wxBrush::SetStyle(wxBrushStyle style
)
126 M_BRUSHDATA
->SetStyle(style
);
129 void wxBrush::SetStipple(const wxBitmap
& WXUNUSED(stipple
))
131 wxFAIL_MSG( wxT("brushes with stipple bitmaps not implemented") );
134 wxGDIRefData
*wxBrush::CreateGDIRefData() const
136 return new wxBrushRefData
;
139 wxGDIRefData
*wxBrush::CloneGDIRefData(const wxGDIRefData
*data
) const
141 return new wxBrushRefData(*(wxBrushRefData
*)data
);