MSVC 2010+ Builds: Fix .pdb File Generation
[atk.git] / atk / atktablecell.c
blob9b1c349ab5e3694a7379fe4ca9286147500c395f
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 "config.h"
22 #include "atktablecell.h"
25 /**
26 * SECTION:atktablecell
27 * @Short_description: The ATK interface implemented for a cell inside
28 * a two-dimentional #AtkTable
29 * @Title:AtkTableCell
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.
35 * See also #AtkTable.
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,
42 gint *row,
43 gint *column,
44 gint *row_span,
45 gint *column_span);
47 static void
48 atk_table_cell_default_init (AtkTableCellInterface *iface)
50 iface->get_row_column_span = atk_table_cell_real_get_row_column_span;
53 /**
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.
62 * Since: 2.12
64 gint
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);
75 else
76 return 0;
79 /**
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.
88 * Since: 2.12
90 GPtrArray *
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);
101 else
102 return NULL;
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.
115 * Since: 2.12
117 gboolean
118 atk_table_cell_get_position (AtkTableCell *cell,
119 gint *row,
120 gint *column)
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);
127 *real_row = -1;
128 *real_column = -1;
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);
136 else
137 return FALSE;
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.
149 * Since: 2.12
151 gint
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);
162 else
163 return 0;
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.
175 * Since: 2.12
177 GPtrArray *
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);
188 else
189 return NULL;
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
204 * on the object.
206 * Returns: TRUE if successful; FALSE otherwise.
208 * Since: 2.12
210 gboolean
211 atk_table_cell_get_row_column_span (AtkTableCell *cell,
212 gint *row,
213 gint *column,
214 gint *row_span,
215 gint *column_span)
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,
234 real_row_span,
235 real_column_span);
236 else
237 return FALSE;
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.
248 * Since: 2.12
250 AtkObject *
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);
261 else
262 return NULL;
265 static gboolean
266 atk_table_cell_real_get_row_column_span (AtkTableCell *cell,
267 gint *row,
268 gint *column,
269 gint *row_span,
270 gint *column_span)
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);