h1(#wxicon). Wx::Icon
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.
h2. Derived from
"Bitmap":bitmap.html
"GDIObject":gdiobject.html
"Object":object.html
h2. Predefined objects
Wx::NULL_ICON
h2. Remarks
It is usually desirable to associate a pertinent icon with a frame. Icons
can also be used for other purposes, for example with "TreeCtrl":treectrl.html
and "ListCtrl":listctrl.html.
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.
h2. See also
"Bitmap":bitmap.html, "Image
"DC#draw_icon":dc.html#DC_drawicon, "Cursor":cursor.html
h2. Methods
* "Icon.new":#Icon_new
* "Icon.from_bitmap":#Icon_frombitmap
* "Icon#get_depth":#Icon_getdepth
* "Icon#get_height":#Icon_getheight
* "Icon#get_width":#Icon_getwidth
* "Icon#load_file":#Icon_loadfile
* "Icon#ok":#Icon_ok
* "Icon#save_file":#Icon_savefile
* "Icon#set_depth":#Icon_setdepth
* "Icon#set_height":#Icon_setheight
* "Icon#set_width":#Icon_setwidth
h3(#Icon_new). Icon.new
This is the recommended constructor for icons in wxRuby
*Icon.new*(%(arg-type)String% name,
%(arg-type)Integer% bitmap_type,
%(arg-type)Integer% desiredWidth = -1,
%(arg-type)Integer% desiredHeight = -1)
Loads an icon from a file or resource.
These are not currently available in wxRuby:
*Icon.new*(%(arg-type)% data, %(arg-type)Integer% type, %(arg-type)Integer% width,
%(arg-type)Integer% height,
%(arg-type)Integer% depth = -1)
Creates an icon from the given data, which can be of arbitrary type.
%(arg-type)Integer% height
%(arg-type)Integer% depth = 1)
Creates an icon from an array of bits.
*Icon.new*(%(arg-type)Integer% width, %(arg-type)Integer% height, %(arg-type)Integer% depth = -1)
Creates a new icon.
*Icon.new*(%(arg-type)"char":char.html% bits)
*Icon.new*(%(arg-type)"char":char.html% bits)
Creates an icon from XPM data.
h4. Parameters
* _bits_ Specifies an array of pixel values.
* _width_ Specifies the width of the icon.
* _height_ Specifies the height of the icon.
* _desiredWidth_ Specifies the desired width of the icon. This
parameter only has an effect in Windows (32-bit) where icon resources can contain
several icons of different sizes.
* _desiredWidth_ Specifies the desired height of the icon. This
parameter only has an effect in Windows (32-bit) where icon resources can contain
several icons of different sizes.
* _depth_ Specifies the depth of the icon. If this is omitted, the display depth of the
screen is used.
* _name_ This can refer to a resource name under MS Windows, or a filename under MS Windows and X.
Its meaning is determined by the _flags_ parameter.
* _loc_ The object describing the location of the native icon, see
"IconLocation":iconlocation.html.
* _bitmap_type_ May be one of the following:
|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.
h3(#Icon_copyfrombitmap). Icon#copy_from_bitmap
*Icon.from_bitmap*(%(arg-type)"Bitmap":bitmap.html% bmp)
Creates a new Icon from the bitmap _bmp_. Under MS Windows and OS X the bitmap
must have mask colour set.
h3(#Icon_getdepth). Icon#get_depth
Integer *get_depth*()
Gets the colour depth of the icon. A value of 1 indicates a
monochrome icon.
h3(#Icon_getheight). Icon#get_height
Integer *get_height*()
Gets the height of the icon in pixels.
h3(#Icon_getwidth). Icon#get_width
Integer *get_width*()
Gets the width of the icon in pixels.
h4. See also
"Icon#get_height":icon.html#Icon_getheight
h3(#Icon_loadfile). Icon#load_file
Boolean *load_file*(%(arg-type)String% name, %(arg-type)"BitmapType":bitmaptype.html% type)
Loads an icon from a file or resource.
h4. Parameters
* _name_ Either a filename or a Windows resource name.
The meaning of _name_ is determined by the _type_ parameter.
* _type_ One of the following values:
|*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.
h4. Return value
true if the operation succeeded, false otherwise.
h4. See also
"Icon.new":icon.html#Icon_new
h3(#Icon_ok). Icon#ok
Boolean *ok*()
Returns true if icon data is present.
h3(#Icon_savefile). Icon#save_file
Boolean *save_file*(%(arg-type)String% name, %(arg-type)"BitmapType":bitmaptype.html% type,
%(arg-type)"Palette":palette.html% palette = nil)
Saves an icon in the named file.
h4. Parameters
* _name_ A filename. The meaning of _name_ is determined by the _type_ parameter.
* _type_ One of the following values:
|*BITMAP_TYPE_ICO*|Save a Windows icon file.|
|*BITMAP_TYPE_XPM*|Save an XPM bitmap file.|
The validity of these flags depends on the platform and Widgets configuration.
* _palette_ An optional palette used for saving the icon.
h4. Return value
true if the operation succeeded, false otherwise.
h4. Remarks
Depending on how Widgets has been configured, not all formats may be available.
h4. See also
"Icon#load_file":icon.html#Icon_loadfile
h3(#Icon_setdepth). Icon#set_depth
*set_depth*(%(arg-type)Integer% depth)
Sets the depth member (does not affect the icon data).
h4. Parameters
* _depth_ Icon depth.
h3(#Icon_setheight). Icon#set_height
*set_height*(%(arg-type)Integer% height)
Sets the height member (does not affect the icon data).
h4. Parameters
* _height_ Icon height in pixels.
h3(#Icon_setwidth). Icon#set_width
*set_width*(%(arg-type)Integer% width)
Sets the width member (does not affect the icon data).
h4. Parameters
* _width_ Icon width in pixels.
h3(#Icon_assign). Icon#=
"Icon& ":icon& .html *operator $=$*(%(arg-type)"Icon":icon.html% 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.
h4. Parameters
* _icon_ Icon to assign.
h4. Return value
Returns 'this' object.
h3(#Icon_equal). Icon#==
Boolean *operator $==$*(%(arg-type)"Icon":icon.html% icon)
Equality operator. This operator tests whether the internal data pointers are
equal (a fast test).
h4. Parameters
* _icon_ Icon to compare with 'this'
h4. Return value
Returns true if the icons were effectively equal, false otherwise.
h3(#Icon_notequal). Icon#!=
Boolean *operator $!=$*(%(arg-type)"Icon":icon.html% icon)
Inequality operator. This operator tests whether the internal data pointers are
unequal (a fast test).
h4. Parameters
* _icon_ Icon to compare with 'this'
h4. Return value
Returns true if the icons were unequal, false otherwise.