1 /////////////////////////////////////////////////////////////////////////////
4 // Author: Stefan Csomor
8 // Copyright: (c) Stefan Csomor
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
)
58 m_stipple
= data
.m_stipple
;
59 m_colour
= data
.m_colour
;
60 m_macBrushKind
= data
.m_macBrushKind
;
61 m_macThemeBrush
= data
.m_macThemeBrush
;
62 m_macThemeBackground
= data
.m_macThemeBackground
;
63 m_macThemeBackgroundExtent
= data
.m_macThemeBackgroundExtent
;
66 wxBrushRefData::~wxBrushRefData()
79 wxBrush::wxBrush(const wxColour
& col
, int Style
)
81 m_refData
= new wxBrushRefData
;
83 M_BRUSHDATA
->m_colour
= col
;
84 M_BRUSHDATA
->m_style
= Style
;
89 wxBrush::wxBrush(const wxBitmap
& stipple
)
91 m_refData
= new wxBrushRefData
;
93 M_BRUSHDATA
->m_colour
= *wxBLACK
;
94 M_BRUSHDATA
->m_stipple
= stipple
;
96 if (M_BRUSHDATA
->m_stipple
.GetMask())
97 M_BRUSHDATA
->m_style
= wxSTIPPLE_MASK_OPAQUE
;
99 M_BRUSHDATA
->m_style
= wxSTIPPLE
;
104 wxBrush::wxBrush(ThemeBrush macThemeBrush
)
106 m_refData
= new wxBrushRefData
;
108 M_BRUSHDATA
->m_macBrushKind
= kwxMacBrushTheme
;
109 M_BRUSHDATA
->m_macThemeBrush
= macThemeBrush
;
113 void wxBrush::Unshare()
115 // Don't change shared data
118 m_refData
= new wxBrushRefData();
122 wxBrushRefData
* ref
= new wxBrushRefData(*(wxBrushRefData
*)m_refData
);
128 void wxBrush::SetColour(const wxColour
& col
)
131 M_BRUSHDATA
->m_macBrushKind
= kwxMacBrushColour
;
132 M_BRUSHDATA
->m_colour
= col
;
137 void wxBrush::SetColour(unsigned char r
, unsigned char g
, unsigned char b
)
141 M_BRUSHDATA
->m_macBrushKind
= kwxMacBrushColour
;
142 M_BRUSHDATA
->m_colour
.Set(r
, g
, b
);
147 void wxBrush::SetStyle(int Style
)
151 M_BRUSHDATA
->m_macBrushKind
= kwxMacBrushColour
;
152 M_BRUSHDATA
->m_style
= Style
;
157 void wxBrush::SetStipple(const wxBitmap
& Stipple
)
161 M_BRUSHDATA
->m_macBrushKind
= kwxMacBrushColour
;
162 M_BRUSHDATA
->m_stipple
= Stipple
;
167 void wxBrush::MacSetTheme(ThemeBrush macThemeBrush
)
171 M_BRUSHDATA
->m_macBrushKind
= kwxMacBrushTheme
;
172 M_BRUSHDATA
->m_macThemeBrush
= macThemeBrush
;
177 void wxBrush::MacSetThemeBackground(unsigned long macThemeBackground
, const WXRECTPTR extent
)
181 M_BRUSHDATA
->m_macBrushKind
= kwxMacBrushThemeBackground
;
182 M_BRUSHDATA
->m_macThemeBackground
= macThemeBackground
;
183 M_BRUSHDATA
->m_macThemeBackgroundExtent
= *(Rect
*)extent
;
187 bool wxBrush::RealizeResource()
192 unsigned long wxBrush::MacGetThemeBackground( WXRECTPTR extent
) const
194 if ( M_BRUSHDATA
&& M_BRUSHDATA
->m_macBrushKind
== kwxMacBrushThemeBackground
)
197 *(Rect
*)extent
= M_BRUSHDATA
->m_macThemeBackgroundExtent
;
198 return M_BRUSHDATA
->m_macThemeBackground
;
206 short wxBrush::MacGetTheme() const
208 return (M_BRUSHDATA
? ( M_BRUSHDATA
->m_macBrushKind
== kwxMacBrushTheme
? M_BRUSHDATA
->m_macThemeBrush
: kThemeBrushBlack
) : kThemeBrushBlack
);
211 wxColour
& wxBrush::GetColour() const
213 return (M_BRUSHDATA
? M_BRUSHDATA
->m_colour
: wxNullColour
);
216 int wxBrush::GetStyle() const
218 return (M_BRUSHDATA
? M_BRUSHDATA
->m_style
: 0);
221 wxBitmap
*wxBrush::GetStipple() const
223 return (M_BRUSHDATA
? & M_BRUSHDATA
->m_stipple
: 0);
226 wxMacBrushKind
wxBrush::MacGetBrushKind() const
228 return (M_BRUSHDATA
? M_BRUSHDATA
->m_macBrushKind
: kwxMacBrushColour
);