2001-12-10 Michael Meeks <michael@ximian.com>
[platform/core/uifw/at-spi2-atk.git] / cspi / spi_table.c
1 #include <stdlib.h> /* for malloc */
2 #include <cspi/spi-private.h>
3
4 /**
5  * AccessibleTable_ref:
6  * @obj: a pointer to the #AccessibleTable implementor on which to operate.
7  *
8  * Increment the reference count for an #AccessibleTable object.
9  *
10  * Returns: (no return code implemented yet).
11  *
12  **/
13 void
14 AccessibleTable_ref (AccessibleTable *obj)
15 {
16   cspi_object_ref (obj);
17 }
18
19 /**
20  * AccessibleTable_unref:
21  * @obj: a pointer to the #AccessibleTable implementor on which to operate.
22  *
23  * Decrement the reference count for an #AccessibleTable object.
24  *
25  * Returns: (no return code implemented yet).
26  *
27  **/
28 void
29 AccessibleTable_unref (AccessibleTable *obj)
30 {
31   cspi_object_unref (obj);
32 }
33
34 /**
35  * AccessibleTable_getCaption:
36  * @obj: a pointer to the #AccessibleTable implementor on which to operate.
37  *
38  * Get an accessible representation of the caption for an #AccessibleTable.
39  *
40  * Returns: an #Accessible object that serves as the table's caption.
41  *
42  **/
43 Accessible *
44 AccessibleTable_getCaption (AccessibleTable *obj)
45 {
46   return (Accessible *)
47     Accessibility_Table__get_caption (CSPI_OBJREF (obj), cspi_ev ());
48 }
49
50 /**
51  * AccessibleTable_getSummary:
52  * @obj: a pointer to the #AccessibleTable implementor on which to operate.
53  *
54  * Get an accessible object which summarizes the contents of an #AccessibleTable.
55  *
56  * Returns: an #Accessible object that serves as the table's summary (often a
57  *          reduced #AccessibleTable).
58  *
59  **/
60 Accessible *
61 AccessibleTable_getSummary (AccessibleTable *obj)
62 {
63   return (Accessible *)
64     Accessibility_Table__get_summary (CSPI_OBJREF (obj), cspi_ev ());
65 }
66
67 /**
68  * AccessibleTable_getNRows:
69  * @obj: a pointer to the #AccessibleTable implementor on which to operate.
70  *
71  * Get the number of rows in an #AccessibleTable,
72  *        exclusive of any rows that are programmatically hidden, but inclusive
73  *        of rows that may be outside of the current scrolling window or viewport.
74  *
75  * Returns: a #long integer indicating the number of rows in the table.
76  *
77  **/
78 long
79 AccessibleTable_getNRows (AccessibleTable *obj)
80 {
81   return (long)
82     Accessibility_Table__get_nRows (CSPI_OBJREF (obj), cspi_ev ());
83 }
84
85 /**
86  * AccessibleTable_getNColumns:
87  * @obj: a pointer to the #AccessibleTable implementor on which to operate.
88  *
89  * Get the number of columns in an #AccessibleTable,
90  *        exclusive of any columns that are programmatically hidden, but inclusive
91  *        of columns that may be outside of the current scrolling window or viewport.
92  *
93  * Returns: a #long integer indicating the number of columns in the table.
94  *
95  **/
96 long
97 AccessibleTable_getNColumns (AccessibleTable *obj)
98 {
99   return (long)
100     Accessibility_Table__get_nColumns (CSPI_OBJREF (obj), cspi_ev ());
101 }
102
103 /**
104  * AccessibleTable_getAccessibleAt:
105  * @obj: a pointer to the #AccessibleTable implementor on which to operate.
106  * @row: the specified table row, zero-indexed.
107  * @column: the specified table column, zero-indexed.
108  *
109  * Get the table cell at the specified row and column indices.
110  *          To get the accessible object at a particular (x, y) screen coordinate,
111  *          use #Accessible_getAccessibleAtPoint ().
112  *
113  * Returns: an #Accessible object representing the specified table cell.
114  *
115  **/
116 Accessible *
117 AccessibleTable_getAccessibleAt (AccessibleTable *obj,
118                                  long int row,
119                                  long int column)
120 {
121   return (Accessible *)
122     Accessibility_Table_getAccessibleAt (CSPI_OBJREF (obj),
123                                (CORBA_long) row, (CORBA_long) column, cspi_ev ());
124 }
125
126 /**
127  * AccessibleTable_getIndexAt:
128  * @obj: a pointer to the #AccessibleTable implementor on which to operate.
129  * @row: the specified table row, zero-indexed.
130  * @column: the specified table column, zero-indexed.
131  *
132  * Get the 1-D child index corresponding to the specified 2-D row and column indices.
133  *          To get the accessible object at a particular (x, y) screen coordinate,
134  *          use #Accessible_getAccessibleAtPoint ().
135  * @see #AccessibleTable_getRowAtIndex(), #AccessibleTable_getColumnAtIndex()
136  *
137  * Returns: a long integer which serves as the index of a specified cell in the
138  *          table, in a form usable by #Accessible_getChildAtIndex().
139  *
140  **/
141 long
142 AccessibleTable_getIndexAt (AccessibleTable *obj,
143                             long int row,
144                             long int column)
145 {
146   return (long)
147     Accessibility_Table_getIndexAt (CSPI_OBJREF (obj),
148                                     (CORBA_long) row, (CORBA_long) column, cspi_ev ());
149 }
150
151
152
153 /**
154  * AccessibleTable_getRowAtIndex:
155  * @obj: a pointer to the #AccessibleTable implementor on which to operate.
156  * @index: the specified child index, zero-indexed.
157  *
158  * Get the table row index occupied by the child at a particular 1-D child index.
159  *
160  * @see #AccessibleTable_getIndexAt(), #AccessibleTable_getColumnAtIndex()
161  *
162  * Returns: a long integer indicating the first row spanned by the child of a
163  *          table, at the specified 1-D (zero-offset) @index.
164  *
165  **/
166 long
167 AccessibleTable_getRowAtIndex (AccessibleTable *obj,
168                                long index)
169 {
170   return (long)
171     Accessibility_Table_getRowAtIndex (CSPI_OBJREF (obj),
172                                        (CORBA_long) index, cspi_ev ());
173 }
174
175
176
177 /**
178  * AccessibleTable_getColumnAtIndex:
179  * @obj: a pointer to the #AccessibleTable implementor on which to operate.
180  * @index: the specified child index, zero-indexed.
181  *
182  * Get the table column index occupied by the child at a particular 1-D child index.
183  *
184  * @see #AccessibleTable_getIndexAt(), #AccessibleTable_getRowAtIndex()
185  *
186  * Returns: a long integer indicating the first column spanned by the child of a
187  *          table, at the specified 1-D (zero-offset) @index.
188  *
189  **/
190 long
191 AccessibleTable_getColumnAtIndex (AccessibleTable *obj,
192                                   long index)
193 {
194   return (long)
195     Accessibility_Table_getColumnAtIndex (CSPI_OBJREF (obj),
196                                           (CORBA_long) index, cspi_ev ());
197 }
198
199
200
201 /**
202  * AccessibleTable_getRowDescription:
203  * @obj: a pointer to the #AccessibleTable implementor on which to operate.
204  * @row: the specified table row, zero-indexed.
205  *
206  * Get a text description of a particular table row.  This differs from
207  * AccessibleTable_getRowHeader, which returns an #Accessible.
208  *
209  * Returns: a UTF-8 string describing the specified table row, if available.
210  *
211  **/
212 char *
213 AccessibleTable_getRowDescription (AccessibleTable *obj,
214                                    long int row)
215 {
216   return (char *)
217     Accessibility_Table_getRowDescription (CSPI_OBJREF (obj),
218                                            (CORBA_long) row, cspi_ev ());
219 }
220
221
222
223 /**
224  * AccessibleTable_getColumnDescription:
225  * @obj: a pointer to the #AccessibleTable implementor on which to operate.
226  * @column: the specified table column, zero-indexed.
227  *
228  * Get a text description of a particular table column.  This differs from
229  * AccessibleTable_getColumnHeader, which returns an #Accessible.
230  *
231  * Returns: a UTF-8 string describing the specified table column, if available.
232  *
233  **/
234 char *
235 AccessibleTable_getColumnDescription (AccessibleTable *obj,
236                                       long int column)
237 {
238   return (char *)
239     Accessibility_Table_getColumnDescription (CSPI_OBJREF (obj),
240                                               (CORBA_long) column, cspi_ev ());
241 }
242
243
244
245 /**
246  * AccessibleTable_getRowExtentAt:
247  * @obj: a pointer to the #AccessibleTable implementor on which to operate.
248  * @row: the specified table row, zero-indexed.
249  * @column: the specified table column, zero-indexed.
250  *
251  * Get the number of rows spanned by the table cell at the specific row and column.
252  * (some tables can have cells which span multiple rows and/or columns).
253  *
254  * Returns: a long integer indicating the number of rows spanned by the specified cell.
255  *
256  **/
257 long
258 AccessibleTable_getRowExtentAt (AccessibleTable *obj,
259                                 long int row,
260                                 long int column)
261 {
262   return (long)
263     Accessibility_Table_getRowExtentAt (CSPI_OBJREF (obj),
264                                         (CORBA_long) row, (CORBA_long) column, cspi_ev ());
265 }
266
267
268
269 /**
270  * AccessibleTable_getColumnExtentAt:
271  * @obj: a pointer to the #AccessibleTable implementor on which to operate.
272  * @row: the specified table row, zero-indexed.
273  * @column: the specified table column, zero-indexed.
274  *
275  * Get the number of columns spanned by the table cell at the specific row and column.
276  * (some tables can have cells which span multiple rows and/or columns).
277  *
278  * Returns: a long integer indicating the number of columns spanned by the specified cell.
279  *
280  **/
281 long
282 AccessibleTable_getColumnExtentAt (AccessibleTable *obj,
283                                    long int row,
284                                    long int column)
285 {
286   return (long)
287     Accessibility_Table_getColumnExtentAt (CSPI_OBJREF (obj),
288                                         (CORBA_long) row, (CORBA_long) column, cspi_ev ());
289 }
290
291
292 /**
293  * AccessibleTable_getRowHeader:
294  * @obj: a pointer to the #AccessibleTable implementor on which to operate.
295  * @row: the specified table row, zero-indexed.
296  *
297  * Get the header associated with a table row, if available.  This differs from
298  * AccessibleTable_getRowDescription, which returns a string.
299  *
300  * Returns: a #Accessible representatin of the specified table row, if available.
301  *
302  **/
303 Accessible *
304 AccessibleTable_getRowHeader (AccessibleTable *obj,
305                               long int row)
306 {
307   return (Accessible *)
308     Accessibility_Table_getRowHeader (CSPI_OBJREF (obj),
309                                       (CORBA_long) row, cspi_ev ());
310 }
311
312
313
314 /**
315  * AccessibleTable_getColumnHeader:
316  * @obj: a pointer to the #AccessibleTable implementor on which to operate.
317  * @column: the specified table column, zero-indexed.
318  *
319  * Get the header associated with a table column, if available.  This differs from
320  * AccessibleTable_getColumnDescription, which returns a string.
321  *
322  * Returns: a #Accessible representatin of the specified table column, if available.
323  *
324  **/
325 Accessible *
326 AccessibleTable_getColumnHeader (AccessibleTable *obj,
327                                  long int column)
328 {
329   return (Accessible *)
330     Accessibility_Table_getColumnHeader (CSPI_OBJREF (obj),
331                                       (CORBA_long) column, cspi_ev ());
332 }
333
334
335 /**
336  * AccessibleTable_getNSelectedRows:
337  * @obj: a pointer to the #AccessibleTable implementor on which to operate.
338  *
339  * Query a table to find out how many rows are currently selected.  Not all tables
340  *  support row selection.
341  *
342  * Returns: a long integer indicating the number of rows currently selected.
343  **/
344 long
345 AccessibleTable_getNSelectedRows (AccessibleTable *obj)
346 {
347   return (long)
348     Accessibility_Table__get_nSelectedRows (CSPI_OBJREF (obj), cspi_ev ());
349 }
350
351
352
353 /**
354  * AccessibleTable_getSelectedRows:
355  * @obj: a pointer to the #AccessibleTable implementor on which to operate.
356  * @selectedRows: a doubly indirected pointer which will be set to the address
357  *       of an array of long integers, specifying which rows are currently selected.
358  *
359  * Query a table for a list of indices of rows which are currently selected.
360  *
361  * Returns: a long integer indicating the length of the array returned in @selectedRows.
362  **/
363 long
364 AccessibleTable_getSelectedRows (AccessibleTable *obj,
365                                  long int **selectedRows)
366 {
367   Accessibility_LongSeq *rows = Accessibility_Table_getSelectedRows (CSPI_OBJREF (obj), cspi_ev ());
368   CORBA_long *i;
369   long *j;
370   long length;
371
372   i = rows->_buffer;
373   length = (long) rows->_length;
374   j = *selectedRows = (long *) malloc (sizeof(long)*length);
375   
376   while (length--)
377     *j++ = (CORBA_long) (*i++);
378
379   length = rows->_length;
380   CORBA_free (rows);
381   return length;
382 }
383
384
385
386 /**
387  * AccessibleTable_getNSelectedColumns:
388  * @obj: a pointer to the #AccessibleTable implementor on which to operate.
389  *
390  * Query a table to find out how many columnss are currently selected.  Not all tables
391  *  support column selection.
392  *
393  * Returns: a long integer indicating the number of columns currently selected.
394  **/
395 long
396 AccessibleTable_getNSelectedColumns (AccessibleTable *obj)
397 {
398   return (long)
399     Accessibility_Table__get_nSelectedColumns (CSPI_OBJREF (obj), cspi_ev ());
400 }
401
402
403 /**
404  * AccessibleTable_getSelectedColumns:
405  * @obj: a pointer to the #AccessibleTable implementor on which to operate.
406  * @selectedColumns: a doubly indirected pointer which will be set to the address
407  *       of an array of long integers, specifying which columns are currently selected.
408  *
409  * Query a table for a list of indices of columns which are currently selected.
410  *       Not all tables support column selection.
411  *
412  * Returns: a long integer indicating the length of the array returned in @selectedColumns.
413  **/
414 long
415 AccessibleTable_getSelectedColumns (AccessibleTable *obj,
416                                     long int **selectedColumns)
417 {
418   Accessibility_LongSeq *columns = Accessibility_Table_getSelectedColumns (CSPI_OBJREF (obj), cspi_ev ());
419   CORBA_long *i;
420   long *j;
421   long length;
422
423   i = columns->_buffer;
424   length = (long) columns->_length;
425   j = *selectedColumns = (long *) malloc (sizeof(long)*length);
426   
427   while (length--)
428     *j++ = (CORBA_long) (*i++);
429
430   length = columns->_length;
431   CORBA_free (columns);
432   return length;
433 }
434
435
436 /**
437  * AccessibleTable_isRowSelected:
438  * @obj: a pointer to the #AccessibleTable implementor on which to operate.
439  * @row:
440  *
441  * Determine whether a table row is selected.  Not all tables support row selection.
442  *
443  * Returns: #TRUE if the specified row is currently selected, #FALSE if not.
444  *
445  **/
446 SPIBoolean
447 AccessibleTable_isRowSelected (AccessibleTable *obj,
448                                long int row)
449 {
450   return (SPIBoolean)
451     Accessibility_Table_isRowSelected (CSPI_OBJREF (obj),
452                                        (CORBA_long) row, cspi_ev ());
453 }
454
455
456
457 /**
458  * AccessibleTable_isColumnSelected:
459  * @obj: a pointer to the #AccessibleTable implementor on which to operate.
460  * @column:
461  *
462  * Determine whether specified table column is selected.
463  * Not all tables support column selection.
464  *
465  * Returns: #TRUE if the specified column is currently selected, #FALSE if not.
466  *
467  **/
468 SPIBoolean
469 AccessibleTable_isColumnSelected (AccessibleTable *obj,
470                                   long int column)
471 {
472   return (SPIBoolean)
473     Accessibility_Table_isColumnSelected (CSPI_OBJREF (obj),
474                                        (CORBA_long) column, cspi_ev ());
475 }
476
477
478
479 /**
480  * AccessibleTable_isSelected:
481  * @obj: a pointer to the #AccessibleTable implementor on which to operate.
482  * @row:
483  * @column:
484  *
485  * Determine whether the cell at a specific row and column is selected.
486  *
487  * Returns: #TRUE if the specified cell is currently selected, #FALSE if not.
488  *
489  **/
490 SPIBoolean
491 AccessibleTable_isSelected (AccessibleTable *obj,
492                             long int row,
493                             long int column)
494 {
495   return (SPIBoolean)
496   Accessibility_Table_isSelected (CSPI_OBJREF (obj),
497                                   (CORBA_long) row, (CORBA_long) column, cspi_ev ());
498 }
499