1 /* ATK - Accessibility Toolkit
2 * Copyright 2001 Sun Microsystems Inc.
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.
23 #include "atkmarshal.h"
27 * @Short_description: The ATK interface implemented for UI components
28 * which contain tabular or row/column information.
31 * #AtkTable should be implemented by components which present
32 * elements ordered via rows and columns. It may also be used to
33 * present tree-structured information if the nodes of the trees can
34 * be said to contain multiple "columns". Individual elements of an
35 * #AtkTable are typically referred to as "cells". Those cells should
36 * implement the interface #AtkTableCell, but #Atk doesn't require
37 * them to be direct children of the current #AtkTable. They can be
38 * grand-children, grand-grand-children etc. #AtkTable provides the
39 * API needed to get a individual cell based on the row and column
42 * Children of #AtkTable are frequently "lightweight" objects, that
43 * is, they may not have backing widgets in the host UI toolkit. They
44 * are therefore often transient.
46 * Since tables are often very complex, #AtkTable includes provision
47 * for offering simplified summary information, as well as row and
48 * column headers and captions. Headers and captions are #AtkObjects
49 * which may implement other interfaces (#AtkText, #AtkImage, etc.) as
50 * appropriate. #AtkTable summaries may themselves be (simplified)
53 * Note for implementors: in the past, #AtkTable required that all the
54 * cells should be direct children of #AtkTable, and provided some
55 * index based methods to request the cells. The practice showed that
56 * that forcing made #AtkTable implementation complex, and hard to
57 * expose other kind of children, like rows or captions. Right now,
58 * index-based methods are deprecated.
72 static void atk_table_base_init (gpointer *g_class);
74 static guint atk_table_signals[LAST_SIGNAL] = { 0 };
77 atk_table_get_type (void)
79 static GType type = 0;
84 sizeof (AtkTableIface),
85 (GBaseInitFunc) atk_table_base_init,
86 (GBaseFinalizeFunc) NULL,
90 type = g_type_register_static (G_TYPE_INTERFACE, "AtkTable", &tinfo, 0);
98 atk_table_base_init (gpointer *g_class)
100 static gboolean initialized = FALSE;
105 * AtkTable::row-inserted:
106 * @atktable: the object which received the signal.
107 * @arg1: The index of the first row inserted.
108 * @arg2: The number of rows inserted.
110 * The "row-inserted" signal is emitted by an object which
111 * implements the AtkTable interface when a row is inserted.
113 atk_table_signals[ROW_INSERTED] =
114 g_signal_new ("row_inserted",
117 G_STRUCT_OFFSET (AtkTableIface, row_inserted),
118 (GSignalAccumulator) NULL, NULL,
119 atk_marshal_VOID__INT_INT,
121 2, G_TYPE_INT, G_TYPE_INT);
123 * AtkTable::column-inserted:
124 * @atktable: the object which received the signal.
125 * @arg1: The index of the column inserted.
126 * @arg2: The number of colums inserted.
128 * The "column-inserted" signal is emitted by an object which
129 * implements the AtkTable interface when a column is inserted.
131 atk_table_signals[COLUMN_INSERTED] =
132 g_signal_new ("column_inserted",
135 G_STRUCT_OFFSET (AtkTableIface, column_inserted),
136 (GSignalAccumulator) NULL, NULL,
137 atk_marshal_VOID__INT_INT,
139 2, G_TYPE_INT, G_TYPE_INT);
141 * AtkTable::row-deleted:
142 * @atktable: the object which received the signal.
143 * @arg1: The index of the first row deleted.
144 * @arg2: The number of rows deleted.
146 * The "row-deleted" signal is emitted by an object which
147 * implements the AtkTable interface when a row is deleted.
149 atk_table_signals[ROW_DELETED] =
150 g_signal_new ("row_deleted",
153 G_STRUCT_OFFSET (AtkTableIface, row_deleted),
154 (GSignalAccumulator) NULL, NULL,
155 atk_marshal_VOID__INT_INT,
157 2, G_TYPE_INT, G_TYPE_INT);
159 * AtkTable::column-deleted:
160 * @atktable: the object which received the signal.
161 * @arg1: The index of the first column deleted.
162 * @arg2: The number of columns deleted.
164 * The "column-deleted" signal is emitted by an object which
165 * implements the AtkTable interface when a column is deleted.
167 atk_table_signals[COLUMN_DELETED] =
168 g_signal_new ("column_deleted",
171 G_STRUCT_OFFSET (AtkTableIface, column_deleted),
172 (GSignalAccumulator) NULL, NULL,
173 atk_marshal_VOID__INT_INT,
175 2, G_TYPE_INT, G_TYPE_INT);
177 * AtkTable::row-reordered:
178 * @atktable: the object which received the signal.
180 * The "row-reordered" signal is emitted by an object which
181 * implements the AtkTable interface when the rows are
184 atk_table_signals[ROW_REORDERED] =
185 g_signal_new ("row_reordered",
188 G_STRUCT_OFFSET (AtkTableIface, row_reordered),
189 (GSignalAccumulator) NULL, NULL,
190 g_cclosure_marshal_VOID__VOID,
194 * AtkTable::column-reordered:
195 * @atktable: the object which received the signal.
197 * The "column-reordered" signal is emitted by an object which
198 * implements the AtkTable interface when the columns are
201 atk_table_signals[COLUMN_REORDERED] =
202 g_signal_new ("column_reordered",
205 G_STRUCT_OFFSET (AtkTableIface, column_reordered),
206 (GSignalAccumulator) NULL, NULL,
207 g_cclosure_marshal_VOID__VOID,
212 * AtkTable::model-changed:
213 * @atktable: the object which received the signal.
215 * The "model-changed" signal is emitted by an object which
216 * implements the AtkTable interface when the model displayed by
219 atk_table_signals[MODEL_CHANGED] =
220 g_signal_new ("model_changed",
223 G_STRUCT_OFFSET (AtkTableIface, model_changed),
224 (GSignalAccumulator) NULL, NULL,
225 g_cclosure_marshal_VOID__VOID,
234 * @table: a GObject instance that implements AtkTableIface
235 * @row: a #gint representing a row in @table
236 * @column: a #gint representing a column in @table
238 * Get a reference to the table cell at @row, @column. This cell
239 * should implement the interface #AtkTableCell
241 * Returns: (transfer full): an #AtkObject representing the referred
245 atk_table_ref_at (AtkTable *table,
249 AtkTableIface *iface;
251 g_return_val_if_fail (ATK_IS_TABLE (table), NULL);
252 g_return_val_if_fail (row >= 0, NULL);
253 g_return_val_if_fail (column >= 0, NULL);
255 iface = ATK_TABLE_GET_IFACE (table);
258 return (iface->ref_at) (table, row, column);
264 * atk_table_get_index_at:
265 * @table: a GObject instance that implements AtkTableIface
266 * @row: a #gint representing a row in @table
267 * @column: a #gint representing a column in @table
269 * Gets a #gint representing the index at the specified @row and
272 * Deprecated: Since 2.12. Use atk_table_ref_at() in order to get the
273 * accessible that represents the cell at (@row, @column)
275 * Returns: a #gint representing the index at specified position.
276 * The value -1 is returned if the object at row,column is not a child
277 * of table or table does not implement this interface.
280 atk_table_get_index_at (AtkTable *table,
284 AtkTableIface *iface;
286 g_return_val_if_fail (ATK_IS_TABLE (table), -1);
287 g_return_val_if_fail (row >= 0, -1);
288 g_return_val_if_fail (column >= 0, -1);
290 iface = ATK_TABLE_GET_IFACE (table);
292 if (iface->get_index_at)
293 return (iface->get_index_at) (table, row, column);
299 * atk_table_get_row_at_index:
300 * @table: a GObject instance that implements AtkTableInterface
301 * @index_: a #gint representing an index in @table
303 * Gets a #gint representing the row at the specified @index_.
305 * Deprecated: since 2.12.
307 * Returns: a gint representing the row at the specified index,
308 * or -1 if the table does not implement this method.
311 atk_table_get_row_at_index (AtkTable *table,
314 AtkTableIface *iface;
316 g_return_val_if_fail (ATK_IS_TABLE (table), -1);
318 iface = ATK_TABLE_GET_IFACE (table);
320 if (iface->get_row_at_index)
321 return (iface->get_row_at_index) (table, index);
327 * atk_table_get_column_at_index:
328 * @table: a GObject instance that implements AtkTableInterface
329 * @index_: a #gint representing an index in @table
331 * Gets a #gint representing the column at the specified @index_.
333 * Deprecated: Since 2.12.
335 * Returns: a gint representing the column at the specified index,
336 * or -1 if the table does not implement this method.
339 atk_table_get_column_at_index (AtkTable *table,
342 AtkTableIface *iface;
344 g_return_val_if_fail (ATK_IS_TABLE (table), 0);
346 iface = ATK_TABLE_GET_IFACE (table);
348 if (iface->get_column_at_index)
349 return (iface->get_column_at_index) (table, index);
355 * atk_table_get_caption:
356 * @table: a GObject instance that implements AtkTableInterface
358 * Gets the caption for the @table.
360 * Returns: (nullable) (transfer none): a AtkObject* representing the
361 * table caption, or %NULL if value does not implement this interface.
364 atk_table_get_caption (AtkTable *table)
366 AtkTableIface *iface;
368 g_return_val_if_fail (ATK_IS_TABLE (table), NULL);
370 iface = ATK_TABLE_GET_IFACE (table);
372 if (iface->get_caption)
373 return (iface->get_caption) (table);
379 * atk_table_get_n_columns:
380 * @table: a GObject instance that implements AtkTableIface
382 * Gets the number of columns in the table.
384 * Returns: a gint representing the number of columns, or 0
385 * if value does not implement this interface.
388 atk_table_get_n_columns (AtkTable *table)
390 AtkTableIface *iface;
392 g_return_val_if_fail (ATK_IS_TABLE (table), 0);
394 iface = ATK_TABLE_GET_IFACE (table);
396 if (iface->get_n_columns)
397 return (iface->get_n_columns) (table);
403 * atk_table_get_column_description:
404 * @table: a GObject instance that implements AtkTableIface
405 * @column: a #gint representing a column in @table
407 * Gets the description text of the specified @column in the table
409 * Returns: a gchar* representing the column description, or %NULL
410 * if value does not implement this interface.
413 atk_table_get_column_description (AtkTable *table,
416 AtkTableIface *iface;
418 g_return_val_if_fail (ATK_IS_TABLE (table), NULL);
420 iface = ATK_TABLE_GET_IFACE (table);
422 if (iface->get_column_description)
423 return (iface->get_column_description) (table, column);
429 * atk_table_get_column_extent_at:
430 * @table: a GObject instance that implements AtkTableIface
431 * @row: a #gint representing a row in @table
432 * @column: a #gint representing a column in @table
434 * Gets the number of columns occupied by the accessible object
435 * at the specified @row and @column in the @table.
437 * Returns: a gint representing the column extent at specified position, or 0
438 * if value does not implement this interface.
441 atk_table_get_column_extent_at (AtkTable *table,
445 AtkTableIface *iface;
447 g_return_val_if_fail (ATK_IS_TABLE (table), 0);
449 iface = ATK_TABLE_GET_IFACE (table);
451 if (iface->get_column_extent_at)
452 return (iface->get_column_extent_at) (table, row, column);
458 * atk_table_get_column_header:
459 * @table: a GObject instance that implements AtkTableIface
460 * @column: a #gint representing a column in the table
462 * Gets the column header of a specified column in an accessible table.
464 * Returns: (nullable) (transfer none): a AtkObject* representing the
465 * specified column header, or %NULL if value does not implement this
469 atk_table_get_column_header (AtkTable *table, gint column)
471 AtkTableIface *iface;
473 g_return_val_if_fail (ATK_IS_TABLE (table), NULL);
475 iface = ATK_TABLE_GET_IFACE (table);
477 if (iface->get_column_header)
478 return (iface->get_column_header) (table, column);
484 * atk_table_get_n_rows:
485 * @table: a GObject instance that implements AtkTableIface
487 * Gets the number of rows in the table.
489 * Returns: a gint representing the number of rows, or 0
490 * if value does not implement this interface.
493 atk_table_get_n_rows (AtkTable *table)
495 AtkTableIface *iface;
497 g_return_val_if_fail (ATK_IS_TABLE (table), 0);
499 iface = ATK_TABLE_GET_IFACE (table);
501 if (iface->get_n_rows)
502 return (iface->get_n_rows) (table);
508 * atk_table_get_row_description:
509 * @table: a GObject instance that implements AtkTableIface
510 * @row: a #gint representing a row in @table
512 * Gets the description text of the specified row in the table
514 * Returns: (nullable): a gchar* representing the row description, or
515 * %NULL if value does not implement this interface.
518 atk_table_get_row_description (AtkTable *table,
521 AtkTableIface *iface;
523 g_return_val_if_fail (ATK_IS_TABLE (table), NULL);
525 iface = ATK_TABLE_GET_IFACE (table);
527 if (iface->get_row_description)
528 return (iface->get_row_description) (table, row);
534 * atk_table_get_row_extent_at:
535 * @table: a GObject instance that implements AtkTableIface
536 * @row: a #gint representing a row in @table
537 * @column: a #gint representing a column in @table
539 * Gets the number of rows occupied by the accessible object
540 * at a specified @row and @column in the @table.
542 * Returns: a gint representing the row extent at specified position, or 0
543 * if value does not implement this interface.
546 atk_table_get_row_extent_at (AtkTable *table,
550 AtkTableIface *iface;
552 g_return_val_if_fail (ATK_IS_TABLE (table), 0);
554 iface = ATK_TABLE_GET_IFACE (table);
556 if (iface->get_row_extent_at)
557 return (iface->get_row_extent_at) (table, row, column);
563 * atk_table_get_row_header:
564 * @table: a GObject instance that implements AtkTableIface
565 * @row: a #gint representing a row in the table
567 * Gets the row header of a specified row in an accessible table.
569 * Returns: (nullable) (transfer none): a AtkObject* representing the
570 * specified row header, or %NULL if value does not implement this
574 atk_table_get_row_header (AtkTable *table, gint row)
576 AtkTableIface *iface;
578 g_return_val_if_fail (ATK_IS_TABLE (table), NULL);
580 iface = ATK_TABLE_GET_IFACE (table);
582 if (iface->get_row_header)
583 return (iface->get_row_header) (table, row);
589 * atk_table_get_summary:
590 * @table: a GObject instance that implements AtkTableIface
592 * Gets the summary description of the table.
594 * Returns: (transfer full): a AtkObject* representing a summary description
595 * of the table, or zero if value does not implement this interface.
598 atk_table_get_summary (AtkTable *table)
600 AtkTableIface *iface;
602 g_return_val_if_fail (ATK_IS_TABLE (table), NULL);
604 iface = ATK_TABLE_GET_IFACE (table);
606 if (iface->get_summary)
607 return (iface->get_summary) (table);
613 * atk_table_get_selected_rows:
614 * @table: a GObject instance that implements AtkTableIface
615 * @selected: a #gint** that is to contain the selected row numbers
617 * Gets the selected rows of the table by initializing **selected with
618 * the selected row numbers. This array should be freed by the caller.
620 * Returns: a gint representing the number of selected rows,
621 * or zero if value does not implement this interface.
624 atk_table_get_selected_rows (AtkTable *table, gint **selected)
626 AtkTableIface *iface;
628 g_return_val_if_fail (ATK_IS_TABLE (table), 0);
630 iface = ATK_TABLE_GET_IFACE (table);
632 if (iface->get_selected_rows)
633 return (iface->get_selected_rows) (table, selected);
639 * atk_table_get_selected_columns:
640 * @table: a GObject instance that implements AtkTableIface
641 * @selected: a #gint** that is to contain the selected columns numbers
643 * Gets the selected columns of the table by initializing **selected with
644 * the selected column numbers. This array should be freed by the caller.
646 * Returns: a gint representing the number of selected columns,
647 * or %0 if value does not implement this interface.
650 atk_table_get_selected_columns (AtkTable *table, gint **selected)
652 AtkTableIface *iface;
654 g_return_val_if_fail (ATK_IS_TABLE (table), 0);
656 iface = ATK_TABLE_GET_IFACE (table);
658 if (iface->get_selected_columns)
659 return (iface->get_selected_columns) (table, selected);
665 * atk_table_is_column_selected:
666 * @table: a GObject instance that implements AtkTableIface
667 * @column: a #gint representing a column in @table
669 * Gets a boolean value indicating whether the specified @column
672 * Returns: a gboolean representing if the column is selected, or 0
673 * if value does not implement this interface.
676 atk_table_is_column_selected (AtkTable *table,
679 AtkTableIface *iface;
681 g_return_val_if_fail (ATK_IS_TABLE (table), FALSE);
683 iface = ATK_TABLE_GET_IFACE (table);
685 if (iface->is_column_selected)
686 return (iface->is_column_selected) (table, column);
692 * atk_table_is_row_selected:
693 * @table: a GObject instance that implements AtkTableIface
694 * @row: a #gint representing a row in @table
696 * Gets a boolean value indicating whether the specified @row
699 * Returns: a gboolean representing if the row is selected, or 0
700 * if value does not implement this interface.
703 atk_table_is_row_selected (AtkTable *table,
706 AtkTableIface *iface;
708 g_return_val_if_fail (ATK_IS_TABLE (table), FALSE);
710 iface = ATK_TABLE_GET_IFACE (table);
712 if (iface->is_row_selected)
713 return (iface->is_row_selected) (table, row);
719 * atk_table_is_selected:
720 * @table: a GObject instance that implements AtkTableIface
721 * @row: a #gint representing a row in @table
722 * @column: a #gint representing a column in @table
724 * Gets a boolean value indicating whether the accessible object
725 * at the specified @row and @column is selected
727 * Returns: a gboolean representing if the cell is selected, or 0
728 * if value does not implement this interface.
731 atk_table_is_selected (AtkTable *table,
735 AtkTableIface *iface;
737 g_return_val_if_fail (ATK_IS_TABLE (table), FALSE);
739 iface = ATK_TABLE_GET_IFACE (table);
741 if (iface->is_selected)
742 return (iface->is_selected) (table, row, column);
748 * atk_table_add_row_selection:
749 * @table: a GObject instance that implements AtkTableIface
750 * @row: a #gint representing a row in @table
752 * Adds the specified @row to the selection.
754 * Returns: a gboolean representing if row was successfully added to selection,
755 * or 0 if value does not implement this interface.
758 atk_table_add_row_selection (AtkTable *table,
761 AtkTableIface *iface;
763 g_return_val_if_fail (ATK_IS_TABLE (table), FALSE);
765 iface = ATK_TABLE_GET_IFACE (table);
767 if (iface->add_row_selection)
768 return (iface->add_row_selection) (table, row);
773 * atk_table_remove_row_selection:
774 * @table: a GObject instance that implements AtkTableIface
775 * @row: a #gint representing a row in @table
777 * Removes the specified @row from the selection.
779 * Returns: a gboolean representing if the row was successfully removed from
780 * the selection, or 0 if value does not implement this interface.
783 atk_table_remove_row_selection (AtkTable *table,
786 AtkTableIface *iface;
788 g_return_val_if_fail (ATK_IS_TABLE (table), FALSE);
790 iface = ATK_TABLE_GET_IFACE (table);
792 if (iface->remove_row_selection)
793 return (iface->remove_row_selection) (table, row);
798 * atk_table_add_column_selection:
799 * @table: a GObject instance that implements AtkTableIface
800 * @column: a #gint representing a column in @table
802 * Adds the specified @column to the selection.
804 * Returns: a gboolean representing if the column was successfully added to
805 * the selection, or 0 if value does not implement this interface.
808 atk_table_add_column_selection (AtkTable *table,
811 AtkTableIface *iface;
813 g_return_val_if_fail (ATK_IS_TABLE (table), FALSE);
815 iface = ATK_TABLE_GET_IFACE (table);
817 if (iface->add_column_selection)
818 return (iface->add_column_selection) (table, column);
823 * atk_table_remove_column_selection:
824 * @table: a GObject instance that implements AtkTableIface
825 * @column: a #gint representing a column in @table
827 * Adds the specified @column to the selection.
829 * Returns: a gboolean representing if the column was successfully removed from
830 * the selection, or 0 if value does not implement this interface.
833 atk_table_remove_column_selection (AtkTable *table,
836 AtkTableIface *iface;
838 g_return_val_if_fail (ATK_IS_TABLE (table), FALSE);
840 iface = ATK_TABLE_GET_IFACE (table);
842 if (iface->remove_column_selection)
843 return (iface->remove_column_selection) (table, column);
849 * atk_table_set_caption:
850 * @table: a GObject instance that implements AtkTableIface
851 * @caption: a #AtkObject representing the caption to set for @table
853 * Sets the caption for the table.
856 atk_table_set_caption (AtkTable *table,
859 AtkTableIface *iface;
861 g_return_if_fail (ATK_IS_TABLE (table));
863 iface = ATK_TABLE_GET_IFACE (table);
865 if (iface->set_caption)
866 (iface->set_caption) (table, caption);
870 * atk_table_set_column_description:
871 * @table: a GObject instance that implements AtkTableIface
872 * @column: a #gint representing a column in @table
873 * @description: a #gchar representing the description text
874 * to set for the specified @column of the @table
876 * Sets the description text for the specified @column of the @table.
879 atk_table_set_column_description (AtkTable *table,
881 const gchar *description)
883 AtkTableIface *iface;
885 g_return_if_fail (ATK_IS_TABLE (table));
887 iface = ATK_TABLE_GET_IFACE (table);
889 if (iface->set_column_description)
890 (iface->set_column_description) (table, column, description);
894 * atk_table_set_column_header:
895 * @table: a GObject instance that implements AtkTableIface
896 * @column: a #gint representing a column in @table
897 * @header: an #AtkTable
899 * Sets the specified column header to @header.
902 atk_table_set_column_header (AtkTable *table,
906 AtkTableIface *iface;
908 g_return_if_fail (ATK_IS_TABLE (table));
910 iface = ATK_TABLE_GET_IFACE (table);
912 if (iface->set_column_header)
913 (iface->set_column_header) (table, column, header);
917 * atk_table_set_row_description:
918 * @table: a GObject instance that implements AtkTableIface
919 * @row: a #gint representing a row in @table
920 * @description: a #gchar representing the description text
921 * to set for the specified @row of @table
923 * Sets the description text for the specified @row of @table.
926 atk_table_set_row_description (AtkTable *table,
928 const gchar *description)
930 AtkTableIface *iface;
932 g_return_if_fail (ATK_IS_TABLE (table));
934 iface = ATK_TABLE_GET_IFACE (table);
936 if (iface->set_row_description)
937 (iface->set_row_description) (table, row, description);
941 * atk_table_set_row_header:
942 * @table: a GObject instance that implements AtkTableIface
943 * @row: a #gint representing a row in @table
944 * @header: an #AtkTable
946 * Sets the specified row header to @header.
949 atk_table_set_row_header (AtkTable *table,
953 AtkTableIface *iface;
955 g_return_if_fail (ATK_IS_TABLE (table));
957 iface = ATK_TABLE_GET_IFACE (table);
959 if (iface->set_row_header)
960 (iface->set_row_header) (table, row, header);
964 * atk_table_set_summary:
965 * @table: a GObject instance that implements AtkTableIface
966 * @accessible: an #AtkObject representing the summary description
969 * Sets the summary description of the table.
972 atk_table_set_summary (AtkTable *table,
973 AtkObject *accessible)
975 AtkTableIface *iface;
977 g_return_if_fail (ATK_IS_TABLE (table));
979 iface = ATK_TABLE_GET_IFACE (table);
981 if (iface->set_summary)
982 (iface->set_summary) (table, accessible);