]> git.saurik.com Git - wxWidgets.git/blob - src/mac/carbon/pen.cpp
Applied patch [ 1215991 ] Mac xrc enables unknown class
[wxWidgets.git] / src / mac / carbon / pen.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: pen.cpp
3 // Purpose: wxPen
4 // Author: Stefan Csomor
5 // Modified by:
6 // Created: 1998-01-01
7 // RCS-ID: $Id$
8 // Copyright: (c) Stefan Csomor
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
13 #pragma implementation "pen.h"
14 #endif
15
16 #include "wx/wxprec.h"
17
18 #include "wx/utils.h"
19 #include "wx/pen.h"
20
21 #if !USE_SHARED_LIBRARIES
22 IMPLEMENT_DYNAMIC_CLASS(wxPen, wxGDIObject)
23 #endif
24
25 wxPenRefData::wxPenRefData()
26 {
27 m_style = wxSOLID;
28 m_width = 1;
29 m_join = wxJOIN_ROUND ;
30 m_cap = wxCAP_ROUND ;
31 m_nbDash = 0 ;
32 m_dash = 0 ;
33 }
34
35 wxPenRefData::wxPenRefData(const wxPenRefData& data)
36 : wxGDIRefData()
37 {
38 m_style = data.m_style;
39 m_width = data.m_width;
40 m_join = data.m_join;
41 m_cap = data.m_cap;
42 m_nbDash = data.m_nbDash;
43 m_dash = data.m_dash;
44 m_colour = data.m_colour;
45 }
46
47 wxPenRefData::~wxPenRefData()
48 {
49 }
50
51 // Pens
52
53 wxPen::wxPen()
54 {
55 }
56
57 wxPen::~wxPen()
58 {
59 }
60
61 // Should implement Create
62 wxPen::wxPen(const wxColour& col, int Width, int Style)
63 {
64 m_refData = new wxPenRefData;
65
66 M_PENDATA->m_colour = col;
67 M_PENDATA->m_width = Width;
68 M_PENDATA->m_style = Style;
69 M_PENDATA->m_join = wxJOIN_ROUND ;
70 M_PENDATA->m_cap = wxCAP_ROUND ;
71 M_PENDATA->m_nbDash = 0 ;
72 M_PENDATA->m_dash = 0 ;
73
74 RealizeResource();
75 }
76
77 wxPen::wxPen(const wxBitmap& stipple, int Width)
78 {
79 m_refData = new wxPenRefData;
80
81 M_PENDATA->m_stipple = stipple;
82 M_PENDATA->m_width = Width;
83 M_PENDATA->m_style = wxSTIPPLE;
84 M_PENDATA->m_join = wxJOIN_ROUND ;
85 M_PENDATA->m_cap = wxCAP_ROUND ;
86 M_PENDATA->m_nbDash = 0 ;
87 M_PENDATA->m_dash = 0 ;
88
89 RealizeResource();
90 }
91
92 void wxPen::Unshare()
93 {
94 // Don't change shared data
95 if (!m_refData)
96 {
97 m_refData = new wxPenRefData();
98 }
99 else
100 {
101 wxPenRefData* ref = new wxPenRefData(*(wxPenRefData*)m_refData);
102 UnRef();
103 m_refData = ref;
104 }
105 }
106
107 void wxPen::SetColour(const wxColour& col)
108 {
109 Unshare();
110
111 M_PENDATA->m_colour = col;
112
113 RealizeResource();
114 }
115
116 void wxPen::SetColour(unsigned char r, unsigned char g, unsigned char b)
117 {
118 Unshare();
119
120 M_PENDATA->m_colour.Set(r, g, b);
121
122 RealizeResource();
123 }
124
125 void wxPen::SetWidth(int Width)
126 {
127 Unshare();
128
129 M_PENDATA->m_width = Width;
130
131 RealizeResource();
132 }
133
134 void wxPen::SetStyle(int Style)
135 {
136 Unshare();
137
138 M_PENDATA->m_style = Style;
139
140 RealizeResource();
141 }
142
143 void wxPen::SetStipple(const wxBitmap& Stipple)
144 {
145 Unshare();
146
147 M_PENDATA->m_stipple = Stipple;
148 M_PENDATA->m_style = wxSTIPPLE;
149
150 RealizeResource();
151 }
152
153 void wxPen::SetDashes(int nb_dashes, const wxDash *Dash)
154 {
155 Unshare();
156
157 M_PENDATA->m_nbDash = nb_dashes;
158 M_PENDATA->m_dash = (wxDash *)Dash;
159
160 RealizeResource();
161 }
162
163 void wxPen::SetJoin(int Join)
164 {
165 Unshare();
166
167 M_PENDATA->m_join = Join;
168
169 RealizeResource();
170 }
171
172 void wxPen::SetCap(int Cap)
173 {
174 Unshare();
175
176 M_PENDATA->m_cap = Cap;
177
178 RealizeResource();
179 }
180
181 bool wxPen::RealizeResource()
182 {
183 // nothing to do here for mac
184 return TRUE;
185 }
186
187