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: (transfer none): a AtkObject* representing the table caption, or
361 * %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: (transfer none): a AtkObject* representing the specified column
465 * header, or %NULL if value does not implement this interface.
468 atk_table_get_column_header (AtkTable *table, gint column)
470 AtkTableIface *iface;
472 g_return_val_if_fail (ATK_IS_TABLE (table), NULL);
474 iface = ATK_TABLE_GET_IFACE (table);
476 if (iface->get_column_header)
477 return (iface->get_column_header) (table, column);
483 * atk_table_get_n_rows:
484 * @table: a GObject instance that implements AtkTableIface
486 * Gets the number of rows in the table.
488 * Returns: a gint representing the number of rows, or 0
489 * if value does not implement this interface.
492 atk_table_get_n_rows (AtkTable *table)
494 AtkTableIface *iface;
496 g_return_val_if_fail (ATK_IS_TABLE (table), 0);
498 iface = ATK_TABLE_GET_IFACE (table);
500 if (iface->get_n_rows)
501 return (iface->get_n_rows) (table);
507 * atk_table_get_row_description:
508 * @table: a GObject instance that implements AtkTableIface
509 * @row: a #gint representing a row in @table
511 * Gets the description text of the specified row in the table
513 * Returns: a gchar* representing the row description, or %NULL
514 * if value does not implement this interface.
517 atk_table_get_row_description (AtkTable *table,
520 AtkTableIface *iface;
522 g_return_val_if_fail (ATK_IS_TABLE (table), NULL);
524 iface = ATK_TABLE_GET_IFACE (table);
526 if (iface->get_row_description)
527 return (iface->get_row_description) (table, row);
533 * atk_table_get_row_extent_at:
534 * @table: a GObject instance that implements AtkTableIface
535 * @row: a #gint representing a row in @table
536 * @column: a #gint representing a column in @table
538 * Gets the number of rows occupied by the accessible object
539 * at a specified @row and @column in the @table.
541 * Returns: a gint representing the row extent at specified position, or 0
542 * if value does not implement this interface.
545 atk_table_get_row_extent_at (AtkTable *table,
549 AtkTableIface *iface;
551 g_return_val_if_fail (ATK_IS_TABLE (table), 0);
553 iface = ATK_TABLE_GET_IFACE (table);
555 if (iface->get_row_extent_at)
556 return (iface->get_row_extent_at) (table, row, column);
562 * atk_table_get_row_header:
563 * @table: a GObject instance that implements AtkTableIface
564 * @row: a #gint representing a row in the table
566 * Gets the row header of a specified row in an accessible table.
568 * Returns: (transfer none): a AtkObject* representing the specified row
569 * header, or %NULL if value does not implement this interface.
572 atk_table_get_row_header (AtkTable *table, gint row)
574 AtkTableIface *iface;
576 g_return_val_if_fail (ATK_IS_TABLE (table), NULL);
578 iface = ATK_TABLE_GET_IFACE (table);
580 if (iface->get_row_header)
581 return (iface->get_row_header) (table, row);
587 * atk_table_get_summary:
588 * @table: a GObject instance that implements AtkTableIface
590 * Gets the summary description of the table.
592 * Returns: (transfer full): a AtkObject* representing a summary description
593 * of the table, or zero if value does not implement this interface.
596 atk_table_get_summary (AtkTable *table)
598 AtkTableIface *iface;
600 g_return_val_if_fail (ATK_IS_TABLE (table), NULL);
602 iface = ATK_TABLE_GET_IFACE (table);
604 if (iface->get_summary)
605 return (iface->get_summary) (table);
611 * atk_table_get_selected_rows:
612 * @table: a GObject instance that implements AtkTableIface
613 * @selected: a #gint** that is to contain the selected row numbers
615 * Gets the selected rows of the table by initializing **selected with
616 * the selected row numbers. This array should be freed by the caller.
618 * Returns: a gint representing the number of selected rows,
619 * or zero if value does not implement this interface.
622 atk_table_get_selected_rows (AtkTable *table, gint **selected)
624 AtkTableIface *iface;
626 g_return_val_if_fail (ATK_IS_TABLE (table), 0);
628 iface = ATK_TABLE_GET_IFACE (table);
630 if (iface->get_selected_rows)
631 return (iface->get_selected_rows) (table, selected);
637 * atk_table_get_selected_columns:
638 * @table: a GObject instance that implements AtkTableIface
639 * @selected: a #gint** that is to contain the selected columns numbers
641 * Gets the selected columns of the table by initializing **selected with
642 * the selected column numbers. This array should be freed by the caller.
644 * Returns: a gint representing the number of selected columns,
645 * or %0 if value does not implement this interface.
648 atk_table_get_selected_columns (AtkTable *table, gint **selected)
650 AtkTableIface *iface;
652 g_return_val_if_fail (ATK_IS_TABLE (table), 0);
654 iface = ATK_TABLE_GET_IFACE (table);
656 if (iface->get_selected_columns)
657 return (iface->get_selected_columns) (table, selected);
663 * atk_table_is_column_selected:
664 * @table: a GObject instance that implements AtkTableIface
665 * @column: a #gint representing a column in @table
667 * Gets a boolean value indicating whether the specified @column
670 * Returns: a gboolean representing if the column is selected, or 0
671 * if value does not implement this interface.
674 atk_table_is_column_selected (AtkTable *table,
677 AtkTableIface *iface;
679 g_return_val_if_fail (ATK_IS_TABLE (table), FALSE);
681 iface = ATK_TABLE_GET_IFACE (table);
683 if (iface->is_column_selected)
684 return (iface->is_column_selected) (table, column);
690 * atk_table_is_row_selected:
691 * @table: a GObject instance that implements AtkTableIface
692 * @row: a #gint representing a row in @table
694 * Gets a boolean value indicating whether the specified @row
697 * Returns: a gboolean representing if the row is selected, or 0
698 * if value does not implement this interface.
701 atk_table_is_row_selected (AtkTable *table,
704 AtkTableIface *iface;
706 g_return_val_if_fail (ATK_IS_TABLE (table), FALSE);
708 iface = ATK_TABLE_GET_IFACE (table);
710 if (iface->is_row_selected)
711 return (iface->is_row_selected) (table, row);
717 * atk_table_is_selected:
718 * @table: a GObject instance that implements AtkTableIface
719 * @row: a #gint representing a row in @table
720 * @column: a #gint representing a column in @table
722 * Gets a boolean value indicating whether the accessible object
723 * at the specified @row and @column is selected
725 * Returns: a gboolean representing if the cell is selected, or 0
726 * if value does not implement this interface.
729 atk_table_is_selected (AtkTable *table,
733 AtkTableIface *iface;
735 g_return_val_if_fail (ATK_IS_TABLE (table), FALSE);
737 iface = ATK_TABLE_GET_IFACE (table);
739 if (iface->is_selected)
740 return (iface->is_selected) (table, row, column);
746 * atk_table_add_row_selection:
747 * @table: a GObject instance that implements AtkTableIface
748 * @row: a #gint representing a row in @table
750 * Adds the specified @row to the selection.
752 * Returns: a gboolean representing if row was successfully added to selection,
753 * or 0 if value does not implement this interface.
756 atk_table_add_row_selection (AtkTable *table,
759 AtkTableIface *iface;
761 g_return_val_if_fail (ATK_IS_TABLE (table), FALSE);
763 iface = ATK_TABLE_GET_IFACE (table);
765 if (iface->add_row_selection)
766 return (iface->add_row_selection) (table, row);
771 * atk_table_remove_row_selection:
772 * @table: a GObject instance that implements AtkTableIface
773 * @row: a #gint representing a row in @table
775 * Removes the specified @row from the selection.
777 * Returns: a gboolean representing if the row was successfully removed from
778 * the selection, or 0 if value does not implement this interface.
781 atk_table_remove_row_selection (AtkTable *table,
784 AtkTableIface *iface;
786 g_return_val_if_fail (ATK_IS_TABLE (table), FALSE);
788 iface = ATK_TABLE_GET_IFACE (table);
790 if (iface->remove_row_selection)
791 return (iface->remove_row_selection) (table, row);
796 * atk_table_add_column_selection:
797 * @table: a GObject instance that implements AtkTableIface
798 * @column: a #gint representing a column in @table
800 * Adds the specified @column to the selection.
802 * Returns: a gboolean representing if the column was successfully added to
803 * the selection, or 0 if value does not implement this interface.
806 atk_table_add_column_selection (AtkTable *table,
809 AtkTableIface *iface;
811 g_return_val_if_fail (ATK_IS_TABLE (table), FALSE);
813 iface = ATK_TABLE_GET_IFACE (table);
815 if (iface->add_column_selection)
816 return (iface->add_column_selection) (table, column);
821 * atk_table_remove_column_selection:
822 * @table: a GObject instance that implements AtkTableIface
823 * @column: a #gint representing a column in @table
825 * Adds the specified @column to the selection.
827 * Returns: a gboolean representing if the column was successfully removed from
828 * the selection, or 0 if value does not implement this interface.
831 atk_table_remove_column_selection (AtkTable *table,
834 AtkTableIface *iface;
836 g_return_val_if_fail (ATK_IS_TABLE (table), FALSE);
838 iface = ATK_TABLE_GET_IFACE (table);
840 if (iface->remove_column_selection)
841 return (iface->remove_column_selection) (table, column);
847 * atk_table_set_caption:
848 * @table: a GObject instance that implements AtkTableIface
849 * @caption: a #AtkObject representing the caption to set for @table
851 * Sets the caption for the table.
854 atk_table_set_caption (AtkTable *table,
857 AtkTableIface *iface;
859 g_return_if_fail (ATK_IS_TABLE (table));
861 iface = ATK_TABLE_GET_IFACE (table);
863 if (iface->set_caption)
864 (iface->set_caption) (table, caption);
868 * atk_table_set_column_description:
869 * @table: a GObject instance that implements AtkTableIface
870 * @column: a #gint representing a column in @table
871 * @description: a #gchar representing the description text
872 * to set for the specified @column of the @table
874 * Sets the description text for the specified @column of the @table.
877 atk_table_set_column_description (AtkTable *table,
879 const gchar *description)
881 AtkTableIface *iface;
883 g_return_if_fail (ATK_IS_TABLE (table));
885 iface = ATK_TABLE_GET_IFACE (table);
887 if (iface->set_column_description)
888 (iface->set_column_description) (table, column, description);
892 * atk_table_set_column_header:
893 * @table: a GObject instance that implements AtkTableIface
894 * @column: a #gint representing a column in @table
895 * @header: an #AtkTable
897 * Sets the specified column header to @header.
900 atk_table_set_column_header (AtkTable *table,
904 AtkTableIface *iface;
906 g_return_if_fail (ATK_IS_TABLE (table));
908 iface = ATK_TABLE_GET_IFACE (table);
910 if (iface->set_column_header)
911 (iface->set_column_header) (table, column, header);
915 * atk_table_set_row_description:
916 * @table: a GObject instance that implements AtkTableIface
917 * @row: a #gint representing a row in @table
918 * @description: a #gchar representing the description text
919 * to set for the specified @row of @table
921 * Sets the description text for the specified @row of @table.
924 atk_table_set_row_description (AtkTable *table,
926 const gchar *description)
928 AtkTableIface *iface;
930 g_return_if_fail (ATK_IS_TABLE (table));
932 iface = ATK_TABLE_GET_IFACE (table);
934 if (iface->set_row_description)
935 (iface->set_row_description) (table, row, description);
939 * atk_table_set_row_header:
940 * @table: a GObject instance that implements AtkTableIface
941 * @row: a #gint representing a row in @table
942 * @header: an #AtkTable
944 * Sets the specified row header to @header.
947 atk_table_set_row_header (AtkTable *table,
951 AtkTableIface *iface;
953 g_return_if_fail (ATK_IS_TABLE (table));
955 iface = ATK_TABLE_GET_IFACE (table);
957 if (iface->set_row_header)
958 (iface->set_row_header) (table, row, header);
962 * atk_table_set_summary:
963 * @table: a GObject instance that implements AtkTableIface
964 * @accessible: an #AtkObject representing the summary description
967 * Sets the summary description of the table.
970 atk_table_set_summary (AtkTable *table,
971 AtkObject *accessible)
973 AtkTableIface *iface;
975 g_return_if_fail (ATK_IS_TABLE (table));
977 iface = ATK_TABLE_GET_IFACE (table);
979 if (iface->set_summary)
980 (iface->set_summary) (table, accessible);