c6983603eb8f5adf59c6275e95d7ec32ea52e396
[platform/upstream/atk.git] / atk / atkobject.h
1 /* ATK -  Accessibility Toolkit
2  * Copyright 2001 Sun Microsystems Inc.
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Library General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */
19
20 #ifndef __ATK_OBJECT_H__
21 #define __ATK_OBJECT_H__
22
23 #ifdef __cplusplus
24 extern "C" {
25 #endif /* __cplusplus */
26
27 #include <glib-object.h>
28 #include <atk/atkstate.h>
29
30 /*
31  * AtkObject represents the minimum information all accessible objects
32  * return. This information includes accessible name, accessible
33  * description, role and state of the object, as well information about
34  * its parent and children. It is also possible to obtain more specific
35  * accessibility information about a component if it supports one or more
36  * of the following interfaces:
37  */
38
39
40 /**
41  *AtkRole:
42  *@ATK_ROLE_INVALID: Invalid role
43  *@ATK_ROLE_ACCEL_LABEL: A label which represents an accelerator
44  *@ATK_ROLE_ALERT: An object which is an alert to the user
45  *@ATK_ROLE_ANIMATION: An object which is an animated image
46  *@ATK_ROLE_ARROW: An arrow in one of the four cardinal directions
47  *@ATK_ROLE_CALENDAR:  An object that displays a calendar and allows the user to select a date
48  *@ATK_ROLE_CANVAS: An object that can be drawn into and is used to trap events
49  *@ATK_ROLE_CHECK_BOX: A choice that can be checked or unchecked and provides a separate indicator for the current state
50  *@ATK_ROLE_CHECK_MENU_ITEM: A menu item with a check box
51  *@ATK_ROLE_COLOR_CHOOSER: A specialized dialog that lets the user choose a color
52  *@ATK_ROLE_COLUMN_HEADER: The header for a column of data
53  *@ATK_ROLE_COMBO_BOX: A list of choices the user can select from
54  *@ATK_ROLE_DATE_EDITOR: An object whose purpose is to allow a user to edit a date
55  *@ATK_ROLE_DESKTOP_ICON: An inconifed internal frame within a DESKTOP_PANE
56  *@ATK_ROLE_DESKTOP_FRAME: A pane that supports internal frames and iconified versions of those internal frames
57  *@ATK_ROLE_DIAL: An object whose purpose is to allow a user to set a value
58  *@ATK_ROLE_DIALOG: A top level window with title bar and a border
59  *@ATK_ROLE_DIRECTORY_PANE: A pane that allows the user to navigate through and select the contents of a directory
60  *@ATK_ROLE_DRAWING_AREA: An object used for drawing custom user interface elements
61  *@ATK_ROLE_FILE_CHOOSER: A specialized dialog that lets the user choose a file
62  *@ATK_ROLE_FILLER: A object that fills up space in a user interface
63  *@ATK_ROLE_FONT_CHOOSER: A specialized dialog that lets the user choose a font
64  *@ATK_ROLE_FRAME: A top level window with a title bar, border, menubar, etc.
65  *@ATK_ROLE_GLASS_PANE: A pane that is guaranteed to be painted on top of all panes beneath it
66  *@ATK_ROLE_HTML_CONTAINER: A document container for HTML, whose children represent the document content
67  *@ATK_ROLE_ICON: A small fixed size picture, typically used to decorate components
68  *@ATK_ROLE_IMAGE: An object whose primary purpose is to display an image
69  *@ATK_ROLE_INTERNAL_FRAME: A frame-like object that is clipped by a desktop pane
70  *@ATK_ROLE_LABEL: An object used to present an icon or short string in an interface
71  *@ATK_ROLE_LAYERED_PANE: A specialized pane that allows its children to be drawn in layers, providing a form of stacking order
72  *@ATK_ROLE_LIST: An object that presents a list of objects to the user and allows the user to select one or more of them 
73  *@ATK_ROLE_LIST_ITEM: An object that represents an element of a list 
74  *@ATK_ROLE_MENU: An object usually found inside a menu bar that contains a list of actions the user can choose from
75  *@ATK_ROLE_MENU_BAR: An object usually drawn at the top of the primary dialog box of an application that contains a list of menus the user can choose from 
76  *@ATK_ROLE_MENU_ITEM: An object usually contained in a menu that presents an action the user can choose
77  *@ATK_ROLE_OPTION_PANE: A specialized pane whose primary use is inside a DIALOG
78  *@ATK_ROLE_PAGE_TAB: An object that is a child of a page tab list
79  *@ATK_ROLE_PAGE_TAB_LIST: An object that presents a series of panels (or page tabs), one at a time, through some mechanism provided by the object 
80  *@ATK_ROLE_PANEL: A generic container that is often used to group objects
81  *@ATK_ROLE_PASSWORD_TEXT: A text object uses for passwords, or other places where the text content is not shown visibly to the user
82  *@ATK_ROLE_POPUP_MENU: A temporary window that is usually used to offer the user a list of choices, and then hides when the user selects one of those choices
83  *@ATK_ROLE_PROGRESS_BAR: An object used to indicate how much of a task has been completed
84  *@ATK_ROLE_PUSH_BUTTON: An object the user can manipulate to tell the application to do something
85  *@ATK_ROLE_RADIO_BUTTON: A specialized check box that will cause other radio buttons in the same group to become unchecked when this one is checked
86  *@ATK_ROLE_RADIO_MENU_ITEM: A check menu item which belongs to a group. At each instant exactly one of the radio menu items from a group is selected
87  *@ATK_ROLE_ROOT_PANE: A specialized pane that has a glass pane and a layered pane as its children
88  *@ATK_ROLE_ROW_HEADER: The header for a row of data
89  *@ATK_ROLE_SCROLL_BAR: An object usually used to allow a user to incrementally view a large amount of data.
90  *@ATK_ROLE_SCROLL_PANE: An object that allows a user to incrementally view a large amount of information
91  *@ATK_ROLE_SEPARATOR: An object usually contained in a menu to provide a visible and logical separation of the contents in a menu
92  *@ATK_ROLE_SLIDER: An object that allows the user to select from a bounded range
93  *@ATK_ROLE_SPLIT_PANE: A specialized panel that presents two other panels at the same time
94  *@ATK_ROLE_SPIN_BUTTON: An object used to get an integer or floating point number from the user
95  *@ATK_ROLE_STATUSBAR: An object which reports messages of minor importance to the user
96  *@ATK_ROLE_TABLE: An object used to represent information in terms of rows and columns
97  *@ATK_ROLE_TABLE_CELL: A cell in a table
98  *@ATK_ROLE_TABLE_COLUMN_HEADER: The header for a column of a table
99  *@ATK_ROLE_TABLE_ROW_HEADER: The header for a row of a table
100  *@ATK_ROLE_TEAR_OFF_MENU_ITEM: A menu item used to tear off and reattach its menu
101  *@ATK_ROLE_TERMINAL: An object that represents an accessible terminal
102  *@ATK_ROLE_TEXT: An object that presents text to the user
103  *@ATK_ROLE_TOGGLE_BUTTON: A specialized push button that can be checked or unchecked, but does not provide a separate indicator for the current state
104  *@ATK_ROLE_TOOL_BAR: A bar or palette usually composed of push buttons or toggle buttons
105  *@ATK_ROLE_TOOL_TIP: An object that provides information about another object
106  *@ATK_ROLE_TREE: An object used to represent hierarchical information to the user
107  *@ATK_ROLE_UNKNOWN: The object contains some Accessible information, but its role is not known
108  *@ATK_ROLE_VIEWPORT: An object usually used in a scroll pane
109  *@ATK_ROLE_WINDOW: A top level window with no title or border
110  *@ATK_ROLE_LAST_DEFINED: not a valid role, used for finding end of enumeration
111  * 
112  *Describes the role of an object
113  **/
114 typedef enum
115 {
116   ATK_ROLE_INVALID,
117   ATK_ROLE_ACCEL_LABEL,
118   ATK_ROLE_ALERT,
119   ATK_ROLE_ANIMATION,
120   ATK_ROLE_ARROW,
121   ATK_ROLE_CALENDAR,
122   ATK_ROLE_CANVAS,
123   ATK_ROLE_CHECK_BOX,
124   ATK_ROLE_CHECK_MENU_ITEM,
125   ATK_ROLE_COLOR_CHOOSER,
126   ATK_ROLE_COLUMN_HEADER,
127   ATK_ROLE_COMBO_BOX,
128   ATK_ROLE_DATE_EDITOR,
129   ATK_ROLE_DESKTOP_ICON,
130   ATK_ROLE_DESKTOP_FRAME,
131   ATK_ROLE_DIAL,
132   ATK_ROLE_DIALOG,
133   ATK_ROLE_DIRECTORY_PANE,
134   ATK_ROLE_DRAWING_AREA,
135   ATK_ROLE_FILE_CHOOSER,
136   ATK_ROLE_FILLER,
137   ATK_ROLE_FONT_CHOOSER,
138   ATK_ROLE_FRAME,
139   ATK_ROLE_GLASS_PANE,
140   ATK_ROLE_HTML_CONTAINER,
141   ATK_ROLE_ICON,
142   ATK_ROLE_IMAGE,
143   ATK_ROLE_INTERNAL_FRAME,
144   ATK_ROLE_LABEL,
145   ATK_ROLE_LAYERED_PANE,
146   ATK_ROLE_LIST,
147   ATK_ROLE_LIST_ITEM,
148   ATK_ROLE_MENU,
149   ATK_ROLE_MENU_BAR,
150   ATK_ROLE_MENU_ITEM,
151   ATK_ROLE_OPTION_PANE,
152   ATK_ROLE_PAGE_TAB,
153   ATK_ROLE_PAGE_TAB_LIST,
154   ATK_ROLE_PANEL,
155   ATK_ROLE_PASSWORD_TEXT,
156   ATK_ROLE_POPUP_MENU,
157   ATK_ROLE_PROGRESS_BAR,
158   ATK_ROLE_PUSH_BUTTON,
159   ATK_ROLE_RADIO_BUTTON,
160   ATK_ROLE_RADIO_MENU_ITEM,
161   ATK_ROLE_ROOT_PANE,
162   ATK_ROLE_ROW_HEADER,
163   ATK_ROLE_SCROLL_BAR,
164   ATK_ROLE_SCROLL_PANE,
165   ATK_ROLE_SEPARATOR,
166   ATK_ROLE_SLIDER,
167   ATK_ROLE_SPLIT_PANE,
168   ATK_ROLE_SPIN_BUTTON,
169   ATK_ROLE_STATUSBAR,
170   ATK_ROLE_TABLE,
171   ATK_ROLE_TABLE_CELL,
172   ATK_ROLE_TABLE_COLUMN_HEADER,
173   ATK_ROLE_TABLE_ROW_HEADER,
174   ATK_ROLE_TEAR_OFF_MENU_ITEM,
175   ATK_ROLE_TERMINAL,
176   ATK_ROLE_TEXT,
177   ATK_ROLE_TOGGLE_BUTTON,
178   ATK_ROLE_TOOL_BAR,
179   ATK_ROLE_TOOL_TIP,
180   ATK_ROLE_TREE,
181   ATK_ROLE_UNKNOWN,
182   ATK_ROLE_VIEWPORT,
183   ATK_ROLE_WINDOW,
184   ATK_ROLE_LAST_DEFINED
185 } AtkRole;
186
187 AtkRole                  atk_role_register        (const gchar *name);
188
189
190 #define ATK_TYPE_OBJECT                           (atk_object_get_type ())
191 #define ATK_OBJECT(obj)                           (G_TYPE_CHECK_INSTANCE_CAST ((obj), ATK_TYPE_OBJECT, AtkObject))
192 #define ATK_OBJECT_CLASS(klass)                   (G_TYPE_CHECK_CLASS_CAST ((klass), ATK_TYPE_OBJECT, AtkObjectClass))
193 #define ATK_IS_OBJECT(obj)                        (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ATK_TYPE_OBJECT))
194 #define ATK_IS_OBJECT_CLASS(klass)                (G_TYPE_CHECK_CLASS_TYPE ((klass), ATK_TYPE_OBJECT))
195 #define ATK_OBJECT_GET_CLASS(obj)                 (G_TYPE_INSTANCE_GET_CLASS ((obj), ATK_TYPE_OBJECT, AtkObjectClass))
196
197 #define ATK_TYPE_IMPLEMENTOR                      (atk_implementor_get_type ())
198 #define ATK_IS_IMPLEMENTOR(obj)                   G_TYPE_CHECK_INSTANCE_TYPE ((obj), ATK_TYPE_IMPLEMENTOR)
199 #define ATK_IMPLEMENTOR(obj)                      G_TYPE_CHECK_INSTANCE_CAST ((obj), ATK_TYPE_IMPLEMENTOR, AtkImplementor)
200 #define ATK_IMPLEMENTOR_GET_IFACE(obj)            (G_TYPE_INSTANCE_GET_INTERFACE ((obj), ATK_TYPE_IMPLEMENTOR, AtkImplementorIface))
201
202
203 typedef struct _AtkImplementor            AtkImplementor; /* dummy typedef */
204 typedef struct _AtkImplementorIface       AtkImplementorIface;
205
206
207 typedef struct _AtkObject                 AtkObject;
208 typedef struct _AtkObjectClass            AtkObjectClass;
209 typedef struct _AtkRelationSet            AtkRelationSet;
210 typedef struct _AtkStateSet               AtkStateSet;
211
212 struct _AtkPropertyValues
213 {
214   gchar  *property_name;
215   GValue old_value;
216   GValue new_value;
217 };
218
219 typedef struct _AtkPropertyValues        AtkPropertyValues;
220
221 /*
222  * For most properties the old_value field of AtkPropertyValues will
223  * not contain a valid value.
224  *
225  * Currently, the only property for which old_value is used is
226  * accessible-state; for instance if there is a focus state the
227  * property change handler will be called for the object which lost the focus
228  * with the old_value containing an AtkState value corresponding to focused
229  * and the property change handler will be called for the object which
230  * received the focus with the new_value containing an AtkState value
231  * corresponding to focused.
232  */
233 typedef void (*AtkPropertyChangeHandler) (AtkObject*, AtkPropertyValues*);
234
235
236 struct _AtkObject
237 {
238   GObject parent;
239
240   gchar *description;
241   gchar *name;
242   AtkObject *accessible_parent;
243   AtkRole role;
244   AtkRelationSet *relation_set;
245 };
246
247 struct _AtkObjectClass
248 {
249   GObjectClass parent;
250
251   /*
252    * Gets the accessible name of the object
253    */
254   G_CONST_RETURN gchar*    (* get_name)            (AtkObject                *accessible);
255   /*
256    * Gets the accessible description of the object
257    */
258   G_CONST_RETURN gchar*    (* get_description)     (AtkObject                *accessible);
259   /*
260    * Gets the accessible parent of the object
261    */
262   AtkObject*               (*get_parent)           (AtkObject                *accessible);
263
264   /*
265    * Gets the number of accessible children of the object
266    */
267   gint                    (* get_n_children)       (AtkObject                *accessible);
268   /*
269    * Returns a reference to the specified accessible child of the object.
270    * The accessible children are 0-based so the first accessible child is
271    * at index 0, the second at index 1 and so on.
272    */
273   AtkObject*              (* ref_child)            (AtkObject                *accessible,
274                                                     gint                      i);
275   /*
276    * Gets the 0-based index of this object in its parent; returns -1 if the
277    * object does not have an accessible parent.
278    */
279   gint                    (* get_index_in_parent) (AtkObject                 *accessible);
280   /*
281    * Gets the RelationSet associated with the object
282    */
283   AtkRelationSet*         (* ref_relation_set)    (AtkObject                 *accessible);
284   /*
285    * Gets the role of the object
286    */
287   AtkRole                 (* get_role)            (AtkObject                 *accessible);
288   /*
289    * Gets the state set of the object
290    */
291   AtkStateSet*            (* ref_state_set)       (AtkObject                 *accessible);
292   /*
293    * Sets the accessible name of the object
294    */
295   void                    (* set_name)            (AtkObject                 *accessible,
296                                                    const gchar               *name);
297   /*
298    * Sets the accessible description of the object
299    */
300   void                    (* set_description)     (AtkObject                 *accessible,
301                                                    const gchar               *description);
302   /*
303    * Sets the accessible parent of the object
304    */
305   void                    (* set_parent)          (AtkObject                 *accessible,
306                                                    AtkObject                 *parent);
307   /*
308    * Sets the accessible role of the object
309    */
310   void                    (* set_role)            (AtkObject                 *accessible,
311                                                    AtkRole                   role);
312   /*
313    * Specifies a function to be called when a property changes value
314    */
315 guint                     (* connect_property_change_handler)    (AtkObject
316                  *accessible,
317                                                                   AtkPropertyChangeHandler       *handler);
318   /*
319    * Removes a property change handler which was specified using
320    * connect_property_change_handler
321    */
322 void                      (* remove_property_change_handler)     (AtkObject
323                 *accessible,
324                                                                   guint
325                 handler_id);
326   /*
327    * The signal handler which is executed when there is a change in the
328    * children of the object
329    */
330   void                    (* children_changed)    (AtkObject                  *accessible,
331                                                    gint                       change_index,
332                                                    AtkObject                  *changed_child);
333   /*
334    * The signal handler which is executed  when there is a focus event
335    * for an object.
336    */
337   void                    (*focus_event)          (AtkObject                  *accessible,
338                                                    gboolean                   focus_in);
339   /*
340    * The signal handler which is executed  when there is a property_change 
341    * signal for an object.
342    */
343   gint                    (*property_change)      (AtkObject                 *accessible,
344                                                    AtkPropertyValues         *values);
345
346 };
347
348 GType            atk_object_get_type   (void);
349
350 struct _AtkImplementorIface
351 {
352   GTypeInterface parent;
353
354   AtkObject*   (*ref_accessible) (AtkImplementor *implementor);
355 };
356 GType atk_implementor_get_type (void);
357
358 /*
359  * This method uses the ref_accessible method in AtkImplementorIface,
360  * if the object's class implements AtkImplementorIface.
361  * Otherwise it returns %NULL.
362  *
363  * IMPORTANT:
364  * Note also that because this method may return flyweight objects,
365  * it increments the returned AtkObject's reference count.
366  * Therefore it is the responsibility of the calling
367  * program to unreference the object when no longer needed.
368  * (c.f. gtk_widget_get_accessible() where this is not the case).
369  */
370 AtkObject*              atk_implementor_ref_accessible            (AtkImplementor *implementor);
371
372 /*
373  * Properties directly supported by AtkObject
374  */
375
376 G_CONST_RETURN gchar*   atk_object_get_name                       (AtkObject *accessible);
377 G_CONST_RETURN gchar*   atk_object_get_description                (AtkObject *accessible);
378 AtkObject*              atk_object_get_parent                     (AtkObject *accessible);
379 gint                    atk_object_get_n_accessible_children      (AtkObject *accessible);
380 AtkObject*              atk_object_ref_accessible_child           (AtkObject *accessible,
381                                                                    gint        i);
382 AtkRelationSet*         atk_object_ref_relation_set               (AtkObject *accessible);
383 AtkRole                 atk_object_get_role                       (AtkObject *accessible);
384 AtkStateSet*            atk_object_ref_state_set                  (AtkObject *accessible);
385 gint                    atk_object_get_index_in_parent            (AtkObject *accessible);
386 void                    atk_object_set_name                       (AtkObject *accessible,
387                                                                    const gchar *name);
388 void                    atk_object_set_description                (AtkObject *accessible,
389                                                                    const gchar *description);
390 void                    atk_object_set_parent                     (AtkObject *accessible,
391                                                                    AtkObject *parent);
392 void                    atk_object_set_role                       (AtkObject *accessible,
393                                                                    AtkRole   role);
394
395
396 /*
397  * to install property change listener, one must
398  * install signal handler for gobject "properties_changed" signal.
399  * (for single notifications of multiple changes).
400  * We could use the "notify" signal instead.
401  *
402  */
403 guint                atk_object_connect_property_change_handler  (AtkObject                      *accessible,
404                                                                   AtkPropertyChangeHandler       *handler);
405 void                 atk_object_remove_property_change_handler   (AtkObject                      *accessible,
406                                                                   guint                          handler_id);
407
408 void                 atk_object_notify_state_change              (AtkObject                      *accessible,
409                                                                   AtkState                       state,
410                                                                   gboolean                       value);
411                                     
412 /*
413  * Note: the properties which are registered with the GType
414  *   property registry, for type ATK_TYPE_OBJECT, are as follows:
415  *
416  *   "accessible-name"
417  *   "accessible-description"
418  *   "accessible-parent"
419  *   "accessible-child"
420  *   "accessible-role"
421  *   "accessible-state"
422  *   "accessible-parent"
423  *   "accessible-text"
424  *   "accessible-caret"
425  *   "accessible-selection"
426  *   "accessible-value"
427  *   "accessible-visible-data"
428  *   "accessible-table-caption"
429  *   "accessible-table-column-header"
430  *   "accessible-table-row-heaer"
431  *   "accessible-table-summary"
432  *   "accessible-model"
433  *
434  * accessibility property change listeners should use the
435  *   normal GObject property interfaces and "properties_changed"
436  *   signal handler semantics to interpret the property change
437  *   information relayed from AtkObject.
438  *   (AtkObject instances will connect to the "properties_changed"
439  *   signal in their host objects, and relay the signals when appropriate).
440  */
441
442 /* For other signals, see related interfaces
443  *
444  *    AtkActionIface,
445  *    AtkComponentIface,
446  *    AtkHypertextIface,
447  *    AtkImageIface,
448  *    AtkSelectionIface,
449  *    AtkTableIface,
450  *    AtkTextIface,
451  *    AtkValueIface.
452  *
453  *  The usage model for obtaining these interface instances is:
454  *    ATK_<interfacename>_GET_IFACE(GObject *accessible),
455  *    where accessible, though specified as a GObject, is
456  *    the AtkObject instance being queried.
457  *  More usually, the interface will be used via a cast to the
458  *    interface's corresponding "type":
459  *
460  *    AtkText textImpl = ATK_TEXT(accessible);
461  *    if (textImpl)
462  *      {
463  *        cpos = atk_text_get_caret_position(textImpl);
464  *      }
465  *
466  *  If it's known in advance that accessible implements AtkTextIface,
467  *    this is shortened to:
468  *
469  *    cpos = atk_text_get_caret_position (ATK_TEXT (accessible));
470  */
471
472 #ifdef __cplusplus
473 }
474 #endif /* __cplusplus */
475
476
477 #endif /* __ATK_OBJECT_H__ */