]> git.saurik.com Git - wxWidgets.git/blame - src/mac/carbon/brush.cpp
detection of aqua layout scheme added
[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
2f1ae414 20#if !USE_SHARED_LIBRARIES
e9576ca5 21IMPLEMENT_DYNAMIC_CLASS(wxBrush, wxGDIObject)
2f1ae414 22#endif
e9576ca5
SC
23
24wxBrushRefData::wxBrushRefData()
25{
26 m_style = wxSOLID;
7d9d1fd7 27 m_macBrushKind = kwxMacBrushColour ;
e9576ca5
SC
28}
29
30wxBrushRefData::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
41wxBrushRefData::~wxBrushRefData()
42{
e9576ca5
SC
43}
44
45// Brushes
46wxBrush::wxBrush()
47{
e9576ca5
SC
48}
49
50wxBrush::~wxBrush()
51{
e9576ca5
SC
52}
53
54wxBrush::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
64wxBrush::wxBrush(const wxBitmap& stipple)
65{
66 m_refData = new wxBrushRefData;
67
2b65eb68 68 M_BRUSHDATA->m_colour = *wxBLACK;
e9576ca5 69 M_BRUSHDATA->m_stipple = stipple;
2b65eb68
SC
70
71 if (M_BRUSHDATA->m_stipple.GetMask())
72 M_BRUSHDATA->m_style = wxSTIPPLE_MASK_OPAQUE;
73 else
74 M_BRUSHDATA->m_style = wxSTIPPLE;
e9576ca5
SC
75
76 RealizeResource();
e9576ca5
SC
77}
78
1dcbbdcf
SC
79wxBrush::wxBrush(ThemeBrush macThemeBrush )
80{
81 m_refData = new wxBrushRefData;
82
7d9d1fd7 83 M_BRUSHDATA->m_macBrushKind = kwxMacBrushTheme;
1dcbbdcf
SC
84 M_BRUSHDATA->m_macThemeBrush = macThemeBrush;
85
86 RealizeResource();
87}
e9576ca5
SC
88void 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
103void wxBrush::SetColour(const wxColour& col)
104{
105 Unshare();
7d9d1fd7 106 M_BRUSHDATA->m_macBrushKind = kwxMacBrushColour;
e9576ca5
SC
107 M_BRUSHDATA->m_colour = col;
108
109 RealizeResource();
110}
111
112void wxBrush::SetColour(unsigned char r, unsigned char g, unsigned char b)
113{
114 Unshare();
115
7d9d1fd7 116 M_BRUSHDATA->m_macBrushKind = kwxMacBrushColour;
e9576ca5
SC
117 M_BRUSHDATA->m_colour.Set(r, g, b);
118
119 RealizeResource();
120}
121
122void wxBrush::SetStyle(int Style)
123{
124 Unshare();
125
7d9d1fd7 126 M_BRUSHDATA->m_macBrushKind = kwxMacBrushColour;
e9576ca5
SC
127 M_BRUSHDATA->m_style = Style;
128
129 RealizeResource();
130}
131
132void wxBrush::SetStipple(const wxBitmap& Stipple)
133{
134 Unshare();
135
7d9d1fd7 136 M_BRUSHDATA->m_macBrushKind = kwxMacBrushColour;
e9576ca5
SC
137 M_BRUSHDATA->m_stipple = Stipple;
138
139 RealizeResource();
140}
141
1dcbbdcf
SC
142void wxBrush::SetMacTheme(ThemeBrush macThemeBrush)
143{
144 Unshare();
145
7d9d1fd7 146 M_BRUSHDATA->m_macBrushKind = kwxMacBrushTheme;
1dcbbdcf
SC
147 M_BRUSHDATA->m_macThemeBrush = macThemeBrush;
148
149 RealizeResource();
150}
151
7d9d1fd7 152void wxBrush::SetMacThemeBackground(ThemeBackgroundKind macThemeBackground, const Rect &extent)
1dcbbdcf
SC
153{
154 Unshare();
155
7d9d1fd7 156 M_BRUSHDATA->m_macBrushKind = kwxMacBrushThemeBackground;
1dcbbdcf 157 M_BRUSHDATA->m_macThemeBackground = macThemeBackground;
7d9d1fd7 158 M_BRUSHDATA->m_macThemeBackgroundExtent = extent ;
1dcbbdcf
SC
159 RealizeResource();
160}
161
e9576ca5
SC
162bool wxBrush::RealizeResource()
163{
519cb848 164 return TRUE;
e9576ca5
SC
165}
166
7d9d1fd7
SC
167ThemeBackgroundKind 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