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