Skip to main content

atk/
text_rectangle.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;
5
6/// A structure used to store a rectangle used by AtkText.
7#[derive(Debug)]
8#[doc(alias = "AtkTextRectangle")]
9pub struct TextRectangle {
10    pub x: i32,
11    pub y: i32,
12    pub width: i32,
13    pub height: i32,
14}
15
16impl TextRectangle {
17    pub fn uninitialized() -> Self {
18        Self {
19            x: 0,
20            y: 0,
21            width: 0,
22            height: 0,
23        }
24    }
25
26    #[doc(hidden)]
27    #[inline]
28    #[allow(clippy::wrong_self_convention)]
29    pub fn to_glib_none_mut(&mut self) -> (*mut ffi::AtkTextRectangle, i32) {
30        (self as *mut TextRectangle as usize as *mut _, 0)
31    }
32}
33
34impl fmt::Display for TextRectangle {
35    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
36        f.debug_struct("TextRectangle")
37            .field("x", &self.x)
38            .field("y", &self.y)
39            .field("width", &self.width)
40            .field("height", &self.height)
41            .finish()
42    }
43}
44
45#[doc(hidden)]
46impl FromGlib<ffi::AtkTextRectangle> for TextRectangle {
47    unsafe fn from_glib(value: ffi::AtkTextRectangle) -> Self {
48        skip_assert_initialized!();
49        Self {
50            x: value.x,
51            y: value.y,
52            width: value.width,
53            height: value.height,
54        }
55    }
56}
57
58#[doc(hidden)]
59impl IntoGlib for TextRectangle {
60    type GlibType = ffi::AtkTextRectangle;
61
62    fn into_glib(self) -> ffi::AtkTextRectangle {
63        ffi::AtkTextRectangle {
64            x: self.x,
65            y: self.y,
66            width: self.width,
67            height: self.height,
68        }
69    }
70}