An icon is a small rectangular bitmap usually used for denoting a minimized application. It is optional (but desirable) to associate a pertinent icon with a frame. Obviously icons in X and Windows 3 are created in a different manner, and colour icons in X are difficult to arrange. Therefore, separate icons will be created for the different environments. Platform-specific methods for creating a wxIcon structure are catered for, and this is an occasion where conditional compilation will probably be required.
Note that a new icon must be created for every time the icon is to be used for a new window. In X, this will ensure that fresh X resources are allocated for this frame. In Windows 3, the icon will not be reloaded if it has already been used. An icon allocated to a frame will be deleted when the frame is deleted.
The following shows the conditional compilation required to define an icon in X and in Windows 3. The alternative is to use the string version of the icon constructor, which loads a file under X and a resource under Windows 3, but has the disadvantage of requiring the X icon file to be available at run-time. If anyone can invent a scheme or macro which does the following more elegantly and platform-independently, I'd like to see it!
#ifdef wx_x short aiai_bits[] ={ #include "aiai.icon" }; #endif #ifdef wx_msw wxIcon *icon = new wxIcon("aiai"); #endif #ifdef wx_x wxIcon *icon = new wxIcon(aiai_bits, 64, 64); #endif
wxIcon::wxIcon
voidwxIconshort bits[], int width, int height
voidwxIconchar * icon_name
Constructor. An icon can be created by passing an array of bits (X only) or by passing a string name. icon_name refers to a filename in X, a resource name in Windows 3.
wxIcon::wxIcon
voidwxIcon
Destroys the icon. Do not explicitly delete an icon pointer which has been passed to a frame - the frame will delete the icon when it is destroyed. If assigning a new icon to a frame, the old icon will be destroyed.