Added additional documentation and fixed a couple of latent bugs.
[platform/core/uifw/at-spi2-atk.git] / cspi / spi_accessible.c
1 #define MAX_ROLES 100
2
3 static char *role_names [MAX_ROLES] =
4 {
5   " ",
6   "accelerator label",
7   "alert",
8   "animation",
9   "arrow",
10   "calendar",
11   "canvas",
12   "check box",
13   "menu item",
14   "color chooser",
15   "column header",
16   "combo box",
17   "date editor",
18   "desktop icon",
19   "desktop frame",
20   "dial",
21   "dialog",
22   "directory pane",
23   "drawing area",
24   "file chooser",
25   "filler",
26   "font chooser",
27   "frame",
28   "glass pane",
29   "HTML container",
30   "icon",
31   "image",
32   "internal frame",
33   "label",
34   "layered pane",
35   "list",
36   "list item",
37   "menu",
38   "menubar",
39   "menu item",
40   "option pane",
41   "page tab",
42   "page tab list",
43   "panel",
44   "password text",
45   "popup menu",
46   "progress bar",
47   "pushbutton",
48   "radiobutton",
49   "radio menu item",
50   "root pane",
51   "row header",
52   "scrollbar",
53   "scrollpane",
54   "separator",
55   "slider",
56   "split pane",
57   "spin button",
58   "status bar",
59   "table",
60   "table cell",
61   "table column header",
62   "table row header",
63   "tearoff menu item",
64   "text",
65   "toggle button",
66   "toolbar",
67   "tooltip",
68   "tree",
69   " ",
70   "viewport",
71   "window",
72 };
73
74 /**
75  * AccessibleRole_getName:
76  * @role: an #AccessibleRole object to query.
77  *
78  * Get a localizeable string that indicates the name of an #AccessibleRole.
79  *
80  * Returns: a localizable string name for an #AccessibleRole enumerated type.
81  **/
82 char*
83 AccessibleRole_getName (AccessibleRole role)
84 {
85   if (role < MAX_ROLES) return role_names [(int) role];
86   else return "";
87 }
88
89
90
91 /**
92  * Accessible_ref:
93  * @obj: a pointer to the #Accessible object on which to operate.
94  *
95  * Increment the reference count for an #Accessible object.
96  *
97  * Returns: (no return code implemented yet).
98  *
99  **/
100 int
101 Accessible_ref (Accessible *obj)
102 {
103   Accessibility_Accessible_ref (*obj, &ev);
104   spi_check_ev (&ev, "ref");
105   return 0;
106 }
107
108
109 /**
110  * Accessible_unref:
111  * @obj: a pointer to the #Accessible object on which to operate.
112  *
113  * Decrement the reference count for an #Accessible object.
114  *
115  * Returns: (no return code implemented yet).
116  *
117  **/
118 int
119 Accessible_unref (Accessible *obj)
120 {
121   Accessibility_Accessible_unref (*obj, &ev);
122   spi_check_ev (&ev, "unref");
123   return 0;
124 }
125
126 /**
127  * Accessible_getName:
128  * @obj: a pointer to the #Accessible object on which to operate.
129  *
130  * Get the name of an #Accessible object.
131  *
132  * Returns: a UTF-8 string indicating the name of the #Accessible object.
133  *
134  **/
135 char *
136 Accessible_getName (Accessible *obj)
137 {
138   char *retval = 
139     (char *)
140     Accessibility_Accessible__get_name (*obj, &ev);
141   spi_check_ev (&ev, "getName"); 
142   return retval;
143 }
144
145 /**
146  * Accessible_getDescription:
147  * @obj: a pointer to the #Accessible object on which to operate.
148  *
149  * Get the description of an #Accessible object.
150  *
151  * Returns: a UTF-8 string describing the #Accessible object.
152  *
153  **/
154 char *
155 Accessible_getDescription (Accessible *obj)
156 {
157   char *retval = (char *)
158     Accessibility_Accessible__get_description (*obj, &ev);
159   spi_check_ev (&ev, "getDescription");
160   return retval;
161 }
162
163 /**
164  * Accessible_getParent:
165  * @obj: a pointer to the #Accessible object to query.
166  *
167  * Get an #Accessible object's parent container.
168  *
169  * Returns: a pointer tothe #Accessible object which contains the given
170  *          #Accessible instance, or NULL if the @obj has no parent container.
171  *
172  **/
173 Accessible *
174 Accessible_getParent (Accessible *obj)
175 {
176   Accessible *retval = 
177       Obj_Add (Accessibility_Accessible__get_parent (*obj, &ev));
178   spi_check_ev (&ev, "getParent");
179   return retval;
180 }
181
182 /**
183  * Accessible_getChildCount:
184  * @obj: a pointer to the #Accessible object on which to operate.
185  *
186  * Get the number of children contained by an #Accessible object.
187  *
188  * Returns: a #long indicating the number of #Accessible children
189  *          contained by an #Accessible object.
190  *
191  **/
192 long
193 Accessible_getChildCount (Accessible *obj)
194 {
195   long retval = (long) Accessibility_Accessible__get_childCount (*obj, &ev);
196   spi_check_ev (&ev, "getChildCount");
197   return retval;
198 }
199
200 /**
201  * Accessible_getChildAtIndex:
202  * @obj: a pointer to the #Accessible object on which to operate.
203  * @childIndex: a #long indicating which child is specified.
204  *
205  * Get the #Accessible child of an #Accessible object at a given index.
206  *
207  * Returns: a pointer to the #Accessible child object at index
208  *          @childIndex.
209  *
210  **/
211 Accessible *
212 Accessible_getChildAtIndex (Accessible *obj,
213                             long int childIndex)
214 {
215   Accessible *retval = Obj_Add (Accessibility_Accessible_getChildAtIndex (*obj, childIndex, &ev));
216   spi_check_ev (&ev, "getChildAtIndex");
217   return retval;
218 }
219
220 /**
221  * Accessible_getIndexInParent:
222  * @obj: a pointer to the #Accessible object on which to operate.
223  *
224  * Get the index of an #Accessible object in its containing #Accessible.
225  *
226  * Returns: a #long indicating the index of the #Accessible object
227  *          in its parent (i.e. containing) #Accessible instance,
228  *          or -1 if @obj has no containing parent.
229  *
230  **/
231 long
232 Accessible_getIndexInParent (Accessible *obj)
233 {
234   long retval = (long) Accessibility_Accessible_getIndexInParent (*obj, &ev);
235   spi_check_ev (&ev, "getIndexInParent");
236   return retval;
237 }
238
239 /**
240  * Accessible_getRelationSet:
241  * @obj: a pointer to the #Accessible object on which to operate.
242  *
243  * Not Yet Implemented.
244  *
245  * Returns: a pointer to an array of #AccessibleRelations.
246  *
247  **/
248 AccessibleRelation **
249 Accessible_getRelationSet (Accessible *obj)
250 {
251   return NULL;
252 }
253
254 /**
255  * Accessible_getRole:
256  * @obj: a pointer to the #Accessible object on which to operate.
257  *
258  * Get the UI role of an #Accessible object.
259  *
260  * Returns: a UTF-8 string indicating the UI role of the #Accessible object.
261  *
262  **/
263 char *
264 Accessible_getRole (Accessible *obj)
265 {
266   char *retval = AccessibleRole_getName (
267                   Accessibility_Accessible_getRole (*obj, &ev));
268   spi_check_ev (&ev, "getRole");
269   return retval;
270 }
271
272 /**
273  * Accessible_getStateSet:
274  * @obj: a pointer to the #Accessible object on which to operate.
275  *
276  * Not Yet Implemented.
277  *
278  * Returns: a pointer to an #AccessibleStateSet representing the object's current state.
279  **/
280 AccessibleStateSet *
281 Accessible_getStateSet (Accessible *obj)
282 {
283   return NULL;
284 }
285
286 /* Interface query methods */
287
288 /**
289  * Accessible_isAction:
290  * @obj: a pointer to the #Accessible instance to query.
291  *
292  * Query whether the specified #Accessible implements #AccessibleAction.
293  *
294  * Returns: #TRUE if @obj implements the #AccessibleAction interface,
295  *          #FALSE otherwise.
296  **/
297 boolean
298 Accessible_isAction (Accessible *obj)
299 {
300   Bonobo_Unknown iface =
301     Accessibility_Accessible_queryInterface (*obj,
302                                              "IDL:Accessibility/Action:1.0",
303                                              &ev);
304   spi_warn_ev (&ev, "isAction");
305
306   return (CORBA_Object_is_nil (iface, &ev)) ? FALSE : TRUE;
307 }
308
309 /**
310  * Accessible_isComponent:
311  * @obj: a pointer to the #Accessible instance to query.
312  *
313  * Query whether the specified #Accessible implements #AccessibleComponent.
314  *
315  * Returns: #TRUE if @obj implements the #AccessibleComponent interface,
316  *          #FALSE otherwise.
317  **/
318 boolean
319 Accessible_isComponent (Accessible *obj)
320 {
321   Bonobo_Unknown iface =
322     Accessibility_Accessible_queryInterface (*obj,
323                                              "IDL:Accessibility/Component:1.0",
324                                              &ev);
325   spi_warn_ev (&ev, "isComponent");
326
327   return (CORBA_Object_is_nil (iface, &ev)) ? FALSE : TRUE;
328 }
329
330 /**
331  * Accessible_isEditableText:
332  * @obj: a pointer to the #Accessible instance to query.
333  *
334  * Query whether the specified #Accessible implements #AccessibleEditableText.
335  *
336  * Returns: #TRUE if @obj implements the #AccessibleEditableText interface,
337  *          #FALSE otherwise.
338  **/
339 boolean
340 Accessible_isEditableText (Accessible *obj)
341 {
342   Bonobo_Unknown iface =
343     Accessibility_Accessible_queryInterface (*obj,
344                                              "IDL:Accessibility/EditableText:1.0",
345                                              &ev);
346   spi_check_ev (&ev, "isEditableText");
347
348   return (CORBA_Object_is_nil (iface, &ev)) ? FALSE : TRUE;
349 }
350
351 /**
352  * Accessible_isHypertext:
353  * @obj: a pointer to the #Accessible instance to query.
354  *
355  * Query whether the specified #Accessible implements #AccessibleHypertext.
356  *
357  * Returns: #TRUE if @obj implements the #AccessibleHypertext interface,
358  *          #FALSE otherwise.
359  **/
360 boolean
361 Accessible_isHypertext (Accessible *obj)
362 {
363   Bonobo_Unknown iface =
364     Accessibility_Accessible_queryInterface (*obj,
365                                              "IDL:Accessibility/Hypertext:1.0",
366                                              &ev);
367
368   spi_check_ev (&ev, "isHypertext");
369
370   return (CORBA_Object_is_nil (iface, &ev)) ? FALSE : TRUE;
371 }
372
373 /**
374  * Accessible_isImage:
375  * @obj: a pointer to the #Accessible instance to query.
376  *
377  * Query whether the specified #Accessible implements #AccessibleImage.
378  *
379  * Returns: #TRUE if @obj implements the #AccessibleImage interface,
380  *          #FALSE otherwise.
381 **/
382 boolean
383 Accessible_isImage (Accessible *obj)
384 {
385   Bonobo_Unknown iface =
386     Accessibility_Accessible_queryInterface (*obj,
387                                              "IDL:Accessibility/Image:1.0",
388                                              &ev);
389   spi_check_ev (&ev, "isImage");
390
391   return (CORBA_Object_is_nil (iface, &ev)) ? FALSE : TRUE;
392 }
393
394 /**
395  * Accessible_isSelection:
396  * @obj: a pointer to the #Accessible instance to query.
397  *
398  * Query whether the specified #Accessible implements #AccessibleSelection.
399  *
400  * Returns: #TRUE if @obj implements the #AccessibleSelection interface,
401  *          #FALSE otherwise.
402 **/
403 boolean
404 Accessible_isSelection (Accessible *obj)
405 {
406   Bonobo_Unknown iface =
407     Accessibility_Accessible_queryInterface (*obj,
408                                              "IDL:Accessibility/Selection:1.0",
409                                              &ev);
410   spi_warn_ev (&ev, "isSelection");
411
412   return (CORBA_Object_is_nil (iface, &ev)) ? FALSE : TRUE;
413
414 }
415
416 /**
417  * Accessible_isTable:
418  * @obj: a pointer to the #Accessible instance to query.
419  *
420  * Query whether the specified #Accessible implements #AccessibleTable.
421  *
422  * Returns: #TRUE if @obj implements the #AccessibleTable interface,
423  *          #FALSE otherwise.
424 **/
425 boolean
426 Accessible_isTable (Accessible *obj)
427 {
428   Bonobo_Unknown iface =
429     Accessibility_Accessible_queryInterface (*obj,
430                                              "IDL:Accessibility/Table:1.0",
431                                              &ev);
432   spi_check_ev (&ev, "isTable");
433
434   return (CORBA_Object_is_nil (iface, &ev)) ? FALSE : TRUE;
435
436 }
437
438 /**
439  * Accessible_isText:
440  * @obj: a pointer to the #Accessible instance to query.
441  *
442  * Query whether the specified #Accessible implements #AccessibleText.
443  *
444  * Returns: #TRUE if @obj implements the #AccessibleText interface,
445  *          #FALSE otherwise.
446 **/
447 boolean
448 Accessible_isText (Accessible *obj)
449 {
450   Bonobo_Unknown iface =
451     Accessibility_Accessible_queryInterface (*obj,
452                                              "IDL:Accessibility/Text:1.0",
453                                              &ev);
454   spi_warn_ev (&ev, "isText");
455
456   return (CORBA_Object_is_nil (iface, &ev)) ? FALSE : TRUE;
457 }
458
459 /**
460  * Accessible_isValue:
461  * @obj: a pointer to the #Accessible instance to query.
462  *
463  * Query whether the specified #Accessible implements #AccessibleValue.
464  *
465  * Returns: #TRUE if @obj implements the #AccessibleValue interface,
466  *          #FALSE otherwise.
467 **/
468 boolean
469 Accessible_isValue (Accessible *obj)
470 {
471   Bonobo_Unknown iface =
472     Accessibility_Accessible_queryInterface (*obj,
473                                              "IDL:Accessibility/Value:1.0",
474                                              &ev);
475   spi_check_ev (&ev, "isValue");
476
477   return (CORBA_Object_is_nil (iface, &ev)) ? FALSE : TRUE;
478 }
479
480 /**
481  * Accessible_getAction:
482  * @obj: a pointer to the #Accessible instance to query.
483  *
484  * Get the #AccessibleAction interface for an #Accessible.
485  *
486  * Returns: a pointer to an #AccessibleAction interface instance, or
487  *          NULL if @obj does not implement #AccessibleAction.
488  **/
489 AccessibleAction *
490 Accessible_getAction (Accessible *obj)
491 {
492   Bonobo_Unknown iface =
493     Accessibility_Accessible_queryInterface (*obj,
494                                              "IDL:Accessibility/Action:1.0",
495                                              &ev);
496   spi_check_ev (&ev, "getAction");
497
498   return (AccessibleAction *)
499           ((CORBA_Object_is_nil (iface, &ev)) ? 0 : Obj_Add (iface));
500 }
501
502 /**
503  * Accessible_getComponent:
504  * @obj: a pointer to the #Accessible instance to query.
505  *
506  * Get the #AccessibleComponent interface for an #Accessible.
507  *
508  * Returns: a pointer to an #AccessibleComponent interface instance, or
509  *          NULL if @obj does not implement #AccessibleComponent.
510  **/
511 AccessibleComponent *
512 Accessible_getComponent (Accessible *obj)
513 {
514   Bonobo_Unknown iface =
515     Accessibility_Accessible_queryInterface (*obj,
516                                              "IDL:Accessibility/Component:1.0",
517                                              &ev);
518   spi_check_ev (&ev, "getComponent");
519
520   return (AccessibleComponent *) ((CORBA_Object_is_nil (iface, &ev)) ? 0 : Obj_Add (iface));
521 }
522
523 /**
524  * Accessible_getEditableText:
525  * @obj: a pointer to the #Accessible instance to query.
526  *
527  * Get the #AccessibleEditableText interface for an #Accessible.
528  *
529  * Returns: a pointer to an #AccessibleEditableText interface instance, or
530  *          NULL if @obj does not implement #AccessibleEditableText.
531  **/
532 AccessibleEditableText *
533 Accessible_getEditableText (Accessible *obj)
534 {
535   Bonobo_Unknown iface =
536     Accessibility_Accessible_queryInterface (*obj,
537                                              "IDL:Accessibility/EditableText:1.0",
538                                              &ev);
539   spi_check_ev (&ev, "getEditableText");
540
541   return (AccessibleEditableText *)
542           ((CORBA_Object_is_nil (iface, &ev)) ? 0 : Obj_Add (iface));
543 }
544
545
546
547 /**
548  * Accessible_getHypertext:
549  * @obj: a pointer to the #Accessible instance to query.
550  *
551  * Get the #AccessibleHypertext interface for an #Accessible.
552  *
553  * Returns: a pointer to an #AccessibleHypertext interface instance, or
554  *          NULL if @obj does not implement #AccessibleHypertext.
555  **/
556 AccessibleHypertext *
557 Accessible_getHypertext (Accessible *obj)
558 {
559   Bonobo_Unknown iface =
560     Accessibility_Accessible_queryInterface (*obj,
561                                              "IDL:Accessibility/Hypertext:1.0",
562                                              &ev);
563   spi_check_ev (&ev, "getHypertext");
564
565   return (AccessibleHypertext *)
566           ((CORBA_Object_is_nil (iface, &ev)) ? 0 : Obj_Add (iface));
567 }
568
569
570
571 /**
572  * Accessible_getImage:
573  * @obj: a pointer to the #Accessible instance to query.
574  *
575  * Get the #AccessibleImage interface for an #Accessible.
576  *
577  * Returns: a pointer to an #AccessibleImage interface instance, or
578  *          NULL if @obj does not implement #AccessibleImage.
579  **/
580 AccessibleImage *
581 Accessible_getImage (Accessible *obj)
582 {
583   Bonobo_Unknown iface =
584     Accessibility_Accessible_queryInterface (*obj,
585                                              "IDL:Accessibility/Image:1.0",
586                                              &ev);
587   spi_check_ev (&ev, "getImage");
588
589   return (AccessibleImage *)
590           ((CORBA_Object_is_nil (iface, &ev)) ? 0 : Obj_Add (iface));
591 }
592
593
594
595 /**
596  * Accessible_getSelection:
597  * @obj: a pointer to the #Accessible instance to query.
598  *
599  * Get the #AccessibleSelection interface for an #Accessible.
600  *
601  * Returns: a pointer to an #AccessibleSelection interface instance, or
602  *          NULL if @obj does not implement #AccessibleSelection.
603  **/
604 AccessibleSelection *
605 Accessible_getSelection (Accessible *obj)
606 {
607   Bonobo_Unknown iface =
608     Accessibility_Accessible_queryInterface (*obj,
609                                              "IDL:Accessibility/Selection:1.0",
610                                              &ev);
611   spi_warn_ev (&ev, "getSelection");
612
613   return (AccessibleSelection *)
614           ((CORBA_Object_is_nil (iface, &ev)) ? 0 : Obj_Add (iface));
615 }
616
617
618
619 /**
620  * Accessible_getTable:
621  * @obj: a pointer to the #Accessible instance to query.
622  *
623  * Get the #AccessibleTable interface for an #Accessible.
624  *
625  * Returns: a pointer to an #AccessibleTable interface instance, or
626  *          NULL if @obj does not implement #AccessibleTable.
627  **/
628 AccessibleTable *
629 Accessible_getTable (Accessible *obj)
630 {
631   Bonobo_Unknown iface =
632     Accessibility_Accessible_queryInterface (*obj,
633                                              "IDL:Accessibility/Table:1.0",
634                                              &ev);
635   spi_check_ev (&ev, "getTable");
636
637   return (AccessibleTable *)
638           ((CORBA_Object_is_nil (iface, &ev)) ? 0 : Obj_Add (iface));
639 }
640
641 /**
642  * Accessible_getText:
643  * @obj: a pointer to the #Accessible instance to query.
644  *
645  * Get the #AccessibleText interface for an #Accessible.
646  *
647  * Returns: a pointer to an #AccessibleText interface instance, or
648  *          NULL if @obj does not implement #AccessibleText.
649  **/
650 AccessibleText *
651 Accessible_getText (Accessible *obj)
652 {
653   Bonobo_Unknown iface =
654     Accessibility_Accessible_queryInterface (*obj,
655                                              "IDL:Accessibility/Text:1.0",
656                                              &ev);
657
658   spi_check_ev (&ev, "getText"); 
659
660   return (AccessibleText *)
661           ((CORBA_Object_is_nil (iface, &ev)) ? 0 : Obj_Add (iface));
662 }
663
664
665
666 /**
667  * Accessible_getValue:
668  * @obj: a pointer to the #Accessible instance to query.
669  *
670  * Get the #AccessibleValue interface for an #Accessible.
671  *
672  * Returns: a pointer to an #AccessibleValue interface instance, or
673  *          NULL if @obj does not implement #AccessibleValue.
674  **/
675 AccessibleValue *
676 Accessible_getValue (Accessible *obj)
677 {
678   Bonobo_Unknown iface =
679     Accessibility_Accessible_queryInterface (*obj,
680                                              "IDL:Accessibility/Value:1.0",
681                                              &ev);
682   return (AccessibleValue *)
683           ((CORBA_Object_is_nil (iface, &ev)) ? 0 : Obj_Add (iface));
684 }
685
686
687
688 /**
689  * Accessible_queryInterface:
690  * @obj: a pointer to the #Accessible instance to query.
691  * @interface_name: a UTF-8 character string specifiying the requested interface.
692  *
693  * Query an #Accessible object to for a named interface.
694  *
695  * Returns: an instance of the named interface object, if it is implemented
696  *          by @obj, or NULL otherwise.
697  *
698  **/
699 GenericInterface *
700 Accessible_queryInterface (Accessible *obj, char *interface_name)
701 {
702   GenericInterface iface;
703   iface = Accessibility_Accessible_queryInterface (*obj,
704                                                     interface_name,
705                                                     &ev);
706   return (iface != NULL) ? Obj_Add (iface) : NULL;
707 }
708