1 /////////////////////////////////////////////////////////////////////////////
8 // Copyright: (c) AUTHOR
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
13 #pragma implementation "brush.h"
20 #include "wx/mac/private.h"
22 #if !USE_SHARED_LIBRARIES
23 IMPLEMENT_DYNAMIC_CLASS(wxBrush
, wxGDIObject
)
26 class WXDLLEXPORT wxBrushRefData
: public wxGDIRefData
28 friend class WXDLLEXPORT wxBrush
;
31 wxBrushRefData(const wxBrushRefData
& data
);
35 wxMacBrushKind m_macBrushKind
;
40 ThemeBrush m_macThemeBrush
;
42 ThemeBackgroundKind m_macThemeBackground
;
43 Rect m_macThemeBackgroundExtent
;
46 #define M_BRUSHDATA ((wxBrushRefData *)m_refData)
48 wxBrushRefData::wxBrushRefData()
51 m_macBrushKind
= kwxMacBrushColour
;
54 wxBrushRefData::wxBrushRefData(const wxBrushRefData
& data
)
56 m_style
= data
.m_style
;
57 m_stipple
= data
.m_stipple
;
58 m_colour
= data
.m_colour
;
59 m_macBrushKind
= data
.m_macBrushKind
;
60 m_macThemeBrush
= data
.m_macThemeBrush
;
61 m_macThemeBackground
= data
.m_macThemeBackground
;
62 m_macThemeBackgroundExtent
= data
.m_macThemeBackgroundExtent
;
65 wxBrushRefData::~wxBrushRefData()
78 wxBrush::wxBrush(const wxColour
& col
, int Style
)
80 m_refData
= new wxBrushRefData
;
82 M_BRUSHDATA
->m_colour
= col
;
83 M_BRUSHDATA
->m_style
= Style
;
88 wxBrush::wxBrush(const wxBitmap
& stipple
)
90 m_refData
= new wxBrushRefData
;
92 M_BRUSHDATA
->m_colour
= *wxBLACK
;
93 M_BRUSHDATA
->m_stipple
= stipple
;
95 if (M_BRUSHDATA
->m_stipple
.GetMask())
96 M_BRUSHDATA
->m_style
= wxSTIPPLE_MASK_OPAQUE
;
98 M_BRUSHDATA
->m_style
= wxSTIPPLE
;
103 wxBrush::wxBrush(ThemeBrush macThemeBrush
)
105 m_refData
= new wxBrushRefData
;
107 M_BRUSHDATA
->m_macBrushKind
= kwxMacBrushTheme
;
108 M_BRUSHDATA
->m_macThemeBrush
= macThemeBrush
;
112 void wxBrush::Unshare()
114 // Don't change shared data
117 m_refData
= new wxBrushRefData();
121 wxBrushRefData
* ref
= new wxBrushRefData(*(wxBrushRefData
*)m_refData
);
127 void wxBrush::SetColour(const wxColour
& col
)
130 M_BRUSHDATA
->m_macBrushKind
= kwxMacBrushColour
;
131 M_BRUSHDATA
->m_colour
= col
;
136 void wxBrush::SetColour(unsigned char r
, unsigned char g
, unsigned char b
)
140 M_BRUSHDATA
->m_macBrushKind
= kwxMacBrushColour
;
141 M_BRUSHDATA
->m_colour
.Set(r
, g
, b
);
146 void wxBrush::SetStyle(int Style
)
150 M_BRUSHDATA
->m_macBrushKind
= kwxMacBrushColour
;
151 M_BRUSHDATA
->m_style
= Style
;
156 void wxBrush::SetStipple(const wxBitmap
& Stipple
)
160 M_BRUSHDATA
->m_macBrushKind
= kwxMacBrushColour
;
161 M_BRUSHDATA
->m_stipple
= Stipple
;
166 void wxBrush::SetMacTheme(ThemeBrush macThemeBrush
)
170 M_BRUSHDATA
->m_macBrushKind
= kwxMacBrushTheme
;
171 M_BRUSHDATA
->m_macThemeBrush
= macThemeBrush
;
176 void wxBrush::SetMacThemeBackground(unsigned long macThemeBackground
, const WXRECTPTR extent
)
180 M_BRUSHDATA
->m_macBrushKind
= kwxMacBrushThemeBackground
;
181 M_BRUSHDATA
->m_macThemeBackground
= macThemeBackground
;
182 M_BRUSHDATA
->m_macThemeBackgroundExtent
= *(Rect
*)extent
;
186 bool wxBrush::RealizeResource()
191 unsigned long wxBrush::GetMacThemeBackground( WXRECTPTR extent
) const
193 if ( M_BRUSHDATA
&& M_BRUSHDATA
->m_macBrushKind
== kwxMacBrushThemeBackground
)
196 *(Rect
*)extent
= M_BRUSHDATA
->m_macThemeBackgroundExtent
;
197 return M_BRUSHDATA
->m_macThemeBackground
;
205 short wxBrush::GetMacTheme() const
207 return (M_BRUSHDATA
? ( M_BRUSHDATA
->m_macBrushKind
== kwxMacBrushTheme
? M_BRUSHDATA
->m_macThemeBrush
: kThemeBrushBlack
) : kThemeBrushBlack
);
210 wxColour
& wxBrush::GetColour() const
211 { return (M_BRUSHDATA
? M_BRUSHDATA
->m_colour
: wxNullColour
); };
213 int wxBrush::GetStyle() const
215 return (M_BRUSHDATA
? M_BRUSHDATA
->m_style
: 0);
218 wxBitmap
*wxBrush::GetStipple() const
220 return (M_BRUSHDATA
? & M_BRUSHDATA
->m_stipple
: 0);
223 wxMacBrushKind
wxBrush::MacGetBrushKind() const
225 return (M_BRUSHDATA
? M_BRUSHDATA
->m_macBrushKind
: kwxMacBrushColour
);