]> git.saurik.com Git - wxWidgets.git/blob - src/x11/pen.cpp
fix wxExecute() return code checks and removed not working code to open URLs in new...
[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 #include "wx/setup.h"
13 #include "wx/utils.h"
14 #include "wx/pen.h"
15 #include "wx/colour.h"
16 #include "wx/bitmap.h"
17
18 //-----------------------------------------------------------------------------
19 // wxPen
20 //-----------------------------------------------------------------------------
21
22 class wxPenRefData: public wxObjectRefData
23 {
24 public:
25 wxPenRefData()
26 {
27 m_width = 1;
28 m_style = wxSOLID;
29 m_joinStyle = wxJOIN_ROUND;
30 m_capStyle = wxCAP_ROUND;
31 m_dash = (wxX11Dash*) NULL;
32 m_countDashes = 0;
33 }
34
35 wxPenRefData( const wxPenRefData& data )
36 {
37 m_style = data.m_style;
38 m_width = data.m_width;
39 m_joinStyle = data.m_joinStyle;
40 m_capStyle = data.m_capStyle;
41 m_colour = data.m_colour;
42 m_countDashes = data.m_countDashes;
43 /*
44 if (data.m_dash) TODO
45 m_dash = new
46 */
47 m_dash = data.m_dash;
48 m_stipple = data.m_stipple;
49 }
50
51 bool operator == (const wxPenRefData& data) const
52 {
53 return (m_style == data.m_style &&
54 m_width == data.m_width &&
55 m_joinStyle == data.m_joinStyle &&
56 m_capStyle == data.m_capStyle &&
57 m_colour == data.m_colour);
58 }
59
60 int m_width;
61 int m_style;
62 int m_joinStyle;
63 int m_capStyle;
64 wxColour m_colour;
65 int m_countDashes;
66 wxBitmap m_stipple;
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::SetStipple( wxBitmap *stipple )
145 {
146 AllocExclusive();
147
148 M_PENDATA->m_stipple = *stipple;;
149 }
150
151 void wxPen::SetStyle( int style )
152 {
153 AllocExclusive();
154
155 M_PENDATA->m_style = style;
156 }
157
158 void wxPen::SetWidth( int width )
159 {
160 AllocExclusive();
161
162 M_PENDATA->m_width = width;
163 }
164
165 int wxPen::GetDashes( wxDash **ptr ) const
166 {
167 *ptr = (M_PENDATA ? (wxDash*)M_PENDATA->m_dash : (wxDash*) NULL);
168 return (M_PENDATA ? M_PENDATA->m_countDashes : 0);
169 }
170
171 int wxPen::GetDashCount() const
172 {
173 return (M_PENDATA->m_countDashes);
174 }
175
176 wxDash* wxPen::GetDash() const
177 {
178 return (wxDash*)M_PENDATA->m_dash;
179 }
180
181 int wxPen::GetCap() const
182 {
183 wxCHECK_MSG( Ok(), -1, wxT("invalid pen") );
184
185 return M_PENDATA->m_capStyle;
186 }
187
188 int wxPen::GetJoin() const
189 {
190 wxCHECK_MSG( Ok(), -1, wxT("invalid pen") );
191
192 return M_PENDATA->m_joinStyle;
193 }
194
195 int wxPen::GetStyle() const
196 {
197 wxCHECK_MSG( Ok(), -1, wxT("invalid pen") );
198
199 return M_PENDATA->m_style;
200 }
201
202 int wxPen::GetWidth() const
203 {
204 wxCHECK_MSG( Ok(), -1, wxT("invalid pen") );
205
206 return M_PENDATA->m_width;
207 }
208
209 wxColour &wxPen::GetColour() const
210 {
211 wxCHECK_MSG( Ok(), wxNullColour, wxT("invalid pen") );
212
213 return M_PENDATA->m_colour;
214 }
215
216 wxBitmap *wxPen::GetStipple() const
217 {
218 wxCHECK_MSG( Ok(), &wxNullBitmap, wxT("invalid pen") );
219
220 return &M_PENDATA->m_stipple;
221 }