]>
Commit | Line | Data |
---|---|---|
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 | ||
2f1ae414 | 20 | #if !USE_SHARED_LIBRARIES |
e9576ca5 | 21 | IMPLEMENT_DYNAMIC_CLASS(wxBrush, wxGDIObject) |
2f1ae414 | 22 | #endif |
e9576ca5 SC |
23 | |
24 | wxBrushRefData::wxBrushRefData() | |
25 | { | |
26 | m_style = wxSOLID; | |
7d9d1fd7 | 27 | m_macBrushKind = kwxMacBrushColour ; |
e9576ca5 SC |
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; | |
7d9d1fd7 | 35 | m_macBrushKind = data.m_macBrushKind ; |
1dcbbdcf | 36 | m_macThemeBrush = data.m_macThemeBrush ; |
7d9d1fd7 SC |
37 | m_macThemeBackground = data.m_macThemeBackground ; |
38 | m_macThemeBackgroundExtent = data.m_macThemeBackgroundExtent ; | |
e9576ca5 SC |
39 | } |
40 | ||
41 | wxBrushRefData::~wxBrushRefData() | |
42 | { | |
e9576ca5 SC |
43 | } |
44 | ||
45 | // Brushes | |
46 | wxBrush::wxBrush() | |
47 | { | |
e9576ca5 SC |
48 | } |
49 | ||
50 | wxBrush::~wxBrush() | |
51 | { | |
e9576ca5 SC |
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(); | |
e9576ca5 SC |
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(); | |
e9576ca5 SC |
72 | } |
73 | ||
1dcbbdcf SC |
74 | wxBrush::wxBrush(ThemeBrush macThemeBrush ) |
75 | { | |
76 | m_refData = new wxBrushRefData; | |
77 | ||
7d9d1fd7 | 78 | M_BRUSHDATA->m_macBrushKind = kwxMacBrushTheme; |
1dcbbdcf SC |
79 | M_BRUSHDATA->m_macThemeBrush = macThemeBrush; |
80 | ||
81 | RealizeResource(); | |
82 | } | |
e9576ca5 SC |
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(); | |
7d9d1fd7 | 101 | M_BRUSHDATA->m_macBrushKind = kwxMacBrushColour; |
e9576ca5 SC |
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 | ||
7d9d1fd7 | 111 | M_BRUSHDATA->m_macBrushKind = kwxMacBrushColour; |
e9576ca5 SC |
112 | M_BRUSHDATA->m_colour.Set(r, g, b); |
113 | ||
114 | RealizeResource(); | |
115 | } | |
116 | ||
117 | void wxBrush::SetStyle(int Style) | |
118 | { | |
119 | Unshare(); | |
120 | ||
7d9d1fd7 | 121 | M_BRUSHDATA->m_macBrushKind = kwxMacBrushColour; |
e9576ca5 SC |
122 | M_BRUSHDATA->m_style = Style; |
123 | ||
124 | RealizeResource(); | |
125 | } | |
126 | ||
127 | void wxBrush::SetStipple(const wxBitmap& Stipple) | |
128 | { | |
129 | Unshare(); | |
130 | ||
7d9d1fd7 | 131 | M_BRUSHDATA->m_macBrushKind = kwxMacBrushColour; |
e9576ca5 SC |
132 | M_BRUSHDATA->m_stipple = Stipple; |
133 | ||
134 | RealizeResource(); | |
135 | } | |
136 | ||
1dcbbdcf SC |
137 | void wxBrush::SetMacTheme(ThemeBrush macThemeBrush) |
138 | { | |
139 | Unshare(); | |
140 | ||
7d9d1fd7 | 141 | M_BRUSHDATA->m_macBrushKind = kwxMacBrushTheme; |
1dcbbdcf SC |
142 | M_BRUSHDATA->m_macThemeBrush = macThemeBrush; |
143 | ||
144 | RealizeResource(); | |
145 | } | |
146 | ||
7d9d1fd7 | 147 | void wxBrush::SetMacThemeBackground(ThemeBackgroundKind macThemeBackground, const Rect &extent) |
1dcbbdcf SC |
148 | { |
149 | Unshare(); | |
150 | ||
7d9d1fd7 | 151 | M_BRUSHDATA->m_macBrushKind = kwxMacBrushThemeBackground; |
1dcbbdcf | 152 | M_BRUSHDATA->m_macThemeBackground = macThemeBackground; |
7d9d1fd7 | 153 | M_BRUSHDATA->m_macThemeBackgroundExtent = extent ; |
1dcbbdcf SC |
154 | RealizeResource(); |
155 | } | |
156 | ||
e9576ca5 SC |
157 | bool wxBrush::RealizeResource() |
158 | { | |
519cb848 | 159 | return TRUE; |
e9576ca5 SC |
160 | } |
161 | ||
7d9d1fd7 SC |
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 |