]> git.saurik.com Git - wxWidgets.git/blob - src/mac/carbon/brush.cpp
wxSystemSettings class API face lift: better names for its methods
[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_style = wxSTIPPLE;
69 M_BRUSHDATA->m_stipple = stipple;
70
71 RealizeResource();
72 }
73
74 wxBrush::wxBrush(ThemeBrush macThemeBrush )
75 {
76 m_refData = new wxBrushRefData;
77
78 M_BRUSHDATA->m_macBrushKind = kwxMacBrushTheme;
79 M_BRUSHDATA->m_macThemeBrush = macThemeBrush;
80
81 RealizeResource();
82 }
83 void wxBrush::Unshare()
84 {
85 // Don't change shared data
86 if (!m_refData)
87 {
88 m_refData = new wxBrushRefData();
89 }
90 else
91 {
92 wxBrushRefData* ref = new wxBrushRefData(*(wxBrushRefData*)m_refData);
93 UnRef();
94 m_refData = ref;
95 }
96 }
97
98 void wxBrush::SetColour(const wxColour& col)
99 {
100 Unshare();
101 M_BRUSHDATA->m_macBrushKind = kwxMacBrushColour;
102 M_BRUSHDATA->m_colour = col;
103
104 RealizeResource();
105 }
106
107 void wxBrush::SetColour(unsigned char r, unsigned char g, unsigned char b)
108 {
109 Unshare();
110
111 M_BRUSHDATA->m_macBrushKind = kwxMacBrushColour;
112 M_BRUSHDATA->m_colour.Set(r, g, b);
113
114 RealizeResource();
115 }
116
117 void wxBrush::SetStyle(int Style)
118 {
119 Unshare();
120
121 M_BRUSHDATA->m_macBrushKind = kwxMacBrushColour;
122 M_BRUSHDATA->m_style = Style;
123
124 RealizeResource();
125 }
126
127 void wxBrush::SetStipple(const wxBitmap& Stipple)
128 {
129 Unshare();
130
131 M_BRUSHDATA->m_macBrushKind = kwxMacBrushColour;
132 M_BRUSHDATA->m_stipple = Stipple;
133
134 RealizeResource();
135 }
136
137 void wxBrush::SetMacTheme(ThemeBrush macThemeBrush)
138 {
139 Unshare();
140
141 M_BRUSHDATA->m_macBrushKind = kwxMacBrushTheme;
142 M_BRUSHDATA->m_macThemeBrush = macThemeBrush;
143
144 RealizeResource();
145 }
146
147 void wxBrush::SetMacThemeBackground(ThemeBackgroundKind macThemeBackground, const Rect &extent)
148 {
149 Unshare();
150
151 M_BRUSHDATA->m_macBrushKind = kwxMacBrushThemeBackground;
152 M_BRUSHDATA->m_macThemeBackground = macThemeBackground;
153 M_BRUSHDATA->m_macThemeBackgroundExtent = extent ;
154 RealizeResource();
155 }
156
157 bool wxBrush::RealizeResource()
158 {
159 return TRUE;
160 }
161
162 ThemeBackgroundKind wxBrush::GetMacThemeBackground(Rect *extent) const
163 {
164 if ( M_BRUSHDATA && M_BRUSHDATA->m_macBrushKind == kwxMacBrushThemeBackground )
165 {
166 if ( extent )
167 *extent = M_BRUSHDATA->m_macThemeBackgroundExtent ;
168 return M_BRUSHDATA->m_macThemeBackground ;
169 }
170 else
171 {
172 return 0 ;
173 }
174 }
175