Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-30 09:32:49

0001 /* ATK -  Accessibility Toolkit
0002  * Copyright 2001 Sun Microsystems Inc.
0003  *
0004  * This library is free software; you can redistribute it and/or
0005  * modify it under the terms of the GNU Library General Public
0006  * License as published by the Free Software Foundation; either
0007  * version 2 of the License, or (at your option) any later version.
0008  *
0009  * This library is distributed in the hope that it will be useful,
0010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0012  * Library General Public License for more details.
0013  *
0014  * You should have received a copy of the GNU Library General Public
0015  * License along with this library; if not, write to the
0016  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
0017  * Boston, MA 02111-1307, USA.
0018  */
0019 
0020 #ifndef __ATK_UTIL_H__
0021 #define __ATK_UTIL_H__
0022 
0023 #if defined(ATK_DISABLE_SINGLE_INCLUDES) && !defined(__ATK_H_INSIDE__) && !defined(ATK_COMPILATION)
0024 #error "Only <atk/atk.h> can be included directly."
0025 #endif
0026 
0027 #include <atk/atkobject.h>
0028 
0029 G_BEGIN_DECLS
0030 
0031 #define ATK_TYPE_UTIL (atk_util_get_type ())
0032 #define ATK_IS_UTIL(obj) G_TYPE_CHECK_INSTANCE_TYPE ((obj), ATK_TYPE_UTIL)
0033 #define ATK_UTIL(obj) G_TYPE_CHECK_INSTANCE_CAST ((obj), ATK_TYPE_UTIL, AtkUtil)
0034 #define ATK_UTIL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ATK_TYPE_UTIL, AtkUtilClass))
0035 #define ATK_IS_UTIL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), ATK_TYPE_UTIL))
0036 #define ATK_UTIL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), ATK_TYPE_UTIL, AtkUtilClass))
0037 
0038 #ifndef _TYPEDEF_ATK_UTIL_
0039 #define _TYPEDEF_ATK_UTIL_
0040 typedef struct _AtkUtil AtkUtil;
0041 typedef struct _AtkUtilClass AtkUtilClass;
0042 typedef struct _AtkKeyEventStruct AtkKeyEventStruct;
0043 #endif
0044 
0045 /**
0046  * AtkEventListener:
0047  * @obj: An #AtkObject instance for whom the callback will be called when
0048  * the specified event (e.g. 'focus:') takes place.
0049  *
0050  * A function which is called when an object emits a matching event,
0051  * as used in #atk_add_focus_tracker.
0052  * Currently the only events for which object-specific handlers are
0053  * supported are events of type "focus:".  Most clients of ATK will prefer to
0054  * attach signal handlers for the various ATK signals instead.
0055  *
0056  * see [id@atk_add_focus_tracker]
0057  **/
0058 typedef void (*AtkEventListener) (AtkObject *obj);
0059 /**
0060  * AtkEventListenerInit:
0061  *
0062  * An #AtkEventListenerInit function is a special function that is
0063  * called in order to initialize the per-object event registration system
0064  * used by #AtkEventListener, if any preparation is required.
0065  *
0066  * see [id@atk_focus_tracker_init]
0067  **/
0068 typedef void (*AtkEventListenerInit) (void);
0069 /**
0070  * AtkKeySnoopFunc:
0071  * @event: an AtkKeyEventStruct containing information about the key event for which
0072  * notification is being given.
0073  * @user_data: a block of data which will be passed to the event listener, on notification.
0074  *
0075  * An #AtkKeySnoopFunc is a type of callback which is called whenever a key event occurs,
0076  * if registered via atk_add_key_event_listener.  It allows for pre-emptive
0077  * interception of key events via the return code as described below.
0078  *
0079  * Returns: TRUE (nonzero) if the event emission should be stopped and the event
0080  * discarded without being passed to the normal GUI recipient; FALSE (zero) if the
0081  * event dispatch to the client application should proceed as normal.
0082  *
0083  * see [id@atk_add_key_event_listener]
0084  **/
0085 typedef gint (*AtkKeySnoopFunc) (AtkKeyEventStruct *event,
0086                                  gpointer user_data);
0087 
0088 /**
0089  * AtkKeyEventStruct:
0090  * @type: An AtkKeyEventType, generally one of ATK_KEY_EVENT_PRESS or ATK_KEY_EVENT_RELEASE
0091  * @state: A bitmask representing the state of the modifier keys immediately after the event takes place.
0092  * The meaning of the bits is currently defined to match the bitmask used by GDK in
0093  * GdkEventType.state, see
0094  * http://developer.gnome.org/doc/API/2.0/gdk/gdk-Event-Structures.html#GdkEventKey
0095  * @keyval: A guint representing a keysym value corresponding to those used by GDK and X11: see
0096  * /usr/X11/include/keysymdef.h.
0097  * @length: The length of member #string.
0098  * @string: A string containing one of the following: either a string approximating the text that would
0099  * result from this keypress, if the key is a control or graphic character, or a symbolic name for this keypress.
0100  * Alphanumeric and printable keys will have the symbolic key name in this string member, for instance "A". "0",
0101  * "semicolon", "aacute".  Keypad keys have the prefix "KP".
0102  * @keycode: The raw hardware code that generated the key event.  This field is raraly useful.
0103  * @timestamp: A timestamp in milliseconds indicating when the event occurred.
0104  * These timestamps are relative to a starting point which should be considered arbitrary,
0105  * and only used to compare the dispatch times of events to one another.
0106  *
0107  * Encapsulates information about a key event.
0108  **/
0109 struct _AtkKeyEventStruct
0110 {
0111   gint type;
0112   guint state;
0113   guint keyval;
0114   gint length;
0115   gchar *string;
0116   guint16 keycode;
0117   guint32 timestamp;
0118 };
0119 
0120 /**
0121  *AtkKeyEventType:
0122  *@ATK_KEY_EVENT_PRESS: specifies a key press event
0123  *@ATK_KEY_EVENT_RELEASE: specifies a key release event
0124  *@ATK_KEY_EVENT_LAST_DEFINED: Not a valid value; specifies end of enumeration
0125  *
0126  *Specifies the type of a keyboard evemt.
0127  **/
0128 typedef enum
0129 {
0130   ATK_KEY_EVENT_PRESS,
0131   ATK_KEY_EVENT_RELEASE,
0132   ATK_KEY_EVENT_LAST_DEFINED
0133 } AtkKeyEventType;
0134 
0135 struct _AtkUtil
0136 {
0137   GObject parent;
0138 };
0139 
0140 /**
0141  * AtkUtilClass:
0142  * @add_global_event_listener: adds the specified function to the list
0143  *  of functions to be called when an ATK event occurs. ATK
0144  *  implementors are discouraged from reimplementing this method.
0145  * @remove_global_event_listener: removes the specified function to
0146  *  the list of functions to be called when an ATK event occurs. ATK
0147  *  implementors are discouraged from reimplementing this method.
0148  * @add_key_event_listener: adds the specified function to the list of
0149  *  functions to be called when a key event occurs.
0150  * @remove_key_event_listener: remove the specified function to the
0151  *  list of functions to be called when a key event occurs.
0152  * @get_root: gets the root accessible container for the current
0153  *  application.
0154  * @get_toolkit_name: gets name string for the GUI toolkit
0155  *  implementing ATK for this application.
0156  * @get_toolkit_version: gets version string for the GUI toolkit
0157  *  implementing ATK for this application.
0158  *
0159  */
0160 struct _AtkUtilClass
0161 {
0162   GObjectClass parent;
0163   guint (*add_global_event_listener) (GSignalEmissionHook listener,
0164                                       const gchar *event_type);
0165   void (*remove_global_event_listener) (guint listener_id);
0166   guint (*add_key_event_listener) (AtkKeySnoopFunc listener,
0167                                    gpointer data);
0168   void (*remove_key_event_listener) (guint listener_id);
0169   AtkObject *(*get_root) (void);
0170   const gchar *(*get_toolkit_name) (void);
0171   const gchar *(*get_toolkit_version) (void);
0172 };
0173 ATK_AVAILABLE_IN_ALL
0174 GType atk_util_get_type (void);
0175 
0176 /**
0177  *AtkCoordType:
0178  *@ATK_XY_SCREEN: specifies xy coordinates relative to the screen
0179  *@ATK_XY_WINDOW: specifies xy coordinates relative to the widget's
0180  * top-level window
0181  *@ATK_XY_PARENT: specifies xy coordinates relative to the widget's
0182  * immediate parent. Since: 2.30
0183  *
0184  *Specifies how xy coordinates are to be interpreted. Used by functions such
0185  *as atk_component_get_position() and atk_text_get_character_extents()
0186  **/
0187 typedef enum
0188 {
0189   ATK_XY_SCREEN,
0190   ATK_XY_WINDOW,
0191   ATK_XY_PARENT
0192 } AtkCoordType;
0193 
0194 ATK_DEPRECATED_IN_2_10
0195 guint atk_add_focus_tracker (AtkEventListener focus_tracker);
0196 ATK_DEPRECATED_IN_2_10
0197 void atk_remove_focus_tracker (guint tracker_id);
0198 ATK_DEPRECATED_IN_2_10
0199 void atk_focus_tracker_init (AtkEventListenerInit init);
0200 ATK_DEPRECATED_IN_2_10
0201 void atk_focus_tracker_notify (AtkObject *object);
0202 ATK_AVAILABLE_IN_ALL
0203 guint atk_add_global_event_listener (GSignalEmissionHook listener,
0204                                      const gchar *event_type);
0205 ATK_AVAILABLE_IN_ALL
0206 void atk_remove_global_event_listener (guint listener_id);
0207 ATK_AVAILABLE_IN_ALL
0208 guint atk_add_key_event_listener (AtkKeySnoopFunc listener, gpointer data);
0209 ATK_AVAILABLE_IN_ALL
0210 void atk_remove_key_event_listener (guint listener_id);
0211 
0212 ATK_AVAILABLE_IN_ALL
0213 AtkObject *atk_get_root (void);
0214 ATK_AVAILABLE_IN_ALL
0215 AtkObject *atk_get_focus_object (void);
0216 
0217 ATK_AVAILABLE_IN_ALL
0218 const gchar *atk_get_toolkit_name (void);
0219 ATK_AVAILABLE_IN_ALL
0220 const gchar *atk_get_toolkit_version (void);
0221 ATK_AVAILABLE_IN_ALL
0222 const gchar *atk_get_version (void);
0223 
0224 /* --- GType boilerplate --- */
0225 /* convenience macros for atk type implementations, which for a type GtkGadgetAccessible will:
0226  * - prototype: static void     gtk_gadget_accessible_class_init (GtkGadgetClass *klass);
0227  * - prototype: static void     gtk_gadget_accessible_init       (GtkGadget      *self);
0228  * - define:    static gpointer gtk_gadget_accessible_parent_class = NULL;
0229  *   gtk_gadget_accessible_parent_class is initialized prior to calling gtk_gadget_class_init()
0230  * - implement: GType           gtk_gadget_accessible_get_type (void) { ... }
0231  * - support custom code in gtk_gadget_accessible_get_type() after the type is registered.
0232  *
0233  * macro arguments: TypeName, type_name, TYPE_PARENT, CODE
0234  * example: ATK_DEFINE_TYPE_WITH_CODE (GtkGadgetAccessible, gtk_gadget_accessible, GTK_TYPE_GADGET,
0235  *                                     G_IMPLEMENT_INTERFACE (ATK_TYPE_TABLE, gtk_gadget_accessible_table_iface_init))
0236  */
0237 
0238 /**
0239  * ATK_DEFINE_TYPE:
0240  * @TN: The name of the new type, in Camel case.
0241  * @t_n: The name of the new type, in lowercase, with words separated by '_'.
0242  * @T_P: The #GType of the parent type.
0243  *
0244  * A convenience macro for type ATK implementations, which declares a class
0245  * initialization function, an instance initialization function (see #GTypeInfo
0246  * for information about these) and a static variable named
0247  * @t_n _parent_class pointing to the parent class. Furthermore, it
0248  * defines a _get_type() function.
0249  *
0250  * Since: 1.22
0251  */
0252 #define ATK_DEFINE_TYPE(TN, t_n, T_P) ATK_DEFINE_TYPE_EXTENDED (TN, t_n, T_P, 0, {})
0253 
0254 /**
0255  * ATK_DEFINE_TYPE_WITH_CODE:
0256  * @TN: The name of the new type, in Camel case.
0257  * @t_n: The name of the new type in lowercase, with words separated by '_'.
0258  * @T_P: The #GType of the parent type.
0259  * @_C_: Custom code that gets inserted in the _get_type() function.
0260  *
0261  * A convenience macro for ATK type implementations.
0262  * Similar to ATK_DEFINE_TYPE(), but allows you to insert custom code into the
0263  * _get_type() function, e.g. interface implementations via G_IMPLEMENT_INTERFACE().
0264  *
0265  * Since: 1.22
0266  */
0267 #define ATK_DEFINE_TYPE_WITH_CODE(TN, t_n, T_P, _C_)         \
0268   _ATK_DEFINE_TYPE_EXTENDED_BEGIN (TN, t_n, T_P, 0) { _C_; } \
0269   _ATK_DEFINE_TYPE_EXTENDED_END ()
0270 
0271 /**
0272  * ATK_DEFINE_ABSTRACT_TYPE:
0273  * @TN: The name of the new type, in Camel case.
0274  * @t_n: The name of the new type, in lowercase, with words separated by '_'.
0275  * @T_P: The #GType of the parent type.
0276  *
0277  * A convenience macro for ATK type implementations.
0278  * Similar to ATK_DEFINE_TYPE(), but defines an abstract type.
0279  *
0280  * Since: 1.22
0281  */
0282 #define ATK_DEFINE_ABSTRACT_TYPE(TN, t_n, T_P) ATK_DEFINE_TYPE_EXTENDED (TN, t_n, T_P, G_TYPE_FLAG_ABSTRACT, {})
0283 
0284 /**
0285  * ATK_DEFINE_ABSTRACT_TYPE_WITH_CODE:
0286  * @TN: The name of the new type, in Camel case.
0287  * @t_n: The name of the new type, in lowercase, with words separated by '_'.
0288  * @T_P: The #GType of the parent type.
0289  * @_C_: Custom code that gets inserted in the _get_type() function.
0290  *
0291  * A convenience macro for ATK type implementations.
0292  * Similar to ATK_DEFINE_TYPE_WITH_CODE(), but defines an abstract type.
0293  *
0294  * Since: 1.22
0295  */
0296 #define ATK_DEFINE_ABSTRACT_TYPE_WITH_CODE(TN, t_n, T_P, _C_)                   \
0297   _ATK_DEFINE_TYPE_EXTENDED_BEGIN (TN, t_n, T_P, G_TYPE_FLAG_ABSTRACT) { _C_; } \
0298   _ATK_DEFINE_TYPE_EXTENDED_END ()
0299 
0300 /**
0301  * ATK_DEFINE_TYPE_EXTENDED:
0302  * @TN: The name of the new type, in Camel case.
0303  * @t_n: The name of the new type, in lowercase, with words separated by '_'.
0304  * @T_P: The #GType of the parent type.
0305  * @_f_: #GTypeFlags to pass to g_type_register_static()
0306  * @_C_: Custom code that gets inserted in the _get_type() function.
0307  *
0308  * The most general convenience macro for ATK type implementations, on which
0309  * ATK_DEFINE_TYPE(), etc are based.
0310  *
0311  * Since: 1.22
0312  */
0313 #define ATK_DEFINE_TYPE_EXTENDED(TN, t_n, T_P, _f_, _C_)       \
0314   _ATK_DEFINE_TYPE_EXTENDED_BEGIN (TN, t_n, T_P, _f_) { _C_; } \
0315   _ATK_DEFINE_TYPE_EXTENDED_END ()
0316 
0317 #define _ATK_DEFINE_TYPE_EXTENDED_BEGIN(TypeName, type_name, TYPE, flags)                  \
0318                                                                                            \
0319   static void type_name##_init (TypeName *self);                                           \
0320   static void type_name##_class_init (TypeName##Class *klass);                             \
0321   static gpointer type_name##_parent_class = NULL;                                         \
0322   static void type_name##_class_intern_init (gpointer klass)                               \
0323   {                                                                                        \
0324     type_name##_parent_class = g_type_class_peek_parent (klass);                           \
0325     type_name##_class_init ((TypeName##Class *) klass);                                    \
0326   }                                                                                        \
0327                                                                                            \
0328   ATK_AVAILABLE_IN_ALL                                                                     \
0329   GType                                                                                    \
0330       type_name##_get_type (void)                                                          \
0331   {                                                                                        \
0332     static volatile gsize g_define_type_id__volatile = 0;                                  \
0333     if (g_once_init_enter (&g_define_type_id__volatile))                                   \
0334       {                                                                                    \
0335         AtkObjectFactory *factory;                                                         \
0336         GType derived_type;                                                                \
0337         GTypeQuery query;                                                                  \
0338         GType derived_atk_type;                                                            \
0339         GType g_define_type_id;                                                            \
0340                                                                                            \
0341         /* Figure out the size of the class and instance we are deriving from */           \
0342         derived_type = g_type_parent (TYPE);                                               \
0343         factory = atk_registry_get_factory (atk_get_default_registry (),                   \
0344                                             derived_type);                                 \
0345         derived_atk_type = atk_object_factory_get_accessible_type (factory);               \
0346         g_type_query (derived_atk_type, &query);                                           \
0347                                                                                            \
0348         g_define_type_id =                                                                 \
0349             g_type_register_static_simple (derived_atk_type,                               \
0350                                            g_intern_static_string (#TypeName),             \
0351                                            query.class_size,                               \
0352                                            (GClassInitFunc) type_name##_class_intern_init, \
0353                                            query.instance_size,                            \
0354                                            (GInstanceInitFunc) type_name##_init,           \
0355                                            (GTypeFlags) flags);                            \
0356         { /* custom code follows */
0357 #define _ATK_DEFINE_TYPE_EXTENDED_END()                              \
0358   /* following custom code */                                        \
0359   }                                                                  \
0360   g_once_init_leave (&g_define_type_id__volatile, g_define_type_id); \
0361   }                                                                  \
0362   return g_define_type_id__volatile;                                 \
0363   } /* closes type_name##_get_type() */
0364 
0365 G_END_DECLS
0366 
0367 #endif /* __ATK_UTIL_H__ */