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.
22 #include "atktablecell.h"
26 * SECTION:atktablecell
27 * @Short_description: The ATK interface implemented for a cell inside
28 * a two-dimentional #AtkTable
31 * Being #AtkTable a component which present elements ordered via rows
32 * and columns, an #AtkTableCell is the interface which each of those
33 * elements, so "cells" should implement.
38 typedef AtkTableCellIface AtkTableCellInterface;
39 G_DEFINE_INTERFACE (AtkTableCell, atk_table_cell, ATK_TYPE_OBJECT)
41 static gboolean atk_table_cell_real_get_row_column_span (AtkTableCell *cell,
48 atk_table_cell_default_init (AtkTableCellInterface *iface)
50 iface->get_row_column_span = atk_table_cell_real_get_row_column_span;
54 * atk_table_cell_get_column_span:
55 * @cell: a GObject instance that implements AtkTableCellIface
57 * Returns the number of columns occupied by this cell accessible.
59 * Returns: a gint representing the number of columns occupied by this cell,
60 * or 0 if the cell does not implement this method.
65 atk_table_cell_get_column_span (AtkTableCell *cell)
67 AtkTableCellIface *iface;
69 g_return_val_if_fail (ATK_IS_TABLE_CELL (cell), 0);
71 iface = ATK_TABLE_CELL_GET_IFACE (cell);
73 if (iface->get_column_span)
74 return (iface->get_column_span) (cell);
80 * atk_table_cell_get_column_header_cells:
81 * @cell: a GObject instance that implements AtkTableCellIface
83 * Returns the column headers as an array of cell accessibles.
85 * Returns: (element-type AtkObject) (transfer full): a GPtrArray of AtkObjects
86 * representing the column header cells.
91 atk_table_cell_get_column_header_cells (AtkTableCell *cell)
93 AtkTableCellIface *iface;
95 g_return_val_if_fail (ATK_IS_TABLE_CELL (cell), NULL);
97 iface = ATK_TABLE_CELL_GET_IFACE (cell);
99 if (iface->get_column_header_cells)
100 return (iface->get_column_header_cells) (cell);
106 * atk_table_cell_get_position:
107 * @cell: a GObject instance that implements AtkTableCellIface
108 * @row: (out): the row of the given cell.
109 * @column: (out): the column of the given cell.
111 * Retrieves the tabular position of this cell.
113 * Returns: TRUE if successful; FALSE otherwise.
118 atk_table_cell_get_position (AtkTableCell *cell,
122 AtkTableCellIface *iface;
123 gint tmp_row, tmp_column;
124 gint *real_row = (row ? row : &tmp_row);
125 gint *real_column = (column ? column : &tmp_column);
130 g_return_val_if_fail (ATK_IS_TABLE_CELL (cell), FALSE);
132 iface = ATK_TABLE_CELL_GET_IFACE (cell);
134 if (iface->get_position)
135 return (iface->get_position) (cell, real_row, real_column);
141 * atk_table_cell_get_row_span:
142 * @cell: a GObject instance that implements AtkTableCellIface
144 * Returns the number of rows occupied by this cell accessible.
146 * Returns: a gint representing the number of rows occupied by this cell,
147 * or 0 if the cell does not implement this method.
152 atk_table_cell_get_row_span (AtkTableCell *cell)
154 AtkTableCellIface *iface;
156 g_return_val_if_fail (ATK_IS_TABLE_CELL (cell), 0);
158 iface = ATK_TABLE_CELL_GET_IFACE (cell);
160 if (iface->get_row_span)
161 return (iface->get_row_span) (cell);
167 * atk_table_cell_get_row_header_cells:
168 * @cell: a GObject instance that implements AtkTableCellIface
170 * Returns the row headers as an array of cell accessibles.
172 * Returns: (element-type AtkObject) (transfer full): a GPtrArray of AtkObjects
173 * representing the row header cells.
178 atk_table_cell_get_row_header_cells (AtkTableCell *cell)
180 AtkTableCellIface *iface;
182 g_return_val_if_fail (ATK_IS_TABLE_CELL (cell), NULL);
184 iface = ATK_TABLE_CELL_GET_IFACE (cell);
186 if (iface->get_row_header_cells)
187 return (iface->get_row_header_cells) (cell);
193 * atk_table_cell_get_row_column_span:
194 * @cell: a GObject instance that implements AtkTableCellIface
195 * @row: (out): the row index of the given cell.
196 * @column: (out): the column index of the given cell.
197 * @row_span: (out): the number of rows occupied by this cell.
198 * @column_span: (out): the number of columns occupied by this cell.
200 * Gets the row and column indexes and span of this cell accessible.
202 * Note: If the object does not implement this function, then, by default, atk
203 * will implement this function by calling get_row_span and get_column_span
206 * Returns: TRUE if successful; FALSE otherwise.
211 atk_table_cell_get_row_column_span (AtkTableCell *cell,
217 AtkTableCellIface *iface;
218 gint local_row = 0, local_column = 0;
219 gint local_row_span = 0, local_column_span = 0;
220 gint *real_row, *real_column;
221 gint *real_row_span, *real_column_span;
223 g_return_val_if_fail (ATK_IS_TABLE_CELL (cell), FALSE);
225 real_row = (row ? row : &local_row);
226 real_column = (column ? column : &local_column);
227 real_row_span = (row_span ? row_span : &local_row_span);
228 real_column_span = (column_span ? column_span : &local_column_span);
230 iface = ATK_TABLE_CELL_GET_IFACE (cell);
232 if (iface->get_row_column_span)
233 return (iface->get_row_column_span) (cell, real_row, real_column,
241 * atk_table_cell_get_table:
242 * @cell: a GObject instance that implements AtkTableCellIface
244 * Returns a reference to the accessible of the containing table.
246 * Returns: (transfer full): the atk object for the containing table.
251 atk_table_cell_get_table (AtkTableCell *cell)
253 AtkTableCellIface *iface;
255 g_return_val_if_fail (ATK_IS_TABLE_CELL (cell), FALSE);
257 iface = ATK_TABLE_CELL_GET_IFACE (cell);
259 if (iface->get_table)
260 return (iface->get_table) (cell);
266 atk_table_cell_real_get_row_column_span (AtkTableCell *cell,
272 atk_table_cell_get_position (cell, row, column);
273 *row_span = atk_table_cell_get_row_span (cell);
274 *column_span = atk_table_cell_get_column_span (cell);
275 return (row != 0 && column != 0 && row_span > 0 && column_span > 0);