1// Package gtk was automatically generated by github.com/bnema/puregotk DO NOT EDIT
2package gtk
3
4import (
5 "structs"
6 "unsafe"
7
8 "github.com/ebitengine/purego"
9
10 "github.com/bnema/puregotk/pkg/core"
11 "github.com/bnema/puregotk/v4/gdk"
12 "github.com/bnema/puregotk/v4/gobject"
13 "github.com/bnema/puregotk/v4/gobject/types"
14)
15
16type WidgetPaintableClass struct {
17 _ structs.HostLayout
18
19 ParentClass gobject.ObjectClass
20}
21
22func (x *WidgetPaintableClass) GoPointer() uintptr {
23 return uintptr(unsafe.Pointer(x))
24}
25
26// A `GdkPaintable` that displays the contents of a widget.
27//
28// `GtkWidgetPaintable` will also take care of the widget not being in a
29// state where it can be drawn (like when it isn't shown) and just draw
30// nothing or where it does not have a size (like when it is hidden) and
31// report no size in that case.
32//
33// Of course, `GtkWidgetPaintable` allows you to monitor widgets for size
34// changes by emitting the [signal@Gdk.Paintable::invalidate-size] signal
35// whenever the size of the widget changes as well as for visual changes by
36// emitting the [signal@Gdk.Paintable::invalidate-contents] signal whenever
37// the widget changes.
38//
39// You can use a `GtkWidgetPaintable` everywhere a `GdkPaintable` is allowed,
40// including using it on a `GtkPicture` (or one of its parents) that it was
41// set on itself via gtk_picture_set_paintable(). The paintable will take care
42// of recursion when this happens. If you do this however, ensure that the
43// [property@Gtk.Picture:can-shrink] property is set to %TRUE or you might
44// end up with an infinitely growing widget.
45type WidgetPaintable struct {
46 gobject.Object
47}
48
49var xWidgetPaintableGLibType func() types.GType
50
51func WidgetPaintableGLibType() types.GType {
52 return xWidgetPaintableGLibType()
53}
54
55func WidgetPaintableNewFromInternalPtr(ptr uintptr) *WidgetPaintable {
56 cls := &WidgetPaintable{}
57 cls.Ptr = ptr
58 return cls
59}
60
61var xNewWidgetPaintable func(uintptr) uintptr
62
63// Creates a new widget paintable observing the given widget.
64func NewWidgetPaintable(WidgetVar *Widget) *WidgetPaintable {
65 var cls *WidgetPaintable
66
67 cret := xNewWidgetPaintable(WidgetVar.GoPointer())
68
69 if cret == 0 {
70 return nil
71 }
72 cls = &WidgetPaintable{}
73 cls.Ptr = cret
74 return cls
75}
76
77var xWidgetPaintableGetWidget func(uintptr) uintptr
78
79// Returns the widget that is observed or %NULL if none.
80func (x *WidgetPaintable) GetWidget() *Widget {
81 var cls *Widget
82
83 cret := xWidgetPaintableGetWidget(x.GoPointer())
84
85 if cret == 0 {
86 return nil
87 }
88 gobject.IncreaseRef(cret)
89 cls = &Widget{}
90 cls.Ptr = cret
91 return cls
92}
93
94var xWidgetPaintableSetWidget func(uintptr, uintptr)
95
96// Sets the widget that should be observed.
97func (x *WidgetPaintable) SetWidget(WidgetVar *Widget) {
98
99 xWidgetPaintableSetWidget(x.GoPointer(), WidgetVar.GoPointer())
100
101}
102
103func (c *WidgetPaintable) GoPointer() uintptr {
104 if c == nil {
105 return 0
106 }
107 return c.Ptr
108}
109
110func (c *WidgetPaintable) SetGoPointer(ptr uintptr) {
111 c.Ptr = ptr
112}
113
114// Compute a concrete size for the `GdkPaintable`.
115//
116// Applies the sizing algorithm outlined in the
117// [CSS Image spec](https://drafts.csswg.org/css-images-3/#default-sizing)
118// to the given @paintable. See that link for more details.
119//
120// It is not necessary to call this function when both @specified_width
121// and @specified_height are known, but it is useful to call this
122// function in GtkWidget:measure implementations to compute the
123// other dimension when only one dimension is given.
124func (x *WidgetPaintable) ComputeConcreteSize(SpecifiedWidthVar float64, SpecifiedHeightVar float64, DefaultWidthVar float64, DefaultHeightVar float64, ConcreteWidthVar *float64, ConcreteHeightVar *float64) {
125
126 gdk.XGdkPaintableComputeConcreteSize(x.GoPointer(), SpecifiedWidthVar, SpecifiedHeightVar, DefaultWidthVar, DefaultHeightVar, ConcreteWidthVar, ConcreteHeightVar)
127
128}
129
130// Gets an immutable paintable for the current contents displayed by @paintable.
131//
132// This is useful when you want to retain the current state of an animation,
133// for example to take a screenshot of a running animation.
134//
135// If the @paintable is already immutable, it will return itself.
136func (x *WidgetPaintable) GetCurrentImage() *gdk.PaintableBase {
137 var cls *gdk.PaintableBase
138
139 cret := gdk.XGdkPaintableGetCurrentImage(x.GoPointer())
140
141 if cret == 0 {
142 return nil
143 }
144 cls = &gdk.PaintableBase{}
145 cls.Ptr = cret
146 return cls
147}
148
149// Get flags for the paintable.
150//
151// This is oftentimes useful for optimizations.
152//
153// See [flags@Gdk.PaintableFlags] for the flags and what they mean.
154func (x *WidgetPaintable) GetFlags() gdk.PaintableFlags {
155
156 cret := gdk.XGdkPaintableGetFlags(x.GoPointer())
157 return cret
158}
159
160// Gets the preferred aspect ratio the @paintable would like to be displayed at.
161//
162// The aspect ratio is the width divided by the height, so a value of 0.5
163// means that the @paintable prefers to be displayed twice as high as it
164// is wide. Consumers of this interface can use this to preserve aspect
165// ratio when displaying the paintable.
166//
167// This is a purely informational value and does not in any way limit the
168// values that may be passed to [method@Gdk.Paintable.snapshot].
169//
170// Usually when a @paintable returns nonzero values from
171// [method@Gdk.Paintable.get_intrinsic_width] and
172// [method@Gdk.Paintable.get_intrinsic_height] the aspect ratio
173// should conform to those values, though that is not required.
174//
175// If the @paintable does not have a preferred aspect ratio,
176// it returns 0. Negative values are never returned.
177func (x *WidgetPaintable) GetIntrinsicAspectRatio() float64 {
178
179 cret := gdk.XGdkPaintableGetIntrinsicAspectRatio(x.GoPointer())
180 return cret
181}
182
183// Gets the preferred height the @paintable would like to be displayed at.
184//
185// Consumers of this interface can use this to reserve enough space to draw
186// the paintable.
187//
188// This is a purely informational value and does not in any way limit the
189// values that may be passed to [method@Gdk.Paintable.snapshot].
190//
191// If the @paintable does not have a preferred height, it returns 0.
192// Negative values are never returned.
193func (x *WidgetPaintable) GetIntrinsicHeight() int {
194
195 cret := gdk.XGdkPaintableGetIntrinsicHeight(x.GoPointer())
196 return cret
197}
198
199// Gets the preferred width the @paintable would like to be displayed at.
200//
201// Consumers of this interface can use this to reserve enough space to draw
202// the paintable.
203//
204// This is a purely informational value and does not in any way limit the
205// values that may be passed to [method@Gdk.Paintable.snapshot].
206//
207// If the @paintable does not have a preferred width, it returns 0.
208// Negative values are never returned.
209func (x *WidgetPaintable) GetIntrinsicWidth() int {
210
211 cret := gdk.XGdkPaintableGetIntrinsicWidth(x.GoPointer())
212 return cret
213}
214
215// Called by implementations of `GdkPaintable` to invalidate their contents.
216//
217// Unless the contents are invalidated, implementations must guarantee that
218// multiple calls of [method@Gdk.Paintable.snapshot] produce the same output.
219//
220// This function will emit the [signal@Gdk.Paintable::invalidate-contents]
221// signal.
222//
223// If a @paintable reports the %GDK_PAINTABLE_STATIC_CONTENTS flag,
224// it must not call this function.
225func (x *WidgetPaintable) InvalidateContents() {
226
227 gdk.XGdkPaintableInvalidateContents(x.GoPointer())
228
229}
230
231// Called by implementations of `GdkPaintable` to invalidate their size.
232//
233// As long as the size is not invalidated, @paintable must return the same
234// values for its intrinsic width, height and aspect ratio.
235//
236// This function will emit the [signal@Gdk.Paintable::invalidate-size]
237// signal.
238//
239// If a @paintable reports the %GDK_PAINTABLE_STATIC_SIZE flag,
240// it must not call this function.
241func (x *WidgetPaintable) InvalidateSize() {
242
243 gdk.XGdkPaintableInvalidateSize(x.GoPointer())
244
245}
246
247// Snapshots the given paintable with the given @width and @height.
248//
249// The paintable is drawn at the current (0,0) offset of the @snapshot.
250// If @width and @height are not larger than zero, this function will
251// do nothing.
252func (x *WidgetPaintable) Snapshot(SnapshotVar *gdk.Snapshot, WidthVar float64, HeightVar float64) {
253
254 gdk.XGdkPaintableSnapshot(x.GoPointer(), SnapshotVar.GoPointer(), WidthVar, HeightVar)
255
256}
257
258func init() {
259 core.SetPackageName("GTK", "gtk4")
260 core.SetSharedLibraries("GTK", []string{"libgtk-4.so.1"})
261 var libs []uintptr
262 for _, libPath := range core.GetPaths("GTK") {
263 lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL)
264 if err != nil {
265 panic(err)
266 }
267 libs = append(libs, lib)
268 }
269
270 core.PuregoSafeRegister(&xWidgetPaintableGLibType, libs, "gtk_widget_paintable_get_type")
271
272 core.PuregoSafeRegister(&xNewWidgetPaintable, libs, "gtk_widget_paintable_new")
273
274 core.PuregoSafeRegister(&xWidgetPaintableGetWidget, libs, "gtk_widget_paintable_get_widget")
275 core.PuregoSafeRegister(&xWidgetPaintableSetWidget, libs, "gtk_widget_paintable_set_widget")
276
277}