Source Code Cross Referenced for AccessibleFactory.java in  » IDE-Eclipse » swt » org » eclipse » swt » accessibility » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » IDE Eclipse » swt » org.eclipse.swt.accessibility 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*******************************************************************************
002:         * Copyright (c) 2000, 2006 IBM Corporation and others.
003:         * All rights reserved. This program and the accompanying materials
004:         * are made available under the terms of the Eclipse Public License v1.0
005:         * which accompanies this distribution, and is available at
006:         * http://www.eclipse.org/legal/epl-v10.html
007:         *
008:         * Contributors:
009:         *     IBM Corporation - initial API and implementation
010:         *******************************************************************************/package org.eclipse.swt.accessibility;
011:
012:        import java.util.*;
013:        import org.eclipse.swt.internal.*;
014:        import org.eclipse.swt.internal.accessibility.gtk.*;
015:        import org.eclipse.swt.internal.gtk.*;
016:        import org.eclipse.swt.*;
017:
018:        class AccessibleFactory {
019:            int /*long*/handle;
020:            int /*long*/objectParentType;
021:            int /*long*/widgetTypeName;
022:            Callback atkObjectFactoryCB_create_accessible;
023:            Callback gTypeInfo_base_init_factory;
024:            Hashtable accessibles = new Hashtable(9);
025:
026:            static final Hashtable Types = new Hashtable(9);
027:            static final Hashtable Factories = new Hashtable(9);
028:            static final int /*long*/DefaultParentType = OS
029:                    .g_type_from_name(Converter.wcsToMbcs(null,
030:                            "GtkAccessible", true)); //$NON-NLS-1$
031:            static final byte[] FACTORY_PARENTTYPENAME = Converter.wcsToMbcs(
032:                    null, "AtkObjectFactory", true); //$NON-NLS-1$
033:            static final byte[] SWT_TYPE_PREFIX = Converter.wcsToMbcs(null,
034:                    "SWT", false); //$NON-NLS-1$
035:            static final byte[] CHILD_TYPENAME = Converter.wcsToMbcs(null,
036:                    "Child", false); //$NON-NLS-1$
037:            static final byte[] FACTORY_TYPENAME = Converter.wcsToMbcs(null,
038:                    "SWTFactory", true); //$NON-NLS-1$
039:            static final int[] actionRoles = { ACC.ROLE_CHECKBUTTON,
040:                    ACC.ROLE_COMBOBOX, ACC.ROLE_LINK, ACC.ROLE_MENUITEM,
041:                    ACC.ROLE_PUSHBUTTON, ACC.ROLE_RADIOBUTTON, };
042:            static final int[] hypertextRoles = { ACC.ROLE_LINK };
043:            static final int[] selectionRoles = { ACC.ROLE_LIST,
044:                    ACC.ROLE_TABFOLDER, ACC.ROLE_TABLE, ACC.ROLE_TREE, };
045:            static final int[] textRoles = { ACC.ROLE_COMBOBOX, ACC.ROLE_LINK,
046:                    ACC.ROLE_LABEL, ACC.ROLE_TEXT, };
047:
048:            /* AT callbacks*/
049:            static final Callback AtkActionCB_get_keybinding;
050:            static final Callback AtkActionCB_get_name;
051:            static final Callback AtkComponentCB_get_extents;
052:            static final Callback AtkComponentCB_get_position;
053:            static final Callback AtkComponentCB_get_size;
054:            static final Callback AtkComponentCB_ref_accessible_at_point;
055:            static final Callback AtkHypertextCB_get_link;
056:            static final Callback AtkHypertextCB_get_n_links;
057:            static final Callback AtkHypertextCB_get_link_index;
058:            static final Callback AtkObjectCB_get_description;
059:            static final Callback AtkObjectCB_get_index_in_parent;
060:            static final Callback AtkObjectCB_get_n_children;
061:            static final Callback AtkObjectCB_get_name;
062:            static final Callback AtkObjectCB_get_parent;
063:            static final Callback AtkObjectCB_get_role;
064:            static final Callback AtkObjectCB_ref_child;
065:            static final Callback AtkObjectCB_ref_state_set;
066:            static final Callback AtkSelectionCB_is_child_selected;
067:            static final Callback AtkSelectionCB_ref_selection;
068:            static final Callback AtkTextCB_get_caret_offset;
069:            static final Callback AtkTextCB_get_n_selections;
070:            static final Callback AtkTextCB_get_selection;
071:            static final Callback AtkTextCB_get_text;
072:            static final Callback AtkTextCB_get_text_after_offset;
073:            static final Callback AtkTextCB_get_text_at_offset;
074:            static final Callback AtkTextCB_get_text_before_offset;
075:            static final Callback AtkTextCB_get_character_at_offset;
076:            static final Callback AtkTextCB_get_character_count;
077:            static final Callback GObjectClass_finalize;
078:            /* interface initialization callbacks */
079:            static final Callback InitActionIfaceCB;
080:            static final Callback InitComponentIfaceCB;
081:            static final Callback InitHypertextIfaceCB;
082:            static final Callback GTypeInfo_base_init_type;
083:            static final Callback InitSelectionIfaceCB;
084:            static final Callback InitTextIfaceCB;
085:            /* interface definitions */
086:            static int /*long*/ObjectIfaceDefinition;
087:            static final int /*long*/ActionIfaceDefinition;
088:            static final int /*long*/ComponentIfaceDefinition;
089:            static final int /*long*/HypertextIfaceDefinition;
090:            static final int /*long*/SelectionIfaceDefinition;
091:            static final int /*long*/TextIfaceDefinition;
092:            static {
093:                AtkActionCB_get_keybinding = newCallback(
094:                        AccessibleObject.class, "atkAction_get_keybinding", 2); //$NON-NLS-1$
095:                AtkActionCB_get_name = newCallback(AccessibleObject.class,
096:                        "atkAction_get_name", 2); //$NON-NLS-1$
097:                AtkComponentCB_get_extents = newCallback(
098:                        AccessibleObject.class, "atkComponent_get_extents", 6); //$NON-NLS-1$
099:                AtkComponentCB_get_position = newCallback(
100:                        AccessibleObject.class, "atkComponent_get_position", 4); //$NON-NLS-1$
101:                AtkComponentCB_get_size = newCallback(AccessibleObject.class,
102:                        "atkComponent_get_size", 4); //$NON-NLS-1$
103:                AtkComponentCB_ref_accessible_at_point = newCallback(
104:                        AccessibleObject.class,
105:                        "atkComponent_ref_accessible_at_point", 4); //$NON-NLS-1$
106:                AtkHypertextCB_get_link = newCallback(AccessibleObject.class,
107:                        "atkHypertext_get_link", 2); //$NON-NLS-1$
108:                AtkHypertextCB_get_n_links = newCallback(
109:                        AccessibleObject.class, "atkHypertext_get_n_links", 1); //$NON-NLS-1$
110:                AtkHypertextCB_get_link_index = newCallback(
111:                        AccessibleObject.class,
112:                        "atkHypertext_get_link_index", 2); //$NON-NLS-1$
113:                AtkObjectCB_get_name = newCallback(AccessibleObject.class,
114:                        "atkObject_get_name", 1); //$NON-NLS-1$
115:                AtkObjectCB_get_description = newCallback(
116:                        AccessibleObject.class, "atkObject_get_description", 1); //$NON-NLS-1$
117:                AtkObjectCB_get_n_children = newCallback(
118:                        AccessibleObject.class, "atkObject_get_n_children", 1); //$NON-NLS-1$
119:                AtkObjectCB_get_role = newCallback(AccessibleObject.class,
120:                        "atkObject_get_role", 1); //$NON-NLS-1$
121:                AtkObjectCB_get_parent = newCallback(AccessibleObject.class,
122:                        "atkObject_get_parent", 1); //$NON-NLS-1$
123:                AtkObjectCB_ref_state_set = newCallback(AccessibleObject.class,
124:                        "atkObject_ref_state_set", 1); //$NON-NLS-1$
125:                AtkObjectCB_get_index_in_parent = newCallback(
126:                        AccessibleObject.class,
127:                        "atkObject_get_index_in_parent", 1); //$NON-NLS-1$
128:                AtkObjectCB_ref_child = newCallback(AccessibleObject.class,
129:                        "atkObject_ref_child", 2); //$NON-NLS-1$
130:                AtkSelectionCB_is_child_selected = newCallback(
131:                        AccessibleObject.class,
132:                        "atkSelection_is_child_selected", 2); //$NON-NLS-1$
133:                AtkSelectionCB_ref_selection = newCallback(
134:                        AccessibleObject.class, "atkSelection_ref_selection", 2); //$NON-NLS-1$
135:                AtkTextCB_get_caret_offset = newCallback(
136:                        AccessibleObject.class, "atkText_get_caret_offset", 1); //$NON-NLS-1$
137:                AtkTextCB_get_n_selections = newCallback(
138:                        AccessibleObject.class, "atkText_get_n_selections", 1); //$NON-NLS-1$
139:                AtkTextCB_get_selection = newCallback(AccessibleObject.class,
140:                        "atkText_get_selection", 4); //$NON-NLS-1$
141:                AtkTextCB_get_text = newCallback(AccessibleObject.class,
142:                        "atkText_get_text", 3); //$NON-NLS-1$
143:                AtkTextCB_get_text_after_offset = newCallback(
144:                        AccessibleObject.class,
145:                        "atkText_get_text_after_offset", 5); //$NON-NLS-1$
146:                AtkTextCB_get_text_at_offset = newCallback(
147:                        AccessibleObject.class, "atkText_get_text_at_offset", 5); //$NON-NLS-1$
148:                AtkTextCB_get_text_before_offset = newCallback(
149:                        AccessibleObject.class,
150:                        "atkText_get_text_before_offset", 5); //$NON-NLS-1$
151:                AtkTextCB_get_character_at_offset = newCallback(
152:                        AccessibleObject.class,
153:                        "atkText_get_character_at_offset", 2); //$NON-NLS-1$
154:                AtkTextCB_get_character_count = newCallback(
155:                        AccessibleObject.class,
156:                        "atkText_get_character_count", 1); //$NON-NLS-1$
157:                GObjectClass_finalize = newCallback(AccessibleObject.class,
158:                        "gObjectClass_finalize", 1); //$NON-NLS-1$
159:                GTypeInfo_base_init_type = newCallback(AccessibleFactory.class,
160:                        "gTypeInfo_base_init_type", 1); //$NON-NLS-1$
161:                /* Action interface */
162:                InitActionIfaceCB = newCallback(AccessibleFactory.class,
163:                        "initActionIfaceCB", 1); //$NON-NLS-1$
164:                GInterfaceInfo interfaceInfo = new GInterfaceInfo();
165:                interfaceInfo.interface_init = InitActionIfaceCB.getAddress();
166:                ActionIfaceDefinition = OS.g_malloc(GInterfaceInfo.sizeof);
167:                OS.memmove(ActionIfaceDefinition, interfaceInfo,
168:                        GInterfaceInfo.sizeof);
169:                /* Component interface */
170:                InitComponentIfaceCB = newCallback(AccessibleFactory.class,
171:                        "initComponentIfaceCB", 1); //$NON-NLS-1$
172:                interfaceInfo = new GInterfaceInfo();
173:                interfaceInfo.interface_init = InitComponentIfaceCB
174:                        .getAddress();
175:                ComponentIfaceDefinition = OS.g_malloc(GInterfaceInfo.sizeof);
176:                OS.memmove(ComponentIfaceDefinition, interfaceInfo,
177:                        GInterfaceInfo.sizeof);
178:                /* Hypertext interface */
179:                InitHypertextIfaceCB = newCallback(AccessibleFactory.class,
180:                        "initHypertextIfaceCB", 1); //$NON-NLS-1$
181:                interfaceInfo = new GInterfaceInfo();
182:                interfaceInfo.interface_init = InitHypertextIfaceCB
183:                        .getAddress();
184:                HypertextIfaceDefinition = OS.g_malloc(GInterfaceInfo.sizeof);
185:                OS.memmove(HypertextIfaceDefinition, interfaceInfo,
186:                        GInterfaceInfo.sizeof);
187:                /* Selection interface */
188:                InitSelectionIfaceCB = newCallback(AccessibleFactory.class,
189:                        "initSelectionIfaceCB", 1); //$NON-NLS-1$
190:                interfaceInfo = new GInterfaceInfo();
191:                interfaceInfo.interface_init = InitSelectionIfaceCB
192:                        .getAddress();
193:                SelectionIfaceDefinition = OS.g_malloc(GInterfaceInfo.sizeof);
194:                OS.memmove(SelectionIfaceDefinition, interfaceInfo,
195:                        GInterfaceInfo.sizeof);
196:                /* Text interface */
197:                InitTextIfaceCB = newCallback(AccessibleFactory.class,
198:                        "initTextIfaceCB", 1); //$NON-NLS-1$
199:                interfaceInfo = new GInterfaceInfo();
200:                interfaceInfo.interface_init = InitTextIfaceCB.getAddress();
201:                TextIfaceDefinition = OS.g_malloc(GInterfaceInfo.sizeof);
202:                OS.memmove(TextIfaceDefinition, interfaceInfo,
203:                        GInterfaceInfo.sizeof);
204:            }
205:
206:            static private Callback newCallback(Object object, String method,
207:                    int argCount) {
208:                Callback callback = new Callback(object, method, argCount);
209:                if (callback.getAddress() == 0)
210:                    SWT.error(SWT.ERROR_NO_MORE_CALLBACKS);
211:                return callback;
212:            }
213:
214:            private AccessibleFactory(int /*long*/widgetType) {
215:                super ();
216:                widgetTypeName = OS.g_type_name(widgetType);
217:                int widgetTypeNameLength = OS.strlen(widgetTypeName) + 1;
218:                byte[] buffer = new byte[widgetTypeNameLength];
219:                OS.memmove(buffer, widgetTypeName, widgetTypeNameLength);
220:                byte[] factoryName = new byte[FACTORY_TYPENAME.length
221:                        + widgetTypeNameLength - 1];
222:                System.arraycopy(FACTORY_TYPENAME, 0, factoryName, 0,
223:                        FACTORY_TYPENAME.length);
224:                System.arraycopy(buffer, 0, factoryName,
225:                        FACTORY_TYPENAME.length - 1, widgetTypeNameLength);
226:                if (OS.g_type_from_name(factoryName) == 0) {
227:                    /* register the factory */
228:                    int /*long*/registry = ATK.atk_get_default_registry();
229:                    int /*long*/previousFactory = ATK
230:                            .atk_registry_get_factory(registry, widgetType);
231:                    objectParentType = ATK
232:                            .atk_object_factory_get_accessible_type(previousFactory);
233:                    if (objectParentType == 0)
234:                        objectParentType = DefaultParentType;
235:                    int /*long*/factoryParentType = OS
236:                            .g_type_from_name(FACTORY_PARENTTYPENAME);
237:                    gTypeInfo_base_init_factory = new Callback(this ,
238:                            "gTypeInfo_base_init_factory", 1); //$NON-NLS-1$
239:                    int /*long*/address = gTypeInfo_base_init_factory
240:                            .getAddress();
241:                    if (address == 0)
242:                        SWT.error(SWT.ERROR_NO_MORE_CALLBACKS);
243:                    GTypeInfo typeInfo = new GTypeInfo();
244:                    typeInfo.base_init = address;
245:                    typeInfo.class_size = (short) ATK
246:                            .AtkObjectFactoryClass_sizeof();
247:                    typeInfo.instance_size = (short) ATK
248:                            .AtkObjectFactory_sizeof();
249:                    int /*long*/info = OS.g_malloc(GTypeInfo.sizeof);
250:                    OS.memmove(info, typeInfo, GTypeInfo.sizeof);
251:                    int /*long*/swtFactoryType = OS.g_type_register_static(
252:                            factoryParentType, factoryName, info, 0);
253:                    ATK.atk_registry_set_factory_type(registry, widgetType,
254:                            swtFactoryType);
255:                    handle = ATK.atk_registry_get_factory(registry, widgetType);
256:                }
257:            }
258:
259:            void addAccessible(Accessible accessible) {
260:                int /*long*/controlHandle = accessible.getControlHandle();
261:                accessibles.put(new LONG(controlHandle), accessible);
262:                ATK.atk_object_factory_create_accessible(handle, controlHandle);
263:            }
264:
265:            int /*long*/atkObjectFactory_create_accessible(int /*long*/widget) {
266:                Accessible accessible = (Accessible) accessibles.get(new LONG(
267:                        widget));
268:                if (accessible == null) {
269:                    /*
270:                     * we don't care about this control, so create it with the parent's
271:                     * type so that its accessibility callbacks will not pass though here 
272:                     */
273:                    int /*long*/result = OS.g_object_new(objectParentType, 0);
274:                    ATK.atk_object_initialize(result, widget);
275:                    return result;
276:                }
277:                /* if an atk object has already been created for this widget then just return it */
278:                if (accessible.accessibleObject != null) {
279:                    return accessible.accessibleObject.handle;
280:                }
281:                int typeNameLength = OS.strlen(widgetTypeName);
282:                byte[] buffer = new byte[typeNameLength];
283:                OS.memmove(buffer, widgetTypeName, typeNameLength);
284:                int /*long*/type = getType(buffer, accessible,
285:                        objectParentType, ACC.CHILDID_SELF);
286:                AccessibleObject object = new AccessibleObject(type, widget,
287:                        accessible, objectParentType, false);
288:                accessible.accessibleObject = object;
289:                return object.handle;
290:            }
291:
292:            static int /*long*/getChildType(Accessible accessible,
293:                    int childIndex) {
294:                return getType(CHILD_TYPENAME, accessible, DefaultParentType,
295:                        childIndex);
296:            }
297:
298:            static int /*long*/getDefaultParentType() {
299:                return DefaultParentType;
300:            }
301:
302:            static int /*long*/getType(byte[] widgetTypeName,
303:                    Accessible accessible, int /*long*/parentType, int childId) {
304:                AccessibleControlEvent event = new AccessibleControlEvent(
305:                        accessible);
306:                event.childID = childId;
307:                AccessibleControlListener[] listeners = accessible
308:                        .getControlListeners();
309:                for (int i = 0; i < listeners.length; i++) {
310:                    listeners[i].getRole(event);
311:                }
312:                boolean action = false, hypertext = false, selection = false, text = false;
313:                if (event.detail != 0) { /* a role was specified */
314:                    for (int i = 0; i < actionRoles.length; i++) {
315:                        if (event.detail == actionRoles[i]) {
316:                            action = true;
317:                            break;
318:                        }
319:                    }
320:                    for (int i = 0; i < hypertextRoles.length; i++) {
321:                        if (event.detail == hypertextRoles[i]) {
322:                            hypertext = true;
323:                            break;
324:                        }
325:                    }
326:                    for (int i = 0; i < selectionRoles.length; i++) {
327:                        if (event.detail == selectionRoles[i]) {
328:                            selection = true;
329:                            break;
330:                        }
331:                    }
332:                    for (int i = 0; i < textRoles.length; i++) {
333:                        if (event.detail == textRoles[i]) {
334:                            text = true;
335:                            break;
336:                        }
337:                    }
338:                } else {
339:                    action = hypertext = selection = text = true;
340:                }
341:                String swtTypeName = new String(SWT_TYPE_PREFIX);
342:                swtTypeName += new String(widgetTypeName);
343:                if (action)
344:                    swtTypeName += "Action"; //$NON-NLS-1$
345:                if (hypertext)
346:                    swtTypeName += "Hypertext"; //$NON-NLS-1$
347:                if (selection)
348:                    swtTypeName += "Selection"; //$NON-NLS-1$
349:                if (text)
350:                    swtTypeName += "Text"; //$NON-NLS-1$
351:
352:                int /*long*/type = 0;
353:                LONG typeInt = (LONG) Types.get(swtTypeName);
354:                if (typeInt != null) {
355:                    type = typeInt.value;
356:                } else {
357:                    /* define the type */
358:                    int /*long*/queryPtr = OS.g_malloc(GTypeQuery.sizeof);
359:                    OS.g_type_query(parentType, queryPtr);
360:                    GTypeQuery query = new GTypeQuery();
361:                    OS.memmove(query, queryPtr, GTypeQuery.sizeof);
362:                    OS.g_free(queryPtr);
363:                    GTypeInfo typeInfo = new GTypeInfo();
364:                    typeInfo.base_init = GTypeInfo_base_init_type.getAddress();
365:                    typeInfo.class_size = (short) query.class_size;
366:                    typeInfo.instance_size = (short) query.instance_size;
367:                    ObjectIfaceDefinition = OS.g_malloc(GTypeInfo.sizeof);
368:                    OS.memmove(ObjectIfaceDefinition, typeInfo,
369:                            GTypeInfo.sizeof);
370:                    byte[] nameBytes = Converter.wcsToMbcs(null, swtTypeName,
371:                            true);
372:                    type = OS.g_type_register_static(parentType, nameBytes,
373:                            ObjectIfaceDefinition, 0);
374:                    OS.g_type_add_interface_static(type,
375:                            AccessibleObject.ATK_COMPONENT_TYPE,
376:                            ComponentIfaceDefinition);
377:                    if (action)
378:                        OS.g_type_add_interface_static(type,
379:                                AccessibleObject.ATK_ACTION_TYPE,
380:                                ActionIfaceDefinition);
381:                    if (hypertext)
382:                        OS.g_type_add_interface_static(type,
383:                                AccessibleObject.ATK_HYPERTEXT_TYPE,
384:                                HypertextIfaceDefinition);
385:                    if (selection)
386:                        OS.g_type_add_interface_static(type,
387:                                AccessibleObject.ATK_SELECTION_TYPE,
388:                                SelectionIfaceDefinition);
389:                    if (text)
390:                        OS.g_type_add_interface_static(type,
391:                                AccessibleObject.ATK_TEXT_TYPE,
392:                                TextIfaceDefinition);
393:                    Types.put(swtTypeName, new LONG(type));
394:                }
395:                return type;
396:            }
397:
398:            int /*long*/gTypeInfo_base_init_factory(int /*long*/klass) {
399:                int /*long*/atkObjectFactoryClass = ATK
400:                        .ATK_OBJECT_FACTORY_CLASS(klass);
401:                AtkObjectFactoryClass objectFactoryClassStruct = new AtkObjectFactoryClass();
402:                ATK.memmove(objectFactoryClassStruct, atkObjectFactoryClass);
403:                atkObjectFactoryCB_create_accessible = new Callback(this ,
404:                        "atkObjectFactory_create_accessible", 1); //$NON-NLS-1$
405:                int /*long*/address = atkObjectFactoryCB_create_accessible
406:                        .getAddress();
407:                if (address == 0)
408:                    SWT.error(SWT.ERROR_NO_MORE_CALLBACKS);
409:                objectFactoryClassStruct.create_accessible = address;
410:                ATK.memmove(atkObjectFactoryClass, objectFactoryClassStruct);
411:                return 0;
412:            }
413:
414:            static int /*long*/gTypeInfo_base_init_type(int /*long*/klass) {
415:                AtkObjectClass objectClass = new AtkObjectClass();
416:                ATK.memmove(objectClass, klass);
417:                objectClass.get_name = AtkObjectCB_get_name.getAddress();
418:                objectClass.get_description = AtkObjectCB_get_description
419:                        .getAddress();
420:                objectClass.get_n_children = AtkObjectCB_get_n_children
421:                        .getAddress();
422:                objectClass.get_role = AtkObjectCB_get_role.getAddress();
423:                objectClass.get_parent = AtkObjectCB_get_parent.getAddress();
424:                objectClass.ref_state_set = AtkObjectCB_ref_state_set
425:                        .getAddress();
426:                objectClass.get_index_in_parent = AtkObjectCB_get_index_in_parent
427:                        .getAddress();
428:                objectClass.ref_child = AtkObjectCB_ref_child.getAddress();
429:                int /*long*/gObjectClass = OS.G_OBJECT_CLASS(klass);
430:                GObjectClass objectClassStruct = new GObjectClass();
431:                OS.memmove(objectClassStruct, gObjectClass);
432:                objectClassStruct.finalize = GObjectClass_finalize.getAddress();
433:                OS.memmove(gObjectClass, objectClassStruct);
434:                ATK.memmove(klass, objectClass);
435:                return 0;
436:            }
437:
438:            static int /*long*/initActionIfaceCB(int /*long*/iface) {
439:                AtkActionIface actionIface = new AtkActionIface();
440:                ATK.memmove(actionIface, iface);
441:                actionIface.get_keybinding = AtkActionCB_get_keybinding
442:                        .getAddress();
443:                actionIface.get_name = AtkActionCB_get_name.getAddress();
444:                ATK.memmove(iface, actionIface);
445:                return 0;
446:            }
447:
448:            static int /*long*/initComponentIfaceCB(int /*long*/iface) {
449:                AtkComponentIface componentIface = new AtkComponentIface();
450:                ATK.memmove(componentIface, iface);
451:                componentIface.get_extents = AtkComponentCB_get_extents
452:                        .getAddress();
453:                componentIface.get_position = AtkComponentCB_get_position
454:                        .getAddress();
455:                componentIface.get_size = AtkComponentCB_get_size.getAddress();
456:                componentIface.ref_accessible_at_point = AtkComponentCB_ref_accessible_at_point
457:                        .getAddress();
458:                ATK.memmove(iface, componentIface);
459:                return 0;
460:            }
461:
462:            static int /*long*/initHypertextIfaceCB(int /*long*/iface) {
463:                AtkHypertextIface hypertextIface = new AtkHypertextIface();
464:                ATK.memmove(hypertextIface, iface);
465:                hypertextIface.get_link = AtkHypertextCB_get_link.getAddress();
466:                hypertextIface.get_link_index = AtkHypertextCB_get_link_index
467:                        .getAddress();
468:                hypertextIface.get_n_links = AtkHypertextCB_get_n_links
469:                        .getAddress();
470:                ATK.memmove(iface, hypertextIface);
471:                return 0;
472:            }
473:
474:            static int /*long*/initSelectionIfaceCB(int /*long*/iface) {
475:                AtkSelectionIface selectionIface = new AtkSelectionIface();
476:                ATK.memmove(selectionIface, iface);
477:                selectionIface.is_child_selected = AtkSelectionCB_is_child_selected
478:                        .getAddress();
479:                selectionIface.ref_selection = AtkSelectionCB_ref_selection
480:                        .getAddress();
481:                ATK.memmove(iface, selectionIface);
482:                return 0;
483:            }
484:
485:            static int /*long*/initTextIfaceCB(int /*long*/iface) {
486:                AtkTextIface textInterface = new AtkTextIface();
487:                ATK.memmove(textInterface, iface);
488:                textInterface.get_caret_offset = AtkTextCB_get_caret_offset
489:                        .getAddress();
490:                textInterface.get_character_at_offset = AtkTextCB_get_character_at_offset
491:                        .getAddress();
492:                textInterface.get_character_count = AtkTextCB_get_character_count
493:                        .getAddress();
494:                textInterface.get_n_selections = AtkTextCB_get_n_selections
495:                        .getAddress();
496:                textInterface.get_selection = AtkTextCB_get_selection
497:                        .getAddress();
498:                textInterface.get_text = AtkTextCB_get_text.getAddress();
499:                textInterface.get_text_after_offset = AtkTextCB_get_text_after_offset
500:                        .getAddress();
501:                textInterface.get_text_at_offset = AtkTextCB_get_text_at_offset
502:                        .getAddress();
503:                textInterface.get_text_before_offset = AtkTextCB_get_text_before_offset
504:                        .getAddress();
505:                ATK.memmove(iface, textInterface);
506:                return 0;
507:            }
508:
509:            static void registerAccessible(Accessible accessible) {
510:                /* If DefaultParentType is 0 then OS accessibility is not active */
511:                if (DefaultParentType == 0)
512:                    return;
513:                int /*long*/controlHandle = accessible.getControlHandle();
514:                int /*long*/widgetType = OS.G_OBJECT_TYPE(controlHandle);
515:                AccessibleFactory factory = (AccessibleFactory) Factories
516:                        .get(new LONG(widgetType));
517:                if (factory == null) {
518:                    factory = new AccessibleFactory(widgetType);
519:                    Factories.put(new LONG(widgetType), factory);
520:                }
521:                factory.addAccessible(accessible);
522:            }
523:
524:            void removeAccessible(Accessible accessible) {
525:                accessibles.remove(new LONG(accessible.getControlHandle()));
526:            }
527:
528:            static void unregisterAccessible(Accessible accessible) {
529:                int /*long*/controlHandle = accessible.getControlHandle();
530:                int /*long*/widgetType = OS.G_OBJECT_TYPE(controlHandle);
531:                AccessibleFactory factory = (AccessibleFactory) Factories
532:                        .get(new LONG(widgetType));
533:                if (factory != null) {
534:                    factory.removeAccessible(accessible);
535:                }
536:            }
537:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.