Add function atk_object_real_set_role() and use it to implement
[atk.git] / atk / atkobject.h
blob273988e21f7298da45d9b6d6c167b378d9bca5e7
1 /* ATK - Accessibility Toolkit
2 * Copyright 2001 Sun Microsystems Inc.
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.
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.
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.
20 #ifndef __ATK_OBJECT_H__
21 #define __ATK_OBJECT_H__
23 #ifdef __cplusplus
24 extern "C" {
25 #endif /* __cplusplus */
27 #include <glib-object.h>
30 * AtkObject represents the minimum information all accessible objects
31 * return. This information includes accessible name, accessible
32 * description, role and state of the object, as well information about
33 * its parent and children. It is also possible to obtain more specific
34 * accessibility information about a component if it supports one or more
35 * of the following interfaces:
37 typedef enum
39 ATK_CHILD_ADDED,
40 ATK_CHILD_REMOVED,
41 ATK_CHILD_CHANGED
42 } AtkChildChangeType;
44 typedef enum
46 ATK_ROLE_INVALID,
47 /* A label which represents an accelerator */
48 ATK_ROLE_ACCEL_LABEL,
49 /* An object is used to alert the user about something */
50 ATK_ROLE_ALERT,
51 /* An object which is an animated image */
52 ATK_ROLE_ANIMATION,
53 /* An arrow in one of the four cardinal directoions */
54 ATK_ROLE_ARROW,
55 /* An object that displays a calendar and allows the user to select a date */
56 ATK_ROLE_CALENDAR,
57 /* An object that can be drawn into and is used to trap events */
58 ATK_ROLE_CANVAS,
60 * A choice that can be checked or unchecked and provides a separate
61 * indicator for the current state.
63 ATK_ROLE_CHECK_BOX,
64 /* A menu item with a check box */
65 ATK_ROLE_CHECK_MENU_ITEM,
66 /* A specialized dialog that lets the user choose a color. */
67 ATK_ROLE_COLOR_CHOOSER,
68 /* The header for a column of data */
69 ATK_ROLE_COLUMN_HEADER,
70 /* A list of choices the user can select from */
71 ATK_ROLE_COMBO_BOX,
72 /* An object whose purpose is to allow a user to edit a date */
73 ATK_ROLE_DATE_EDITOR,
74 /* An inconifed internal frame within a DESKTOP_PANE */
75 ATK_ROLE_DESKTOP_ICON,
77 * A pane that supports internal frames and iconified versions of those
78 * internal frames.
80 ATK_ROLE_DESKTOP_FRAME,
81 /* An object whose purpose is to allow a user to set a value */
82 ATK_ROLE_DIAL,
83 /* A top level window with title bar and a border */
84 ATK_ROLE_DIALOG,
86 * A pane that allows the user to navigate through and select the contents
87 * of a directory
89 ATK_ROLE_DIRECTORY_PANE,
91 * A specialized dialog that displays the files in the directory and lets
92 * the user select a file, browse a different directory, or specify a
93 * filename.
95 /* An object used for drawing custom user interface elements */
96 ATK_ROLE_DRAWING_AREA,
97 /* A specialized dialog that lets the user choose a file. */
98 ATK_ROLE_FILE_CHOOSER,
99 /* A object that fills up space in a user interface */
100 ATK_ROLE_FILLER,
101 /* A specialized dialog that lets the user choose a font. */
102 ATK_ROLE_FONT_CHOOSER,
103 /* A top level window with a title bar, border, menubar, etc. */
104 ATK_ROLE_FRAME,
105 /* A pane that is guaranteed to be painted on top of all panes beneath it */
106 ATK_ROLE_GLASS_PANE,
108 * A document container for HTML, whose children
109 * represent the document content.
111 ATK_ROLE_HTML_CONTAINER,
112 /* A small fixed size picture, typically used to decorate components */
113 ATK_ROLE_ICON,
114 /* An object whose primary purpose is to display an image */
115 ATK_ROLE_IMAGE,
116 /* A frame-like object that is clipped by a desktop pane. */
117 ATK_ROLE_INTERNAL_FRAME,
118 /* An object used to present an icon or short string in an interface */
119 ATK_ROLE_LABEL,
121 * A specialized pane that allows its children to be drawn in layers,
122 * providing a form of stacking order.
124 ATK_ROLE_LAYERED_PANE,
126 * An object that presents a list of objects to the user and allows the
127 * user to select one or more of them.
129 ATK_ROLE_LIST,
130 /* An object that represents an element of a list. */
131 ATK_ROLE_LIST_ITEM,
133 * An object usually found inside a menu bar that contains a list of
134 * actions the user can choose from.
136 ATK_ROLE_MENU,
138 * An object usually drawn at the top of the primary dialog box of an
139 * application that contains a list of menus the user can choose from.
141 ATK_ROLE_MENU_BAR,
143 * An object usually contained in a menu that presents an action the
144 * user can choose.
146 ATK_ROLE_MENU_ITEM,
147 /* A specialized pane whose primary use is inside a DIALOG */
148 ATK_ROLE_OPTION_PANE,
149 /* An object that is a child of a page tab list */
150 ATK_ROLE_PAGE_TAB,
152 * An object that presents a series of panels (or page tabs), one at a time,
153 * through some mechanism provided by the object.
155 ATK_ROLE_PAGE_TAB_LIST,
156 /* A generic container that is often used to group objects. */
157 ATK_ROLE_PANEL,
159 * A text object uses for passwords, or other places where the text
160 * content is not shown visibly to the user.
162 ATK_ROLE_PASSWORD_TEXT,
164 * A temporary window that is usually used to offer the user a list of
165 * choices, and then hides when the user selects one of those choices.
167 ATK_ROLE_POPUP_MENU,
168 /* An object used to indicate how much of a task has been completed. */
169 ATK_ROLE_PROGRESS_BAR,
171 * An object the user can manipulate to tell the application to do
172 * something.
174 ATK_ROLE_PUSH_BUTTON,
176 * A specialized check box that will cause other radio buttons in the
177 * same group to become uncghecked when this one is checked.
179 ATK_ROLE_RADIO_BUTTON,
181 * A check menu item which belongs to a group. At each instant exactly
182 * one of the radio menu items from a group is selected
184 ATK_ROLE_RADIO_MENU_ITEM,
186 * A specialized pane that has a glass pane and a layered pane as its
187 * children.
189 ATK_ROLE_ROOT_PANE,
190 /* The header for a row of data */
191 ATK_ROLE_ROW_HEADER,
193 * An object usually used to allow a user to incrementally view a large
194 * amount of data.
196 ATK_ROLE_SCROLL_BAR,
198 * An object that allows a user to incrementally view a large amount
199 * of information.
201 ATK_ROLE_SCROLL_PANE,
203 * An object usually contained in a menu to provide a visible and
204 * logical separation of the contents in a menu.
206 ATK_ROLE_SEPARATOR,
207 /* An object that allows the user to select from a bounded range */
208 ATK_ROLE_SLIDER,
209 /* A specialized panel that presents two other panels at the same time. */
210 ATK_ROLE_SPLIT_PANE,
211 /* An object used to get an integer or floating point number from the user */
212 ATK_ROLE_SPIN_BUTTON,
213 /* An object which reports messages of minor importance to the user */
214 ATK_STATUS_BAR,
215 /* An object used to rpesent information in terms of rows and columns. */
216 ATK_ROLE_TABLE,
217 ATK_ROLE_TABLE_CELL,
218 ATK_ROLE_TABLE_COLUMN_HEADER,
219 ATK_ROLE_TABLE_ROW_HEADER,
220 /* A menu item used to tear off and reattach its menu */
221 ATK_ROLE_TEAR_OFF_MENU_ITEM,
222 /* An object that presents text to the user */
223 ATK_ROLE_TEXT,
225 * A specialized push button that can be checked or unchecked, but does
226 * not procide a separate indicator for the current state.
228 ATK_ROLE_TOGGLE_BUTTON,
230 * A bar or palette usually composed of push buttons or toggle buttons
232 ATK_ROLE_TOOL_BAR,
234 * An object that provides information about another object
236 ATK_ROLE_TOOL_TIP,
237 /* An object used to repsent hierarchical information to the user. */
238 ATK_ROLE_TREE,
240 * The object contains some Accessible information, but its role is
241 * not known.
243 ATK_ROLE_UNKNOWN,
244 /* An object usually used in a scroll pane. */
245 ATK_ROLE_VIEWPORT,
246 /* A top level window with no title or border */
247 ATK_ROLE_WINDOW,
248 /* not a valid role, used for finding end of enumeration. */
249 ATK_ROLE_LAST_DEFINED
250 } AtkRole;
252 AtkRole atk_role_register (const gchar *name);
255 #define ATK_TYPE_OBJECT (atk_object_get_type ())
256 #define ATK_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ATK_TYPE_OBJECT, AtkObject))
257 #define ATK_OBJECT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ATK_TYPE_OBJECT, AtkObjectClass))
258 #define ATK_IS_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ATK_TYPE_OBJECT))
259 #define ATK_IS_OBJECT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), ATK_TYPE_OBJECT))
260 #define ATK_OBJECT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), ATK_TYPE_OBJECT, AtkObjectClass))
262 #define ATK_TYPE_IMPLEMENTOR (atk_implementor_get_type ())
263 #define ATK_IS_IMPLEMENTOR(obj) G_TYPE_CHECK_INSTANCE_TYPE ((obj), ATK_TYPE_IMPLEMENTOR)
264 #define ATK_IMPLEMENTOR(obj) G_TYPE_CHECK_INSTANCE_CAST ((obj), ATK_TYPE_IMPLEMENTOR, AtkImplementor)
265 #define ATK_IMPLEMENTOR_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), ATK_TYPE_IMPLEMENTOR, AtkImplementorIface))
268 typedef struct _AtkImplementor AtkImplementor; /* dummy typedef */
269 typedef struct _AtkImplementorIface AtkImplementorIface;
272 typedef struct _AtkObject AtkObject;
273 typedef struct _AtkObjectClass AtkObjectClass;
274 typedef struct _AtkRelationSet AtkRelationSet;
275 typedef struct _AtkStateSet AtkStateSet;
277 struct _AtkPropertyValues
279 gchar *property_name;
280 GValue old_value;
281 GValue new_value;
284 typedef struct _AtkPropertyValues AtkPropertyValues;
287 * For most properties the old_value field of AtkPropertyValues will
288 * not contain a valid value.
290 * Currently, the only property for which old_value is used is
291 * accessible-state; for instance if there is a focus state the
292 * property change handler will be called for the object which lost the focus
293 * with the old_value containing an AtkState value corresponding to focused
294 * and the property change handler will be called for the object which
295 * received the focus with the new_value containing an AtkState value
296 * corresponding to focused.
298 typedef void (*AtkPropertyChangeHandler) (AtkObject*, AtkPropertyValues*);
301 struct _AtkObject
303 GObject parent;
305 gchar *description;
306 gchar *name;
307 AtkObject *accessible_parent;
308 AtkRole role;
309 AtkRelationSet *relation_set;
312 struct _AtkObjectClass
314 GObjectClass parent;
317 * Gets the accessible name of the object
319 G_CONST_RETURN gchar* (* get_name) (AtkObject *accessible);
321 * Gets the accessible description of the object
323 G_CONST_RETURN gchar* (* get_description) (AtkObject *accessible);
325 * Gets the accessible parent of the object
327 AtkObject* (*get_parent) (AtkObject *accessible);
330 * Gets the number of accessible children of the object
332 gint (* get_n_children) (AtkObject *accessible);
334 * Returns a reference to the specified accessible child of the object.
335 * The accessible children are 0-based so the first accessible child is
336 * at index 0, the second at index 1 and so on.
338 AtkObject* (* ref_child) (AtkObject *accessible,
339 gint i);
341 * Gets the 0-based index of this object in its parent; returns -1 if the
342 * object does not have an accessible parent.
344 gint (* get_index_in_parent) (AtkObject *accessible);
346 * Gets the RelationSet associated with the object
348 AtkRelationSet* (* ref_relation_set) (AtkObject *accessible);
350 * Gets the role of the object
352 AtkRole (* get_role) (AtkObject *accessible);
354 * Gets the state set of the object
356 AtkStateSet* (* ref_state_set) (AtkObject *accessible);
358 * Sets the accessible name of the object
360 void (* set_name) (AtkObject *accessible,
361 const gchar *name);
363 * Sets the accessible description of the object
365 void (* set_description) (AtkObject *accessible,
366 const gchar *description);
368 * Sets the accessible parent of the object
370 void (* set_parent) (AtkObject *accessible,
371 AtkObject *parent);
373 * Sets the accessible role of the object
375 void (* set_role) (AtkObject *accessible,
376 AtkRole role);
378 * Specifies a function to be called when a property changes value
380 guint (* connect_property_change_handler) (AtkObject
381 *accessible,
382 AtkPropertyChangeHandler *handler);
384 * Removes a property change handler which was specified using
385 * connect_property_change_handler
387 void (* remove_property_change_handler) (AtkObject
388 *accessible,
389 guint
390 handler_id);
392 * The signal handler which is executed when there is a change in the
393 * children of the object
395 void (* children_changed) (AtkObject *accessible,
396 AtkChildChangeType change_type,
397 AtkObject *changed_child);
399 GType atk_object_get_type (void);
401 struct _AtkImplementorIface
403 GTypeInterface parent;
405 AtkObject* (*ref_accessible) (AtkImplementor *implementor);
407 GType atk_implementor_get_type (void);
410 * This method uses the ref_accessible method in AtkImplementorIface,
411 * if the object's class implements AtkImplementorIface.
412 * Otherwise it returns %NULL.
414 * IMPORTANT:
415 * Note also that because this method may return flyweight objects,
416 * it increments the returned AtkObject's reference count.
417 * Therefore it is the responsibility of the calling
418 * program to unreference the object when no longer needed.
419 * (c.f. gtk_widget_get_accessible() where this is not the case).
421 AtkObject* atk_implementor_ref_accessible (AtkImplementor *implementor);
424 * Properties directly supported by AtkObject
427 G_CONST_RETURN gchar* atk_object_get_name (AtkObject *accessible);
428 G_CONST_RETURN gchar* atk_object_get_description (AtkObject *accessible);
429 AtkObject* atk_object_get_parent (AtkObject *accessible);
430 gint atk_object_get_n_accessible_children (AtkObject *accessible);
431 AtkObject* atk_object_ref_accessible_child (AtkObject *accessible,
432 gint i);
433 AtkRelationSet* atk_object_ref_relation_set (AtkObject *accessible);
434 AtkRole atk_object_get_role (AtkObject *accessible);
435 AtkStateSet* atk_object_ref_state_set (AtkObject *accessible);
436 gint atk_object_get_index_in_parent (AtkObject *accessible);
437 void atk_object_set_name (AtkObject *accessible,
438 const gchar *name);
439 void atk_object_set_description (AtkObject *accessible,
440 const gchar *description);
441 void atk_object_set_parent (AtkObject *accessible,
442 AtkObject *parent);
443 void atk_object_set_role (AtkObject *accessible,
444 AtkRole role);
448 * to install property change listener, one must
449 * install signal handler for gobject "properties_changed" signal.
450 * (for single notifications of multiple changes).
451 * We could use the "notify" signal instead.
454 guint atk_object_connect_property_change_handler (AtkObject *accessible,
455 AtkPropertyChangeHandler *handler);
456 void atk_object_remove_property_change_handler (AtkObject *accessible,
457 guint handler_id);
460 * Note: the properties which are registered with the GType
461 * property registry, for type ATK_TYPE_OBJECT, are as follows:
463 * "accessible-name"
464 * "accessible-description"
465 * "accessible-parent"
466 * "accessible-child"
467 * "accessible-role"
468 * "accessible-state"
470 * accessibility property change listeners should use the
471 * normal GObject property interfaces and "properties_changed"
472 * signal handler semantics to interpret the property change
473 * information relayed from AtkObject.
474 * (AtkObject instances will connect to the "properties_changed"
475 * signal in their host objects, and relay the signals when appropriate).
478 /* For other signals, see related interfaces
480 * AtkActionIface,
481 * AtkComponentIface,
482 * AtkHypertextIface,
483 * AtkImageIface,
484 * AtkSelectionIface,
485 * AtkTableIface,
486 * AtkTextIface,
487 * AtkValueIface.
489 * The usage model for obtaining these interface instances is:
490 * ATK_<interfacename>_GET_IFACE(GObject *accessible),
491 * where accessible, though specified as a GObject, is
492 * the AtkObject instance being queried.
493 * More usually, the interface will be used via a cast to the
494 * interface's corresponding "type":
496 * AtkText textImpl = ATK_TEXT(accessible);
497 * if (textImpl)
499 * cpos = atk_text_get_caret_position(textImpl);
502 * If it's known in advance that accessible implements AtkTextIface,
503 * this is shortened to:
505 * cpos = atk_text_get_caret_position (ATK_TEXT (accessible));
508 #ifdef __cplusplus
510 #endif /* __cplusplus */
513 #endif /* __ATK_OBJECT_H__ */