1 /////////////////////////////////////////////////////////////////////////////
8 // Copyright: (c) AUTHOR
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
13 #pragma implementation "brush.h"
20 #if !USE_SHARED_LIBRARIES
21 IMPLEMENT_DYNAMIC_CLASS(wxBrush
, wxGDIObject
)
24 wxBrushRefData::wxBrushRefData()
27 m_macBrushKind
= kwxMacBrushColour
;
30 wxBrushRefData::wxBrushRefData(const wxBrushRefData
& data
)
32 m_style
= data
.m_style
;
33 m_stipple
= data
.m_stipple
;
34 m_colour
= data
.m_colour
;
35 m_macBrushKind
= data
.m_macBrushKind
;
36 m_macThemeBrush
= data
.m_macThemeBrush
;
37 m_macThemeBackground
= data
.m_macThemeBackground
;
38 m_macThemeBackgroundExtent
= data
.m_macThemeBackgroundExtent
;
41 wxBrushRefData::~wxBrushRefData()
54 wxBrush::wxBrush(const wxColour
& col
, int Style
)
56 m_refData
= new wxBrushRefData
;
58 M_BRUSHDATA
->m_colour
= col
;
59 M_BRUSHDATA
->m_style
= Style
;
64 wxBrush::wxBrush(const wxBitmap
& stipple
)
66 m_refData
= new wxBrushRefData
;
68 M_BRUSHDATA
->m_colour
= *wxBLACK
;
69 M_BRUSHDATA
->m_stipple
= stipple
;
71 if (M_BRUSHDATA
->m_stipple
.GetMask())
72 M_BRUSHDATA
->m_style
= wxSTIPPLE_MASK_OPAQUE
;
74 M_BRUSHDATA
->m_style
= wxSTIPPLE
;
79 wxBrush::wxBrush(ThemeBrush macThemeBrush
)
81 m_refData
= new wxBrushRefData
;
83 M_BRUSHDATA
->m_macBrushKind
= kwxMacBrushTheme
;
84 M_BRUSHDATA
->m_macThemeBrush
= macThemeBrush
;
88 void wxBrush::Unshare()
90 // Don't change shared data
93 m_refData
= new wxBrushRefData();
97 wxBrushRefData
* ref
= new wxBrushRefData(*(wxBrushRefData
*)m_refData
);
103 void wxBrush::SetColour(const wxColour
& col
)
106 M_BRUSHDATA
->m_macBrushKind
= kwxMacBrushColour
;
107 M_BRUSHDATA
->m_colour
= col
;
112 void wxBrush::SetColour(unsigned char r
, unsigned char g
, unsigned char b
)
116 M_BRUSHDATA
->m_macBrushKind
= kwxMacBrushColour
;
117 M_BRUSHDATA
->m_colour
.Set(r
, g
, b
);
122 void wxBrush::SetStyle(int Style
)
126 M_BRUSHDATA
->m_macBrushKind
= kwxMacBrushColour
;
127 M_BRUSHDATA
->m_style
= Style
;
132 void wxBrush::SetStipple(const wxBitmap
& Stipple
)
136 M_BRUSHDATA
->m_macBrushKind
= kwxMacBrushColour
;
137 M_BRUSHDATA
->m_stipple
= Stipple
;
142 void wxBrush::SetMacTheme(ThemeBrush macThemeBrush
)
146 M_BRUSHDATA
->m_macBrushKind
= kwxMacBrushTheme
;
147 M_BRUSHDATA
->m_macThemeBrush
= macThemeBrush
;
152 void wxBrush::SetMacThemeBackground(ThemeBackgroundKind macThemeBackground
, const Rect
&extent
)
156 M_BRUSHDATA
->m_macBrushKind
= kwxMacBrushThemeBackground
;
157 M_BRUSHDATA
->m_macThemeBackground
= macThemeBackground
;
158 M_BRUSHDATA
->m_macThemeBackgroundExtent
= extent
;
162 bool wxBrush::RealizeResource()
167 ThemeBackgroundKind
wxBrush::GetMacThemeBackground(Rect
*extent
) const
169 if ( M_BRUSHDATA
&& M_BRUSHDATA
->m_macBrushKind
== kwxMacBrushThemeBackground
)
172 *extent
= M_BRUSHDATA
->m_macThemeBackgroundExtent
;
173 return M_BRUSHDATA
->m_macThemeBackground
;