Class: Wx::Cursor

Inherits:
GDIObject show all
Defined in:
lib/wx/doc/gen/cursor.rb

Overview

Note:

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

A cursor is a small bitmap usually used for denoting where the mouse pointer is, with a picture that might indicate the interpretation of a mouse click.

As with icons, cursors in X and MS Windows are created in a different manner. Therefore, separate cursors will be created for the different environments. Platform-specific methods for creating a Cursor object are catered for, and this is an occasion where conditional compilation will probably be required (see Icon for an example). A single cursor object may be used in many windows (any subwindow type). The wxWidgets convention is to set the cursor for a window, as in X, rather than to set it globally as in MS Windows, although a global set_cursor function is also available for MS Windows use.

Category: Graphics Device Interface (GDI) Predefined objects/pointers: - NULL_CURSOR - STANDARD_CURSOR - HOURGLASS_CURSOR - CROSS_CURSOR

Instance Method Summary collapse

Methods inherited from GDIObject

#clone, #dup

Methods inherited from Object

#clone, #dup, #is_same_as, #un_share

Constructor Details

#initializeWx::Cursor #initialize(cursorName, type = Wx::CURSOR_DEFAULT_TYPE, hotSpotX = 0, hotSpotY = 0) ⇒ Wx::Cursor #initialize(cursorId) ⇒ Wx::Cursor #initialize(image) ⇒ Wx::Cursor #initialize(cursor) ⇒ Wx::Cursor

Returns a new instance of Cursor.

Overloads:

  • #initializeWx::Cursor

    Default constructor.

  • #initialize(cursorName, type = Wx::CURSOR_DEFAULT_TYPE, hotSpotX = 0, hotSpotY = 0) ⇒ Wx::Cursor

    Constructs a cursor by passing a string resource name or filename.

    The arguments hotSpotX and hotSpotY are only used when there’s no hotspot info in the resource/image-file to load (e.g. when using BitmapType::BITMAP_TYPE_ICO under WXMSW or BitmapType::BITMAP_TYPE_XPM under WXGTK).

    Parameters:

    • cursorName (String)

      The name of the resource or the image file to load.

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

      Icon type to load. It defaults to Wx::CURSOR_DEFAULT_TYPE, which is a #define associated to different values on different platforms:

      • under Windows, it defaults to BITMAP_TYPE_CUR_RESOURCE. Other permitted types under Windows are BitmapType::BITMAP_TYPE_CUR (to load a cursor from a .cur cursor file), BitmapType::BITMAP_TYPE_ICO (to load a cursor from a .ico icon file) and BitmapType::BITMAP_TYPE_ANI (to load a cursor from a .ani icon file).

      • under MacOS, it defaults to BITMAP_TYPE_MACCURSOR_RESOURCE; when specifying a string resource name, first the color cursors ‘crsr’ and then the black/white cursors ‘CURS’ in the resource chain are scanned through. Note that resource forks are deprecated on macOS so this is only available for legacy reasons and should not be used in new code.

      • under GTK, it defaults to BitmapType::BITMAP_TYPE_XPM. See the wxCursor(const wxImage& image) ctor for more info.

      • under X11, it defaults to BitmapType::BITMAP_TYPE_XPM.

      • under Motif, it defaults to BitmapType::BITMAP_TYPE_XBM.

    • hotSpotX (Integer) (defaults to: 0)

      Hotspot x coordinate (relative to the top left of the image).

    • hotSpotY (Integer) (defaults to: 0)

      Hotspot y coordinate (relative to the top left of the image).

  • #initialize(cursorId) ⇒ Wx::Cursor

    Constructs a cursor using a cursor identifier.

    Parameters:

  • #initialize(image) ⇒ Wx::Cursor

    Constructs a cursor from a Image.

    If cursor are monochrome on the current platform, colors with the RGB elements all greater than 127 will be foreground, colors less than this background. The mask (if any) will be used to specify the transparent area. In WXMSW the foreground will be white and the background black. If the cursor is larger than 32x32 it is resized. In WXGTK, colour cursors and alpha channel are supported (starting from GTK+ 2.2). Otherwise the two most frequent colors will be used for foreground and background. In any case, the cursor will be displayed at the size of the image. Under WXOSX (Cocoa), large cursors are supported. Notice that the image can define the cursor hot spot. To set it you need to use Image#set_option with IMAGE_OPTION_CUR_HOTSPOT_X or IMAGE_OPTION_CUR_HOTSPOT_Y, e.g.

    image.set_option(Wx::IMAGE_OPTION_CUR_HOTSPOT_X, hotSpotX)
      image.set_option(Wx::IMAGE_OPTION_CUR_HOTSPOT_X, hotSpotY)
    

    Parameters:

  • #initialize(cursor) ⇒ Wx::Cursor

    Copy constructor, uses reference counting.

    Parameters:

    • cursor (Wx::Cursor)

      Pointer or reference to a cursor to copy.



79
# File 'lib/wx/doc/gen/cursor.rb', line 79

def initialize(*args) end

Instance Method Details

#get_hot_spotWx::Point Also known as: hot_spot

Returns the coordinates of the cursor hot spot.

The hot spot is the point at which the mouse is actually considered to be when this cursor is used. This method is currently only implemented in WXMSW and WXGTK2+ and simply returns DEFAULT_POSITION in the other ports.

Returns:



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

def get_hot_spot; end

#is_okBoolean Also known as: ok?

Returns true if cursor data is present.

Returns:

  • (Boolean)


83
# File 'lib/wx/doc/gen/cursor.rb', line 83

def is_ok; end