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