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