KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > swt > accessibility > AccessibleFactory


1 /*******************************************************************************
2  * Copyright (c) 2000, 2005 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.swt.accessibility;
12
13
14 import java.util.*;
15 import org.eclipse.swt.internal.*;
16 import org.eclipse.swt.internal.accessibility.gtk.*;
17 import org.eclipse.swt.internal.gtk.*;
18 import org.eclipse.swt.*;
19
20 class AccessibleFactory {
21     int /*long*/ handle;
22     int /*long*/ objectParentType;
23     int /*long*/ widgetTypeName;
24     Callback atkObjectFactoryCB_create_accessible;
25     Callback gTypeInfo_base_init_factory;
26     Hashtable accessibles = new Hashtable (9);
27     
28     static final Hashtable Types = new Hashtable (9);
29     static final Hashtable Factories = new Hashtable (9);
30     static final int /*long*/ DefaultParentType = OS.g_type_from_name (Converter.wcsToMbcs (null, "GtkAccessible", true)); //$NON-NLS-1$
31
static final byte[] FACTORY_PARENTTYPENAME = Converter.wcsToMbcs (null, "AtkObjectFactory", true); //$NON-NLS-1$
32
static final byte[] SWT_TYPE_PREFIX = Converter.wcsToMbcs (null, "SWT", false); //$NON-NLS-1$
33
static final byte[] CHILD_TYPENAME = Converter.wcsToMbcs (null, "Child", false); //$NON-NLS-1$
34
static final byte[] FACTORY_TYPENAME = Converter.wcsToMbcs (null, "SWTFactory", true); //$NON-NLS-1$
35
static final int[] actionRoles = {
36         ACC.ROLE_CHECKBUTTON, ACC.ROLE_COMBOBOX, ACC.ROLE_LINK,
37         ACC.ROLE_MENUITEM, ACC.ROLE_PUSHBUTTON, ACC.ROLE_RADIOBUTTON,
38     };
39     static final int[] hypertextRoles = {ACC.ROLE_LINK};
40     static final int[] selectionRoles = {
41         ACC.ROLE_LIST, ACC.ROLE_TABFOLDER, ACC.ROLE_TABLE, ACC.ROLE_TREE,
42     };
43     static final int[] textRoles = {
44         ACC.ROLE_COMBOBOX, ACC.ROLE_LINK, ACC.ROLE_LABEL, ACC.ROLE_TEXT,
45     };
46
47     /* AT callbacks*/
48     static final Callback AtkActionCB_get_keybinding;
49     static final Callback AtkActionCB_get_name;
50     static final Callback AtkComponentCB_get_extents;
51     static final Callback AtkComponentCB_get_position;
52     static final Callback AtkComponentCB_get_size;
53     static final Callback AtkComponentCB_ref_accessible_at_point;
54     static final Callback AtkHypertextCB_get_link;
55     static final Callback AtkHypertextCB_get_n_links;
56     static final Callback AtkHypertextCB_get_link_index;
57     static final Callback AtkObjectCB_get_description;
58     static final Callback AtkObjectCB_get_index_in_parent;
59     static final Callback AtkObjectCB_get_n_children;
60     static final Callback AtkObjectCB_get_name;
61     static final Callback AtkObjectCB_get_parent;
62     static final Callback AtkObjectCB_get_role;
63     static final Callback AtkObjectCB_ref_child;
64     static final Callback AtkObjectCB_ref_state_set;
65     static final Callback AtkSelectionCB_is_child_selected;
66     static final Callback AtkSelectionCB_ref_selection;
67     static final Callback AtkTextCB_get_caret_offset;
68     static final Callback AtkTextCB_get_n_selections;
69     static final Callback AtkTextCB_get_selection;
70     static final Callback AtkTextCB_get_text;
71     static final Callback AtkTextCB_get_text_after_offset;
72     static final Callback AtkTextCB_get_text_at_offset;
73     static final Callback AtkTextCB_get_text_before_offset;
74     static final Callback AtkTextCB_get_character_at_offset;
75     static final Callback AtkTextCB_get_character_count;
76     static final Callback GObjectClass_finalize;
77     /* interface initialization callbacks */
78     static final Callback InitActionIfaceCB;
79     static final Callback InitComponentIfaceCB;
80     static final Callback InitHypertextIfaceCB;
81     static final Callback GTypeInfo_base_init_type;
82     static final Callback InitSelectionIfaceCB;
83     static final Callback InitTextIfaceCB;
84     /* interface definitions */
85     static int /*long*/ ObjectIfaceDefinition;
86     static final int /*long*/ ActionIfaceDefinition;
87     static final int /*long*/ ComponentIfaceDefinition;
88     static final int /*long*/ HypertextIfaceDefinition;
89     static final int /*long*/ SelectionIfaceDefinition;
90     static final int /*long*/ TextIfaceDefinition;
91     static {
92         AtkActionCB_get_keybinding = newCallback (AccessibleObject.class, "atkAction_get_keybinding", 2); //$NON-NLS-1$
93
AtkActionCB_get_name = newCallback (AccessibleObject.class, "atkAction_get_name", 2); //$NON-NLS-1$
94
AtkComponentCB_get_extents = newCallback (AccessibleObject.class, "atkComponent_get_extents", 6); //$NON-NLS-1$
95
AtkComponentCB_get_position = newCallback (AccessibleObject.class, "atkComponent_get_position", 4); //$NON-NLS-1$
96
AtkComponentCB_get_size = newCallback (AccessibleObject.class, "atkComponent_get_size", 4); //$NON-NLS-1$
97
AtkComponentCB_ref_accessible_at_point = newCallback (AccessibleObject.class, "atkComponent_ref_accessible_at_point", 4); //$NON-NLS-1$
98
AtkHypertextCB_get_link = newCallback (AccessibleObject.class, "atkHypertext_get_link", 2); //$NON-NLS-1$
99
AtkHypertextCB_get_n_links = newCallback (AccessibleObject.class, "atkHypertext_get_n_links", 1); //$NON-NLS-1$
100
AtkHypertextCB_get_link_index = newCallback (AccessibleObject.class, "atkHypertext_get_link_index", 2); //$NON-NLS-1$
101
AtkObjectCB_get_name = newCallback (AccessibleObject.class, "atkObject_get_name", 1); //$NON-NLS-1$
102
AtkObjectCB_get_description = newCallback (AccessibleObject.class, "atkObject_get_description", 1); //$NON-NLS-1$
103
AtkObjectCB_get_n_children = newCallback (AccessibleObject.class, "atkObject_get_n_children", 1); //$NON-NLS-1$
104
AtkObjectCB_get_role = newCallback (AccessibleObject.class, "atkObject_get_role", 1); //$NON-NLS-1$
105
AtkObjectCB_get_parent = newCallback (AccessibleObject.class, "atkObject_get_parent", 1); //$NON-NLS-1$
106
AtkObjectCB_ref_state_set = newCallback (AccessibleObject.class, "atkObject_ref_state_set", 1); //$NON-NLS-1$
107
AtkObjectCB_get_index_in_parent = newCallback (AccessibleObject.class, "atkObject_get_index_in_parent", 1); //$NON-NLS-1$
108
AtkObjectCB_ref_child = newCallback (AccessibleObject.class, "atkObject_ref_child", 2); //$NON-NLS-1$
109
AtkSelectionCB_is_child_selected = newCallback (AccessibleObject.class, "atkSelection_is_child_selected", 2); //$NON-NLS-1$
110
AtkSelectionCB_ref_selection = newCallback (AccessibleObject.class, "atkSelection_ref_selection", 2); //$NON-NLS-1$
111
AtkTextCB_get_caret_offset = newCallback (AccessibleObject.class, "atkText_get_caret_offset", 1); //$NON-NLS-1$
112
AtkTextCB_get_n_selections = newCallback (AccessibleObject.class, "atkText_get_n_selections", 1); //$NON-NLS-1$
113
AtkTextCB_get_selection = newCallback (AccessibleObject.class, "atkText_get_selection", 4); //$NON-NLS-1$
114
AtkTextCB_get_text = newCallback (AccessibleObject.class, "atkText_get_text", 3); //$NON-NLS-1$
115
AtkTextCB_get_text_after_offset = newCallback (AccessibleObject.class, "atkText_get_text_after_offset", 5); //$NON-NLS-1$
116
AtkTextCB_get_text_at_offset = newCallback ( AccessibleObject.class, "atkText_get_text_at_offset", 5); //$NON-NLS-1$
117
AtkTextCB_get_text_before_offset = newCallback (AccessibleObject.class, "atkText_get_text_before_offset", 5); //$NON-NLS-1$
118
AtkTextCB_get_character_at_offset = newCallback (AccessibleObject.class, "atkText_get_character_at_offset", 2); //$NON-NLS-1$
119
AtkTextCB_get_character_count = newCallback (AccessibleObject.class, "atkText_get_character_count", 1); //$NON-NLS-1$
120
GObjectClass_finalize = newCallback (AccessibleObject.class, "gObjectClass_finalize", 1); //$NON-NLS-1$
121
GTypeInfo_base_init_type = newCallback (AccessibleFactory.class, "gTypeInfo_base_init_type", 1); //$NON-NLS-1$
122
/* Action interface */
123         InitActionIfaceCB = newCallback (AccessibleFactory.class, "initActionIfaceCB", 1); //$NON-NLS-1$
124
GInterfaceInfo interfaceInfo = new GInterfaceInfo ();
125         interfaceInfo.interface_init = InitActionIfaceCB.getAddress ();
126         ActionIfaceDefinition = OS.g_malloc (GInterfaceInfo.sizeof);
127         OS.memmove (ActionIfaceDefinition, interfaceInfo, GInterfaceInfo.sizeof);
128         /* Component interface */
129         InitComponentIfaceCB = newCallback (AccessibleFactory.class, "initComponentIfaceCB", 1); //$NON-NLS-1$
130
interfaceInfo = new GInterfaceInfo ();
131         interfaceInfo.interface_init = InitComponentIfaceCB.getAddress ();
132         ComponentIfaceDefinition = OS.g_malloc (GInterfaceInfo.sizeof);
133         OS.memmove (ComponentIfaceDefinition, interfaceInfo, GInterfaceInfo.sizeof);
134         /* Hypertext interface */
135         InitHypertextIfaceCB = newCallback (AccessibleFactory.class, "initHypertextIfaceCB", 1); //$NON-NLS-1$
136
interfaceInfo = new GInterfaceInfo ();
137         interfaceInfo.interface_init = InitHypertextIfaceCB.getAddress ();
138         HypertextIfaceDefinition = OS.g_malloc (GInterfaceInfo.sizeof);
139         OS.memmove (HypertextIfaceDefinition, interfaceInfo, GInterfaceInfo.sizeof);
140         /* Selection interface */
141         InitSelectionIfaceCB = newCallback (AccessibleFactory.class, "initSelectionIfaceCB", 1); //$NON-NLS-1$
142
interfaceInfo = new GInterfaceInfo ();
143         interfaceInfo.interface_init = InitSelectionIfaceCB.getAddress ();
144         SelectionIfaceDefinition = OS.g_malloc (GInterfaceInfo.sizeof);
145         OS.memmove (SelectionIfaceDefinition, interfaceInfo, GInterfaceInfo.sizeof);
146         /* Text interface */
147         InitTextIfaceCB = newCallback (AccessibleFactory.class, "initTextIfaceCB", 1); //$NON-NLS-1$
148
interfaceInfo = new GInterfaceInfo ();
149         interfaceInfo.interface_init = InitTextIfaceCB.getAddress ();
150         TextIfaceDefinition = OS.g_malloc (GInterfaceInfo.sizeof);
151         OS.memmove (TextIfaceDefinition, interfaceInfo, GInterfaceInfo.sizeof);
152     }
153
154     static private Callback newCallback (Object JavaDoc object, String JavaDoc method, int argCount) {
155         Callback callback = new Callback (object, method, argCount);
156         if (callback.getAddress () == 0) SWT.error (SWT.ERROR_NO_MORE_CALLBACKS);
157         return callback;
158     }
159     
160     private AccessibleFactory (int /*long*/ widgetType) {
161         super ();
162         /* If DefaultParentType is 0 then OS accessibility is not active */
163         if (DefaultParentType == 0) return;
164         widgetTypeName = OS.g_type_name (widgetType);
165         int widgetTypeNameLength = OS.strlen (widgetTypeName) + 1;
166         byte[] buffer = new byte [widgetTypeNameLength];
167         OS.memmove (buffer, widgetTypeName, widgetTypeNameLength);
168         byte[] factoryName = new byte [FACTORY_TYPENAME.length + widgetTypeNameLength - 1];
169         System.arraycopy (FACTORY_TYPENAME, 0, factoryName, 0, FACTORY_TYPENAME.length);
170         System.arraycopy (buffer, 0, factoryName, FACTORY_TYPENAME.length - 1, widgetTypeNameLength);
171         if (OS.g_type_from_name (factoryName) == 0) {
172             /* register the factory */
173             int /*long*/ registry = ATK.atk_get_default_registry ();
174             int /*long*/ previousFactory = ATK.atk_registry_get_factory (registry, widgetType);
175             objectParentType = ATK.atk_object_factory_get_accessible_type (previousFactory);
176             if (objectParentType == 0) objectParentType = DefaultParentType;
177             int /*long*/ factoryParentType = OS.g_type_from_name (FACTORY_PARENTTYPENAME);
178             gTypeInfo_base_init_factory = new Callback (this, "gTypeInfo_base_init_factory", 1); //$NON-NLS-1$
179
int /*long*/ address = gTypeInfo_base_init_factory.getAddress ();
180             if (address == 0) SWT.error (SWT.ERROR_NO_MORE_CALLBACKS);
181             GTypeInfo typeInfo = new GTypeInfo ();
182             typeInfo.base_init = address;
183             typeInfo.class_size = (short)ATK.AtkObjectFactoryClass_sizeof ();
184             typeInfo.instance_size = (short)ATK.AtkObjectFactory_sizeof ();
185             handle = OS.g_malloc (GTypeInfo.sizeof);
186             OS.memmove (handle, typeInfo, GTypeInfo.sizeof);
187             int /*long*/ swtFactory = OS.g_type_register_static (factoryParentType, factoryName, handle, 0);
188             ATK.atk_registry_set_factory_type (registry, widgetType, swtFactory);
189         }
190     }
191     
192     void addAccessible (Accessible accessible) {
193         int /*long*/ controlHandle = accessible.getControlHandle ();
194         accessibles.put (new LONG (controlHandle), accessible);
195     }
196
197     int /*long*/ atkObjectFactory_create_accessible (int /*long*/ widget) {
198         Accessible accessible = (Accessible) accessibles.get (new LONG (widget));
199         if (accessible == null) {
200             /*
201             * we don't care about this control, so create it with the parent's
202             * type so that its accessibility callbacks will not pass though here
203             */

204             int /*long*/ result = OS.g_object_new (objectParentType, 0);
205             ATK.atk_object_initialize (result, widget);
206             return result;
207         }
208         int typeNameLength = OS.strlen (widgetTypeName);
209         byte[] buffer = new byte [typeNameLength];
210         OS.memmove (buffer, widgetTypeName, typeNameLength);
211         int /*long*/ type = getType (buffer, accessible, objectParentType, ACC.CHILDID_SELF);
212         AccessibleObject object = new AccessibleObject (type, widget, accessible, objectParentType, false);
213         accessible.accessibleObject = object;
214         return object.handle;
215     }
216     
217     static int /*long*/ getChildType (Accessible accessible, int childIndex) {
218         return getType (CHILD_TYPENAME, accessible, DefaultParentType, childIndex);
219     }
220
221     static int /*long*/ getDefaultParentType () {
222         return DefaultParentType;
223     }
224
225     static int /*long*/ getType (byte[] widgetTypeName, Accessible accessible, int /*long*/ parentType, int childId) {
226         AccessibleControlEvent event = new AccessibleControlEvent (accessible);
227         event.childID = childId;
228         AccessibleControlListener[] listeners = accessible.getControlListeners ();
229         for (int i = 0; i < listeners.length; i++) {
230             listeners [i].getRole (event);
231         }
232         boolean action = false, hypertext = false, selection = false, text = false;
233         if (event.detail != 0) { /* a role was specified */
234             for (int i = 0; i < actionRoles.length; i++) {
235                 if (event.detail == actionRoles [i]) {
236                     action = true;
237                     break;
238                 }
239             }
240             for (int i = 0; i < hypertextRoles.length; i++) {
241                 if (event.detail == hypertextRoles [i]) {
242                     hypertext = true;
243                     break;
244                 }
245             }
246             for (int i = 0; i < selectionRoles.length; i++) {
247                 if (event.detail == selectionRoles [i]) {
248                     selection = true;
249                     break;
250                 }
251             }
252             for (int i = 0; i < textRoles.length; i++) {
253                 if (event.detail == textRoles [i]) {
254                     text = true;
255                     break;
256                 }
257             }
258         } else {
259             action = hypertext = selection = text = true;
260         }
261         String JavaDoc swtTypeName = new String JavaDoc (SWT_TYPE_PREFIX);
262         swtTypeName += new String JavaDoc (widgetTypeName);
263         if (action) swtTypeName += "Action"; //$NON-NLS-1$
264
if (hypertext) swtTypeName += "Hypertext"; //$NON-NLS-1$
265
if (selection) swtTypeName += "Selection"; //$NON-NLS-1$
266
if (text) swtTypeName += "Text"; //$NON-NLS-1$
267

268         int /*long*/ type = 0;
269         LONG typeInt = (LONG)Types.get (swtTypeName);
270         if (typeInt != null) {
271             type = typeInt.value;
272         } else {
273             /* define the type */
274             int /*long*/ queryPtr = OS.g_malloc (GTypeQuery.sizeof);
275             OS.g_type_query (parentType, queryPtr);
276             GTypeQuery query = new GTypeQuery ();
277             OS.memmove (query, queryPtr, GTypeQuery.sizeof);
278             OS.g_free (queryPtr);
279             GTypeInfo typeInfo = new GTypeInfo ();
280             typeInfo.base_init = GTypeInfo_base_init_type.getAddress ();
281             typeInfo.class_size = (short) query.class_size;
282             typeInfo.instance_size = (short) query.instance_size;
283             ObjectIfaceDefinition = OS.g_malloc (GTypeInfo.sizeof);
284             OS.memmove (ObjectIfaceDefinition, typeInfo, GTypeInfo.sizeof);
285             byte[] nameBytes = new byte [swtTypeName.length () + 1];
286             System.arraycopy(swtTypeName.getBytes (), 0, nameBytes, 0, swtTypeName.length ());
287             type = OS.g_type_register_static (parentType, nameBytes, ObjectIfaceDefinition, 0);
288             OS.g_type_add_interface_static (type, AccessibleObject.ATK_COMPONENT_TYPE, ComponentIfaceDefinition);
289             if (action) OS.g_type_add_interface_static (type, AccessibleObject.ATK_ACTION_TYPE, ActionIfaceDefinition);
290             if (hypertext) OS.g_type_add_interface_static (type, AccessibleObject.ATK_HYPERTEXT_TYPE, HypertextIfaceDefinition);
291             if (selection) OS.g_type_add_interface_static (type, AccessibleObject.ATK_SELECTION_TYPE, SelectionIfaceDefinition);
292             if (text) OS.g_type_add_interface_static (type, AccessibleObject.ATK_TEXT_TYPE, TextIfaceDefinition);
293             Types.put (swtTypeName, new LONG (type));
294         }
295         return type;
296     }
297
298     int /*long*/ gTypeInfo_base_init_factory (int /*long*/ klass) {
299         int /*long*/ atkObjectFactoryClass = ATK.ATK_OBJECT_FACTORY_CLASS (klass);
300         AtkObjectFactoryClass objectFactoryClassStruct = new AtkObjectFactoryClass ();
301         ATK.memmove (objectFactoryClassStruct, atkObjectFactoryClass);
302         atkObjectFactoryCB_create_accessible = new Callback (this, "atkObjectFactory_create_accessible", 1); //$NON-NLS-1$
303
int /*long*/ address = atkObjectFactoryCB_create_accessible.getAddress ();
304         if (address == 0) SWT.error (SWT.ERROR_NO_MORE_CALLBACKS);
305         objectFactoryClassStruct.create_accessible = address;
306         ATK.memmove (atkObjectFactoryClass, objectFactoryClassStruct);
307         return 0;
308     }
309     
310     static int /*long*/ gTypeInfo_base_init_type (int /*long*/ klass) {
311         AtkObjectClass objectClass = new AtkObjectClass ();
312         ATK.memmove (objectClass, klass);
313         objectClass.get_name = AtkObjectCB_get_name.getAddress ();
314         objectClass.get_description = AtkObjectCB_get_description.getAddress ();
315         objectClass.get_n_children = AtkObjectCB_get_n_children.getAddress ();
316         objectClass.get_role = AtkObjectCB_get_role.getAddress ();
317         objectClass.get_parent = AtkObjectCB_get_parent.getAddress ();
318         objectClass.ref_state_set = AtkObjectCB_ref_state_set.getAddress ();
319         objectClass.get_index_in_parent = AtkObjectCB_get_index_in_parent.getAddress ();
320         objectClass.ref_child = AtkObjectCB_ref_child.getAddress ();
321         int /*long*/ gObjectClass = OS.G_OBJECT_CLASS (klass);
322         GObjectClass objectClassStruct = new GObjectClass ();
323         OS.memmove (objectClassStruct, gObjectClass);
324         objectClassStruct.finalize = GObjectClass_finalize.getAddress ();
325         OS.memmove (gObjectClass, objectClassStruct);
326         ATK.memmove (klass, objectClass);
327         return 0;
328     }
329     
330     static int /*long*/ initActionIfaceCB (int /*long*/ iface) {
331         AtkActionIface actionIface = new AtkActionIface ();
332         ATK.memmove (actionIface, iface);
333         actionIface.get_keybinding = AtkActionCB_get_keybinding.getAddress ();
334         actionIface.get_name = AtkActionCB_get_name.getAddress ();
335         ATK.memmove (iface, actionIface);
336         return 0;
337     }
338     
339     static int /*long*/ initComponentIfaceCB (int /*long*/ iface) {
340         AtkComponentIface componentIface = new AtkComponentIface ();
341         ATK.memmove (componentIface, iface);
342         componentIface.get_extents = AtkComponentCB_get_extents.getAddress ();
343         componentIface.get_position = AtkComponentCB_get_position.getAddress ();
344         componentIface.get_size = AtkComponentCB_get_size.getAddress ();
345         componentIface.ref_accessible_at_point = AtkComponentCB_ref_accessible_at_point.getAddress ();
346         ATK.memmove (iface, componentIface);
347         return 0;
348     }
349
350     static int /*long*/ initHypertextIfaceCB (int /*long*/ iface) {
351         AtkHypertextIface hypertextIface = new AtkHypertextIface ();
352         ATK.memmove (hypertextIface, iface);
353         hypertextIface.get_link = AtkHypertextCB_get_link.getAddress ();
354         hypertextIface.get_link_index = AtkHypertextCB_get_link_index.getAddress ();
355         hypertextIface.get_n_links = AtkHypertextCB_get_n_links.getAddress ();
356         ATK.memmove (iface, hypertextIface);
357         return 0;
358     }
359
360     static int /*long*/ initSelectionIfaceCB (int /*long*/ iface) {
361         AtkSelectionIface selectionIface = new AtkSelectionIface ();
362         ATK.memmove (selectionIface, iface);
363         selectionIface.is_child_selected = AtkSelectionCB_is_child_selected.getAddress ();
364         selectionIface.ref_selection = AtkSelectionCB_ref_selection.getAddress ();
365         ATK.memmove (iface, selectionIface);
366         return 0;
367     }
368
369     static int /*long*/ initTextIfaceCB (int /*long*/ iface) {
370         AtkTextIface textInterface = new AtkTextIface ();
371         ATK.memmove (textInterface, iface);
372         textInterface.get_caret_offset = AtkTextCB_get_caret_offset.getAddress ();
373         textInterface.get_character_at_offset = AtkTextCB_get_character_at_offset.getAddress ();
374         textInterface.get_character_count = AtkTextCB_get_character_count.getAddress ();
375         textInterface.get_n_selections = AtkTextCB_get_n_selections.getAddress ();
376         textInterface.get_selection = AtkTextCB_get_selection.getAddress ();
377         textInterface.get_text = AtkTextCB_get_text.getAddress ();
378         textInterface.get_text_after_offset = AtkTextCB_get_text_after_offset.getAddress ();
379         textInterface.get_text_at_offset = AtkTextCB_get_text_at_offset.getAddress ();
380         textInterface.get_text_before_offset = AtkTextCB_get_text_before_offset.getAddress ();
381         ATK.memmove (iface, textInterface);
382         return 0;
383     }
384
385     static void registerAccessible (Accessible accessible) {
386         int /*long*/ controlHandle = accessible.getControlHandle ();
387         int /*long*/ widgetType = OS.G_OBJECT_TYPE (controlHandle);
388         AccessibleFactory factory = (AccessibleFactory) Factories.get (new LONG (widgetType));
389         if (factory == null) {
390             factory = new AccessibleFactory (widgetType);
391             Factories.put (new LONG (widgetType), factory);
392         }
393         factory.addAccessible (accessible);
394     }
395     
396     void removeAccessible (Accessible accessible) {
397         accessibles.remove (new LONG (accessible.getControlHandle ()));
398     }
399     
400     static void unregisterAccessible (Accessible accessible) {
401         int /*long*/ controlHandle = accessible.getControlHandle ();
402         int /*long*/ widgetType = OS.G_OBJECT_TYPE (controlHandle);
403         AccessibleFactory factory = (AccessibleFactory) Factories.get (new LONG (widgetType));
404         if (factory != null) {
405             factory.removeAccessible (accessible);
406         }
407     }
408 }
409
Popular Tags