wCursor

A cursor is a small bitmap usually used for denoting where the mouse pointer is. There are two special predefined cursor: wNilCursor and wDefaultCursor. See wWindow.setCursor() for details.

Superclass:wGdiObject
Seealso:wDC wIconImage
Enum:
wStockCursorDescription
wCursorArrowStandard arrow
wCursorIbeamI-beam
wCursorWaitHourglass
wCursorCrossCrosshair
wCursorUpArrowVertical arrow
wCursorSizeNwseDouble-pointed arrow pointing northwest and southeast
wCursorSizeNeswDouble-pointed arrow pointing northeast and southwest
wCursorSizeWeDouble-pointed arrow pointing west and east
wCursorSizeNsDouble-pointed arrow pointing north and south
wCursorSizeAllFour-pointed arrow pointing north, south, east, and west
wCursorNoSlashed circle
wCursorHandHand
wCursorAppStartingStandard arrow and small hourglass
wCursorHelpArrow and question mark

Types

wStockCursor = enum
  wCursorArrow = 32512, wCursorIbeam = 32513, wCursorWait = 32514, wCursorCross = 32515,
  wCursorUpArrow = 32516, wCursorSize = 32640, wCursorIcon = 32641,
  wCursorSizeNwse = 32642, wCursorSizeNesw = 32643, wCursorSizeWe = 32644,
  wCursorSizeNs = 32645, wCursorSizeAll = 32646, wCursorNo = 32648, wCursorHand = 32649,
  wCursorAppStarting = 32650, wCursorHelp = 32651
wCursorError = object of wGdiObjectError
  
An error raised when wCursor creation failed.

Procs

proc getHotspot(self: wCursor): wPoint {...}{.raises: [], tags: [].}
Returns the coordinates of the cursor hotspot.
proc getSize(self: wCursor): wSize {...}{.raises: [], tags: [].}
Returns the size of the cursor.
proc getWidth(self: wCursor): int {...}{.inline, raises: [], tags: [].}
Gets the width of the cursor in pixels.
proc getHeight(self: wCursor): int {...}{.inline, raises: [], tags: [].}
Gets the height of the cursor in pixels.
proc init(self: wCursor; hCursor: HCURSOR; copy = true; shared = false;
         hotspot = wDefaultPoint) {...}{.raises: [wCursorError], tags: [].}
Initializes a cursor from system cursor handle. If copy is false, the function only wrap the handle to wCursor object. If shared is false, the handle will be destroyed together with wCursor object by the GC. Otherwise, the caller is responsible for destroying it. Hotspot can be changed if needed.
proc Cursor(hCursor: HCURSOR; copy = true; shared = false; hotspot = wDefaultPoint): wCursor {...}{.
    inline, discardable, raises: [wCursorError], tags: [].}
Constructor.
proc init(self: wCursor; id: wStockCursor) {...}{.raises: [wCursorError], tags: [].}
Initializes a cursor using a cursor identifier.
proc Cursor(id: wStockCursor): wCursor {...}{.inline, discardable, raises: [wCursorError],
                                     tags: [].}
Constructor.
proc init(self: wCursor; iconImage: wIconImage; size = wDefaultSize;
         hotspot = wDefaultPoint) {...}{.raises: [wNilAccess, wNilAccess, Exception,
    wCursorError], tags: [RootEffect].}
Initializes a cursor from an icon image. If hotspot is wDefaultPoint, it use the hotspot stored in wIconImage object. If it is wDefaultPoint too, the creation failed.
proc Cursor(iconImage: wIconImage; size = wDefaultSize; hotspot = wDefaultPoint): wCursor {...}{.
    inline, discardable, raises: [wNilAccess, Exception, wCursorError],
    tags: [RootEffect].}
Constructor.
proc init(self: wCursor; icon: wIcon; hotspot: wPoint) {...}{.inline,
    raises: [wNilAccess, wCursorError], tags: [].}
