]> git.saurik.com Git - wxWidgets.git/blame_incremental - src/mac/brush.cpp
use specific linker flags under Mac OS X when linking executables against the
[wxWidgets.git] / src / mac / brush.cpp
... / ...
CommitLineData
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
20#include "wx/mac/private.h"
21
22#if !USE_SHARED_LIBRARIES
23IMPLEMENT_DYNAMIC_CLASS(wxBrush, wxGDIObject)
24#endif
25
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
48wxBrushRefData::wxBrushRefData()
49{
50 m_style = wxSOLID;
51 m_macBrushKind = kwxMacBrushColour ;
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;
59 m_macBrushKind = data.m_macBrushKind ;
60 m_macThemeBrush = data.m_macThemeBrush ;
61 m_macThemeBackground = data.m_macThemeBackground ;
62 m_macThemeBackgroundExtent = data.m_macThemeBackgroundExtent ;
63}
64
65wxBrushRefData::~wxBrushRefData()
66{
67}
68
69// Brushes
70wxBrush::wxBrush()
71{
72}
73
74wxBrush::~wxBrush()
75{
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();
86}
87
88wxBrush::wxBrush(const wxBitmap& stipple)
89{
90 m_refData = new wxBrushRefData;
91
92 M_BRUSHDATA->m_colour = *wxBLACK;
93 M_BRUSHDATA->m_stipple = stipple;
94
95 if (M_BRUSHDATA->m_stipple.GetMask())
96 M_BRUSHDATA->m_style = wxSTIPPLE_MASK_OPAQUE;
97 else
98 M_BRUSHDATA->m_style = wxSTIPPLE;
99
100 RealizeResource();
101}
102
103wxBrush::wxBrush(ThemeBrush macThemeBrush )
104{
105 m_refData = new wxBrushRefData;
106
107 M_BRUSHDATA->m_macBrushKind = kwxMacBrushTheme;
108 M_BRUSHDATA->m_macThemeBrush = macThemeBrush;
109
110 RealizeResource();
111}
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();
130 M_BRUSHDATA->m_macBrushKind = kwxMacBrushColour;
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
140 M_BRUSHDATA->m_macBrushKind = kwxMacBrushColour;
141 M_BRUSHDATA->m_colour.Set(r, g, b);
142
143 RealizeResource();
144}
145
146void wxBrush::SetStyle(int Style)
147{
148 Unshare();
149
150 M_BRUSHDATA->m_macBrushKind = kwxMacBrushColour;
151 M_BRUSHDATA->m_style = Style;
152
153 RealizeResource();
154}
155
156void wxBrush::SetStipple(const wxBitmap& Stipple)
157{
158 Unshare();
159
160 M_BRUSHDATA->m_macBrushKind = kwxMacBrushColour;
161 M_BRUSHDATA->m_stipple = Stipple;
162
163 RealizeResource();
164}
165
166void wxBrush::SetMacTheme(ThemeBrush macThemeBrush)
167{
168 Unshare();
169
170 M_BRUSHDATA->m_macBrushKind = kwxMacBrushTheme;
171 M_BRUSHDATA->m_macThemeBrush = macThemeBrush;
172
173 RealizeResource();
174}
175
176void wxBrush::SetMacThemeBackground(unsigned long macThemeBackground, const WXRECTPTR extent)
177{
178 Unshare();
179
180 M_BRUSHDATA->m_macBrushKind = kwxMacBrushThemeBackground;
181 M_BRUSHDATA->m_macThemeBackground = macThemeBackground;
182 M_BRUSHDATA->m_macThemeBackgroundExtent = *(Rect*)extent ;
183 RealizeResource();
184}
185
186bool wxBrush::RealizeResource()
187{
188 return TRUE;
189}
190
191unsigned long wxBrush::GetMacThemeBackground( WXRECTPTR extent) const
192{
193 if ( M_BRUSHDATA && M_BRUSHDATA->m_macBrushKind == kwxMacBrushThemeBackground )
194 {
195 if ( extent )
196 *(Rect*)extent = M_BRUSHDATA->m_macThemeBackgroundExtent ;
197 return M_BRUSHDATA->m_macThemeBackground ;
198 }
199 else
200 {
201 return 0 ;
202 }
203}
204
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};