An icon is a small rectangular bitmap usually used for denoting a minimized application. It differs from a Bitmap in always having a mask associated with it for transparent drawing. On some platforms, icons and bitmaps are implemented identically, since there is no real distinction between a Bitmap with a mask and an icon; and there is no specific icon format on some platforms (X-based applications usually standardize on XPMs for small bitmaps and icons). However, some platforms (such as Windows) make the distinction, so a separate class is provided.
Wx::NULL_ICON
It is usually desirable to associate a pertinent icon with a frame. Icons can also be used for other purposes, for example with TreeCtrl and ListCtrl.
Icons have different formats on different platforms. Therefore, separate icons will usually be created for the different environments. Platform-specific methods for creating a Icon structure are catered for, and this is an occasion where conditional initialisation 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 Windows, 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.
Bitmap, “Image DC#draw_icon, Cursor
This is the recommended constructor for icons in wxRuby
Icon.new(String name,
Integer bitmap_type,
Integer desiredWidth = -1,
Integer desiredHeight = -1)
Loads an icon from a file or resource.
These are not currently available in wxRuby:
Icon.new(% data, %(arg-type)Integer type, Integer width,
Integer height,
Integer depth = -1)
Creates an icon from the given data, which can be of arbitrary type.
Integer height
Integer depth = 1)
Creates an icon from an array of bits.
Icon.new(Integer width, Integer height, Integer depth = -1)
Creates a new icon.
Icon.new(char bits)
Icon.new(char bits)
Creates an icon from XPM data.
| BITMAP_TYPE_ICO | Load a Windows icon file. |
| BITMAP_TYPE_ICO_RESOURCE | Load a Windows icon from the resource database. |
| BITMAP_TYPE_GIF | Load a GIF bitmap file. |
| BITMAP_TYPE_XBM | Load an X bitmap file. |
| BITMAP_TYPE_XPM | Load an XPM bitmap file. |
The validity of these flags depends on the platform and Widgets configuration. If all possible Widgets settings are used, the Windows platform supports ICO file, ICO resource, XPM data, XPM file and PNG file. Under GTK, the available formats are BMP file, XPM data, XPM file, and PNG file. For cross-platform reliability, ensure that the second argument specifying the type is given.
Icon.from_bitmap(Bitmap bmp)
Creates a new Icon from the bitmap bmp. Under MS Windows and OS X the bitmap must have mask colour set.
Integer get_depth()
Gets the colour depth of the icon. A value of 1 indicates a monochrome icon.
Integer get_height()
Gets the height of the icon in pixels.
Integer get_width()
Gets the width of the icon in pixels.
Boolean load_file(String name, BitmapType type)
Loads an icon from a file or resource.
| BITMAP_TYPE_ICO | Load a Windows icon file. |
| BITMAP_TYPE_ICO_RESOURCE | Load a Windows icon from the resource database. |
| BITMAP_TYPE_GIF | Load a GIF bitmap file. |
| BITMAP_TYPE_XBM | Load an X bitmap file. |
| BITMAP_TYPE_XPM | Load an XPM bitmap file. |
The validity of these flags depends on the platform and Widgets configuration.
true if the operation succeeded, false otherwise.
Boolean ok()
Returns true if icon data is present.
Boolean save_file(String name, BitmapType type,
Palette palette = nil)
Saves an icon in the named file.
| BITMAP_TYPE_ICO | Save a Windows icon file. |
| BITMAP_TYPE_XPM | Save an XPM bitmap file. |
true if the operation succeeded, false otherwise.
Depending on how Widgets has been configured, not all formats may be available.
set_depth(Integer depth)
Sets the depth member (does not affect the icon data).
set_height(Integer height)
Sets the height member (does not affect the icon data).
set_width(Integer width)
Sets the width member (does not affect the icon data).
Icon&% .html operator $=$(Icon icon)
Assignment operator. This operator does not copy any data, but instead passes a pointer to the data in icon and increments a reference counter. It is a fast operation.
Returns ‘this’ object.
Boolean operator $==$(Icon icon)
Equality operator. This operator tests whether the internal data pointers are equal (a fast test).
Returns true if the icons were effectively equal, false otherwise.
Boolean operator $!=$(Icon icon)
Inequality operator. This operator tests whether the internal data pointers are unequal (a fast test).
Returns true if the icons were unequal, false otherwise.
[This page automatically generated from the Textile source at Thu May 01 00:50:39 +0100 2008]