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