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 gdk;
6 use glib::object::Cast;
7 use glib::object::IsA;
8 use glib::translate::*;
9 use glib::StaticType;
10 use glib::ToValue;
11 use gtk_sys;
12 use std::fmt;
13 use Align;
14 use Buildable;
15 use Container;
16 use Widget;
17 
18 glib_wrapper! {
19     pub struct DrawingArea(Object<gtk_sys::GtkDrawingArea, gtk_sys::GtkDrawingAreaClass, DrawingAreaClass>) @extends Widget, @implements Buildable;
20 
21     match fn {
22         get_type => || gtk_sys::gtk_drawing_area_get_type(),
23     }
24 }
25 
26 impl DrawingArea {
new() -> DrawingArea27     pub fn new() -> DrawingArea {
28         assert_initialized_main_thread!();
29         unsafe { Widget::from_glib_none(gtk_sys::gtk_drawing_area_new()).unsafe_cast() }
30     }
31 }
32 
33 impl Default for DrawingArea {
default() -> Self34     fn default() -> Self {
35         Self::new()
36     }
37 }
38 
39 #[derive(Clone, Default)]
40 pub struct DrawingAreaBuilder {
41     app_paintable: Option<bool>,
42     can_default: Option<bool>,
43     can_focus: Option<bool>,
44     events: Option<gdk::EventMask>,
45     expand: Option<bool>,
46     #[cfg(any(feature = "v3_20", feature = "dox"))]
47     focus_on_click: Option<bool>,
48     halign: Option<Align>,
49     has_default: Option<bool>,
50     has_focus: Option<bool>,
51     has_tooltip: Option<bool>,
52     height_request: Option<i32>,
53     hexpand: Option<bool>,
54     hexpand_set: Option<bool>,
55     is_focus: Option<bool>,
56     margin: Option<i32>,
57     margin_bottom: Option<i32>,
58     margin_end: Option<i32>,
59     margin_start: Option<i32>,
60     margin_top: Option<i32>,
61     name: Option<String>,
62     no_show_all: Option<bool>,
63     opacity: Option<f64>,
64     parent: Option<Container>,
65     receives_default: Option<bool>,
66     sensitive: Option<bool>,
67     tooltip_markup: Option<String>,
68     tooltip_text: Option<String>,
69     valign: Option<Align>,
70     vexpand: Option<bool>,
71     vexpand_set: Option<bool>,
72     visible: Option<bool>,
73     width_request: Option<i32>,
74 }
75 
76 impl DrawingAreaBuilder {
new() -> Self77     pub fn new() -> Self {
78         Self::default()
79     }
80 
build(self) -> DrawingArea81     pub fn build(self) -> DrawingArea {
82         let mut properties: Vec<(&str, &dyn ToValue)> = vec![];
83         if let Some(ref app_paintable) = self.app_paintable {
84             properties.push(("app-paintable", app_paintable));
85         }
86         if let Some(ref can_default) = self.can_default {
87             properties.push(("can-default", can_default));
88         }
89         if let Some(ref can_focus) = self.can_focus {
90             properties.push(("can-focus", can_focus));
91         }
92         if let Some(ref events) = self.events {
93             properties.push(("events", events));
94         }
95         if let Some(ref expand) = self.expand {
96             properties.push(("expand", expand));
97         }
98         #[cfg(any(feature = "v3_20", feature = "dox"))]
99         {
100             if let Some(ref focus_on_click) = self.focus_on_click {
101                 properties.push(("focus-on-click", focus_on_click));
102             }
103         }
104         if let Some(ref halign) = self.halign {
105             properties.push(("halign", halign));
106         }
107         if let Some(ref has_default) = self.has_default {
108             properties.push(("has-default", has_default));
109         }
110         if let Some(ref has_focus) = self.has_focus {
111             properties.push(("has-focus", has_focus));
112         }
113         if let Some(ref has_tooltip) = self.has_tooltip {
114             properties.push(("has-tooltip", has_tooltip));
115         }
116         if let Some(ref height_request) = self.height_request {
117             properties.push(("height-request", height_request));
118         }
119         if let Some(ref hexpand) = self.hexpand {
120             properties.push(("hexpand", hexpand));
121         }
122         if let Some(ref hexpand_set) = self.hexpand_set {
123             properties.push(("hexpand-set", hexpand_set));
124         }
125         if let Some(ref is_focus) = self.is_focus {
126             properties.push(("is-focus", is_focus));
127         }
128         if let Some(ref margin) = self.margin {
129             properties.push(("margin", margin));
130         }
131         if let Some(ref margin_bottom) = self.margin_bottom {
132             properties.push(("margin-bottom", margin_bottom));
133         }
134         if let Some(ref margin_end) = self.margin_end {
135             properties.push(("margin-end", margin_end));
136         }
137         if let Some(ref margin_start) = self.margin_start {
138             properties.push(("margin-start", margin_start));
139         }
140         if let Some(ref margin_top) = self.margin_top {
141             properties.push(("margin-top", margin_top));
142         }
143         if let Some(ref name) = self.name {
144             properties.push(("name", name));
145         }
146         if let Some(ref no_show_all) = self.no_show_all {
147             properties.push(("no-show-all", no_show_all));
148         }
149         if let Some(ref opacity) = self.opacity {
150             properties.push(("opacity", opacity));
151         }
152         if let Some(ref parent) = self.parent {
153             properties.push(("parent", parent));
154         }
155         if let Some(ref receives_default) = self.receives_default {
156             properties.push(("receives-default", receives_default));
157         }
158         if let Some(ref sensitive) = self.sensitive {
159             properties.push(("sensitive", sensitive));
160         }
161         if let Some(ref tooltip_markup) = self.tooltip_markup {
162             properties.push(("tooltip-markup", tooltip_markup));
163         }
164         if let Some(ref tooltip_text) = self.tooltip_text {
165             properties.push(("tooltip-text", tooltip_text));
166         }
167         if let Some(ref valign) = self.valign {
168             properties.push(("valign", valign));
169         }
170         if let Some(ref vexpand) = self.vexpand {
171             properties.push(("vexpand", vexpand));
172         }
173         if let Some(ref vexpand_set) = self.vexpand_set {
174             properties.push(("vexpand-set", vexpand_set));
175         }
176         if let Some(ref visible) = self.visible {
177             properties.push(("visible", visible));
178         }
179         if let Some(ref width_request) = self.width_request {
180             properties.push(("width-request", width_request));
181         }
182         glib::Object::new(DrawingArea::static_type(), &properties)
183             .expect("object new")
184             .downcast()
185             .expect("downcast")
186     }
187 
app_paintable(mut self, app_paintable: bool) -> Self188     pub fn app_paintable(mut self, app_paintable: bool) -> Self {
189         self.app_paintable = Some(app_paintable);
190         self
191     }
192 
can_default(mut self, can_default: bool) -> Self193     pub fn can_default(mut self, can_default: bool) -> Self {
194         self.can_default = Some(can_default);
195         self
196     }
197 
can_focus(mut self, can_focus: bool) -> Self198     pub fn can_focus(mut self, can_focus: bool) -> Self {
199         self.can_focus = Some(can_focus);
200         self
201     }
202 
events(mut self, events: gdk::EventMask) -> Self203     pub fn events(mut self, events: gdk::EventMask) -> Self {
204         self.events = Some(events);
205         self
206     }
207 
expand(mut self, expand: bool) -> Self208     pub fn expand(mut self, expand: bool) -> Self {
209         self.expand = Some(expand);
210         self
211     }
212 
213     #[cfg(any(feature = "v3_20", feature = "dox"))]
focus_on_click(mut self, focus_on_click: bool) -> Self214     pub fn focus_on_click(mut self, focus_on_click: bool) -> Self {
215         self.focus_on_click = Some(focus_on_click);
216         self
217     }
218 
halign(mut self, halign: Align) -> Self219     pub fn halign(mut self, halign: Align) -> Self {
220         self.halign = Some(halign);
221         self
222     }
223 
has_default(mut self, has_default: bool) -> Self224     pub fn has_default(mut self, has_default: bool) -> Self {
225         self.has_default = Some(has_default);
226         self
227     }
228 
has_focus(mut self, has_focus: bool) -> Self229     pub fn has_focus(mut self, has_focus: bool) -> Self {
230         self.has_focus = Some(has_focus);
231         self
232     }
233 
has_tooltip(mut self, has_tooltip: bool) -> Self234     pub fn has_tooltip(mut self, has_tooltip: bool) -> Self {
235         self.has_tooltip = Some(has_tooltip);
236         self
237     }
238 
height_request(mut self, height_request: i32) -> Self239     pub fn height_request(mut self, height_request: i32) -> Self {
240         self.height_request = Some(height_request);
241         self
242     }
243 
hexpand(mut self, hexpand: bool) -> Self244     pub fn hexpand(mut self, hexpand: bool) -> Self {
245         self.hexpand = Some(hexpand);
246         self
247     }
248 
hexpand_set(mut self, hexpand_set: bool) -> Self249     pub fn hexpand_set(mut self, hexpand_set: bool) -> Self {
250         self.hexpand_set = Some(hexpand_set);
251         self
252     }
253 
is_focus(mut self, is_focus: bool) -> Self254     pub fn is_focus(mut self, is_focus: bool) -> Self {
255         self.is_focus = Some(is_focus);
256         self
257     }
258 
margin(mut self, margin: i32) -> Self259     pub fn margin(mut self, margin: i32) -> Self {
260         self.margin = Some(margin);
261         self
262     }
263 
margin_bottom(mut self, margin_bottom: i32) -> Self264     pub fn margin_bottom(mut self, margin_bottom: i32) -> Self {
265         self.margin_bottom = Some(margin_bottom);
266         self
267     }
268 
margin_end(mut self, margin_end: i32) -> Self269     pub fn margin_end(mut self, margin_end: i32) -> Self {
270         self.margin_end = Some(margin_end);
271         self
272     }
273 
margin_start(mut self, margin_start: i32) -> Self274     pub fn margin_start(mut self, margin_start: i32) -> Self {
275         self.margin_start = Some(margin_start);
276         self
277     }
278 
margin_top(mut self, margin_top: i32) -> Self279     pub fn margin_top(mut self, margin_top: i32) -> Self {
280         self.margin_top = Some(margin_top);
281         self
282     }
283 
name(mut self, name: &str) -> Self284     pub fn name(mut self, name: &str) -> Self {
285         self.name = Some(name.to_string());
286         self
287     }
288 
no_show_all(mut self, no_show_all: bool) -> Self289     pub fn no_show_all(mut self, no_show_all: bool) -> Self {
290         self.no_show_all = Some(no_show_all);
291         self
292     }
293 
opacity(mut self, opacity: f64) -> Self294     pub fn opacity(mut self, opacity: f64) -> Self {
295         self.opacity = Some(opacity);
296         self
297     }
298 
parent<P: IsA<Container>>(mut self, parent: &P) -> Self299     pub fn parent<P: IsA<Container>>(mut self, parent: &P) -> Self {
300         self.parent = Some(parent.clone().upcast());
301         self
302     }
303 
receives_default(mut self, receives_default: bool) -> Self304     pub fn receives_default(mut self, receives_default: bool) -> Self {
305         self.receives_default = Some(receives_default);
306         self
307     }
308 
sensitive(mut self, sensitive: bool) -> Self309     pub fn sensitive(mut self, sensitive: bool) -> Self {
310         self.sensitive = Some(sensitive);
311         self
312     }
313 
tooltip_markup(mut self, tooltip_markup: &str) -> Self314     pub fn tooltip_markup(mut self, tooltip_markup: &str) -> Self {
315         self.tooltip_markup = Some(tooltip_markup.to_string());
316         self
317     }
318 
tooltip_text(mut self, tooltip_text: &str) -> Self319     pub fn tooltip_text(mut self, tooltip_text: &str) -> Self {
320         self.tooltip_text = Some(tooltip_text.to_string());
321         self
322     }
323 
valign(mut self, valign: Align) -> Self324     pub fn valign(mut self, valign: Align) -> Self {
325         self.valign = Some(valign);
326         self
327     }
328 
vexpand(mut self, vexpand: bool) -> Self329     pub fn vexpand(mut self, vexpand: bool) -> Self {
330         self.vexpand = Some(vexpand);
331         self
332     }
333 
vexpand_set(mut self, vexpand_set: bool) -> Self334     pub fn vexpand_set(mut self, vexpand_set: bool) -> Self {
335         self.vexpand_set = Some(vexpand_set);
336         self
337     }
338 
visible(mut self, visible: bool) -> Self339     pub fn visible(mut self, visible: bool) -> Self {
340         self.visible = Some(visible);
341         self
342     }
343 
width_request(mut self, width_request: i32) -> Self344     pub fn width_request(mut self, width_request: i32) -> Self {
345         self.width_request = Some(width_request);
346         self
347     }
348 }
349 
350 pub const NONE_DRAWING_AREA: Option<&DrawingArea> = None;
351 
352 impl fmt::Display for DrawingArea {
fmt(&self, f: &mut fmt::Formatter) -> fmt::Result353     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
354         write!(f, "DrawingArea")
355     }
356 }
357