1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
// Copyright 2013-2018, The Gtk-rs Project Developers.
// See the COPYRIGHT file at the top-level directory of this distribution.
// Licensed under the MIT license, see the LICENSE file or <http://opensource.org/licenses/MIT>

use atk_sys;
use glib::translate::*;
use std::fmt;

#[derive(Debug)]
pub struct TextRectangle {
    pub x: i32,
    pub y: i32,
    pub width: i32,
    pub height: i32,
}

impl TextRectangle {
    pub fn uninitialized() -> Self {
        TextRectangle {
            x: 0,
            y: 0,
            width: 0,
            height: 0,
        }
    }

    #[doc(hidden)]
    #[inline]
    pub fn to_glib_none_mut(&mut self) -> (*mut atk_sys::AtkTextRectangle, i32) {
        (self as *mut TextRectangle as usize as *mut _, 0)
    }
}

impl fmt::Display for TextRectangle {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        f.debug_struct("TextRectangle")
            .field("x", &self.x)
            .field("y", &self.y)
            .field("width", &self.width)
            .field("height", &self.height)
            .finish()
    }
}

#[doc(hidden)]
impl FromGlib<atk_sys::AtkTextRectangle> for TextRectangle {
    fn from_glib(value: atk_sys::AtkTextRectangle) -> Self {
        skip_assert_initialized!();
        TextRectangle {
            x: value.x,
            y: value.y,
            width: value.width,
            height: value.height,
        }
    }
}

#[doc(hidden)]
impl ToGlib for TextRectangle {
    type GlibType = atk_sys::AtkTextRectangle;

    fn to_glib(&self) -> atk_sys::AtkTextRectangle {
        atk_sys::AtkTextRectangle {
            x: self.x,
            y: self.y,
            width: self.width,
            height: self.height,
        }
    }
}