wxpenlistthere is only one instance of this class: wxthepenlist. 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. there are two mechanisms in recent versions of wxwidgets 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'. 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. the only compelling use for the pen list is for wxwidgets to keep track of pens in order to clean them up on exit. it is also kept for backward compatibility with earlier versions of wxwidgets. see also members
wxpenlist::wxpenlist
wxpenlist::wxpenlistvoid wxpenlist() constructor. the application should not construct its own pen list: use the object pointer wxthepenlist.
wxpenlist::findorcreatepenwxpen* findorcreatepen(const wxcolour& colour, int width, int style) finds a pen with the specified attributes and returns it, else creates a new pen, adds it to the pen list, and returns it. wxpen* findorcreatepen(const wxstring& colourname, int width, int style) finds a pen with the specified attributes and returns it, else creates a new pen, adds it to the pen list, and returns it. parameters colour
colourname
width
style
|