Class: Wx::Icon

Inherits:
Bitmap
  • Object
show all
Defined in:
lib/wx/doc/gen/icon.rb

Overview

Note:

This class is untracked and should not be derived from nor instances extended!

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.

Remark:

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 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 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. For more information please see Bitmaps and Icons.

Category: Graphics Device Interface (GDI) Predefined objects/pointers: NULL_ICON

See Also:

Instance Method Summary collapse

Constructor Details

#initializeWx::Icon #initialize(icon) ⇒ Wx::Icon #initialize(name, type = Wx::ICON_DEFAULT_TYPE, desiredWidth = -1, desiredHeight = -1) ⇒ Wx::Icon #initialize(loc) ⇒ Wx::Icon

Returns a new instance of Icon.

Overloads:

  • #initializeWx::Icon

    Default ctor.

    Constructs an icon object with no data; an assignment or another member function such as #load_file must be called subsequently.

  • #initialize(icon) ⇒ Wx::Icon

    Copy ctor.

    Parameters:

  • #initialize(name, type = Wx::ICON_DEFAULT_TYPE, desiredWidth = -1, desiredHeight = -1) ⇒ Wx::Icon

    Loads an icon from a file or resource.

    Parameters:

    • name (String)

      This can refer to a resource name or a filename under MS Windows and X. Its meaning is determined by the type parameter.

    • type (Wx::BitmapType) (defaults to: Wx::ICON_DEFAULT_TYPE)

      May be one of the BitmapType values and indicates which type of bitmap should be loaded. See the note in the class detailed description. Note that the Wx::ICON_DEFAULT_TYPE constant has different value under different wxWidgets ports. See the icon.h header for the value it takes for a specific port.

    • desiredWidth (Integer) (defaults to: -1)

      Specifies the desired width of the icon. This parameter only has an effect in Windows where icon resources can contain several icons of different sizes.

    • desiredHeight (Integer) (defaults to: -1)

      Specifies the desired height of the icon. This parameter only has an effect in Windows where icon resources can contain several icons of different sizes.

    See Also:

  • #initialize(loc) ⇒ Wx::Icon

    Loads an icon from the specified location.

    Parameters:



66
# File 'lib/wx/doc/gen/icon.rb', line 66

def initialize(*args) end

Instance Method Details

#copy_from_bitmap(bmp) ⇒ void

This method returns an undefined value.

Copies bmp bitmap to this icon.

Under MS Windows the bitmap must have mask colour set.

Parameters:

See Also:



85
# File 'lib/wx/doc/gen/icon.rb', line 85

def copy_from_bitmap(bmp) end

#create_from_hicon(icon) ⇒ Boolean

Attach a Windows icon handle.

This WXMSW-specific method allows assigning a native Windows HICON (which must be cast to WXHICON opaque handle type) to Wx::Icon. Notice that this means that the HICON will be destroyed by Wx::Icon when it is destroyed. true if successful.

Availability: only available for the WXMSW port.

Parameters:

  • icon (WXHICON)

Returns:

  • (Boolean)

Requires:

  • WXMSW


77
# File 'lib/wx/doc/gen/icon.rb', line 77

def create_from_hicon(icon) end

#get_depthInteger Also known as: depth

Gets the colour depth of the icon.

A value of 1 indicates a monochrome icon.

Returns:

  • (Integer)


91
# File 'lib/wx/doc/gen/icon.rb', line 91

def get_depth; end

#get_heightInteger Also known as: height

Gets the height of the icon in physical pixels.

Returns:

  • (Integer)

See Also:



100
# File 'lib/wx/doc/gen/icon.rb', line 100

def get_height; end

#get_logical_heightFloat Also known as: logical_height

Gets the height of the icon in logical pixels.

See Bitmap#get_logical_height.

Returns:

  • (Float)


107
# File 'lib/wx/doc/gen/icon.rb', line 107

def get_logical_height; end

#get_logical_sizeWx::Size Also known as: logical_size

Gets the size of the icon in logical pixels.

See Bitmap#get_logical_size.

Returns:



114
# File 'lib/wx/doc/gen/icon.rb', line 114

def get_logical_size; end

#get_logical_widthFloat Also known as: logical_width

Gets the width of the icon in logical pixels.

See Bitmap#get_logical_width.

Returns:

  • (Float)


121
# File 'lib/wx/doc/gen/icon.rb', line 121

def get_logical_width; end

#get_scale_factorFloat Also known as: scale_factor

Gets the scale factor of this icon.

See Bitmap#get_scale_factor.

Returns:

  • (Float)


128
# File 'lib/wx/doc/gen/icon.rb', line 128

def get_scale_factor; end

#get_sizeWx::Size Also known as: size

Gets the size of the icon in physical pixels.

Returns:

See Also:



136
# File 'lib/wx/doc/gen/icon.rb', line 136

def get_size; end

#get_widthInteger Also known as: width

Gets the width of the icon in physical pixels.

Returns:

  • (Integer)

See Also:



145
# File 'lib/wx/doc/gen/icon.rb', line 145

def get_width; end

#is_okBoolean Also known as: ok?

Returns true if icon data is present.

Returns:

  • (Boolean)


150
# File 'lib/wx/doc/gen/icon.rb', line 150

def is_ok; end

#load_file(name, type = Wx::ICON_DEFAULT_TYPE, desiredWidth = -1,, desiredHeight = -1)) ⇒ Boolean

Loads an icon from a file or resource.

true if the operation succeeded, false otherwise.

Parameters:

  • name (String)

    Either a filename or a Windows resource name. The meaning of name is determined by the type parameter.

  • type (Wx::BitmapType) (defaults to: Wx::ICON_DEFAULT_TYPE)

    One of the BitmapType values; see the note in the class detailed description. Note that the Wx::ICON_DEFAULT_TYPE constant has different value under different wxWidgets ports. See the icon.h header for the value it takes for a specific port.

  • desiredWidth (Integer) (defaults to: -1,)

    Specifies the desired width of the icon. This parameter only has an effect in Windows where icon resources can contain several icons of different sizes.

  • desiredHeight (Integer) (defaults to: -1))

    Specifies the desired height of the icon. This parameter only has an effect in Windows where icon resources can contain several icons of different sizes.

Returns:

  • (Boolean)


161
# File 'lib/wx/doc/gen/icon.rb', line 161

def load_file(name, type=Wx::ICON_DEFAULT_TYPE, desiredWidth=-1, desiredHeight=-1) end