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 
5 use crate::Align;
6 use crate::Buildable;
7 use crate::Container;
8 use crate::Widget;
9 use glib::object::Cast;
10 use glib::object::IsA;
11 use glib::translate::*;
12 use glib::StaticType;
13 use glib::ToValue;
14 use std::fmt;
15 
16 glib::wrapper! {
17     #[doc(alias = "GtkDrawingArea")]
18     pub struct DrawingArea(Object<ffi::GtkDrawingArea, ffi::GtkDrawingAreaClass>) @extends Widget, @implements Buildable;
19 
20     match fn {
21         type_ => || ffi::gtk_drawing_area_get_type(),
22     }
23 }
24 
25 impl DrawingArea {
26     #[doc(alias = "gtk_drawing_area_new")]
new() -> DrawingArea27     pub fn new() -> DrawingArea {
28         assert_initialized_main_thread!();
29         unsafe { Widget::from_glib_none(ffi::gtk_drawing_area_new()).unsafe_cast() }
30     }
31 
32     // rustdoc-stripper-ignore-next
33     /// Creates a new builder-pattern struct instance to construct [`DrawingArea`] objects.
34     ///
35     /// This method returns an instance of [`DrawingAreaBuilder`] which can be used to create [`DrawingArea`] objects.
builder() -> DrawingAreaBuilder36     pub fn builder() -> DrawingAreaBuilder {
37         DrawingAreaBuilder::default()
38     }
39 }
40 
41 impl Default for DrawingArea {
default() -> Self42     fn default() -> Self {
43         Self::new()
44     }
45 }
46 
47 #[derive(Clone, Default)]
48 // rustdoc-stripper-ignore-next
49 /// A [builder-pattern] type to construct [`DrawingArea`] objects.
50 ///
51 /// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
52 pub struct DrawingAreaBuilder {
53     app_paintable: Option<bool>,
54     can_default: Option<bool>,
55     can_focus: Option<bool>,
56     events: Option<gdk::EventMask>,
57     expand: Option<bool>,
58     #[cfg(any(feature = "v3_20", feature = "dox"))]
59     #[cfg_attr(feature = "dox", doc(cfg(feature = "v3_20")))]
60     focus_on_click: Option<bool>,
61     halign: Option<Align>,
62     has_default: Option<bool>,
63     has_focus: Option<bool>,
64     has_tooltip: Option<bool>,
65     height_request: Option<i32>,
66     hexpand: Option<bool>,
67     hexpand_set: Option<bool>,
68     is_focus: Option<bool>,
69     margin: Option<i32>,
70     margin_bottom: Option<i32>,
71     margin_end: Option<i32>,
72     margin_start: Option<i32>,
73     margin_top: Option<i32>,
74     name: Option<String>,
75     no_show_all: Option<bool>,
76     opacity: Option<f64>,
77     parent: Option<Container>,
78     receives_default: Option<bool>,
79     sensitive: Option<bool>,
80     tooltip_markup: Option<String>,
81     tooltip_text: Option<String>,
82     valign: Option<Align>,
83     vexpand: Option<bool>,
84     vexpand_set: Option<bool>,
85     visible: Option<bool>,
86     width_request: Option<i32>,
87 }
88 
89 impl DrawingAreaBuilder {
90     // rustdoc-stripper-ignore-next
91     /// Create a new [`DrawingAreaBuilder`].
new() -> Self92     pub fn new() -> Self {
93         Self::default()
94     }
95 
96     // rustdoc-stripper-ignore-next
97     /// Build the [`DrawingArea`].
build(self) -> DrawingArea98     pub fn build(self) -> DrawingArea {
99         let mut properties: Vec<(&str, &dyn ToValue)> = vec![];
100         if let Some(ref app_paintable) = self.app_paintable {
101             properties.push(("app-paintable", app_paintable));
102         }
103         if let Some(ref can_default) = self.can_default {
104             properties.push(("can-default", can_default));
105         }
106         if let Some(ref can_focus) = self.can_focus {
107             properties.push(("can-focus", can_focus));
108         }
109         if let Some(ref events) = self.events {
110             properties.push(("events", events));
111         }
112         if let Some(ref expand) = self.expand {
113             properties.push(("expand", expand));
114         }
115         #[cfg(any(feature = "v3_20", feature = "dox"))]
116         if let Some(ref focus_on_click) = self.focus_on_click {
117             properties.push(("focus-on-click", focus_on_click));
118         }
119         if let Some(ref halign) = self.halign {
120             properties.push(("halign", halign));
121         }
122         if let Some(ref has_default) = self.has_default {
123             properties.push(("has-default", has_default));
124         }
125         if let Some(ref has_focus) = self.has_focus {
126             properties.push(("has-focus", has_focus));
127         }
128         if let Some(ref has_tooltip) = self.has_tooltip {
129             properties.push(("has-tooltip", has_tooltip));
130         }
131         if let Some(ref height_request) = self.height_request {
132             properties.push(("height-request", height_request));
133         }
134         if let Some(ref hexpand) = self.hexpand {
135             properties.push(("hexpand", hexpand));
136         }
137         if let Some(ref hexpand_set) = self.hexpand_set {
138             properties.push(("hexpand-set", hexpand_set));
139         }
140         if let Some(ref is_focus) = self.is_focus {
141             properties.push(("is-focus", is_focus));
142         }
143         if let Some(ref margin) = self.margin {
144             properties.push(("margin", margin));
145         }
146         if let Some(ref margin_bottom) = self.margin_bottom {
147             properties.push(("margin-bottom", margin_bottom));
148         }
149         if let Some(ref margin_end) = self.margin_end {
150             properties.push(("margin-end", margin_end));
151         }
152         if let Some(ref margin_start) = self.margin_start {
153             properties.push(("margin-start", margin_start));
154         }
155         if let Some(ref margin_top) = self.margin_top {
156             properties.push(("margin-top", margin_top));
157         }
158         if let Some(ref name) = self.name {
159             properties.push(("name", name));
160         }
161         if let Some(ref no_show_all) = self.no_show_all {
162             properties.push(("no-show-all", no_show_all));
163         }
164         if let Some(ref opacity) = self.opacity {
165             properties.push(("opacity", opacity));
166         }
167         if let Some(ref parent) = self.parent {
168             properties.push(("parent", parent));
169         }
170         if let Some(ref receives_default) = self.receives_default {
171             properties.push(("receives-default", receives_default));
172         }
173         if let Some(ref sensitive) = self.sensitive {
174             properties.push(("sensitive", sensitive));
175         }
176         if let Some(ref tooltip_markup) = self.tooltip_markup {
177             properties.push(("tooltip-markup", tooltip_markup));
178         }
179         if let Some(ref tooltip_text) = self.tooltip_text {
180             properties.push(("tooltip-text", tooltip_text));
181         }
182         if let Some(ref valign) = self.valign {
183             properties.push(("valign", valign));
184         }
185         if let Some(ref vexpand) = self.vexpand {
186             properties.push(("vexpand", vexpand));
187         }
188         if let Some(ref vexpand_set) = self.vexpand_set {
189             properties.push(("vexpand-set", vexpand_set));
190         }
191         if let Some(ref visible) = self.visible {
192             properties.push(("visible", visible));
193         }
194         if let Some(ref width_request) = self.width_request {
195             properties.push(("width-request", width_request));
196         }
197         glib::Object::new::<DrawingArea>(&properties)
198             .expect("Failed to create an instance of DrawingArea")
199     }
200 
app_paintable(mut self, app_paintable: bool) -> Self201     pub fn app_paintable(mut self, app_paintable: bool) -> Self {
202         self.app_paintable = Some(app_paintable);
203         self
204     }
205 
can_default(mut self, can_default: bool) -> Self206     pub fn can_default(mut self, can_default: bool) -> Self {
207         self.can_default = Some(can_default);
208         self
209     }
210 
can_focus(mut self, can_focus: bool) -> Self211     pub fn can_focus(mut self, can_focus: bool) -> Self {
212         self.can_focus = Some(can_focus);
213         self
214     }
215 
events(mut self, events: gdk::EventMask) -> Self216     pub fn events(mut self, events: gdk::EventMask) -> Self {
217         self.events = Some(events);
218         self
219     }
220 
expand(mut self, expand: bool) -> Self221     pub fn expand(mut self, expand: bool) -> Self {
222         self.expand = Some(expand);
223         self
224     }
225 
226     #[cfg(any(feature = "v3_20", feature = "dox"))]
227     #[cfg_attr(feature = "dox", doc(cfg(feature = "v3_20")))]
focus_on_click(mut self, focus_on_click: bool) -> Self228     pub fn focus_on_click(mut self, focus_on_click: bool) -> Self {
229         self.focus_on_click = Some(focus_on_click);
230         self
231     }
232 
halign(mut self, halign: Align) -> Self233     pub fn halign(mut self, halign: Align) -> Self {
234         self.halign = Some(halign);
235         self
236     }
237 
has_default(mut self, has_default: bool) -> Self238     pub fn has_default(mut self, has_default: bool) -> Self {
239         self.has_default = Some(has_default);
240         self
241     }
242 
has_focus(mut self, has_focus: bool) -> Self243     pub fn has_focus(mut self, has_focus: bool) -> Self {
244         self.has_focus = Some(has_focus);
245         self
246     }
247 
has_tooltip(mut self, has_tooltip: bool) -> Self248     pub fn has_tooltip(mut self, has_tooltip: bool) -> Self {
249         self.has_tooltip = Some(has_tooltip);
250         self
251     }
252 
height_request(mut self, height_request: i32) -> Self253     pub fn height_request(mut self, height_request: i32) -> Self {
254         self.height_request = Some(height_request);
255         self
256     }
257 
hexpand(mut self, hexpand: bool) -> Self258     pub fn hexpand(mut self, hexpand: bool) -> Self {
259         self.hexpand = Some(hexpand);
260         self
261     }
262 
hexpand_set(mut self, hexpand_set: bool) -> Self263     pub fn hexpand_set(mut self, hexpand_set: bool) -> Self {
264         self.hexpand_set = Some(hexpand_set);
265         self
266     }
267 
is_focus(mut self, is_focus: bool) -> Self268     pub fn is_focus(mut self, is_focus: bool) -> Self {
269         self.is_focus = Some(is_focus);
270         self
271     }
272 
margin(mut self, margin: i32) -> Self273     pub fn margin(mut self, margin: i32) -> Self {
274         self.margin = Some(margin);
275         self
276     }
277 
margin_bottom(mut self, margin_bottom: i32) -> Self278     pub fn margin_bottom(mut self, margin_bottom: i32) -> Self {
279         self.margin_bottom = Some(margin_bottom);
280         self
281     }
282 
margin_end(mut self, margin_end: i32) -> Self283     pub fn margin_end(mut self, margin_end: i32) -> Self {
284         self.margin_end = Some(margin_end);
285         self
286     }
287 
margin_start(mut self, margin_start: i32) -> Self288     pub fn margin_start(mut self, margin_start: i32) -> Self {
289         self.margin_start = Some(margin_start);
290         self
291     }
292 
margin_top(mut self, margin_top: i32) -> Self293     pub fn margin_top(mut self, margin_top: i32) -> Self {
294         self.margin_top = Some(margin_top);
295         self
296     }
297 
name(mut self, name: &str) -> Self298     pub fn name(mut self, name: &str) -> Self {
299         self.name = Some(name.to_string());
300         self
301     }
302 
no_show_all(mut self, no_show_all: bool) -> Self303     pub fn no_show_all(mut self, no_show_all: bool) -> Self {
304         self.no_show_all = Some(no_show_all);
305         self
306     }
307 
opacity(mut self, opacity: f64) -> Self308     pub fn opacity(mut self, opacity: f64) -> Self {
309         self.opacity = Some(opacity);
310         self
311     }
312 
parent<P: IsA<Container>>(mut self, parent: &P) -> Self313     pub fn parent<P: IsA<Container>>(mut self, parent: &P) -> Self {
314         self.parent = Some(parent.clone().upcast());
315         self
316     }
317 
receives_default(mut self, receives_default: bool) -> Self318     pub fn receives_default(mut self, receives_default: bool) -> Self {
319         self.receives_default = Some(receives_default);
320         self
321     }
322 
sensitive(mut self, sensitive: bool) -> Self323     pub fn sensitive(mut self, sensitive: bool) -> Self {
324         self.sensitive = Some(sensitive);
325         self
326     }
327 
tooltip_markup(mut self, tooltip_markup: &str) -> Self328     pub fn tooltip_markup(mut self, tooltip_markup: &str) -> Self {
329         self.tooltip_markup = Some(tooltip_markup.to_string());
330         self
331     }
332 
tooltip_text(mut self, tooltip_text: &str) -> Self333     pub fn tooltip_text(mut self, tooltip_text: &str) -> Self {
334         self.tooltip_text = Some(tooltip_text.to_string());
335         self
336     }
337 
valign(mut self, valign: Align) -> Self338     pub fn valign(mut self, valign: Align) -> Self {
339         self.valign = Some(valign);
340         self
341     }
342 
vexpand(mut self, vexpand: bool) -> Self343     pub fn vexpand(mut self, vexpand: bool) -> Self {
344         self.vexpand = Some(vexpand);
345         self
346     }
347 
vexpand_set(mut self, vexpand_set: bool) -> Self348     pub fn vexpand_set(mut self, vexpand_set: bool) -> Self {
349         self.vexpand_set = Some(vexpand_set);
350         self
351     }
352 
visible(mut self, visible: bool) -> Self353     pub fn visible(mut self, visible: bool) -> Self {
354         self.visible = Some(visible);
355         self
356     }
357 
width_request(mut self, width_request: i32) -> Self358     pub fn width_request(mut self, width_request: i32) -> Self {
359         self.width_request = Some(width_request);
360         self
361     }
362 }
363 
364 pub const NONE_DRAWING_AREA: Option<&DrawingArea> = None;
365 
366 impl fmt::Display for DrawingArea {
fmt(&self, f: &mut fmt::Formatter) -> fmt::Result367     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
368         f.write_str("DrawingArea")
369     }
370 }
371