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