Initializes a cursor from the given wIcon object and hotspot.
proc Cursor(icon: wIcon; hotspot: wPoint): wCursor {...}{.inline, discardable,
    raises: [wNilAccess, wCursorError], tags: [].}
Constructor.
proc init(self: wCursor; image: wImage; hotspot: wPoint) {...}{.inline,
    raises: [wNilAccess, wNilAccess, Exception, wCursorError], tags: [RootEffect].}
Initializes a cursor from the given wImage object and hotspot.
proc Cursor(image: wImage; hotspot: wPoint): wCursor {...}{.inline, discardable,
    raises: [wNilAccess, Exception, wCursorError], tags: [RootEffect].}
Constructor.
proc init(self: wCursor; bmp: wBitmap; hotspot: wPoint) {...}{.inline,
    raises: [wNilAccess, wNilAccess, Exception, wCursorError], tags: [RootEffect].}
Initializes a cursor from the given wBitmap object and hotspot.
proc Cursor(bmp: wBitmap; hotspot: wPoint): wCursor {...}{.inline, discardable,
    raises: [wNilAccess, Exception, wCursorError], tags: [RootEffect].}
Constructor.
proc init(self: wCursor; cursor: wCursor; hotspot = wDefaultPoint) {...}{.inline,
    raises: [wNilAccess, wCursorError], tags: [].}
Initializes a cursor by wCursor object, aka. copy. Hotspot can be changed if needed.
proc Cursor(cursor: wCursor; hotspot = wDefaultPoint): wCursor {...}{.inline, discardable,
    raises: [wNilAccess, wCursorError], tags: [].}
Constructor.
proc init(self: wCursor; data: pointer; length: int; size = wDefaultSize;
         hotspot = wDefaultPoint) {...}{.raises: [wNilAccess, wNilAccess, Exception,
    wCursorError], tags: [RootEffect].}
Initializes a cursor from binary data of .ico, .cur, or .ani file.
proc Cursor(data: pointer; length: int; size = wDefaultSize; hotspot = wDefaultPoint): wCursor {...}{.
    inline, discardable, raises: [wNilAccess, Exception, wCursorError],
    tags: [RootEffect].}
Constructor.
proc init(self: wCursor; str: string; size = wDefaultSize; hotspot = wDefaultPoint) {...}{.
    raises: [wNilAccess, Exception, wCursorError], tags: [RootEffect, ReadIOEffect].}

Initializes a cursor from a file. The file should be in format of .ico, .cur, .ani, or Windows PE file (.exe or .dll, etc). If str is not a valid file path, it will be regarded as the binary data of .ico, .cur, or .ani file.

For Windows PE file (.exe or .dll), it allows string like "shell32.dll,-10" to specifies the icon index or "shell32.dll:-1001" to to specifies the cursor index. Use zero-based index to specified the resource position, and negative value to specified the resource identifier. Empty filename (e.g. ",-1") to specified the current executable file.

proc Cursor(str: string; size = wDefaultSize; hotspot = wDefaultPoint): wCursor {...}{.inline,
    discardable, raises: [wNilAccess, Exception, wCursorError],
    tags: [RootEffect, ReadIOEffect].}
Constructor.

Methods

method delete(self: wCursor) {...}{.raises: [], tags: [].}
Nim's garbage collector will delete this object by default. However, sometimes you maybe want do that by yourself.

Templates

template wNilCursor(): untyped
Predefined nil cursor. Don't delete.
template wDefaultCursor(): untyped
Predefined default cursor. Don't delete.
template wArrorCursor(): untyped
Predefined arror cursor. Don't delete.
template wSizeAllCursor(): untyped
Predefined size all cursor. Don't delete.
template wSizeWeCursor(): untyped
Predefined size west east cursor. Don't delete.
template wSizeNsCursor(): untyped
Predefined north south cursor. Don't delete.
template wHandCursor(): untyped
Predefined hand cursor. Don't delete.