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