[go: up one dir, main page]

gtk/
border.rs

1// Take a look at the license at the top of the repository in the LICENSE file.
2
3use glib::translate::*;
4use std::fmt;
5use std::ops;
6
7glib::wrapper! {
8    #[doc(alias = "GtkBorder")]
9    pub struct Border(BoxedInline<ffi::GtkBorder>);
10
11    match fn {
12        copy => |ptr| ffi::gtk_border_copy(mut_override(ptr)),
13        free => |ptr| ffi::gtk_border_free(ptr),
14        type_ => || ffi::gtk_border_get_type(),
15    }
16}
17
18impl ops::Deref for Border {
19    type Target = ffi::GtkBorder;
20
21    fn deref(&self) -> &Self::Target {
22        &self.inner
23    }
24}
25
26impl ops::DerefMut for Border {
27    fn deref_mut(&mut self) -> &mut Self::Target {
28        &mut self.inner
29    }
30}
31
32impl Border {
33    #[doc(alias = "gtk_border_new")]
34    pub fn new() -> Self {
35        assert_initialized_main_thread!();
36        unsafe { from_glib_full(ffi::gtk_border_new()) }
37    }
38}
39
40impl Default for Border {
41    fn default() -> Self {
42        Self::new()
43    }
44}
45
46impl fmt::Debug for Border {
47    fn fmt(&self, fmt: &mut fmt::Formatter) -> Result<(), fmt::Error> {
48        fmt.debug_struct("Border")
49            .field("left", &self.left)
50            .field("right", &self.right)
51            .field("top", &self.top)
52            .field("bottom", &self.bottom)
53            .finish()
54    }
55}
56
57impl PartialEq for Border {
58    fn eq(&self, other: &Self) -> bool {
59        self.left == other.left
60            && self.right == other.right
61            && self.top == other.top
62            && self.bottom == other.bottom
63    }
64}
65
66impl Eq for Border {}