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

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