]> git.saurik.com Git - wxWidgets.git/blame_incremental - src/mac/brush.cpp
wxSystemSettings class API face lift: better names for its methods
[wxWidgets.git] / src / mac / brush.cpp
... / ...
CommitLineData
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
21IMPLEMENT_DYNAMIC_CLASS(wxBrush, wxGDIObject)
22#endif
23
24wxBrushRefData::wxBrushRefData()
25{
26 m_style = wxSOLID;
27 m_macBrushKind = kwxMacBrushColour ;
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;
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
41wxBrushRefData::~wxBrushRefData()
42{
43}
44
45// Brushes
46wxBrush::wxBrush()
47{
48}
49
50wxBrush::~wxBrush()
51{
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();
62}
63
64wxBrush::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
74wxBrush::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}
83void 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
98void 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
107void 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
117void 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
127void 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
137void 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
147void 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
157bool wxBrush::RealizeResource()
158{
159 return TRUE;
160}
161
162ThemeBackgroundKind 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