gtk/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 gdk;
6use glib::object::Cast;
7use glib::object::IsA;
8use glib::translate::*;
9use glib::StaticType;
10use glib::ToValue;
11use gtk_sys;
12use std::fmt;
13use Align;
14use Buildable;
15use Container;
16use ResizeMode;
17use Widget;
18
19glib_wrapper! {
20    pub struct Fixed(Object<gtk_sys::GtkFixed, gtk_sys::GtkFixedClass, FixedClass>) @extends Container, Widget, @implements Buildable;
21
22    match fn {
23        get_type => || gtk_sys::gtk_fixed_get_type(),
24    }
25}
26
27impl Fixed {
28    pub fn new() -> Fixed {
29        assert_initialized_main_thread!();
30        unsafe { Widget::from_glib_none(gtk_sys::gtk_fixed_new()).unsafe_cast() }
31    }
32}
33
34impl Default for Fixed {
35    fn default() -> Self {
36        Self::new()
37    }
38}
39
40pub struct FixedBuilder {
41    border_width: Option<u32>,
42    child: Option<Widget>,
43    resize_mode: Option<ResizeMode>,
44    app_paintable: Option<bool>,
45    can_default: Option<bool>,
46    can_focus: Option<bool>,
47    events: Option<gdk::EventMask>,
48    expand: Option<bool>,
49    #[cfg(any(feature = "v3_20", feature = "dox"))]
50    focus_on_click: Option<bool>,
51    halign: Option<Align>,
52    has_default: Option<bool>,
53    has_focus: Option<bool>,
54    has_tooltip: Option<bool>,
55    height_request: Option<i32>,
56    hexpand: Option<bool>,
57    hexpand_set: Option<bool>,
58    is_focus: Option<bool>,
59    margin: Option<i32>,
60    margin_bottom: Option<i32>,
61    margin_end: Option<i32>,
62    margin_start: Option<i32>,
63    margin_top: Option<i32>,
64    name: Option<String>,
65    no_show_all: Option<bool>,
66    opacity: Option<f64>,
67    parent: Option<Container>,
68    receives_default: Option<bool>,
69    sensitive: Option<bool>,
70    //style: /*Unknown type*/,
71    tooltip_markup: Option<String>,
72    tooltip_text: Option<String>,
73    valign: Option<Align>,
74    vexpand: Option<bool>,
75    vexpand_set: Option<bool>,
76    visible: Option<bool>,
77    width_request: Option<i32>,
78}
79
80impl FixedBuilder {
81    pub fn new() -> Self {
82        Self {
83            border_width: None,
84            child: None,
85            resize_mode: None,
86            app_paintable: None,
87            can_default: None,
88            can_focus: None,
89            events: None,
90            expand: None,
91            #[cfg(any(feature = "v3_20", feature = "dox"))]
92            focus_on_click: None,
93            halign: None,
94            has_default: None,
95            has_focus: None,
96            has_tooltip: None,
97            height_request: None,
98            hexpand: None,
99            hexpand_set: None,
100            is_focus: None,
101            margin: None,
102            margin_bottom: None,
103            margin_end: None,
104            margin_start: None,
105            margin_top: None,
106            name: None,
107            no_show_all: None,
108            opacity: None,
109            parent: None,
110            receives_default: None,
111            sensitive: None,
112            tooltip_markup: None,
113            tooltip_text: None,
114            valign: None,
115            vexpand: None,
116            vexpand_set: None,
117            visible: None,
118            width_request: None,
119        }
120    }
121
122    pub fn build(self) -> Fixed {
123        let mut properties: Vec<(&str, &dyn ToValue)> = vec![];
124        if let Some(ref border_width) = self.border_width {
125            properties.push(("border-width", border_width));
126        }
127        if let Some(ref child) = self.child {
128            properties.push(("child", child));
129        }
130        if let Some(ref resize_mode) = self.resize_mode {
131            properties.push(("resize-mode", resize_mode));
132        }
133        if let Some(ref app_paintable) = self.app_paintable {
134            properties.push(("app-paintable", app_paintable));
135        }
136        if let Some(ref can_default) = self.can_default {
137            properties.push(("can-default", can_default));
138        }
139        if let Some(ref can_focus) = self.can_focus {
140            properties.push(("can-focus", can_focus));
141        }
142        if let Some(ref events) = self.events {
143            properties.push(("events", events));
144        }
145        if let Some(ref expand) = self.expand {
146            properties.push(("expand", expand));
147        }
148        #[cfg(any(feature = "v3_20", feature = "dox"))]
149        {
150            if let Some(ref focus_on_click) = self.focus_on_click {
151                properties.push(("focus-on-click", focus_on_click));
152            }
153        }
154        if let Some(ref halign) = self.halign {
155            properties.push(("halign", halign));
156        }
157        if let Some(ref has_default) = self.has_default {
158            properties.push(("has-default", has_default));
159        }
160        if let Some(ref has_focus) = self.has_focus {
161            properties.push(("has-focus", has_focus));
162        }
163        if let Some(ref has_tooltip) = self.has_tooltip {
164            properties.push(("has-tooltip", has_tooltip));
165        }
166        if let Some(ref height_request) = self.height_request {
167            properties.push(("height-request", height_request));
168        }
169        if let Some(ref hexpand) = self.hexpand {
170            properties.push(("hexpand", hexpand));
171        }
172        if let Some(ref hexpand_set) = self.hexpand_set {
173            properties.push(("hexpand-set", hexpand_set));
174        }
175        if let Some(ref is_focus) = self.is_focus {
176            properties.push(("is-focus", is_focus));
177        }
178        if let Some(ref margin) = self.margin {
179            properties.push(("margin", margin));
180        }
181        if let Some(ref margin_bottom) = self.margin_bottom {
182            properties.push(("margin-bottom", margin_bottom));
183        }
184        if let Some(ref margin_end) = self.margin_end {
185            properties.push(("margin-end", margin_end));
186        }
187        if let Some(ref margin_start) = self.margin_start {
188            properties.push(("margin-start", margin_start));
189        }
190        if let Some(ref margin_top) = self.margin_top {
191            properties.push(("margin-top", margin_top));
192        }
193        if let Some(ref name) = self.name {
194            properties.push(("name", name));
195        }
196        if let Some(ref no_show_all) = self.no_show_all {
197            properties.push(("no-show-all", no_show_all));
198        }
199        if let Some(ref opacity) = self.opacity {
200            properties.push(("opacity", opacity));
201        }
202        if let Some(ref parent) = self.parent {
203            properties.push(("parent", parent));
204        }
205        if let Some(ref receives_default) = self.receives_default {
206            properties.push(("receives-default", receives_default));
207        }
208        if let Some(ref sensitive) = self.sensitive {
209            properties.push(("sensitive", sensitive));
210        }
211        if let Some(ref tooltip_markup) = self.tooltip_markup {
212            properties.push(("tooltip-markup", tooltip_markup));
213        }
214        if let Some(ref tooltip_text) = self.tooltip_text {
215            properties.push(("tooltip-text", tooltip_text));
216        }
217        if let Some(ref valign) = self.valign {
218            properties.push(("valign", valign));
219        }
220        if let Some(ref vexpand) = self.vexpand {
221            properties.push(("vexpand", vexpand));
222        }
223        if let Some(ref vexpand_set) = self.vexpand_set {
224            properties.push(("vexpand-set", vexpand_set));
225        }
226        if let Some(ref visible) = self.visible {
227            properties.push(("visible", visible));
228        }
229        if let Some(ref width_request) = self.width_request {
230            properties.push(("width-request", width_request));
231        }
232        glib::Object::new(Fixed::static_type(), &properties)
233            .expect("object new")
234            .downcast()
235            .expect("downcast")
236    }
237
238    pub fn border_width(mut self, border_width: u32) -> Self {
239        self.border_width = Some(border_width);
240        self
241    }
242
243    pub fn child(mut self, child: &Widget) -> Self {
244        self.child = Some(child.clone());
245        self
246    }
247
248    pub fn resize_mode(mut self, resize_mode: ResizeMode) -> Self {
249        self.resize_mode = Some(resize_mode);
250        self
251    }
252
253    pub fn app_paintable(mut self, app_paintable: bool) -> Self {
254        self.app_paintable = Some(app_paintable);
255        self
256    }
257
258    pub fn can_default(mut self, can_default: bool) -> Self {
259        self.can_default = Some(can_default);
260        self
261    }
262
263    pub fn can_focus(mut self, can_focus: bool) -> Self {
264        self.can_focus = Some(can_focus);
265        self
266    }
267
268    pub fn events(mut self, events: gdk::EventMask) -> Self {
269        self.events = Some(events);
270        self
271    }
272
273    pub fn expand(mut self, expand: bool) -> Self {
274        self.expand = Some(expand);
275        self
276    }
277
278    #[cfg(any(feature = "v3_20", feature = "dox"))]
279    pub fn focus_on_click(mut self, focus_on_click: bool) -> Self {
280        self.focus_on_click = Some(focus_on_click);
281        self
282    }
283
284    pub fn halign(mut self, halign: Align) -> Self {
285        self.halign = Some(halign);
286        self
287    }
288
289    pub fn has_default(mut self, has_default: bool) -> Self {
290        self.has_default = Some(has_default);
291        self
292    }
293
294    pub fn has_focus(mut self, has_focus: bool) -> Self {
295        self.has_focus = Some(has_focus);
296        self
297    }
298
299    pub fn has_tooltip(mut self, has_tooltip: bool) -> Self {
300        self.has_tooltip = Some(has_tooltip);
301        self
302    }
303
304    pub fn height_request(mut self, height_request: i32) -> Self {
305        self.height_request = Some(height_request);
306        self
307    }
308
309    pub fn hexpand(mut self, hexpand: bool) -> Self {
310        self.hexpand = Some(hexpand);
311        self
312    }
313
314    pub fn hexpand_set(mut self, hexpand_set: bool) -> Self {
315        self.hexpand_set = Some(hexpand_set);
316        self
317    }
318
319    pub fn is_focus(mut self, is_focus: bool) -> Self {
320        self.is_focus = Some(is_focus);
321        self
322    }
323
324    pub fn margin(mut self, margin: i32) -> Self {
325        self.margin = Some(margin);
326        self
327    }
328
329    pub fn margin_bottom(mut self, margin_bottom: i32) -> Self {
330        self.margin_bottom = Some(margin_bottom);
331        self
332    }
333
334    pub fn margin_end(mut self, margin_end: i32) -> Self {
335        self.margin_end = Some(margin_end);
336        self
337    }
338
339    pub fn margin_start(mut self, margin_start: i32) -> Self {
340        self.margin_start = Some(margin_start);
341        self
342    }
343
344    pub fn margin_top(mut self, margin_top: i32) -> Self {
345        self.margin_top = Some(margin_top);
346        self
347    }
348
349    pub fn name(mut self, name: &str) -> Self {
350        self.name = Some(name.to_string());
351        self
352    }
353
354    pub fn no_show_all(mut self, no_show_all: bool) -> Self {
355        self.no_show_all = Some(no_show_all);
356        self
357    }
358
359    pub fn opacity(mut self, opacity: f64) -> Self {
360        self.opacity = Some(opacity);
361        self
362    }
363
364    pub fn parent(mut self, parent: &Container) -> Self {
365        self.parent = Some(parent.clone());
366        self
367    }
368
369    pub fn receives_default(mut self, receives_default: bool) -> Self {
370        self.receives_default = Some(receives_default);
371        self
372    }
373
374    pub fn sensitive(mut self, sensitive: bool) -> Self {
375        self.sensitive = Some(sensitive);
376        self
377    }
378
379    pub fn tooltip_markup(mut self, tooltip_markup: &str) -> Self {
380        self.tooltip_markup = Some(tooltip_markup.to_string());
381        self
382    }
383
384    pub fn tooltip_text(mut self, tooltip_text: &str) -> Self {
385        self.tooltip_text = Some(tooltip_text.to_string());
386        self
387    }
388
389    pub fn valign(mut self, valign: Align) -> Self {
390        self.valign = Some(valign);
391        self
392    }
393
394    pub fn vexpand(mut self, vexpand: bool) -> Self {
395        self.vexpand = Some(vexpand);
396        self
397    }
398
399    pub fn vexpand_set(mut self, vexpand_set: bool) -> Self {
400        self.vexpand_set = Some(vexpand_set);
401        self
402    }
403
404    pub fn visible(mut self, visible: bool) -> Self {
405        self.visible = Some(visible);
406        self
407    }
408
409    pub fn width_request(mut self, width_request: i32) -> Self {
410        self.width_request = Some(width_request);
411        self
412    }
413}
414
415pub const NONE_FIXED: Option<&Fixed> = None;
416
417pub trait FixedExt: 'static {
418    fn move_<P: IsA<Widget>>(&self, widget: &P, x: i32, y: i32);
419
420    fn put<P: IsA<Widget>>(&self, widget: &P, x: i32, y: i32);
421}
422
423impl<O: IsA<Fixed>> FixedExt for O {
424    fn move_<P: IsA<Widget>>(&self, widget: &P, x: i32, y: i32) {
425        unsafe {
426            gtk_sys::gtk_fixed_move(
427                self.as_ref().to_glib_none().0,
428                widget.as_ref().to_glib_none().0,
429                x,
430                y,
431            );
432        }
433    }
434
435    fn put<P: IsA<Widget>>(&self, widget: &P, x: i32, y: i32) {
436        unsafe {
437            gtk_sys::gtk_fixed_put(
438                self.as_ref().to_glib_none().0,
439                widget.as_ref().to_glib_none().0,
440                x,
441                y,
442            );
443        }
444    }
445}
446
447impl fmt::Display for Fixed {
448    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
449        write!(f, "Fixed")
450    }
451}