File: wx169.htm

package info (click to toggle)
wxwin2-doc 2.01-1
  • links: PTS
  • area: main
  • in suites: potato
  • size: 6,540 kB
  • ctags: 5,968
  • sloc: cpp: 15,157; makefile: 434; sh: 6
file content (449 lines) | stat: -rw-r--r-- 13,376 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
<HTML>
<head><title>wxPen</title></head>

<BODY BGCOLOR=#FFFFFF>
<A NAME="wxpen"></A><CENTER>
<A HREF="wx.htm"><img align=center src="contents.gif" BORDER=0 ALT="Contents"></A> <A HREF="wx22.htm#classref"><img align=center src="up.gif" BORDER=0 ALT="Up"></A> <A HREF="wx168.htm#wxpathlist"><img align=center src="back.gif" BORDER=0 ALT="Previous"></A> <A HREF="wx170.htm#wxpenlist"><img align=center src="forward.gif" BORDER=0 ALT="Next"></A> </CENTER><HR>

<H2>wxPen</H2>
<P>
A pen is a drawing tool for drawing outlines. It is used for drawing
lines and painting the outline of rectangles, ellipses, etc. It has a
colour, a width and a style. <P>
<B><FONT COLOR="#FF0000">Derived from</FONT></B><P>
<A HREF="wx107.htm#wxgdiobject">wxGDIObject</A><BR>

<A HREF="wx158.htm#wxobject">wxObject</A><P>
<B><FONT COLOR="#FF0000">Include files</FONT></B><P>
&lt;wx/pen.h&gt;<P>
<B><FONT COLOR="#FF0000">Predefined objects</FONT></B><P>
Objects:<P>
<B>wxNullPen</B><P>
Pointers:<P>
<B>wxRED_PEN<BR>

wxCYAN_PEN<BR>

wxGREEN_PEN<BR>

wxBLACK_PEN<BR>

wxWHITE_PEN<BR>

wxTRANSPARENT_PEN<BR>

wxBLACK_DASHED_PEN<BR>

wxGREY_PEN<BR>

wxMEDIUM_GREY_PEN<BR>

wxLIGHT_GREY_PEN</B><P>
<B><FONT COLOR="#FF0000">Remarks</FONT></B><P>
On a monochrome display, wxWindows shows all non-white pens as black.<P>
Do not initialize objects on the stack before the program commences,
since other required structures may not have been set up yet. Instead,
define global pointers to objects and create them in <I>OnInit</I> or
when required.<P>
An application may wish to dynamically create pens with different
characteristics, and there is the consequent danger that a large number
of duplicate pens will be created. Therefore an application may wish to
get a pointer to a pen by using the global list of pens <B>
wxThePenList</B>, and calling the member function <B>FindOrCreatePen</B>.
See the entry for <A HREF="wx170.htm#wxpenlist">wxPenList</A>.<P>
wxPen uses a reference counting system, so assignments between brushes are very
cheap. You can therefore use actual wxPen objects instead of pointers without
efficiency problems. Once one wxPen object changes its data it will create its
own pen data internally so that other pens, which previously shared the
data using the reference counting, are not affected.<P>
<B><FONT COLOR="#FF0000">See also</FONT></B><P>
<A HREF="wx170.htm#wxpenlist">wxPenList</A>, <A HREF="wx65.htm#wxdc">wxDC</A>, <A HREF="wx65.htm#wxdcsetpen">wxDC::SetPen</A><P>
<B><FONT COLOR="#FF0000">Members</FONT></B><P>
<A HREF="#wxpenconstr">wxPen::wxPen</A><BR>
<A HREF="#topic648">wxPen::~wxPen</A><BR>
<A HREF="#wxpengetcap">wxPen::GetCap</A><BR>
<A HREF="#wxpengetcolour">wxPen::GetColour</A><BR>
<A HREF="#wxpengetdashes">wxPen::GetDashes</A><BR>
<A HREF="#wxpengetjoin">wxPen::GetJoin</A><BR>
<A HREF="#wxpengetstipple">wxPen::GetStipple</A><BR>
<A HREF="#wxpengetstyle">wxPen::GetStyle</A><BR>
<A HREF="#wxpengetwidth">wxPen::GetWidth</A><BR>
<A HREF="#wxpenok">wxPen::Ok</A><BR>
<A HREF="#wxpensetcap">wxPen::SetCap</A><BR>
<A HREF="#wxpensetcolour">wxPen::SetColour</A><BR>
<A HREF="#wxpensetdashes">wxPen::SetDashes</A><BR>
<A HREF="#wxpensetjoin">wxPen::SetJoin</A><BR>
<A HREF="#wxpensetstipple">wxPen::SetStipple</A><BR>
<A HREF="#wxpensetstyle">wxPen::SetStyle</A><BR>
<A HREF="#wxpensetwidth">wxPen::SetWidth</A><BR>
<A HREF="#wxpenassignment">wxPen::operator =</A><BR>
<A HREF="#wxpenequals">wxPen::operator ==</A><BR>
<A HREF="#wxpennotequals">wxPen::operator !=</A><BR>
<P>

