]> git.saurik.com Git - wxWidgets.git/blob - src/mac/carbon/pen.cpp
VTK wrapper of vtkRenderWindow for wxPython. Tested on MSW so far.
[wxWidgets.git] / src / mac / carbon / 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 void wxPen::Unshare()
108 {
109 // Don't change shared data
110 if (!m_refData)
111 {
112 m_refData = new wxPenRefData();
113 }
114 else
115 {
116 wxPenRefData* ref = new wxPenRefData(*(wxPenRefData*)m_refData);
117 UnRef();
118 m_refData = ref;
119 }
120 }
121
122 void wxPen::SetColour(const wxColour& col)
123 {
124 Unshare();
125
126 M_PENDATA->m_colour = col;
127
128 RealizeResource();
129 }
130
131 void wxPen::SetColour(unsigned char r, unsigned char g, unsigned char b)
132 {
133 Unshare();
134
135 M_PENDATA->m_colour.Set(r, g, b);
136
137 RealizeResource();
138 }
139
140 void wxPen::SetWidth(int Width)
141 {
142 Unshare();
143
144 M_PENDATA->m_width = Width;
145
146 RealizeResource();
147 }
148
149 void wxPen::SetStyle(int Style)
150 {
151 Unshare();
152
153 M_PENDATA->m_style = Style;
154
155 RealizeResource();
156 }
157
158 void wxPen::SetStipple(const wxBitmap& Stipple)
159 {
160 Unshare();
161
162 M_PENDATA->m_stipple = Stipple;
163 M_PENDATA->m_style = wxSTIPPLE;
164
165 RealizeResource();
166 }
167
168 void wxPen::SetDashes(int nb_dashes, const wxDash *Dash)
169 {
170 Unshare();
171
172 M_PENDATA->m_nbDash = nb_dashes;
173 M_PENDATA->m_dash = (wxDash *)Dash;
174
175 RealizeResource();
176 }
177
178 void wxPen::SetJoin(int Join)
179 {
180 Unshare();
181
182 M_PENDATA->m_join = Join;
183
184 RealizeResource();
185 }
186
187 void wxPen::SetCap(int Cap)
188 {
189 Unshare();
190
191 M_PENDATA->m_cap = Cap;
192
193 RealizeResource();
194 }
195
196 bool wxPen::RealizeResource()
197 {
198 // TODO: create actual pen
199 return FALSE;
200 }
201
202