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