]> git.saurik.com Git - wxWidgets.git/blob - src/stubs/pen.cpp
Some more Motif work; included utils.h in fileconf.cpp (for wxGetHomeDir or something)
[wxWidgets.git] / src / stubs / pen.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: pen.cpp
3 // Purpose: wxPen
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 "pen.h"
14 #endif
15
16 #include "wx/setup.h"
17 #include "wx/utils.h"
18 #include "wx/pen.h"
19
20 #if !USE_SHARED_LIBRARIES
21 IMPLEMENT_DYNAMIC_CLASS(wxPen, wxGDIObject)
22 #endif
23
24 wxPenRefData::wxPenRefData()
25 {
26 m_style = wxSOLID;
27 m_width = 1;
28 m_join = wxJOIN_ROUND ;
29 m_cap = wxCAP_ROUND ;
30 m_nbDash = 0 ;
31 m_dash = 0 ;
32 /* TODO: null data
33 m_hPen = 0;
34 */
35 }
36
37 wxPenRefData::wxPenRefData(const wxPenRefData& data)
38 {
39 m_style = data.m_style;
40 m_width = data.m_width;
41 m_join = data.m_join;
42 m_cap = data.m_cap;
43 m_nbDash = data.m_nbDash;
44 m_dash = data.m_dash;
45 m_colour = data.m_colour;
46 /* TODO: null data
47 m_hPen = 0;
48 */
49 }
50
51 wxPenRefData::~wxPenRefData()
52 {
53 // TODO: delete data
54 }
55
56 // Pens
57
58 wxPen::wxPen()
59 {
60 if ( wxThePenList )
61 wxThePenList->AddPen(this);
62 }
63
64 wxPen::~wxPen()
65 {
66 if (wxThePenList)
67 wxThePenList->RemovePen(this);
68 }
69
70 // Should implement Create
71 wxPen::wxPen(const wxColour& col, int Width, int Style)
72 {
73 m_refData = new wxPenRefData;
74
75 M_PENDATA->m_colour = col;
76 M_PENDATA->m_width = Width;
77 M_PENDATA->m_style = Style;
78 M_PENDATA->m_join = wxJOIN_ROUND ;
79 M_PENDATA->m_cap = wxCAP_ROUND ;
80 M_PENDATA->m_nbDash = 0 ;
81 M_PENDATA->m_dash = 0 ;
82
83 RealizeResource();
84
85 if ( wxThePenList )
86 wxThePenList->AddPen(this);
87 }
88
89 wxPen::wxPen(const wxBitmap& stipple, int Width)
90 {
91 m_refData = new wxPenRefData;
92
93 M_PENDATA->m_stipple = stipple;
94 M_PENDATA->m_width = Width;
95 M_PENDATA->m_style = wxSTIPPLE;
96 M_PENDATA->m_join = wxJOIN_ROUND ;
97 M_PENDATA->m_cap = wxCAP_ROUND ;
98 M_PENDATA->m_nbDash = 0 ;
99 M_PENDATA->m_dash = 0 ;
100
101 RealizeResource();
102
103 if ( wxThePenList )
104 wxThePenList->AddPen(this);
105 }
106
107 wxPen::wxPen(const wxString& col, int Width, int Style)
108 {
109 m_refData = new wxPenRefData;
110
111 M_PENDATA->m_colour = col;
112 M_PENDATA->m_width = Width;
113 M_PENDATA->m_style = Style;
114 M_PENDATA->m_join = wxJOIN_ROUND ;
115 M_PENDATA->m_cap = wxCAP_ROUND ;
116 M_PENDATA->m_nbDash = 0 ;
117 M_PENDATA->m_dash = 0 ;
118
119 RealizeResource();
120
121 if ( wxThePenList )
122 wxThePenList->AddPen(this);
123 }
124
125 void wxPen::Unshare()
126 {
127 // Don't change shared data
128 if (!m_refData)
129 {
130 m_refData = new wxPenRefData();
131 }
132 else
133 {
134 wxPenRefData* ref = new wxPenRefData(*(wxPenRefData*)m_refData);
135 UnRef();
136 m_refData = ref;
137 }
138 }
139
140 void wxPen::SetColour(const wxColour& col)
141 {
142 Unshare();
143
144 M_PENDATA->m_colour = col;
145
146 RealizeResource();
147 }
148
149 void wxPen::SetColour(const wxString& col)
150 {
151 Unshare();
152
153 M_PENDATA->m_colour = col;
154
155 RealizeResource();
156 }
157
158 void wxPen::SetColour(const unsigned char r, const unsigned char g, const unsigned char b)
159 {
160 Unshare();
161
162 M_PENDATA->m_colour.Set(r, g, b);
163
164 RealizeResource();
165 }
166
167 void wxPen::SetWidth(int Width)
168 {
169 Unshare();
170
171 M_PENDATA->m_width = Width;
172
173 RealizeResource();
174 }
175
176 void wxPen::SetStyle(int Style)
177 {
178 Unshare();
179
180 M_PENDATA->m_style = Style;
181
182 RealizeResource();
183 }
184
185 void wxPen::SetStipple(const wxBitmap& Stipple)
186 {
187 Unshare();
188
189 M_PENDATA->m_stipple = Stipple;
190 M_PENDATA->m_style = wxSTIPPLE;
191
192 RealizeResource();
193 }
194
195 void wxPen::SetDashes(int nb_dashes, const wxDash *Dash)
196 {
197 Unshare();
198
199 M_PENDATA->m_nbDash = nb_dashes;
200 M_PENDATA->m_dash = (wxDash *)Dash;
201
202 RealizeResource();
203 }
204
205 void wxPen::SetJoin(int Join)
206 {
207 Unshare();
208
209 M_PENDATA->m_join = Join;
210
211 RealizeResource();
212 }
213
214 void wxPen::SetCap(int Cap)
215 {
216 Unshare();
217
218 M_PENDATA->m_cap = Cap;
219
220 RealizeResource();
221 }
222
223 bool wxPen::RealizeResource()
224 {
225 // TODO: create actual pen
226 return FALSE;
227 }
228
229