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.
63 atk_table_cell_get_column_span (AtkTableCell *cell)
65 AtkTableCellIface *iface;
67 g_return_val_if_fail (ATK_IS_TABLE_CELL (cell), 0);
69 iface = ATK_TABLE_CELL_GET_IFACE (cell);
71 if (iface->get_column_span)
72 return (iface->get_column_span) (cell);
78 * atk_table_cell_get_column_header_cells:
79 * @cell: a GObject instance that implements AtkTableCellIface
81 * Returns the column headers as an array of cell accessibles.
83 * Returns: (element-type AtkObject) (transfer full): a GPtrArray of AtkObjects
84 * representing the column header cells.
89 atk_table_cell_get_column_header_cells (AtkTableCell *cell)
91 AtkTableCellIface *iface;
93 g_return_val_if_fail (ATK_IS_TABLE_CELL (cell), NULL);
95 iface = ATK_TABLE_CELL_GET_IFACE (cell);
97 if (iface->get_column_header_cells)
98 return (iface->get_column_header_cells) (cell);
104 * atk_table_cell_get_position:
105 * @cell: a GObject instance that implements AtkTableCellIface
106 * @row: (out): the row of the given cell.
107 * @column: (out): the column of the given cell.
109 * Retrieves the tabular position of this cell.
111 * Returns: TRUE if successful; FALSE otherwise.
116 atk_table_cell_get_position (AtkTableCell *cell,
120 AtkTableCellIface *iface;
121 gint tmp_row, tmp_column;
122 gint *real_row = (row ? row : &tmp_row);
123 gint *real_column = (column ? column : &tmp_column);
128 g_return_val_if_fail (ATK_IS_TABLE_CELL (cell), FALSE);
130 iface = ATK_TABLE_CELL_GET_IFACE (cell);
132 if (iface->get_position)
133 return (iface->get_position) (cell, real_row, real_column);
139 * atk_table_cell_get_row_span:
140 * @cell: a GObject instance that implements AtkTableCellIface
142 * Returns the number of rows occupied by this cell accessible.
144 * Returns: a gint representing the number of rows occupied by this cell,
145 * or 0 if the cell does not implement this method.
150 atk_table_cell_get_row_span (AtkTableCell *cell)
152 AtkTableCellIface *iface;
154 g_return_val_if_fail (ATK_IS_TABLE_CELL (cell), 0);
156 iface = ATK_TABLE_CELL_GET_IFACE (cell);
158 if (iface->get_row_span)
159 return (iface->get_row_span) (cell);
165 * atk_table_cell_get_row_header_cells:
166 * @cell: a GObject instance that implements AtkTableCellIface
168 * Returns the row headers as an array of cell accessibles.
170 * Returns: (element-type AtkObject) (transfer full): a GPtrArray of AtkObjects
171 * representing the row header cells.
176 atk_table_cell_get_row_header_cells (AtkTableCell *cell)
178 AtkTableCellIface *iface;
180 g_return_val_if_fail (ATK_IS_TABLE_CELL (cell), NULL);
182 iface = ATK_TABLE_CELL_GET_IFACE (cell);
184 if (iface->get_row_header_cells)
185 return (iface->get_row_header_cells) (cell);
191 * atk_table_cell_get_row_column_span:
192 * @cell: a GObject instance that implements AtkTableCellIface
193 * @row: (out): the row index of the given cell.
194 * @column: (out): the column index of the given cell.
195 * @row_span: (out): the number of rows occupied by this cell.
196 * @column_span: (out): the number of columns occupied by this cell.
198 * Gets the row and column indexes and span of this cell accessible.
200 * Note: If the object does not implement this function, then, by default, atk
201 * will implement this function by calling get_row_span and get_column_span
204 * Returns: TRUE if successful; FALSE otherwise.
209 atk_table_cell_get_row_column_span (AtkTableCell *cell,
215 AtkTableCellIface *iface;
216 gint local_row = 0, local_column = 0;
217 gint local_row_span = 0, local_column_span = 0;
218 gint *real_row, *real_column;
219 gint *real_row_span, *real_column_span;
221 g_return_val_if_fail (ATK_IS_TABLE_CELL (cell), FALSE);
223 real_row = (row ? row : &local_row);
224 real_column = (column ? column : &local_column);
225 real_row_span = (row_span ? row_span : &local_row_span);
226 real_column_span = (column_span ? column_span : &local_column_span);
228 iface = ATK_TABLE_CELL_GET_IFACE (cell);
230 if (iface->get_row_column_span)
231 return (iface->get_row_column_span) (cell, real_row, real_column,
239 * atk_table_cell_get_table:
240 * @cell: a GObject instance that implements AtkTableCellIface
242 * Returns a reference to the accessible of the containing table.
244 * Returns: (transfer full): the atk object for the containing table.
249 atk_table_cell_get_table (AtkTableCell *cell)
251 AtkTableCellIface *iface;
253 g_return_val_if_fail (ATK_IS_TABLE_CELL (cell), FALSE);
255 iface = ATK_TABLE_CELL_GET_IFACE (cell);
257 if (iface->get_table)
258 return (iface->get_table) (cell);
264 atk_table_cell_real_get_row_column_span (AtkTableCell *cell,
270 atk_table_cell_get_position (cell, row, column);
271 *row_span = atk_table_cell_get_row_span (cell);
272 *column_span = atk_table_cell_get_column_span (cell);
273 return (row != 0 && column != 0 && row_span > 0 && column_span > 0);