[go: up one dir, main page]

gdk4/auto/
popup_layout.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::{ffi, AnchorHints, Gravity, Rectangle};
6use glib::translate::*;
7
8glib::wrapper! {
9    #[derive(Debug, PartialOrd, Ord, Hash)]
10    pub struct PopupLayout(Shared<ffi::GdkPopupLayout>);
11
12    match fn {
13        ref => |ptr| ffi::gdk_popup_layout_ref(ptr),
14        unref => |ptr| ffi::gdk_popup_layout_unref(ptr),
15        type_ => || ffi::gdk_popup_layout_get_type(),
16    }
17}
18
19impl PopupLayout {
20    #[doc(alias = "gdk_popup_layout_new")]
21    pub fn new(
22        anchor_rect: &Rectangle,
23        rect_anchor: Gravity,
24        surface_anchor: Gravity,
25    ) -> PopupLayout {
26        assert_initialized_main_thread!();
27        unsafe {
28            from_glib_full(ffi::gdk_popup_layout_new(
29                anchor_rect.to_glib_none().0,
30                rect_anchor.into_glib(),
31                surface_anchor.into_glib(),
32            ))
33        }
34    }
35
36    #[doc(alias = "gdk_popup_layout_copy")]
37    #[must_use]
38    pub fn copy(&self) -> PopupLayout {
39        unsafe { from_glib_full(ffi::gdk_popup_layout_copy(self.to_glib_none().0)) }
40    }
41
42    #[doc(alias = "gdk_popup_layout_equal")]
43    fn equal(&self, other: &PopupLayout) -> bool {
44        unsafe {
45            from_glib(ffi::gdk_popup_layout_equal(
46                self.to_glib_none().0,
47                other.to_glib_none().0,
48            ))
49        }
50    }
51
52    #[doc(alias = "gdk_popup_layout_get_anchor_hints")]
53    #[doc(alias = "get_anchor_hints")]
54    pub fn anchor_hints(&self) -> AnchorHints {
55        unsafe {
56            from_glib(ffi::gdk_popup_layout_get_anchor_hints(
57                self.to_glib_none().0,
58            ))
59        }
60    }
61
62    #[doc(alias = "gdk_popup_layout_get_anchor_rect")]
63    #[doc(alias = "get_anchor_rect")]
64    pub fn anchor_rect(&self) -> Rectangle {
65        unsafe { from_glib_none(ffi::gdk_popup_layout_get_anchor_rect(self.to_glib_none().0)) }
66    }
67
68    #[doc(alias = "gdk_popup_layout_get_rect_anchor")]
69    #[doc(alias = "get_rect_anchor")]
70    pub fn rect_anchor(&self) -> Gravity {
71        unsafe { from_glib(ffi::gdk_popup_layout_get_rect_anchor(self.to_glib_none().0)) }
72    }
73
74    #[cfg(feature = "v4_2")]
75    #[cfg_attr(docsrs, doc(cfg(feature = "v4_2")))]
76    #[doc(alias = "gdk_popup_layout_get_shadow_width")]
77    #[doc(alias = "get_shadow_width")]
78    pub fn shadow_width(&self) -> (i32, i32, i32, i32) {
79        unsafe {
80            let mut left = std::mem::MaybeUninit::uninit();
81            let mut right = std::mem::MaybeUninit::uninit();
82            let mut top = std::mem::MaybeUninit::uninit();
83            let mut bottom = std::mem::MaybeUninit::uninit();
84            ffi::gdk_popup_layout_get_shadow_width(
85                self.to_glib_none().0,
86                left.as_mut_ptr(),
87                right.as_mut_ptr(),
88                top.as_mut_ptr(),
89                bottom.as_mut_ptr(),
90            );
91            (
92                left.assume_init(),
93                right.assume_init(),
94                top.assume_init(),
95                bottom.assume_init(),
96            )
97        }
98    }
99
100    #[doc(alias = "gdk_popup_layout_get_surface_anchor")]
101    #[doc(alias = "get_surface_anchor")]
102    pub fn surface_anchor(&self) -> Gravity {
103        unsafe {
104            from_glib(ffi::gdk_popup_layout_get_surface_anchor(
105                self.to_glib_none().0,
106            ))
107        }
108    }
109
110    #[doc(alias = "gdk_popup_layout_set_anchor_hints")]
111    pub fn set_anchor_hints(&self, anchor_hints: AnchorHints) {
112        unsafe {
113            ffi::gdk_popup_layout_set_anchor_hints(self.to_glib_none().0, anchor_hints.into_glib());
114        }
115    }
116
117    #[doc(alias = "gdk_popup_layout_set_anchor_rect")]
118    pub fn set_anchor_rect(&self, anchor_rect: &Rectangle) {
119        unsafe {
120            ffi::gdk_popup_layout_set_anchor_rect(
121                self.to_glib_none().0,
122                anchor_rect.to_glib_none().0,
123            );
124        }
125    }
126
127    #[doc(alias = "gdk_popup_layout_set_offset")]
128    pub fn set_offset(&self, dx: i32, dy: i32) {
129        unsafe {
130            ffi::gdk_popup_layout_set_offset(self.to_glib_none().0, dx, dy);
131        }
132    }
133
134    #[doc(alias = "gdk_popup_layout_set_rect_anchor")]
135    pub fn set_rect_anchor(&self, anchor: Gravity) {
136        unsafe {
137            ffi::gdk_popup_layout_set_rect_anchor(self.to_glib_none().0, anchor.into_glib());
138        }
139    }
140
141    #[cfg(feature = "v4_2")]
142    #[cfg_attr(docsrs, doc(cfg(feature = "v4_2")))]
143    #[doc(alias = "gdk_popup_layout_set_shadow_width")]
144    pub fn set_shadow_width(&self, left: i32, right: i32, top: i32, bottom: i32) {
145        unsafe {
146            ffi::gdk_popup_layout_set_shadow_width(self.to_glib_none().0, left, right, top, bottom);
147        }
148    }
149
150    #[doc(alias = "gdk_popup_layout_set_surface_anchor")]
151    pub fn set_surface_anchor(&self, anchor: Gravity) {
152        unsafe {
153            ffi::gdk_popup_layout_set_surface_anchor(self.to_glib_none().0, anchor.into_glib());
154        }
155    }
156}
157
158impl PartialEq for PopupLayout {
159    #[inline]
160    fn eq(&self, other: &Self) -> bool {
161        self.equal(other)
162    }
163}
164
165impl Eq for PopupLayout {}