Mercurial > projects > dwt-linux
comparison dwt/accessibility/AccessibleFactory.d @ 238:380bad9f6852
reverted char[] to String
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Mon, 05 May 2008 00:42:55 +0200 |
parents | de2578a843a7 |
children | 5a30aa9820f3 |
comparison
equal
deleted
inserted
replaced
237:98b80b00af79 | 238:380bad9f6852 |
---|---|
10 * Port to the D programming language: | 10 * Port to the D programming language: |
11 * Frank Benoit <benoit@tionex.de> | 11 * Frank Benoit <benoit@tionex.de> |
12 *******************************************************************************/ | 12 *******************************************************************************/ |
13 module dwt.accessibility.AccessibleFactory; | 13 module dwt.accessibility.AccessibleFactory; |
14 | 14 |
15 import dwt.dwthelper.utils; | |
16 | |
15 | 17 |
16 import dwt.internal.accessibility.gtk.ATK; | 18 import dwt.internal.accessibility.gtk.ATK; |
17 import dwt.internal.gtk.OS; | 19 import dwt.internal.gtk.OS; |
18 import dwt.accessibility.Accessible; | 20 import dwt.accessibility.Accessible; |
19 import dwt.accessibility.ACC; | 21 import dwt.accessibility.ACC; |
33 | 35 |
34 //Callback atkObjectFactoryCB_create_accessible; | 36 //Callback atkObjectFactoryCB_create_accessible; |
35 //Callback gTypeInfo_base_init_factory; | 37 //Callback gTypeInfo_base_init_factory; |
36 Accessible[GtkWidget*] accessibles; | 38 Accessible[GtkWidget*] accessibles; |
37 | 39 |
38 static long[char[]] Types; | 40 static long[String] Types; |
39 static AccessibleFactory[long] Factories; | 41 static AccessibleFactory[long] Factories; |
40 | 42 |
41 static uint DefaultParentType; //$NON-NLS-1$ | 43 static uint DefaultParentType; //$NON-NLS-1$ |
42 static const char[] FACTORY_PARENTTYPENAME = "AtkObjectFactory"; | 44 static const String FACTORY_PARENTTYPENAME = "AtkObjectFactory"; |
43 static const char[] SWT_TYPE_PREFIX = "DWT"; | 45 static const String SWT_TYPE_PREFIX = "DWT"; |
44 static const char[] CHILD_TYPENAME = "Child"; | 46 static const String CHILD_TYPENAME = "Child"; |
45 static const char[] FACTORY_TYPENAME = "SWTFactory"; | 47 static const String FACTORY_TYPENAME = "SWTFactory"; |
46 static const int[] actionRoles = [ | 48 static const int[] actionRoles = [ |
47 ACC.ROLE_CHECKBUTTON, ACC.ROLE_COMBOBOX, ACC.ROLE_LINK, | 49 ACC.ROLE_CHECKBUTTON, ACC.ROLE_COMBOBOX, ACC.ROLE_LINK, |
48 ACC.ROLE_MENUITEM, ACC.ROLE_PUSHBUTTON, ACC.ROLE_RADIOBUTTON, | 50 ACC.ROLE_MENUITEM, ACC.ROLE_PUSHBUTTON, ACC.ROLE_RADIOBUTTON, |
49 ]; | 51 ]; |
50 static const int[] hypertextRoles = [ACC.ROLE_LINK]; | 52 static const int[] hypertextRoles = [ACC.ROLE_LINK]; |
94 } | 96 } |
95 } | 97 } |
96 | 98 |
97 private this (int /*long*/ widgetType) { | 99 private this (int /*long*/ widgetType) { |
98 widgetTypeName = OS.g_type_name (widgetType); | 100 widgetTypeName = OS.g_type_name (widgetType); |
99 char[] factoryName = FACTORY_TYPENAME ~ fromStringz( widgetTypeName ) ~ \0; | 101 String factoryName = FACTORY_TYPENAME ~ fromStringz( widgetTypeName ) ~ \0; |
100 if (OS.g_type_from_name (factoryName.ptr) is 0) { | 102 if (OS.g_type_from_name (factoryName.ptr) is 0) { |
101 /* register the factory */ | 103 /* register the factory */ |
102 auto registry = ATK.atk_get_default_registry (); | 104 auto registry = ATK.atk_get_default_registry (); |
103 auto previousFactory = ATK.atk_registry_get_factory (registry, widgetType); | 105 auto previousFactory = ATK.atk_registry_get_factory (registry, widgetType); |
104 objectParentType = ATK.atk_object_factory_get_accessible_type (previousFactory); | 106 objectParentType = ATK.atk_object_factory_get_accessible_type (previousFactory); |
136 } | 138 } |
137 /* if an atk object has already been created for this widget then just return it */ | 139 /* if an atk object has already been created for this widget then just return it */ |
138 if (accessible.accessibleObject !is null) { | 140 if (accessible.accessibleObject !is null) { |
139 return accessible.accessibleObject.handle; | 141 return accessible.accessibleObject.handle; |
140 } | 142 } |
141 char[] buffer = fromStringz( widgetTypeName ).dup; | 143 String buffer = fromStringz( widgetTypeName ).dup; |
142 auto type = getType (buffer, accessible, objectParentType, ACC.CHILDID_SELF); | 144 auto type = getType (buffer, accessible, objectParentType, ACC.CHILDID_SELF); |
143 AccessibleObject object = new AccessibleObject (type, cast(GtkWidget*)widget, accessible, objectParentType, false); | 145 AccessibleObject object = new AccessibleObject (type, cast(GtkWidget*)widget, accessible, objectParentType, false); |
144 accessible.accessibleObject = object; | 146 accessible.accessibleObject = object; |
145 return object.handle; | 147 return object.handle; |
146 } | 148 } |
156 | 158 |
157 static int /*long*/ getDefaultParentType () { | 159 static int /*long*/ getDefaultParentType () { |
158 return DefaultParentType; | 160 return DefaultParentType; |
159 } | 161 } |
160 | 162 |
161 static int /*long*/ getType (char[] widgetTypeName, Accessible accessible, int /*long*/ parentType, int childId) { | 163 static int /*long*/ getType (String widgetTypeName, Accessible accessible, int /*long*/ parentType, int childId) { |
162 AccessibleControlEvent event = new AccessibleControlEvent (accessible); | 164 AccessibleControlEvent event = new AccessibleControlEvent (accessible); |
163 event.childID = childId; | 165 event.childID = childId; |
164 AccessibleControlListener[] listeners = accessible.getControlListeners (); | 166 AccessibleControlListener[] listeners = accessible.getControlListeners (); |
165 for (int i = 0; i < listeners.length; i++) { | 167 for (int i = 0; i < listeners.length; i++) { |
166 listeners [i].getRole (event); | 168 listeners [i].getRole (event); |
192 } | 194 } |
193 } | 195 } |
194 } else { | 196 } else { |
195 action = hypertext = selection = text = true; | 197 action = hypertext = selection = text = true; |
196 } | 198 } |
197 char[] swtTypeName = SWT_TYPE_PREFIX.dup; | 199 String swtTypeName = SWT_TYPE_PREFIX.dup; |
198 swtTypeName ~= widgetTypeName; | 200 swtTypeName ~= widgetTypeName; |
199 if (action) swtTypeName ~= "Action"; //$NON-NLS-1$ | 201 if (action) swtTypeName ~= "Action"; //$NON-NLS-1$ |
200 if (hypertext) swtTypeName ~= "Hypertext"; //$NON-NLS-1$ | 202 if (hypertext) swtTypeName ~= "Hypertext"; //$NON-NLS-1$ |
201 if (selection) swtTypeName ~= "Selection"; //$NON-NLS-1$ | 203 if (selection) swtTypeName ~= "Selection"; //$NON-NLS-1$ |
202 if (text) swtTypeName ~= "Text"; //$NON-NLS-1$ | 204 if (text) swtTypeName ~= "Text"; //$NON-NLS-1$ |