]> git.saurik.com Git - wxWidgets.git/blame - src/mac/carbon/brush.cpp
gcc pragmas fixes
[wxWidgets.git] / src / mac / carbon / brush.cpp
CommitLineData
e9576ca5
SC
1/////////////////////////////////////////////////////////////////////////////
2// Name: brush.cpp
3// Purpose: wxBrush
4// Author: AUTHOR
5// Modified by:
6// Created: ??/??/98
7// RCS-ID: $Id$
8// Copyright: (c) AUTHOR
9// Licence: wxWindows licence
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
SC
48wxBrushRefData::wxBrushRefData()
49{
50 m_style = wxSOLID;
7d9d1fd7 51 m_macBrushKind = kwxMacBrushColour ;
e9576ca5
SC
52}
53
54wxBrushRefData::wxBrushRefData(const wxBrushRefData& data)
55{
56 m_style = data.m_style;
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{
114 // Don't change shared data
115 if (!m_refData)
116 {
117 m_refData = new wxBrushRefData();
118 }
119 else
120 {
121 wxBrushRefData* ref = new wxBrushRefData(*(wxBrushRefData*)m_refData);
122 UnRef();
123 m_refData = ref;
124 }
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
1dcbbdcf
SC
166void wxBrush::SetMacTheme(ThemeBrush macThemeBrush)
167{
168 Unshare();
169
7d9d1fd7 170 M_BRUSHDATA->m_macBrushKind = kwxMacBrushTheme;
1dcbbdcf
SC
171 M_BRUSHDATA->m_macThemeBrush = macThemeBrush;
172
173 RealizeResource();
174}
175
76a5e5d2 176void wxBrush::SetMacThemeBackground(unsigned long macThemeBackground, const WXRECTPTR extent)
1dcbbdcf
SC
177{
178 Unshare();
179
7d9d1fd7 180 M_BRUSHDATA->m_macBrushKind = kwxMacBrushThemeBackground;
1dcbbdcf 181 M_BRUSHDATA->m_macThemeBackground = macThemeBackground;
76a5e5d2 182 M_BRUSHDATA->m_macThemeBackgroundExtent = *(Rect*)extent ;
1dcbbdcf
SC
183 RealizeResource();
184}
185
e9576ca5
SC
186bool wxBrush::RealizeResource()
187{
519cb848 188 return TRUE;
e9576ca5
SC
189}
190
76a5e5d2 191unsigned long wxBrush::GetMacThemeBackground( WXRECTPTR extent) const
7d9d1fd7
SC
192{
193 if ( M_BRUSHDATA && M_BRUSHDATA->m_macBrushKind == kwxMacBrushThemeBackground )
194 {
195 if ( extent )
76a5e5d2 196 *(Rect*)extent = M_BRUSHDATA->m_macThemeBackgroundExtent ;
7d9d1fd7
SC
197 return M_BRUSHDATA->m_macThemeBackground ;
198 }
199 else
200 {
201 return 0 ;
202 }
203}
204
76a5e5d2
SC
205short wxBrush::GetMacTheme() const
206{
207 return (M_BRUSHDATA ? ( M_BRUSHDATA->m_macBrushKind == kwxMacBrushTheme ? M_BRUSHDATA->m_macThemeBrush : kThemeBrushBlack) : kThemeBrushBlack);
208};
209
210wxColour& wxBrush::GetColour() const
211{ return (M_BRUSHDATA ? M_BRUSHDATA->m_colour : wxNullColour); };
212
213int wxBrush::GetStyle() const
214{
215 return (M_BRUSHDATA ? M_BRUSHDATA->m_style : 0);
216};
217
218wxBitmap *wxBrush::GetStipple() const
219{
220 return (M_BRUSHDATA ? & M_BRUSHDATA->m_stipple : 0);
221};
222
223wxMacBrushKind wxBrush::MacGetBrushKind() const
224{
225 return (M_BRUSHDATA ? M_BRUSHDATA->m_macBrushKind : kwxMacBrushColour);
226};