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