]> git.saurik.com Git - wxWidgets.git/blob - src/mac/carbon/brush.cpp
removing dependancy on mac headers from public wx headers (eventually adding wx/mac...
[wxWidgets.git] / src / mac / carbon / brush.cpp
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 #if !USE_SHARED_LIBRARIES
21 IMPLEMENT_DYNAMIC_CLASS(wxBrush, wxGDIObject)
22 #endif
23
24 wxBrushRefData::wxBrushRefData()
25 {
26 m_style = wxSOLID;
27 m_macBrushKind = kwxMacBrushColour ;
28 }
29
30 wxBrushRefData::wxBrushRefData(const wxBrushRefData& data)
31 {
32 m_style = data.m_style;
33 m_stipple = data.m_stipple;
34 m_colour = data.m_colour;
35 m_macBrushKind = data.m_macBrushKind ;
36 m_macThemeBrush = data.m_macThemeBrush ;
37 m_macThemeBackground = data.m_macThemeBackground ;
38 m_macThemeBackgroundExtent = data.m_macThemeBackgroundExtent ;
39 }
40
41 wxBrushRefData::~wxBrushRefData()
42 {
43 }
44
45 // Brushes
46 wxBrush::wxBrush()
47 {
48 }
49
50 wxBrush::~wxBrush()
51 {
52 }
53
54 wxBrush::wxBrush(const wxColour& col, int Style)
55 {
56 m_refData = new wxBrushRefData;
57
58 M_BRUSHDATA->m_colour = col;
59 M_BRUSHDATA->m_style = Style;
60
61 RealizeResource();
62 }
63
64 wxBrush::wxBrush(const wxBitmap& stipple)
65 {
66 m_refData = new wxBrushRefData;
67
68 M_BRUSHDATA->m_colour = *wxBLACK;
69 M_BRUSHDATA->m_stipple = stipple;
70
71 if (M_BRUSHDATA->m_stipple.GetMask())
72 M_BRUSHDATA->m_style = wxSTIPPLE_MASK_OPAQUE;
73 else
74 M_BRUSHDATA->m_style = wxSTIPPLE;
75
76 RealizeResource();
77 }
78
79 wxBrush::wxBrush(ThemeBrush macThemeBrush )
80 {
81 m_refData = new wxBrushRefData;
82
83 M_BRUSHDATA->m_macBrushKind = kwxMacBrushTheme;
84 M_BRUSHDATA->m_macThemeBrush = macThemeBrush;
85
86 RealizeResource();
87 }
88 void wxBrush::Unshare()
89 {
90 // Don't change shared data
91 if (!m_refData)
92 {
93 m_refData = new wxBrushRefData();
94 }
95 else
96 {
97 wxBrushRefData* ref = new wxBrushRefData(*(wxBrushRefData*)m_refData);
98 UnRef();
99 m_refData = ref;
100 }
101 }
102
103 void wxBrush::SetColour(const wxColour& col)
104 {
105 Unshare();
106 M_BRUSHDATA->m_macBrushKind = kwxMacBrushColour;
107 M_BRUSHDATA->m_colour = col;
108
109 RealizeResource();
110 }
111
112 void wxBrush::SetColour(unsigned char r, unsigned char g, unsigned char b)
113 {
114 Unshare();
115
116 M_BRUSHDATA->m_macBrushKind = kwxMacBrushColour;
117 M_BRUSHDATA->m_colour.Set(r, g, b);
118
119 RealizeResource();
120 }
121
122 void wxBrush::SetStyle(int Style)
123 {
124 Unshare();
125
126 M_BRUSHDATA->m_macBrushKind = kwxMacBrushColour;
127 M_BRUSHDATA->m_style = Style;
128
129 RealizeResource();
130 }
131
132 void wxBrush::SetStipple(const wxBitmap& Stipple)
133 {
134 Unshare();
135
136 M_BRUSHDATA->m_macBrushKind = kwxMacBrushColour;
137 M_BRUSHDATA->m_stipple = Stipple;
138
139 RealizeResource();
140 }
141
142 void wxBrush::SetMacTheme(ThemeBrush macThemeBrush)
143 {
144 Unshare();
145
146 M_BRUSHDATA->m_macBrushKind = kwxMacBrushTheme;
147 M_BRUSHDATA->m_macThemeBrush = macThemeBrush;
148
149 RealizeResource();
150 }
151
152 void wxBrush::SetMacThemeBackground(ThemeBackgroundKind macThemeBackground, const Rect &extent)
153 {
154 Unshare();
155
156 M_BRUSHDATA->m_macBrushKind = kwxMacBrushThemeBackground;
157 M_BRUSHDATA->m_macThemeBackground = macThemeBackground;
158 M_BRUSHDATA->m_macThemeBackgroundExtent = extent ;
159 RealizeResource();
160 }
161
162 bool wxBrush::RealizeResource()
163 {
164 return TRUE;
165 }
166
167 ThemeBackgroundKind wxBrush::GetMacThemeBackground(Rect *extent) const
168 {
169 if ( M_BRUSHDATA && M_BRUSHDATA->m_macBrushKind == kwxMacBrushThemeBackground )
170 {
171 if ( extent )
172 *extent = M_BRUSHDATA->m_macThemeBackgroundExtent ;
173 return M_BRUSHDATA->m_macThemeBackground ;
174 }
175 else
176 {
177 return 0 ;
178 }
179 }
180