Added better gtk-doc comments.
[platform/upstream/atk.git] / atk / atktable.c
1 /* ATK -  Accessibility Toolkit
2  * Copyright 2001 Sun Microsystems Inc.
3  *
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.
8  *
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.
13  *
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.
18  */
19
20 #include "atktable.h"
21
22 GType
23 atk_table_get_type ()
24 {
25   static GType type = 0;
26
27   if (!type) {
28     GTypeInfo tinfo =
29     {
30       sizeof (AtkTableIface),
31       NULL,
32       NULL,
33
34     };
35
36     type = g_type_register_static (G_TYPE_INTERFACE, "AtkTable", &tinfo, 0);
37   }
38
39   return type;
40 }
41
42 /**
43  * atk_table_ref_at:
44  * @table: a GObject instance that implements AtkTableIface
45  * @row: a #gint representing a row in @table
46  * @column: a #gint representing a column in @table
47  *
48  * Get a reference to the table cell at @row, @column
49  *
50  * Returns: a AtkObject* representing the referred to accessible
51  **/
52 AtkObject*
53 atk_table_ref_at (AtkTable *obj,
54                   gint     row,
55                   gint     column)
56 {
57   AtkTableIface *iface;
58
59   g_return_val_if_fail (obj != NULL, NULL);
60   g_return_val_if_fail (ATK_IS_TABLE (obj), NULL);
61
62   iface = ATK_TABLE_GET_IFACE (obj);
63
64   if (iface->ref_at)
65     return (iface->ref_at) (obj, row, column);
66   else
67     return NULL;
68 }
69
70 /**
71  * atk_table_get_index_at:
72  * @table: a GObject instance that implements AtkTableIface
73  * @row: a #gint representing a row in @table
74  * @column: a #gint representing a column in @table
75  *
76  * Returns a #gint representing the index at the specified @row and @column,
77  * or 0 if value does not implement this interface.
78  * Note: callers should not rely on %NULL or on a zero value for
79  * indication of whether AtkSelectionIface is implemented, they should
80  * use type checking/interface checking macros or the
81  * atk_get_accessible_table() convenience method.
82  *
83  * Returns: a #gint representing the index at specified position, or 0
84  * if value does not implement this interface.
85  **/
86 gint
87 atk_table_get_index_at (AtkTable *obj,
88                         gint     row,
89                         gint     column)
90 {
91   AtkTableIface *iface;
92
93   g_return_val_if_fail (obj != NULL, 0);
94   g_return_val_if_fail (ATK_IS_TABLE (obj), 0);
95
96   iface = ATK_TABLE_GET_IFACE (obj);
97
98   if (iface->get_index_at)
99     return (iface->get_index_at) (obj, row, column);
100   else
101     return 0;
102 }
103
104 /**
105  * atk_table_get_row_at_index:
106  * @table: a GObject instance that implements AtkTableInterface
107  * @index: a #gint representing an index in @table
108  *
109  * Returns a #gint representing the row at the specified @index, or 0
110  * if the value does not implement this interface
111  * Note: callers should not rely on %NULL or on a zero value for
112  * indication of whether AtkSelectionIface is implemented, they should
113  * use type checking/interface checking macros or the
114  * atk_get_accessible_table() convenience method.
115  *
116  * Returns: a gint representing the row at the specified  index, or 0
117  * if value does not implement this interface.
118  **/
119 gint
120 atk_table_get_row_at_index (AtkTable *obj,
121                             gint     index)
122 {
123   AtkTableIface *iface;
124
125   g_return_val_if_fail (obj != NULL, 0);
126   g_return_val_if_fail (ATK_IS_TABLE (obj), 0);
127
128   iface = ATK_TABLE_GET_IFACE (obj);
129
130   if (iface->get_row_at_index)
131     return (iface->get_row_at_index) (obj, index);
132   else
133     return 0;
134 }
135
136 /**
137  * atk_table_get_column_at_index:
138  * @table: a GObject instance that implements AtkTableInterface
139  * @index: a #gint representing an index in @table
140  *
141  * Returns a #gint representing the column at the specified @index, or 0
142  * if the value does not implement this interface
143  * Note: callers should not rely on %NULL or on a zero value for
144  * indication of whether AtkSelectionIface is implemented, they should
145  * use type checking/interface checking macros or the
146  * atk_get_accessible_table() convenience method.
147  *
148  * Returns: a gint representing the column at the specified  index, or 0
149  * if value does not implement this interface.
150  **/
151 gint
152 atk_table_get_column_at_index (AtkTable *obj,
153                                gint     index)
154 {
155   AtkTableIface *iface;
156
157   g_return_val_if_fail (obj != NULL, 0);
158   g_return_val_if_fail (ATK_IS_TABLE (obj), 0);
159
160   iface = ATK_TABLE_GET_IFACE (obj);
161
162   if (iface->get_column_at_index)
163     return (iface->get_column_at_index) (obj, index);
164   else
165     return 0;
166 }
167
168 /**
169  * atk_table_get_caption:
170  * @table: a GObject instance that implements AtkTableInterface
171  *
172  * Gets the caption for the @table.
173  * Note: callers should not rely on %NULL or on a zero value for
174  * indication of whether AtkSelectionIface is implemented, they should
175  * use type checking/interface checking macros or the
176  * atk_get_accessible_table() convenience method.
177  *
178  * Returns: a AtkObject* representing the table caption, or %NULL
179  * if value does not implement this interface.
180  **/
181 AtkObject*
182 atk_table_get_caption (AtkTable *obj)
183 {
184   AtkTableIface *iface;
185
186   g_return_val_if_fail (obj != NULL, NULL);
187   g_return_val_if_fail (ATK_IS_TABLE (obj), NULL);
188
189   iface = ATK_TABLE_GET_IFACE (obj);
190
191   if (iface->get_caption)
192     return (iface->get_caption) (obj);
193   else
194     return NULL;
195 }
196
197 /**
198  * atk_table_get_n_columns:
199  * @table: a GObject instance that implements AtkTableIface
200  *
201  * Gets the number of columns in the table.
202  * Note: callers should not rely on %NULL or on a zero value for
203  * indication of whether AtkSelectionIface is implemented, they should
204  * use type checking/interface checking macros or the
205  * atk_get_accessible_table() convenience method.
206  *
207  * Returns: a gint representing the number of columns, or 0
208  * if value does not implement this interface.
209  **/
210 gint
211 atk_table_get_n_columns (AtkTable *obj)
212 {
213   AtkTableIface *iface;
214
215   g_return_val_if_fail (obj != NULL, 0);
216   g_return_val_if_fail (ATK_IS_TABLE (obj), 0);
217
218   iface = ATK_TABLE_GET_IFACE (obj);
219
220   if (iface->get_n_columns)
221     return (iface->get_n_columns) (obj);
222   else
223     return 0;
224 }
225
226 /**
227  * atk_table_get_column_description:
228  * @table: a GObject instance that implements AtkTableIface
229  * @column: a #gint representing a column in @table
230  *
231  * Gets the description text of the specified @column in the table
232  * Note: callers should not rely on %NULL or on a zero value for
233  * indication of whether AtkSelectionIface is implemented, they should
234  * use type checking/interface checking macros or the
235  * atk_get_accessible_table() convenience method.
236  *
237  * Returns: a AtkObject* representing the table description, or NULL
238  * if value does not implement this interface.
239  **/
240 AtkObject*
241 atk_table_get_column_description (AtkTable *obj,
242                                   gint     column)
243 {
244   AtkTableIface *iface;
245
246   g_return_val_if_fail (obj != NULL, NULL);
247   g_return_val_if_fail (ATK_IS_TABLE (obj), NULL);
248
249   iface = ATK_TABLE_GET_IFACE (obj);
250
251   if (iface->get_column_description)
252     return (iface->get_column_description) (obj, column);
253   else
254     return NULL;
255 }
256
257 /**
258  * atk_table_get_column_extent_at:
259  * @table: a GObject instance that implements AtkTableIface
260  * @row: a #gint representing a row in @table
261  * @column: a #gint representing a column in @table
262  *
263  * Gets the number of columns occupied by the accessible object
264  * at the specified @row and @column in the @table.
265  * Note: callers should not rely on %NULL or on a zero value for
266  * indication of whether AtkSelectionIface is implemented, they should
267  * use type checking/interface checking macros or the
268  * atk_get_accessible_table() convenience method.
269  *
270  * Returns: a gint representing the column extent at specified position, or 0
271  * if value does not implement this interface.
272  **/
273 gint
274 atk_table_get_column_extent_at (AtkTable *obj,
275                                 gint     row,
276                                 gint     column)
277 {
278   AtkTableIface *iface;
279
280   g_return_val_if_fail (obj != NULL, 0);
281   g_return_val_if_fail (ATK_IS_TABLE (obj), 0);
282
283   iface = ATK_TABLE_GET_IFACE (obj);
284
285   if (iface->get_column_extent_at)
286     return (iface->get_column_extent_at) (obj, row, column);
287   else
288     return 0;
289 }
290
291 /**
292  * atk_table_get_column_header:
293  * @table: a GObject instance that implements AtkTableIface
294  *
295  * Gets the column headers of an accessible table.
296  * Note: callers should not rely on %NULL or on a zero value for
297  * indication of whether AtkSelectionIface is implemented, they should
298  * use type checking/interface checking macros or the
299  * atk_get_accessible_table() convenience method.
300  *
301  * Returns: a AtkObject* representing the column headers, or %NULL
302  * if value does not implement this interface.
303  **/
304 AtkTable*
305 atk_table_get_column_header (AtkTable *obj)
306 {
307   AtkTableIface *iface;
308
309   g_return_val_if_fail (obj != NULL, NULL);
310   g_return_val_if_fail (ATK_IS_TABLE (obj), NULL);
311
312   iface = ATK_TABLE_GET_IFACE (obj);
313
314   if (iface->get_column_header)
315     return (iface->get_column_header) (obj);
316   else
317     return NULL;
318 }
319
320 /**
321  * atk_table_get_n_rows:
322  * @table: a GObject instance that implements AtkTableIface
323  *
324  * Gets the number of rows in the table.
325  * Note: callers should not rely on %NULL or on a zero value for
326  * indication of whether AtkSelectionIface is implemented, they should
327  * use type checking/interface checking macros or the
328  * atk_get_accessible_table() convenience method.
329  *
330  * Returns: a gint representing the number of rows, or 0
331  * if value does not implement this interface.
332  **/
333 gint
334 atk_table_get_n_rows (AtkTable *obj)
335 {
336   AtkTableIface *iface;
337
338   g_return_val_if_fail (obj != NULL, 0);
339   g_return_val_if_fail (ATK_IS_TABLE (obj), 0);
340
341   iface = ATK_TABLE_GET_IFACE (obj);
342
343   if (iface->get_n_rows)
344     return (iface->get_n_rows) (obj);
345   else
346     return 0;
347 }
348
349 /**
350  * atk_table_get_row_description:
351  * @table: a GObject instance that implements AtkTableIface
352  * @r: a #gint representing a row in @table
353  *
354  * Gets the description text of the specified row in the table
355  * Note: callers should not rely on %NULL or on a zero value for
356  * indication of whether AtkSelectionIface is implemented, they should
357  * use type checking/interface checking macros or the
358  * atk_get_accessible_table() convenience method.
359  *
360  * Returns: a AtkObject* representing the table description, or %NULL
361  * if value does not implement this interface.
362  **/
363 AtkObject*
364 atk_table_get_row_description (AtkTable *obj,
365                                gint      row)
366 {
367   AtkTableIface *iface;
368
369   g_return_val_if_fail (obj != NULL, NULL);
370   g_return_val_if_fail (ATK_IS_TABLE (obj), NULL);
371
372   iface = ATK_TABLE_GET_IFACE (obj);
373
374   if (iface->get_row_description)
375     return (iface->get_row_description) (obj, row);
376   else
377     return NULL;
378 }
379
380 /**
381  * atk_table_get_row_extent_at:
382  * @table: a GObject instance that implements AtkTableIface
383  * @row: a #gint representing a row in @table
384  * @column: a #gint representing a column in @table
385  *
386  * Gets the number of rows occupied by the accessible object
387  * at a specified @row and @column in the @table.
388  * Note: callers should not rely on %NULL or on a zero value for
389  * indication of whether AtkSelectionIface is implemented, they should
390  * use type checking/interface checking macros or the
391  * atk_get_accessible_table() convenience method.
392  *
393  * Returns: a gint representing the row extent at specified position, or 0
394  * if value does not implement this interface.
395  **/
396 gint
397 atk_table_get_row_extent_at (AtkTable *obj,
398                              gint     row,
399                              gint     column)
400 {
401   AtkTableIface *iface;
402
403   g_return_val_if_fail (obj != NULL, 0);
404   g_return_val_if_fail (ATK_IS_TABLE (obj), 0);
405
406   iface = ATK_TABLE_GET_IFACE (obj);
407
408   if (iface->get_row_extent_at)
409     return (iface->get_row_extent_at) (obj, row, column);
410   else
411     return 0;
412 }
413
414 /**
415  * atk_table_get_row_header:
416  * @table: a GObject instance that implements AtkTableIface
417  *
418  * Gets the row headers of an accessible table.
419  * Note: callers should not rely on %NULL or on a zero value for
420  * indication of whether AtkSelectionIface is implemented, they should
421  * use type checking/interface checking macros or the
422  * atk_get_accessible_table() convenience method.
423  *
424  * Returns: a AtkTable* representing the row headers, or %NULL
425  * if value does not implement this interface.
426  **/
427 AtkTable*
428 atk_table_get_row_header (AtkTable *obj)
429 {
430   AtkTableIface *iface;
431
432   g_return_val_if_fail (obj != NULL, NULL);
433   g_return_val_if_fail (ATK_IS_TABLE (obj), NULL);
434
435   iface = ATK_TABLE_GET_IFACE (obj);
436
437   if (iface->get_row_header)
438     return (iface->get_row_header) (obj);
439   else
440     return NULL;
441 }
442
443 /**
444  * atk_table_get_summary:
445  * @table: a GObject instance that implements AtkTableIface
446  *
447  * Gets the summary description of the table.
448  * Note: callers should not rely on %NULL or on a zero value for
449  * indication of whether AtkSelectionIface is implemented, they should
450  * use type checking/interface checking macros or the
451  * atk_get_accessible_table() convenience method.
452  *
453  * Returns: a AtkObject* representing a sumary description of the table,
454  * or %NULL if value does not implement this interface.
455  **/
456 AtkObject*
457 atk_table_get_summary (AtkTable *obj)
458 {
459   AtkTableIface *iface;
460
461   g_return_val_if_fail (obj != NULL, NULL);
462   g_return_val_if_fail (ATK_IS_TABLE (obj), NULL);
463
464   iface = ATK_TABLE_GET_IFACE (obj);
465
466   if (iface->get_summary)
467     return (iface->get_summary) (obj);
468   else
469     return NULL;
470 }
471
472 /**
473  * atk_table_get_selected_rows:
474  * @table: a GObject instance that implements AtkTableIface
475  *
476  * Gets the selected rows of the table.
477  * Note: callers should not rely on %NULL or on a zero value for
478  * indication of whether AtkSelectionIface is implemented, they should
479  * use type checking/interface checking macros or the
480  * atk_get_accessible_table() convenience method.
481  *
482  * Returns: a gint* representing the selected rows,
483  * or %NULL if value does not implement this interface.
484  **/
485 gint*
486 atk_table_get_selected_rows (AtkTable *obj)
487 {
488   AtkTableIface *iface;
489
490   g_return_val_if_fail (obj != NULL, NULL);
491   g_return_val_if_fail (ATK_IS_TABLE (obj), NULL);
492
493   iface = ATK_TABLE_GET_IFACE (obj);
494
495   if (iface->get_selected_rows)
496     return (iface->get_selected_rows) (obj);
497   else
498     return NULL;
499 }
500
501 /**
502  * atk_table_get_selected_columns:
503  * @table: a GObject instance that implements AtkTableIface
504  *
505  * Gets the selected columns of the table.
506  * Note: callers should not rely on %NULL or on a zero value for
507  * indication of whether AtkSelectionIface is implemented, they should
508  * use type checking/interface checking macros or the
509  * atk_get_accessible_table() convenience method.
510  *
511  * Returns: a gint* representing the selected columns,
512  * or %NULL if value does not implement this interface.
513  *
514  **/
515 gint*
516 atk_table_get_selected_columns (AtkTable *obj)
517 {
518   AtkTableIface *iface;
519
520   g_return_val_if_fail (obj != NULL, NULL);
521   g_return_val_if_fail (ATK_IS_TABLE (obj), NULL);
522
523   iface = ATK_TABLE_GET_IFACE (obj);
524
525   if (iface->get_selected_columns)
526     return (iface->get_selected_columns) (obj);
527   else
528     return NULL;
529 }
530
531 /**
532  * atk_table_is_column_selected:
533  * @table: a GObject instance that implements AtkTableIface
534  * @column: a #gint representing a column in @table
535  *
536  * Gets a boolean value indicating whether the specified @column
537  * is selected
538  * Note: callers should not rely on %NULL or on a zero value for
539  * indication of whether AtkSelectionIface is implemented, they should
540  * use type checking/interface checking macros or the
541  * atk_get_accessible_table() convenience method.
542  *
543  * Returns: a gboolean representing if the column is selected, or 0
544  * if value does not implement this interface.
545  **/
546 gboolean
547 atk_table_is_column_selected (AtkTable *obj,
548                               gint     column)
549 {
550   AtkTableIface *iface;
551
552   g_return_val_if_fail (obj != NULL, FALSE);
553   g_return_val_if_fail (ATK_IS_TABLE (obj), FALSE);
554
555   iface = ATK_TABLE_GET_IFACE (obj);
556
557   if (iface->is_column_selected)
558     return (iface->is_column_selected) (obj, column);
559   else
560     return FALSE;
561 }
562
563 /**
564  * atk_table_is_row_selected:
565  * @table: a GObject instance that implements AtkTableIface
566  * @row: a #gint representing a row in @table
567  *
568  * Gets a boolean value indicating whether the specified @row
569  * is selected
570  * Note: callers should not rely on %NULL or on a zero value for
571  * indication of whether AtkSelectionIface is implemented, they should
572  * use type checking/interface checking macros or the
573  * atk_get_accessible_table() convenience method.
574  *
575  * Returns: a gboolean representing if the row is selected, or 0
576  * if value does not implement this interface.
577  **/
578 gboolean
579 atk_table_is_row_selected (AtkTable *obj,
580                            gint     row)
581 {
582   AtkTableIface *iface;
583
584   g_return_val_if_fail (obj != NULL, FALSE);
585   g_return_val_if_fail (ATK_IS_TABLE (obj), FALSE);
586
587   iface = ATK_TABLE_GET_IFACE (obj);
588
589   if (iface->is_row_selected)
590     return (iface->is_row_selected) (obj, row);
591   else
592     return FALSE;
593 }
594
595 /**
596  * atk_table_is_selected:
597  * @table: a GObject instance that implements AtkTableIface
598  * @row: a #gint representing a row in @table
599  * @column: a #gint representing a column in @table
600  *
601  * Gets a boolean value indicating whether the acessible object
602  * at the specified @row and @column is selected
603  * Note: callers should not rely on %NULL or on a zero value for
604  * indication of whether AtkSelectionIface is implemented, they should
605  * use type checking/interface checking macros or the
606  * atk_get_accessible_table() convenience method.
607  *
608  * Returns: a gboolean representing if the cell is selected, or 0
609  * if value does not implement this interface.
610  **/
611 gboolean
612 atk_table_is_selected (AtkTable *obj,
613                        gint     row,
614                        gint     column)
615 {
616   AtkTableIface *iface;
617
618   g_return_val_if_fail (obj != NULL, FALSE);
619   g_return_val_if_fail (ATK_IS_TABLE (obj), FALSE);
620
621   iface = ATK_TABLE_GET_IFACE (obj);
622
623   if (iface->is_selected)
624     return (iface->is_selected) (obj, row, column);
625   else
626     return FALSE;
627 }
628
629 /**
630  * atk_table_set_caption:
631  * @table: a GObject instance that implements AtkTableIface
632  * @accessible: an #AtkObject representing the caption to set for @table
633  *
634  * Sets the caption for the table.
635  **/
636 void
637 atk_table_set_caption (AtkTable       *obj,
638                        AtkObject      *accessible)
639 {
640   AtkTableIface *iface;
641
642   g_return_if_fail (obj != NULL);
643   g_return_if_fail (ATK_IS_TABLE (obj));
644
645   iface = ATK_TABLE_GET_IFACE (obj);
646
647   if (iface->set_caption)
648     (iface->set_caption) (obj, accessible);
649 }
650
651 /**
652  * atk_table_set_column_description:
653  * @table: a GObject instance that implements AtkTableIface
654  * @column: a #gint representing a column in @table
655  * @accessible: an #AtkObject representing the description text
656  * to set for the specified @column of the @table
657  *
658  * Sets the description text for the specified @column of the @table.
659  **/
660 void
661 atk_table_set_column_description (AtkTable       *obj,
662                                   gint           column,
663                                   AtkObject      *accessible)
664 {
665   AtkTableIface *iface;
666
667   g_return_if_fail (obj != NULL);
668   g_return_if_fail (ATK_IS_TABLE (obj));
669
670   iface = ATK_TABLE_GET_IFACE (obj);
671
672   if (iface->set_column_description)
673     (iface->set_column_description) (obj, column, accessible);
674 }
675
676 /**
677  * atk_table_set_column_header:
678  * @table: a GObject instance that implements AtkTableIface
679  * @column: a #gint representing a column in @table
680  * @header: an #AtkTable
681  *
682  * Sets the specified column header to @header
683  **/
684 void
685 atk_table_set_column_header (AtkTable *obj,
686                              gint     column,
687                              AtkTable *header)
688 {
689   AtkTableIface *iface;
690
691   g_return_if_fail (obj != NULL);
692   g_return_if_fail (ATK_IS_TABLE (obj));
693
694   iface = ATK_TABLE_GET_IFACE (obj);
695
696   if (iface->set_column_header)
697     (iface->set_column_header) (obj, column, header);
698 }
699
700 /**
701  * atk_table_set_row_description:
702  * @table: a GObject instance that implements AtkTableIface
703  * @row: a #gint representing a row in @table
704  * @accessible: an #AtkObject representing the description text
705  * to set for the specified @row of @table
706  *
707  * Sets the description text for the specified @row of @table.
708  **/
709 void
710 atk_table_set_row_description (AtkTable       *obj,
711                                gint           row,
712                                AtkObject      *accessible)
713 {
714   AtkTableIface *iface;
715
716   g_return_if_fail (obj != NULL);
717   g_return_if_fail (ATK_IS_TABLE (obj));
718
719   iface = ATK_TABLE_GET_IFACE (obj);
720
721   if (iface->set_row_description)
722     (iface->set_row_description) (obj, row, accessible);
723 }
724
725 /**
726  * atk_table_set_row_header:
727  * @table: a GObject instance that implements AtkTableIface
728  * @row: a #gint representing a row in @table
729  * @header: an #AtkTable 
730  *
731  * Sets the specified row header to @header
732  **/
733 void
734 atk_table_set_row_header (AtkTable *obj,
735                           gint     row,
736                           AtkTable *header)
737 {
738   AtkTableIface *iface;
739
740   g_return_if_fail (obj != NULL);
741   g_return_if_fail (ATK_IS_TABLE (obj));
742
743   iface = ATK_TABLE_GET_IFACE (obj);
744
745   if (iface->set_row_header)
746     (iface->set_row_header) (obj, row, header);
747 }
748
749 /**
750  * atk_table_set_summary:
751  * @table: a GObject instance that implements AtkTableIface
752  * @accessible: an #AtkObject representing the summary description
753  * to set for @table
754  *
755  * Sets the summary description of the table
756  **/
757 void
758 atk_table_set_summary (AtkTable       *obj,
759                        AtkObject      *accessible)
760 {
761   AtkTableIface *iface;
762
763   g_return_if_fail (obj != NULL);
764   g_return_if_fail (ATK_IS_TABLE (obj));
765
766   iface = ATK_TABLE_GET_IFACE (obj);
767
768   if (iface->set_summary)
769     (iface->set_summary) (obj, accessible);
770 }