]> git.saurik.com Git - wxWidgets.git/blob - src/qt/brush.cpp
Visualage C++ V4.0 duplicate symbol fixes
[wxWidgets.git] / src / qt / 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 IMPLEMENT_DYNAMIC_CLASS(wxBrush, wxGDIObject)
21
22 wxBrushRefData::wxBrushRefData()
23 {
24 m_style = wxSOLID;
25 // TODO: null data
26 }
27
28 wxBrushRefData::wxBrushRefData(const wxBrushRefData& data)
29 {
30 m_style = data.m_style;
31 m_stipple = data.m_stipple;
32 m_colour = data.m_colour;
33 /* TODO: null data
34 m_hBrush = 0;
35 */
36 }
37
38 wxBrushRefData::~wxBrushRefData()
39 {
40 // TODO: delete data
41 }
42
43 // Brushes
44 wxBrush::wxBrush()
45 {
46 if ( wxTheBrushList )
47 wxTheBrushList->AddBrush(this);
48 }
49
50 wxBrush::~wxBrush()
51 {
52 if ( wxTheBrushList )
53 wxTheBrushList->RemoveBrush(this);
54 }
55
56 wxBrush::wxBrush(const wxColour& col, int Style)
57 {
58 m_refData = new wxBrushRefData;
59
60 M_BRUSHDATA->m_colour = col;
61 M_BRUSHDATA->m_style = Style;
62
63 RealizeResource();
64
65 if ( wxTheBrushList )
66 wxTheBrushList->AddBrush(this);
67 }
68
69 wxBrush::wxBrush(const wxString& col, int Style)
70 {
71 m_refData = new wxBrushRefData;
72
73 // Implicit conversion from string to wxColour via colour database
74 M_BRUSHDATA->m_colour = col;
75 M_BRUSHDATA->m_style = Style;
76
77 RealizeResource();
78
79 if ( wxTheBrushList )
80 wxTheBrushList->AddBrush(this);
81 }
82
83 wxBrush::wxBrush(const wxBitmap& stipple)
84 {
85 m_refData = new wxBrushRefData;
86
87 M_BRUSHDATA->m_style = wxSTIPPLE;
88 M_BRUSHDATA->m_stipple = stipple;
89
90 RealizeResource();
91
92 if ( wxTheBrushList )
93 wxTheBrushList->AddBrush(this);
94 }
95
96 void wxBrush::Unshare()
97 {
98 // Don't change shared data
99 if (!m_refData)
100 {
101 m_refData = new wxBrushRefData();
102 }
103 else
104 {
105 wxBrushRefData* ref = new wxBrushRefData(*(wxBrushRefData*)m_refData);
106 UnRef();
107 m_refData = ref;
108 }
109 }
110
111 void wxBrush::SetColour(const wxColour& col)
112 {
113 Unshare();
114
115 M_BRUSHDATA->m_colour = col;
116
117 RealizeResource();
118 }
119
120 void wxBrush::SetColour(const wxString& col)
121 {
122 Unshare();
123
124 M_BRUSHDATA->m_colour = col;
125
126 RealizeResource();
127 }
128
129 void wxBrush::SetColour(const unsigned char r, const unsigned char g, const unsigned char b)
130 {
131 Unshare();
132
133 M_BRUSHDATA->m_colour.Set(r, g, b);
134
135 RealizeResource();
136 }
137
138 void wxBrush::SetStyle(int Style)
139 {
140 Unshare();
141
142 M_BRUSHDATA->m_style = Style;
143
144 RealizeResource();
145 }
146
147 void wxBrush::SetStipple(const wxBitmap& Stipple)
148 {
149 Unshare();
150
151 M_BRUSHDATA->m_stipple = Stipple;
152
153 RealizeResource();
154 }
155
156 void wxBrush::RealizeResource()
157 {
158 // TODO: create the brush
159 }
160