<HR>
<A NAME="wxpenconstr"></A>
<H3>wxPen::wxPen</H3>
<P>
<B></B> <B>wxPen</B>()<P>
Default constructor. The pen will be uninitialised, and <A HREF="wx169.htm#wxpenok">wxPen::Ok</A> will
return FALSE.<P>
<B></B> <B>wxPen</B>(<B>const wxColour&amp;</B><I> colour</I>, <B>int</B><I> width</I>, <B>int</B><I> style</I>)<P>
Constructs a pen from a colour object, pen width and style.<P>
<B></B> <B>wxPen</B>(<B>const wxString&amp; </B><I>colourName</I>, <B>int</B><I> width</I>, <B>int</B><I> style</I>)<P>
Constructs a pen from a colour name, pen width and style.<P>
<B></B> <B>wxPen</B>(<B>const wxBitmap&amp;</B><I> stipple</I>, <B>int</B><I> width</I>)<P>
Constructs a stippled pen from a stipple bitmap and a width.<P>
<B></B> <B>wxPen</B>(<B>const wxPen&amp;</B><I> pen</I>)<P>
Copy constructor. This uses reference counting so is a cheap operation.<P>
<B><FONT COLOR="#FF0000">Parameters</FONT></B><P>
<I>colour</I><UL><UL>
A colour object.</UL></UL>
<P>
<I>colourName</I><UL><UL>
A colour name.</UL></UL>
<P>
<I>width</I><UL><UL>
Pen width. Under Windows, the pen width cannot be greater than 1 if
the style is wxDOT, wxLONG_DASH, wxSHORT_DASH, wxDOT_DASH, or wxUSER_DASH.</UL></UL>
<P>
<I>stipple</I><UL><UL>
A stipple bitmap.</UL></UL>
<P>
<I>pen</I><UL><UL>
A pointer or reference to a pen to copy.</UL></UL>
<P>
<I>width</I><UL><UL>
Pen width. Under Windows, the pen width cannot be greater than 1 if
the style is wxDOT, wxLONG_DASH, wxSHORT_DASH, wxDOT_DASH, or wxUSER_DASH.</UL></UL>

  
<I>style</I><UL><UL>
The style may be one of the following:<P>

<TABLE>


<TR><TD VALIGN=TOP>
<B>wxSOLID</B>
</TD>

<TD VALIGN=TOP>
Solid style.
</TD></TR>


<TR><TD VALIGN=TOP>
<B>wxTRANSPARENT</B>
</TD>

<TD VALIGN=TOP>
No pen is used.
</TD></TR>


<TR><TD VALIGN=TOP>
<B>wxDOT</B>
</TD>

<TD VALIGN=TOP>
Dotted style.
</TD></TR>


<TR><TD VALIGN=TOP>
<B>wxLONG_DASH</B>
</TD>

<TD VALIGN=TOP>
Long dashed style.
</TD></TR>


