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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT

use crate::Object;
use glib::object::IsA;
use glib::translate::*;
use std::fmt;
use std::mem;

glib::wrapper! {
    /// Being [`Table`][crate::Table] a component which present elements ordered via rows
    /// and columns, an [`TableCell`][crate::TableCell] is the interface which each of those
    /// elements, so "cells" should implement.
    ///
    /// See also [`Table`][crate::Table].
    ///
    /// # Implements
    ///
    /// [`TableCellExt`][trait@crate::prelude::TableCellExt], [`AtkObjectExt`][trait@crate::prelude::AtkObjectExt], [`trait@glib::ObjectExt`]
    #[doc(alias = "AtkTableCell")]
    pub struct TableCell(Interface<ffi::AtkTableCell, ffi::AtkTableCellIface>) @requires Object;

    match fn {
        type_ => || ffi::atk_table_cell_get_type(),
    }
}

impl TableCell {
    pub const NONE: Option<&'static TableCell> = None;
}

/// Trait containing all [`struct@TableCell`] methods.
///
/// # Implementors
///
/// [`NoOpObject`][struct@crate::NoOpObject], [`TableCell`][struct@crate::TableCell]
pub trait TableCellExt: 'static {
    /// Returns the column headers as an array of cell accessibles.
    ///
    /// # Returns
    ///
    /// a GPtrArray of AtkObjects
    /// representing the column header cells.
    #[doc(alias = "atk_table_cell_get_column_header_cells")]
    #[doc(alias = "get_column_header_cells")]
    fn column_header_cells(&self) -> Vec<Object>;

    /// Returns the number of columns occupied by this cell accessible.
    ///
    /// # Returns
    ///
    /// a gint representing the number of columns occupied by this cell,
    /// or 0 if the cell does not implement this method.
    #[doc(alias = "atk_table_cell_get_column_span")]
    #[doc(alias = "get_column_span")]
    fn column_span(&self) -> i32;

    /// Retrieves the tabular position of this cell.
    ///
    /// # Returns
    ///
    /// TRUE if successful; FALSE otherwise.
    ///
    /// ## `row`
    /// the row of the given cell.
    ///
    /// ## `column`
    /// the column of the given cell.
    #[doc(alias = "atk_table_cell_get_position")]
    #[doc(alias = "get_position")]
    fn position(&self) -> Option<(i32, i32)>;

    /// Gets the row and column indexes and span of this cell accessible.
    ///
    /// Note: If the object does not implement this function, then, by default, atk
    /// will implement this function by calling get_row_span and get_column_span
    /// on the object.
    ///
    /// # Returns
    ///
    /// TRUE if successful; FALSE otherwise.
    ///
    /// ## `row`
    /// the row index of the given cell.
    ///
    /// ## `column`
    /// the column index of the given cell.
    ///
    /// ## `row_span`
    /// the number of rows occupied by this cell.
    ///
    /// ## `column_span`
    /// the number of columns occupied by this cell.
    #[doc(alias = "atk_table_cell_get_row_column_span")]
    #[doc(alias = "get_row_column_span")]
    fn row_column_span(&self) -> Option<(i32, i32, i32, i32)>;

    /// Returns the row headers as an array of cell accessibles.
    ///
    /// # Returns
    ///
    /// a GPtrArray of AtkObjects
    /// representing the row header cells.
    #[doc(alias = "atk_table_cell_get_row_header_cells")]
    #[doc(alias = "get_row_header_cells")]
    fn row_header_cells(&self) -> Vec<Object>;

    /// Returns the number of rows occupied by this cell accessible.
    ///
    /// # Returns
    ///
    /// a gint representing the number of rows occupied by this cell,
    /// or 0 if the cell does not implement this method.
    #[doc(alias = "atk_table_cell_get_row_span")]
    #[doc(alias = "get_row_span")]
    fn row_span(&self) -> i32;

    /// Returns a reference to the accessible of the containing table.
    ///
    /// # Returns
    ///
    /// the atk object for the containing table.
    #[doc(alias = "atk_table_cell_get_table")]
    #[doc(alias = "get_table")]
    fn table(&self) -> Option<Object>;
}

impl<O: IsA<TableCell>> TableCellExt for O {
    fn column_header_cells(&self) -> Vec<Object> {
        unsafe {
            FromGlibPtrContainer::from_glib_full(ffi::atk_table_cell_get_column_header_cells(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    fn column_span(&self) -> i32 {
        unsafe { ffi::atk_table_cell_get_column_span(self.as_ref().to_glib_none().0) }
    }

    fn position(&self) -> Option<(i32, i32)> {
        unsafe {
            let mut row = mem::MaybeUninit::uninit();
            let mut column = mem::MaybeUninit::uninit();
            let ret = from_glib(ffi::atk_table_cell_get_position(
                self.as_ref().to_glib_none().0,
                row.as_mut_ptr(),
                column.as_mut_ptr(),
            ));
            let row = row.assume_init();
            let column = column.assume_init();
            if ret {
                Some((row, column))
            } else {
                None
            }
        }
    }

    fn row_column_span(&self) -> Option<(i32, i32, i32, i32)> {
        unsafe {
            let mut row = mem::MaybeUninit::uninit();
            let mut column = mem::MaybeUninit::uninit();
            let mut row_span = mem::MaybeUninit::uninit();
            let mut column_span = mem::MaybeUninit::uninit();
            let ret = from_glib(ffi::atk_table_cell_get_row_column_span(
                self.as_ref().to_glib_none().0,
                row.as_mut_ptr(),
                column.as_mut_ptr(),
                row_span.as_mut_ptr(),
                column_span.as_mut_ptr(),
            ));
            let row = row.assume_init();
            let column = column.assume_init();
            let row_span = row_span.assume_init();
            let column_span = column_span.assume_init();
            if ret {
                Some((row, column, row_span, column_span))
            } else {
                None
            }
        }
    }

    fn row_header_cells(&self) -> Vec<Object> {
        unsafe {
            FromGlibPtrContainer::from_glib_full(ffi::atk_table_cell_get_row_header_cells(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    fn row_span(&self) -> i32 {
        unsafe { ffi::atk_table_cell_get_row_span(self.as_ref().to_glib_none().0) }
    }

    fn table(&self) -> Option<Object> {
        unsafe {
            from_glib_full(ffi::atk_table_cell_get_table(
                self.as_ref().to_glib_none().0,
            ))
        }
    }
}

impl fmt::Display for TableCell {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        f.write_str("TableCell")
    }
}