File: wx170.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 (89 lines) | stat: -rw-r--r-- 4,033 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
<HTML>
<head><title>wxPenList</title></head>

<BODY BGCOLOR=#FFFFFF>
<A NAME="wxpenlist"></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="wx169.htm#wxpen"><img align=center src="back.gif" BORDER=0 ALT="Previous"></A> <A HREF="wx171.htm#wxpoint"><img align=center src="forward.gif" BORDER=0 ALT="Next"></A> </CENTER><HR>

<H2>wxPenList</H2>
<P>
There is only one instance of this class: <B>wxThePenList</B>.  Use
this object to search for a previously created pen of the desired
type and create it if not already found. In some windowing systems,
the pen may be a scarce resource, so it can pay to reuse old
resources if possible. When an application finishes, all pens will
be deleted and their resources freed, eliminating the possibility of
'memory leaks'. However, it is best not to rely on this automatic
cleanup because it can lead to double deletion in some circumstances.<P>
There are two mechanisms in recent versions of wxWindows which make the
pen list less useful than it once was. Under Windows, scarce resources
are cleaned up internally if they are not being used. Also, a referencing
counting mechanism applied to all GDI objects means that some sharing
of underlying resources is possible. You don't have to keep track of pointers,
working out when it is safe delete a pen, because the referencing counting does
it for you. For example, you can set a pen in a device context, and then
immediately delete the pen you passed, because the pen is 'copied'.<P>
So you may find it easier to ignore the pen list, and instead create
and copy pens as you see fit. If your Windows resource meter suggests
your application is using too many resources, you can resort to using
GDI lists to share objects explicitly.<P>
The only compelling use for the pen list is for wxWindows to keep
track of pens in order to clean them up on exit. It is also kept for
backward compatibility with earlier versions of wxWindows.<P>
<B><FONT COLOR="#FF0000">See also</FONT></B><P>
<A HREF="wx169.htm#wxpen">wxPen</A><P>
<B><FONT COLOR="#FF0000">Members</FONT></B><P>
<A HREF="#topic649">wxPenList::wxPenList</A><BR>
<A HREF="#wxpenlistaddpen">wxPenList::AddPen</A><BR>
<A HREF="#wxpenlistfindorcreatepen">wxPenList::FindOrCreatePen</A><BR>
<A HREF="#wxpenlistremovepen">wxPenList::RemovePen</A><BR>
<P>

<HR>
<A NAME="topic649"></A>
<H3>wxPenList::wxPenList</H3>
<P>
<B>void</B> <B>wxPenList</B>()<P>
Constructor. The application should not construct its own pen list:
use the object pointer <B>wxThePenList</B>.<P>

<HR>
<A NAME="wxpenlistaddpen"></A>
<H3>wxPenList::AddPen</H3>
<P>
<B>void</B> <B>AddPen</B>(<B>wxPen*</B><I> pen</I>)<P>
Used internally by wxWindows to add a pen to the list.<P>

<HR>
<A NAME="wxpenlistfindorcreatepen"></A>
<H3>wxPenList::FindOrCreatePen</H3>
<P>
<B>wxPen*</B> <B>FindOrCreatePen</B>(<B>const wxColour&amp; </B><I>colour</I>, <B>int</B><I> width</I>, <B>int</B><I> style</I>)<P>
Finds a pen with the specified attributes and returns it, else creates a new pen, adds it
to the pen list, and returns it.<P>
<B>wxPen*</B> <B>FindOrCreatePen</B>(<B>const wxString&amp; </B><I>colourName</I>, <B>int</B><I> width</I>, <B>int</B><I> style</I>)<P>
Finds a pen with the specified attributes and returns it, else creates a new pen, adds it
to the pen list, and returns it.<P>
<B><FONT COLOR="#FF0000">Parameters</FONT></B><P>
<I>colour</I><UL><UL>
Colour object.</UL></UL>
<P>
<I>colourName</I><UL><UL>
Colour name, which should be in the <A HREF="wx48.htm#wxcolourdatabase">colour database</A>.</UL></UL>
<P>
<I>width</I><UL><UL>
Width of pen.</UL></UL>
<P>
<I>style</I><UL><UL>
Pen style. See <A HREF="wx169.htm#wxpenconstr">wxPen::wxPen</A> for a list of styles.</UL></UL>
<P>

<HR>
<A NAME="wxpenlistremovepen"></A>
<H3>wxPenList::RemovePen</H3>
<P>
<B>void</B> <B>RemovePen</B>(<B>wxPen*</B><I> pen</I>)<P>
Used by wxWindows to remove a pen from the list.<P>


</BODY></HTML>