]> git.saurik.com Git - wxWidgets.git/blame - interface/pen.h
add const qualifiers
[wxWidgets.git] / interface / pen.h
CommitLineData
23324ae1
FM
1/////////////////////////////////////////////////////////////////////////////
2// Name: pen.h
3// Purpose: documentation for wxPen class
4// Author: wxWidgets team
5// RCS-ID: $Id$
6// Licence: wxWindows license
7/////////////////////////////////////////////////////////////////////////////
8
9/**
10 @class wxPen
11 @wxheader{pen.h}
7c913512 12
23324ae1
FM
13 A pen is a drawing tool for drawing outlines. It is used for drawing
14 lines and painting the outline of rectangles, ellipses, etc. It has a
15 colour, a width and a style.
7c913512 16
23324ae1
FM
17 @library{wxcore}
18 @category{gdi}
7c913512 19
23324ae1
FM
20 @stdobjects
21 Objects:
22 wxNullPen
23 Pointers:
24 wxRED_PEN
7c913512 25
23324ae1 26 wxCYAN_PEN
7c913512 27
23324ae1 28 wxGREEN_PEN
7c913512 29
23324ae1 30 wxBLACK_PEN
7c913512 31
23324ae1 32 wxWHITE_PEN
7c913512 33
23324ae1 34 wxTRANSPARENT_PEN
7c913512 35
23324ae1 36 wxBLACK_DASHED_PEN
7c913512 37
23324ae1 38 wxGREY_PEN
7c913512 39
23324ae1 40 wxMEDIUM_GREY_PEN
7c913512 41
23324ae1 42 wxLIGHT_GREY_PEN
7c913512 43
23324ae1
FM
44 @seealso
45 wxPenList, wxDC, wxDC::SetPen
46*/
47class wxPen : public wxGDIObject
48{
49public:
50 //@{
51 /**
52 Copy constructor, uses @ref overview_trefcount "reference counting".
53
7c913512 54 @param colour
4cc4bfaf 55 A colour object.
7c913512 56 @param colourName
4cc4bfaf 57 A colour name.
7c913512 58 @param width
4cc4bfaf
FM
59 Pen width. Under Windows, the pen width cannot be greater than 1 if
60 the style is wxDOT, wxLONG_DASH, wxSHORT_DASH, wxDOT_DASH, or wxUSER_DASH.
7c913512 61 @param stipple
4cc4bfaf 62 A stipple bitmap.
7c913512 63 @param pen
4cc4bfaf 64 A pointer or reference to a pen to copy.
7c913512 65 @param style
4cc4bfaf
FM
66 The style may be one of the following:
67
68
69
70
71
72
73 wxSOLID
74
75
76
77
78 Solid style.
79
80
81
82
83
84 wxTRANSPARENT
85
86
87
88
89 No pen is used.
90
91
92
93
94
95 wxDOT
96
97
98
99
100 Dotted style.
101
102
103
104
105
106 wxLONG_DASH
107
108
109
110
111 Long dashed style.
112
113
114
115
116
117 wxSHORT_DASH
118
119
120
121
122 Short dashed style.
123
124
125
126
127
128 wxDOT_DASH
129
130
131
132
133 Dot and dash style.
134
135
136
137
138
139 wxSTIPPLE
140
141
142
143
144 Use the stipple bitmap.
145
146
147
148
149
150 wxUSER_DASH
151
152
153
154
155 Use the user dashes: see SetDashes().
156
157
158
159
160
161 wxBDIAGONAL_HATCH
162
163
164
165
166 Backward diagonal hatch.
167
168
169
23324ae1 170
23324ae1 171
4cc4bfaf 172 wxCROSSDIAG_HATCH
23324ae1 173
23324ae1 174
23324ae1
FM
175
176
4cc4bfaf 177 Cross-diagonal hatch.
23324ae1 178
23324ae1
FM
179
180
23324ae1 181
23324ae1 182
4cc4bfaf 183 wxFDIAGONAL_HATCH
23324ae1 184
23324ae1 185
23324ae1
FM
186
187
4cc4bfaf 188 Forward diagonal hatch.
23324ae1 189
23324ae1
FM
190
191
23324ae1 192
23324ae1 193
4cc4bfaf 194 wxCROSS_HATCH
23324ae1 195
23324ae1 196
23324ae1
FM
197
198
4cc4bfaf 199 Cross hatch.
23324ae1 200
23324ae1
FM
201
202
23324ae1 203
23324ae1 204
4cc4bfaf 205 wxHORIZONTAL_HATCH
23324ae1 206
23324ae1 207
23324ae1
FM
208
209
4cc4bfaf 210 Horizontal hatch.
23324ae1 211
23324ae1
FM
212
213
23324ae1 214
23324ae1 215
4cc4bfaf 216 wxVERTICAL_HATCH
23324ae1 217
23324ae1 218
23324ae1
FM
219
220
4cc4bfaf 221 Vertical hatch.
23324ae1
FM
222
223 @remarks Different versions of Windows and different versions of other
4cc4bfaf
FM
224 platforms support very different subsets of the styles
225 above - there is no similarity even between Windows95
226 and Windows98 - so handle with care.
23324ae1 227
4cc4bfaf 228 @see SetStyle(), SetColour(), SetWidth(), SetStipple()
23324ae1
FM
229 */
230 wxPen();
7c913512
FM
231 wxPen(const wxColour& colour, int width = 1,
232 int style = wxSOLID);
233 wxPen(const wxString& colourName, int width, int style);
234 wxPen(const wxBitmap& stipple, int width);
235 wxPen(const wxPen& pen);
23324ae1
FM
236 //@}
237
238 /**
239 Destructor.
240 See @ref overview_refcountdestruct "reference-counted object destruction" for
241 more info.
242
243 @remarks Although all remaining pens are deleted when the application
4cc4bfaf
FM
244 exits, the application should try to clean up all pens
245 itself. This is because wxWidgets cannot know if a
246 pointer to the pen object is stored in an application
247 data structure, and there is a risk of double deletion.
23324ae1
FM
248 */
249 ~wxPen();
250
251 /**
252 Returns the pen cap style, which may be one of @b wxCAP_ROUND, @b
253 wxCAP_PROJECTING and
254 @b wxCAP_BUTT. The default is @b wxCAP_ROUND.
255
4cc4bfaf 256 @see SetCap()
23324ae1 257 */
328f5751 258 int GetCap() const;
23324ae1
FM
259
260 /**
261 Returns a reference to the pen colour.
262
4cc4bfaf 263 @see SetColour()
23324ae1 264 */
328f5751 265 wxColour GetColour() const;
23324ae1
FM
266
267 /**
268 Gets an array of dashes (defined as char in X, DWORD under Windows).
4cc4bfaf 269 @a dashes is a pointer to the internal array. Do not deallocate or store this
23324ae1
FM
270 pointer.
271 The function returns the number of dashes associated with this pen.
272
4cc4bfaf 273 @see SetDashes()
23324ae1 274 */
328f5751 275 int GetDashes(wxDash** dashes) const;
23324ae1
FM
276
277 /**
278 Returns the pen join style, which may be one of @b wxJOIN_BEVEL, @b
279 wxJOIN_ROUND and
280 @b wxJOIN_MITER. The default is @b wxJOIN_ROUND.
281
4cc4bfaf 282 @see SetJoin()
23324ae1 283 */
328f5751 284 int GetJoin() const;
23324ae1
FM
285
286 /**
287 Gets a pointer to the stipple bitmap.
288
4cc4bfaf 289 @see SetStipple()
23324ae1 290 */
328f5751 291 wxBitmap* GetStipple() const;
23324ae1
FM
292
293 /**
294 Returns the pen style.
295
4cc4bfaf 296 @see wxPen(), SetStyle()
23324ae1 297 */
328f5751 298 int GetStyle() const;
23324ae1
FM
299
300 /**
301 Returns the pen width.
302
4cc4bfaf 303 @see SetWidth()
23324ae1 304 */
328f5751 305 int GetWidth() const;
23324ae1
FM
306
307 /**
308 Returns @true if the pen is initialised.
309 */
328f5751 310 bool IsOk() const;
23324ae1
FM
311
312 /**
313 Sets the pen cap style, which may be one of @b wxCAP_ROUND, @b wxCAP_PROJECTING
314 and
315 @b wxCAP_BUTT. The default is @b wxCAP_ROUND.
316
4cc4bfaf 317 @see GetCap()
23324ae1
FM
318 */
319 void SetCap(int capStyle);
320
321 //@{
322 /**
323 The pen's colour is changed to the given colour.
324
4cc4bfaf 325 @see GetColour()
23324ae1
FM
326 */
327 void SetColour(wxColour& colour);
7c913512
FM
328 void SetColour(const wxString& colourName);
329 void SetColour(unsigned char red, unsigned char green,
330 unsigned char blue);
23324ae1
FM
331 //@}
332
333 /**
334 Associates an array of pointers to dashes (defined as char in X, DWORD under
335 Windows)
336 with the pen. The array is not deallocated by wxPen, but neither must it be
337 deallocated by the calling application until the pen is deleted or this
338 function is called with a @NULL array.
339
4cc4bfaf 340 @see GetDashes()
23324ae1
FM
341 */
342 void SetDashes(int n, wxDash* dashes);
343
344 /**
345 Sets the pen join style, which may be one of @b wxJOIN_BEVEL, @b wxJOIN_ROUND
346 and
347 @b wxJOIN_MITER. The default is @b wxJOIN_ROUND.
348
4cc4bfaf 349 @see GetJoin()
23324ae1
FM
350 */
351 void SetJoin(int join_style);
352
353 /**
354 Sets the bitmap for stippling.
355
4cc4bfaf 356 @see GetStipple()
23324ae1
FM
357 */
358 void SetStipple(wxBitmap* stipple);
359
360 /**
361 Set the pen style.
362
4cc4bfaf 363 @see wxPen()
23324ae1
FM
364 */
365 void SetStyle(int style);
366
367 /**
368 Sets the pen width.
369
4cc4bfaf 370 @see GetWidth()
23324ae1
FM
371 */
372 void SetWidth(int width);
373
374 /**
375 Inequality operator.
376 See @ref overview_refcountequality "reference-counted object comparison" for
377 more info.
378 */
379 bool operator !=(const wxPen& pen);
380
381 /**
382 Assignment operator, using @ref overview_trefcount "reference counting".
383 */
384 wxPen operator =(const wxPen& pen);
385
386 /**
387 Equality operator.
388 See @ref overview_refcountequality "reference-counted object comparison" for
389 more info.
390 */
391 bool operator ==(const wxPen& pen);
392};