]> git.saurik.com Git - wxWidgets.git/blame_incremental - src/x11/pen.cpp
added vendor display name (for consistency with app display name &c) (patch 1831303)
[wxWidgets.git] / src / x11 / pen.cpp
... / ...
CommitLineData
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// for compilers that support precompilation, includes "wx.h".
13#include "wx/wxprec.h"
14
15#include "wx/pen.h"
16
17#ifndef WX_PRECOMP
18 #include "wx/utils.h"
19 #include "wx/bitmap.h"
20 #include "wx/colour.h"
21#endif
22
23//-----------------------------------------------------------------------------
24// wxPen
25//-----------------------------------------------------------------------------
26
27class wxPenRefData: public wxObjectRefData
28{
29public:
30 wxPenRefData()
31 {
32 m_width = 1;
33 m_style = wxSOLID;
34 m_joinStyle = wxJOIN_ROUND;
35 m_capStyle = wxCAP_ROUND;
36 m_dash = (wxX11Dash*) NULL;
37 m_countDashes = 0;
38 }
39
40 wxPenRefData( const wxPenRefData& data )
41 {
42 m_style = data.m_style;
43 m_width = data.m_width;
44 m_joinStyle = data.m_joinStyle;
45 m_capStyle = data.m_capStyle;
46 m_colour = data.m_colour;
47 m_countDashes = data.m_countDashes;
48/*
49 if (data.m_dash) TODO
50 m_dash = new
51*/
52 m_dash = data.m_dash;
53 m_stipple = data.m_stipple;
54 }
55
56 bool operator == (const wxPenRefData& data) const
57 {
58 return (m_style == data.m_style &&
59 m_width == data.m_width &&
60 m_joinStyle == data.m_joinStyle &&
61 m_capStyle == data.m_capStyle &&
62 m_colour == data.m_colour);
63 }
64
65 int m_width;
66 int m_style;
67 int m_joinStyle;
68 int m_capStyle;
69 wxColour m_colour;
70 int m_countDashes;
71 wxBitmap m_stipple;
72 wxX11Dash *m_dash;
73};
74
75//-----------------------------------------------------------------------------
76
77#define M_PENDATA ((wxPenRefData *)m_refData)
78
79IMPLEMENT_DYNAMIC_CLASS(wxPen,wxGDIObject)
80
81wxPen::wxPen( const wxColour &colour, int width, int style )
82{
83 m_refData = new wxPenRefData();
84 M_PENDATA->m_width = width;
85 M_PENDATA->m_style = style;
86 M_PENDATA->m_colour = colour;
87}
88
89wxPen::~wxPen()
90{
91 // m_refData unrefed in ~wxObject
92}
93
94wxObjectRefData *wxPen::CreateRefData() const
95{
96 return new wxPenRefData;
97}
98
99wxObjectRefData *wxPen::CloneRefData(const wxObjectRefData *data) const
100{
101 return new wxPenRefData(*(wxPenRefData *)data);
102}
103
104bool wxPen::operator == ( const wxPen& pen ) const
105{
106 if (m_refData == pen.m_refData) return true;
107
108 if (!m_refData || !pen.m_refData) return false;
109
110 return ( *(wxPenRefData*)m_refData == *(wxPenRefData*)pen.m_refData );
111}
112
113void wxPen::SetColour( const wxColour &colour )
114{
115 AllocExclusive();
116
117 M_PENDATA->m_colour = colour;
118}
119
120void wxPen::SetDashes( int number_of_dashes, const wxDash *dash )
121{
122 AllocExclusive();
123
124 M_PENDATA->m_countDashes = number_of_dashes;
125 M_PENDATA->m_dash = (wxX11Dash *)dash; // TODO
126}
127
128void wxPen::SetColour( unsigned char red, unsigned char green, unsigned char blue )
129{
130 AllocExclusive();
131
132 M_PENDATA->m_colour.Set( red, green, blue );
133}
134
135void wxPen::SetCap( int capStyle )
136{
137 AllocExclusive();
138
139 M_PENDATA->m_capStyle = capStyle;
140}
141
142void wxPen::SetJoin( int joinStyle )
143{
144 AllocExclusive();
145
146 M_PENDATA->m_joinStyle = joinStyle;
147}
148
149void wxPen::SetStipple( wxBitmap *stipple )
150{
151 AllocExclusive();
152
153 M_PENDATA->m_stipple = *stipple;
154}
155
156void wxPen::SetStyle( int style )
157{
158 AllocExclusive();
159
160 M_PENDATA->m_style = style;
161}
162
163void wxPen::SetWidth( int width )
164{
165 AllocExclusive();
166
167 M_PENDATA->m_width = width;
168}
169
170int wxPen::GetDashes( wxDash **ptr ) const
171{
172 *ptr = (M_PENDATA ? (wxDash*)M_PENDATA->m_dash : (wxDash*) NULL);
173 return (M_PENDATA ? M_PENDATA->m_countDashes : 0);
174}
175
176int wxPen::GetDashCount() const
177{
178 return (M_PENDATA->m_countDashes);
179}
180
181wxDash* wxPen::GetDash() const
182{
183 return (wxDash*)M_PENDATA->m_dash;
184}
185
186int wxPen::GetCap() const
187{
188 wxCHECK_MSG( Ok(), -1, wxT("invalid pen") );
189
190 return M_PENDATA->m_capStyle;
191}
192
193int wxPen::GetJoin() const
194{
195 wxCHECK_MSG( Ok(), -1, wxT("invalid pen") );
196
197 return M_PENDATA->m_joinStyle;
198}
199
200int wxPen::GetStyle() const
201{
202 wxCHECK_MSG( Ok(), -1, wxT("invalid pen") );
203
204 return M_PENDATA->m_style;
205}
206
207int wxPen::GetWidth() const
208{
209 wxCHECK_MSG( Ok(), -1, wxT("invalid pen") );
210
211 return M_PENDATA->m_width;
212}
213
214wxColour &wxPen::GetColour() const
215{
216 wxCHECK_MSG( Ok(), wxNullColour, wxT("invalid pen") );
217
218 return M_PENDATA->m_colour;
219}
220
221wxBitmap *wxPen::GetStipple() const
222{
223 wxCHECK_MSG( Ok(), &wxNullBitmap, wxT("invalid pen") );
224
225 return &M_PENDATA->m_stipple;
226}