// 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/gdk" "github.com/bnema/puregotk/v4/gobject" "github.com/bnema/puregotk/v4/gobject/types" ) type WidgetPaintableClass struct { _ structs.HostLayout ParentClass gobject.ObjectClass } func (x *WidgetPaintableClass) GoPointer() uintptr { return uintptr(unsafe.Pointer(x)) } // A `GdkPaintable` that displays the contents of a widget. // // `GtkWidgetPaintable` will also take care of the widget not being in a // state where it can be drawn (like when it isn't shown) and just draw // nothing or where it does not have a size (like when it is hidden) and // report no size in that case. // // Of course, `GtkWidgetPaintable` allows you to monitor widgets for size // changes by emitting the [signal@Gdk.Paintable::invalidate-size] signal // whenever the size of the widget changes as well as for visual changes by // emitting the [signal@Gdk.Paintable::invalidate-contents] signal whenever // the widget changes. // // You can use a `GtkWidgetPaintable` everywhere a `GdkPaintable` is allowed, // including using it on a `GtkPicture` (or one of its parents) that it was // set on itself via gtk_picture_set_paintable(). The paintable will take care // of recursion when this happens. If you do this however, ensure that the // [property@Gtk.Picture:can-shrink] property is set to %TRUE or you might // end up with an infinitely growing widget. type WidgetPaintable struct { gobject.Object } var xWidgetPaintableGLibType func() types.GType func WidgetPaintableGLibType() types.GType { return xWidgetPaintableGLibType() } func WidgetPaintableNewFromInternalPtr(ptr uintptr) *WidgetPaintable { cls := &WidgetPaintable{} cls.Ptr = ptr return cls } var xNewWidgetPaintable func(uintptr) uintptr // Creates a new widget paintable observing the given widget. func NewWidgetPaintable(WidgetVar *Widget) *WidgetPaintable { var cls *WidgetPaintable cret := xNewWidgetPaintable(WidgetVar.GoPointer()) if cret == 0 { return nil } cls = &WidgetPaintable{} cls.Ptr = cret return cls } var xWidgetPaintableGetWidget func(uintptr) uintptr // Returns the widget that is observed or %NULL if none. func (x *WidgetPaintable) GetWidget() *Widget { var cls *Widget cret := xWidgetPaintableGetWidget(x.GoPointer()) if cret == 0 { return nil } gobject.IncreaseRef(cret) cls = &Widget{} cls.Ptr = cret return cls } var xWidgetPaintableSetWidget func(uintptr, uintptr) // Sets the widget that should be observed. func (x *WidgetPaintable) SetWidget(WidgetVar *Widget) { xWidgetPaintableSetWidget(x.GoPointer(), WidgetVar.GoPointer()) } func (c *WidgetPaintable) GoPointer() uintptr { if c == nil { return 0 } return c.Ptr } func (c *WidgetPaintable) SetGoPointer(ptr uintptr) { c.Ptr = ptr } // Compute a concrete size for the `GdkPaintable`. // // Applies the sizing algorithm outlined in the // [CSS Image spec](https://drafts.csswg.org/css-images-3/#default-sizing) // to the given @paintable. See that link for more details. // // It is not necessary to call this function when both @specified_width // and @specified_height are known, but it is useful to call this // function in GtkWidget:measure implementations to compute the // other dimension when only one dimension is given. func (x *WidgetPaintable) ComputeConcreteSize(SpecifiedWidthVar float64, SpecifiedHeightVar float64, DefaultWidthVar float64, DefaultHeightVar float64, ConcreteWidthVar *float64, ConcreteHeightVar *float64) { gdk.XGdkPaintableComputeConcreteSize(x.GoPointer(), SpecifiedWidthVar, SpecifiedHeightVar, DefaultWidthVar, DefaultHeightVar, ConcreteWidthVar, ConcreteHeightVar) } // Gets an immutable paintable for the current contents displayed by @paintable. // // This is useful when you want to retain the current state of an animation, // for example to take a screenshot of a running animation. // // If the @paintable is already immutable, it will return itself. func (x *WidgetPaintable) GetCurrentImage() *gdk.PaintableBase { var cls *gdk.PaintableBase cret := gdk.XGdkPaintableGetCurrentImage(x.GoPointer()) if cret == 0 { return nil } cls = &gdk.PaintableBase{} cls.Ptr = cret return cls } // Get flags for the paintable. // // This is oftentimes useful for optimizations. // // See [flags@Gdk.PaintableFlags] for the flags and what they mean. func (x *WidgetPaintable) GetFlags() gdk.PaintableFlags { cret := gdk.XGdkPaintableGetFlags(x.GoPointer()) return cret } // Gets the preferred aspect ratio the @paintable would like to be displayed at. // // The aspect ratio is the width divided by the height, so a value of 0.5 // means that the @paintable prefers to be displayed twice as high as it // is wide. Consumers of this interface can use this to preserve aspect // ratio when displaying the paintable. // // This is a purely informational value and does not in any way limit the // values that may be passed to [method@Gdk.Paintable.snapshot]. // // Usually when a @paintable returns nonzero values from // [method@Gdk.Paintable.get_intrinsic_width] and // [method@Gdk.Paintable.get_intrinsic_height] the aspect ratio // should conform to those values, though that is not required. // // If the @paintable does not have a preferred aspect ratio, // it returns 0. Negative values are never returned. func (x *WidgetPaintable) GetIntrinsicAspectRatio() float64 { cret := gdk.XGdkPaintableGetIntrinsicAspectRatio(x.GoPointer()) return cret } // Gets the preferred height the @paintable would like to be displayed at. // // Consumers of this interface can use this to reserve enough space to draw // the paintable. // // This is a purely informational value and does not in any way limit the // values that may be passed to [method@Gdk.Paintable.snapshot]. // // If the @paintable does not have a preferred height, it returns 0. // Negative values are never returned. func (x *WidgetPaintable) GetIntrinsicHeight() int { cret := gdk.XGdkPaintableGetIntrinsicHeight(x.GoPointer()) return cret } // Gets the preferred width the @paintable would like to be displayed at. // // Consumers of this interface can use this to reserve enough space to draw // the paintable. // // This is a purely informational value and does not in any way limit the // values that may be passed to [method@Gdk.Paintable.snapshot]. // // If the @paintable does not have a preferred width, it returns 0. // Negative values are never returned. func (x *WidgetPaintable) GetIntrinsicWidth() int { cret := gdk.XGdkPaintableGetIntrinsicWidth(x.GoPointer()) return cret } // Called by implementations of `GdkPaintable` to invalidate their contents. // // Unless the contents are invalidated, implementations must guarantee that // multiple calls of [method@Gdk.Paintable.snapshot] produce the same output. // // This function will emit the [signal@Gdk.Paintable::invalidate-contents] // signal. // // If a @paintable reports the %GDK_PAINTABLE_STATIC_CONTENTS flag, // it must not call this function. func (x *WidgetPaintable) InvalidateContents() { gdk.XGdkPaintableInvalidateContents(x.GoPointer()) } // Called by implementations of `GdkPaintable` to invalidate their size. // // As long as the size is not invalidated, @paintable must return the same // values for its intrinsic width, height and aspect ratio. // // This function will emit the [signal@Gdk.Paintable::invalidate-size] // signal. // // If a @paintable reports the %GDK_PAINTABLE_STATIC_SIZE flag, // it must not call this function. func (x *WidgetPaintable) InvalidateSize() { gdk.XGdkPaintableInvalidateSize(x.GoPointer()) } // Snapshots the given paintable with the given @width and @height. // // The paintable is drawn at the current (0,0) offset of the @snapshot. // If @width and @height are not larger than zero, this function will // do nothing. func (x *WidgetPaintable) Snapshot(SnapshotVar *gdk.Snapshot, WidthVar float64, HeightVar float64) { gdk.XGdkPaintableSnapshot(x.GoPointer(), SnapshotVar.GoPointer(), WidthVar, HeightVar) } 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(&xWidgetPaintableGLibType, libs, "gtk_widget_paintable_get_type") core.PuregoSafeRegister(&xNewWidgetPaintable, libs, "gtk_widget_paintable_new") core.PuregoSafeRegister(&xWidgetPaintableGetWidget, libs, "gtk_widget_paintable_get_widget") core.PuregoSafeRegister(&xWidgetPaintableSetWidget, libs, "gtk_widget_paintable_set_widget") }