]> git.saurik.com Git - wxWidgets.git/blob - src/mac/carbon/pen.cpp
cleanup:
[wxWidgets.git] / src / mac / carbon / pen.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/mac/carbon/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 #include "wx/wxprec.h"
13
14 #include "wx/pen.h"
15
16 #ifndef WX_PRECOMP
17 #include "wx/utils.h"
18 #endif
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 = 0 ;
30 }
31
32 wxPenRefData::wxPenRefData(const wxPenRefData& data)
33 : wxGDIRefData()
34 {
35 m_style = data.m_style;
36 m_width = data.m_width;
37 m_join = data.m_join;
38 m_cap = data.m_cap;
39 m_nbDash = data.m_nbDash;
40 m_dash = data.m_dash;
41 m_colour = data.m_colour;
42 }
43
44 wxPenRefData::~wxPenRefData()
45 {
46 }
47
48 // Pens
49
50 wxPen::wxPen()
51 {
52 }
53
54 wxPen::~wxPen()
55 {
56 }
57
58 // Should implement Create
59 wxPen::wxPen(const wxColour& col, int Width, int Style)
60 {
61 m_refData = new wxPenRefData;
62
63 M_PENDATA->m_colour = col;
64 M_PENDATA->m_width = Width;
65 M_PENDATA->m_style = Style;
66 M_PENDATA->m_join = wxJOIN_ROUND ;
67 M_PENDATA->m_cap = wxCAP_ROUND ;
68 M_PENDATA->m_nbDash = 0 ;
69 M_PENDATA->m_dash = 0 ;
70
71 RealizeResource();
72 }
73
74 wxPen::wxPen(const wxBitmap& stipple, int Width)
75 {
76 m_refData = new wxPenRefData;
77
78 M_PENDATA->m_stipple = stipple;
79 M_PENDATA->m_width = Width;
80 M_PENDATA->m_style = wxSTIPPLE;
81 M_PENDATA->m_join = wxJOIN_ROUND ;
82 M_PENDATA->m_cap = wxCAP_ROUND ;
83 M_PENDATA->m_nbDash = 0 ;
84 M_PENDATA->m_dash = 0 ;
85
86 RealizeResource();
87 }
88
89 void wxPen::Unshare()
90 {
91 // Don't change shared data
92 if (!m_refData)
93 {
94 m_refData = new wxPenRefData();
95 }
96 else
97 {
98 wxPenRefData* ref = new wxPenRefData(*(wxPenRefData*)m_refData);
99 UnRef();
100 m_refData = ref;
101 }
102 }
103
104 void wxPen::SetColour(const wxColour& col)
105 {
106 Unshare();
107
108 M_PENDATA->m_colour = col;
109
110 RealizeResource();
111 }
112
113 void wxPen::SetColour(unsigned char r, unsigned char g, unsigned char b)
114 {
115 Unshare();
116
117 M_PENDATA->m_colour.Set(r, g, b);
118
119 RealizeResource();
120 }
121
122 void wxPen::SetWidth(int Width)
123 {
124 Unshare();
125
126 M_PENDATA->m_width = Width;
127
128 RealizeResource();
129 }
130
131 void wxPen::SetStyle(int Style)
132 {
133 Unshare();
134
135 M_PENDATA->m_style = Style;
136
137 RealizeResource();
138 }
139
140 void wxPen::SetStipple(const wxBitmap& Stipple)
141 {
142 Unshare();
143
144 M_PENDATA->m_stipple = Stipple;
145 M_PENDATA->m_style = wxSTIPPLE;
146
147 RealizeResource();
148 }
149
150 void wxPen::SetDashes(int nb_dashes, const wxDash *Dash)
151 {
152 Unshare();
153
154 M_PENDATA->m_nbDash = nb_dashes;
155 M_PENDATA->m_dash = (wxDash *)Dash;
156
157 RealizeResource();
158 }
159
160 void wxPen::SetJoin(int Join)
161 {
162 Unshare();
163
164 M_PENDATA->m_join = Join;
165
166 RealizeResource();
167 }
168
169 void wxPen::SetCap(int Cap)
170 {
171 Unshare();
172
173 M_PENDATA->m_cap = Cap;
174
175 RealizeResource();
176 }
177
178 bool wxPen::RealizeResource()
179 {
180 // nothing to do here for mac
181 return true;
182 }