atkrelation.c \
atkrelationset.c \
atkselection.c \
+ atkstate.c \
atkstateset.c \
atktable.c \
atktext.c \
atkrelation.h \
atkrelationset.h \
atkselection.h \
+ atkstate.h \
atkstateset.h \
atktable.h \
atktext.h \
#include <atk/atkrelation.h>
#include <atk/atkrelationset.h>
#include <atk/atkselection.h>
+#include <atk/atkstate.h>
#include <atk/atkstateset.h>
#include <atk/atktable.h>
#include <atk/atktext.h>
#include "atk.h"
-#define NUM_POSSIBLE_STATES (sizeof(AtkStateMask)*8)
-
-#define ATK_STATE(state_enum) ((AtkStateMask)(1 << ((guint64)(state_enum)%64)))
-
/* New GObject properties registered by AtkObject */
enum
{
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
klass->ref_relation_set = atk_object_real_ref_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,
}
/**
- * atk_state_register
- * @name: a character string describing the new state.
- * return values: a #AtkState value for the new state.
- *
- * Returns a #AtkState value for the new state.
- **/
-AtkStateType
-atk_state_type_register (const 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 */
-}
-
-/**
* atk_object_ref_state_set
* @accessible: a #AtkObject
* return values: a reference to a #AtkStateSet which is the state set of the accessible
(klass->remove_property_change_handler) (accessible, handler_id);
}
-G_CONST_RETURN gchar*
-atk_state_mask_get_name (AtkStateMask state)
-{
- gint n;
-
- if (state == 0)
- return NULL;
-
- for (n=0; n<NUM_POSSIBLE_STATES; ++n)
- {
- /* fall through and return null if multiple bits are set */
- if (state == (1 << n)) return state_names[n];
- }
-
- return NULL;
-}
-
-AtkStateMask
-atk_state_mask_for_name (const gchar *name)
-{
- gint i;
-
- g_return_val_if_fail ((strlen(name)>0), 0);
- for (i=0; i<NUM_POSSIBLE_STATES; ++i)
- {
- if (!strcmp(name, state_names[i])) return ATK_STATE(i);
- }
- return 0;
-}
-
/**
* atk_implementor_ref_accessible
* @object: The GObject instance which should implement #AtkImplementorIface
AtkRole atk_role_register (const 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_DEFUNCT,
- /* Indicates this object may have been removed by the application */
- ATK_STATE_EDITABLE,
- /* Indicates this object allows progressive disclosure of its children */
- ATK_STATE_EXPANDABLE,
- /* Indicates this object is expandable */
- 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 (const gchar *name);
-
#define ATK_TYPE_OBJECT (atk_object_get_type ())
#define ATK_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ATK_TYPE_OBJECT, AtkObject))
typedef struct _AtkRelationSet AtkRelationSet;
typedef struct _AtkStateSet AtkStateSet;
-typedef guint64 AtkState;
-typedef guint64 AtkStateMask;
-
-
struct _AtkPropertyValues
{
gchar *property_name;
* cpos = atk_text_get_caret_position (ATK_TEXT (accessible));
*/
-G_CONST_RETURN gchar* atk_state_mask_get_name (AtkStateMask state);
-AtkStateMask atk_state_mask_for_name (const gchar *name);
-
#ifdef __cplusplus
}
#endif /* __cplusplus */
--- /dev/null
+/* 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 "atkstate.h"
+
+#define NUM_POSSIBLE_STATES (sizeof(AtkState)*8)
+
+static gchar* state_names[NUM_POSSIBLE_STATES] = {
+ "invalid",
+ "active",
+ "armed",
+ "busy",
+ "checked",
+ "collapsed",
+ "defunct",
+ "editable",
+ "expandable",
+ "expanded",
+ "focusable",
+ "focused",
+ "horizontal",
+ "iconified",
+ "modal",
+ "multi-line",
+ "multiselect,ble",
+ "opaque",
+ "pressed",
+ "resizeable",
+ "selectable",
+ "selected",
+ "sensitive",
+ "showing",
+ "single-line",
+ "transient",
+ "vertical",
+ "visible"
+};
+
+/**
+ * atk_state_type_register
+ * @name: a character string describing the new state.
+ * return values: a #AtkState value for the new state.
+ *
+ * Returns a #AtkState value for the new state.
+ **/
+AtkStateType
+atk_state_type_register (const gchar *name)
+{
+ static guint type = ATK_STATE_LAST_DEFINED;
+ if (type < NUM_POSSIBLE_STATES)
+ {
+ state_names[++type] = g_strdup (name);
+ return (type);
+ }
+ return ATK_STATE_INVALID; /* caller needs to check */
+}
+
+/**
+ * atk_state_type_get_name
+ * @state: The #AtkStateType whose name is required
+ * Return the string describing the state
+ */
+G_CONST_RETURN gchar*
+atk_state_type_get_name (AtkStateType state)
+{
+ gint n;
+
+ if (state == 0)
+ return NULL;
+
+ for (n=0; n<NUM_POSSIBLE_STATES; n++)
+ {
+ if (state == n)
+ return state_names[n];
+ }
+
+ return NULL;
+}
+
+AtkStateType
+atk_state_type_for_name (const gchar *name)
+{
+ gint i;
+
+ g_return_val_if_fail (name != NULL, 0);
+ g_return_val_if_fail (strlen (name) > 0, 0);
+
+ for (i = 0; i < NUM_POSSIBLE_STATES; i++)
+ {
+ if (state_names[i] == NULL)
+ continue;
+ if (!strcmp(name, state_names[i]))
+ return i;
+ }
+ return 0;
+}
--- /dev/null
+/* 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_STATE_H__
+#define __ATK_STATE_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+#include <glib-object.h>
+
+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 interface object corresponding to this object
+ * no longer exists.
+ */
+ ATK_STATE_DEFUNCT,
+ /* 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;
+
+typedef guint64 AtkState;
+
+AtkStateType atk_state_type_register (const gchar *name);
+
+G_CONST_RETURN gchar* atk_state_type_get_name (AtkStateType type);
+AtkStateType atk_state_type_for_name (const gchar *name);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* __ATK_STATE_H__ */
#include "atkobject.h"
#include "atkstateset.h"
-#define ATK_STATE(state_enum) ((AtkStateMask)(1 << ((guint64)(state_enum)%64)))
+#define ATK_STATE(state_enum) ((AtkState)(1 << ((guint64)(state_enum)%64)))
struct _AtkRealStateSet
{
#include <glib-object.h>
#include <atk/atkobject.h>
+#include <atk/atkstate.h>
#define ATK_TYPE_STATE_SET (atk_state_set_get_type ())
#define ATK_STATE_SET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ATK_TYPE_STATE_SET, AtkStateSet))
#include <atk/atk.h>
-static gboolean test_state_set();
+static gboolean test_state_set ();
+static gboolean test_state ();
static gboolean
-test_state_set()
+test_state_set ()
{
AtkStateSet *state_set1, *state_set2, *state_set3;
AtkStateType state_array[3];
gboolean b_val;
- state_set1 = atk_state_set_new();
+ state_set1 = atk_state_set_new ();
b_val = atk_state_set_is_empty (state_set1);
if (b_val)
}
+static gboolean
+test_state ()
+{
+ AtkStateType type1, type2;
+ G_CONST_RETURN gchar *name;
+
+ name = atk_state_type_get_name (ATK_STATE_VISIBLE);
+ g_return_val_if_fail (name, FALSE);
+ if (strcmp (name, "visible") != 0)
+ {
+ g_print ("Unexpected name for ATK_STATE_VISIBLE %s\n", name);
+ return FALSE;
+ }
+
+ name = atk_state_type_get_name (ATK_STATE_MODAL);
+ g_return_val_if_fail (name, FALSE);
+ if (strcmp (name, "modal") != 0)
+ {
+ g_print ("Unexpected name for ATK_STATE_MODAL %s\n", name);
+ return FALSE;
+ }
+
+ type1 = atk_state_type_for_name ("focused");
+ if (type1 != ATK_STATE_FOCUSED)
+ {
+ g_print ("Unexpected type for focused\n");
+ return FALSE;
+ }
+
+ type1 = atk_state_type_register ("test_state");
+ name = atk_state_type_get_name (type1);
+ g_return_val_if_fail (name, FALSE);
+ if (strcmp (name, "test_state") != 0)
+ {
+ g_print ("Unexpected name for test_state %s\n", name);
+ return FALSE;
+ }
+ type2 = atk_state_type_for_name ("test_state");
+ g_return_val_if_fail (name, FALSE);
+ if (type1 != type2)
+ {
+ g_print ("Unexpected type for test_state\n");
+ return FALSE;
+ }
+ type2 = atk_state_type_for_name ("TEST-STATE");
+ if (type2 != 0)
+ {
+ g_print ("Unexpected type for TEST-STATE\n");
+ return FALSE;
+ }
+ /*
+ * Check that a non-existent type returns NULL
+ */
+ name = atk_state_type_get_name (ATK_STATE_LAST_DEFINED +2);
+ if (name)
+ {
+ g_print ("Unexpected name for undefined type\n");
+ return FALSE;
+ }
+ return TRUE;
+}
+
int
-gtk_module_init(gint argc, char* argv[])
+gtk_module_init (gint argc, char* argv[])
{
gboolean b_ret;
g_print("State Set test module loaded\n");
- b_ret = test_state_set();
-
+ b_ret = test_state_set ();
if (b_ret)
{
g_print ("State Set tests succeeded\n");
{
g_print ("State Set tests failed\n");
}
+ b_ret = test_state ();
+ if (b_ret)
+ {
+ g_print ("State tests succeeded\n");
+ }
+ else
+ {
+ g_print ("State tests failed\n");
+ }
return 0;
}