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