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