Skip to main content

atk/auto/
image.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::{CoordType, ffi};
6use glib::{prelude::*, translate::*};
7
8glib::wrapper! {
9    /// The ATK Interface implemented by components
10    ///  which expose image or pixmap content on-screen.
11    ///
12    /// [`Image`][crate::Image] should be implemented by [`Object`][crate::Object] subtypes on behalf of
13    /// components which display image/pixmap information onscreen, and
14    /// which provide information (other than just widget borders, etc.)
15    /// via that image content. For instance, icons, buttons with icons,
16    /// toolbar elements, and image viewing panes typically should
17    /// implement [`Image`][crate::Image].
18    ///
19    /// [`Image`][crate::Image] primarily provides two types of information: coordinate
20    /// information (useful for screen review mode of screenreaders, and
21    /// for use by onscreen magnifiers), and descriptive information. The
22    /// descriptive information is provided for alternative, text-only
23    /// presentation of the most significant information present in the
24    /// image.
25    ///
26    /// # Implements
27    ///
28    /// [`AtkImageExt`][trait@crate::prelude::AtkImageExt]
29    #[doc(alias = "AtkImage")]
30    pub struct Image(Interface<ffi::AtkImage, ffi::AtkImageIface>);
31
32    match fn {
33        type_ => || ffi::atk_image_get_type(),
34    }
35}
36
37impl Image {
38    pub const NONE: Option<&'static Image> = None;
39}
40
41/// Trait containing all [`struct@Image`] methods.
42///
43/// # Implementors
44///
45/// [`Image`][struct@crate::Image], [`NoOpObject`][struct@crate::NoOpObject]
46pub trait AtkImageExt: IsA<Image> + 'static {
47    /// Get a textual description of this image.
48    ///
49    /// # Returns
50    ///
51    /// a string representing the image description
52    #[doc(alias = "atk_image_get_image_description")]
53    #[doc(alias = "get_image_description")]
54    fn image_description(&self) -> Option<glib::GString> {
55        unsafe {
56            from_glib_none(ffi::atk_image_get_image_description(
57                self.as_ref().to_glib_none().0,
58            ))
59        }
60    }
61
62    /// Retrieves the locale identifier associated to the [`Image`][crate::Image].
63    ///
64    /// # Returns
65    ///
66    /// a string corresponding to the POSIX
67    ///  `LC_MESSAGES` locale used by the image description, or
68    ///  [`None`] if the image does not specify a locale.
69    #[doc(alias = "atk_image_get_image_locale")]
70    #[doc(alias = "get_image_locale")]
71    fn image_locale(&self) -> Option<glib::GString> {
72        unsafe {
73            from_glib_none(ffi::atk_image_get_image_locale(
74                self.as_ref().to_glib_none().0,
75            ))
76        }
77    }
78
79    /// Gets the position of the image in the form of a point specifying the
80    /// images top-left corner.
81    ///
82    /// If the position can not be obtained (e.g. missing support), x and y are set
83    /// to -1.
84    /// ## `coord_type`
85    /// specifies whether the coordinates are relative to the screen
86    /// or to the components top level window
87    ///
88    /// # Returns
89    ///
90    ///
91    /// ## `x`
92    /// address of `gint` to put x coordinate position; otherwise, -1 if value cannot be obtained.
93    ///
94    /// ## `y`
95    /// address of `gint` to put y coordinate position; otherwise, -1 if value cannot be obtained.
96    #[doc(alias = "atk_image_get_image_position")]
97    #[doc(alias = "get_image_position")]
98    fn image_position(&self, coord_type: CoordType) -> (i32, i32) {
99        unsafe {
100            let mut x = std::mem::MaybeUninit::uninit();
101            let mut y = std::mem::MaybeUninit::uninit();
102            ffi::atk_image_get_image_position(
103                self.as_ref().to_glib_none().0,
104                x.as_mut_ptr(),
105                y.as_mut_ptr(),
106                coord_type.into_glib(),
107            );
108            (x.assume_init(), y.assume_init())
109        }
110    }
111
112    /// Get the width and height in pixels for the specified image.
113    /// The values of `width` and `height` are returned as -1 if the
114    /// values cannot be obtained (for instance, if the object is not onscreen).
115    ///
116    /// If the size can not be obtained (e.g. missing support), x and y are set
117    /// to -1.
118    ///
119    /// # Returns
120    ///
121    ///
122    /// ## `width`
123    /// filled with the image width, or -1 if the value cannot be obtained.
124    ///
125    /// ## `height`
126    /// filled with the image height, or -1 if the value cannot be obtained.
127    #[doc(alias = "atk_image_get_image_size")]
128    #[doc(alias = "get_image_size")]
129    fn image_size(&self) -> (i32, i32) {
130        unsafe {
131            let mut width = std::mem::MaybeUninit::uninit();
132            let mut height = std::mem::MaybeUninit::uninit();
133            ffi::atk_image_get_image_size(
134                self.as_ref().to_glib_none().0,
135                width.as_mut_ptr(),
136                height.as_mut_ptr(),
137            );
138            (width.assume_init(), height.assume_init())
139        }
140    }
141
142    /// Sets the textual description for this image.
143    /// ## `description`
144    /// a string description to set for `self`
145    ///
146    /// # Returns
147    ///
148    /// boolean TRUE, or FALSE if operation could
149    /// not be completed.
150    #[doc(alias = "atk_image_set_image_description")]
151    fn set_image_description(&self, description: &str) -> bool {
152        unsafe {
153            from_glib(ffi::atk_image_set_image_description(
154                self.as_ref().to_glib_none().0,
155                description.to_glib_none().0,
156            ))
157        }
158    }
159}
160
161impl<O: IsA<Image>> AtkImageExt for O {}