Copyright | Will Thompson and Iñaki García Etxebarria |
---|---|
License | LGPL-2.1 |
Maintainer | Iñaki García Etxebarria |
Safe Haskell | None |
Language | Haskell2010 |
GdkCursor
is used to create and destroy cursors.
Cursors are immutable objects, so once you created them, there is no way to modify them later. You should create a new cursor when you want to change something about it.
Cursors by themselves are not very interesting: they must be bound to a
window for users to see them. This is done with surfaceSetCursor
or surfaceSetDeviceCursor
. Applications will typically
use higher-level GTK functions such as gtk_widget_set_cursor()
instead.
Cursors are not bound to a given Display
, so they can be shared.
However, the appearance of cursors may vary when used on different
platforms.
Named and texture cursors
There are multiple ways to create cursors. The platform's own cursors
can be created with cursorNewFromName
. That function lists
the commonly available names that are shared with the CSS specification.
Other names may be available, depending on the platform in use. On some
platforms, what images are used for named cursors may be influenced by
the cursor theme.
Another option to create a cursor is to use cursorNewFromTexture
and provide an image to use for the cursor.
To ease work with unsupported cursors, a fallback cursor can be provided.
If a Surface
cannot use a cursor because of the reasons mentioned
above, it will try the fallback cursor. Fallback cursors can themselves have
fallback cursors again, so it is possible to provide a chain of progressively
easier to support cursors. If none of the provided cursors can be supported,
the default cursor will be the ultimate fallback.
Synopsis
- newtype Cursor = Cursor (ManagedPtr Cursor)
- class (GObject o, IsDescendantOf Cursor o) => IsCursor o
- toCursor :: (MonadIO m, IsCursor o) => o -> m Cursor
- cursorGetFallback :: (HasCallStack, MonadIO m, IsCursor a) => a -> m (Maybe Cursor)
- cursorGetHotspotX :: (HasCallStack, MonadIO m, IsCursor a) => a -> m Int32
- cursorGetHotspotY :: (HasCallStack, MonadIO m, IsCursor a) => a -> m Int32
- cursorGetName :: (HasCallStack, MonadIO m, IsCursor a) => a -> m (Maybe Text)
- cursorGetTexture :: (HasCallStack, MonadIO m, IsCursor a) => a -> m (Maybe Texture)
- cursorNewFromName :: (HasCallStack, MonadIO m, IsCursor a) => Text -> Maybe a -> m (Maybe Cursor)
- cursorNewFromTexture :: (HasCallStack, MonadIO m, IsTexture a, IsCursor b) => a -> Int32 -> Int32 -> Maybe b -> m Cursor
- constructCursorFallback :: (IsCursor o, MonadIO m, IsCursor a) => a -> m (GValueConstruct o)
- getCursorFallback :: (MonadIO m, IsCursor o) => o -> m (Maybe Cursor)
- constructCursorHotspotX :: (IsCursor o, MonadIO m) => Int32 -> m (GValueConstruct o)
- getCursorHotspotX :: (MonadIO m, IsCursor o) => o -> m Int32
- constructCursorHotspotY :: (IsCursor o, MonadIO m) => Int32 -> m (GValueConstruct o)
- getCursorHotspotY :: (MonadIO m, IsCursor o) => o -> m Int32
- constructCursorName :: (IsCursor o, MonadIO m) => Text -> m (GValueConstruct o)
- getCursorName :: (MonadIO m, IsCursor o) => o -> m (Maybe Text)
- constructCursorTexture :: (IsCursor o, MonadIO m, IsTexture a) => a -> m (GValueConstruct o)
- getCursorTexture :: (MonadIO m, IsCursor o) => o -> m (Maybe Texture)
Exported types
Memory-managed wrapper type.
Instances
Eq Cursor Source # | |
GObject Cursor Source # | |
Defined in GI.Gdk.Objects.Cursor | |
ManagedPtrNewtype Cursor Source # | |
Defined in GI.Gdk.Objects.Cursor toManagedPtr :: Cursor -> ManagedPtr Cursor # | |
TypedObject Cursor Source # | |
Defined in GI.Gdk.Objects.Cursor | |
HasParentTypes Cursor Source # | |
Defined in GI.Gdk.Objects.Cursor | |
IsGValue (Maybe Cursor) Source # | Convert |
Defined in GI.Gdk.Objects.Cursor | |
type ParentTypes Cursor Source # | |
Defined in GI.Gdk.Objects.Cursor type ParentTypes Cursor = '[Object] |
Methods
Click to display all available methods, including inherited ones
Methods
bindProperty, bindPropertyFull, forceFloating, freezeNotify, getv, isFloating, notify, notifyByPspec, ref, refSink, runDispose, stealData, stealQdata, thawNotify, unref, watchClosure.
Getters
getData, getFallback, getHotspotX, getHotspotY, getName, getProperty, getQdata, getTexture.
Setters
getFallback
:: (HasCallStack, MonadIO m, IsCursor a) | |
=> a |
|
-> m (Maybe Cursor) | Returns: the fallback of the cursor or |
Returns the fallback for this cursor
.
The fallback will be used if this cursor is not available on a given
GdkDisplay
. For named cursors, this can happen when using nonstandard
names or when using an incomplete cursor theme. For textured cursors,
this can happen when the texture is too large or when the GdkDisplay
it is used on does not support textured cursors.
getHotspotX
:: (HasCallStack, MonadIO m, IsCursor a) | |
=> a |
|
-> m Int32 | Returns: the horizontal offset of the hotspot or 0 for named cursors |
Returns the horizontal offset of the hotspot.
The hotspot indicates the pixel that will be directly above the cursor.
Note that named cursors may have a nonzero hotspot, but this function
will only return the hotspot position for cursors created with
cursorNewFromTexture
.
getHotspotY
:: (HasCallStack, MonadIO m, IsCursor a) | |
=> a |
|
-> m Int32 | Returns: the vertical offset of the hotspot or 0 for named cursors |
Returns the vertical offset of the hotspot.
The hotspot indicates the pixel that will be directly above the cursor.
Note that named cursors may have a nonzero hotspot, but this function
will only return the hotspot position for cursors created with
cursorNewFromTexture
.
getName
:: (HasCallStack, MonadIO m, IsCursor a) | |
=> a |
|
-> m (Maybe Text) | Returns: the name of the cursor or |
Returns the name of the cursor.
If the cursor is not a named cursor, Nothing
will be returned.
getTexture
:: (HasCallStack, MonadIO m, IsCursor a) | |
=> a |
|
-> m (Maybe Texture) | Returns: the texture for cursor or |
Returns the texture for the cursor.
If the cursor is a named cursor, Nothing
will be returned.
newFromName
:: (HasCallStack, MonadIO m, IsCursor a) | |
=> Text |
|
-> Maybe a |
|
-> m (Maybe Cursor) | Returns: a new |
Creates a new cursor by looking up name
in the current cursor
theme.
A recommended set of cursor names that will work across different platforms can be found in the CSS specification:
| | | | | | --- | --- | ---- | --- | | "none" | "default" | "help" | "pointer" | | "context-menu" | "progress" | "wait" | "cell" | | "crosshair" | "text" | "vertical-text" | "alias" | | "copy" | "no-drop" | "move" | "not-allowed" | | "grab" | "grabbing" | "all-scroll" | "col-resize" | | "row-resize" | "n-resize" | "e-resize" | "s-resize" | | "w-resize" | "ne-resize" | "nw-resize" | "sw-resize" | | "se-resize" | "ew-resize" | "ns-resize" | "nesw-resize" | | "nwse-resize" | "zoom-in" | "zoom-out" | |
newFromTexture
:: (HasCallStack, MonadIO m, IsTexture a, IsCursor b) | |
=> a |
|
-> Int32 |
|
-> Int32 |
|
-> Maybe b |
|
-> m Cursor | Returns: a new |
Creates a new cursor from a GdkTexture
.
Properties
fallback
Cursor to fall back to if this cursor cannot be displayed.
constructCursorFallback :: (IsCursor o, MonadIO m, IsCursor a) => a -> m (GValueConstruct o) Source #
Construct a GValueConstruct
with valid value for the “fallback
” property. This is rarely needed directly, but it is used by new
.
getCursorFallback :: (MonadIO m, IsCursor o) => o -> m (Maybe Cursor) Source #
Get the value of the “fallback
” property.
When overloading is enabled, this is equivalent to
get
cursor #fallback
hotspotX
X position of the cursor hotspot in the cursor image.
constructCursorHotspotX :: (IsCursor o, MonadIO m) => Int32 -> m (GValueConstruct o) Source #
Construct a GValueConstruct
with valid value for the “hotspot-x
” property. This is rarely needed directly, but it is used by new
.
getCursorHotspotX :: (MonadIO m, IsCursor o) => o -> m Int32 Source #
Get the value of the “hotspot-x
” property.
When overloading is enabled, this is equivalent to
get
cursor #hotspotX
hotspotY
Y position of the cursor hotspot in the cursor image.
constructCursorHotspotY :: (IsCursor o, MonadIO m) => Int32 -> m (GValueConstruct o) Source #
Construct a GValueConstruct
with valid value for the “hotspot-y
” property. This is rarely needed directly, but it is used by new
.
getCursorHotspotY :: (MonadIO m, IsCursor o) => o -> m Int32 Source #
Get the value of the “hotspot-y
” property.
When overloading is enabled, this is equivalent to
get
cursor #hotspotY
name
Name of this this cursor.
The name will be Nothing
if the cursor was created from a texture.
constructCursorName :: (IsCursor o, MonadIO m) => Text -> m (GValueConstruct o) Source #
Construct a GValueConstruct
with valid value for the “name
” property. This is rarely needed directly, but it is used by new
.
getCursorName :: (MonadIO m, IsCursor o) => o -> m (Maybe Text) Source #
Get the value of the “name
” property.
When overloading is enabled, this is equivalent to
get
cursor #name
texture
The texture displayed by this cursor.
The texture will be Nothing
if the cursor was created from a name.
constructCursorTexture :: (IsCursor o, MonadIO m, IsTexture a) => a -> m (GValueConstruct o) Source #
Construct a GValueConstruct
with valid value for the “texture
” property. This is rarely needed directly, but it is used by new
.
getCursorTexture :: (MonadIO m, IsCursor o) => o -> m (Maybe Texture) Source #
Get the value of the “texture
” property.
When overloading is enabled, this is equivalent to
get
cursor #texture