<TR><TD VALIGN=TOP>
<B>wxSHORT_DASH</B>
</TD>

<TD VALIGN=TOP>
Short dashed style.
</TD></TR>


<TR><TD VALIGN=TOP>
<B>wxDOT_DASH</B>
</TD>

<TD VALIGN=TOP>
Dot and dash style.
</TD></TR>


<TR><TD VALIGN=TOP>
<B>wxSTIPPLE</B>
</TD>

<TD VALIGN=TOP>
Use the stipple bitmap.
</TD></TR>


<TR><TD VALIGN=TOP>
<B>wxUSER_DASH</B>
</TD>

<TD VALIGN=TOP>
Use the user dashes: see <A HREF="wx169.htm#wxpensetdashes">wxPen::SetDashes</A>.
</TD></TR>


<TR><TD VALIGN=TOP>
<B>wxBDIAGONAL_HATCH</B>
</TD>

<TD VALIGN=TOP>
Backward diagonal hatch.
</TD></TR>


<TR><TD VALIGN=TOP>
<B>wxCROSSDIAG_HATCH</B>
</TD>

<TD VALIGN=TOP>
Cross-diagonal hatch.
</TD></TR>


<TR><TD VALIGN=TOP>
<B>wxFDIAGONAL_HATCH</B>
</TD>

<TD VALIGN=TOP>
Forward diagonal hatch.
</TD></TR>


<TR><TD VALIGN=TOP>
<B>wxCROSS_HATCH</B>
</TD>

<TD VALIGN=TOP>
Cross hatch.
</TD></TR>


<TR><TD VALIGN=TOP>
<B>wxHORIZONTAL_HATCH</B>
</TD>

<TD VALIGN=TOP>
Horizontal hatch.
</TD></TR>


<TR><TD VALIGN=TOP>
<B>wxVERTICAL_HATCH</B>
</TD>

<TD VALIGN=TOP>
Vertical hatch.
</TD></TR>


</TABLE>
</UL></UL>
<P>
<B><FONT COLOR="#FF0000">Remarks</FONT></B><P>
If the named colour form is used, an appropriate <B>wxColour</B> structure
is found in the colour database.<P>
<I>style</I> may be one of wxSOLID, wxDOT, wxLONG_DASH, wxSHORT_DASH and
wxDOT_DASH.<P>
<B><FONT COLOR="#FF0000">See also</FONT></B><P>
<A HREF="wx169.htm#wxpensetstyle">wxPen::SetStyle</A>, <A HREF="wx169.htm#wxpensetcolour">wxPen::SetColour</A>,
<A HREF="wx169.htm#wxpensetwidth">wxPen::SetWidth</A>, <A HREF="wx169.htm#wxpensetstipple">wxPen::SetStipple</A><P>

<HR>
<A NAME="topic648"></A>
<H3>wxPen::~wxPen</H3>
<P>
<B></B> <B>~wxPen</B>()<P>
Destructor.<P>
<B><FONT COLOR="#FF0000">Remarks</FONT></B><P>
The destructor may not delete the underlying pen object of the native windowing
system, since wxBrush uses a reference counting system for efficiency.<P>
Although all remaining pens are deleted when the application exits,
the application should try to clean up all pens itself. This is because
wxWindows cannot know if a pointer to the pen object is stored in an
application data structure, and there is a risk of double deletion.<P>

<HR>
<A NAME="wxpengetcap"></A>
<H3>wxPen::GetCap</H3>
<P>
<B>int</B> <B>GetCap</B>() <B>const</B><P>
Returns the pen cap style, which may be one of <B>wxCAP_ROUND</B>, <B>wxCAP_PROJECTING</B> and
<B>wxCAP_BUTT</B>. The default is <B>wxCAP_ROUND</B>.<P>
<B><FONT COLOR="#FF0000">See also</FONT></B><P>
<A HREF="wx169.htm#wxpensetcap">wxPen::SetCap</A><P>

