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_style
= wxSTIPPLE
;
69 M_BRUSHDATA
->m_stipple
= stipple
;
74 wxBrush::wxBrush(ThemeBrush macThemeBrush
)
76 m_refData
= new wxBrushRefData
;
78 M_BRUSHDATA
->m_macBrushKind
= kwxMacBrushTheme
;
79 M_BRUSHDATA
->m_macThemeBrush
= macThemeBrush
;
83 void wxBrush::Unshare()
85 // Don't change shared data
88 m_refData
= new wxBrushRefData();
92 wxBrushRefData
* ref
= new wxBrushRefData(*(wxBrushRefData
*)m_refData
);
98 void wxBrush::SetColour(const wxColour
& col
)
101 M_BRUSHDATA
->m_macBrushKind
= kwxMacBrushColour
;
102 M_BRUSHDATA
->m_colour
= col
;
107 void wxBrush::SetColour(unsigned char r
, unsigned char g
, unsigned char b
)
111 M_BRUSHDATA
->m_macBrushKind
= kwxMacBrushColour
;
112 M_BRUSHDATA
->m_colour
.Set(r
, g
, b
);
117 void wxBrush::SetStyle(int Style
)
121 M_BRUSHDATA
->m_macBrushKind
= kwxMacBrushColour
;
122 M_BRUSHDATA
->m_style
= Style
;
127 void wxBrush::SetStipple(const wxBitmap
& Stipple
)
131 M_BRUSHDATA
->m_macBrushKind
= kwxMacBrushColour
;
132 M_BRUSHDATA
->m_stipple
= Stipple
;
137 void wxBrush::SetMacTheme(ThemeBrush macThemeBrush
)
141 M_BRUSHDATA
->m_macBrushKind
= kwxMacBrushTheme
;
142 M_BRUSHDATA
->m_macThemeBrush
= macThemeBrush
;
147 void wxBrush::SetMacThemeBackground(ThemeBackgroundKind macThemeBackground
, const Rect
&extent
)
151 M_BRUSHDATA
->m_macBrushKind
= kwxMacBrushThemeBackground
;
152 M_BRUSHDATA
->m_macThemeBackground
= macThemeBackground
;
153 M_BRUSHDATA
->m_macThemeBackgroundExtent
= extent
;
157 bool wxBrush::RealizeResource()
162 ThemeBackgroundKind
wxBrush::GetMacThemeBackground(Rect
*extent
) const
164 if ( M_BRUSHDATA
&& M_BRUSHDATA
->m_macBrushKind
== kwxMacBrushThemeBackground
)
167 *extent
= M_BRUSHDATA
->m_macThemeBackgroundExtent
;
168 return M_BRUSHDATA
->m_macThemeBackground
;