// Package gdk was automatically generated by github.com/bnema/puregotk DO NOT EDIT package gdk import ( "unsafe" "github.com/ebitengine/purego" "github.com/bnema/puregotk/pkg/core" "github.com/bnema/puregotk/v4/glib" "github.com/bnema/puregotk/v4/gobject" "github.com/bnema/puregotk/v4/gobject/types" ) // The type of callback used by a dynamic `GdkCursor` to generate // a texture for the cursor image at the given @cursor_size // and @scale. // // The actual cursor size in application pixels may be different // from @cursor_size x @cursor_size, and will be returned in // @width, @height. The returned texture should have a size that // corresponds to the actual cursor size, in device pixels (i.e. // application pixels, multiplied by @scale). // // This function may fail and return `NULL`, in which case // the fallback cursor will be used. type CursorGetTextureCallback func(uintptr, int, float64, *int, *int, *int, *int, uintptr) uintptr // 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 [method@Gdk.Surface.set_cursor] // or [method@Gdk.Surface.set_device_cursor]. Applications will typically // use higher-level GTK functions such as [gtk_widget_set_cursor()](../gtk4/method.Widget.set_cursor.html) // instead. // // Cursors are not bound to a given [class@Gdk.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 [ctor@Gdk.Cursor.new_from_name]. 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 [ctor@Gdk.Cursor.new_from_texture] // and provide an image to use for the cursor. // // To ease work with unsupported cursors, a fallback cursor can be provided. // If a [class@Gdk.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. type Cursor struct { gobject.Object } var xCursorGLibType func() types.GType func CursorGLibType() types.GType { return xCursorGLibType() } func CursorNewFromInternalPtr(ptr uintptr) *Cursor { cls := &Cursor{} cls.Ptr = ptr return cls } var xNewCursorFromCallback func(uintptr, uintptr, uintptr, uintptr) uintptr // Creates a new callback-based cursor object. // // Cursors of this kind produce textures for the cursor // image on demand, when the @callback is called. func NewCursorFromCallback(CallbackVar *CursorGetTextureCallback, DataVar uintptr, DestroyVar *glib.DestroyNotify, FallbackVar *Cursor) *Cursor { var cls *Cursor var CallbackVarRef uintptr if CallbackVar != nil { CallbackVarPtr := uintptr(unsafe.Pointer(CallbackVar)) if cbRefPtr, ok := glib.GetCallback(CallbackVarPtr); ok { CallbackVarRef = cbRefPtr } else { fcb := func(arg0 uintptr, arg1 int, arg2 float64, arg3 *int, arg4 *int, arg5 *int, arg6 *int, arg7 uintptr) uintptr { cbFn := *CallbackVar return cbFn(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7) } CallbackVarRef = purego.NewCallback(fcb) glib.SaveCallbackWithClosure(CallbackVarPtr, CallbackVarRef, CallbackVar) } } var DestroyVarRef uintptr if DestroyVar != nil { DestroyVarPtr := uintptr(unsafe.Pointer(DestroyVar)) if cbRefPtr, ok := glib.GetCallback(DestroyVarPtr); ok { DestroyVarRef = cbRefPtr } else { fcb := func(arg0 uintptr) { cbFn := *DestroyVar cbFn(arg0) } DestroyVarRef = purego.NewCallback(fcb) glib.SaveCallbackWithClosure(DestroyVarPtr, DestroyVarRef, DestroyVar) } } cret := xNewCursorFromCallback(CallbackVarRef, DataVar, DestroyVarRef, FallbackVar.GoPointer()) if cret == 0 { return nil } cls = &Cursor{} cls.Ptr = cret return cls } var xNewCursorFromName func(string, uintptr) uintptr // 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" | No cursor | // | ![](default_cursor.png) | "default" | The default cursor | // | ![](help_cursor.png) | "help" | Help is available | // | ![](pointer_cursor.png) | "pointer" | Indicates a link or interactive element | // | ![](context_menu_cursor.png) |"context-menu" | A context menu is available | // | ![](progress_cursor.png) | "progress" | Progress indicator | // | ![](wait_cursor.png) | "wait" | Busy cursor | // | ![](cell_cursor.png) | "cell" | Cell(s) may be selected | // | ![](crosshair_cursor.png) | "crosshair" | Simple crosshair | // | ![](text_cursor.png) | "text" | Text may be selected | // | ![](vertical_text_cursor.png) | "vertical-text" | Vertical text may be selected | // | ![](alias_cursor.png) | "alias" | DND: Something will be linked | // | ![](copy_cursor.png) | "copy" | DND: Something will be copied | // | ![](move_cursor.png) | "move" | DND: Something will be moved | // | ![](dnd_ask_cursor.png) | "dnd-ask" | DND: User can choose action to be carried out | // | ![](no_drop_cursor.png) | "no-drop" | DND: Can't drop here | // | ![](not_allowed_cursor.png) | "not-allowed" | DND: Action will not be carried out | // | ![](grab_cursor.png) | "grab" | DND: Something can be grabbed | // | ![](grabbing_cursor.png) | "grabbing" | DND: Something is being grabbed | // | ![](n_resize_cursor.png) | "n-resize" | Resizing: Move north border | // | ![](e_resize_cursor.png) | "e-resize" | Resizing: Move east border | // | ![](s_resize_cursor.png) | "s-resize" | Resizing: Move south border | // | ![](w_resize_cursor.png) | "w-resize" | Resizing: Move west border | // | ![](ne_resize_cursor.png) | "ne-resize" | Resizing: Move north-east corner | // | ![](nw_resize_cursor.png) | "nw-resize" | Resizing: Move north-west corner | // | ![](sw_resize_cursor.png) | "sw-resize" | Resizing: Move south-west corner | // | ![](se_resize_cursor.png) | "se-resize" | Resizing: Move south-east corner | // | ![](col_resize_cursor.png) | "col-resize" | Resizing: Move an item or border horizontally | // | ![](row_resize_cursor.png) | "row-resize" | Resizing: Move an item or border vertically | // | ![](ew_resize_cursor.png) | "ew-resize" | Moving: Something can be moved horizontally | // | ![](ns_resize_cursor.png) | "ns-resize" | Moving: Something can be moved vertically | // | ![](nesw_resize_cursor.png) | "nesw-resize" | Moving: Something can be moved diagonally, north-east to south-west | // | ![](nwse_resize_cursor.png) | "nwse-resize" | Moving: something can be moved diagonally, north-west to south-east | // | ![](all_resize_cursor.png) | "all-resize" | Moving: Something can be moved in any direction | // | ![](all_scroll_cursor.png) | "all-scroll" | Can scroll in any direction | // | ![](zoom_in_cursor.png) | "zoom-in" | Zoom in | // | ![](zoom_out_cursor.png) | "zoom-out" | Zoom out | func NewCursorFromName(NameVar string, FallbackVar *Cursor) *Cursor { var cls *Cursor cret := xNewCursorFromName(NameVar, FallbackVar.GoPointer()) if cret == 0 { return nil } cls = &Cursor{} cls.Ptr = cret return cls } var xNewCursorFromTexture func(uintptr, int, int, uintptr) uintptr // Creates a new cursor from a `GdkTexture`. func NewCursorFromTexture(TextureVar *Texture, HotspotXVar int, HotspotYVar int, FallbackVar *Cursor) *Cursor { var cls *Cursor cret := xNewCursorFromTexture(TextureVar.GoPointer(), HotspotXVar, HotspotYVar, FallbackVar.GoPointer()) if cret == 0 { return nil } cls = &Cursor{} cls.Ptr = cret return cls } var xCursorGetFallback func(uintptr) uintptr // 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. func (x *Cursor) GetFallback() *Cursor { var cls *Cursor cret := xCursorGetFallback(x.GoPointer()) if cret == 0 { return nil } gobject.IncreaseRef(cret) cls = &Cursor{} cls.Ptr = cret return cls } var xCursorGetHotspotX func(uintptr) int // 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 // [ctor@Gdk.Cursor.new_from_texture]. func (x *Cursor) GetHotspotX() int { cret := xCursorGetHotspotX(x.GoPointer()) return cret } var xCursorGetHotspotY func(uintptr) int // 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 // [ctor@Gdk.Cursor.new_from_texture]. func (x *Cursor) GetHotspotY() int { cret := xCursorGetHotspotY(x.GoPointer()) return cret } var xCursorGetName func(uintptr) string // Returns the name of the cursor. // // If the cursor is not a named cursor, %NULL will be returned. func (x *Cursor) GetName() string { cret := xCursorGetName(x.GoPointer()) return cret } var xCursorGetTexture func(uintptr) uintptr // Returns the texture for the cursor. // // If the cursor is a named cursor, %NULL will be returned. func (x *Cursor) GetTexture() *Texture { var cls *Texture cret := xCursorGetTexture(x.GoPointer()) if cret == 0 { return nil } gobject.IncreaseRef(cret) cls = &Texture{} cls.Ptr = cret return cls } func (c *Cursor) GoPointer() uintptr { if c == nil { return 0 } return c.Ptr } func (c *Cursor) SetGoPointer(ptr uintptr) { c.Ptr = ptr } // SetPropertyHotspotX sets the "hotspot-x" property. // X position of the cursor hotspot in the cursor image. func (x *Cursor) SetPropertyHotspotX(value int) { var v gobject.Value v.Init(gobject.TypeIntVal) v.SetInt(value) x.SetProperty("hotspot-x", &v) } // GetPropertyHotspotX gets the "hotspot-x" property. // X position of the cursor hotspot in the cursor image. func (x *Cursor) GetPropertyHotspotX() int { var v gobject.Value x.GetProperty("hotspot-x", &v) return v.GetInt() } // SetPropertyHotspotY sets the "hotspot-y" property. // Y position of the cursor hotspot in the cursor image. func (x *Cursor) SetPropertyHotspotY(value int) { var v gobject.Value v.Init(gobject.TypeIntVal) v.SetInt(value) x.SetProperty("hotspot-y", &v) } // GetPropertyHotspotY gets the "hotspot-y" property. // Y position of the cursor hotspot in the cursor image. func (x *Cursor) GetPropertyHotspotY() int { var v gobject.Value x.GetProperty("hotspot-y", &v) return v.GetInt() } // SetPropertyName sets the "name" property. // Name of this this cursor. // // The name will be %NULL if the cursor was created from a texture. func (x *Cursor) SetPropertyName(value string) { var v gobject.Value v.Init(gobject.TypeStringVal) v.SetString(&value) x.SetProperty("name", &v) } // GetPropertyName gets the "name" property. // Name of this this cursor. // // The name will be %NULL if the cursor was created from a texture. func (x *Cursor) GetPropertyName() string { var v gobject.Value x.GetProperty("name", &v) return v.GetString() } func init() { core.SetPackageName("GDK", "gtk4") core.SetSharedLibraries("GDK", []string{"libgtk-4.so.1"}) var libs []uintptr for _, libPath := range core.GetPaths("GDK") { lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL) if err != nil { panic(err) } libs = append(libs, lib) } core.PuregoSafeRegister(&xCursorGLibType, libs, "gdk_cursor_get_type") core.PuregoSafeRegister(&xNewCursorFromCallback, libs, "gdk_cursor_new_from_callback") core.PuregoSafeRegister(&xNewCursorFromName, libs, "gdk_cursor_new_from_name") core.PuregoSafeRegister(&xNewCursorFromTexture, libs, "gdk_cursor_new_from_texture") core.PuregoSafeRegister(&xCursorGetFallback, libs, "gdk_cursor_get_fallback") core.PuregoSafeRegister(&xCursorGetHotspotX, libs, "gdk_cursor_get_hotspot_x") core.PuregoSafeRegister(&xCursorGetHotspotY, libs, "gdk_cursor_get_hotspot_y") core.PuregoSafeRegister(&xCursorGetName, libs, "gdk_cursor_get_name") core.PuregoSafeRegister(&xCursorGetTexture, libs, "gdk_cursor_get_texture") }