gtk4/auto/
fixed.rs

1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from gir-files (https://github.com/gtk-rs/gir-files)
3// DO NOT EDIT
4
5use crate::{
6    ffi, Accessible, AccessibleRole, Align, Buildable, ConstraintTarget, LayoutManager, Overflow,
7    Widget,
8};
9use glib::{prelude::*, translate::*};
10
11glib::wrapper! {
12    #[doc(alias = "GtkFixed")]
13    pub struct Fixed(Object<ffi::GtkFixed, ffi::GtkFixedClass>) @extends Widget, @implements Accessible, Buildable, ConstraintTarget;
14
15    match fn {
16        type_ => || ffi::gtk_fixed_get_type(),
17    }
18}
19
20impl Fixed {
21    pub const NONE: Option<&'static Fixed> = None;
22
23    #[doc(alias = "gtk_fixed_new")]
24    pub fn new() -> Fixed {
25        assert_initialized_main_thread!();
26        unsafe { Widget::from_glib_none(ffi::gtk_fixed_new()).unsafe_cast() }
27    }
28
29    // rustdoc-stripper-ignore-next
30    /// Creates a new builder-pattern struct instance to construct [`Fixed`] objects.
31    ///
32    /// This method returns an instance of [`FixedBuilder`](crate::builders::FixedBuilder) which can be used to create [`Fixed`] objects.
33    pub fn builder() -> FixedBuilder {
34        FixedBuilder::new()
35    }
36}
37
38impl Default for Fixed {
39    fn default() -> Self {
40        Self::new()
41    }
42}
43
44// rustdoc-stripper-ignore-next
45/// A [builder-pattern] type to construct [`Fixed`] objects.
46///
47/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
48#[must_use = "The builder must be built to be used"]
49pub struct FixedBuilder {
50    builder: glib::object::ObjectBuilder<'static, Fixed>,
51}
52
53impl FixedBuilder {
54    fn new() -> Self {
55        Self {
56            builder: glib::object::Object::builder(),
57        }
58    }
59
60    pub fn can_focus(self, can_focus: bool) -> Self {
61        Self {
62            builder: self.builder.property("can-focus", can_focus),
63        }
64    }
65
66    pub fn can_target(self, can_target: bool) -> Self {
67        Self {
68            builder: self.builder.property("can-target", can_target),
69        }
70    }
71
72    pub fn css_classes(self, css_classes: impl Into<glib::StrV>) -> Self {
73        Self {
74            builder: self.builder.property("css-classes", css_classes.into()),
75        }
76    }
77
78    pub fn css_name(self, css_name: impl Into<glib::GString>) -> Self {
79        Self {
80            builder: self.builder.property("css-name", css_name.into()),
81        }
82    }
83
84    pub fn cursor(self, cursor: &gdk::Cursor) -> Self {
85        Self {
86            builder: self.builder.property("cursor", cursor.clone()),
87        }
88    }
89
90    pub fn focus_on_click(self, focus_on_click: bool) -> Self {
91        Self {
92            builder: self.builder.property("focus-on-click", focus_on_click),
93        }
94    }
95
96    pub fn focusable(self, focusable: bool) -> Self {
97        Self {
98            builder: self.builder.property("focusable", focusable),
99        }
100    }
101
102    pub fn halign(self, halign: Align) -> Self {
103        Self {
104            builder: self.builder.property("halign", halign),
105        }
106    }
107
108    pub fn has_tooltip(self, has_tooltip: bool) -> Self {
109        Self {
110            builder: self.builder.property("has-tooltip", has_tooltip),
111        }
112    }
113
114    pub fn height_request(self, height_request: i32) -> Self {
115        Self {
116            builder: self.builder.property("height-request", height_request),
117        }
118    }
119
120    pub fn hexpand(self, hexpand: bool) -> Self {
121        Self {
122            builder: self.builder.property("hexpand", hexpand),
123        }
124    }
125
126    pub fn hexpand_set(self, hexpand_set: bool) -> Self {
127        Self {
128            builder: self.builder.property("hexpand-set", hexpand_set),
129        }
130    }
131
132    pub fn layout_manager(self, layout_manager: &impl IsA<LayoutManager>) -> Self {
133        Self {
134            builder: self
135                .builder
136                .property("layout-manager", layout_manager.clone().upcast()),
137        }
138    }
139
140    #[cfg(feature = "v4_18")]
141    #[cfg_attr(docsrs, doc(cfg(feature = "v4_18")))]
142    pub fn limit_events(self, limit_events: bool) -> Self {
143        Self {
144            builder: self.builder.property("limit-events", limit_events),
145        }
146    }
147
148    pub fn margin_bottom(self, margin_bottom: i32) -> Self {
149        Self {
150            builder: self.builder.property("margin-bottom", margin_bottom),
151        }
152    }
153
154    pub fn margin_end(self, margin_end: i32) -> Self {
155        Self {
156            builder: self.builder.property("margin-end", margin_end),
157        }
158    }
159
160    pub fn margin_start(self, margin_start: i32) -> Self {
161        Self {
162            builder: self.builder.property("margin-start", margin_start),
163        }
164    }
165
166    pub fn margin_top(self, margin_top: i32) -> Self {
167        Self {
168            builder: self.builder.property("margin-top", margin_top),
169        }
170    }
171
172    pub fn name(self, name: impl Into<glib::GString>) -> Self {
173        Self {
174            builder: self.builder.property("name", name.into()),
175        }
176    }
177
178    pub fn opacity(self, opacity: f64) -> Self {
179        Self {
180            builder: self.builder.property("opacity", opacity),
181        }
182    }
183
184    pub fn overflow(self, overflow: Overflow) -> Self {
185        Self {
186            builder: self.builder.property("overflow", overflow),
187        }
188    }
189
190    pub fn receives_default(self, receives_default: bool) -> Self {
191        Self {
192            builder: self.builder.property("receives-default", receives_default),
193        }
194    }
195
196    pub fn sensitive(self, sensitive: bool) -> Self {
197        Self {
198            builder: self.builder.property("sensitive", sensitive),
199        }
200    }
201
202    pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
203        Self {
204            builder: self
205                .builder
206                .property("tooltip-markup", tooltip_markup.into()),
207        }
208    }
209
210    pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
211        Self {
212            builder: self.builder.property("tooltip-text", tooltip_text.into()),
213        }
214    }
215
216    pub fn valign(self, valign: Align) -> Self {
217        Self {
218            builder: self.builder.property("valign", valign),
219        }
220    }
221
222    pub fn vexpand(self, vexpand: bool) -> Self {
223        Self {
224            builder: self.builder.property("vexpand", vexpand),
225        }
226    }
227
228    pub fn vexpand_set(self, vexpand_set: bool) -> Self {
229        Self {
230            builder: self.builder.property("vexpand-set", vexpand_set),
231        }
232    }
233
234    pub fn visible(self, visible: bool) -> Self {
235        Self {
236            builder: self.builder.property("visible", visible),
237        }
238    }
239
240    pub fn width_request(self, width_request: i32) -> Self {
241        Self {
242            builder: self.builder.property("width-request", width_request),
243        }
244    }
245
246    pub fn accessible_role(self, accessible_role: AccessibleRole) -> Self {
247        Self {
248            builder: self.builder.property("accessible-role", accessible_role),
249        }
250    }
251
252    // rustdoc-stripper-ignore-next
253    /// Build the [`Fixed`].
254    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
255    pub fn build(self) -> Fixed {
256        assert_initialized_main_thread!();
257        self.builder.build()
258    }
259}
260
261mod sealed {
262    pub trait Sealed {}
263    impl<T: super::IsA<super::Fixed>> Sealed for T {}
264}
265
266pub trait FixedExt: IsA<Fixed> + sealed::Sealed + 'static {
267    #[doc(alias = "gtk_fixed_get_child_position")]
268    #[doc(alias = "get_child_position")]
269    fn child_position(&self, widget: &impl IsA<Widget>) -> (f64, f64) {
270        unsafe {
271            let mut x = std::mem::MaybeUninit::uninit();
272            let mut y = std::mem::MaybeUninit::uninit();
273            ffi::gtk_fixed_get_child_position(
274                self.as_ref().to_glib_none().0,
275                widget.as_ref().to_glib_none().0,
276                x.as_mut_ptr(),
277                y.as_mut_ptr(),
278            );
279            (x.assume_init(), y.assume_init())
280        }
281    }
282
283    #[doc(alias = "gtk_fixed_get_child_transform")]
284    #[doc(alias = "get_child_transform")]
285    fn child_transform(&self, widget: &impl IsA<Widget>) -> Option<gsk::Transform> {
286        unsafe {
287            from_glib_none(ffi::gtk_fixed_get_child_transform(
288                self.as_ref().to_glib_none().0,
289                widget.as_ref().to_glib_none().0,
290            ))
291        }
292    }
293
294    #[doc(alias = "gtk_fixed_move")]
295    #[doc(alias = "move")]
296    fn move_(&self, widget: &impl IsA<Widget>, x: f64, y: f64) {
297        unsafe {
298            ffi::gtk_fixed_move(
299                self.as_ref().to_glib_none().0,
300                widget.as_ref().to_glib_none().0,
301                x,
302                y,
303            );
304        }
305    }
306
307    #[doc(alias = "gtk_fixed_put")]
308    fn put(&self, widget: &impl IsA<Widget>, x: f64, y: f64) {
309        unsafe {
310            ffi::gtk_fixed_put(
311                self.as_ref().to_glib_none().0,
312                widget.as_ref().to_glib_none().0,
313                x,
314                y,
315            );
316        }
317    }
318
319    #[doc(alias = "gtk_fixed_remove")]
320    fn remove(&self, widget: &impl IsA<Widget>) {
321        unsafe {
322            ffi::gtk_fixed_remove(
323                self.as_ref().to_glib_none().0,
324                widget.as_ref().to_glib_none().0,
325            );
326        }
327    }
328
329    #[doc(alias = "gtk_fixed_set_child_transform")]
330    fn set_child_transform(&self, widget: &impl IsA<Widget>, transform: Option<&gsk::Transform>) {
331        unsafe {
332            ffi::gtk_fixed_set_child_transform(
333                self.as_ref().to_glib_none().0,
334                widget.as_ref().to_glib_none().0,
335                transform.to_glib_none().0,
336            );
337        }
338    }
339}
340
341impl<O: IsA<Fixed>> FixedExt for O {}