]> git.saurik.com Git - wxWidgets.git/blob - src/gtk/pen.cpp
Fillid in many more missing functions (such as Enable())
[wxWidgets.git] / src / gtk / pen.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: pen.cpp
3 // Purpose:
4 // Author: Robert Roebling
5 // Created: 01/02/97
6 // Id:
7 // Copyright: (c) 1998 Robert Roebling, Julian Smart and Markus Holzem
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
10
11
12 #ifdef __GNUG__
13 #pragma implementation "pen.h"
14 #endif
15
16 #include "wx/pen.h"
17
18 //-----------------------------------------------------------------------------
19 // wxPen
20 //-----------------------------------------------------------------------------
21
22 class wxPenRefData: public wxObjectRefData
23 {
24 public:
25
26 wxPenRefData(void);
27
28 int m_width;
29 int m_style;
30 int m_joinStyle;
31 int m_capStyle;
32 wxColour m_colour;
33 };
34
35 wxPenRefData::wxPenRefData(void)
36 {
37 m_width = 1;
38 m_style = wxSOLID;
39 m_joinStyle = wxJOIN_ROUND;
40 m_capStyle = wxCAP_ROUND;
41 }
42
43 //-----------------------------------------------------------------------------
44
45 #define M_PENDATA ((wxPenRefData *)m_refData)
46
47 IMPLEMENT_DYNAMIC_CLASS(wxPen,wxGDIObject)
48
49 wxPen::wxPen(void)
50 {
51 if (wxThePenList) wxThePenList->AddPen( this );
52 }
53
54 wxPen::wxPen( const wxColour &colour, int width, int style )
55 {
56 m_refData = new wxPenRefData();
57 M_PENDATA->m_width = width;
58 M_PENDATA->m_style = style;
59 M_PENDATA->m_colour = colour;
60
61 if (wxThePenList) wxThePenList->AddPen( this );
62 }
63
64 wxPen::wxPen( const wxString &colourName, int width, int style )
65 {
66 m_refData = new wxPenRefData();
67 M_PENDATA->m_width = width;
68 M_PENDATA->m_style = style;
69 M_PENDATA->m_colour = colourName;
70
71 if (wxThePenList) wxThePenList->AddPen( this );
72 }
73
74 wxPen::wxPen( const wxPen& pen )
75 {
76 Ref( pen );
77 if (wxThePenList) wxThePenList->AddPen( this );
78 }
79
80 wxPen::wxPen( const wxPen* pen )
81 {
82 UnRef();
83 if (pen) Ref( *pen );
84
85 if (wxThePenList) wxThePenList->AddPen( this );
86 }
87
88 wxPen::~wxPen(void)
89 {
90 if (wxThePenList) wxThePenList->RemovePen( this );
91 }
92
93 wxPen& wxPen::operator = ( const wxPen& pen )
94 {
95 if (*this == pen) return (*this);
96 Ref( pen );
97 return *this;
98 }
99
100 bool wxPen::operator == ( const wxPen& pen )
101 {
102 return m_refData == pen.m_refData;
103 }
104
105 bool wxPen::operator != ( const wxPen& pen )
106 {
107 return m_refData != pen.m_refData;
108 }
109
110 void wxPen::SetColour( const wxColour &colour )
111 {
112 if (!m_refData)
113 m_refData = new wxPenRefData();
114
115 M_PENDATA->m_colour = colour;
116 }
117
118 void wxPen::SetColour( const wxString &colourName )
119 {
120 if (!m_refData)
121 m_refData = new wxPenRefData();
122
123 M_PENDATA->m_colour = colourName;
124 }
125
126 void wxPen::SetColour( int red, int green, int blue )
127 {
128 if (!m_refData)
129 m_refData = new wxPenRefData();
130
131 M_PENDATA->m_colour.Set( red, green, blue );
132 }
133
134 void wxPen::SetCap( int capStyle )
135 {
136 if (!m_refData)
137 m_refData = new wxPenRefData();
138
139 M_PENDATA->m_capStyle = capStyle;
140 }
141
142 void wxPen::SetJoin( int joinStyle )
143 {
144 if (!m_refData)
145 m_refData = new wxPenRefData();
146
147 M_PENDATA->m_joinStyle = joinStyle;
148 }
149
150 void wxPen::SetStyle( int style )
151 {
152 if (!m_refData)
153 m_refData = new wxPenRefData();
154
155 M_PENDATA->m_style = style;
156 }
157
158 void wxPen::SetWidth( int width )
159 {
160 if (!m_refData)
161 m_refData = new wxPenRefData();
162
163 M_PENDATA->m_width = width;
164 }
165
166 int wxPen::GetCap(void) const
167 {
168 return M_PENDATA->m_capStyle;
169 }
170
171 int wxPen::GetJoin(void) const
172 {
173 if (!m_refData)
174 return 0;
175 else
176 return M_PENDATA->m_joinStyle;
177 }
178
179 int wxPen::GetStyle(void) const
180 {
181 if (!m_refData)
182 return 0;
183 else
184 return M_PENDATA->m_style;
185 }
186
187 int wxPen::GetWidth(void) const
188 {
189 if (!m_refData)
190 return 0;
191 else
192 return M_PENDATA->m_width;
193 }
194
195 wxColour &wxPen::GetColour(void) const
196 {
197 if (!m_refData)
198 return wxNullColour;
199 else
200 return M_PENDATA->m_colour;
201 }
202
203 bool wxPen::Ok(void) const
204 {
205 return (m_refData);
206 }
207