source: trunk/third/at-spi/cspi/spi_table.c @ 18688

Revision 18688, 20.4 KB checked in by ghudson, 21 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r18687, which included commits to RCS files with non-trunk default branches.
Line 
1/*
2 * AT-SPI - Assistive Technology Service Provider Interface
3 * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
4 *
5 * Copyright 2001, 2002 Sun Microsystems Inc.,
6 * Copyright 2001, 2002 Ximian, Inc.
7 *
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
12 *
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16 * Library General Public License for more details.
17 *
18 * You should have received a copy of the GNU Library General Public
19 * License along with this library; if not, write to the
20 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21 * Boston, MA 02111-1307, USA.
22 */
23
24#include <stdlib.h> /* for malloc */
25#include <cspi/spi-private.h>
26
27/**
28 * AccessibleTable_ref:
29 * @obj: a pointer to the #AccessibleTable implementor on which to operate.
30 *
31 * Increment the reference count for an #AccessibleTable object.
32 **/
33void
34AccessibleTable_ref (AccessibleTable *obj)
35{
36  cspi_object_ref (obj);
37}
38
39/**
40 * AccessibleTable_unref:
41 * @obj: a pointer to the #AccessibleTable implementor on which to operate.
42 *
43 * Decrement the reference count for an #AccessibleTable object.
44 **/
45void
46AccessibleTable_unref (AccessibleTable *obj)
47{
48  cspi_object_unref (obj);
49}
50
51/**
52 * AccessibleTable_getCaption:
53 * @obj: a pointer to the #AccessibleTable implementor on which to operate.
54 *
55 * Get an accessible representation of the caption for an #AccessibleTable.
56 *
57 * Returns: an #Accessible object that serves as the table's caption.
58 **/
59Accessible *
60AccessibleTable_getCaption (AccessibleTable *obj)
61{
62  Accessible *retval;
63
64  cspi_return_val_if_fail (obj != NULL, NULL);
65
66  retval =  cspi_object_add (
67                             Accessibility_Table__get_caption (CSPI_OBJREF (obj), cspi_ev ()));
68  cspi_return_val_if_ev ("getCaption", NULL);
69  return retval;
70}
71
72/**
73 * AccessibleTable_getSummary:
74 * @obj: a pointer to the #AccessibleTable implementor on which to operate.
75 *
76 * Get an accessible object which summarizes the contents of an #AccessibleTable.
77 *
78 * Returns: an #Accessible object that serves as the table's summary (often a
79 *          reduced #AccessibleTable).
80 **/
81Accessible *
82AccessibleTable_getSummary (AccessibleTable *obj)
83{
84  Accessible *retval;
85
86  cspi_return_val_if_fail (obj != NULL, NULL);
87
88retval = cspi_object_add (
89                          Accessibility_Table__get_summary (CSPI_OBJREF (obj), cspi_ev ()));
90 cspi_return_val_if_ev ("getSummary", NULL);
91 return retval;
92}
93
94/**
95 * AccessibleTable_getNRows:
96 * @obj: a pointer to the #AccessibleTable implementor on which to operate.
97 *
98 * Get the number of rows in an #AccessibleTable,
99 *        exclusive of any rows that are programmatically hidden, but inclusive
100 *        of rows that may be outside of the current scrolling window or viewport.
101 *
102 * Returns: a #long integer indicating the number of rows in the table.
103 **/
104long
105AccessibleTable_getNRows (AccessibleTable *obj)
106{
107  long retval;
108
109  cspi_return_val_if_fail (obj != NULL, -1);
110
111  retval =
112    Accessibility_Table__get_nRows (CSPI_OBJREF (obj), cspi_ev ());
113         
114  cspi_return_val_if_ev ("getNRows", -1);
115
116  return retval;
117         
118}
119
120/**
121 * AccessibleTable_getNColumns:
122 * @obj: a pointer to the #AccessibleTable implementor on which to operate.
123 *
124 * Get the number of columns in an #AccessibleTable,
125 *        exclusive of any columns that are programmatically hidden, but inclusive
126 *        of columns that may be outside of the current scrolling window or viewport.
127 *
128 * Returns: a #long integer indicating the number of columns in the table.
129 **/
130long
131AccessibleTable_getNColumns (AccessibleTable *obj)
132{
133  long retval;
134
135  cspi_return_val_if_fail (obj != NULL, -1);
136
137  retval =
138    Accessibility_Table__get_nColumns (CSPI_OBJREF (obj), cspi_ev ());
139         
140  cspi_return_val_if_ev ("getNColumns", -1);
141
142  return retval;
143}
144
145/**
146 * AccessibleTable_getAccessibleAt:
147 * @obj: a pointer to the #AccessibleTable implementor on which to operate.
148 * @row: the specified table row, zero-indexed.
149 * @column: the specified table column, zero-indexed.
150 *
151 * Get the table cell at the specified row and column indices.
152 *          To get the accessible object at a particular (x, y) screen coordinate,
153 *          use #Accessible_getAccessibleAtPoint ().
154 *
155 * Returns: an #Accessible object representing the specified table cell.
156 **/
157Accessible *
158AccessibleTable_getAccessibleAt (AccessibleTable *obj,
159                                 long int row,
160                                 long int column)
161{
162  Accessible *retval;
163
164  cspi_return_val_if_fail (obj != NULL, NULL);
165
166  retval = cspi_object_add (
167                            Accessibility_Table_getAccessibleAt (
168                                                                 CSPI_OBJREF (obj), row,
169                                                                 column, cspi_ev ()));
170  cspi_return_val_if_ev ("getAccessibleAt", NULL);
171 return retval;
172}
173
174/**
175 * AccessibleTable_getIndexAt:
176 * @obj: a pointer to the #AccessibleTable implementor on which to operate.
177 * @row: the specified table row, zero-indexed.
178 * @column: the specified table column, zero-indexed.
179 *
180 * Get the 1-D child index corresponding to the specified 2-D row and column indices.
181 *          To get the accessible object at a particular (x, y) screen coordinate,
182 *          use #Accessible_getAccessibleAtPoint ().
183 * @see #AccessibleTable_getRowAtIndex(), #AccessibleTable_getColumnAtIndex()
184 *
185 * Returns: a long integer which serves as the index of a specified cell in the
186 *          table, in a form usable by #Accessible_getChildAtIndex().
187 **/
188long
189AccessibleTable_getIndexAt (AccessibleTable *obj,
190                            long int row,
191                            long int column)
192{
193  long retval;
194
195  cspi_return_val_if_fail (obj != NULL, -1);
196
197  retval =
198    Accessibility_Table_getIndexAt (
199      CSPI_OBJREF (obj), row,
200      column, cspi_ev ());
201         
202  cspi_return_val_if_ev ("getIndexAt", -1);
203
204  return retval;
205}
206
207/**
208 * AccessibleTable_getRowAtIndex:
209 * @obj: a pointer to the #AccessibleTable implementor on which to operate.
210 * @index: the specified child index, zero-indexed.
211 *
212 * Get the table row index occupied by the child at a particular 1-D child index.
213 *
214 * @see #AccessibleTable_getIndexAt(), #AccessibleTable_getColumnAtIndex()
215 *
216 * Returns: a long integer indicating the first row spanned by the child of a
217 *          table, at the specified 1-D (zero-offset) @index.
218 **/
219long
220AccessibleTable_getRowAtIndex (AccessibleTable *obj,
221                               long index)
222{
223  long retval;
224
225  cspi_return_val_if_fail (obj != NULL, -1);
226
227  retval =
228    Accessibility_Table_getRowAtIndex (CSPI_OBJREF (obj),
229                                       index, cspi_ev ());
230         
231  cspi_return_val_if_ev ("getRowAtIndex", -1);
232
233  return retval;
234}
235
236/**
237 * AccessibleTable_getColumnAtIndex:
238 * @obj: a pointer to the #AccessibleTable implementor on which to operate.
239 * @index: the specified child index, zero-indexed.
240 *
241 * Get the table column index occupied by the child at a particular 1-D child index.
242 *
243 * @see #AccessibleTable_getIndexAt(), #AccessibleTable_getRowAtIndex()
244 *
245 * Returns: a long integer indicating the first column spanned by the child of a
246 *          table, at the specified 1-D (zero-offset) @index.
247 **/
248long
249AccessibleTable_getColumnAtIndex (AccessibleTable *obj,
250                                  long index)
251{
252  long retval;
253
254  cspi_return_val_if_fail (obj != NULL, -1);
255
256  retval =
257    Accessibility_Table_getColumnAtIndex (CSPI_OBJREF (obj),
258                                          index, cspi_ev ());
259         
260  cspi_return_val_if_ev ("getColumnAtIndex", -1);
261
262  return retval;
263}
264
265/**
266 * AccessibleTable_getRowDescription:
267 * @obj: a pointer to the #AccessibleTable implementor on which to operate.
268 * @row: the specified table row, zero-indexed.
269 *
270 * Get a text description of a particular table row.  This differs from
271 * AccessibleTable_getRowHeader, which returns an #Accessible.
272 *
273 * Returns: a UTF-8 string describing the specified table row, if available.
274 **/
275char *
276AccessibleTable_getRowDescription (AccessibleTable *obj,
277                                   long int         row)
278{
279  char *retval;
280
281  cspi_return_val_if_fail (obj != NULL, NULL);
282
283  retval =
284    Accessibility_Table_getRowDescription (CSPI_OBJREF (obj),
285                                           row, cspi_ev ());
286         
287  cspi_return_val_if_ev ("getRowDescription", NULL);
288
289  return retval;
290}
291
292/**
293 * AccessibleTable_getColumnDescription:
294 * @obj: a pointer to the #AccessibleTable implementor on which to operate.
295 * @column: the specified table column, zero-indexed.
296 *
297 * Get a text description of a particular table column.  This differs from
298 * AccessibleTable_getColumnHeader, which returns an #Accessible.
299 *
300 * Returns: a UTF-8 string describing the specified table column, if available.
301 **/
302char *
303AccessibleTable_getColumnDescription (AccessibleTable *obj,
304                                      long int         column)
305{
306  char *retval;
307
308  cspi_return_val_if_fail (obj != NULL, NULL);
309
310  retval =
311    Accessibility_Table_getColumnDescription (CSPI_OBJREF (obj),
312                                              column, cspi_ev ());
313
314  cspi_return_val_if_ev ("getColumnDescription", NULL);
315
316  return retval;
317}
318
319/**
320 * AccessibleTable_getRowExtentAt:
321 * @obj: a pointer to the #AccessibleTable implementor on which to operate.
322 * @row: the specified table row, zero-indexed.
323 * @column: the specified table column, zero-indexed.
324 *
325 * Get the number of rows spanned by the table cell at the specific row and column.
326 * (some tables can have cells which span multiple rows and/or columns).
327 *
328 * Returns: a long integer indicating the number of rows spanned by the specified cell.
329 **/
330long
331AccessibleTable_getRowExtentAt (AccessibleTable *obj,
332                                long int         row,
333                                long int         column)
334{
335  long retval;
336
337  cspi_return_val_if_fail (obj != NULL, -1);
338
339  retval =
340    Accessibility_Table_getRowExtentAt (
341      CSPI_OBJREF (obj), row,
342      column, cspi_ev ());
343         
344  cspi_return_val_if_ev ("getRowExtentAt", -1);
345
346  return retval;
347}
348
349/**
350 * AccessibleTable_getColumnExtentAt:
351 * @obj: a pointer to the #AccessibleTable implementor on which to operate.
352 * @row: the specified table row, zero-indexed.
353 * @column: the specified table column, zero-indexed.
354 *
355 * Get the number of columns spanned by the table cell at the specific row and column.
356 * (some tables can have cells which span multiple rows and/or columns).
357 *
358 * Returns: a long integer indicating the number of columns spanned by the specified cell.
359 **/
360long
361AccessibleTable_getColumnExtentAt (AccessibleTable *obj,
362                                   long int         row,
363                                   long int         column)
364{
365  long retval;
366
367  cspi_return_val_if_fail (obj != NULL, -1);
368
369  retval =
370    Accessibility_Table_getColumnExtentAt (
371      CSPI_OBJREF (obj), row,
372      column, cspi_ev ());
373         
374  cspi_return_val_if_ev ("getColumnExtentAt", -1);
375
376  return retval;
377}
378
379/**
380 * AccessibleTable_getRowHeader:
381 * @obj: a pointer to the #AccessibleTable implementor on which to operate.
382 * @row: the specified table row, zero-indexed.
383 *
384 * Get the header associated with a table row, if available.  This differs from
385 * AccessibleTable_getRowDescription, which returns a string.
386 *
387 * Returns: a #Accessible representatin of the specified table row, if available.
388 **/
389Accessible *
390AccessibleTable_getRowHeader (AccessibleTable *obj,
391                              long int         row)
392{
393  Accessible *retval;
394
395  cspi_return_val_if_fail (obj != NULL, NULL);
396
397  retval = cspi_object_add (
398                            Accessibility_Table_getRowHeader (CSPI_OBJREF (obj),
399                                                              row, cspi_ev ()));
400  cspi_return_val_if_ev ("getRowHeader", NULL);
401
402 return retval;
403}
404
405/**
406 * AccessibleTable_getColumnHeader:
407 * @obj: a pointer to the #AccessibleTable implementor on which to operate.
408 * @column: the specified table column, zero-indexed.
409 *
410 * Get the header associated with a table column, if available.  This differs from
411 * AccessibleTable_getColumnDescription, which returns a string.
412 *
413 * Returns: a #Accessible representatin of the specified table column, if available.
414 **/
415Accessible *
416AccessibleTable_getColumnHeader (AccessibleTable *obj,
417                                 long int column)
418{
419  Accessible *retval;
420
421  cspi_return_val_if_fail (obj != NULL, NULL);
422
423  retval = cspi_object_add (
424                            Accessibility_Table_getColumnHeader (CSPI_OBJREF (obj),
425                                                                 column, cspi_ev ()));
426  cspi_return_val_if_ev ("getColumnHeader", NULL);
427
428  return retval;
429}
430
431/**
432 * AccessibleTable_getNSelectedRows:
433 * @obj: a pointer to the #AccessibleTable implementor on which to operate.
434 *
435 * Query a table to find out how many rows are currently selected.  Not all tables
436 *  support row selection.
437 *
438 * Returns: a long integer indicating the number of rows currently selected.
439 **/
440long
441AccessibleTable_getNSelectedRows (AccessibleTable *obj)
442{
443  long retval;
444
445  cspi_return_val_if_fail (obj != NULL, -1);
446
447  retval =
448    Accessibility_Table__get_nSelectedRows (CSPI_OBJREF (obj), cspi_ev ());
449         
450  cspi_return_val_if_ev ("getNSelectedRows", -1);
451
452  return retval;
453}
454
455static long
456cspi_long_seq_to_array (Accessibility_LongSeq *seq, long int **array)
457{
458  long *j;
459  long length, i;
460
461  if (!cspi_check_ev ("getSelectionItems"))
462    {
463      *array = NULL;
464      return 0;
465    }
466
467  length = seq->_length;
468
469  j = *array = malloc (sizeof (long) * length);
470
471  for (i = 0; i < length; i++)
472    {
473      j[i] = seq->_buffer [i];
474    }
475
476  CORBA_free (seq);
477
478  return length;
479}
480
481/**
482 * AccessibleTable_getSelectedRows:
483 * @obj: a pointer to the #AccessibleTable implementor on which to operate.
484 * @selectedRows: a doubly indirected pointer which will be set to the address
485 *       of an array of long integers, specifying which rows are currently selected.
486 *
487 * Query a table for a list of indices of rows which are currently selected.
488 *
489 * Returns: a long integer indicating the length of the array returned in @selectedRows.
490 **/
491long
492AccessibleTable_getSelectedRows (AccessibleTable *obj,
493                                 long int       **selectedRows)
494{
495  Accessibility_LongSeq *rows;
496
497  *selectedRows = NULL;
498
499  cspi_return_val_if_fail (obj != NULL, 0);
500
501  rows = Accessibility_Table_getSelectedRows (CSPI_OBJREF (obj), cspi_ev ());
502
503  cspi_return_val_if_ev ("getSelectedRows", -1);
504
505  return cspi_long_seq_to_array (rows, selectedRows);
506}
507
508/**
509 * AccessibleTable_getNSelectedColumns:
510 * @obj: a pointer to the #AccessibleTable implementor on which to operate.
511 *
512 * Query a table to find out how many columnss are currently selected.  Not all tables
513 *  support column selection.
514 *
515 * Returns: a long integer indicating the number of columns currently selected.
516 **/
517long
518AccessibleTable_getNSelectedColumns (AccessibleTable *obj)
519{
520  long retval;
521
522  cspi_return_val_if_fail (obj != NULL, -1);
523
524  retval =
525    Accessibility_Table__get_nSelectedColumns (CSPI_OBJREF (obj), cspi_ev ());
526         
527  cspi_return_val_if_ev ("getNSelectedColumns", -1);
528
529  return retval;
530}
531
532/**
533 * AccessibleTable_getSelectedColumns:
534 * @obj: a pointer to the #AccessibleTable implementor on which to operate.
535 * @selectedColumns: a doubly indirected pointer which will be set to the address
536 *       of an array of long integers, specifying which columns are currently selected.
537 *
538 * Query a table for a list of indices of columns which are currently selected.
539 *       Not all tables support column selection.
540 *
541 * Returns: a long integer indicating the length of the array returned in @selectedColumns.
542 **/
543long
544AccessibleTable_getSelectedColumns (AccessibleTable *obj,
545                                    long int       **selectedColumns)
546{
547  Accessibility_LongSeq *columns;
548
549  *selectedColumns = NULL;
550
551  cspi_return_val_if_fail (obj != NULL, 0);
552
553  columns = Accessibility_Table_getSelectedColumns (CSPI_OBJREF (obj), cspi_ev ());
554
555  cspi_return_val_if_ev ("getSelectedColumns", -1);
556  return cspi_long_seq_to_array (columns, selectedColumns);
557}
558
559/**
560 * AccessibleTable_isRowSelected:
561 * @obj: a pointer to the #AccessibleTable implementor on which to operate.
562 * @row:
563 *
564 * Determine whether a table row is selected.  Not all tables support row selection.
565 *
566 * Returns: #TRUE if the specified row is currently selected, #FALSE if not.
567 **/
568SPIBoolean
569AccessibleTable_isRowSelected (AccessibleTable *obj,
570                               long int         row)
571{
572  SPIBoolean retval;
573
574  cspi_return_val_if_fail (obj != NULL, FALSE);
575
576  retval =
577    Accessibility_Table_isRowSelected (CSPI_OBJREF (obj),
578                                       row, cspi_ev ());
579
580  cspi_return_val_if_ev ("isRowSelected", FALSE);
581
582  return retval;
583}
584
585/**
586 * AccessibleTable_isColumnSelected:
587 * @obj: a pointer to the #AccessibleTable implementor on which to operate.
588 * @column:
589 *
590 * Determine whether specified table column is selected.
591 * Not all tables support column selection.
592 *
593 * Returns: #TRUE if the specified column is currently selected, #FALSE if not.
594 **/
595SPIBoolean
596AccessibleTable_isColumnSelected (AccessibleTable *obj,
597                                  long int         column)
598{
599  SPIBoolean retval;
600
601  cspi_return_val_if_fail (obj != NULL, FALSE);
602
603  retval =
604    Accessibility_Table_isColumnSelected (CSPI_OBJREF (obj),
605                                          column, cspi_ev ());
606         
607  cspi_return_val_if_ev ("isColumnSelected", FALSE);
608
609  return retval;
610}
611
612/**
613 * AccessibleTable_addRowSelection:
614 * @obj: a pointer to the #AccessibleTable implementor on which to operate.
615 * @row:
616 *
617 * Select the specified row, adding it to the current row selection.
618 * Not all tables support row selection.
619 *
620 * Returns: #TRUE if the specified row was successfully selected, #FALSE if not.
621 **/
622SPIBoolean
623AccessibleTable_addRowSelection (AccessibleTable *obj,
624                                 long int         row)
625{
626  SPIBoolean retval;
627
628  cspi_return_val_if_fail (obj != NULL, FALSE);
629
630  retval =
631    Accessibility_Table_addRowSelection (CSPI_OBJREF (obj),
632                                         row, cspi_ev ());
633         
634  cspi_return_val_if_ev ("addRowSelection", FALSE);
635
636  return retval;
637}
638
639/**
640 * AccessibleTable_addColumnSelection:
641 * @obj: a pointer to the #AccessibleTable implementor on which to operate.
642 * @column:
643 *
644 * Select the specified column, adding it to the current column selection.
645 * Not all tables support column selection.
646 *
647 * Returns: #TRUE if the specified column was successfully selected, #FALSE if not.
648 **/
649SPIBoolean
650AccessibleTable_addColumnSelection (AccessibleTable *obj,
651                                    long int         column)
652{
653  SPIBoolean retval;
654
655  cspi_return_val_if_fail (obj != NULL, FALSE);
656
657  retval =
658    Accessibility_Table_addColumnSelection (CSPI_OBJREF (obj),
659                                            column, cspi_ev ());
660         
661  cspi_return_val_if_ev ("addColumnSelection", FALSE);
662
663  return retval;
664}
665
666/**
667 * AccessibleTable_removeRowSelection:
668 * @obj: a pointer to the #AccessibleTable implementor on which to operate.
669 * @row:
670 *
671 * De-select the specified row, removing it to the current row selection.
672 * Not all tables support row selection.
673 *
674 * Returns: #TRUE if the specified row was successfully de-selected, #FALSE if not.
675 **/
676SPIBoolean
677AccessibleTable_removeRowSelection (AccessibleTable *obj,
678                                    long int         row)
679{
680  SPIBoolean retval;
681
682  cspi_return_val_if_fail (obj != NULL, FALSE);
683
684  retval =
685    Accessibility_Table_removeRowSelection (CSPI_OBJREF (obj),
686                                            row, cspi_ev ());
687         
688  cspi_return_val_if_ev ("removeRowSelection", FALSE);
689
690  return retval;
691}
692
693/**
694 * AccessibleTable_removeColumnSelection:
695 * @obj: a pointer to the #AccessibleTable implementor on which to operate.
696 * @column:
697 *
698 * De-select the specified column, removing it to the current column selection.
699 * Not all tables support column selection.
700 *
701 * Returns: #TRUE if the specified column was successfully de-selected, #FALSE if not.
702 **/
703SPIBoolean
704AccessibleTable_removeColumnSelection (AccessibleTable *obj,
705                                       long int         column)
706{
707  SPIBoolean retval;
708
709  cspi_return_val_if_fail (obj != NULL, FALSE);
710
711  retval =
712    Accessibility_Table_removeColumnSelection (CSPI_OBJREF (obj),
713                                               column, cspi_ev ());
714         
715  cspi_return_val_if_ev ("removeColumnSelection", FALSE);
716
717  return retval;
718}
719
720/**
721 * AccessibleTable_isSelected:
722 * @obj: a pointer to the #AccessibleTable implementor on which to operate.
723 * @row:
724 * @column:
725 *
726 * Determine whether the cell at a specific row and column is selected.
727 *
728 * Returns: #TRUE if the specified cell is currently selected, #FALSE if not.
729 **/
730SPIBoolean
731AccessibleTable_isSelected (AccessibleTable *obj,
732                            long int row,
733                            long int column)
734{
735  SPIBoolean retval;
736
737  cspi_return_val_if_fail (obj != NULL, FALSE);
738
739  retval =
740    Accessibility_Table_isSelected (CSPI_OBJREF (obj),
741                                    row,
742                                    column, cspi_ev ());
743         
744  cspi_return_val_if_ev ("isSelected", FALSE);
745
746  return retval;
747}
748
Note: See TracBrowser for help on using the repository browser.