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