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