]> git.saurik.com Git - wxWidgets.git/blame_incremental - src/gtk1/pen.cpp
remove executable property from non-executable files, closes #15504
[wxWidgets.git] / src / gtk1 / pen.cpp
... / ...
CommitLineData
1/////////////////////////////////////////////////////////////////////////////
2// Name: src/gtk1/pen.cpp
3// Purpose:
4// Author: Robert Roebling
5// Copyright: (c) 1998 Robert Roebling
6// Licence: wxWindows licence
7/////////////////////////////////////////////////////////////////////////////
8
9// For compilers that support precompilation, includes "wx.h".
10#include "wx/wxprec.h"
11
12#include "wx/pen.h"
13
14#ifndef WX_PRECOMP
15 #include "wx/colour.h"
16#endif
17
18#include <gdk/gdk.h>
19
20//-----------------------------------------------------------------------------
21// wxPen
22//-----------------------------------------------------------------------------
23
24class wxPenRefData : public wxGDIRefData
25{
26public:
27 wxPenRefData()
28 {
29 m_width = 1;
30 m_style = wxPENSTYLE_SOLID;
31 m_joinStyle = wxJOIN_ROUND;
32 m_capStyle = wxCAP_ROUND;
33 m_dash = NULL;
34 m_countDashes = 0;
35 }
36
37 wxPenRefData( const wxPenRefData& data )
38 : wxGDIRefData()
39 {
40 m_style = data.m_style;
41 m_width = data.m_width;
42 m_joinStyle = data.m_joinStyle;
43 m_capStyle = data.m_capStyle;
44 m_colour = data.m_colour;
45 m_countDashes = data.m_countDashes;
46 m_dash = data.m_dash;
47 }
48
49 bool operator == (const wxPenRefData& data) const
50 {
51 if ( m_countDashes != data.m_countDashes )
52 return false;
53
54 if ( m_dash )
55 {
56 if ( !data.m_dash ||
57 memcmp(m_dash, data.m_dash, m_countDashes*sizeof(wxGTKDash)) )
58 {
59 return false;
60 }
61 }
62 else if ( data.m_dash )
63 {
64 return false;
65 }
66
67
68 return m_style == data.m_style &&
69 m_width == data.m_width &&
70 m_joinStyle == data.m_joinStyle &&
71 m_capStyle == data.m_capStyle &&
72 m_colour == data.m_colour;
73 }
74
75 int m_width;
76 wxPenStyle m_style;
77 wxPenJoin m_joinStyle;
78 wxPenCap m_capStyle;
79 wxColour m_colour;
80 int m_countDashes;
81 wxGTKDash *m_dash;
82};
83
84//-----------------------------------------------------------------------------
85
86#define M_PENDATA ((wxPenRefData *)m_refData)
87
88IMPLEMENT_DYNAMIC_CLASS(wxPen,wxGDIObject)
89
90wxPen::wxPen( const wxColour &colour, int width, wxPenStyle style )
91{
92 m_refData = new wxPenRefData();
93 M_PENDATA->m_width = width;
94 M_PENDATA->m_style = style;
95 M_PENDATA->m_colour = colour;
96}
97
98#if FUTURE_WXWIN_COMPATIBILITY_3_0
99wxPen::wxPen(const wxColour& colour, int width, int style)
100{
101 m_refData = new wxPenRefData();
102 M_PENDATA->m_width = width;
103 M_PENDATA->m_style = (wxPenStyle)style;
104 M_PENDATA->m_colour = colour;
105}
106#endif
107
108wxGDIRefData *wxPen::CreateGDIRefData() const
109{
110 return new wxPenRefData;
111}
112
113wxGDIRefData *wxPen::CloneGDIRefData(const wxGDIRefData *data) const
114{
115 return new wxPenRefData(*(wxPenRefData *)data);
116}
117
118bool wxPen::operator == ( const wxPen& pen ) const
119{
120 if (m_refData == pen.m_refData) return true;
121
122 if (!m_refData || !pen.m_refData) return false;
123
124 return *(wxPenRefData*)m_refData == *(wxPenRefData*)pen.m_refData;
125}
126
127void wxPen::SetColour( const wxColour &colour )
128{
129 AllocExclusive();
130
131 M_PENDATA->m_colour = colour;
132}
133
134void wxPen::SetDashes( int number_of_dashes, const wxDash *dash )
135{
136 AllocExclusive();
137
138 M_PENDATA->m_countDashes = number_of_dashes;
139 M_PENDATA->m_dash = (wxGTKDash *)dash;
140}
141
142void wxPen::SetColour( unsigned char red, unsigned char green, unsigned char blue )
143{
144 AllocExclusive();
145
146 M_PENDATA->m_colour.Set( red, green, blue );
147}
148
149void wxPen::SetCap( wxPenCap capStyle )
150{
151 AllocExclusive();
152
153 M_PENDATA->m_capStyle = capStyle;
154}
155
156void wxPen::SetJoin( wxPenJoin joinStyle )
157{
158 AllocExclusive();
159
160 M_PENDATA->m_joinStyle = joinStyle;
161}
162
163void wxPen::SetStyle( wxPenStyle style )
164{
165 AllocExclusive();
166
167 M_PENDATA->m_style = style;
168}
169
170void wxPen::SetWidth( int width )
171{
172 AllocExclusive();
173
174 M_PENDATA->m_width = width;
175}
176
177void wxPen::SetStipple(const wxBitmap& WXUNUSED(stipple))
178{
179 wxFAIL_MSG( "stippled pens not supported" );
180}
181
182int wxPen::GetDashes( wxDash **ptr ) const
183{
184 wxCHECK_MSG( IsOk(), -1, wxT("invalid pen") );
185
186 *ptr = (wxDash*)M_PENDATA->m_dash;
187 return M_PENDATA->m_countDashes;
188}
189
190int wxPen::GetDashCount() const
191{
192 wxCHECK_MSG( IsOk(), -1, wxT("invalid pen") );
193
194 return (M_PENDATA->m_countDashes);
195}
196
197wxDash* wxPen::GetDash() const
198{
199 wxCHECK_MSG( IsOk(), NULL, wxT("invalid pen") );
200
201 return (wxDash*)M_PENDATA->m_dash;
202}
203
204wxPenCap wxPen::GetCap() const
205{
206 wxCHECK_MSG( IsOk(), wxCAP_INVALID, wxT("invalid pen") );
207
208 return M_PENDATA->m_capStyle;
209}
210
211wxPenJoin wxPen::GetJoin() const
212{
213 wxCHECK_MSG( IsOk(), wxJOIN_INVALID, wxT("invalid pen") );
214
215 return M_PENDATA->m_joinStyle;
216}
217
218wxPenStyle wxPen::GetStyle() const
219{
220 wxCHECK_MSG( IsOk(), wxPENSTYLE_INVALID, wxT("invalid pen") );
221
222 return M_PENDATA->m_style;
223}
224
225int wxPen::GetWidth() const
226{
227 wxCHECK_MSG( IsOk(), -1, wxT("invalid pen") );
228
229 return M_PENDATA->m_width;
230}
231
232wxColour wxPen::GetColour() const
233{
234 wxCHECK_MSG( IsOk(), wxNullColour, wxT("invalid pen") );
235
236 return M_PENDATA->m_colour;
237}
238
239wxBitmap *wxPen::GetStipple() const
240{
241 return NULL;
242}
243