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
// 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 atk_sys;
use glib::object::IsA;
use glib::translate::*;
use std::fmt;
use std::mem;
use Object;

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

    match fn {
        get_type => || atk_sys::atk_table_cell_get_type(),
    }
}

pub const NONE_TABLE_CELL: Option<&TableCell> = None;

/// Trait containing all `TableCell` methods.
///
/// # Implementors
///
/// [`NoOpObject`](struct.NoOpObject.html), [`TableCell`](struct.TableCell.html)
pub trait TableCellExt: 'static {
    /// Returns the column headers as an array of cell accessibles.
    ///
    /// # Returns
    ///
    /// a GPtrArray of AtkObjects
    /// representing the column header cells.
    fn get_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.
    fn get_column_span(&self) -> i32;

    /// Retrieves the tabular position of this cell.
    /// ## `row`
    /// the row of the given cell.
    /// ## `column`
    /// the column of the given cell.
    ///
    /// # Returns
    ///
    /// TRUE if successful; FALSE otherwise.
    fn get_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.
    /// ## `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.
    ///
    /// # Returns
    ///
    /// TRUE if successful; FALSE otherwise.
    fn get_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.
    fn get_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.
    fn get_row_span(&self) -> i32;

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

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

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

    fn get_position(&self) -> Option<(i32, i32)> {
        unsafe {
            let mut row = mem::MaybeUninit::uninit();
            let mut column = mem::MaybeUninit::uninit();
            let ret = from_glib(atk_sys::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 get_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(atk_sys::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 get_row_header_cells(&self) -> Vec<Object> {
        unsafe {
            FromGlibPtrContainer::from_glib_full(atk_sys::atk_table_cell_get_row_header_cells(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

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

    fn get_table(&self) -> Option<Object> {
        unsafe {
            from_glib_full(atk_sys::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 {
        write!(f, "TableCell")
    }
}