<HR>
<A NAME="wxpengetcolour"></A>
<H3>wxPen::GetColour</H3>
<P>
<B>wxColour&amp;</B> <B>GetColour</B>() <B>const</B><P>
Returns a reference to the pen colour.<P>
<B><FONT COLOR="#FF0000">See also</FONT></B><P>
<A HREF="wx169.htm#wxpensetcolour">wxPen::SetColour</A><P>

<HR>
<A NAME="wxpengetdashes"></A>
<H3>wxPen::GetDashes</H3>
<P>
<B>int</B> <B>GetDashes</B>(<B>wxDash**</B><I> dashes</I>) <B>const</B><P>
Gets an array of dashes (defined as char in X, DWORD under Windows).
<I>dashes</I> is a pointer to the internal array. Do not deallocate or store this pointer.
The function returns the number of dashes associated with this pen.<P>
<B><FONT COLOR="#FF0000">See also</FONT></B><P>
<A HREF="wx169.htm#wxpensetdashes">wxPen::SetDashes</A><P>

<HR>
<A NAME="wxpengetjoin"></A>
<H3>wxPen::GetJoin</H3>
<P>
<B>int</B> <B>GetJoin</B>() <B>const</B><P>
Returns the pen join style, which may be one of <B>wxJOIN_BEVEL</B>, <B>wxJOIN_ROUND</B> and
<B>wxJOIN_MITER</B>. The default is <B>wxJOIN_ROUND</B>.<P>
<B><FONT COLOR="#FF0000">See also</FONT></B><P>
<A HREF="wx169.htm#wxpensetjoin">wxPen::SetJoin</A><P>

<HR>
<A NAME="wxpengetstipple"></A>
<H3>wxPen::GetStipple</H3>
<P>
<B>wxBitmap* </B> <B>GetStipple</B>() <B>const</B><P>
Gets a pointer to the stipple bitmap.<P>
<B><FONT COLOR="#FF0000">See also</FONT></B><P>
<A HREF="wx169.htm#wxpensetstipple">wxPen::SetStipple</A><P>

<HR>
<A NAME="wxpengetstyle"></A>
<H3>wxPen::GetStyle</H3>
<P>
<B>int</B> <B>GetStyle</B>() <B>const</B><P>
Returns the pen style.<P>
<B><FONT COLOR="#FF0000">See also</FONT></B><P>
<A HREF="wx169.htm#wxpenconstr">wxPen::wxPen</A>, <A HREF="wx169.htm#wxpensetstyle">wxPen::SetStyle</A><P>

<HR>
<A NAME="wxpengetwidth"></A>
<H3>wxPen::GetWidth</H3>
<P>
<B>int</B> <B>GetWidth</B>() <B>const</B><P>
Returns the pen width.<P>
<B><FONT COLOR="#FF0000">See also</FONT></B><P>
<A HREF="wx169.htm#wxpensetwidth">wxPen::SetWidth</A><P>

<HR>
<A NAME="wxpenok"></A>
<H3>wxPen::Ok</H3>
<P>
<B>bool</B> <B>Ok</B>() <B>const</B><P>
Returns TRUE if the pen is initialised.<P>

<HR>
<A NAME="wxpensetcap"></A>
<H3>wxPen::SetCap</H3>
<P>
<B>void</B> <B>SetCap</B>(<B>int</B><I> capStyle</I>)<P>
Sets the pen cap style, which may be one of <B>wxCAP_ROUND</B>, <B>wxCAP_PROJECTING</B> and
<B>wxCAP_BUTT</B>. The default is <B>wxCAP_ROUND</B>.<P>
<B><FONT COLOR="#FF0000">See also</FONT></B><P>
<A HREF="wx169.htm#wxpengetcap">wxPen::GetCap</A><P>

