]> git.saurik.com Git - wxWidgets.git/blob - src/gtk/pen.cpp
Removed a deprecated wxBitmap constructor, and some
[wxWidgets.git] / src / gtk / pen.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: pen.cpp
3 // Purpose:
4 // Author: Robert Roebling
5 // Id: $Id$
6 // Copyright: (c) 1998 Robert Roebling
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
9
10
11 #ifdef __GNUG__
12 #pragma implementation "pen.h"
13 #endif
14
15 #include "wx/pen.h"
16 #include "wx/colour.h"
17
18 #include <gdk/gdk.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 = (wxGTKDash*) NULL;
34 m_countDashes = 0;
35 }
36
37 wxPenRefData( const wxPenRefData& data )
38 : wxObjectRefData()
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 /*
47 if (data.m_dash) TODO
48 m_dash = new
49 */
50 m_dash = data.m_dash;
51 }
52
53 bool operator == (const wxPenRefData& data) const
54 {
55 return (m_style == data.m_style &&
56 m_width == data.m_width &&
57 m_joinStyle == data.m_joinStyle &&
58 m_capStyle == data.m_capStyle &&
59 m_colour == data.m_colour);
60 }
61
62 int m_width;
63 int m_style;
64 int m_joinStyle;
65 int m_capStyle;
66 wxColour m_colour;
67 int m_countDashes;
68 wxGTKDash *m_dash;
69 };
70
71 //-----------------------------------------------------------------------------
72
73 #define M_PENDATA ((wxPenRefData *)m_refData)
74
75 IMPLEMENT_DYNAMIC_CLASS(wxPen,wxGDIObject)
76
77 wxPen::wxPen( const wxColour &colour, int width, int style )
78 {
79 m_refData = new wxPenRefData();
80 M_PENDATA->m_width = width;
81 M_PENDATA->m_style = style;
82 M_PENDATA->m_colour = colour;
83 }
84
85 wxPen::~wxPen()
86 {
87 // m_refData unrefed in ~wxObject
88 }
89
90 wxObjectRefData *wxPen::CreateRefData() const
91 {
92 return new wxPenRefData;
93 }
94
95 wxObjectRefData *wxPen::CloneRefData(const wxObjectRefData *data) const
96 {
97 return new wxPenRefData(*(wxPenRefData *)data);
98 }
99
100 bool wxPen::operator == ( const wxPen& pen ) const
101 {
102 if (m_refData == pen.m_refData) return TRUE;
103
104 if (!m_refData || !pen.m_refData) return FALSE;
105
106 return ( *(wxPenRefData*)m_refData == *(wxPenRefData*)pen.m_refData );
107 }
108
109 void wxPen::SetColour( const wxColour &colour )
110 {
111 AllocExclusive();
112
113 M_PENDATA->m_colour = colour;
114 }
115
116 void wxPen::SetDashes( int number_of_dashes, const wxDash *dash )
117 {
118 AllocExclusive();
119
120 M_PENDATA->m_countDashes = number_of_dashes;
121 M_PENDATA->m_dash = (wxGTKDash *)dash; /* TODO */
122 }
123
124 void wxPen::SetColour( int red, int green, int blue )
125 {
126 AllocExclusive();
127
128 M_PENDATA->m_colour.Set( red, green, blue );
129 }
130
131 void wxPen::SetCap( int capStyle )
132 {
133 AllocExclusive();
134
135 M_PENDATA->m_capStyle = capStyle;
136 }
137
138 void wxPen::SetJoin( int joinStyle )
139 {
140 AllocExclusive();
141
142 M_PENDATA->m_joinStyle = joinStyle;
143 }
144
145 void wxPen::SetStyle( int style )
146 {
147 AllocExclusive();
148
149 M_PENDATA->m_style = style;
150 }
151
152 void wxPen::SetWidth( int width )
153 {
154 AllocExclusive();
155
156 M_PENDATA->m_width = width;
157 }
158
159 int wxPen::GetDashes( wxDash **ptr ) const
160 {
161 *ptr = (M_PENDATA ? (wxDash*)M_PENDATA->m_dash : (wxDash*) NULL);
162 return (M_PENDATA ? M_PENDATA->m_countDashes : 0);
163 }
164
165 int wxPen::GetDashCount() const
166 {
167 return (M_PENDATA->m_countDashes);
168 }
169
170 wxDash* wxPen::GetDash() const
171 {
172 return (wxDash*)M_PENDATA->m_dash;
173 }
174
175 int wxPen::GetCap() const
176 {
177 wxCHECK_MSG( Ok(), -1, wxT("invalid pen") );
178
179 return M_PENDATA->m_capStyle;
180 }
181
182 int wxPen::GetJoin() const
183 {
184 wxCHECK_MSG( Ok(), -1, wxT("invalid pen") );
185
186 return M_PENDATA->m_joinStyle;
187 }
188
189 int wxPen::GetStyle() const
190 {
191 wxCHECK_MSG( Ok(), -1, wxT("invalid pen") );
192
193 return M_PENDATA->m_style;
194 }
195
196 int wxPen::GetWidth() const
197 {
198 wxCHECK_MSG( Ok(), -1, wxT("invalid pen") );
199
200 return M_PENDATA->m_width;
201 }
202
203 wxColour &wxPen::GetColour() const
204 {
205 wxCHECK_MSG( Ok(), wxNullColour, wxT("invalid pen") );
206
207 return M_PENDATA->m_colour;
208 }
209