]> git.saurik.com Git - wxWidgets.git/blame - src/mac/classic/brush.cpp
Separated XML and HTML rich text I/O handlers
[wxWidgets.git] / src / mac / classic / brush.cpp
CommitLineData
2646f485 1/////////////////////////////////////////////////////////////////////////////
46562151 2// Name: src/mac/classic/brush.cpp
2646f485
SC
3// Purpose: wxBrush
4// Author: Stefan Csomor
5// Modified by:
6// Created: 1998-01-01
7// RCS-ID: $Id$
8// Copyright: (c) Stefan Csomor
46562151 9// Licence: wxWindows licence
2646f485
SC
10/////////////////////////////////////////////////////////////////////////////
11
2646f485
SC
12#include "wx/setup.h"
13#include "wx/utils.h"
14#include "wx/brush.h"
15
16#include "wx/mac/private.h"
17
2646f485 18IMPLEMENT_DYNAMIC_CLASS(wxBrush, wxGDIObject)
2646f485
SC
19
20class WXDLLEXPORT wxBrushRefData: public wxGDIRefData
21{
22 friend class WXDLLEXPORT wxBrush;
23public:
24 wxBrushRefData();
25 wxBrushRefData(const wxBrushRefData& data);
26 ~wxBrushRefData();
27
28protected:
29 wxMacBrushKind m_macBrushKind ;
30 int m_style;
31 wxBitmap m_stipple ;
32 wxColour m_colour;
46562151 33
2646f485 34 ThemeBrush m_macThemeBrush ;
46562151 35
2646f485
SC
36 ThemeBackgroundKind m_macThemeBackground ;
37 Rect m_macThemeBackgroundExtent ;
38};
39
40#define M_BRUSHDATA ((wxBrushRefData *)m_refData)
41
42wxBrushRefData::wxBrushRefData()
43 : m_style(wxSOLID)
44{
45 m_macBrushKind = kwxMacBrushColour ;
46}
47
48wxBrushRefData::wxBrushRefData(const wxBrushRefData& data)
49 : wxGDIRefData()
50 , m_style(data.m_style)
51{
52 m_stipple = data.m_stipple;
53 m_colour = data.m_colour;
54 m_macBrushKind = data.m_macBrushKind ;
55 m_macThemeBrush = data.m_macThemeBrush ;
56 m_macThemeBackground = data.m_macThemeBackground ;
57 m_macThemeBackgroundExtent = data.m_macThemeBackgroundExtent ;
58}
59
60wxBrushRefData::~wxBrushRefData()
61{
62}
63
64// Brushes
65wxBrush::wxBrush()
66{
67}
68
69wxBrush::~wxBrush()
70{
71}
72
73wxBrush::wxBrush(const wxColour& col, int Style)
74{
75 m_refData = new wxBrushRefData;
76
77 M_BRUSHDATA->m_colour = col;
78 M_BRUSHDATA->m_style = Style;
79
80 RealizeResource();
81}
82
83wxBrush::wxBrush(const wxBitmap& stipple)
84{
85 m_refData = new wxBrushRefData;
86
87 M_BRUSHDATA->m_colour = *wxBLACK;
88 M_BRUSHDATA->m_stipple = stipple;
46562151 89
2646f485
SC
90 if (M_BRUSHDATA->m_stipple.GetMask())
91 M_BRUSHDATA->m_style = wxSTIPPLE_MASK_OPAQUE;
92 else
93 M_BRUSHDATA->m_style = wxSTIPPLE;
94
95 RealizeResource();
96}
97
46562151 98wxBrush::wxBrush(ThemeBrush macThemeBrush )
2646f485
SC
99{
100 m_refData = new wxBrushRefData;
101
102 M_BRUSHDATA->m_macBrushKind = kwxMacBrushTheme;
103 M_BRUSHDATA->m_macThemeBrush = macThemeBrush;
104
105 RealizeResource();
106}
107void wxBrush::Unshare()
108{
109 // Don't change shared data
110 if (!m_refData)
111 {
112 m_refData = new wxBrushRefData();
113 }
114 else
115 {
116 wxBrushRefData* ref = new wxBrushRefData(*(wxBrushRefData*)m_refData);
117 UnRef();
118 m_refData = ref;
119 }
120}
121
122void wxBrush::SetColour(const wxColour& col)
123{
124 Unshare();
125 M_BRUSHDATA->m_macBrushKind = kwxMacBrushColour;
126 M_BRUSHDATA->m_colour = col;
127
128 RealizeResource();
129}
130
1a1498c0 131void wxBrush::SetColour(unsigned char r, unsigned char g, unsigned char b)
2646f485
SC
132{
133 Unshare();
134
135 M_BRUSHDATA->m_macBrushKind = kwxMacBrushColour;
136 M_BRUSHDATA->m_colour.Set(r, g, b);
137
138 RealizeResource();
139}
140
141void wxBrush::SetStyle(int Style)
142{
143 Unshare();
144
145 M_BRUSHDATA->m_macBrushKind = kwxMacBrushColour;
146 M_BRUSHDATA->m_style = Style;
147
148 RealizeResource();
149}
150
151void wxBrush::SetStipple(const wxBitmap& Stipple)
152{
153 Unshare();
154
155 M_BRUSHDATA->m_macBrushKind = kwxMacBrushColour;
156 M_BRUSHDATA->m_stipple = Stipple;
157
158 RealizeResource();
159}
160
161void wxBrush::SetMacTheme(ThemeBrush macThemeBrush)
162{
163 Unshare();
164
165 M_BRUSHDATA->m_macBrushKind = kwxMacBrushTheme;
166 M_BRUSHDATA->m_macThemeBrush = macThemeBrush;
167
168 RealizeResource();
169}
170
171void wxBrush::SetMacThemeBackground(unsigned long macThemeBackground, const WXRECTPTR extent)
172{
173 Unshare();
174
175 M_BRUSHDATA->m_macBrushKind = kwxMacBrushThemeBackground;
176 M_BRUSHDATA->m_macThemeBackground = macThemeBackground;
177 M_BRUSHDATA->m_macThemeBackgroundExtent = *(Rect*)extent ;
178 RealizeResource();
179}
180
181bool wxBrush::RealizeResource()
182{
46562151 183 return true;
2646f485
SC
184}
185
46562151 186unsigned long wxBrush::GetMacThemeBackground( WXRECTPTR extent) const
2646f485 187{
46562151
WS
188 if ( M_BRUSHDATA && M_BRUSHDATA->m_macBrushKind == kwxMacBrushThemeBackground )
189 {
190 if ( extent )
191 *(Rect*)extent = M_BRUSHDATA->m_macThemeBackgroundExtent ;
192 return M_BRUSHDATA->m_macThemeBackground ;
193 }
194 else
195 {
196 return 0 ;
197 }
2646f485
SC
198}
199
46562151
WS
200short wxBrush::GetMacTheme() const
201{
202 return (M_BRUSHDATA ? ( M_BRUSHDATA->m_macBrushKind == kwxMacBrushTheme ? M_BRUSHDATA->m_macThemeBrush : kThemeBrushBlack) : kThemeBrushBlack);
2646f485
SC
203}
204
46562151 205wxColour& wxBrush::GetColour() const
2646f485
SC
206{
207 return (M_BRUSHDATA ? M_BRUSHDATA->m_colour : wxNullColour);
208}
209
46562151
WS
210int wxBrush::GetStyle() const
211{
212 return (M_BRUSHDATA ? M_BRUSHDATA->m_style : 0);
2646f485
SC
213}
214
46562151
WS
215wxBitmap *wxBrush::GetStipple() const
216{
217 return (M_BRUSHDATA ? & M_BRUSHDATA->m_stipple : 0);
2646f485
SC
218}
219
46562151
WS
220wxMacBrushKind wxBrush::MacGetBrushKind() const
221{
222 return (M_BRUSHDATA ? M_BRUSHDATA->m_macBrushKind : kwxMacBrushColour);
62f864c3 223}