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