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