]> git.saurik.com Git - wxWidgets.git/blame - src/mac/carbon/brush.cpp
fixed (harmless) unused variable warning in release build
[wxWidgets.git] / src / mac / carbon / brush.cpp
CommitLineData
e9576ca5
SC
1/////////////////////////////////////////////////////////////////////////////
2// Name: brush.cpp
3// Purpose: wxBrush
a31a5f85 4// Author: Stefan Csomor
e9576ca5 5// Modified by:
a31a5f85 6// Created: 1998-01-01
e9576ca5 7// RCS-ID: $Id$
a31a5f85 8// Copyright: (c) Stefan Csomor
65571936 9// Licence: wxWindows licence
e9576ca5
SC
10/////////////////////////////////////////////////////////////////////////////
11
a8e9860d 12#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
e9576ca5
SC
13#pragma implementation "brush.h"
14#endif
15
a8e9860d
SC
16#include "wx/wxprec.h"
17
e9576ca5
SC
18#include "wx/utils.h"
19#include "wx/brush.h"
20
76a5e5d2
SC
21#include "wx/mac/private.h"
22
e9576ca5 23IMPLEMENT_DYNAMIC_CLASS(wxBrush, wxGDIObject)
e9576ca5 24
76a5e5d2
SC
25class WXDLLEXPORT wxBrushRefData: public wxGDIRefData
26{
27 friend class WXDLLEXPORT wxBrush;
28public:
29 wxBrushRefData();
30 wxBrushRefData(const wxBrushRefData& data);
31 ~wxBrushRefData();
32
33protected:
34 wxMacBrushKind m_macBrushKind ;
35 int m_style;
36 wxBitmap m_stipple ;
37 wxColour m_colour;
38
39 ThemeBrush m_macThemeBrush ;
40
41 ThemeBackgroundKind m_macThemeBackground ;
42 Rect m_macThemeBackgroundExtent ;
43};
44
45#define M_BRUSHDATA ((wxBrushRefData *)m_refData)
46
e9576ca5 47wxBrushRefData::wxBrushRefData()
d84afea9 48 : m_style(wxSOLID)
e9576ca5 49{
7d9d1fd7 50 m_macBrushKind = kwxMacBrushColour ;
e9576ca5
SC
51}
52
53wxBrushRefData::wxBrushRefData(const wxBrushRefData& data)
d84afea9
GD
54 : wxGDIRefData()
55 , m_style(data.m_style)
e9576ca5 56{
e9576ca5
SC
57 m_stipple = data.m_stipple;
58 m_colour = data.m_colour;
7d9d1fd7 59 m_macBrushKind = data.m_macBrushKind ;
1dcbbdcf 60 m_macThemeBrush = data.m_macThemeBrush ;
7d9d1fd7
SC
61 m_macThemeBackground = data.m_macThemeBackground ;
62 m_macThemeBackgroundExtent = data.m_macThemeBackgroundExtent ;
e9576ca5
SC
63}
64
65wxBrushRefData::~wxBrushRefData()
66{
e9576ca5
SC
67}
68
69// Brushes
70wxBrush::wxBrush()
71{
e9576ca5
SC
72}
73
74wxBrush::~wxBrush()
75{
e9576ca5
SC
76}
77
78wxBrush::wxBrush(const wxColour& col, int Style)
79{
80 m_refData = new wxBrushRefData;
81
82 M_BRUSHDATA->m_colour = col;
83 M_BRUSHDATA->m_style = Style;
84
85 RealizeResource();
e9576ca5
SC
86}
87
88wxBrush::wxBrush(const wxBitmap& stipple)
89{
90 m_refData = new wxBrushRefData;
91
2b65eb68 92 M_BRUSHDATA->m_colour = *wxBLACK;
e9576ca5 93 M_BRUSHDATA->m_stipple = stipple;
2b65eb68
SC
94
95 if (M_BRUSHDATA->m_stipple.GetMask())
96 M_BRUSHDATA->m_style = wxSTIPPLE_MASK_OPAQUE;
97 else
98 M_BRUSHDATA->m_style = wxSTIPPLE;
e9576ca5
SC
99
100 RealizeResource();
e9576ca5
SC
101}
102
1dcbbdcf
SC
103wxBrush::wxBrush(ThemeBrush macThemeBrush )
104{
105 m_refData = new wxBrushRefData;
106
7d9d1fd7 107 M_BRUSHDATA->m_macBrushKind = kwxMacBrushTheme;
1dcbbdcf
SC
108 M_BRUSHDATA->m_macThemeBrush = macThemeBrush;
109
110 RealizeResource();
111}
e9576ca5
SC
112void wxBrush::Unshare()
113{
e40298d5
JS
114 // Don't change shared data
115 if (!m_refData)
e9576ca5 116 {
e40298d5
JS
117 m_refData = new wxBrushRefData();
118 }
e9576ca5
SC
119 else
120 {
e40298d5
JS
121 wxBrushRefData* ref = new wxBrushRefData(*(wxBrushRefData*)m_refData);
122 UnRef();
123 m_refData = ref;
124 }
e9576ca5
SC
125}
126
127void wxBrush::SetColour(const wxColour& col)
128{
129 Unshare();
7d9d1fd7 130 M_BRUSHDATA->m_macBrushKind = kwxMacBrushColour;
e9576ca5
SC
131 M_BRUSHDATA->m_colour = col;
132
133 RealizeResource();
134}
135
136void wxBrush::SetColour(unsigned char r, unsigned char g, unsigned char b)
137{
138 Unshare();
139
7d9d1fd7 140 M_BRUSHDATA->m_macBrushKind = kwxMacBrushColour;
e9576ca5
SC
141 M_BRUSHDATA->m_colour.Set(r, g, b);
142
143 RealizeResource();
144}
145
146void wxBrush::SetStyle(int Style)
147{
148 Unshare();
149
7d9d1fd7 150 M_BRUSHDATA->m_macBrushKind = kwxMacBrushColour;
e9576ca5
SC
151 M_BRUSHDATA->m_style = Style;
152
153 RealizeResource();
154}
155
156void wxBrush::SetStipple(const wxBitmap& Stipple)
157{
158 Unshare();
159
7d9d1fd7 160 M_BRUSHDATA->m_macBrushKind = kwxMacBrushColour;
e9576ca5
SC
161 M_BRUSHDATA->m_stipple = Stipple;
162
163 RealizeResource();
164}
165
facd6764 166void wxBrush::MacSetTheme(ThemeBrush macThemeBrush)
1dcbbdcf
SC
167{
168 Unshare();
169
7d9d1fd7 170 M_BRUSHDATA->m_macBrushKind = kwxMacBrushTheme;
1dcbbdcf 171 M_BRUSHDATA->m_macThemeBrush = macThemeBrush;
ff38d8c1
SC
172 RGBColor color ;
173 GetThemeBrushAsColor( macThemeBrush , 32, true, &color );
174 M_BRUSHDATA->m_colour.Set( color.red >> 8 , color.green >> 8 , color.blue >> 8 ) ;
175
1dcbbdcf
SC
176 RealizeResource();
177}
178
facd6764 179void wxBrush::MacSetThemeBackground(unsigned long macThemeBackground, const WXRECTPTR extent)
1dcbbdcf
SC
180{
181 Unshare();
182
7d9d1fd7 183 M_BRUSHDATA->m_macBrushKind = kwxMacBrushThemeBackground;
1dcbbdcf 184 M_BRUSHDATA->m_macThemeBackground = macThemeBackground;
76a5e5d2 185 M_BRUSHDATA->m_macThemeBackgroundExtent = *(Rect*)extent ;
1dcbbdcf
SC
186 RealizeResource();
187}
188
e9576ca5
SC
189bool wxBrush::RealizeResource()
190{
519cb848 191 return TRUE;
e9576ca5
SC
192}
193
facd6764 194unsigned long wxBrush::MacGetThemeBackground( WXRECTPTR extent) const
7d9d1fd7
SC
195{
196 if ( M_BRUSHDATA && M_BRUSHDATA->m_macBrushKind == kwxMacBrushThemeBackground )
197 {
198 if ( extent )
76a5e5d2 199 *(Rect*)extent = M_BRUSHDATA->m_macThemeBackgroundExtent ;
7d9d1fd7
SC
200 return M_BRUSHDATA->m_macThemeBackground ;
201 }
202 else
203 {
204 return 0 ;
205 }
206}
207
facd6764 208short wxBrush::MacGetTheme() const
76a5e5d2 209{
e40298d5
JS
210 return (M_BRUSHDATA ? ( M_BRUSHDATA->m_macBrushKind == kwxMacBrushTheme ? M_BRUSHDATA->m_macThemeBrush : kThemeBrushBlack) : kThemeBrushBlack);
211}
76a5e5d2
SC
212
213wxColour& wxBrush::GetColour() const
e40298d5
JS
214{
215 return (M_BRUSHDATA ? M_BRUSHDATA->m_colour : wxNullColour);
216}
76a5e5d2
SC
217
218int wxBrush::GetStyle() const
219{
e40298d5
JS
220 return (M_BRUSHDATA ? M_BRUSHDATA->m_style : 0);
221}
76a5e5d2
SC
222
223wxBitmap *wxBrush::GetStipple() const
224{
e40298d5
JS
225 return (M_BRUSHDATA ? & M_BRUSHDATA->m_stipple : 0);
226}
76a5e5d2
SC
227
228wxMacBrushKind wxBrush::MacGetBrushKind() const
229{
e40298d5 230 return (M_BRUSHDATA ? M_BRUSHDATA->m_macBrushKind : kwxMacBrushColour);
a8e9860d 231}