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 atk_sys;
6 use glib::object::Cast;
7 use glib::object::IsA;
8 use glib::signal::connect_raw;
9 use glib::signal::SignalHandlerId;
10 use glib::translate::*;
11 use glib_sys;
12 use std::boxed::Box as Box_;
13 use std::fmt;
14 use std::mem;
15 use std::mem::transmute;
16 use CoordType;
17 use Layer;
18 use Object;
19 use Rectangle;
20 #[cfg(any(feature = "v2_30", feature = "dox"))]
21 use ScrollType;
22 
23 glib_wrapper! {
24     pub struct Component(Interface<atk_sys::AtkComponent>);
25 
26     match fn {
27         get_type => || atk_sys::atk_component_get_type(),
28     }
29 }
30 
31 pub const NONE_COMPONENT: Option<&Component> = None;
32 
33 pub trait ComponentExt: 'static {
contains(&self, x: i32, y: i32, coord_type: CoordType) -> bool34     fn contains(&self, x: i32, y: i32, coord_type: CoordType) -> bool;
35 
get_alpha(&self) -> f6436     fn get_alpha(&self) -> f64;
37 
get_extents(&self, coord_type: CoordType) -> (i32, i32, i32, i32)38     fn get_extents(&self, coord_type: CoordType) -> (i32, i32, i32, i32);
39 
get_layer(&self) -> Layer40     fn get_layer(&self) -> Layer;
41 
get_mdi_zorder(&self) -> i3242     fn get_mdi_zorder(&self) -> i32;
43 
get_position(&self, coord_type: CoordType) -> (i32, i32)44     fn get_position(&self, coord_type: CoordType) -> (i32, i32);
45 
get_size(&self) -> (i32, i32)46     fn get_size(&self) -> (i32, i32);
47 
grab_focus(&self) -> bool48     fn grab_focus(&self) -> bool;
49 
ref_accessible_at_point(&self, x: i32, y: i32, coord_type: CoordType) -> Option<Object>50     fn ref_accessible_at_point(&self, x: i32, y: i32, coord_type: CoordType) -> Option<Object>;
51 
52     #[cfg(any(feature = "v2_30", feature = "dox"))]
scroll_to(&self, type_: ScrollType) -> bool53     fn scroll_to(&self, type_: ScrollType) -> bool;
54 
55     #[cfg(any(feature = "v2_30", feature = "dox"))]
scroll_to_point(&self, coords: CoordType, x: i32, y: i32) -> bool56     fn scroll_to_point(&self, coords: CoordType, x: i32, y: i32) -> bool;
57 
set_extents(&self, x: i32, y: i32, width: i32, height: i32, coord_type: CoordType) -> bool58     fn set_extents(&self, x: i32, y: i32, width: i32, height: i32, coord_type: CoordType) -> bool;
59 
set_position(&self, x: i32, y: i32, coord_type: CoordType) -> bool60     fn set_position(&self, x: i32, y: i32, coord_type: CoordType) -> bool;
61 
set_size(&self, width: i32, height: i32) -> bool62     fn set_size(&self, width: i32, height: i32) -> bool;
63 
connect_bounds_changed<F: Fn(&Self, &Rectangle) + 'static>(&self, f: F) -> SignalHandlerId64     fn connect_bounds_changed<F: Fn(&Self, &Rectangle) + 'static>(&self, f: F) -> SignalHandlerId;
65 }
66 
67 impl<O: IsA<Component>> ComponentExt for O {
contains(&self, x: i32, y: i32, coord_type: CoordType) -> bool68     fn contains(&self, x: i32, y: i32, coord_type: CoordType) -> bool {
69         unsafe {
70             from_glib(atk_sys::atk_component_contains(
71                 self.as_ref().to_glib_none().0,
72                 x,
73                 y,
74                 coord_type.to_glib(),
75             ))
76         }
77     }
78 
get_alpha(&self) -> f6479     fn get_alpha(&self) -> f64 {
80         unsafe { atk_sys::atk_component_get_alpha(self.as_ref().to_glib_none().0) }
81     }
82 
get_extents(&self, coord_type: CoordType) -> (i32, i32, i32, i32)83     fn get_extents(&self, coord_type: CoordType) -> (i32, i32, i32, i32) {
84         unsafe {
85             let mut x = mem::MaybeUninit::uninit();
86             let mut y = mem::MaybeUninit::uninit();
87             let mut width = mem::MaybeUninit::uninit();
88             let mut height = mem::MaybeUninit::uninit();
89             atk_sys::atk_component_get_extents(
90                 self.as_ref().to_glib_none().0,
91                 x.as_mut_ptr(),
92                 y.as_mut_ptr(),
93                 width.as_mut_ptr(),
94                 height.as_mut_ptr(),
95                 coord_type.to_glib(),
96             );
97             let x = x.assume_init();
98             let y = y.assume_init();
99             let width = width.assume_init();
100             let height = height.assume_init();
101             (x, y, width, height)
102         }
103     }
104 
get_layer(&self) -> Layer105     fn get_layer(&self) -> Layer {
106         unsafe {
107             from_glib(atk_sys::atk_component_get_layer(
108                 self.as_ref().to_glib_none().0,
109             ))
110         }
111     }
112 
get_mdi_zorder(&self) -> i32113     fn get_mdi_zorder(&self) -> i32 {
114         unsafe { atk_sys::atk_component_get_mdi_zorder(self.as_ref().to_glib_none().0) }
115     }
116 
get_position(&self, coord_type: CoordType) -> (i32, i32)117     fn get_position(&self, coord_type: CoordType) -> (i32, i32) {
118         unsafe {
119             let mut x = mem::MaybeUninit::uninit();
120             let mut y = mem::MaybeUninit::uninit();
121             atk_sys::atk_component_get_position(
122                 self.as_ref().to_glib_none().0,
123                 x.as_mut_ptr(),
124                 y.as_mut_ptr(),
125                 coord_type.to_glib(),
126             );
127             let x = x.assume_init();
128             let y = y.assume_init();
129             (x, y)
130         }
131     }
132 
get_size(&self) -> (i32, i32)133     fn get_size(&self) -> (i32, i32) {
134         unsafe {
135             let mut width = mem::MaybeUninit::uninit();
136             let mut height = mem::MaybeUninit::uninit();
137             atk_sys::atk_component_get_size(
138                 self.as_ref().to_glib_none().0,
139                 width.as_mut_ptr(),
140                 height.as_mut_ptr(),
141             );
142             let width = width.assume_init();
143             let height = height.assume_init();
144             (width, height)
145         }
146     }
147 
grab_focus(&self) -> bool148     fn grab_focus(&self) -> bool {
149         unsafe {
150             from_glib(atk_sys::atk_component_grab_focus(
151                 self.as_ref().to_glib_none().0,
152             ))
153         }
154     }
155 
ref_accessible_at_point(&self, x: i32, y: i32, coord_type: CoordType) -> Option<Object>156     fn ref_accessible_at_point(&self, x: i32, y: i32, coord_type: CoordType) -> Option<Object> {
157         unsafe {
158             from_glib_full(atk_sys::atk_component_ref_accessible_at_point(
159                 self.as_ref().to_glib_none().0,
160                 x,
161                 y,
162                 coord_type.to_glib(),
163             ))
164         }
165     }
166 
167     #[cfg(any(feature = "v2_30", feature = "dox"))]
scroll_to(&self, type_: ScrollType) -> bool168     fn scroll_to(&self, type_: ScrollType) -> bool {
169         unsafe {
170             from_glib(atk_sys::atk_component_scroll_to(
171                 self.as_ref().to_glib_none().0,
172                 type_.to_glib(),
173             ))
174         }
175     }
176 
177     #[cfg(any(feature = "v2_30", feature = "dox"))]
scroll_to_point(&self, coords: CoordType, x: i32, y: i32) -> bool178     fn scroll_to_point(&self, coords: CoordType, x: i32, y: i32) -> bool {
179         unsafe {
180             from_glib(atk_sys::atk_component_scroll_to_point(
181                 self.as_ref().to_glib_none().0,
182                 coords.to_glib(),
183                 x,
184                 y,
185             ))
186         }
187     }
188 
set_extents(&self, x: i32, y: i32, width: i32, height: i32, coord_type: CoordType) -> bool189     fn set_extents(&self, x: i32, y: i32, width: i32, height: i32, coord_type: CoordType) -> bool {
190         unsafe {
191             from_glib(atk_sys::atk_component_set_extents(
192                 self.as_ref().to_glib_none().0,
193                 x,
194                 y,
195                 width,
196                 height,
197                 coord_type.to_glib(),
198             ))
199         }
200     }
201 
set_position(&self, x: i32, y: i32, coord_type: CoordType) -> bool202     fn set_position(&self, x: i32, y: i32, coord_type: CoordType) -> bool {
203         unsafe {
204             from_glib(atk_sys::atk_component_set_position(
205                 self.as_ref().to_glib_none().0,
206                 x,
207                 y,
208                 coord_type.to_glib(),
209             ))
210         }
211     }
212 
set_size(&self, width: i32, height: i32) -> bool213     fn set_size(&self, width: i32, height: i32) -> bool {
214         unsafe {
215             from_glib(atk_sys::atk_component_set_size(
216                 self.as_ref().to_glib_none().0,
217                 width,
218                 height,
219             ))
220         }
221     }
222 
connect_bounds_changed<F: Fn(&Self, &Rectangle) + 'static>(&self, f: F) -> SignalHandlerId223     fn connect_bounds_changed<F: Fn(&Self, &Rectangle) + 'static>(&self, f: F) -> SignalHandlerId {
224         unsafe extern "C" fn bounds_changed_trampoline<P, F: Fn(&P, &Rectangle) + 'static>(
225             this: *mut atk_sys::AtkComponent,
226             arg1: *mut atk_sys::AtkRectangle,
227             f: glib_sys::gpointer,
228         ) where
229             P: IsA<Component>,
230         {
231             let f: &F = &*(f as *const F);
232             f(
233                 &Component::from_glib_borrow(this).unsafe_cast(),
234                 &from_glib_borrow(arg1),
235             )
236         }
237         unsafe {
238             let f: Box_<F> = Box_::new(f);
239             connect_raw(
240                 self.as_ptr() as *mut _,
241                 b"bounds-changed\0".as_ptr() as *const _,
242                 Some(transmute(bounds_changed_trampoline::<Self, F> as usize)),
243                 Box_::into_raw(f),
244             )
245         }
246     }
247 }
248 
249 impl fmt::Display for Component {
fmt(&self, f: &mut fmt::Formatter) -> fmt::Result250     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
251         write!(f, "Component")
252     }
253 }
254