<HR>
<A NAME="wxpensetcolour"></A>
<H3>wxPen::SetColour</H3>
<P>
<B>void</B> <B>SetColour</B>(<B>wxColour&amp;</B><I> colour</I>)<P>
<B>void</B> <B>SetColour</B>(<B>const wxString&amp; </B><I>colourName</I>)<P>
<B>void</B> <B>SetColour</B>(<B>int</B><I> red</I>, <B>int</B><I> green</I>, <B>int</B><I> blue</I>)<P>
The pen's colour is changed to the given colour.<P>
<B><FONT COLOR="#FF0000">See also</FONT></B><P>
<A HREF="wx169.htm#wxpengetcolour">wxPen::GetColour</A><P>

<HR>
<A NAME="wxpensetdashes"></A>
<H3>wxPen::SetDashes</H3>
<P>
<B>void</B> <B>SetDashes</B>(<B>int </B><I>n</I>, <B>wxDash*</B><I> dashes</I>)<P>
Associates an array of pointers to dashes (defined as char in X, DWORD under Windows)
with the pen. The array is not deallocated by wxPen, but neither must it be
deallocated by the calling application until the pen is deleted or this
function is called with a NULL array.<P>
<B><FONT COLOR="#FF0000">See also</FONT></B><P>
<A HREF="wx169.htm#wxpengetdashes">wxPen::GetDashes</A><P>

<HR>
<A NAME="wxpensetjoin"></A>
<H3>wxPen::SetJoin</H3>
<P>
<B>void</B> <B>SetJoin</B>(<B>int</B><I>join_style</I>)<P>
Sets the pen join style, which may be one of <B>wxJOIN_BEVEL</B>, <B>wxJOIN_ROUND</B> and
<B>wxJOIN_MITER</B>. The default is <B>wxJOIN_ROUND</B>.<P>
<B><FONT COLOR="#FF0000">See also</FONT></B><P>
<A HREF="wx169.htm#wxpengetjoin">wxPen::GetJoin</A><P>

<HR>
<A NAME="wxpensetstipple"></A>
<H3>wxPen::SetStipple</H3>
<P>
<B>void</B> <B>SetStipple</B>(<B>wxBitmap* </B><I>stipple</I>)<P>
Sets the bitmap for stippling.<P>
<B><FONT COLOR="#FF0000">See also</FONT></B><P>
<A HREF="wx169.htm#wxpengetstipple">wxPen::GetStipple</A><P>

<HR>
<A NAME="wxpensetstyle"></A>
<H3>wxPen::SetStyle</H3>
<P>
<B>void</B> <B>SetStyle</B>(<B>int</B><I> style</I>)<P>
Set the pen style.<P>
<B><FONT COLOR="#FF0000">See also</FONT></B><P>
<A HREF="wx169.htm#wxpenconstr">wxPen::wxPen</A><P>

<HR>
<A NAME="wxpensetwidth"></A>
<H3>wxPen::SetWidth</H3>
<P>
<B>void</B> <B>SetWidth</B>(<B>int</B><I> width</I>)<P>
Sets the pen width.<P>
<B><FONT COLOR="#FF0000">See also</FONT></B><P>
<A HREF="wx169.htm#wxpengetwidth">wxPen::GetWidth</A><P>

<HR>
<A NAME="wxpenassignment"></A>
<H3>wxPen::operator =</H3>
<P>
<B>wxPen&amp;</B> <B>operator =</B>(<B>const wxPen&amp; </B><I>pen</I>)<P>
Assignment operator, using reference counting. Returns a reference
to 'this'.<P>

<HR>
<A NAME="wxpenequals"></A>
<H3>wxPen::operator ==</H3>
<P>
<B>bool</B> <B>operator ==</B>(<B>const wxPen&amp; </B><I>pen</I>)<P>
Equality operator. Two pens are equal if they contain pointers
to the same underlying pen data. It does not compare each attribute,
so two independently-created pens using the same parameters will
fail the test.<P>

<HR>
<A NAME="wxpennotequals"></A>
<H3>wxPen::operator !=</H3>
<P>
<B>bool</B> <B>operator !=</B>(<B>const wxPen&amp; </B><I>pen</I>)<P>
Inequality operator. Two pens are not equal if they contain pointers
to different underlying pen data. It does not compare each attribute.<P>

</BODY></HTML>