// Package gtk was automatically generated by github.com/bnema/puregotk DO NOT EDIT package gtk import ( "structs" "unsafe" "github.com/ebitengine/purego" "github.com/bnema/puregotk/pkg/core" "github.com/bnema/puregotk/v4/cairo" "github.com/bnema/puregotk/v4/glib" "github.com/bnema/puregotk/v4/gobject" "github.com/bnema/puregotk/v4/gobject/types" ) // Whenever @drawing_area needs to redraw, this function will be called. // // This function should exclusively redraw the contents of the drawing area // and must not call any widget functions that cause changes. type DrawingAreaDrawFunc func(uintptr, *cairo.Context, int, int, uintptr) type DrawingAreaClass struct { _ structs.HostLayout ParentClass WidgetClass xResize uintptr Padding [8]uintptr } func (x *DrawingAreaClass) GoPointer() uintptr { return uintptr(unsafe.Pointer(x)) } // OverrideResize sets the "resize" callback function. func (x *DrawingAreaClass) OverrideResize(cb func(*DrawingArea, int, int)) { if cb == nil { x.xResize = 0 } else { x.xResize = purego.NewCallback(func(AreaVarp uintptr, WidthVarp int, HeightVarp int) { cb(DrawingAreaNewFromInternalPtr(AreaVarp), WidthVarp, HeightVarp) }) } } // GetResize gets the "resize" callback function. func (x *DrawingAreaClass) GetResize() func(*DrawingArea, int, int) { if x.xResize == 0 { return nil } var rawCallback func(AreaVarp uintptr, WidthVarp int, HeightVarp int) purego.RegisterFunc(&rawCallback, x.xResize) return func(AreaVar *DrawingArea, WidthVar int, HeightVar int) { rawCallback(AreaVar.GoPointer(), WidthVar, HeightVar) } } // Allows drawing with cairo. // // <picture> // // <source srcset="drawingarea-dark.png" media="(prefers-color-scheme: dark)"> // <img alt="An example GtkDrawingArea" src="drawingarea.png"> // // </picture> // // It’s essentially a blank widget; you can draw on it. After // creating a drawing area, the application may want to connect to: // // - The [signal@Gtk.Widget::realize] signal to take any necessary actions // when the widget is instantiated on a particular display. // (Create GDK resources in response to this signal.) // // - The [signal@Gtk.DrawingArea::resize] signal to take any necessary // actions when the widget changes size. // // - Call [method@Gtk.DrawingArea.set_draw_func] to handle redrawing the // contents of the widget. // // The following code portion demonstrates using a drawing // area to display a circle in the normal widget foreground // color. // // ## Simple GtkDrawingArea usage // // ```c // static void // draw_function (GtkDrawingArea *area, // // cairo_t *cr, // int width, // int height, // gpointer data) // // { // GdkRGBA color; // // cairo_arc (cr, // width / 2.0, height / 2.0, // MIN (width, height) / 2.0, // 0, 2 * G_PI); // // gtk_widget_get_color (GTK_WIDGET (area), // &color); // gdk_cairo_set_source_rgba (cr, &color); // // cairo_fill (cr); // } // // int // main (int argc, char **argv) // // { // gtk_init (); // // GtkWidget *area = gtk_drawing_area_new (); // gtk_drawing_area_set_content_width (GTK_DRAWING_AREA (area), 100); // gtk_drawing_area_set_content_height (GTK_DRAWING_AREA (area), 100); // gtk_drawing_area_set_draw_func (GTK_DRAWING_AREA (area), // draw_function, // NULL, NULL); // return 0; // } // // ``` // // The draw function is normally called when a drawing area first comes // onscreen, or when it’s covered by another window and then uncovered. // You can also force a redraw by adding to the “damage region” of the // drawing area’s window using [method@Gtk.Widget.queue_draw]. // This will cause the drawing area to call the draw function again. // // The available routines for drawing are documented in the // [Cairo documentation](https://www.cairographics.org/manual/); GDK // offers additional API to integrate with Cairo, like [func@Gdk.cairo_set_source_rgba] // or [func@Gdk.cairo_set_source_pixbuf]. // // To receive mouse events on a drawing area, you will need to use // event controllers. To receive keyboard events, you will need to set // the “can-focus” property on the drawing area, and you should probably // draw some user-visible indication that the drawing area is focused. // // If you need more complex control over your widget, you should consider // creating your own `GtkWidget` subclass. type DrawingArea struct { Widget } var xDrawingAreaGLibType func() types.GType func DrawingAreaGLibType() types.GType { return xDrawingAreaGLibType() } func DrawingAreaNewFromInternalPtr(ptr uintptr) *DrawingArea { cls := &DrawingArea{} cls.Ptr = ptr return cls } var xNewDrawingArea func() uintptr // Creates a new drawing area. func NewDrawingArea() *DrawingArea { var cls *DrawingArea cret := xNewDrawingArea() if cret == 0 { return nil } gobject.IncreaseRef(cret) cls = &DrawingArea{} cls.Ptr = cret return cls } var xDrawingAreaGetContentHeight func(uintptr) int // Retrieves the content height of the `GtkDrawingArea`. func (x *DrawingArea) GetContentHeight() int { cret := xDrawingAreaGetContentHeight(x.GoPointer()) return cret } var xDrawingAreaGetContentWidth func(uintptr) int // Retrieves the content width of the `GtkDrawingArea`. func (x *DrawingArea) GetContentWidth() int { cret := xDrawingAreaGetContentWidth(x.GoPointer()) return cret } var xDrawingAreaSetContentHeight func(uintptr, int) // Sets the desired height of the contents of the drawing area. // // Note that because widgets may be allocated larger sizes than they // requested, it is possible that the actual height passed to your draw // function is larger than the height set here. You can use // [method@Gtk.Widget.set_valign] to avoid that. // // If the height is set to 0 (the default), the drawing area may disappear. func (x *DrawingArea) SetContentHeight(HeightVar int) { xDrawingAreaSetContentHeight(x.GoPointer(), HeightVar) } var xDrawingAreaSetContentWidth func(uintptr, int) // Sets the desired width of the contents of the drawing area. // // Note that because widgets may be allocated larger sizes than they // requested, it is possible that the actual width passed to your draw // function is larger than the width set here. You can use // [method@Gtk.Widget.set_halign] to avoid that. // // If the width is set to 0 (the default), the drawing area may disappear. func (x *DrawingArea) SetContentWidth(WidthVar int) { xDrawingAreaSetContentWidth(x.GoPointer(), WidthVar) } var xDrawingAreaSetDrawFunc func(uintptr, uintptr, uintptr, uintptr) // Setting a draw function is the main thing you want to do when using // a drawing area. // // The draw function is called whenever GTK needs to draw the contents // of the drawing area to the screen. // // The draw function will be called during the drawing stage of GTK. // In the drawing stage it is not allowed to change properties of any // GTK widgets or call any functions that would cause any properties // to be changed. You should restrict yourself exclusively to drawing // your contents in the draw function. // // If what you are drawing does change, call [method@Gtk.Widget.queue_draw] // on the drawing area. This will cause a redraw and will call @draw_func again. func (x *DrawingArea) SetDrawFunc(DrawFuncVar *DrawingAreaDrawFunc, UserDataVar uintptr, DestroyVar *glib.DestroyNotify) { var DrawFuncVarRef uintptr if DrawFuncVar != nil { DrawFuncVarPtr := uintptr(unsafe.Pointer(DrawFuncVar)) if cbRefPtr, ok := glib.GetCallback(DrawFuncVarPtr); ok { DrawFuncVarRef = cbRefPtr } else { fcb := func(arg0 uintptr, arg1 *cairo.Context, arg2 int, arg3 int, arg4 uintptr) { cbFn := *DrawFuncVar cbFn(arg0, arg1, arg2, arg3, arg4) } DrawFuncVarRef = purego.NewCallback(fcb) glib.SaveCallbackWithClosure(DrawFuncVarPtr, DrawFuncVarRef, DrawFuncVar) } } 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) } } xDrawingAreaSetDrawFunc(x.GoPointer(), DrawFuncVarRef, UserDataVar, DestroyVarRef) } func (c *DrawingArea) GoPointer() uintptr { if c == nil { return 0 } return c.Ptr } func (c *DrawingArea) SetGoPointer(ptr uintptr) { c.Ptr = ptr } // SetPropertyContentHeight sets the "content-height" property. // The content height. func (x *DrawingArea) SetPropertyContentHeight(value int) { var v gobject.Value v.Init(gobject.TypeIntVal) v.SetInt(value) x.SetProperty("content-height", &v) } // GetPropertyContentHeight gets the "content-height" property. // The content height. func (x *DrawingArea) GetPropertyContentHeight() int { var v gobject.Value x.GetProperty("content-height", &v) return v.GetInt() } // SetPropertyContentWidth sets the "content-width" property. // The content width. func (x *DrawingArea) SetPropertyContentWidth(value int) { var v gobject.Value v.Init(gobject.TypeIntVal) v.SetInt(value) x.SetProperty("content-width", &v) } // GetPropertyContentWidth gets the "content-width" property. // The content width. func (x *DrawingArea) GetPropertyContentWidth() int { var v gobject.Value x.GetProperty("content-width", &v) return v.GetInt() } // Emitted once when the widget is realized, and then each time the widget // is changed while realized. // // This is useful in order to keep state up to date with the widget size, // like for instance a backing surface. func (x *DrawingArea) ConnectResize(cb *func(DrawingArea, int, int)) uint { cbPtr := uintptr(unsafe.Pointer(cb)) if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { handlerID := gobject.SignalConnect(x.GoPointer(), "resize", cbRefPtr) glib.SaveHandlerMapping(handlerID, cbPtr) return handlerID } fcb := func(clsPtr uintptr, WidthVarp int, HeightVarp int) { fa := DrawingArea{} fa.Ptr = clsPtr cbFn := *cb cbFn(fa, WidthVarp, HeightVarp) } cbRefPtr := purego.NewCallback(fcb) glib.SaveCallbackWithClosure(cbPtr, cbRefPtr, cb) handlerID := gobject.SignalConnect(x.GoPointer(), "resize", cbRefPtr) glib.SaveHandlerMapping(handlerID, cbPtr) return handlerID } // Requests the user's screen reader to announce the given message. // // This kind of notification is useful for messages that // either have only a visual representation or that are not // exposed visually at all, e.g. a notification about a // successful operation. // // Also, by using this API, you can ensure that the message // does not interrupts the user's current screen reader output. func (x *DrawingArea) Announce(MessageVar string, PriorityVar AccessibleAnnouncementPriority) { XGtkAccessibleAnnounce(x.GoPointer(), MessageVar, PriorityVar) } // Retrieves the accessible parent for an accessible object. // // This function returns `NULL` for top level widgets. func (x *DrawingArea) GetAccessibleParent() *AccessibleBase { var cls *AccessibleBase cret := XGtkAccessibleGetAccessibleParent(x.GoPointer()) if cret == 0 { return nil } cls = &AccessibleBase{} cls.Ptr = cret return cls } // Retrieves the accessible role of an accessible object. func (x *DrawingArea) GetAccessibleRole() AccessibleRole { cret := XGtkAccessibleGetAccessibleRole(x.GoPointer()) return cret } // Retrieves the implementation for the given accessible object. func (x *DrawingArea) GetAtContext() *ATContext { var cls *ATContext cret := XGtkAccessibleGetAtContext(x.GoPointer()) if cret == 0 { return nil } cls = &ATContext{} cls.Ptr = cret return cls } // Queries the coordinates and dimensions of this accessible // // This functionality can be overridden by `GtkAccessible` // implementations, e.g. to get the bounds from an ignored // child widget. func (x *DrawingArea) GetBounds(XVar *int, YVar *int, WidthVar *int, HeightVar *int) bool { cret := XGtkAccessibleGetBounds(x.GoPointer(), XVar, YVar, WidthVar, HeightVar) return cret } // Retrieves the first accessible child of an accessible object. func (x *DrawingArea) GetFirstAccessibleChild() *AccessibleBase { var cls *AccessibleBase cret := XGtkAccessibleGetFirstAccessibleChild(x.GoPointer()) if cret == 0 { return nil } cls = &AccessibleBase{} cls.Ptr = cret return cls } // Retrieves the next accessible sibling of an accessible object func (x *DrawingArea) GetNextAccessibleSibling() *AccessibleBase { var cls *AccessibleBase cret := XGtkAccessibleGetNextAccessibleSibling(x.GoPointer()) if cret == 0 { return nil } cls = &AccessibleBase{} cls.Ptr = cret return cls } // Queries a platform state, such as focus. // // This functionality can be overridden by `GtkAccessible` // implementations, e.g. to get platform state from an ignored // child widget, as is the case for `GtkText` wrappers. func (x *DrawingArea) GetPlatformState(StateVar AccessiblePlatformState) bool { cret := XGtkAccessibleGetPlatformState(x.GoPointer(), StateVar) return cret } // Resets the accessible property to its default value. func (x *DrawingArea) ResetProperty(PropertyVar AccessibleProperty) { XGtkAccessibleResetProperty(x.GoPointer(), PropertyVar) } // Resets the accessible relation to its default value. func (x *DrawingArea) ResetRelation(RelationVar AccessibleRelation) { XGtkAccessibleResetRelation(x.GoPointer(), RelationVar) } // Resets the accessible state to its default value. func (x *DrawingArea) ResetState(StateVar AccessibleState) { XGtkAccessibleResetState(x.GoPointer(), StateVar) } // Sets the parent and sibling of an accessible object. // // This function is meant to be used by accessible implementations that are // not part of the widget hierarchy, and but act as a logical bridge between // widgets. For instance, if a widget creates an object that holds metadata // for each child, and you want that object to implement the `GtkAccessible` // interface, you will use this function to ensure that the parent of each // child widget is the metadata object, and the parent of each metadata // object is the container widget. func (x *DrawingArea) SetAccessibleParent(ParentVar Accessible, NextSiblingVar Accessible) { XGtkAccessibleSetAccessibleParent(x.GoPointer(), ParentVar.GoPointer(), NextSiblingVar.GoPointer()) } // Updates the next accessible sibling. // // That might be useful when a new child of a custom accessible // is created, and it needs to be linked to a previous child. func (x *DrawingArea) UpdateNextAccessibleSibling(NewSiblingVar Accessible) { XGtkAccessibleUpdateNextAccessibleSibling(x.GoPointer(), NewSiblingVar.GoPointer()) } // Informs ATs that the platform state has changed. // // This function should be used by `GtkAccessible` implementations that // have a platform state but are not widgets. Widgets handle platform // states automatically. func (x *DrawingArea) UpdatePlatformState(StateVar AccessiblePlatformState) { XGtkAccessibleUpdatePlatformState(x.GoPointer(), StateVar) } // Updates a list of accessible properties. // // See the [enum@Gtk.AccessibleProperty] documentation for the // value types of accessible properties. // // This function should be called by `GtkWidget` types whenever // an accessible property change must be communicated to assistive // technologies. // // Example: // ```c // value = gtk_adjustment_get_value (adjustment); // gtk_accessible_update_property (GTK_ACCESSIBLE (spin_button), // // GTK_ACCESSIBLE_PROPERTY_VALUE_NOW, value, // -1); // // ``` func (x *DrawingArea) UpdateProperty(FirstPropertyVar AccessibleProperty, varArgs ...interface{}) { XGtkAccessibleUpdateProperty(x.GoPointer(), FirstPropertyVar, varArgs...) } // Updates an array of accessible properties. // // This function should be called by `GtkWidget` types whenever an accessible // property change must be communicated to assistive technologies. // // This function is meant to be used by language bindings. func (x *DrawingArea) UpdatePropertyValue(NPropertiesVar int, PropertiesVar []AccessibleProperty, ValuesVar []gobject.Value) { XGtkAccessibleUpdatePropertyValue(x.GoPointer(), NPropertiesVar, PropertiesVar, ValuesVar) } // Updates a list of accessible relations. // // This function should be called by `GtkWidget` types whenever an accessible // relation change must be communicated to assistive technologies. // // If the [enum@Gtk.AccessibleRelation] requires a list of references, // you should pass each reference individually, followed by `NULL`, e.g. // // ```c // gtk_accessible_update_relation (accessible, // // GTK_ACCESSIBLE_RELATION_CONTROLS, // ref1, NULL, // GTK_ACCESSIBLE_RELATION_LABELLED_BY, // ref1, ref2, ref3, NULL, // -1); // // ``` func (x *DrawingArea) UpdateRelation(FirstRelationVar AccessibleRelation, varArgs ...interface{}) { XGtkAccessibleUpdateRelation(x.GoPointer(), FirstRelationVar, varArgs...) } // Updates an array of accessible relations. // // This function should be called by `GtkWidget` types whenever an accessible // relation change must be communicated to assistive technologies. // // This function is meant to be used by language bindings. func (x *DrawingArea) UpdateRelationValue(NRelationsVar int, RelationsVar []AccessibleRelation, ValuesVar []gobject.Value) { XGtkAccessibleUpdateRelationValue(x.GoPointer(), NRelationsVar, RelationsVar, ValuesVar) } // Updates a list of accessible states. // // See the [enum@Gtk.AccessibleState] documentation for the // value types of accessible states. // // This function should be called by `GtkWidget` types whenever // an accessible state change must be communicated to assistive // technologies. // // Example: // // ```c // value = GTK_ACCESSIBLE_TRISTATE_MIXED; // gtk_accessible_update_state (GTK_ACCESSIBLE (check_button), // // GTK_ACCESSIBLE_STATE_CHECKED, value, // -1); // // ``` func (x *DrawingArea) UpdateState(FirstStateVar AccessibleState, varArgs ...interface{}) { XGtkAccessibleUpdateState(x.GoPointer(), FirstStateVar, varArgs...) } // Updates an array of accessible states. // // This function should be called by `GtkWidget` types whenever an accessible // state change must be communicated to assistive technologies. // // This function is meant to be used by language bindings. func (x *DrawingArea) UpdateStateValue(NStatesVar int, StatesVar []AccessibleState, ValuesVar []gobject.Value) { XGtkAccessibleUpdateStateValue(x.GoPointer(), NStatesVar, StatesVar, ValuesVar) } // Gets the ID of the @buildable object. // // `GtkBuilder` sets the name based on the ID attribute // of the `<object>` tag used to construct the @buildable. func (x *DrawingArea) GetBuildableId() string { cret := XGtkBuildableGetBuildableId(x.GoPointer()) return cret } func init() { core.SetPackageName("GTK", "gtk4") core.SetSharedLibraries("GTK", []string{"libgtk-4.so.1"}) var libs []uintptr for _, libPath := range core.GetPaths("GTK") { lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL) if err != nil { panic(err) } libs = append(libs, lib) } core.PuregoSafeRegister(&xDrawingAreaGLibType, libs, "gtk_drawing_area_get_type") core.PuregoSafeRegister(&xNewDrawingArea, libs, "gtk_drawing_area_new") core.PuregoSafeRegister(&xDrawingAreaGetContentHeight, libs, "gtk_drawing_area_get_content_height") core.PuregoSafeRegister(&xDrawingAreaGetContentWidth, libs, "gtk_drawing_area_get_content_width") core.PuregoSafeRegister(&xDrawingAreaSetContentHeight, libs, "gtk_drawing_area_set_content_height") core.PuregoSafeRegister(&xDrawingAreaSetContentWidth, libs, "gtk_drawing_area_set_content_width") core.PuregoSafeRegister(&xDrawingAreaSetDrawFunc, libs, "gtk_drawing_area_set_draw_func") }