1 /* ATK - Accessibility Toolkit
2 * Copyright 2014 SUSE LLC.
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
20 #include "atktablecell.h"
24 * SECTION:atktablecell
25 * @Short_description: The ATK interface implemented for a cell inside
26 * a two-dimentional #AtkTable
29 * Being #AtkTable a component which present elements ordered via rows
30 * and columns, an #AtkTableCell is the interface which each of those
31 * elements, so "cells" should implement.
36 typedef AtkTableCellIface AtkTableCellInterface;
37 G_DEFINE_INTERFACE (AtkTableCell, atk_table_cell, ATK_TYPE_OBJECT)
39 static gboolean atk_table_cell_real_get_row_column_span (AtkTableCell *cell,
46 atk_table_cell_default_init (AtkTableCellInterface *iface)
48 iface->get_row_column_span = atk_table_cell_real_get_row_column_span;
52 * atk_table_cell_get_column_span:
53 * @cell: a GObject instance that implements AtkTableCellIface
55 * Returns the number of columns occupied by this cell accessible.
57 * Returns: a gint representing the number of columns occupied by this cell,
58 * or 0 if the cell does not implement this method.
61 atk_table_cell_get_column_span (AtkTableCell *cell)
63 AtkTableCellIface *iface;
65 g_return_val_if_fail (ATK_IS_TABLE_CELL (cell), 0);
67 iface = ATK_TABLE_CELL_GET_IFACE (cell);
69 if (iface->get_column_span)
70 return (iface->get_column_span) (cell);
76 * atk_table_cell_get_column_header_cells:
77 * @cell: a GObject instance that implements AtkTableCellIface
79 * Returns the column headers as an array of cell accessibles.
81 * Returns: (element-type AtkObject) (transfer full): a GPtrArray of AtkObjects
82 * representing the column header cells.
85 atk_table_cell_get_column_header_cells (AtkTableCell *cell)
87 AtkTableCellIface *iface;
89 g_return_val_if_fail (ATK_IS_TABLE_CELL (cell), NULL);
91 iface = ATK_TABLE_CELL_GET_IFACE (cell);
93 if (iface->get_column_header_cells)
94 return (iface->get_column_header_cells) (cell);
100 * atk_table_cell_get_position:
101 * @cell: a GObject instance that implements AtkTableCellIface
102 * @row: (out): the row of the given cell.
103 * @column: (out): the column of the given cell.
105 * Retrieves the tabular position of this cell.
107 * Returns: TRUE if successful; FALSE otherwise.
110 atk_table_cell_get_position (AtkTableCell *cell,
114 AtkTableCellIface *iface;
115 gint tmp_row, tmp_column;
116 gint *real_row = (row ? row : &tmp_row);
117 gint *real_column = (column ? column : &tmp_column);
122 g_return_val_if_fail (ATK_IS_TABLE_CELL (cell), FALSE);
124 iface = ATK_TABLE_CELL_GET_IFACE (cell);
126 if (iface->get_position)
127 return (iface->get_position) (cell, real_row, real_column);
133 * atk_table_cell_get_row_span:
134 * @cell: a GObject instance that implements AtkTableCellIface
136 * Returns the number of rows occupied by this cell accessible.
138 * Returns: a gint representing the number of rows occupied by this cell,
139 * or 0 if the cell does not implement this method.
142 atk_table_cell_get_row_span (AtkTableCell *cell)
144 AtkTableCellIface *iface;
146 g_return_val_if_fail (ATK_IS_TABLE_CELL (cell), 0);
148 iface = ATK_TABLE_CELL_GET_IFACE (cell);
150 if (iface->get_row_span)
151 return (iface->get_row_span) (cell);
157 * atk_table_cell_get_row_header_cells:
158 * @cell: a GObject instance that implements AtkTableCellIface
160 * Returns the row headers as an array of cell accessibles.
162 * Returns: (element-type AtkObject) (transfer full): a GPtrArray of AtkObjects
163 * representing the row header cells.
166 atk_table_cell_get_row_header_cells (AtkTableCell *cell)
168 AtkTableCellIface *iface;
170 g_return_val_if_fail (ATK_IS_TABLE_CELL (cell), NULL);
172 iface = ATK_TABLE_CELL_GET_IFACE (cell);
174 if (iface->get_row_header_cells)
175 return (iface->get_row_header_cells) (cell);
181 * atk_table_cell_get_row_column_span:
182 * @cell: a GObject instance that implements AtkTableCellIface
183 * @row: (out): the row index of the given cell.
184 * @column: (out): the column index of the given cell.
185 * @row_span: (out): the number of rows occupied by this cell.
186 * @column_span: (out): the number of columns occupied by this cell.
188 * Gets the row and column indexes and span of this cell accessible.
190 * Note: If the object does not implement this function, then, by default, atk
191 * will implement this function by calling get_row_span and get_column_span
194 * Returns: TRUE if successful; FALSE otherwise.
197 atk_table_cell_get_row_column_span (AtkTableCell *cell,
203 AtkTableCellIface *iface;
204 gint local_row = 0, local_column = 0;
205 gint local_row_span = 0, local_column_span = 0;
206 gint *real_row, *real_column;
207 gint *real_row_span, *real_column_span;
209 g_return_val_if_fail (ATK_IS_TABLE_CELL (cell), FALSE);
211 real_row = (row ? row : &local_row);
212 real_column = (column ? column : &local_column);
213 real_row_span = (row_span ? row_span : &local_row_span);
214 real_column_span = (column_span ? column_span : &local_column_span);
216 iface = ATK_TABLE_CELL_GET_IFACE (cell);
218 if (iface->get_row_column_span)
219 return (iface->get_row_column_span) (cell, real_row, real_column,
227 * atk_table_cell_get_table:
228 * @cell: a GObject instance that implements AtkTableCellIface
230 * Returns a reference to the accessible of the containing table.
232 * Returns: (transfer full): the atk object for the containing table.
235 atk_table_cell_get_table (AtkTableCell *cell)
237 AtkTableCellIface *iface;
239 g_return_val_if_fail (ATK_IS_TABLE_CELL (cell), FALSE);
241 iface = ATK_TABLE_CELL_GET_IFACE (cell);
243 if (iface->get_table)
244 return (iface->get_table) (cell);
250 atk_table_cell_real_get_row_column_span (AtkTableCell *cell,
256 atk_table_cell_get_position (cell, row, column);
257 *row_span = atk_table_cell_get_row_span (cell);
258 *column_span = atk_table_cell_get_column_span (cell);
259 return (row != 0 && column != 0 && row_span > 0 && column_span > 0);