]> git.saurik.com Git - wxWidgets.git/blob - src/x11/pen.cpp
Fixed usage of wxXmString
[wxWidgets.git] / src / x11 / pen.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/x11/pen.cpp
3 // Purpose: wxPen
4 // Author: Julian Smart
5 // Modified by:
6 // Created: 17/09/98
7 // RCS-ID: $Id$
8 // Copyright: (c) Julian Smart
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 //-----------------------------------------------------------------------------
21 // wxPen
22 //-----------------------------------------------------------------------------
23
24 class wxPenRefData: public wxObjectRefData
25 {
26 public:
27 wxPenRefData()
28 {
29 m_width = 1;
30 m_style = wxSOLID;
31 m_joinStyle = wxJOIN_ROUND;
32 m_capStyle = wxCAP_ROUND;
33 m_dash = (wxX11Dash*) NULL;
34 m_countDashes = 0;
35 }
36
37 wxPenRefData( const wxPenRefData& data )
38 {
39 m_style = data.m_style;
40 m_width = data.m_width;
41 m_joinStyle = data.m_joinStyle;
42 m_capStyle = data.m_capStyle;
43 m_colour = data.m_colour;
44 m_countDashes = data.m_countDashes;
45 /*
46 if (data.m_dash) TODO
47 m_dash = new
48 */
49 m_dash = data.m_dash;
50 }
51
52 bool operator == (const wxPenRefData& data) const
53 {
54 return (m_style == data.m_style &&
55 m_width == data.m_width &&
56 m_joinStyle == data.m_joinStyle &&
57 m_capStyle == data.m_capStyle &&
58 m_colour == data.m_colour);
59 }
60
61 int m_width;
62 int m_style;
63 int m_joinStyle;
64 int m_capStyle;
65 wxColour m_colour;
66 int m_countDashes;
67 wxX11Dash *m_dash;
68 };
69
70 //-----------------------------------------------------------------------------
71
72 #define M_PENDATA ((wxPenRefData *)m_refData)
73
74 IMPLEMENT_DYNAMIC_CLASS(wxPen,wxGDIObject)
75
76 wxPen::wxPen( const wxColour &colour, int width, int style )
77 {
78 m_refData = new wxPenRefData();
79 M_PENDATA->m_width = width;
80 M_PENDATA->m_style = style;
81 M_PENDATA->m_colour = colour;
82 }
83
84 wxPen::~wxPen()
85 {
86 // m_refData unrefed in ~wxObject
87 }
88
89 wxObjectRefData *wxPen::CreateRefData() const
90 {
91 return new wxPenRefData;
92 }
93
94 wxObjectRefData *wxPen::CloneRefData(const wxObjectRefData *data) const
95 {
96 return new wxPenRefData(*(wxPenRefData *)data);
97 }
98
99 bool wxPen::operator == ( const wxPen& pen ) const
100 {
101 if (m_refData == pen.m_refData) return TRUE;
102
103 if (!m_refData || !pen.m_refData) return FALSE;
104
105 return ( *(wxPenRefData*)m_refData == *(wxPenRefData*)pen.m_refData );
106 }
107
108 void wxPen::SetColour( const wxColour &colour )
109 {
110 AllocExclusive();
111
112 M_PENDATA->m_colour = colour;
113 }
114
115 void wxPen::SetDashes( int number_of_dashes, const wxDash *dash )
116 {
117 AllocExclusive();
118
119 M_PENDATA->m_countDashes = number_of_dashes;
120 M_PENDATA->m_dash = (wxX11Dash *)dash; // TODO
121 }
122
123 void wxPen::SetColour( int red, int green, int blue )
124 {
125 AllocExclusive();
126
127 M_PENDATA->m_colour.Set( red, green, blue );
128 }
129
130 void wxPen::SetCap( int capStyle )
131 {
132 AllocExclusive();
133
134 M_PENDATA->m_capStyle = capStyle;
135 }
136
137 void wxPen::SetJoin( int joinStyle )
138 {
139 AllocExclusive();
140
141 M_PENDATA->m_joinStyle = joinStyle;
142 }
143
144 void wxPen::SetStyle( int style )
145 {
146 AllocExclusive();
147
148 M_PENDATA->m_style = style;
149 }
150
151 void wxPen::SetWidth( int width )
152 {
153 AllocExclusive();
154
155 M_PENDATA->m_width = width;
156 }
157
158 int wxPen::GetDashes( wxDash **ptr ) const
159 {
160 *ptr = (M_PENDATA ? (wxDash*)M_PENDATA->m_dash : (wxDash*) NULL);
161 return (M_PENDATA ? M_PENDATA->m_countDashes : 0);
162 }
163
164 int wxPen::GetDashCount() const
165 {
166 return (M_PENDATA->m_countDashes);
167 }
168
169 wxDash* wxPen::GetDash() const
170 {
171 return (wxDash*)M_PENDATA->m_dash;
172 }
173
174 int wxPen::GetCap() const
175 {
176 wxCHECK_MSG( Ok(), -1, wxT("invalid pen") );
177
178 return M_PENDATA->m_capStyle;
179 }
180
181 int wxPen::GetJoin() const
182 {
183 wxCHECK_MSG( Ok(), -1, wxT("invalid pen") );
184
185 return M_PENDATA->m_joinStyle;
186 }
187
188 int wxPen::GetStyle() const
189 {
190 wxCHECK_MSG( Ok(), -1, wxT("invalid pen") );
191
192 return M_PENDATA->m_style;
193 }
194
195 int wxPen::GetWidth() const
196 {
197 wxCHECK_MSG( Ok(), -1, wxT("invalid pen") );
198
199 return M_PENDATA->m_width;
200 }
201
202 wxColour &wxPen::GetColour() const
203 {
204 wxCHECK_MSG( Ok(), wxNullColour, wxT("invalid pen") );
205
206 return M_PENDATA->m_colour;
207 }