From: Bill Haneman Date: Thu, 26 Apr 2001 14:23:41 +0000 (+0000) Subject: Initial revision X-Git-Tag: Initial~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=dba66b4bec94a908cd35a5537209db255fa5fa33;p=platform%2Fupstream%2Fatk.git Initial revision --- dba66b4bec94a908cd35a5537209db255fa5fa33 diff --git a/ChangeLog b/ChangeLog new file mode 100644 index 0000000..256f2db --- /dev/null +++ b/ChangeLog @@ -0,0 +1,4 @@ +Tue Apr 25 10:10:00 2001 Padraig Obriain + + * Start a ChangeLog + diff --git a/Makefile.am b/Makefile.am new file mode 100644 index 0000000..ae92ff3 --- /dev/null +++ b/Makefile.am @@ -0,0 +1,9 @@ +# Process this file with automake to create Makefile.in. + +SUBDIRS=atk + +EXTRA_DIST = \ + atk.pc.in + +pkgconfigdir = $(libdir)/pkgconfig +pkgconfig_DATA = atk.pc diff --git a/atk.pc.in b/atk.pc.in new file mode 100644 index 0000000..f0967c5 --- /dev/null +++ b/atk.pc.in @@ -0,0 +1,11 @@ +prefix=@prefix@ +exec_prefix=@exec_prefix@ +libdir=@libdir@ +includedir=@includedir@ + +Name: Atk +Description: Accessibility Toolkit +Version: @VERSION@ +Requires: @GLIB_PACKAGES@ @PANGO_PACKAGES@ +Libs: -L${libdir} -latk +Cflags: -I${includedir} diff --git a/atk/Makefile.am b/atk/Makefile.am new file mode 100644 index 0000000..df17806 --- /dev/null +++ b/atk/Makefile.am @@ -0,0 +1,49 @@ + +lib_LTLIBRARIES = libatk.la + +libatk_la_SOURCES = \ + atkaction.c \ + atkcomponent.c \ + atkeditabletext.c \ + atkhyperlink.c \ + atkhypertext.c \ + atkimage.c \ + atknoopobject.c \ + atknoopobject.h \ + atknoopobjectfactory.c \ + atknoopobjectfactory.h \ + atkobject.c \ + atkobjectfactory.c \ + atkregistry.c \ + atkselection.c \ + atktable.c \ + atktext.c \ + atkutil.c \ + atkvalue.c + +INCLUDES = \ + -I$(top_srcdir) \ + @DEP_CFLAGS@ + +LDFLAGS = \ + -no-undefined \ + @DEP_LIBS@ + +libatkincludedir=$(includedir)/atk + +libatkinclude_HEADERS = \ + atk.h \ + atkaction.h \ + atkcomponent.h \ + atkeditabletext.h \ + atkhyperlink.h \ + atkhypertext.h \ + atkobject.h \ + atkobjectfactory.h \ + atkimage.h \ + atkregistry.h \ + atkselection.h \ + atktable.h \ + atktext.h \ + atkutil.h \ + atkvalue.h diff --git a/atk/atk.h b/atk/atk.h new file mode 100755 index 0000000..a9bf7e2 --- /dev/null +++ b/atk/atk.h @@ -0,0 +1,33 @@ +/* ATK - Accessibility Toolkit + * Copyright 2001 Sun Microsystems Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include diff --git a/atk/atkaction.c b/atk/atkaction.c new file mode 100755 index 0000000..456405f --- /dev/null +++ b/atk/atkaction.c @@ -0,0 +1,139 @@ +/* ATK - Accessibility Toolkit + * Copyright 2001 Sun Microsystems Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#include "atkaction.h" + +GType +atk_action_get_type () +{ + static GType type = 0; + + if (!type) { + GTypeInfo tinfo = + { + sizeof (AtkActionIface), + NULL, + NULL, + + }; + + type = g_type_register_static (G_TYPE_INTERFACE, "AtkAction", &tinfo, 0); + } + + return type; +} + +/** + * atk_action_do_action: + * @value: a GObject instance that implements AtkActionIface + * @return: void + **/ +void +atk_action_do_action (AtkAction *obj, + gint i) +{ + AtkActionIface *iface; + + g_return_if_fail (obj != NULL); + g_return_if_fail (ATK_IS_ACTION (obj)); + + iface = ATK_ACTION_GET_IFACE (obj); + + if (iface->do_action) + (iface->do_action) (obj, i); +} + +/** + * atk_action_get_n_actions: + * @value: a GObject instance that implements AtkActionIface + * @return: a gint representing the number of actions , or 0 + * if value does not implement this interface. + * + * WARNING: callers should not rely on %NULL or on a zero value for + * indication of whether GaccessibleActionValue is implemented, they should + * use type checking/interface checking macros or the + * atk_object_get_action_interface() convenience method. + **/ +gint +atk_action_get_n_actions (AtkAction *obj) +{ + AtkActionIface *iface; + + g_return_val_if_fail (obj != NULL, 0); + g_return_val_if_fail (ATK_IS_ACTION (obj), 0); + + iface = ATK_ACTION_GET_IFACE (obj); + + if (iface->get_n_actions) + return (iface->get_n_actions) (obj); + else + return 0; +} + +/** + * atk_action_get_description: + * @value: a GObject instance that implements AtkActionIface + * @return: a #gchar representing the description, or %NULL + * if value does not implement this interface. + * + * WARNING: callers should not rely on %NULL or on a zero value for + * indication of whether GaccessibleValue is implemented, they should + * use type checking/interface checking macros or the + * atk_object_get_action_interface() convenience method. + **/ +G_CONST_RETURN gchar* +atk_action_get_description (AtkAction *obj, + gint i) +{ + AtkActionIface *iface; + + g_return_val_if_fail (obj != NULL, NULL); + g_return_val_if_fail (ATK_IS_ACTION (obj), NULL); + + iface = ATK_ACTION_GET_IFACE (obj); + + if (iface->get_description) + return (iface->get_description) (obj, i); + else + return NULL; +} + +/** + * atk_action_get_keybinding: + * @value: a GObject instance that implements AtkActionIface + * @return: a #gchar representing the keybinding, or %NULL + * if there is no keybinding for this action. + * + **/ +G_CONST_RETURN gchar* +atk_action_get_keybinding (AtkAction *obj, + gint i) +{ + AtkActionIface *iface; + + g_return_val_if_fail (obj != NULL, NULL); + g_return_val_if_fail (ATK_IS_ACTION (obj), NULL); + + iface = ATK_ACTION_GET_IFACE (obj); + + if (iface->get_keybinding) + return (iface->get_keybinding) (obj, i); + else + return NULL; +} diff --git a/atk/atkaction.h b/atk/atkaction.h new file mode 100755 index 0000000..0f36872 --- /dev/null +++ b/atk/atkaction.h @@ -0,0 +1,106 @@ +/* ATK - Accessibility Toolkit + * Copyright 2001 Sun Microsystems Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#ifndef __ATK_ACTION_H__ +#define __ATK_ACTION_H__ + +#include + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/* + * The interface AtkAction should be supported by any object that can + * perform one or more actions. The interface provides the standard + * mechanism for an assitive technology to determine what those actions + * are as well as tell the object to perform them. Any object that can + * be manipulated should support this interface. + */ + + +#define ATK_TYPE_ACTION (atk_action_get_type ()) +#define ATK_IS_ACTION(obj) G_TYPE_CHECK_INSTANCE_TYPE ((obj), ATK_TYPE_ACTION) +#define ATK_ACTION(obj) G_TYPE_CHECK_INSTANCE_CAST ((obj), ATK_TYPE_ACTION, AtkAction) +#define ATK_ACTION_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), ATK_TYPE_ACTION, AtkActionIface)) + +#ifndef _TYPEDEF_ATK_ACTION_ +#define _TYPEDEF_ATK_ACTION_ +typedef struct _AtkAction AtkAction; +#endif + +struct _AtkActionIface +{ + GTypeInterface parent; + + /* + * Perform the specified action on the object + */ + gboolean (*do_action) (AtkAction *action, + gint i); + /* + * Returns the number of accessible actions available on the object. + * If there are more than one, the first one is considered the + * "default" action of the object. + */ + gint (*get_n_actions) (AtkAction *action); + /* + * Returns a description of the specified action of the object + */ + G_CONST_RETURN gchar* (*get_description) (AtkAction *action, + gint i); + /* + * Returns a keybinding associated with this action, if one exists. + */ + G_CONST_RETURN gchar* (*get_keybinding) (AtkAction *action, + gint i); + +}; +GType atk_action_get_type (); + +/* + * These are the function which would be called by an application with + * the argument being a AtkObject object cast to (AtkAction). + * + * The function will just check that * the corresponding + * function pointer is not NULL and will call it. + * + * The "real" implementation of the function for accessible will be + * provided in a support library + */ + +void atk_action_do_action (AtkAction *action, + gint i); +gint atk_action_get_n_actions (AtkAction *action); +G_CONST_RETURN gchar* atk_action_get_description (AtkAction *action, + gint i); + + +/* + * Additional GObject properties exported by AtkAction: + * "accessible_action" + * (an accessible action, or the list of actions, has changed) + */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + + +#endif /* __ATK_ACTION_H__ */ diff --git a/atk/atkcomponent.c b/atk/atkcomponent.c new file mode 100755 index 0000000..f7a0ea4 --- /dev/null +++ b/atk/atkcomponent.c @@ -0,0 +1,233 @@ +/* ATK - Accessibility Toolkit + * Copyright 2001 Sun Microsystems Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + + +#include "atkcomponent.h" + +GType +atk_component_get_type () +{ + static GType type = 0; + + if (!type) { + static const GTypeInfo tinfo = + { + sizeof (AtkComponentIface), + NULL, + NULL, + + }; + + type = g_type_register_static (G_TYPE_INTERFACE, "AtkComponent", &tinfo, 0); + } + + return type; +} + +/** + * + **/ +guint +atk_component_add_focus_handler (AtkComponent *component, + AtkFocusHandler handler) +{ + AtkComponentIface *iface = NULL; + g_return_val_if_fail (component != NULL, 0); + g_return_val_if_fail (ATK_IS_COMPONENT (component), 0); + + iface = ATK_COMPONENT_GET_IFACE (component); + + if (iface->add_focus_handler) + return (iface->add_focus_handler) (component, handler); + else + return 0; +} + +/** + * + **/ +void +atk_component_remove_focus_handler (AtkComponent *component, + guint handler_id) +{ + AtkComponentIface *iface = NULL; + g_return_if_fail (component != NULL); + g_return_if_fail (ATK_IS_COMPONENT (component)); + + iface = ATK_COMPONENT_GET_IFACE (component); + + if (iface->remove_focus_handler) + (iface->remove_focus_handler) (component, handler_id); +} + +gboolean +atk_component_contains (AtkComponent *component, + gint x, + gint y) +{ + AtkComponentIface *iface = NULL; + g_return_val_if_fail (component != NULL, FALSE); + g_return_val_if_fail (ATK_IS_COMPONENT (component), FALSE); + + iface = ATK_COMPONENT_GET_IFACE (component); + + if (iface->contains) + return (iface->contains) (component, x, y); + else + return FALSE; +} + +AtkObject* +atk_component_get_accessible_at_point (AtkComponent *component, + gint x, + gint y) +{ + AtkComponentIface *iface = NULL; + g_return_val_if_fail (component != NULL, FALSE); + g_return_val_if_fail (ATK_IS_COMPONENT (component), FALSE); + + iface = ATK_COMPONENT_GET_IFACE (component); + + if (iface->get_accessible_at_point) + return (iface->get_accessible_at_point) (component, x, y); + else + return FALSE; +} + +void +atk_component_get_extents (AtkComponent *component, + gint *x, + gint *y, + gint *width, + gint *height) +{ + AtkComponentIface *iface = NULL; + g_return_if_fail (component != NULL); + g_return_if_fail (ATK_IS_COMPONENT (component)); + + iface = ATK_COMPONENT_GET_IFACE (component); + + if (iface->get_extents) + (iface->get_extents) (component, x, y, width, height); +} + +void +atk_component_get_position (AtkComponent *component, + gint *x, + gint *y) +{ + AtkComponentIface *iface = NULL; + g_return_if_fail (component != NULL); + g_return_if_fail (ATK_IS_COMPONENT (component)); + + iface = ATK_COMPONENT_GET_IFACE (component); + + if (iface->get_position) + (iface->get_position) (component, x, y); +} + +void +atk_component_get_position_on_screen (AtkComponent *component, + gint *x, + gint *y) +{ + AtkComponentIface *iface = NULL; + g_return_if_fail (component != NULL); + g_return_if_fail (ATK_IS_COMPONENT (component)); + + iface = ATK_COMPONENT_GET_IFACE (component); + + if (iface->get_position_on_screen) + return (iface->get_position_on_screen) (component, x, y); +} + +void +atk_component_get_size (AtkComponent *component, + gint *x, + gint *y) +{ + AtkComponentIface *iface = NULL; + g_return_if_fail (component != NULL); + g_return_if_fail (ATK_IS_COMPONENT (component)); + + iface = ATK_COMPONENT_GET_IFACE (component); + + if (iface->get_size) + (iface->get_size) (component, x, y); +} + +void +atk_component_grab_focus (AtkComponent *component) +{ + AtkComponentIface *iface = NULL; + g_return_if_fail (component != NULL); + g_return_if_fail (ATK_IS_COMPONENT (component)); + + iface = ATK_COMPONENT_GET_IFACE (component); + + if (iface->grab_focus) + (iface->grab_focus) (component); +} + +void +atk_component_set_extents (AtkComponent *component, + gint x, + gint y, + gint width, + gint height) +{ + AtkComponentIface *iface = NULL; + g_return_if_fail (component != NULL); + g_return_if_fail (ATK_IS_COMPONENT (component)); + + iface = ATK_COMPONENT_GET_IFACE (component); + + if (iface->set_extents) + (iface->set_extents) (component, x, y, width, height); +} + +void +atk_component_set_position (AtkComponent *component, + gint x, + gint y) +{ + AtkComponentIface *iface = NULL; + g_return_if_fail (component != NULL); + g_return_if_fail (ATK_IS_COMPONENT (component)); + + iface = ATK_COMPONENT_GET_IFACE (component); + + if (iface->set_position) + (iface->set_position) (component, x, y); +} + +void +atk_component_set_size (AtkComponent *component, + gint x, + gint y) +{ + AtkComponentIface *iface = NULL; + g_return_if_fail (component != NULL); + g_return_if_fail (ATK_IS_COMPONENT (component)); + + iface = ATK_COMPONENT_GET_IFACE (component); + + if (iface->set_size) + (iface->set_size) (component, x, y); +} diff --git a/atk/atkcomponent.h b/atk/atkcomponent.h new file mode 100755 index 0000000..42c21e5 --- /dev/null +++ b/atk/atkcomponent.h @@ -0,0 +1,181 @@ +/* ATK - Accessibility Toolkit + * Copyright 2001 Sun Microsystems Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#ifndef __ATK_COMPONENT_H__ +#define __ATK_COMPONENT_H__ + +#include + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/* + * The AtkComponent interface should be supported by any object that is + * rendered on the screen. The interface provides the standard mechanism + * for an assistive technology to determine and set the graphical + * representation of an object. + */ + +#define ATK_TYPE_COMPONENT (atk_component_get_type ()) +#define ATK_IS_COMPONENT(obj) G_TYPE_CHECK_INSTANCE_TYPE ((obj), ATK_TYPE_COMPONENT) +#define ATK_COMPONENT(obj) G_TYPE_CHECK_INSTANCE_CAST ((obj), ATK_TYPE_COMPONENT, AtkComponent) +#define ATK_COMPONENT_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), ATK_TYPE_COMPONENT, AtkComponentIface)) + +#ifndef _TYPEDEF_ATK_COMPONENT_ +#define _TYPEDEF_ATK_COMPONENT_ +typedef struct _AtkComponent AtkComponent; +#endif + +typedef void (*AtkFocusHandler) (AtkObject*, gboolean); + + +struct _AtkComponentIface +{ + GTypeInterface parent; + + /* + * Add the specified handler to the set of functions to be called + * when this object receives focus (in or out) events. + */ + guint (* add_focus_handler) (AtkComponent *component, + AtkFocusHandler handler); + /* + * Checks whether the specified point is within the extent of the object, + * the points x and y coordinates are defined to be relative to the + * coordinate system of the object. + */ + gboolean (* contains) (AtkComponent *component, + gint x, + gint y); + + /* + * Gets the accessible child, if one exists, contained at the local + * coordinate point specified by x and y. + */ + AtkObject* (* get_accessible_at_point) (AtkComponent *component, + gint x, + gint y); + /* + * Gets the rectangle which gives the extent of the object. + */ + void (* get_extents) (AtkComponent *component, + gint *x, + gint *y, + gint *width, + gint *height); + /* + * Gets the position of the object relative to the parent in the form of + * a point specifying the object's top-left corner in the screen's + * coordinate space. + */ + void (* get_position) (AtkComponent *component, + gint *x, + gint *y); + /* + * Returns the position of the object on the screen + */ + void (* get_position_on_screen) (AtkComponent *component, + gint *root_x, + gint *root_y); + /* + * Returns the size of the object + */ + void (* get_size) (AtkComponent *component, + gint *width, + gint *height); + /* + * Grabs focus for this object + */ + void (* grab_focus) (AtkComponent *component); + /* + * Remove the handler specified by the handler_id from the list of + * functions to be executed when this object receives focus (in or out) + */ + void (* remove_focus_handler) (AtkComponent *component, + guint handler_id); + /* + * Sets the extents of the object + */ + void (* set_extents) (AtkComponent *component, + gint x, + gint y, + gint width, + gint height); + /* + * Set the position of the object + */ + void (* set_position) (AtkComponent *component, + gint x, + gint y); + /* + * Set the size of the object + */ + void (* set_size) (AtkComponent *component, + gint width, + gint height); +}; + +GType atk_component_get_type (); + +/* convenience functions */ + +guint atk_component_add_focus_handler (AtkComponent *component, + AtkFocusHandler handler); +gboolean atk_component_contains (AtkComponent *component, + gint x, + gint y); +AtkObject* atk_component_get_accessible_at_point(AtkComponent *component, + gint x, + gint y); +void atk_component_get_extents (AtkComponent *component, + gint *x, + gint *y, + gint *width, + gint *height); +void atk_component_get_position (AtkComponent *component, + gint *x, + gint *y); +void atk_component_get_position_on_screen (AtkComponent *component, + gint *x, + gint *y); +void atk_component_get_size (AtkComponent *component, + gint *width, + gint *height); +void atk_component_grab_focus (AtkComponent *component); +void atk_component_remove_focus_handler (AtkComponent *component, + guint handler_id); +void atk_component_set_extents (AtkComponent *component, + gint x, + gint y, + gint width, + gint height); +void atk_component_set_position (AtkComponent *component, + gint x, + gint y); +void atk_component_set_size (AtkComponent *component, + gint width, + gint height); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + + +#endif /* __ATK_COMPONENT_H__ */ diff --git a/atk/atkeditabletext.c b/atk/atkeditabletext.c new file mode 100755 index 0000000..2d65cc6 --- /dev/null +++ b/atk/atkeditabletext.c @@ -0,0 +1,225 @@ +/* ATK - The Accessibility Toolkit for GTK+ + * Copyright 2001 Sun Microsystems Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#include "atkeditabletext.h" + +enum { + TEXT_CHANGED, + CARET_MOVED, + LAST_SIGNAL +}; + +struct _AtkEditableTextIfaceClass +{ + GObjectClass parent; +}; + +typedef struct _AtkEditableTextIfaceClass AtkEditableTextIfaceClass; + +#if 0 +static void atk_editable_text_interface_init (AtkEditableTextIfaceClass *klass); + +static gpointer parent_class = NULL; +#endif + + +GType +atk_editable_text_get_type () +{ + static GType type = 0; + + if (!type) { + static const GTypeInfo tinfo = + { + sizeof (AtkEditableTextIface), + NULL, + NULL, + + }; + + type = g_type_register_static (G_TYPE_INTERFACE, "AtkEditableText", &tinfo, 0); + } + + return type; +} + +/* + * Additional GObject properties exported by AtkText: + * "accessible_text" (accessible text has changed) + * "accessible_caret" (accessible text cursor position changed: + * editable text only) + */ + +#if 0 +static void +atk_editable_text_interface_init (AtkEditableTextIfaceClass *klass) +{ + parent_class = g_type_class_ref (ATK_TYPE_EDITABLE_TEXT); + + /* Note that text_changed signal supports details "insert", "delete", possibly "replace". */ + + atk_signals[TEXT_CHANGED] = + g_signal_newc ("text_changed", + G_TYPE_FROM_CLASS (klass), + G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED, + G_STRUCT_OFFSET (AtkEditableTextClass, text_changed), /* still need to declare and define this func */ + NULL, + g_cclosure_marshal_VOID__UINT_POINTER, + G_TYPE_NONE, + 2, G_TYPE_UINT, ATK_TYPE_OBJECT); + + atk_signals[CARET_MOVED] = + g_signal_newc ("text_caret_moved", + G_TYPE_FROM_CLASS (klass), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (AtkTextClass, caret_changed), /* still need to declare and define this func */ + NULL, + g_cclosure_marshal_VOID__UINT_POINTER, + G_TYPE_NONE, + 2, G_TYPE_UINT, ATK_TYPE_OBJECT); +} +#endif + +void +atk_editable_text_select_text (AtkEditableText *text, + gint start_pos, + gint end_pos) +{ + AtkEditableTextIface *iface; + + g_return_if_fail (text != NULL); + g_return_if_fail (ATK_IS_EDITABLE_TEXT (text)); + + iface = ATK_EDITABLE_TEXT_GET_IFACE (text); + + if (iface->select_text) + (*(iface->select_text)) (text, start_pos, end_pos); +} + +void +atk_editable_text_set_attributes (AtkEditableText *text, + gint start_pos, + gint end_pos, + PangoAttrList *attributes) +{ + AtkEditableTextIface *iface; + + g_return_if_fail (text != NULL); + g_return_if_fail (ATK_IS_EDITABLE_TEXT (text)); + + iface = ATK_EDITABLE_TEXT_GET_IFACE (text); + + if (iface->set_attributes) + (*(iface->set_attributes)) (text, start_pos, end_pos, attributes); +} + +void +atk_editable_text_set_text_contents (AtkEditableText *text, + const gchar *string) +{ + AtkEditableTextIface *iface; + + g_return_if_fail (text != NULL); + g_return_if_fail (ATK_IS_EDITABLE_TEXT (text)); + + iface = ATK_EDITABLE_TEXT_GET_IFACE (text); + + if (iface->set_text_contents) + (*(iface->set_text_contents)) (text, string); +} + +void +atk_editable_text_insert_text (AtkEditableText *text, + const gchar *string, + gint length, + gint *position) +{ + AtkEditableTextIface *iface; + + g_return_if_fail (text != NULL); + g_return_if_fail (ATK_IS_EDITABLE_TEXT (text)); + + iface = ATK_EDITABLE_TEXT_GET_IFACE (text); + + if (iface->insert_text) + (*(iface->insert_text)) (text, string, length, position); +} + +void +atk_editable_text_copy_text (AtkEditableText *text, + gint start_pos, + gint end_pos) +{ + AtkEditableTextIface *iface; + + g_return_if_fail (text != NULL); + g_return_if_fail (ATK_IS_EDITABLE_TEXT (text)); + + iface = ATK_EDITABLE_TEXT_GET_IFACE (text); + + if (iface->copy_text) + (*(iface->copy_text)) (text, start_pos, end_pos); +} + +void +atk_editable_text_cut_text (AtkEditableText *text, + gint start_pos, + gint end_pos) +{ + AtkEditableTextIface *iface; + + g_return_if_fail (text != NULL); + g_return_if_fail (ATK_IS_EDITABLE_TEXT (text)); + + iface = ATK_EDITABLE_TEXT_GET_IFACE (text); + + if (iface->cut_text) + (*(iface->cut_text)) (text, start_pos, end_pos); +} + +void +atk_editable_text_delete_text (AtkEditableText *text, + gint start_pos, + gint end_pos) +{ + AtkEditableTextIface *iface; + + g_return_if_fail (text != NULL); + g_return_if_fail (ATK_IS_EDITABLE_TEXT (text)); + + iface = ATK_EDITABLE_TEXT_GET_IFACE (text); + + if (iface->delete_text) + (*(iface->delete_text)) (text, start_pos, end_pos); +} + +void +atk_editable_text_paste_text (AtkEditableText *text, + gint position) +{ + AtkEditableTextIface *iface; + + g_return_if_fail (text != NULL); + g_return_if_fail (ATK_IS_EDITABLE_TEXT (text)); + + iface = ATK_EDITABLE_TEXT_GET_IFACE (text); + + if (iface->paste_text) + (*(iface->paste_text)) (text, position); +} diff --git a/atk/atkeditabletext.h b/atk/atkeditabletext.h new file mode 100755 index 0000000..cab9b6a --- /dev/null +++ b/atk/atkeditabletext.h @@ -0,0 +1,106 @@ +/* ATK - Accessibility Toolkit + * Copyright 2001 Sun Microsystems Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#ifndef __ATK_EDITABLE_TEXT_H__ +#define __ATK_EDITABLE_TEXT_H__ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/* + * AtkEditableText is used to support access in an "accessibility" context + * to editing features of editable text widgets. + */ + +#define ATK_TYPE_EDITABLE_TEXT (atk_editable_text_get_type ()) +#define ATK_IS_EDITABLE_TEXT(obj) G_TYPE_CHECK_INSTANCE_TYPE ((obj), ATK_TYPE_EDITABLE_TEXT) +#define ATK_EDITABLE_TEXT(obj) G_TYPE_CHECK_INSTANCE_CAST ((obj), ATK_TYPE_EDITABLE_TEXT, AtkEditableText) +#define ATK_EDITABLE_TEXT_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), ATK_TYPE_EDITABLE_TEXT, AtkEditableTextIface)) + +#ifndef _TYPEDEF_ATK_EDITABLE_TEXT_ +#define _TYPEDEF_ATK_EDITABLE_TEXT_ +typedef struct _AtkEditableText AtkEditableText; +#endif + +struct _AtkEditableTextIface +{ + GTypeInterface parent_interface; + + void (* select_text) (AtkEditableText *text, + gint start_pos, + gint end_pos); + void (* set_attributes) (AtkEditableText *text, + gint start_pos, + gint end_pos, + PangoAttrList *attributes); + void (* set_text_contents) (AtkEditableText *text, + const gchar *string); + void (* insert_text) (AtkEditableText *text, + const gchar *string, + gint length, + gint *position); + void (* copy_text) (AtkEditableText *text, + gint start_pos, + gint end_pos); + void (* cut_text) (AtkEditableText *text, + gint start_pos, + gint end_pos); + void (* delete_text) (AtkEditableText *text, + gint start_pos, + gint end_pos); + void (* paste_text) (AtkEditableText *text, + gint position); +}; +GType atk_editable_text_get_type (void); + +void atk_editable_text_select_text (AtkEditableText *text, + gint start_pos, + gint end_pos); +void atk_editable_text_set_attributes (AtkEditableText *text, + gint start_pos, + gint end_pos, + PangoAttrList *attributes); +void atk_editable_text_set_text_contents (AtkEditableText *text, + const gchar *string); +void atk_editable_text_insert_text (AtkEditableText *text, + const gchar *string, + gint length, + gint *position); +void atk_editable_text_copy_text (AtkEditableText *text, + gint start_pos, + gint end_pos); +void atk_editable_text_cut_text (AtkEditableText *text, + gint start_pos, + gint end_pos); +void atk_editable_text_delete_text (AtkEditableText *text, + gint start_pos, + gint end_pos); +void atk_editable_text_paste_text (AtkEditableText *text, + gint position); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + + +#endif /* __ATK_EDITABLE_TEXT_H__ */ diff --git a/atk/atkhyperlink.c b/atk/atkhyperlink.c new file mode 100755 index 0000000..cfef2e5 --- /dev/null +++ b/atk/atkhyperlink.c @@ -0,0 +1,160 @@ +/* ATK - Accessibility Toolkit + * Copyright 2001 Sun Microsystems Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#include "atkhyperlink.h" + + +static void atk_hyperlink_class_init (AtkHyperlinkClass *klass); +static void atk_hyperlink_init (AtkHyperlink *link, + AtkHyperlinkClass *klass); + +static void atk_hyperlink_action_iface_init (AtkActionIface *iface); + +static gpointer parent_class = NULL; + +GType +atk_hyperlink_get_type (void) +{ + static GType type = 0; + + if (!type) + { + static const GTypeInfo typeInfo = + { + sizeof (AtkHyperlinkClass), + (GBaseInitFunc) NULL, + (GBaseFinalizeFunc) NULL, + (GClassInitFunc) atk_hyperlink_class_init, + (GClassFinalizeFunc) NULL, + NULL, + sizeof (AtkObject), + 0, + (GInstanceInitFunc) atk_hyperlink_init, + } ; + + static const GInterfaceInfo action_info = + { + (GInterfaceInitFunc) atk_hyperlink_action_iface_init, + (GInterfaceFinalizeFunc) NULL, + NULL + }; + + type = g_type_register_static (G_TYPE_OBJECT, "AtkHyperlink", &typeInfo, 0) ; + g_type_add_interface_static (type, ATK_TYPE_ACTION, &action_info); + } + return type; +} + +static void +atk_hyperlink_class_init (AtkHyperlinkClass *klass) +{ + parent_class = g_type_class_ref (G_TYPE_OBJECT); + +} + +static void +atk_hyperlink_init (AtkHyperlink *link, + AtkHyperlinkClass *klass) +{ +} + +GObject* +atk_hyperlink_get_anchor (AtkHyperlink *link, + gint i) +{ + AtkHyperlinkClass *klass; + + g_return_val_if_fail ((link != NULL), NULL); + g_return_val_if_fail (ATK_IS_HYPERLINK (link), NULL); + + klass = ATK_HYPERLINK_GET_CLASS (link); + g_return_val_if_fail ((klass->get_anchor != NULL), NULL); + + return (klass->get_anchor) (link, i); +} + +GObject* +atk_hyperlink_get_object (AtkHyperlink *link, + gint i) +{ + AtkHyperlinkClass *klass; + + g_return_val_if_fail ((link != NULL), NULL); + g_return_val_if_fail (ATK_IS_HYPERLINK (link), NULL); + + klass = ATK_HYPERLINK_GET_CLASS (link); + g_return_val_if_fail ((klass->get_object != NULL), NULL); + + return (klass->get_object) (link, i); +} + +gint +atk_hyperlink_get_end_index (AtkHyperlink *link) +{ + AtkHyperlinkClass *klass; + + g_return_val_if_fail ((link != NULL), 0); + g_return_val_if_fail (ATK_IS_HYPERLINK (link), 0); + + klass = ATK_HYPERLINK_GET_CLASS (link); + g_return_val_if_fail ((klass->get_end_index != NULL), 0); + + return (klass->get_end_index) (link); +} + +gint +atk_hyperlink_get_start_index (AtkHyperlink *link) +{ + AtkHyperlinkClass *klass; + + g_return_val_if_fail ((link != NULL), 0); + g_return_val_if_fail (ATK_IS_HYPERLINK (link), 0); + + klass = ATK_HYPERLINK_GET_CLASS (link); + g_return_val_if_fail ((klass->get_start_index != NULL), 0); + + return (klass->get_end_index) (link); +} + +gboolean +atk_hyperlink_get_is_valid (AtkHyperlink *link) +{ + AtkHyperlinkClass *klass; + + g_return_val_if_fail ((link != NULL), FALSE); + g_return_val_if_fail (ATK_IS_HYPERLINK (link), FALSE); + + klass = ATK_HYPERLINK_GET_CLASS (link); + g_return_val_if_fail ((klass->is_valid != NULL), FALSE); + + return (klass->is_valid) (link); +} + +static void atk_hyperlink_action_iface_init (AtkActionIface *iface) +{ + /* + * We do nothing here + * + * When we come to derive a class from AtkHyperlink we will provide an + * implementation of the AtkAction interface. + * + * This depends on being able to override an interface in a derived class + * which currently (March 2001) is not implemented but will be in GTK+ 2.0. + */ +} diff --git a/atk/atkhyperlink.h b/atk/atkhyperlink.h new file mode 100755 index 0000000..39b3511 --- /dev/null +++ b/atk/atkhyperlink.h @@ -0,0 +1,102 @@ +/* ATK - Accessibility Toolkit + * Copyright 2001 Sun Microsystems Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#ifndef __ATK_HYPERLINK_H__ +#define __ATK_HYPERLINK_H__ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#include + +/* + * AtkHyperLink encapsulates a link or set of links in a hypertext document. + * + * It implements the AtkAction interface. + */ + +#define ATK_TYPE_HYPERLINK (atk_hyperlink_get_type ()) +#define ATK_HYPERLINK(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ATK_TYPE_HYPERLINK, AtkHyperlink)) +#define ATK_HYPERLINK_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ATK_TYPE_HYPERLINK, AtkHyperlinkClass)) +#define ATK_IS_HYPERLINK(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ATK_TYPE_HYPERLINK)) +#define ATK_IS_HYPERLINK_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), ATK_TYPE_HYPERLINK)) +#define ATK_HYPERLINK_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), ATK_TYPE_HYPERLINK, AtkHyperlinkClass)) + +typedef struct _AtkHyperlink AtkHyperlink; +typedef struct _AtkHyperlinkClass AtkHyperlinkClass; + +struct _AtkHyperlink +{ + GObject parent; +}; + +struct _AtkHyperlinkClass +{ + GObjectClass parent; + + /* + * Returns an object which represents the link anchor, as appropriate for + * that link. + */ + GObject* (* get_anchor) (AtkHyperlink *link, + gint i); + /* + * Returns an object which represents the link action, as appropriate for + * that link. + */ + GObject* (* get_object) (AtkHyperlink *link, + gint i); + /* + * Gets the index with the hypertext document at which this link ends + */ + gint (* get_end_index) (AtkHyperlink *link); + /* + * Gets the index with the hypertext document at which this link begins + */ + gint (* get_start_index) (AtkHyperlink *link); + /* + * Since the document a link is associated with may have changed, this + * method returns whether or not this link is still valid (with respect + * to the document is references) + */ + gboolean (* is_valid) (AtkHyperlink *link); +}; + +GType atk_hyperlink_get_type (void); + +GObject* atk_hyperlink_get_anchor (AtkHyperlink *link, + gint i); + +GObject* atk_hyperlink_get_object (AtkHyperlink *link, + gint i); + +gint atk_hyperlink_get_end_index (AtkHyperlink *link); + +gint atk_hyperlink_get_start_index (AtkHyperlink *link); + +gboolean atk_hyperlink_is_valid (AtkHyperlink *link); + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + + +#endif /* __ATK_HYPERLINK_H__ */ diff --git a/atk/atkhypertext.c b/atk/atkhypertext.c new file mode 100755 index 0000000..01af03b --- /dev/null +++ b/atk/atkhypertext.c @@ -0,0 +1,112 @@ +/* ATK - The Accessibility Toolkit for GTK+ + * Copyright 2001 Sun Microsystems Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#include "atkhypertext.h" + +struct _AtkHypertextIfaceClass +{ + GObjectClass parent; +}; + +typedef struct _AtkHypertextIfaceClass AtkHypertextIfaceClass; + +static void atk_hypertext_interface_init (AtkHypertextIfaceClass *klass); + +static gpointer parent_class = NULL; + + +GType +atk_hypertext_get_type () +{ + static GType type = 0; + + if (!type) { + static const GTypeInfo tinfo = + { + sizeof (AtkHypertextIface), + NULL, + NULL, + (GInterfaceInitFunc) atk_hypertext_interface_init, + }; + + type = g_type_register_static (G_TYPE_INTERFACE, "AtkHypertext", &tinfo, 0); + } + + return type; +} + + +/* + */ + +static void +atk_hypertext_interface_init (AtkHypertextIfaceClass *klass) +{ + parent_class = g_type_class_ref (ATK_TYPE_HYPERTEXT); +} + +AtkHyperLink* +atk_hypertext_get_link (AtkHypertext *hypertext, + gint link_index) +{ + AtkHypertextIface *iface; + + g_return_val_if_fail (hypertext != NULL, NULL); + g_return_val_if_fail (ATK_IS_HYPERTEXT (hypertext), NULL); + + iface = ATK_HYPERTEXT_GET_IFACE (hypertext); + + if (iface->get_link) + return (*(iface->get_link)) (hypertext, link_index); + else + return NULL; +} + +gint +atk_hypertext_get_n_links (AtkHypertext *hypertext) +{ + AtkHypertextIface *iface; + + g_return_val_if_fail (hypertext != NULL, 0); + g_return_val_if_fail (ATK_IS_HYPERTEXT (hypertext), 0); + + iface = ATK_HYPERTEXT_GET_IFACE (hypertext); + + if (iface->get_n_links) + return (*(iface->get_n_links)) (hypertext); + else + return 0; +} + +gint +atk_hypertext_get_link_index (AtkHypertext *hypertext, + gint char_index) +{ + AtkHypertextIface *iface; + + g_return_val_if_fail (hypertext != NULL, -1); + g_return_val_if_fail (ATK_IS_HYPERTEXT (hypertext), -1); + + iface = ATK_HYPERTEXT_GET_IFACE (hypertext); + + if (iface->get_link_index) + return (*(iface->get_link_index)) (hypertext, char_index); + else + return -1; +} diff --git a/atk/atkhypertext.h b/atk/atkhypertext.h new file mode 100755 index 0000000..e69f638 --- /dev/null +++ b/atk/atkhypertext.h @@ -0,0 +1,87 @@ +/* ATK - Accessibility Toolkit + * Copyright 2001 Sun Microsystems Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#ifndef __ATK_HYPERTEXT_H__ +#define __ATK_HYPERTEXT_H__ + +#include + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/* The AtkHypertext class is the base class for all classes that present + * hypertext information on the display. This class provides the standard + * mechanism for an assistive technology to access that text via its + * content, attributes, and spatial location. It also provides standard + * mechanisms for manipulating hyperlinks. + * + * I do not think that there is a GTK+ widget for this but I assume that + * there will be a custom widget so we define the interface. + */ + +#define ATK_TYPE_HYPERTEXT (atk_hypertext_get_type ()) +#define ATK_IS_HYPERTEXT(obj) G_TYPE_CHECK_INSTANCE_TYPE ((obj), ATK_TYPE_HYPERTEXT) +#define ATK_HYPERTEXT(obj) G_TYPE_CHECK_INSTANCE_CAST ((obj), ATK_TYPE_HYPERTEXT, AtkHypertext) +#define ATK_HYPERTEXT_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), ATK_TYPE_HYPERTEXT, AtkHypertextIface)) + +#ifndef _TYPEDEF_ATK_HYPERTEXT_ +#define _TYPEDEF_ATK_HYPERTEXT_ +typedef struct _AtkHypertext AtkHypertext; +#endif + +typedef struct _AtkHyperLink AtkHyperLink; + +struct _AtkHypertextIface +{ + GTypeInterface parent; + + /* + * Returns the nth link of this hypertext document + */ + AtkHyperLink*(* get_link) (AtkHypertext *hypertext, + gint link_index); + /* + * Returns the number of links within this hypertext document. + */ + gint (* get_n_links) (AtkHypertext *hypertext); + /* + * Returns the index into the array of hyperlinks that is associated + * this character index, or -1 if there is no hyperlink associated with + * this index. + */ + gint (* get_link_index) (AtkHypertext *hypertext, + gint char_index); + +}; +GType atk_hypertext_get_type (void); + +AtkHyperLink* atk_hypertext_get_link (AtkHypertext *hypertext, + gint link_index); +gint atk_hypertext_get_n_links (AtkHypertext *hypertext); +gint atk_hypertext_get_link_index (AtkHypertext *hypertext, + gint char_index); + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + + +#endif /* __ATK_HYPERTEXT_H__ */ diff --git a/atk/atkimage.c b/atk/atkimage.c new file mode 100755 index 0000000..4736c50 --- /dev/null +++ b/atk/atkimage.c @@ -0,0 +1,169 @@ +/* ATK - Accessibility Toolkit + * Copyright 2001 Sun Microsystems Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +/* Superseded by atkimage.c */ +#include "atkimage.h" + +GType +atk_image_get_type () +{ + static GType type = 0; + + if (!type) { + static const GTypeInfo tinfo = + { + sizeof (AtkImageIface), + NULL, + NULL, + + }; + + type = g_type_register_static (G_TYPE_INTERFACE, "AtkImage", &tinfo, 0); + } + + return type; +} + +/** + * atk_image_get_storage_type: + * @value: a GObject instance that implements AtkImageIface + * @return: a AtkStorageType representing the image storage type, or 0 + * if value does not implement this interface. + * + * WARNING: callers should not rely on %NULL or on a zero value for + * indication of whether AtkImageIface is implemented, they should + * use type checking/interface checking macros or the + * atk_get_accessible_image() convenience method. + **/ +AtkImageType +atk_image_get_storage_type (AtkImage *obj) +{ + AtkImageIface *iface; + + g_return_val_if_fail (obj != NULL, 0); + g_return_val_if_fail (ATK_IS_IMAGE (obj), 0); + + iface = ATK_IMAGE_GET_IFACE (obj); + + if (iface->get_storage_type) + return (iface->get_storage_type) (obj); + else + return 0; +} + +/** + * atk_image_get_image_description: + * @value: a GObject instance that implements AtkImageIface + * @return: a gchar* representing the image description, or NULL + * if value does not implement this interface. + * + * WARNING: callers should not rely on %NULL or on a zero value for + * indication of whether AtkImageIface is implemented, they should + * use type checking/interface checking macros or the + * atk_get_accessible_image() convenience method. + **/ +G_CONST_RETURN gchar* +atk_image_get_image_description (AtkImage *obj) +{ + AtkImageIface *iface; + + g_return_val_if_fail (obj != NULL, NULL); + g_return_val_if_fail (ATK_IS_IMAGE (obj), NULL); + + iface = ATK_IMAGE_GET_IFACE (obj); + + if (iface->get_image_description) + return (iface->get_image_description) (obj); + else + return NULL; +} + +/** + * atk_image_get_image_height: + * @value: a GObject instance that implements AtkImageIface + * @return: a gint representing the image height, or 0 + * if value does not implement this interface. + * + * WARNING: callers should not rely on %NULL or on a zero value for + * indication of whether AtkImageIface is implemented, they should + * use type checking/interface checking macros or the + * atk_get_accessible_image() convenience method. + **/ +gint +atk_image_get_image_height (AtkImage *obj) +{ + AtkImageIface *iface; + + g_return_val_if_fail (obj != NULL, 0); + g_return_val_if_fail (ATK_IS_IMAGE (obj), 0); + + iface = ATK_IMAGE_GET_IFACE (obj); + + if (iface->get_image_height) + return (iface->get_image_height) (obj); + else + return 0; +} + +/** + * atk_image_get_image_width: + * @value: a GObject instance that implements AtkImageIface + * @return: a gint representing the image width, or 0 + * if value does not implement this interface. + * + * WARNING: callers should not rely on %NULL or on a zero value for + * indication of whether AtkImageIface is implemented, they should + * use type checking/interface checking macros or the + * atk_get_accessible_image() convenience method. + **/ +gint +atk_image_get_image_width (AtkImage *obj) +{ + AtkImageIface *iface; + + g_return_val_if_fail (obj != NULL, 0); + g_return_val_if_fail (ATK_IS_IMAGE (obj), 0); + + iface = ATK_IMAGE_GET_IFACE (obj); + + if (iface->get_image_width) + return (iface->get_image_width) (obj); + else + return 0; +} + +/** + * atk_image_set_image_description: + * @value: a GObject instance that implements AtkImageIface + * @return: void + **/ +void +atk_image_set_image_description (AtkImage *obj, + const gchar *description) +{ + AtkImageIface *iface; + + g_return_if_fail (obj != NULL); + g_return_if_fail (ATK_IS_IMAGE (obj)); + + iface = ATK_IMAGE_GET_IFACE (obj); + + if (iface->set_image_description) + (iface->set_image_description) (obj, description); +} diff --git a/atk/atkimage.h b/atk/atkimage.h new file mode 100755 index 0000000..51ec881 --- /dev/null +++ b/atk/atkimage.h @@ -0,0 +1,100 @@ +/* ATK - Accessibility Toolkit + * Copyright 2001 Sun Microsystems Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#ifndef __ATK_IMAGE_H__ +#define __ATK_IMAGE_H__ + +#include + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/* + * The AtkImage interface should be supported by any object that has an + * associated image. This interface provides the standard mechanism for + * an assistive technology to get descriptive information about images. + */ + +#define ATK_TYPE_IMAGE (atk_image_get_type ()) +#define ATK_IS_IMAGE(obj) G_TYPE_CHECK_INSTANCE_TYPE ((obj), ATK_TYPE_IMAGE) +#define ATK_IMAGE(obj) G_TYPE_CHECK_INSTANCE_CAST ((obj), ATK_TYPE_IMAGE, AtkImage) +#define ATK_IMAGE_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), ATK_TYPE_IMAGE, AtkImageIface)) + +#ifndef _TYPEDEF_ATK_IMAGE_ +#define _TYPEDEF_ATK_IMAGE_ +typedef struct _AtkImage AtkImage; +#endif + +typedef enum +{ + ATK_IMAGE_EMPTY, + ATK_IMAGE_PIXMAP, + ATK_IMAGE_IMAGE, + ATK_IMAGE_PIXBUF, + ATK_IMAGE_STOCK, + ATK_IMAGE_ICON_SET +} AtkImageType; + +struct _AtkImageIface +{ + GTypeInterface parent; + + /* + * Gets the type of representation being used to store image data + */ + AtkImageType (*get_storage_type) (AtkImage *image); + /* + * Gets the description of the image + */ + G_CONST_RETURN gchar* ( *get_image_description) (AtkImage *image); + /* + * Gets the height of the image + */ + gint ( *get_image_height) (AtkImage *image); + /* + * Gets the width of the image + */ + gint ( *get_image_width) (AtkImage *image); + /* + * Sets the description of the image + */ + void ( *set_image_description) (AtkImage *image, + const gchar *description); + +}; +GType atk_image_get_type (void); + +AtkImageType atk_image_get_storage_type (AtkImage *image); +G_CONST_RETURN gchar* atk_image_get_image_description (AtkImage *image); + +gint atk_image_get_image_height (AtkImage *image); + +gint atk_image_get_image_width (AtkImage *image); + +void atk_image_set_image_description (AtkImage *image, + const gchar *description); + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + + +#endif /* __ATK_IMAGE_H__ */ diff --git a/atk/atknoopobject.c b/atk/atknoopobject.c new file mode 100644 index 0000000..b786ba2 --- /dev/null +++ b/atk/atknoopobject.c @@ -0,0 +1,146 @@ +/* ATK - Accessibility Toolkit + * Copyright 2001 Sun Microsystems Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#include "atk.h" +#include "atknoopobject.h" + +static void atk_no_op_object_class_init (AtkNoOpObjectClass *klass); + +static gpointer parent_class = NULL; + + +GType +atk_no_op_object_get_type (void) +{ + static GType type = 0; + + if (!type) + { + static const GTypeInfo tinfo = + { + sizeof (AtkObjectClass), + (GBaseInitFunc) NULL, /* base init */ + (GBaseFinalizeFunc) NULL, /* base finalize */ + (GClassInitFunc) atk_no_op_object_class_init, /* class init */ + (GClassFinalizeFunc) NULL, /* class finalize */ + NULL, /* class data */ + sizeof (AtkNoOpObject), /* instance size */ + 0, /* nb preallocs */ + (GInstanceInitFunc) NULL, /* instance init */ + NULL /* value table */ + }; + + static const GInterfaceInfo atk_component_info = + { + (GInterfaceInitFunc) NULL, + (GInterfaceFinalizeFunc) NULL, + NULL + }; + + static const GInterfaceInfo atk_action_info = + { + (GInterfaceInitFunc) NULL, + (GInterfaceFinalizeFunc) NULL, + NULL + }; + + static const GInterfaceInfo atk_editable_text_info = + { + (GInterfaceInitFunc) NULL, + (GInterfaceFinalizeFunc) NULL, + NULL + }; + + static const GInterfaceInfo atk_image_info = + { + (GInterfaceInitFunc) NULL, + (GInterfaceFinalizeFunc) NULL, + NULL + }; + + static const GInterfaceInfo atk_selection_info = + { + (GInterfaceInitFunc) NULL, + (GInterfaceFinalizeFunc) NULL, + NULL + }; + + static const GInterfaceInfo atk_table_info = + { + (GInterfaceInitFunc) NULL, + (GInterfaceFinalizeFunc) NULL, + NULL + }; + + static const GInterfaceInfo atk_text_info = + { + (GInterfaceInitFunc) NULL, + (GInterfaceFinalizeFunc) NULL, + NULL + }; + + static const GInterfaceInfo atk_value_info = + { + (GInterfaceInitFunc) NULL, + (GInterfaceFinalizeFunc) NULL, + NULL + }; + + + type = g_type_register_static (ATK_TYPE_OBJECT, + "AtkNoOpObject", &tinfo, 0); + g_type_add_interface_static (type, ATK_TYPE_COMPONENT, + &atk_component_info); + g_type_add_interface_static (type, ATK_TYPE_ACTION, + &atk_action_info); + g_type_add_interface_static (type, ATK_TYPE_EDITABLE_TEXT, + &atk_editable_text_info); + g_type_add_interface_static (type, ATK_TYPE_IMAGE, + &atk_image_info); + g_type_add_interface_static (type, ATK_TYPE_SELECTION, + &atk_selection_info); + g_type_add_interface_static (type, ATK_TYPE_TABLE, + &atk_table_info); + g_type_add_interface_static (type, ATK_TYPE_TEXT, + &atk_text_info); + g_type_add_interface_static (type, ATK_TYPE_VALUE, + &atk_value_info); + } + return type; +} + +static void +atk_no_op_object_class_init (AtkNoOpObjectClass *klass) +{ + parent_class = g_type_class_ref (ATK_TYPE_OBJECT); +} + +AtkObject* +atk_no_op_object_new (GObject *obj) +{ + AtkObject* accessible; + + g_return_val_if_fail ((obj != NULL), NULL); + + accessible = g_object_new (ATK_TYPE_NO_OP_OBJECT, NULL); + g_return_val_if_fail ((accessible != NULL), NULL); + + return accessible; +} + diff --git a/atk/atknoopobject.h b/atk/atknoopobject.h new file mode 100644 index 0000000..0a12fe9 --- /dev/null +++ b/atk/atknoopobject.h @@ -0,0 +1,57 @@ +/* ATK - Accessibility Toolkit + * Copyright 2001 Sun Microsystems Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#ifndef __ATK_NO_OP_OBJECT_H__ +#define __ATK_NO_OP_OBJECT_H__ + + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#define ATK_TYPE_NO_OP_OBJECT (atk_no_op_object_get_type ()) +#define ATK_NO_OP_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ATK_TYPE_NO_OP_OBJECT, AtkNoOpObject)) +#define ATK_NO_OP_OBJECT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ATK_TYPE_NO_OP_OBJECT, AtkNoOpObjectClass)) +#define ATK_IS_NO_OP_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ATK_TYPE_NO_OP_OBJECT)) +#define ATK_IS_NO_OP_OBJECT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), ATK_TYPE_NO_OP_OBJECT)) +#define ATK_NO_OP_OBJECT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), ATK_TYPE_NO_OP_OBJECT, AtkNoOpObjectClass)) + +typedef struct _AtkNoOpObject AtkNoOpObject; +typedef struct _AtkNoOpObjectClass AtkNoOpObjectClass; + +struct _AtkNoOpObject +{ + AtkObject parent; +}; + +GType agtk_widget_get_type (void); + +struct _AtkNoOpObjectClass +{ + AtkObjectClass parent_class; +}; + +AtkObject *atk_no_op_object_new (GObject *obj); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + + +#endif /* __ATK_NO_OP_OBJECT_H__ */ diff --git a/atk/atknoopobjectfactory.c b/atk/atknoopobjectfactory.c new file mode 100755 index 0000000..0b0547a --- /dev/null +++ b/atk/atknoopobjectfactory.c @@ -0,0 +1,89 @@ +/* ATK - Accessibility Toolkit + * Copyright 2001 Sun Microsystems Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#include "atkobject.h" +#include "atknoopobject.h" +#include "atknoopobjectfactory.h" + +static void atk_no_op_object_factory_class_init ( + AtkNoOpObjectFactoryClass *klass); + +static AtkObject* atk_no_op_object_factory_create_accessible ( + GObject *obj); + +static AtkNoOpObjectFactoryClass *parent_class = NULL; + +GType +atk_no_op_object_factory_get_type () +{ + static GType type = 0; + + if (!type) + { + static const GTypeInfo tinfo = + { + sizeof (AtkNoOpObjectFactoryClass), + (GBaseInitFunc) NULL, /* base init */ + (GBaseFinalizeFunc) NULL, /* base finalize */ + (GClassInitFunc) atk_no_op_object_factory_class_init, /* class init */ + (GClassFinalizeFunc) NULL, /* class finalize */ + NULL, /* class data */ + sizeof (AtkNoOpObjectFactory), /* instance size */ + 0, /* nb preallocs */ + (GInstanceInitFunc) NULL, /* instance init */ + NULL /* value table */ + }; + type = g_type_register_static ( + ATK_TYPE_OBJECT_FACTORY, + "AtkNoOpObjectFactory" , &tinfo, 0); + } + + return type; +} + +static void +atk_no_op_object_factory_class_init (AtkNoOpObjectFactoryClass *klass) +{ + AtkObjectFactoryClass *class = ATK_OBJECT_FACTORY_CLASS (klass); + + parent_class = g_type_class_ref (ATK_TYPE_OBJECT_FACTORY); + + class->create_accessible = atk_no_op_object_factory_create_accessible; +} + +AtkObjectFactory* +atk_no_op_object_factory_new () +{ + GObject *factory; + + factory = g_object_new (ATK_TYPE_NO_OP_OBJECT_FACTORY, NULL); + + g_return_val_if_fail (factory != NULL, NULL); + return ATK_OBJECT_FACTORY (factory); +} + +static AtkObject* +atk_no_op_object_factory_create_accessible (GObject *obj) +{ + AtkObject *accessible; + + accessible = atk_no_op_object_new (obj); + + return accessible; +} diff --git a/atk/atknoopobjectfactory.h b/atk/atknoopobjectfactory.h new file mode 100755 index 0000000..1df9231 --- /dev/null +++ b/atk/atknoopobjectfactory.h @@ -0,0 +1,58 @@ +/* ATK - Accessibility Toolkit + * Copyright 2001 Sun Microsystems Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#ifndef __ATK_NO_OP_OBJECT_FACTORY_H__ +#define __ATK_NO_OP_OBJECT_FACTORY_H__ + +#include + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#define ATK_TYPE_NO_OP_OBJECT_FACTORY (atk_no_op_object_factory_get_type ()) +#define ATK_NO_OP_OBJECT_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ATK_TYPE_NO_OP_OBJECT_FACTORY, AtkNoOpObjectFactory)) +#define ATK_NO_OP_OBJECT_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ATK_TYPE_NO_OP_OBJECT_FACTORY, AtkNoOpObjectFactoryClass)) +#define ATK_IS_NO_OP_OBJECT_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ATK_TYPE_NO_OP_OBJECT_FACTORY)) +#define ATK_IS_NO_OP_OBJECT_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), ATK_TYPE_NO_OP_OBJECT_FACTORY)) +#define ATK_NO_OP_OBJECT_FACTORY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ( (obj), ATK_TYPE_NO_OP_OBJECT_FACTORY, AtkNoOpObjectFactoryClass)) + +typedef struct _AtkNoOpObjectFactory AtkNoOpObjectFactory; +typedef struct _AtkNoOpObjectFactoryClass AtkNoOpObjectFactoryClass; + +struct _AtkNoOpObjectFactory +{ + AtkObjectFactory parent; +}; + +struct _AtkNoOpObjectFactoryClass +{ + AtkObjectFactoryClass parent_class; +}; + +GType atk_no_op_object_factory_get_type(); + +AtkObjectFactory *atk_no_op_object_factory_new(); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + + +#endif /* __ATK_NO_OP_OBJECT_FACTORY_H__ */ diff --git a/atk/atkobject.c b/atk/atkobject.c new file mode 100755 index 0000000..42bb1b5 --- /dev/null +++ b/atk/atkobject.c @@ -0,0 +1,799 @@ +/* ATK - Accessibility Toolkit + * Copyright 2001 Sun Microsystems Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#include + +#include "atk.h" + +#define NUM_POSSIBLE_STATES (sizeof(AtkStateMask)*8) + +/* New GObject properties registered by AtkObject */ +enum +{ + PROP_0, /* gobject convention */ + + PROP_NAME, + PROP_DESCRIPTION, + PROP_PARENT, /* ancestry has changed */ + PROP_CHILD, /* children have changed in number or identity */ + PROP_ROLE, /* AtkRole has changed */ + PROP_STATE, /* AtkState has changed */ + PROP_TEXT, /* Used only by AtkText implementors */ + PROP_CARET, /* Used only by AtkText implementors */ + PROP_LAST /* gobject convention */ +}; + +enum { + CHILDREN_CHANGED, + LAST_SIGNAL +}; + +struct _AtkRelationSet +{ + GArray *relations; +}; + +struct _AtkRelation +{ + GArray *target; + AtkRelationType relationship; +}; + + +typedef struct +{ + GObject object; +} _AtkIfaceImplementor; + +static void atk_object_class_init (AtkObjectClass *klass); +static void atk_object_init (AtkObject *accessible, + AtkObjectClass *klass); +static AtkRelationSet* atk_object_real_get_relation_set (AtkObject *accessible); + +static void atk_object_real_set_property(GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec); +static void atk_object_real_get_property(GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec); +static void atk_object_finalize (GObject *object); + +static gchar* state_names[NUM_POSSIBLE_STATES]; + +#if 0 +static guint atk_object_signals[LAST_SIGNAL] = { 0, }; +#endif + +static gpointer parent_class = NULL; + +static const gchar* atk_object_name_property_name = "accessible-name"; +static const gchar* atk_object_name_property_state = "accessible-state"; +static const gchar* atk_object_name_property_description = "accessible-description"; + +GType +atk_object_get_type (void) +{ + static GType type = 0; + + if (!type) + { + static const GTypeInfo typeInfo = + { + sizeof (AtkObjectClass), + (GBaseInitFunc) NULL, + (GBaseFinalizeFunc) NULL, + (GClassInitFunc) atk_object_class_init, + (GClassFinalizeFunc) NULL, + NULL, + sizeof (AtkObject), + 0, + (GInstanceInitFunc) atk_object_init, + } ; + type = g_type_register_static (G_TYPE_OBJECT, "AtkObject", &typeInfo, 0) ; + } + return type; +} + +static void +atk_object_class_init (AtkObjectClass *klass) +{ + GObjectClass *gobject_class = G_OBJECT_CLASS (klass); + + parent_class = g_type_class_ref (G_TYPE_OBJECT); + + gobject_class->set_property = atk_object_real_set_property; + gobject_class->get_property = atk_object_real_get_property; + gobject_class->finalize = atk_object_finalize; + + klass->get_relation_set = atk_object_real_get_relation_set; + + state_names[ATK_STATE_ARMED] = "armed"; + state_names[ATK_STATE_BUSY] = "busy"; + state_names[ATK_STATE_CHECKED] = "checked"; + state_names[ATK_STATE_COLLAPSED] = "collapsed"; + state_names[ATK_STATE_EDITABLE] = "editable"; + state_names[ATK_STATE_EXPANDABLE] = "expandable"; + state_names[ATK_STATE_EXPANDED] = "expanded"; + state_names[ATK_STATE_FOCUSABLE] = "focusable"; + state_names[ATK_STATE_FOCUSED] = "focused"; + state_names[ATK_STATE_HORIZONTAL] = "horizontal"; + state_names[ATK_STATE_ICONIFIED] = "iconified"; + state_names[ATK_STATE_MODAL] = "modal"; + state_names[ATK_STATE_MULTI_LINE] = "multi-line"; + state_names[ATK_STATE_MULTISELECTABLE] = "multiselectable"; + state_names[ATK_STATE_OPAQUE] = "opaque"; + state_names[ATK_STATE_PRESSED] = "pressed"; + state_names[ATK_STATE_RESIZABLE] = "resizeable"; + state_names[ATK_STATE_SELECTABLE] = "selectable"; + state_names[ATK_STATE_SELECTED] = "selected"; + state_names[ATK_STATE_SENSITIVE] = "sensitive"; + state_names[ATK_STATE_SHOWING] = "showing"; + state_names[ATK_STATE_SINGLE_LINE] = "single-line"; + state_names[ATK_STATE_TRANSIENT] = "transient"; + state_names[ATK_STATE_VERTICAL] = "vertical"; + state_names[ATK_STATE_VISIBLE] = "visible"; + + klass->children_changed = NULL; + + g_object_class_install_property (gobject_class, + PROP_NAME, + g_param_spec_string (atk_object_name_property_name, + "Accessible Name", + "Object instance\'s name formatted for " + "assistive technology access", + NULL, + G_PARAM_READWRITE)); + g_object_class_install_property (gobject_class, + PROP_DESCRIPTION, + g_param_spec_string (atk_object_name_property_description, + "Accessible Description", + "Description of an object, formatted for " + "assistive technology access", + NULL, + G_PARAM_READWRITE)); + g_object_class_install_property (gobject_class, + PROP_STATE, + g_param_spec_int (atk_object_name_property_state, + "Accessible State", + "The current state of this object " + "or its UI component", + 0, + G_MAXINT, + 0, + G_PARAM_WRITABLE)); +#if 0 + /* register some properties - these could be change signals instead */ + g_object_class_install_property (gobject_class, + PROP_PARENT, + g_param_spec_ccallback ("accessible_parent", "Accessible Parent", + "First accessible ancestor (container or object) " + "which this object is a descendant of", + G_PARAM_READWRITE)); + + + g_object_class_install_property (gobject_class, + PROP_ROLE, + g_param_spec_ccallback ("accessible_role", "Accessible Role", + "The user-interface role of this object", + G_PARAM_READWRITE)); + g_object_class_install_property (gobject_class, + PROP_STATE, + g_param_spec_ccallback ("accessible_state", "Accessible State", + "The current state of this object " + "or its UI component", + G_PARAM_READWRITE)); + g_object_class_install_property (gobject_class, + PROP_TEXT, + g_param_spec_ccallback ("accessible_text", "Accessible Text", + "This object\'s accessible text contents", + G_PARAM_READWRITE)); + g_object_class_install_property (gobject_class, + PROP_CARET, + g_param_spec_ccallback ("accessible_caret", "Accessible Text Caret", + "The current text caret state and position " + "for this component", + G_PARAM_READWRITE)); + gaccessible_signals[CHILDREN_CHANGED] = + g_signal_newc ("accessible_children_changed", + G_TYPE_FROM_CLASS (klass), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (AtkObjectClass, children_changed), /* still need to declare and define this func */ + NULL, + g_cclosure_marshal_VOID__UINT_POINTER, + G_TYPE_NONE, + 2, G_TYPE_UINT, ATK_TYPE_OBJECT); +#endif +} + +static void +atk_object_init (AtkObject *accessible, + AtkObjectClass *klass) +{ + accessible->relation_set = g_malloc (sizeof (AtkRelationSet)); + g_return_if_fail (accessible->relation_set != NULL); + accessible->relation_set->relations = NULL; +} + +GType +atk_object_iface_get_type (void) +{ + static GType type = 0; + + if (!type) + { + static const GTypeInfo typeInfo = + { + sizeof (AtkObjectIface), + (GBaseInitFunc) NULL, + (GBaseFinalizeFunc) NULL, + } ; + + type = g_type_register_static (G_TYPE_INTERFACE, "AtkObjectIface", &typeInfo, 0) ; + } + + return type; +} + +G_CONST_RETURN gchar* +atk_object_get_name (AtkObject *accessible) +{ + AtkObjectClass *klass; + + g_return_val_if_fail ((accessible != NULL), NULL); + g_return_val_if_fail (ATK_IS_OBJECT (accessible), NULL); + + klass = ATK_OBJECT_GET_CLASS (accessible); + if (klass->get_name) + return (klass->get_name) (accessible); + else + return NULL; +} + +G_CONST_RETURN gchar* +atk_object_get_description (AtkObject *accessible) +{ + AtkObjectClass *klass; + + g_return_val_if_fail ((accessible != NULL), NULL); + g_return_val_if_fail (ATK_IS_OBJECT (accessible), NULL); + + klass = ATK_OBJECT_GET_CLASS (accessible); + if (klass->get_description) + return (klass->get_description) (accessible); + else + return NULL; +} + +AtkObject* +atk_object_get_parent (AtkObject *accessible) +{ + AtkObjectClass *klass; + + g_return_val_if_fail ((accessible != NULL), NULL); + g_return_val_if_fail (ATK_IS_OBJECT (accessible), NULL); + + klass = ATK_OBJECT_GET_CLASS (accessible); + if (klass->get_parent) + return (klass->get_parent) (accessible); + else + return NULL; +} + +gint +atk_object_get_n_accessible_children (AtkObject *accessible) +{ + AtkObjectClass *klass; + + g_return_val_if_fail ((accessible != NULL), 0); + g_return_val_if_fail (ATK_IS_OBJECT (accessible), 0); + + klass = ATK_OBJECT_GET_CLASS (accessible); + if (klass->get_n_children) + return (klass->get_n_children) (accessible); + else + return 0; +} + +AtkObject* +atk_object_ref_accessible_child (AtkObject *accessible, + gint i) +{ + AtkObjectClass *klass; + + g_return_val_if_fail ((accessible != NULL), NULL); + g_return_val_if_fail (ATK_IS_OBJECT (accessible), NULL); + + klass = ATK_OBJECT_GET_CLASS (accessible); + if (klass->ref_child) + return (klass->ref_child) (accessible, i); + else + return NULL; +} + +AtkRelationSet* +atk_object_get_relation_set (AtkObject *accessible) +{ + AtkObjectClass *klass; + + g_return_val_if_fail ((accessible != NULL), NULL); + g_return_val_if_fail (ATK_IS_OBJECT (accessible), NULL); + + klass = ATK_OBJECT_GET_CLASS (accessible); + if (klass->get_relation_set) + return (klass->get_relation_set) (accessible); + else + return NULL; +} + +AtkRole +atk_role_register (gchar *name) +{ + /* TODO: associate name with new type */ + static guint type = ATK_ROLE_LAST_DEFINED; + return (++type); +} + +AtkRole +atk_object_get_role (AtkObject *accessible) { + AtkObjectClass *klass; + + g_return_val_if_fail ((accessible != NULL), ATK_ROLE_UNKNOWN); + g_return_val_if_fail (ATK_IS_OBJECT (accessible), ATK_ROLE_UNKNOWN); + + klass = ATK_OBJECT_GET_CLASS (accessible); + if (klass->get_role) + return (klass->get_role) (accessible); + else + return ATK_ROLE_UNKNOWN; +} + +AtkStateType +atk_state_type_register (gchar *name) +{ + /* TODO: associate name with new type */ + static guint type = ATK_STATE_LAST_DEFINED; + if (type < NUM_POSSIBLE_STATES) { + return (++type); + } + return ATK_STATE_INVALID; /* caller needs to check */ +} + +AtkState +atk_object_get_state (AtkObject *accessible) { + AtkObjectClass *klass; + + g_return_val_if_fail ((accessible != NULL), 0); + g_return_val_if_fail (ATK_IS_OBJECT (accessible), 0); + + klass = ATK_OBJECT_GET_CLASS (accessible); + if (klass->get_state) + return (klass->get_state) (accessible); + else + return 0; +} + +gint +atk_object_get_index_in_parent (AtkObject *accessible) +{ + AtkObjectClass *klass; + + g_return_val_if_fail ((accessible != NULL), -1); + g_return_val_if_fail (ATK_OBJECT (accessible), -1); + + klass = ATK_OBJECT_GET_CLASS (accessible); + if (klass->get_index_in_parent) + return (klass->get_index_in_parent) (accessible); + else + return -1; +} + +void +atk_object_set_name (AtkObject *accessible, + const gchar *name) +{ + AtkObjectClass *klass; + + g_return_if_fail ((accessible != NULL)); + g_return_if_fail (ATK_IS_OBJECT (accessible)); + g_return_if_fail ((name != NULL)); + + klass = ATK_OBJECT_GET_CLASS (accessible); + if (klass->set_name) + { + (klass->set_name) (accessible, name); + g_object_notify (G_OBJECT (accessible), atk_object_name_property_name); + } +} + +void +atk_object_set_description (AtkObject *accessible, + const gchar *description) +{ + AtkObjectClass *klass; + + g_return_if_fail ((accessible != NULL)); + g_return_if_fail (ATK_IS_OBJECT (accessible)); + g_return_if_fail ((description != NULL)); + + klass = ATK_OBJECT_GET_CLASS (accessible); + if (klass->set_description) + { + (klass->set_description) (accessible, description); + g_object_notify (G_OBJECT (accessible), atk_object_name_property_description); + } +} + +void +atk_object_set_parent (AtkObject *accessible, + AtkObject *parent) +{ + AtkObjectClass *klass; + + g_return_if_fail ((accessible != NULL)); + g_return_if_fail (ATK_IS_OBJECT (accessible)); + + klass = ATK_OBJECT_GET_CLASS (accessible); + if (klass->set_parent) + (klass->set_parent) (accessible, parent); +} + +void +atk_object_set_role (AtkObject *accessible, + AtkRole role) +{ + AtkObjectClass *klass; + + g_return_if_fail ((accessible != NULL)); + g_return_if_fail (ATK_IS_OBJECT (accessible)); + + klass = ATK_OBJECT_GET_CLASS (accessible); + if (klass->set_role) + (klass->set_role) (accessible, role); +} + +guint +atk_object_connect_property_change_handler (AtkObject *accessible, + AtkPropertyChangeHandler *handler) +{ + AtkObjectClass *klass; + + g_return_val_if_fail ((accessible != NULL), 0); + g_return_val_if_fail (ATK_IS_OBJECT (accessible), 0); + g_return_val_if_fail ((handler != NULL), 0); + + klass = ATK_OBJECT_GET_CLASS (accessible); + if (klass->connect_property_change_handler) + return (klass->connect_property_change_handler) (accessible, handler); + else + return 0; +} + +void +atk_object_remove_property_change_handler (AtkObject *accessible, + guint handler_id) +{ + AtkObjectClass *klass; + + g_return_if_fail ((accessible != NULL)); + g_return_if_fail (ATK_IS_OBJECT (accessible)); + + klass = ATK_OBJECT_GET_CLASS (accessible); + if (klass->remove_property_change_handler) + (klass->remove_property_change_handler) (accessible, handler_id); +} + +AtkRelationType +atk_relation_type_register (gchar *name) +{ + /* TODO: associate name with new type */ + static guint type = ATK_RELATION_LAST_DEFINED; + return (++type); +} + +AtkRelation* +atk_relation_new (GArray *target, + AtkRelationType relationship) +{ + AtkRelation* relation; + g_return_val_if_fail ((target != NULL), NULL); + + relation = (AtkRelation *) g_malloc (sizeof (AtkRelation)); + + g_return_val_if_fail ((relation != NULL), NULL); + + relation->target = target; + relation->relationship = relationship; + + return relation; +} + +gboolean +atk_relation_set_contains (AtkRelationSet *set, + AtkRelationType relationship) +{ + GArray *array_item; + AtkRelation *item; + gint i; + + g_return_val_if_fail ((set != NULL), FALSE); + + array_item = set->relations; + if (array_item == NULL) + return FALSE; + for (i = 0; i < array_item->len; i++) + { + item = g_array_index (array_item, AtkRelation*, i); + if (item->relationship == relationship) + return TRUE; + } + return FALSE; +} + +void +atk_relation_set_remove (AtkRelationSet *set, + AtkRelation *relation) +{ + GArray *array_item; + AtkRelation *item; + gint i; + + g_return_if_fail (set != NULL); + g_return_if_fail (relation != NULL); + + array_item = set->relations; + if (array_item == NULL) + return; + for (i = 0; i < array_item->len; i++) + { + item = g_array_index (array_item, AtkRelation*, i); + if (item == relation) + { + g_array_remove_index (array_item, i); + return; + } + } +} + +void +atk_relation_set_add (AtkRelationSet *set, + AtkRelation *relation) +{ + g_return_if_fail (set != NULL); + g_return_if_fail (relation != NULL); + + if (set->relations == NULL) + { + set->relations = g_array_new (FALSE, TRUE, sizeof (AtkRelation)); + } + set->relations = g_array_append_val (set->relations, relation); +} + +gint +atk_relation_set_get_n_relations (AtkRelationSet *set) +{ + g_return_val_if_fail (set != NULL, 0); + + if (set->relations == NULL) + return 0; + + return set->relations->len; +} + +AtkRelation* +atk_relation_set_get_relation (AtkRelationSet *set, + gint i) +{ + GArray *array_item; + AtkRelation* item; + + g_return_val_if_fail (set != NULL, NULL); + g_return_val_if_fail (i >= 0, NULL); + + array_item = set->relations; + if (array_item == NULL) + return NULL; + item = g_array_index (array_item, AtkRelation*, i); + if (item == NULL) + return NULL; + + return item; +} + +AtkRelation* +atk_relation_set_get_relation_by_type (AtkRelationSet *set, + AtkRelationType relationship) +{ + GArray *array_item; + AtkRelation *item; + gint i; + + g_return_val_if_fail (set != NULL, NULL); + + array_item = set->relations; + if (array_item == NULL) + return NULL; + for (i = 0; i < array_item->len; i++) + { + item = g_array_index (array_item, AtkRelation*, i); + if (item->relationship == relationship) + return item; + } + return NULL; +} + +AtkRelationType +atk_relation_get_type (AtkRelation *relation) +{ + g_return_val_if_fail (relation != NULL, 0); + return relation->relationship; +} + +GArray* +atk_relation_get_target (AtkRelation *relation) +{ + g_return_val_if_fail (relation != NULL, 0); + return relation->target; +} + +gchar* +atk_state_mask_get_name (AtkStateMask state) +{ + gint n; + + if (state == 0) + return NULL; + + for (n=0; n0), 0); + for (i=0; iref_accessible)) (object) ; + + g_return_val_if_fail ((accessible != NULL), NULL); + + return ATK_OBJECT (accessible) ; +} + +AtkRelationSet* +atk_object_real_get_relation_set (AtkObject *accessible) +{ + return accessible->relation_set; +} + +static void +atk_object_real_set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec) +{ + AtkObject *accessible; + + accessible = ATK_OBJECT (object); + + switch (prop_id) + { + case PROP_NAME: + atk_object_set_name (accessible, g_value_get_string (value)); + break; + case PROP_DESCRIPTION: + atk_object_set_description (accessible, g_value_get_string (value)); + break; + case PROP_STATE: + g_print ("This interface does not support setting the state of an accessible object\n"); + break; + default: + break; + } +} + +static void +atk_object_real_get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec) +{ + AtkObject *accessible; + + accessible = ATK_OBJECT (object); + + switch (prop_id) + { + case PROP_NAME: + g_value_set_string (value, atk_object_get_name (accessible)); + break; + case PROP_DESCRIPTION: + g_value_set_string (value, atk_object_get_description (accessible)); + break; + case PROP_STATE: + g_value_set_int (value, atk_object_get_state (accessible)); + break; + default: + break; + } +} + +static void +atk_object_finalize (GObject *object) +{ + AtkObject *accessible; + GArray *relations; + + g_return_if_fail (ATK_IS_OBJECT (object)); + + accessible = ATK_OBJECT (object); + + g_free (accessible->name); + g_free (accessible->description); + + /* + * Free memory allocated for relations and relation sets; + */ + relations = accessible->relation_set->relations; + if (relations) + { + gint len = relations->len; + gint i; + AtkRelation *relation; + + for (i = 0; i < len; i++) + { + relation = g_array_index (relations, AtkRelation*, i); + g_array_free (relation->target, TRUE); + } + g_array_free (relations, TRUE); + } + g_free (accessible->relation_set); + + G_OBJECT_CLASS (parent_class)->finalize (object); +} diff --git a/atk/atkobject.h b/atk/atkobject.h new file mode 100755 index 0000000..dba5452 --- /dev/null +++ b/atk/atkobject.h @@ -0,0 +1,646 @@ +/* ATK - Accessibility Toolkit + * Copyright 2001 Sun Microsystems Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#ifndef __ATK_OBJECT_H__ +#define __ATK_OBJECT_H__ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#include + +/* + * AtkObject represents the minimum information all accessible objects + * return. This information includes accessible name, accessible + * description, role and state of the object, as well information about + * its parent and children. It is also possible to obtain more specific + * accessibility information about a component if it supports one or more + * of the following interfaces: + */ +typedef enum +{ + ATK_CHILD_ADDED, + ATK_CHILD_REMOVED, + ATK_CHILD_CHANGED +} AtkChildChangeType; + +typedef enum +{ + ATK_ROLE_INVALID, + /* Object is used to alert the user about something */ + ATK_ROLE_ALERT, + /* Object that can be drawn into and is sued to trap events */ + ATK_ROLE_CANVAS, + /* + * A choice that can be checked or unchecked and provides a separate + * indicator for the current state. + */ + ATK_ROLE_CHECK_BOX, + /* A specialized dialog that lets the user choose a color. */ + ATK_ROLE_COLOR_CHOOSER, + /* The header for a column of data */ + ATK_ROLE_COLUMN_HEADER, + /* A list of choices the user can select from */ + ATK_ROLE_COMBO_BOX, + /* An inconifed internal frame within a DESKTOP_PANE */ + ATK_ROLE_DESKTOP_ICON, + /* + * A pane that supports internal frames and iconified versions of those + * internal frames. + */ + ATK_ROLE_DESKTOP_FRAME, + /* A top level window with title bar and a border */ + ATK_ROLE_DIALOG, + /* + * A pane that allows the user to navigate through and select the contents + * of a directory + */ + ATK_ROLE_DIRECTORY_PANE, + /* + * A specialized dialog that displays the files in the directory and lets + * the user select a file, browse a different directory, or specify a + * filename. + */ + ATK_ROLE_FILE_CHOOSER, + /* + * A object that fills up space in a user interface + */ + ATK_ROLE_FILLER, + /* XXX Don't know sure about this. */ + ATK_ROLE_FOCUS_TRAVERSABLE, + /* A top level window with a title bar, border, menubar, etc. */ + ATK_ROLE_FRAME, + /* A pane that is guaranteed to be painted on top of all panes beneath it */ + ATK_ROLE_GLASS_PANE, + /* + * A document container for HTML, whose children + * represent the document content. + */ + ATK_ROLE_HTML_CONTAINER, + /* A small fixed size picture, typically used to decorate components */ + ATK_ROLE_ICON, + /* A frame-like object that is clipped by a desktop pane. */ + ATK_ROLE_INTERNAL_FRAME, + /* An object used to present an icon or short string in an interface */ + ATK_ROLE_LABEL, + /* + * A specialized pane that allows its children to be drawn in layers, + * providing a form of stacking order. + */ + ATK_ROLE_LAYERED_PANE, + /* + * An object that presents a list of objects to the user and allows the + * user to select one or more of them. + */ + ATK_ROLE_LIST, + /* An object that represents an element of a list. */ + ATK_ROLE_LIST_ITEM, + /* + * An object usually found inside a menu bar that contains a list of + * actions the user can choose from. + */ + ATK_ROLE_MENU, + /* + * 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. + */ + ATK_ROLE_MENU_BAR, + /* + * An object usually contained in a menu that presents an action the + * user can choose. + */ + ATK_ROLE_MENU_ITEM, + /* A specialized pane whose primary use is inside a DIALOG */ + ATK_ROLE_OPTION_PANE, + /* An object that is a child of a page tab list */ + ATK_ROLE_PAGE_TAB, + /* + * An object that presents a series of panels (or page tabs), one at a time, + * through some mechanism provided by the object. + */ + ATK_ROLE_PAGE_TAB_LIST, + /* A generic container that is often used to group objects. */ + ATK_ROLE_PANEL, + /* + * A text object uses for passwords, or other places where the text + * content is not shown visibly to the user. + */ + ATK_ROLE_PASSWORD_TEXT, + /* + * 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. + */ + ATK_ROLE_POPUP_MENU, + /* An object used to indicate how much of a task has been completed. */ + ATK_ROLE_PROGRESS_BAR, + /* + * An object the user can manipulate to tell the application to do + * something. + */ + ATK_ROLE_PUSH_BUTTON, + /* + * A specialized check box that will cause other radio buttons in the + * same group to become uncghecked when this one is checked. + */ + ATK_ROLE_RADIO_BUTTON, + /* + * A specialized pane that has a glass pane and a layered pane as its + * children. + */ + ATK_ROLE_ROOT_PANE, + /* The header for a row of data */ + ATK_ROLE_ROW_HEADER, + /* + * An object usually used to allow a user to incrementally view a large + * amount of data. + */ + ATK_ROLE_SCROLL_BAR, + /* + * An object that allows a user to incrementally view a large amount + * of information. + */ + ATK_ROLE_SCROLL_PANE, + /* + * An object usually contained in a menu to provide a visible and + * logical separation of the contents in a menu. + */ + ATK_ROLE_SEPARATOR, + /* An object that allows the user to select from a bounded range */ + ATK_ROLE_SLIDER, + /* A specialized panel that presents two other panels at the same time. */ + ATK_ROLE_SPLIT_PANE, + /* An object used to rpesent information in terms of rows and columns. */ + ATK_ROLE_TABLE, + ATK_ROLE_TABLE_CELL, + ATK_ROLE_TABLE_COLUMN_HEADER, + ATK_ROLE_TABLE_ROW_HEADER, + /* An object that presents text to the user */ + ATK_ROLE_TEXT, + /* + * A specialized push button that can be checked or unchecked, but does + * not procide a separate indicator for the current state. + */ + ATK_ROLE_TOGGLE_BUTTON, + /* + * A bar or palette usually composed of push buttons or toggle buttons + */ + ATK_ROLE_TOOL_BAR, + /* + * An object that provides information about another object + */ + ATK_ROLE_TOOL_TIP, + /* An object used to repsent hierarchical information to the user. */ + ATK_ROLE_TREE, + /* + * The object contains some Accessible information, but its role is + * not known. + */ + ATK_ROLE_UNKNOWN, + /* An object usually used in a scroll pane. */ + ATK_ROLE_VIEWPORT, + /* A top level window with no title or border */ + ATK_ROLE_WINDOW, + /* not a valid role, used for finding end of enumeration. */ + ATK_ROLE_LAST_DEFINED +} AtkRole; + +AtkRole atk_role_register (gchar *name); + +typedef enum +{ + ATK_STATE_INVALID, + /* Indicates a window is currently the active window */ + ATK_STATE_ACTIVE, + /* Indicates that the object is armed */ + ATK_STATE_ARMED, + /* Indicates the current object is busy */ + ATK_STATE_BUSY, + /* Indicates this object is currently checked */ + ATK_STATE_CHECKED, + /* Indicates this object is collapsed */ + ATK_STATE_COLLAPSED, + /* Indicates the user can change the contents of this object */ + ATK_STATE_EDITABLE, + /* Indicates this object allows progressive disclosure of its children */ + ATK_STATE_EXPANDABLE, + /* Indicates this object its expanded */ + ATK_STATE_EXPANDED, + /* + * Indicates this object can accept keyboard focus, which means all + * events resulting from typing on the keyboard will normally be passed + * to it when it has focus + */ + ATK_STATE_FOCUSABLE, + /* Indicates this object currently has the keyboard focus */ + ATK_STATE_FOCUSED, + /* Indicates the orientation of thsi object is horizontal */ + ATK_STATE_HORIZONTAL, + /* Indicates this object is minimized and is represented only by an icon */ + ATK_STATE_ICONIFIED, + /* + * Indicates something must be done with this object before the user can + * interact with an object in a different window. + */ + ATK_STATE_MODAL, + /* Indicates this (text) object can contain multiple lines of text */ + ATK_STATE_MULTI_LINE, + /* + * Indicates this object allows more than one of its children to be + * selected at the same time + */ + ATK_STATE_MULTISELECTABLE, + /* Indicates this object paints every pixel within its rectangular region. */ + ATK_STATE_OPAQUE, + /* Indicates this object is currently pressed */ + ATK_STATE_PRESSED, + /* Indicates the size of this object is not fixed */ + ATK_STATE_RESIZABLE, + /* + * Indicates this object is the child of an object that allows its + * children to be selected and that this child is one of those children + * that can be selected. + */ + ATK_STATE_SELECTABLE, + /* + * Indicates this object is the child of an object that allows its + * children to be selected and that this child is one of those children + * that has been selected. + */ + ATK_STATE_SELECTED, + /* Indicates this object is sensitive */ + ATK_STATE_SENSITIVE, + /* + * Indicates this object, the object's parent, the object's parent's + * parent, and so on, are all visible + */ + ATK_STATE_SHOWING, + /* Indicates this (text) object can contain only a single line of text */ + ATK_STATE_SINGLE_LINE, + /* Indicates this object is transient */ + ATK_STATE_TRANSIENT, + /* Indicates the orientation of this object is vertical */ + ATK_STATE_VERTICAL, + /* Indicates this object is visible */ + ATK_STATE_VISIBLE, + ATK_STATE_LAST_DEFINED +} AtkStateType; + +AtkStateType atk_state_type_register (gchar *name); + + +#define ATK_TYPE_OBJECT (atk_object_get_type ()) +#define ATK_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ATK_TYPE_OBJECT, AtkObject)) +#define ATK_OBJECT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ATK_TYPE_OBJECT, AtkObjectClass)) +#define ATK_IS_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ATK_TYPE_OBJECT)) +#define ATK_IS_OBJECT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), ATK_TYPE_OBJECT)) +#define ATK_OBJECT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), ATK_TYPE_OBJECT, AtkObjectClass)) + +#define ATK_TYPE_OBJECT_IFACE (atk_object_iface_get_type ()) +#define ATK_OBJECT_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), ATK_TYPE_OBJECT_IFACE, AtkObjectIface)) + + +/* Forward declarations of interface structures */ + +typedef struct _AtkIfaceImplementor AtkIfaceImplementor; + +typedef struct _AtkObjectIface AtkObjectIface; + +typedef struct _AtkActionIface AtkActionIface; +typedef struct _AtkComponentIface AtkComponentIface; +typedef struct _AtkEditableTextIface AtkEditableTextIface; +typedef struct _AtkHypertextIface AtkHypertextIface; +typedef struct _AtkImageIface AtkImageIface; +typedef struct _AtkSelectionIface AtkSelectionIface; +typedef struct _AtkTableIface AtkTableIface; +typedef struct _AtkTextIface AtkTextIface; +typedef struct _AtkValueIface AtkValueIface; + + +typedef struct _AtkObject AtkObject; +typedef struct _AtkObjectClass AtkObjectClass; +typedef struct _AtkRelation AtkRelation; +typedef struct _AtkRelationSet AtkRelationSet; + +typedef guint64 AtkStateMask; +typedef guint64 AtkState; + +#define ATK_STATE(state_enum) ((AtkStateMask)(1 << ((guint64)(state_enum)%64))) + +struct _AtkPropertyValues +{ + gchar *property_name; + GValue old_value; + GValue new_value; +}; + +typedef struct _AtkPropertyValues AtkPropertyValues; + +/* + * For most properties the old_value field of AtkPropertyValues will + * not contain a valid value. + * + * Currently, the only property for which old_value is used is + * accessible-state; for instance if there is a focus state the + * property change handler will be called for the object which lost the focus + * with the old_value containing an AtkState value corresponding to focused + * and the property change handler will be called for the object which + * received the focus with the new_value containing an AtkState value + * corresponding to focused. + */ +typedef void (*AtkPropertyChangeHandler) (AtkObject*, AtkPropertyValues*); + + +struct _AtkObject +{ + GObject parent; + + gchar *description; + gchar *name; + AtkObject *accessible_parent; + AtkRole role; + AtkRelationSet *relation_set; +}; + +struct _AtkObjectClass +{ + GObjectClass parent; + + /* + * Gets the accessible name of the object + */ + G_CONST_RETURN gchar* (* get_name) (AtkObject *accessible); + /* + * Gets the accessible description of the object + */ + G_CONST_RETURN gchar* (* get_description) (AtkObject *accessible); + /* + * Gets the accessible parent of the object + */ + AtkObject* (*get_parent) (AtkObject *accessible); + + /* + * Gets the number of accessible children of the object + */ + gint (* get_n_children) (AtkObject *accessible); + /* + * Returns a reference to the specified accessible child of the object. + * The accessible children are 0-based so the first accessible child is + * at index 0, the second at index 1 and so on. + */ + AtkObject* (* ref_child) (AtkObject *accessible, + gint i); + /* + * Gets the 0-based index of this object in its parent; returns -1 if the + * object does not have an accessible parent. + */ + gint (* get_index_in_parent) (AtkObject *accessible); + /* + * Gets the RelationSet associated with the object + */ + AtkRelationSet* (* get_relation_set) (AtkObject *accessible); + /* + * Gets the role of the object + */ + AtkRole (* get_role) (AtkObject *accessible); + /* + * Gets the state set of the object + */ + AtkState (* get_state) (AtkObject *accessible); + /* + * Sets the accessible name of the object + */ + void (* set_name) (AtkObject *accessible, + const gchar *name); + /* + * Sets the accessible description of the object + */ + void (* set_description) (AtkObject *accessible, + const gchar *description); + /* + * Sets the accessible parent of the object + */ + void (* set_parent) (AtkObject *accessible, + AtkObject *parent); + /* + * Sets the accessible role of the object + */ + void (* set_role) (AtkObject *accessible, + AtkRole role); + /* + * Specifies a function to be called when a property changes value + */ +guint (* connect_property_change_handler) (AtkObject + *accessible, + AtkPropertyChangeHandler *handler); + /* + * Removes a property change handler which was specified using + * connect_property_change_handler + */ +void (* remove_property_change_handler) (AtkObject + *accessible, + guint + handler_id); + /* + * The signal handler which is executed when there is a change in the + * children of the object + */ + void (* children_changed) (AtkObject *accessible, + AtkChildChangeType change_type, + AtkObject *changed_child); +}; +GType atk_object_get_type (void); + +struct _AtkObjectIface +{ + GTypeInterface parent; + + AtkObject* (*ref_accessible) (AtkIfaceImplementor *accessible); +}; +GType atk_object_iface_get_type (void); + +/* + * This method uses the ref_accessible method in AtkObjectIface, + * if the object's class implements AtkObjectIface. + * Otherwise it returns %NULL. + * + * IMPORTANT: + * Note also that because this method may return flyweight objects, + * it increments the returned AtkObject's reference count. + * Therefore it is the responsibility of the calling + * program to unreference the object when no longer needed. + * (c.f. gtk_widget_get_accessible() where this is not the case). + */ +AtkObject* atk_object_ref_accessible (AtkIfaceImplementor *accessible); + +/* + * Properties directly supported by AtkObject + */ + +G_CONST_RETURN gchar* atk_object_get_name (AtkObject *accessible); +G_CONST_RETURN gchar* atk_object_get_description (AtkObject *accessible); +AtkObject* atk_object_get_parent (AtkObject *accessible); +gint atk_object_get_n_accessible_children (AtkObject *accessible); +AtkObject* atk_object_ref_accessible_child (AtkObject *accessible, + gint i); +AtkRelationSet* atk_object_get_relation_set (AtkObject *accessible); +AtkRole atk_object_get_role (AtkObject *accessible); +AtkState atk_object_get_state (AtkObject *accessible); +gint atk_object_get_index_in_parent (AtkObject *accessible); +void atk_object_set_name (AtkObject *accessible, + const gchar *name); +void atk_object_set_description (AtkObject *accessible, + const gchar *description); +void atk_object_set_parent (AtkObject *accessible, + AtkObject *parent); +void atk_object_set_role (AtkObject *accessible, + AtkRole role); + + +/* + * to install property change listener, one must + * install signal handler for gobject "properties_changed" signal. + * (for single notifications of multiple changes). + * We could use the "notify" signal instead. + * + */ +guint atk_object_connect_property_change_handler (AtkObject *accessible, + AtkPropertyChangeHandler *handler); +void atk_object_remove_property_change_handler (AtkObject *accessible, + guint handler_id); + +/* + * Note: the properties which are registered with the GType + * property registry, for type ATK_TYPE_OBJECT, are as follows: + * + * "accessible-name" + * "accessible-description" + * "accessible-parent" + * "accessible-child" + * "accessible-role" + * "accessible-state" + * + * accessibility property change listeners should use the + * normal GObject property interfaces and "properties_changed" + * signal handler semantics to interpret the property change + * information relayed from AtkObject. + * (AtkObject instances will connect to the "properties_changed" + * signal in their host objects, and relay the signals when appropriate). + */ + +/* For other signals, see related interfaces + * + * AtkActionIface, + * AtkComponentIface, + * AtkHypertextIface, + * AtkImageIface, + * AtkSelectionIface, + * AtkTableIface, + * AtkTextIface, + * AtkValueIface. + * + * The usage model for obtaining these interface instances is: + * ATK__GET_IFACE(GObject *accessible), + * where accessible, though specified as a GObject, is + * the AtkObject instance being queried. + * More usually, the interface will be used via a cast to the + * interface's corresponding "type": + * + * AtkText textImpl = ATK_TEXT(accessible); + * if (textImpl) + * { + * cpos = atk_text_get_caret_position(textImpl); + * } + * + * If it's known in advance that accessible implements AtkTextIface, + * this is shortened to: + * + * cpos = atk_text_get_caret_position (ATK_TEXT (accessible)); + */ + +typedef enum +{ + ATK_RELATION_NULL = 0, + + ATK_RELATION_CONTROLLED_BY, + ATK_RELATION_CONTROLLER_FOR, + ATK_RELATION_LABEL_FOR, + ATK_RELATION_LABELLED_BY, + ATK_RELATION_MEMBER_OF, + ATK_RELATION_LAST_DEFINED +} AtkRelationType; + +AtkRelationType atk_relation_type_register (gchar *name); + +/* + * Create a new relation for the specified key and the specified list + * of targets. + */ +AtkRelation* atk_relation_new (GArray *target, + AtkRelationType relationship); +/* + * Returns whether the relation set contains a relation that matches the + * specified type. + */ +gboolean atk_relation_set_contains (AtkRelationSet *set, + AtkRelationType relationship); +/* + * Remove a relation from the from the relation set. + */ +void atk_relation_set_remove (AtkRelationSet *set, + AtkRelation *relation); +/* + * Add a new relation to the current relation set if it is not already + * present. + */ +void atk_relation_set_add (AtkRelationSet *set, + AtkRelation *relation); +/* + * Returns the number of relations in a relation set. + */ +gint atk_relation_set_get_n_relations (AtkRelationSet *set); +/* + * Returns the relation at the specified position in the relation set. + */ +AtkRelation* atk_relation_set_get_relation (AtkRelationSet *set, + gint i); +/* + * Returns a relation that matches the specified type. + */ +AtkRelation* atk_relation_set_get_relation_by_type (AtkRelationSet *set, + AtkRelationType relationship); + +/* + * Returns the type of a relation. + */ +AtkRelationType atk_relation_get_type (AtkRelation *relation); +/* + * Returns the target list of a relation. + */ +GArray* atk_relation_get_target (AtkRelation *relation); + +gchar* atk_state_mask_get_name (AtkStateMask state); +AtkStateMask atk_state_mask_for_name (gchar *name); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + + +#endif /* __ATK_OBJECT_H__ */ diff --git a/atk/atkobjectfactory.c b/atk/atkobjectfactory.c new file mode 100755 index 0000000..da84c6d --- /dev/null +++ b/atk/atkobjectfactory.c @@ -0,0 +1,92 @@ +/* ATK - Accessibility Toolkit + * Copyright 2001 Sun Microsystems Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#include "atkobjectfactory.h" +#include "atknoopobjectfactory.h" + +static void atk_object_factory_class_init (AtkObjectFactoryClass *klass); + +static gpointer parent_class = NULL; + +GType +atk_object_factory_get_type () +{ + static GType type = 0; + + if (!type) { + GTypeInfo tinfo = + { + sizeof (AtkObjectFactoryClass), + (GBaseInitFunc) NULL, /* base init */ + (GBaseFinalizeFunc) NULL, /* base finalize */ + (GClassInitFunc) atk_object_factory_class_init, /* class init */ + (GClassFinalizeFunc) NULL, /* class finalize */ + NULL, /* class data */ + sizeof (AtkObjectFactory), /* instance size */ + 0, /* nb preallocs */ + (GInstanceInitFunc) NULL, /* instance init */ + NULL /* value table */ + }; + + type = g_type_register_static (G_TYPE_OBJECT, "AtkObjectFactory", &tinfo, 0); + } + return type; +} + +static void +atk_object_factory_class_init (AtkObjectFactoryClass *klass) +{ + parent_class = g_type_class_ref (G_TYPE_OBJECT); + +} + + +AtkObject* +atk_object_factory_create_accessible (AtkObjectFactory *factory, + GObject *obj) +{ + AtkObjectFactoryClass *klass; + AtkObject *accessible = NULL; + + g_return_val_if_fail ((factory != NULL), NULL); + g_return_val_if_fail (ATK_IS_OBJECT_FACTORY (factory), NULL); + g_return_val_if_fail (obj != NULL, NULL); + g_return_val_if_fail (G_IS_OBJECT (obj), NULL); + + klass = ATK_OBJECT_FACTORY_GET_CLASS (factory); + + if (klass->create_accessible) + { + accessible = klass->create_accessible (obj); + } + return accessible; +} + +void +atk_object_factory_invalidate (AtkObjectFactory *factory) +{ + AtkObjectFactoryClass *klass; + + g_return_if_fail (factory != NULL); + g_return_if_fail (ATK_OBJECT_FACTORY (factory)); + + klass = ATK_OBJECT_FACTORY_GET_CLASS (factory); + if (klass->invalidate) + (klass->invalidate) (factory); +} diff --git a/atk/atkobjectfactory.h b/atk/atkobjectfactory.h new file mode 100755 index 0000000..a1147f9 --- /dev/null +++ b/atk/atkobjectfactory.h @@ -0,0 +1,63 @@ +/* ATK - Accessibility Toolkit + * Copyright 2001 Sun Microsystems Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#ifndef __ATK_OBJECT_FACTORY_H__ +#define __ATK_OBJECT_FACTORY_H__ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#define ATK_TYPE_OBJECT_FACTORY (atk_object_factory_get_type ()) +#define ATK_OBJECT_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ATK_TYPE_OBJECT_FACTORY, AtkObjectFactory)) +#define ATK_OBJECT_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ATK_TYPE_OBJECT_FACTORY, AtkObjectFactoryClass)) +#define ATK_IS_OBJECT_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ATK_TYPE_OBJECT_FACTORY)) +#define ATK_IS_OBJECT_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), ATK_TYPE_OBJECT_FACTORY)) +#define ATK_OBJECT_FACTORY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), ATK_TYPE_OBJECT_FACTORY, AtkObjectFactoryClass)) + +typedef struct _AtkObjectFactory AtkObjectFactory; +typedef struct _AtkObjectFactoryClass AtkObjectFactoryClass; + +struct _AtkObjectFactory +{ + GObject parent; +}; + +struct _AtkObjectFactoryClass +{ + GObjectClass parent_class; + + AtkObject* (* create_accessible) (GObject *obj); + void (* invalidate) (AtkObjectFactory *factory); +}; + +GType atk_object_factory_get_type(); + +AtkObject* atk_object_factory_create_accessible(AtkObjectFactory *factory, GObject *obj); +void atk_object_factory_invalidate (AtkObjectFactory *factory); +#ifdef __cplusplus +} +#endif /* __cplusplus */ + + +#endif /* __GTK_OBJECT_FACTORY_H__ */ + diff --git a/atk/atkregistry.c b/atk/atkregistry.c new file mode 100644 index 0000000..8ad9847 --- /dev/null +++ b/atk/atkregistry.c @@ -0,0 +1,229 @@ +/* ATK - Accessibility Toolkit + * Copyright 2001 Sun Microsystems Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#include "atkregistry.h" +#include "atknoopobjectfactory.h" + +static AtkRegistry *default_registry = NULL;; + +static void atk_registry_init (AtkRegistry *instance, + AtkRegistryClass *klass); +static void atk_registry_finalize (GObject *instance); +static void atk_registry_class_init (AtkRegistryClass *klass); + +static AtkRegistry* atk_registry_new (); +static GType atk_registry_get_factory_type (AtkRegistry *registry, + GType type); + +GType +atk_registry_get_type (void) +{ + static GType type = 0; + + if (!type) + { + static const GTypeInfo info = + { + sizeof (AtkRegistryClass), + (GBaseInitFunc) NULL, /* base_init */ + (GBaseFinalizeFunc) NULL, /* base_finalize */ + (GClassInitFunc) atk_registry_class_init, /* class_init */ + (GClassFinalizeFunc) NULL, /* class_finalize */ + NULL, /* class_data */ + sizeof (AtkRegistry), /* instance size */ + 0, /* n_preallocs */ + (GInstanceInitFunc) atk_registry_init, /* instance init */ + NULL /* value table */ + }; + + type = g_type_register_static (G_TYPE_OBJECT, "AtkRegistry", &info, 0); + } + + return type; +} + +static void +atk_registry_class_init (AtkRegistryClass *klass) +{ + GObjectClass *object_class; + + /* is paranoia appropriate in a class initializer ? */ + g_return_if_fail (G_IS_OBJECT_CLASS (klass)); + + object_class = G_OBJECT_CLASS (klass); + object_class->finalize = atk_registry_finalize; + default_registry = atk_registry_new (); +} + +#if 0 +/* + * Cannot define a class_finalize function when calling + * g_type_register_static() + */ +static void +atk_registry_class_finalize (GObjectClass *klass) +{ + g_return_if_fail (ATK_IS_REGISTRY_CLASS (klass)); + + g_free (default_registry); +} +#endif + +static void +atk_registry_init (AtkRegistry *instance, AtkRegistryClass *klass) +{ + instance->factory_type_registry = g_hash_table_new (NULL, NULL); + instance->factory_singleton_cache = g_hash_table_new (NULL, NULL); +} + +static AtkRegistry* +atk_registry_new () +{ + GObject *object; + + object = g_object_new (ATK_TYPE_REGISTRY, NULL); + + g_return_val_if_fail ((object != NULL), NULL); + g_return_val_if_fail (ATK_IS_REGISTRY (object), NULL); + + return (AtkRegistry *) object; +} + +static void +atk_registry_finalize (GObject *instance) +{ + AtkRegistry *registry; + + g_return_if_fail (ATK_IS_REGISTRY (instance)); + registry = ATK_REGISTRY (instance); + g_free (registry->factory_type_registry); + g_free (registry->factory_singleton_cache); +} + + +void +atk_registry_set_factory_type (AtkRegistry *registry, + GType type, + GType factory_type) +{ + GType old_type; + gpointer value; + AtkObjectFactory *old_factory; + + g_return_if_fail (ATK_IS_REGISTRY (registry)); + + value = g_hash_table_lookup (registry->factory_type_registry, + GUINT_TO_POINTER (type)); + old_type = GPOINTER_TO_UINT (value); + if (old_type && old_type != factory_type) + { + g_hash_table_remove (registry->factory_type_registry, + GUINT_TO_POINTER (type)); + /* + * If the old factory was created, notify it that it has + * been replaced, then free it. + */ + old_factory = g_hash_table_lookup (registry->factory_singleton_cache, + GUINT_TO_POINTER (old_type)); + if (old_factory) + { + atk_object_factory_invalidate (old_factory); + g_type_free_instance ((GTypeInstance *) old_factory); + } + } + g_hash_table_insert (registry->factory_type_registry, + GUINT_TO_POINTER (type), + GUINT_TO_POINTER (factory_type)); +} + +GType +atk_registry_get_factory_type (AtkRegistry *registry, + GType type) +{ + GType factory_type; + gpointer value; + + /* + * look up factory type in first hash; + * if there isn't an explicitly registered factory type, + * try inheriting one... + */ + do { + value = + g_hash_table_lookup (registry->factory_type_registry, + GUINT_TO_POINTER (type)); + type = g_type_parent (type); + if (type == G_TYPE_INVALID) + { + break; + } + } while (value == NULL); + + factory_type = GPOINTER_TO_UINT (value); + return factory_type; +} + + +AtkObjectFactory* +atk_registry_get_factory (AtkRegistry *registry, + GType type) +{ + gpointer factory_pointer = NULL; + GType factory_type; + + factory_type = atk_registry_get_factory_type (registry, type); + + if (factory_type == G_TYPE_INVALID) + { + /* Factory type has not been specified for this object type */ + static AtkObjectFactory* default_factory = NULL; + + if (!default_factory) + default_factory = atk_no_op_object_factory_new (); + + return default_factory; + } + + /* ask second hashtable for instance of factory type */ + factory_pointer = + g_hash_table_lookup (registry->factory_singleton_cache, + GUINT_TO_POINTER (factory_type)); + + /* if there isn't one already, create one and save it */ + if (factory_pointer == NULL) + { + factory_pointer = g_type_create_instance (factory_type); + g_hash_table_insert (registry->factory_singleton_cache, + GUINT_TO_POINTER (factory_type), + factory_pointer); + } + + return ATK_OBJECT_FACTORY (factory_pointer); +} + + +AtkRegistry* +atk_get_default_registry () +{ + if (!default_registry) + { + default_registry = atk_registry_new(); + } + return default_registry; +} diff --git a/atk/atkregistry.h b/atk/atkregistry.h new file mode 100644 index 0000000..7bd7e1d --- /dev/null +++ b/atk/atkregistry.h @@ -0,0 +1,67 @@ +/* ATK - Accessibility Toolkit + * Copyright 2001 Sun Microsystems Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#ifndef __ATK_REGISTRY_H__ +#define __ATK_REGISTRY_H__ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#include +#include "atkobjectfactory.h" + +#define ATK_TYPE_REGISTRY (atk_registry_get_type ()) +#define ATK_REGISTRY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ATK_TYPE_REGISTRY, AtkRegistry)) +#define ATK_REGISTRY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ATK_TYPE_REGISTRY, AtkRegistryClass)) +#define ATK_IS_REGISTRY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ATK_TYPE_REGISTRY)) +#define ATK_IS_REGISTRY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), ATK_TYPE_REGISTRY)) +#define ATK_REGISTRY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), ATK_TYPE_REGISTRY, AtkRegistryClass)) + +struct _AtkRegistry +{ + GObject parent; + GHashTable *factory_type_registry; + GHashTable *factory_singleton_cache; +}; + +struct _AtkRegistryClass +{ + GObjectClass parent_class; +}; + +typedef struct _AtkRegistry AtkRegistry; +typedef struct _AtkRegistryClass AtkRegistryClass; + + +void atk_registry_set_factory_type (AtkRegistry *registry, + GType type, + GType factory_type); + +AtkObjectFactory* atk_registry_get_factory (AtkRegistry *registry, + GType type); + +AtkRegistry* atk_get_default_registry (); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* __ATK_REGISTRY_H__ */ + diff --git a/atk/atkselection.c b/atk/atkselection.c new file mode 100755 index 0000000..3c62042 --- /dev/null +++ b/atk/atkselection.c @@ -0,0 +1,201 @@ +/* ATK - Accessibility Toolkit + * Copyright 2001 Sun Microsystems Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#include "atkselection.h" + +GType +atk_selection_get_type () +{ + static GType type = 0; + + if (!type) { + GTypeInfo tinfo = + { + sizeof (AtkSelectionIface), + NULL, + NULL, + + }; + + type = g_type_register_static (G_TYPE_INTERFACE, "AtkSelection", &tinfo, 0); + } + + return type; +} + +/** + * atk_selection_add_selection: + * @value: a GObject instance that implements AtkSelectionIface + * @return: void + **/ +void +atk_selection_add_selection (AtkSelection *obj, + gint i) +{ + AtkSelectionIface *iface; + + g_return_if_fail (obj != NULL); + g_return_if_fail (ATK_IS_SELECTION (obj)); + + iface = ATK_SELECTION_GET_IFACE (obj); + + if (iface->add_selection) + (iface->add_selection) (obj, i); +} + +/** + * atk_selection_clear_selection: + * @value: a GObject instance that implements AtkSelectionIface + * @return: void + **/ +void +atk_selection_clear_selection (AtkSelection *obj) +{ + AtkSelectionIface *iface; + + g_return_if_fail (obj != NULL); + g_return_if_fail (ATK_IS_SELECTION (obj)); + + iface = ATK_SELECTION_GET_IFACE (obj); + + if (iface->clear_selection) + (iface->clear_selection) (obj); +} + +/** + * atk_selection_ref_selection: + * @value: a GObject instance that implements AtkSelectionIface + * @return: a AtkObject* representing the selected accessible , or NULL + * if value does not implement this interface. + * + * WARNING: callers should not rely on %NULL or on a zero value for + * indication of whether AtkSelectionIface is implemented, they should + * use type checking/interface checking macros or the + * atk_get_accessible_value() convenience method. + **/ +AtkObject* +atk_selection_ref_selection (AtkSelection *obj, + gint i) +{ + AtkSelectionIface *iface; + + g_return_val_if_fail (obj != NULL, NULL); + g_return_val_if_fail (ATK_IS_SELECTION (obj), NULL); + + iface = ATK_SELECTION_GET_IFACE (obj); + + if (iface->ref_selection) + return (iface->ref_selection) (obj, i); + else + return NULL; +} + +/** + * atk_selection_get_selection_count: + * @value: a GObject instance that implements AtkSelectionIface + * @return: a gint representing the number of items selected, or 0 + * if value does not implement this interface. + * + * WARNING: callers should not rely on %NULL or on a zero value for + * indication of whether AtkSelectionIface is implemented, they should + * use type checking/interface checking macros or the + * atk_get_accessible_value() convenience method. + **/ +gint +atk_selection_get_selection_count (AtkSelection *obj) +{ + AtkSelectionIface *iface; + + g_return_val_if_fail (obj != NULL, 0); + g_return_val_if_fail (ATK_IS_SELECTION (obj), 0); + + iface = ATK_SELECTION_GET_IFACE (obj); + + if (iface->get_selection_count) + return (iface->get_selection_count) (obj); + else + return 0; +} + +/** + * atk_selection_is_child_selected: + * @value: a GObject instance that implements AtkSelectionIface + * @return: a gboolean representing the specified child is selected, or 0 + * if value does not implement this interface. + * + * WARNING: callers should not rely on %NULL or on a zero value for + * indication of whether AtkSelectionIface is implemented, they should + * use type checking/interface checking macros or the + * atk_get_accessible_value() convenience method. + **/ +gboolean +atk_selection_is_child_selected (AtkSelection *obj, + gint i) +{ + AtkSelectionIface *iface; + + g_return_val_if_fail (obj != NULL, FALSE); + g_return_val_if_fail (ATK_IS_SELECTION (obj), FALSE); + + iface = ATK_SELECTION_GET_IFACE (obj); + + if (iface->is_child_selected) + return (iface->is_child_selected) (obj, i); + else + return FALSE; +} + +/** + * atk_selection_remove_selection: + * @value: a GObject instance that implements AtkSelectionIface + * @return: void + **/ +void +atk_selection_remove_selection (AtkSelection *obj, + gint i) +{ + AtkSelectionIface *iface; + + g_return_if_fail (obj != NULL); + g_return_if_fail (ATK_IS_SELECTION (obj)); + + iface = ATK_SELECTION_GET_IFACE (obj); + + if (iface->remove_selection) + (iface->remove_selection) (obj, i); +} + +/** + * atk_selection_select_all_selection: + * @value: a GObject instance that implements AtkSelectionIface + * @return: void + **/ +void +atk_selection_select_all_selection (AtkSelection *obj) +{ + AtkSelectionIface *iface; + + g_return_if_fail (obj != NULL); + g_return_if_fail (ATK_IS_SELECTION (obj)); + + iface = ATK_SELECTION_GET_IFACE (obj); + + if (iface->select_all_selection) + (iface->select_all_selection) (obj); +} diff --git a/atk/atkselection.h b/atk/atkselection.h new file mode 100755 index 0000000..52051c1 --- /dev/null +++ b/atk/atkselection.h @@ -0,0 +1,113 @@ +/* ATK - Accessibility Toolkit + * Copyright 2001 Sun Microsystems Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#ifndef __ATK_SELECTION_H__ +#define __ATK_SELECTION_H__ + +#include + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/* + * This AtkSelection interface provides the standard mechanism for an + * assistive technology to determine what the current selected children are, + * as well as modify the selection set. Any object that has children that + * can be selected should support the AtkSelection interface. + */ + +#define ATK_TYPE_SELECTION (atk_selection_get_type ()) +#define ATK_IS_SELECTION(obj) G_TYPE_CHECK_INSTANCE_TYPE ((obj), ATK_TYPE_SELECTION) +#define ATK_SELECTION(obj) G_TYPE_CHECK_INSTANCE_CAST ((obj), ATK_TYPE_SELECTION, AtkSelection) +#define ATK_SELECTION_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), ATK_TYPE_SELECTION, AtkSelectionIface)) + +#ifndef _TYPEDEF_ATK_SELECTION_ +#define _TYPEDEF_ATK_SELECTION_ +typedef struct _AtkSelection AtkSelection; +#endif + +struct _AtkSelectionIface +{ + GTypeInterface parent; + + /* + * Adds the specified accessible child of the object to the + * object's selection. + */ + void (* add_selection) (AtkSelection *selection, + gint i); + /* + * Clears the selection in the object so that no children in the object + * are selected. + */ + void (* clear_selection) (AtkSelection *selection); + /* + * Returns a reference to the accessible object representing the specified + * selected * child of the object. + */ + AtkObject* (* ref_selection) (AtkSelection *selection, + gint i); + /* + * Returns the number of accessible children currently selected. + */ + gint (* get_selection_count) (AtkSelection *selection); + /* + * Determines if the current child of this object is selected + */ + gboolean (* is_child_selected) (AtkSelection *selection, + gint i); + /* + * Removes the specified child of the object from the object's selection. + */ + void (* remove_selection) (AtkSelection *selection, + gint i); + /* + * Causes every child of the object to be selected if the object + * supports multiple selections. + */ + void (* select_all_selection) (AtkSelection *selection); + +}; +GType atk_selection_get_type (); + +void atk_selection_add_selection (AtkSelection *selection, + gint i); + +void atk_selection_clear_selection (AtkSelection *selection); + +AtkObject* atk_selection_ref_selection (AtkSelection *selection, + gint i); + +gint atk_selection_get_selection_count (AtkSelection *selection); + +gboolean atk_selection_is_child_selected (AtkSelection *selection, + gint i); + +void atk_selection_remove_selection (AtkSelection *selection, + gint i); + +void atk_selection_select_all_selection (AtkSelection *selection); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + + +#endif /* __ATK_SELECTION_H__ */ diff --git a/atk/atktable.c b/atk/atktable.c new file mode 100755 index 0000000..5394321 --- /dev/null +++ b/atk/atktable.c @@ -0,0 +1,693 @@ +/* ATK - Accessibility Toolkit + * Copyright 2001 Sun Microsystems Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#include "atktable.h" + +GType +atk_table_get_type () +{ + static GType type = 0; + + if (!type) { + GTypeInfo tinfo = + { + sizeof (AtkTableIface), + NULL, + NULL, + + }; + + type = g_type_register_static (G_TYPE_INTERFACE, "AtkTable", &tinfo, 0); + } + + return type; +} + +/** + * atk_table_ref_at: + * @value: a GObject instance that implements AtkTableIface + * @return: a AtkObject* representing the referred to accessible , or NULL + * if value does not implement this interface. + * + * WARNING: callers should not rely on %NULL or on a zero value for + * indication of whether AtkSelectionIface is implemented, they should + * use type checking/interface checking macros or the + * atk_get_accessible_table() convenience method. + **/ +AtkObject* +atk_table_ref_at (AtkTable *obj, + gint row, + gint column) +{ + AtkTableIface *iface; + + g_return_val_if_fail (obj != NULL, NULL); + g_return_val_if_fail (ATK_IS_TABLE (obj), NULL); + + iface = ATK_TABLE_GET_IFACE (obj); + + if (iface->ref_at) + return (iface->ref_at) (obj, row, column); + else + return NULL; +} + +/** + * atk_table_get_index_at: + * @value: a GObject instance that implements AtkTableIface + * @return: a gint representing the index at specified position, or 0 + * if value does not implement this interface. + * + * WARNING: callers should not rely on %NULL or on a zero value for + * indication of whether AtkSelectionIface is implemented, they should + * use type checking/interface checking macros or the + * atk_get_accessible_table() convenience method. + **/ +gint +atk_table_get_index_at (AtkTable *obj, + gint row, + gint column) +{ + AtkTableIface *iface; + + g_return_val_if_fail (obj != NULL, 0); + g_return_val_if_fail (ATK_IS_TABLE (obj), 0); + + iface = ATK_TABLE_GET_IFACE (obj); + + if (iface->get_index_at) + return (iface->get_index_at) (obj, row, column); + else + return 0; +} + +/** + * atk_table_get_row_at_index: + * @value: a GObject instance that implements AtkTableInterface + * @return: a gint representing the row at the specified index, or 0 + * if value does not implement this interface. + * + * WARNING: callers should not rely on %NULL or on a zero value for + * indication of whether AtkSelectionIface is implemented, they should + * use type checking/interface checking macros or the + * atk_get_accessible_table() convenience method. + **/ +gint +atk_table_get_row_at_index (AtkTable *obj, + gint index) +{ + AtkTableIface *iface; + + g_return_val_if_fail (obj != NULL, 0); + g_return_val_if_fail (ATK_IS_TABLE (obj), 0); + + iface = ATK_TABLE_GET_IFACE (obj); + + if (iface->get_row_at_index) + return (iface->get_row_at_index) (obj, index); + else + return 0; +} + +/** + * atk_table_get_column_at_index: + * @value: a GObject instance that implements AtkTableInterface + * @return: a gint representing the column at the specified index, or 0 + * if value does not implement this interface. + * + * WARNING: callers should not rely on %NULL or on a zero value for + * indication of whether AtkSelectionIface is implemented, they should + * use type checking/interface checking macros or the + * atk_get_accessible_table() convenience method. + **/ +gint +atk_table_get_column_at_index (AtkTable *obj, + gint index) +{ + AtkTableIface *iface; + + g_return_val_if_fail (obj != NULL, 0); + g_return_val_if_fail (ATK_IS_TABLE (obj), 0); + + iface = ATK_TABLE_GET_IFACE (obj); + + if (iface->get_column_at_index) + return (iface->get_column_at_index) (obj, index); + else + return 0; +} + +/** + * atk_table_get_caption: + * @value: a GObject instance that implements AtkTableInterface + * @return: a AtkObject* representing the table caption, or NULL + * if value does not implement this interface. + * + * WARNING: callers should not rely on %NULL or on a zero value for + * indication of whether AtkSelectionIface is implemented, they should + * use type checking/interface checking macros or the + * atk_get_accessible_table() convenience method. + **/ +AtkObject* +atk_table_get_caption (AtkTable *obj) +{ + AtkTableIface *iface; + + g_return_val_if_fail (obj != NULL, NULL); + g_return_val_if_fail (ATK_IS_TABLE (obj), NULL); + + iface = ATK_TABLE_GET_IFACE (obj); + + if (iface->get_caption) + return (iface->get_caption) (obj); + else + return NULL; +} + +/** + * atk_table_get_n_columns: + * @value: a GObject instance that implements AtkTableIface + * @return: a gint representing the number of columns, or 0 + * if value does not implement this interface. + * + * WARNING: callers should not rely on %NULL or on a zero value for + * indication of whether AtkSelectionIface is implemented, they should + * use type checking/interface checking macros or the + * atk_get_accessible_table() convenience method. + **/ +gint +atk_table_get_n_columns (AtkTable *obj) +{ + AtkTableIface *iface; + + g_return_val_if_fail (obj != NULL, 0); + g_return_val_if_fail (ATK_IS_TABLE (obj), 0); + + iface = ATK_TABLE_GET_IFACE (obj); + + if (iface->get_n_columns) + return (iface->get_n_columns) (obj); + else + return 0; +} + +/** + * atk_table_get_column_description: + * @value: a GObject instance that implements AtkTableIface + * @return: a AtkObject* representing the table description, or NULL + * if value does not implement this interface. + * + * WARNING: callers should not rely on %NULL or on a zero value for + * indication of whether AtkSelectionIface is implemented, they should + * use type checking/interface checking macros or the + * atk_get_accessible_table() convenience method. + **/ +AtkObject* +atk_table_get_column_description (AtkTable *obj, + gint column) +{ + AtkTableIface *iface; + + g_return_val_if_fail (obj != NULL, NULL); + g_return_val_if_fail (ATK_IS_TABLE (obj), NULL); + + iface = ATK_TABLE_GET_IFACE (obj); + + if (iface->get_column_description) + return (iface->get_column_description) (obj, column); + else + return NULL; +} + +/** + * atk_table_get_column_extent_at: + * @value: a GObject instance that implements AtkTableIface + * @return: a gint representing the column extent at specified position, or 0 + * if value does not implement this interface. + * + * WARNING: callers should not rely on %NULL or on a zero value for + * indication of whether AtkSelectionIface is implemented, they should + * use type checking/interface checking macros or the + * atk_get_accessible_table() convenience method. + **/ +gint +atk_table_get_column_extent_at (AtkTable *obj, + gint row, + gint column) +{ + AtkTableIface *iface; + + g_return_val_if_fail (obj != NULL, 0); + g_return_val_if_fail (ATK_IS_TABLE (obj), 0); + + iface = ATK_TABLE_GET_IFACE (obj); + + if (iface->get_column_extent_at) + return (iface->get_column_extent_at) (obj, row, column); + else + return 0; +} + +/** + * atk_table_get_column_header: + * @value: a GObject instance that implements AtkTableIface + * @return: a AtkObject* representing the column headers, or NULL + * if value does not implement this interface. + * + * WARNING: callers should not rely on %NULL or on a zero value for + * indication of whether AtkSelectionIface is implemented, they should + * use type checking/interface checking macros or the + * atk_get_accessible_table() convenience method. + **/ +AtkTable* +atk_table_get_column_header (AtkTable *obj) +{ + AtkTableIface *iface; + + g_return_val_if_fail (obj != NULL, NULL); + g_return_val_if_fail (ATK_IS_TABLE (obj), NULL); + + iface = ATK_TABLE_GET_IFACE (obj); + + if (iface->get_column_header) + return (iface->get_column_header) (obj); + else + return NULL; +} + +/** + * atk_table_get_n_rows: + * @value: a GObject instance that implements AtkTableIface + * @return: a gint representing the number of rows, or 0 + * if value does not implement this interface. + * + * WARNING: callers should not rely on %NULL or on a zero value for + * indication of whether AtkSelectionIface is implemented, they should + * use type checking/interface checking macros or the + * atk_get_accessible_table() convenience method. + **/ +gint +atk_table_get_n_rows (AtkTable *obj) +{ + AtkTableIface *iface; + + g_return_val_if_fail (obj != NULL, 0); + g_return_val_if_fail (ATK_IS_TABLE (obj), 0); + + iface = ATK_TABLE_GET_IFACE (obj); + + if (iface->get_n_rows) + return (iface->get_n_rows) (obj); + else + return 0; +} + +/** + * atk_table_get_row_description: + * @value: a GObject instance that implements AtkTableIface + * @return: a AtkObject* representing the table description, or NULL + * if value does not implement this interface. + * + * WARNING: callers should not rely on %NULL or on a zero value for + * indication of whether AtkSelectionIface is implemented, they should + * use type checking/interface checking macros or the + * atk_get_accessible_table() convenience method. + **/ +AtkObject* +atk_table_get_row_description (AtkTable *obj, + gint row) +{ + AtkTableIface *iface; + + g_return_val_if_fail (obj != NULL, NULL); + g_return_val_if_fail (ATK_IS_TABLE (obj), NULL); + + iface = ATK_TABLE_GET_IFACE (obj); + + if (iface->get_row_description) + return (iface->get_row_description) (obj, row); + else + return NULL; +} + +/** + * atk_table_get_row_extent_at: + * @value: a GObject instance that implements AtkTableIface + * @return: a gint representing the row extent at specified position, or 0 + * if value does not implement this interface. + * + * WARNING: callers should not rely on %NULL or on a zero value for + * indication of whether AtkSelectionIface is implemented, they should + * use type checking/interface checking macros or the + * atk_get_accessible_table() convenience method. + **/ +gint +atk_table_get_row_extent_at (AtkTable *obj, + gint row, + gint column) +{ + AtkTableIface *iface; + + g_return_val_if_fail (obj != NULL, 0); + g_return_val_if_fail (ATK_IS_TABLE (obj), 0); + + iface = ATK_TABLE_GET_IFACE (obj); + + if (iface->get_row_extent_at) + return (iface->get_row_extent_at) (obj, row, column); + else + return 0; +} + +/** + * atk_table_get_row_header: + * @value: a GObject instance that implements AtkTableIface + * @return: a AtkTable* representing the row headers, or NULL + * if value does not implement this interface. + * + * WARNING: callers should not rely on %NULL or on a zero value for + * indication of whether AtkSelectionIface is implemented, they should + * use type checking/interface checking macros or the + * atk_get_accessible_table() convenience method. + **/ +AtkTable* +atk_table_get_row_header (AtkTable *obj) +{ + AtkTableIface *iface; + + g_return_val_if_fail (obj != NULL, NULL); + g_return_val_if_fail (ATK_IS_TABLE (obj), NULL); + + iface = ATK_TABLE_GET_IFACE (obj); + + if (iface->get_row_header) + return (iface->get_row_header) (obj); + else + return NULL; +} + +/** + * atk_table_get_summary: + * @value: a GObject instance that implements AtkTableIface + * @return: a AtkObject* representing a sumary description of the table, + * or NULL if value does not implement this interface. + * + * WARNING: callers should not rely on %NULL or on a zero value for + * indication of whether AtkSelectionIface is implemented, they should + * use type checking/interface checking macros or the + * atk_get_accessible_table() convenience method. + **/ +AtkObject* +atk_table_get_summary (AtkTable *obj) +{ + AtkTableIface *iface; + + g_return_val_if_fail (obj != NULL, NULL); + g_return_val_if_fail (ATK_IS_TABLE (obj), NULL); + + iface = ATK_TABLE_GET_IFACE (obj); + + if (iface->get_summary) + return (iface->get_summary) (obj); + else + return NULL; +} + +/** + * atk_table_get_selected_rows: + * @value: a GObject instance that implements AtkTableIface + * @return: a gint* representing the selected rows, + * or NULL if value does not implement this interface. + * + * WARNING: callers should not rely on %NULL or on a zero value for + * indication of whether AtkSelectionIface is implemented, they should + * use type checking/interface checking macros or the + * atk_get_accessible_table() convenience method. + **/ +gint* +atk_table_get_selected_rows (AtkTable *obj) +{ + AtkTableIface *iface; + + g_return_val_if_fail (obj != NULL, NULL); + g_return_val_if_fail (ATK_IS_TABLE (obj), NULL); + + iface = ATK_TABLE_GET_IFACE (obj); + + if (iface->get_selected_rows) + return (iface->get_selected_rows) (obj); + else + return NULL; +} + +/** + * atk_table_get_selected_columns: + * @value: a GObject instance that implements AtkTableIface + * @return: a gint* representing the selected columns, + * or NULL if value does not implement this interface. + * + * WARNING: callers should not rely on %NULL or on a zero value for + * indication of whether AtkSelectionIface is implemented, they should + * use type checking/interface checking macros or the + * atk_get_accessible_table() convenience method. + **/ +gint* +atk_table_get_selected_columns (AtkTable *obj) +{ + AtkTableIface *iface; + + g_return_val_if_fail (obj != NULL, NULL); + g_return_val_if_fail (ATK_IS_TABLE (obj), NULL); + + iface = ATK_TABLE_GET_IFACE (obj); + + if (iface->get_selected_columns) + return (iface->get_selected_columns) (obj); + else + return NULL; +} + +/** + * atk_table_is_column_selected: + * @value: a GObject instance that implements AtkTableIface + * @return: a gboolean representing the column is selected, or 0 + * if value does not implement this interface. + * + * WARNING: callers should not rely on %NULL or on a zero value for + * indication of whether AtkSelectionIface is implemented, they should + * use type checking/interface checking macros or the + * atk_get_accessible_table() convenience method. + **/ +gboolean +atk_table_is_column_selected (AtkTable *obj, + gint column) +{ + AtkTableIface *iface; + + g_return_val_if_fail (obj != NULL, FALSE); + g_return_val_if_fail (ATK_IS_TABLE (obj), FALSE); + + iface = ATK_TABLE_GET_IFACE (obj); + + if (iface->is_column_selected) + return (iface->is_column_selected) (obj, column); + else + return FALSE; +} + +/** + * atk_table_is_row_selected: + * @value: a GObject instance that implements AtkTableIface + * @return: a gboolean representing the row is selected, or 0 + * if value does not implement this interface. + * + * WARNING: callers should not rely on %NULL or on a zero value for + * indication of whether AtkSelectionIface is implemented, they should + * use type checking/interface checking macros or the + * atk_get_accessible_table() convenience method. + **/ +gboolean +atk_table_is_row_selected (AtkTable *obj, + gint row) +{ + AtkTableIface *iface; + + g_return_val_if_fail (obj != NULL, FALSE); + g_return_val_if_fail (ATK_IS_TABLE (obj), FALSE); + + iface = ATK_TABLE_GET_IFACE (obj); + + if (iface->is_row_selected) + return (iface->is_row_selected) (obj, row); + else + return FALSE; +} + +/** + * atk_table_is_selected: + * @value: a GObject instance that implements AtkTableIface + * @return: a gboolean representing the cell is selected, or 0 + * if value does not implement this interface. + * + * WARNING: callers should not rely on %NULL or on a zero value for + * indication of whether AtkSelectionIface is implemented, they should + * use type checking/interface checking macros or the + * atk_get_accessible_table() convenience method. + **/ +gboolean +atk_table_is_selected (AtkTable *obj, + gint row, + gint column) +{ + AtkTableIface *iface; + + g_return_val_if_fail (obj != NULL, FALSE); + g_return_val_if_fail (ATK_IS_TABLE (obj), FALSE); + + iface = ATK_TABLE_GET_IFACE (obj); + + if (iface->is_selected) + return (iface->is_selected) (obj, row, column); + else + return FALSE; +} + +/** + * atk_table_set_caption: + * @value: a GObject instance that implements AtkTableIface + * @return: void + **/ +void +atk_table_set_caption (AtkTable *obj, + AtkObject *accessible) +{ + AtkTableIface *iface; + + g_return_if_fail (obj != NULL); + g_return_if_fail (ATK_IS_TABLE (obj)); + + iface = ATK_TABLE_GET_IFACE (obj); + + if (iface->set_caption) + (iface->set_caption) (obj, accessible); +} + +/** + * atk_table_set_column_description: + * @value: a GObject instance that implements AtkTableIface + * @return: void + **/ +void +atk_table_set_column_description (AtkTable *obj, + gint column, + AtkObject *accessible) +{ + AtkTableIface *iface; + + g_return_if_fail (obj != NULL); + g_return_if_fail (ATK_IS_TABLE (obj)); + + iface = ATK_TABLE_GET_IFACE (obj); + + if (iface->set_column_description) + (iface->set_column_description) (obj, column, accessible); +} + +/** + * atk_table_set_column_header: + * @value: a GObject instance that implements AtkTableIface + * @return: void + **/ +void +atk_table_set_column_header (AtkTable *obj, + gint column, + AtkTable *header) +{ + AtkTableIface *iface; + + g_return_if_fail (obj != NULL); + g_return_if_fail (ATK_IS_TABLE (obj)); + + iface = ATK_TABLE_GET_IFACE (obj); + + if (iface->set_column_header) + (iface->set_column_header) (obj, column, header); +} + +/** + * atk_table_set_row_description: + * @value: a GObject instance that implements AtkTableIface + * @return: void + **/ +void +atk_table_set_row_description (AtkTable *obj, + gint row, + AtkObject *accessible) +{ + AtkTableIface *iface; + + g_return_if_fail (obj != NULL); + g_return_if_fail (ATK_IS_TABLE (obj)); + + iface = ATK_TABLE_GET_IFACE (obj); + + if (iface->set_row_description) + (iface->set_row_description) (obj, row, accessible); +} + +/** + * atk_table_set_row_header: + * @value: a GObject instance that implements AtkTableIface + * @return: void + **/ +void +atk_table_set_row_header (AtkTable *obj, + gint row, + AtkTable *header) +{ + AtkTableIface *iface; + + g_return_if_fail (obj != NULL); + g_return_if_fail (ATK_IS_TABLE (obj)); + + iface = ATK_TABLE_GET_IFACE (obj); + + if (iface->set_row_header) + (iface->set_row_header) (obj, row, header); +} + +/** + * atk_table_set_summary: + * @value: a GObject instance that implements AtkTableIface + * @return: void + **/ +void +atk_table_set_summary (AtkTable *obj, + AtkObject *accessible) +{ + AtkTableIface *iface; + + g_return_if_fail (obj != NULL); + g_return_if_fail (ATK_IS_TABLE (obj)); + + iface = ATK_TABLE_GET_IFACE (obj); + + if (iface->set_summary) + (iface->set_summary) (obj, accessible); +} diff --git a/atk/atktable.h b/atk/atktable.h new file mode 100755 index 0000000..3ccdd98 --- /dev/null +++ b/atk/atktable.h @@ -0,0 +1,233 @@ +/* ATK - Accessibility Toolkit + * Copyright 2001 Sun Microsystems Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#ifndef __ATK_TABLE_H__ +#define __ATK_TABLE_H__ + +#include + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/* + * AtkTable describes a user-interface component that presents data in + * two-dimensional table format. + */ + + +#define ATK_TYPE_TABLE (atk_table_get_type ()) +#define ATK_IS_TABLE(obj) G_TYPE_CHECK_INSTANCE_TYPE ((obj), ATK_TYPE_TABLE) +#define ATK_TABLE(obj) G_TYPE_CHECK_INSTANCE_CAST ((obj), ATK_TYPE_TABLE, AtkTable) +#define ATK_TABLE_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), ATK_TYPE_TABLE, AtkTableIface)) + +#ifndef _TYPEDEF_ATK_TABLE_ +#define _TYPEDEF_ATK_TABLE_ +typedef struct _AtkTable AtkTable; +#endif + +struct _AtkTableIface +{ + GTypeInterface parent; + + /* + * Returns a reference to the accessible object at a specified row + * and column in the table. + */ + AtkObject* (* ref_at) (AtkTable *table, + gint row, + gint column); + gint (* get_index_at) (AtkTable *table, + gint row, + gint column); + gint (* get_row_at_index) (AtkTable *table, + gint index); + gint (* get_column_at_index) (AtkTable *table, + gint index); + /* + * Returns the caption for the table. + */ + AtkObject* (* get_caption) (AtkTable *table); + /* + * Returns the number of columns in the table. + */ + gint (* get_n_columns) (AtkTable *table); + /* + * Returns the description text of the specified column in the table + */ + AtkObject* (* get_column_description) (AtkTable *table, + gint column); + /* + * Returns the number of columns occupied by the accessible object + * at a specified row and column in the table. + */ + gint (* get_column_extent_at) (AtkTable *table, + gint row, + gint column); + /* + * Returns the column headers of an accessible table. + */ + AtkTable* (* get_column_header) (AtkTable *table); + /* + * Returns the number of rows in the table. + */ + gint (* get_n_rows) (AtkTable *table); + /* + * Returns the description text of the specified row in the table + */ + AtkObject* (* get_row_description) (AtkTable *table, + gint row); + /* + * Returns the number of rows occupied by the accessible object + * at a specified row and column in the table. + */ + gint (* get_row_extent_at) (AtkTable *table, + gint row, + gint column); + /* + * Returns the row headers of an accessible table. + */ + AtkTable* (* get_row_header) (AtkTable *table); + /* + * Returns the summary description of the table. + */ + AtkObject* (* get_summary) (AtkTable *table); + /* + * Returns the selected columns of the table. + */ + gint* (* get_selected_columns) (AtkTable *table); + /* + * Returns the selected rows of the table. + */ + gint* (* get_selected_rows) (AtkTable *table); + /* + * Returns a boolean value indicating whether the specified column + * is selected + */ + gboolean (* is_column_selected) (AtkTable *table, + gint column); + /* + * Returns a boolean value indicating whether the specified row + * is selected + */ + gboolean (* is_row_selected) (AtkTable *table, + gint row); + /* + * Returns a boolean value indicating whether the acessible object + * at the specified row and column is selected + */ + gboolean (* is_selected) (AtkTable *table, + gint row, + gint column); + /* + * Sets the caption for the table. + */ + void (* set_caption) (AtkTable *table, + AtkObject *accessible); + /* + * Sets the description text for the specified column of the table. + */ + void (* set_column_description) (AtkTable *table, + gint column, + AtkObject *accessible); + /* + * Sets the column headers + */ + void (* set_column_header) (AtkTable *table, + gint column, + AtkTable *header); + /* + * Sets the description text for the specified row of the table. + */ + void (* set_row_description) (AtkTable *table, + gint row, + AtkObject *accessible); + /* + * Sets the row headers + */ + void (* set_row_header) (AtkTable *table, + gint row, + AtkTable *header); + /* + * Sets the summary description of the table + */ + void (* set_summary) (AtkTable *table, + AtkObject *accessible); +}; + +GType atk_table_get_type (); + +AtkObject* atk_table_ref_at (AtkTable *table, + gint row, + gint column); +gint atk_table_get_index_at (AtkTable *table, + gint row, + gint column); +gint atk_table_get_row_at_index (AtkTable *table, + gint index); +gint atk_table_get_column_at_index (AtkTable *table, + gint index); +AtkObject* atk_table_get_caption (AtkTable *table); +gint atk_table_get_n_columns (AtkTable *table); +AtkObject* atk_table_get_column_description (AtkTable *table, + gint column); +gint atk_table_get_column_extent_at (AtkTable *table, + gint row, + gint column); +AtkTable* atk_table_get_column_header (AtkTable *table); +gint atk_table_get_n_rows (AtkTable *table); +AtkObject* atk_table_get_row_description (AtkTable *table, + gint r); +gint atk_table_get_row_extent_at (AtkTable *table, + gint row, + gint column); +AtkTable* atk_table_get_row_header (AtkTable *table); +AtkObject* atk_table_get_summary (AtkTable *table); +gint* atk_table_get_selected_columns (AtkTable *table); +gint* atk_table_get_selected_rows (AtkTable *table); +gboolean atk_table_is_column_selected (AtkTable *table, + gint column); +gboolean atk_table_is_row_selected (AtkTable *table, + gint row); +gboolean atk_table_is_selected (AtkTable *table, + gint row, + gint column); +void atk_table_set_caption (AtkTable *table, + AtkObject *accessible); +void atk_table_set_column_description (AtkTable *table, + gint column, + AtkObject *accessible); +void atk_table_set_column_header (AtkTable *table, + gint column, + AtkTable *header); +void atk_table_set_row_description (AtkTable *table, + gint row, + AtkObject *accessible); +void atk_table_set_row_header (AtkTable *table, + gint row, + AtkTable *header); +void atk_table_set_summary (AtkTable *table, + AtkObject *accessible); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + + +#endif /* __ATK_TABLE_H__ */ diff --git a/atk/atktext.c b/atk/atktext.c new file mode 100755 index 0000000..dcc865b --- /dev/null +++ b/atk/atktext.c @@ -0,0 +1,307 @@ +/* ATK - The Accessibility Toolkit for GTK+ + * Copyright 2001 Sun Microsystems Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#include "atktext.h" + +struct _AtkTextIfaceClass +{ + GObjectClass parent; +}; + +typedef struct _AtkTextIfaceClass AtkTextIfaceClass; + + +GType +atk_text_get_type () +{ + static GType type = 0; + + if (!type) { + static const GTypeInfo tinfo = + { + sizeof (AtkTextIface), + NULL, + NULL, + + }; + + type = g_type_register_static (G_TYPE_INTERFACE, "AtkText", &tinfo, 0); + } + + return type; +} + +gchar* +atk_text_get_text (AtkText *text, + gint start_offset, + gint end_offset) +{ + AtkTextIface *iface; + + g_return_val_if_fail (text != NULL, NULL); + g_return_val_if_fail (ATK_IS_TEXT (text), NULL); + + iface = ATK_TEXT_GET_IFACE (text); + + if (iface->get_text) + return (*(iface->get_text)) (text, start_offset, end_offset); + else + return NULL; +} + +gunichar +atk_text_get_character_at_offset (AtkText *text, + gint offset) +{ + AtkTextIface *iface; + + g_return_val_if_fail (text != NULL, (gunichar) 0); + g_return_val_if_fail (ATK_IS_TEXT (text), (gunichar) 0); + + iface = ATK_TEXT_GET_IFACE (text); + + if (iface->get_character_at_offset) + return (*(iface->get_character_at_offset)) (text, offset); + else + return (gunichar) 0; +} + +gchar* +atk_text_get_text_after_offset (AtkText *text, + gint offset, + AtkTextBoundary boundary_type) +{ + AtkTextIface *iface; + + g_return_val_if_fail (text != NULL, NULL); + g_return_val_if_fail (ATK_IS_TEXT (text), NULL); + + iface = ATK_TEXT_GET_IFACE (text); + + if (iface->get_text_after_offset) + return (*(iface->get_text_after_offset)) (text, offset, boundary_type); + else + return NULL; +} + +gchar* +atk_text_get_text_at_offset (AtkText *text, + gint offset, + AtkTextBoundary boundary_type) +{ + AtkTextIface *iface; + + g_return_val_if_fail (text != NULL, NULL); + g_return_val_if_fail (ATK_IS_TEXT (text), NULL); + + iface = ATK_TEXT_GET_IFACE (text); + + if (iface->get_text_at_offset) + return (*(iface->get_text_at_offset)) (text, offset, boundary_type); + else + return NULL; +} + +gchar* +atk_text_get_text_before_offset (AtkText *text, + gint offset, + AtkTextBoundary boundary_type) +{ + AtkTextIface *iface; + + g_return_val_if_fail (text != NULL, NULL); + g_return_val_if_fail (ATK_IS_TEXT (text), NULL); + + iface = ATK_TEXT_GET_IFACE (text); + + if (iface->get_text_before_offset) + return (*(iface->get_text_before_offset)) (text, offset, boundary_type); + else + return NULL; +} + +gint +atk_text_get_caret_offset (AtkText *text) +{ + AtkTextIface *iface; + + g_return_val_if_fail (text != NULL, -1); + g_return_val_if_fail (ATK_IS_TEXT (text), -1); + + iface = ATK_TEXT_GET_IFACE (text); + + if (iface->get_caret_offset) + return (*(iface->get_caret_offset)) (text); + else + return -1; +} + +void +atk_text_get_row_col_at_offset (AtkText *text, + gint offset, + gint *row, + gint *col) +{ + AtkTextIface *iface; + + g_return_if_fail (text != NULL); + g_return_if_fail (ATK_IS_TEXT (text)); + + iface = ATK_TEXT_GET_IFACE (text); + + if (iface->get_row_col_at_offset) + (*(iface->get_row_col_at_offset)) (text, offset, row, col); + else + { + *row = 0; + *col = 0; + } +} + +PangoAttrList* +atk_text_get_range_attributes (AtkText *text, + gint start_offset, + gint end_offset) +{ + AtkTextIface *iface; + + g_return_val_if_fail (text != NULL, NULL); + g_return_val_if_fail (ATK_IS_TEXT (text), NULL); + + iface = ATK_TEXT_GET_IFACE (text); + + if (iface->get_range_attributes) + return (*(iface->get_range_attributes)) (text, start_offset, end_offset); + else + return NULL; +} + +void +atk_text_get_character_extents (AtkText *text, + gint offset, + gint *x, + gint *y, + gint *length, + gint *width) +{ + AtkTextIface *iface; + + g_return_if_fail (text != NULL); + g_return_if_fail (ATK_IS_TEXT (text)); + + iface = ATK_TEXT_GET_IFACE (text); + + if (iface->get_character_extents) + (*(iface->get_character_extents)) (text, offset, x, y, length, width); + else + { + *x = 0; + *x = 0; + *length = 0; + *width = 0; + } +} + +gint +atk_text_get_character_count (AtkText *text) +{ + AtkTextIface *iface; + + g_return_val_if_fail (text != NULL, -1); + g_return_val_if_fail (ATK_IS_TEXT (text), -1); + + iface = ATK_TEXT_GET_IFACE (text); + + if (iface->get_character_count) + return (*(iface->get_character_count)) (text); + else + return -1; +} + +gint +atk_text_get_offset_at_point (AtkText *text, + gint x, + gint y) +{ + AtkTextIface *iface; + + g_return_val_if_fail (text != NULL, -1); + g_return_val_if_fail (ATK_IS_TEXT (text), -1); + + iface = ATK_TEXT_GET_IFACE (text); + + if (iface->get_offset_at_point) + return (*(iface->get_offset_at_point)) (text, x, y); + else + return -1; +} + +gchar* +atk_text_get_selected_text (AtkText *text) +{ + AtkTextIface *iface; + + g_return_val_if_fail (text != NULL, NULL); + g_return_val_if_fail (ATK_IS_TEXT (text), NULL); + + iface = ATK_TEXT_GET_IFACE (text); + + if (iface->get_selected_text) + return (*(iface->get_selected_text)) (text); + else + return NULL; +} + +gboolean +atk_text_get_selection_bounds (AtkText *text, + gint *start_offset, + gint *end_offset) +{ + AtkTextIface *iface; + + g_return_val_if_fail (text != NULL, FALSE); + g_return_val_if_fail (ATK_IS_TEXT (text), FALSE); + + iface = ATK_TEXT_GET_IFACE (text); + + if (iface->get_selection_bounds) + return (*(iface->get_selection_bounds)) (text, start_offset, end_offset); + else + { + *start_offset = 0; + *end_offset = 0; + return FALSE; + } +} + +void +atk_text_set_selection_bounds (AtkText *text, + gint start_offset, + gint end_offset) +{ + AtkTextIface *iface; + + g_return_if_fail (text != NULL); + g_return_if_fail (ATK_IS_TEXT (text)); + + iface = ATK_TEXT_GET_IFACE (text); + + if (iface->set_selection_bounds) + (*(iface->set_selection_bounds)) (text, start_offset, end_offset); +} diff --git a/atk/atktext.h b/atk/atktext.h new file mode 100755 index 0000000..16136b9 --- /dev/null +++ b/atk/atktext.h @@ -0,0 +1,156 @@ +/* ATK - The Accessibility Toolkit for GTK+ + * Copyright 2001 Sun Microsystems Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + + +#ifndef __ATK_TEXT_H__ +#define __ATK_TEXT_H__ + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#define ATK_TYPE_TEXT (atk_text_get_type ()) +#define ATK_IS_TEXT(obj) G_TYPE_CHECK_INSTANCE_TYPE ((obj), ATK_TYPE_TEXT) +#define ATK_TEXT(obj) G_TYPE_CHECK_INSTANCE_CAST ((obj), ATK_TYPE_TEXT, AtkText) +#define ATK_TEXT_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), ATK_TYPE_TEXT, AtkTextIface)) + +#ifndef _TYPEDEF_ATK_TEXT_ +#define _TYPEDEF_ATK_TEXT_ +typedef struct _AtkText AtkText; +#endif + +typedef enum { + ATK_TEXT_BOUNDARY_CHAR, + ATK_TEXT_BOUNDARY_CURSOR_POS, + ATK_TEXT_BOUNDARY_WORD_START, + ATK_TEXT_BOUNDARY_WORD_END, + ATK_TEXT_BOUNDARY_SENTENCE_START, + ATK_TEXT_BOUNDARY_SENTENCE_END, + ATK_TEXT_BOUNDARY_LINE_START, + ATK_TEXT_BOUNDARY_LINE_END +} AtkTextBoundary; + +struct _AtkTextIface +{ + GTypeInterface parent; + + gchar* (* get_text) (AtkText *text, + gint start_offset, + gint end_offset); + gchar* (* get_text_after_offset) (AtkText *text, + gint offset, + AtkTextBoundary boundary_type); + gchar* (* get_text_at_offset) (AtkText *text, + gint offset, + AtkTextBoundary boundary_type); + gunichar (* get_character_at_offset) (AtkText *text, + gint offset); + gchar* (* get_text_before_offset) (AtkText *text, + gint offset, + AtkTextBoundary boundary_type); + gint (* get_caret_offset) (AtkText *text); + void (* get_row_col_at_offset) (AtkText *text, + gint offset, + gint *row, + gint *col); + PangoAttrList* (* get_range_attributes) (AtkText *text, + gint start_offset, + gint end_offset); + void (* get_character_extents) (AtkText *text, + gint offset, + gint *x, + gint *y, + gint *length, + gint *width); + gint (* get_character_count) (AtkText *text); + gint (* get_offset_at_point) (AtkText *text, + gint x, + gint y); + gchar* (* get_selected_text) (AtkText *text); + gboolean (* get_selection_bounds) (AtkText *text, + gint *start_offset, + gint *end_offset); + void (* set_selection_bounds) (AtkText *text, + gint start_offset, + gint end_offset); + +}; +GType atk_text_get_type (void); + + +/* + * Additional AtkObject properties used by AtkText: + * "accessible_text" (accessible text has changed) + * "accessible_caret" (accessible text cursor position changed: + * editable text only) + */ + +gchar* atk_text_get_text (AtkText *text, + gint start_offset, + gint end_offset); + +gunichar atk_text_get_character_at_offset (AtkText *text, + gint offset); + +gchar* atk_text_get_text_after_offset (AtkText *text, + gint offset, + AtkTextBoundary boundary_type); +gchar* atk_text_get_text_at_offset (AtkText *text, + gint offset, + AtkTextBoundary boundary_type); +gchar* atk_text_get_text_before_offset (AtkText *text, + gint offset, + AtkTextBoundary boundary_type); +gint atk_text_get_caret_offset (AtkText *text); +void atk_text_get_row_col_at_offset (AtkText *text, + gint offset, + gint *row, + gint *col); +PangoAttrList* atk_text_get_range_attributes (AtkText *text, + gint start_offset, + gint end_offset); +void atk_text_get_character_extents (AtkText *text, + gint offset, + gint *x, + gint *y, + gint *length, + gint *width); +gint atk_text_get_character_count (AtkText *text); +gint atk_text_get_offset_at_point (AtkText *text, + gint x, + gint y); +gchar* atk_text_get_selected_text (AtkText *text); +gboolean atk_text_get_selection_bounds (AtkText *text, + gint *start_offset, + gint *end_offset); +void atk_text_set_selection_bounds (AtkText *text, + gint start_offset, + gint end_offset); + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + + +#endif /* __ATK_TEXT_H__ */ diff --git a/atk/atkutil.c b/atk/atkutil.c new file mode 100755 index 0000000..e9317f5 --- /dev/null +++ b/atk/atkutil.c @@ -0,0 +1,116 @@ +/* ATK - Accessibility Toolkit + * Copyright 2001 Sun Microsystems Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#include "atkutil.h" + +/* + * This file supports the addition and removal of multiple focus handlers + * as long as they are all called in the same thread. + */ +static AtkFocusTrackerInit focus_tracker_init = NULL; + +static gboolean init_done = FALSE; + +/* + * Array of FocusTracker structs + */ +static GArray *trackers = NULL; +static guint index = 0; + +struct _FocusTracker { + guint index; + AtkFocusTracker func; +}; +typedef struct _FocusTracker FocusTracker; + +void +atk_focus_tracker_init (AtkFocusTrackerInit init) +{ + if (focus_tracker_init == NULL) + focus_tracker_init = init; +} + +guint +atk_add_focus_tracker (AtkFocusTracker focus_tracker) +{ + g_return_val_if_fail ((focus_tracker != NULL), 0); + + if (!init_done) + { + if (focus_tracker_init != NULL) + { + focus_tracker_init (); + } + trackers = g_array_sized_new (FALSE, TRUE, sizeof (FocusTracker), 0); + init_done = TRUE; + } + if (init_done) + { + FocusTracker item; + + item.index = ++index; + item.func = focus_tracker; + trackers = g_array_append_val (trackers, item); + return index; + } + else + { + return 0; + } +} + +void +atk_remove_focus_tracker (guint tracker_id) +{ + FocusTracker *item; + guint i; + + if (trackers == NULL) + return; + + if (tracker_id == 0) + return; + + for (i = 0; i < trackers->len; i++) + { + item = &g_array_index (trackers, FocusTracker, i); + if (item->index == tracker_id) + { + trackers = g_array_remove_index (trackers, i); + break; + } + } +} + +void +atk_focus_tracker_notify (AtkObject *object) +{ + FocusTracker *item; + guint i; + + if (trackers == NULL) + return; + + for (i = 0; i < trackers->len; i++) + { + item = &g_array_index (trackers, FocusTracker, i); + g_return_if_fail (item != NULL); + item->func (object); + } +} diff --git a/atk/atkutil.h b/atk/atkutil.h new file mode 100755 index 0000000..716a545 --- /dev/null +++ b/atk/atkutil.h @@ -0,0 +1,65 @@ +/* ATK - Accessibility Toolkit + * Copyright 2001 Sun Microsystems Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#ifndef __ATK_UTIL_H__ +#define __ATK_UTIL_H__ + +#include + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/* + * A focus tracker is a function which is called when an object + * receives focus. + */ +typedef void (*AtkFocusTracker) (AtkObject*); +typedef void (*AtkFocusTrackerInit) (void); + + +/* + * Adds the specified function to the list of functions to be called + * when an object receives focus. + */ +guint atk_add_focus_tracker (AtkFocusTracker focus_tracker); +/* + * Removes the specified focus tracker from the list of function + * to be called when any object receives focus + */ +void atk_remove_focus_tracker (guint tracker_id); +/* + * Specifies the function to be called for focus tracker initialization. + * removal. This function should be called by an implementation of the + * ATK interface if any specific work needs to be done to enable + * focus tracking. + */ +void atk_focus_tracker_init (AtkFocusTrackerInit add_function); +/* + * Cause the focus tracker functions which have been specified to be + * executed for the object. + */ +void atk_focus_tracker_notify (AtkObject *object); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + + +#endif /* __ATK_UTIL_H__ */ diff --git a/atk/atkvalue.c b/atk/atkvalue.c new file mode 100755 index 0000000..eaddd69 --- /dev/null +++ b/atk/atkvalue.c @@ -0,0 +1,146 @@ +/* ATK - Accessibility Toolkit + * Copyright 2001 Sun Microsystems Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#include "atkvalue.h" + +GType +atk_value_get_type () +{ + static GType type = 0; + + if (!type) { + GTypeInfo tinfo = + { + sizeof (AtkValueIface), + NULL, + NULL, + + }; + + type = g_type_register_static (G_TYPE_INTERFACE, "AtkValue", &tinfo, 0); + } + + return type; +} + +/** + * atk_value_get_current_value: + * @obj@: a GObject instance that implements AtkValueIface + * @value: a #GValue representing the current accessible value + * + * WARNING: callers should not rely on %NULL or on a zero value for + * indication of whether AtkValue is implemented, they should + * use type checking/interface checking macros or the + * atk_get_accessible_value() convenience method. + **/ +void +atk_value_get_current_value (AtkValue *obj, + GValue *value) +{ + AtkValueIface *iface; + + g_return_if_fail (obj != NULL); + g_return_if_fail (value != NULL); + g_return_if_fail (ATK_IS_VALUE (obj)); + g_return_if_fail (G_IS_VALUE (value)); + + iface = ATK_VALUE_GET_IFACE (obj); + + if (iface->get_current_value) + (iface->get_current_value) (obj, value); +} + +/** + * atk_value_get_maximum_value: + * @obj: a GObject instance that implements AtkValueIface + * @value: a #GValue representing the maximum accessible value + * + * WARNING: callers should not rely on %NULL or on a zero value for + * indication of whether AtkValue is implemented, they should + * use type checking/interface checking macros or the + * atk_get_accessible_value() convenience method. + **/ +void +atk_value_get_maximum_value (AtkValue *obj, + GValue *value) +{ + AtkValueIface *iface; + + g_return_if_fail (obj != NULL); + g_return_if_fail (value != NULL); + g_return_if_fail (ATK_IS_VALUE (obj)); + g_return_if_fail (G_IS_VALUE (value)); + + iface = ATK_VALUE_GET_IFACE (obj); + + if (iface->get_maximum_value) + (iface->get_maximum_value) (obj, value); +} + +/** + * atk_value_get_minimum_value: + * @obj: a GObject instance that implements AtkValueIface + * @value: a #GValue representing the minimum accessible value + * + * WARNING: callers should not rely on %NULL or on a zero value for + * indication of whether AtkValue is implemented, they should + * use type checking/interface checking macros or the + * atk_get_accessible_value() convenience method. + **/ +void +atk_value_get_minimum_value (AtkValue *obj, + GValue *value) +{ + AtkValueIface *iface; + + g_return_if_fail (obj != NULL); + g_return_if_fail (value != NULL); + g_return_if_fail (ATK_IS_VALUE (obj)); + g_return_if_fail (G_IS_VALUE (value)); + + iface = ATK_VALUE_GET_IFACE (obj); + + if (iface->get_minimum_value) + return (iface->get_minimum_value) (obj, value); +} + +/** + * atk_value_set_current_value: + * @obj: a GObject instance that implements AtkValueIface + * @value: a #GValue which is the desired new accessible value. + * @return: %true if new value is successfully set, %false otherwise. + **/ +gboolean +atk_value_set_current_value (AtkValue *obj, + GValue *value) +{ + AtkValueIface *iface; + + g_return_val_if_fail (obj != NULL, FALSE); + g_return_val_if_fail (value != NULL, FALSE); + g_return_val_if_fail (ATK_IS_VALUE (obj), FALSE); + g_return_val_if_fail (G_IS_VALUE (value), FALSE); + + iface = ATK_VALUE_GET_IFACE (obj); + + if (iface->set_current_value) + return (iface->set_current_value) (obj, value); + else + return FALSE; +} diff --git a/atk/atkvalue.h b/atk/atkvalue.h new file mode 100755 index 0000000..bbf8be8 --- /dev/null +++ b/atk/atkvalue.h @@ -0,0 +1,101 @@ +/* ATK - Accessibility Toolkit + * Copyright 2001 Sun Microsystems Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#ifndef __ATK_VALUE_H__ +#define __ATK_VALUE_H__ + +#include + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/* + * The AtkValue interface should be supported by any object that + * supports a numerical value (e.g., a scroll bar). This interface + * provides the standard mechanism for an assistive technology to + * determine and set the numerical value as well as get the minimum + * and maximum values. + */ + +#define ATK_TYPE_VALUE (atk_value_get_type ()) +#define ATK_IS_VALUE(obj) G_TYPE_CHECK_INSTANCE_TYPE ((obj), ATK_TYPE_VALUE) +#define ATK_VALUE(obj) G_TYPE_CHECK_INSTANCE_CAST ((obj), ATK_TYPE_VALUE, AtkValue) +#define ATK_VALUE_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), ATK_TYPE_VALUE, AtkValueIface)) + +#ifndef _TYPEDEF_ATK_VALUE_ +#define _TYPEDEF_ATK_VALUE__ +typedef struct _AtkValue AtkValue; +#endif + +struct _AtkValueIface +{ + GTypeInterface parent; + + /* + * Gets the value of this object + */ + void (* get_current_value) (AtkValue *obj, + GValue *value); + /* + * Gets the maximum value of this object + */ + void (* get_maximum_value) (AtkValue *obj, + GValue *value); + /* + * Gets the minimum value of this object + */ + void (* get_minimum_value) (AtkValue *obj, + GValue *value); + /* + * Sets the value of this object + */ + gboolean (* set_current_value) (AtkValue *obj, + GValue *value); + +}; + +GType atk_value_get_type (void); + +void atk_value_get_current_value (AtkValue *obj, + GValue *value); + + +void atk_value_get_maximum_value (AtkValue *obj, + GValue *value); + +void atk_value_get_minimum_value (AtkValue *obj, + GValue *value); + +gboolean atk_value_set_current_value (AtkValue *obj, + GValue *value); + +/* + * Additional GObject properties exported by GaccessibleValue: + * "accessible_value" + * (the accessible value has changed) + */ + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + + +#endif /* __ATK_VALUE_H__ */ diff --git a/autogen.sh b/autogen.sh new file mode 100755 index 0000000..253c618 --- /dev/null +++ b/autogen.sh @@ -0,0 +1,57 @@ +#!/bin/sh +# Run this to generate all the initial makefiles, etc. + +srcdir=`dirname $0` +test -z "$srcdir" && srcdir=. + +ORIGDIR=`pwd` +cd $srcdir +PROJECT=Atk +TEST_TYPE=-f +FILE=atk/atk.h + +DIE=0 + +(autoconf --version) < /dev/null > /dev/null 2>&1 || { + echo + echo "You must have autoconf installed to compile $PROJECT." + echo "Download the appropriate package for your distribution," + echo "or get the source tarball at ftp://ftp.gnu.org/pub/gnu/" + DIE=1 +} + +(automake --version) < /dev/null > /dev/null 2>&1 || { + echo + echo "You must have automake installed to compile $PROJECT." + echo "Get ftp://sourceware.cygnus.com/pub/automake/automake-1.4.tar.gz" + echo "(or a newer version if it is available)" + DIE=1 +} + +if test "$DIE" -eq 1; then + exit 1 +fi + +test $TEST_TYPE $FILE || { + echo "You must run this script in the top-level $PROJECT directory" + exit 1 +} + +if test -z "$*"; then + echo "I am going to run ./configure with no arguments - if you wish " + echo "to pass any to it, please specify them on the $0 command line." +fi + +aclocal $ACLOCAL_FLAGS + +# optionally run autoheader +(autoheader --version) < /dev/null > /dev/null 2>&1 && autoheader + +automake -a $am_opt +autoconf +cd $ORIGDIR + +$srcdir/configure --enable-maintainer-mode "$@" + +echo +echo "Now type 'make' to compile $PROJECT." diff --git a/configure.in b/configure.in new file mode 100644 index 0000000..bbe2266 --- /dev/null +++ b/configure.in @@ -0,0 +1,81 @@ +dnl Process this file with autoconf to produce a configure script. + +ATK_MAJOR_VERSION=0 +ATK_MINOR_VERSION=1 + +AC_SUBST(ATK_MAJOR_VERSION) +AC_SUBST(ATK_MINOR_VERSION) + +AC_INIT(ChangeLog) +AM_INIT_AUTOMAKE(atk, 0.1) + +AC_PROG_CC +AM_DISABLE_STATIC +AM_PROG_LIBTOOL + +changequote(,)dnl +if test "x$GCC" = "xyes"; then + case " $CFLAGS " in + *[\ \ ]-Wall[\ \ ]*) ;; + *) CFLAGS="$CFLAGS -Wall" ;; + esac +fi +changequote([,])dnl + + +# +# Find pkg-config +# +AC_PATH_PROG(PKG_CONFIG, pkg-config, no) +if test x$PKG_CONFIG = xno ; then + AC_MSG_ERROR([*** pkg-config not found. See http://pkgconfig.sourceforge.net]) +fi + +if ! pkg-config --atleast-pkgconfig-version 0.5 ; then + AC_MSG_ERROR([*** pkg-config too old; version 0.5 or better required.]) +fi + +GLIB_PACKAGES="gobject-2.0 gmodule-2.0 gthread-2.0" +AC_SUBST(GLIB_PACKAGES) +GLIB_REQUIRED_VERSION=1.3.2 + +AC_MSG_CHECKING(GLib version) +if $PKG_CONFIG --atleast-version $GLIB_REQUIRED_VERSION glib-2.0 ; then + AC_MSG_RESULT(yes) +else + AC_MSG_ERROR([ +*** GLIB $GLIB_REQUIRED_VERSION or newer is required. The latest version of GLIB +*** is always available from ftp://ftp.gtk.org/. + ]) +fi + +PANGO_PACKAGES="pango" +AC_SUBST(PANGO_PACKAGES) + +# Check for Pango flags + +AC_MSG_CHECKING(Pango version) +if $PKG_CONFIG --exists $PANGO_PACKAGES ; then + AC_MSG_RESULT(yes) +else + AC_MSG_ERROR([ +*** Pango not found. Pango is required to build ATK. +*** See http://www.pango.org for Pango information. +]) +fi + +DEP_CFLAGS=`$PKG_CONFIG --cflags $GLIB_PACKAGES $PANGO_PACKAGES` +DEP_LIBS=`$PKG_CONFIG --libs $GLIB_PACKAGES $PANGO_PACKAGES` +AC_SUBST(DEP_CFLAGS) +AC_SUBST(DEP_LIBS) + +AC_CHECK_LIB(pango, pango_context_new, :, AC_MSG_ERROR([ +*** Can't link to Pango. Pango is required to build +*** GTK+. For more information see http://www.pango.org]), $DEP_LIBS) + + +AC_OUTPUT([ +Makefile +atk/Makefile +atk.pc +])