comparison dwt/accessibility/Accessible.d @ 134:fa7d7d66b9ed

Accessible
author Frank Benoit <benoit@tionex.de>
date Wed, 13 Feb 2008 03:22:44 +0100
parents 205350493476
children ab60f3309436
comparison
equal deleted inserted replaced
133:ce00a993e4c3 134:fa7d7d66b9ed
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.Accessible; 13 module dwt.accessibility.Accessible;
14 14
15 import dwt.widgets.Control;
16 //PORTING_TYPE
17 import dwt.accessibility.Accessible;
18 import dwt.accessibility.AccessibleControlListener;
19 import dwt.accessibility.AccessibleListener;
20 import dwt.accessibility.AccessibleTextListener;
21 import dwt.widgets.Control;
22 class Accessible {
23 public static Accessible internal_new_Accessible(Control control) {
24 return new Accessible;
25 }
26 // int AddRef();
27 // int Release();
28 // int QueryInterface(int, int);
29 // void checkWidget();
30 // void setFocus(int);
31 void internal_dispose_Accessible(){
32 }
33 int internal_WM_GETOBJECT(int, int){
34 assert(false);
35 return 0;
36 }
37 // bool isValidThread();
38 // int Next(int, int, int);
39 // int Skip(int);
40 void addAccessibleListener(AccessibleListener){
41 }
42 void addAccessibleControlListener(AccessibleControlListener){
43 }
44 // void addAccessibleTextListener(AccessibleTextListener);
45 // void removeAccessibleListener(AccessibleListener);
46 // void removeAccessibleControlListener(AccessibleControlListener);
47 // void removeAccessibleTextListener(AccessibleTextListener);
48 // int childIDToOs(int);
49 // void textCaretMoved(int);
50 // void textChanged(int, int, int);
51 // void textSelectionChanged();
52 // int accDoDefaultAction(int);
53 // int accHitTest(int, int, int);
54 // int accLocation(int, int, int, int, int);
55 // int osToChildID(int);
56 // int accNavigate(int, int, int);
57 // int accSelect(int, int);
58 // int get_accChild(int, int);
59 // int get_accChildCount(int);
60 // int get_accDefaultAction(int, int);
61 // int get_accDescription(int, int);
62 // int get_accFocus(int);
63 // int get_accHelp(int, int);
64 // int get_accHelpTopic(int, int, int);
65 // int get_accKeyboardShortcut(int, int);
66 // int get_accName(int, int);
67 // int get_accParent(int);
68 // int get_accRole(int, int);
69 // int osToRole(int);
70 // int roleToOs(int);
71 // int get_accSelection(int);
72 // int get_accState(int, int);
73 // int osToState(int);
74 // int stateToOs(int);
75 // int get_accValue(int, int);
76 // int put_accName(int, int);
77 // int put_accValue(int, int);
78 // int Clone(int);
79 // Control getControl();
80 // void selectionChanged();
81 // int Reset();
82 //int refCount;
83 //int enumIndex;
84 //COMObject objIAccessible;
85 //COMObject objIEnumVARIANT;
86 //IAccessible iaccessible;
87 //Vector accessibleListeners;
88 //Vector accessibleControlListeners;
89 //Vector textListeners;
90 //Object[] variants;
91 //Control control;
92 }
93
94
95 /++
96 import dwt.DWT; 15 import dwt.DWT;
97 import dwt.DWTException; 16 import dwt.DWTException;
98 import dwt.internal.ole.win32.COM; 17 import dwt.internal.ole.win32.COM;
99 import dwt.internal.ole.win32.COMObject; 18 import dwt.internal.ole.win32.OAIDL;
100 import dwt.internal.ole.win32.GUID; 19 import dwt.internal.ole.win32.ifs;
101 import dwt.internal.ole.win32.IAccessible; 20 import dwt.internal.ole.win32.extras;
102 import dwt.internal.ole.win32.IEnumVARIANT;
103 import dwt.internal.ole.win32.VARIANT;
104 import dwt.internal.win32.OS; 21 import dwt.internal.win32.OS;
105 import dwt.internal.win32.TVITEM; 22 import dwt.internal.DWTEventListener;
106 import dwt.ole.win32.OLE; 23 import dwt.ole.win32.OLE;
24 import dwt.ole.win32.Variant;
107 import dwt.widgets.Control; 25 import dwt.widgets.Control;
108 import dwt.widgets.Table; 26 import dwt.widgets.Table;
109 import dwt.widgets.TableItem; 27 import dwt.widgets.TableItem;
110 import dwt.widgets.Tree; 28 import dwt.widgets.Tree;
111 import dwt.widgets.TreeItem; 29 import dwt.widgets.TreeItem;
112 import dwt.widgets.Widget; 30 import dwt.widgets.Widget;
31
32 import dwt.accessibility.ACC;
33 import dwt.accessibility.AccessibleControlListener;
34 import dwt.accessibility.AccessibleListener;
35 import dwt.accessibility.AccessibleTextListener;
36 import dwt.accessibility.AccessibleControlEvent;
37 import dwt.accessibility.AccessibleEvent;
38
39 import dwt.dwthelper.utils;
40 import tango.core.Array;
41 import tango.core.Thread;
113 42
114 /** 43 /**
115 * Instances of this class provide a bridge between application 44 * Instances of this class provide a bridge between application
116 * code and assistive technology clients. Many platforms provide 45 * code and assistive technology clients. Many platforms provide
117 * default accessible behavior for most widgets, and this class 46 * default accessible behavior for most widgets, and this class
132 * 61 *
133 * @since 2.0 62 * @since 2.0
134 */ 63 */
135 public class Accessible { 64 public class Accessible {
136 int refCount = 0, enumIndex = 0; 65 int refCount = 0, enumIndex = 0;
137 COMObject objIAccessible, objIEnumVARIANT; 66 _IAccessibleImpl objIAccessible;
67 _IEnumVARIANTImpl objIEnumVARIANT;
138 IAccessible iaccessible; 68 IAccessible iaccessible;
139 Vector accessibleListeners = new Vector(); 69 DWTEventListener[] accessibleListeners;
140 Vector accessibleControlListeners = new Vector(); 70 DWTEventListener[] accessibleControlListeners;
141 Vector textListeners = new Vector (); 71 DWTEventListener[] textListeners;
142 Object[] variants; 72 Object[] variants;
143 Control control; 73 Control control;
144 74
145 Accessible(Control control) { 75 this(Control control) {
146 this.control = control; 76 this.control = control;
147 int /*long*/[] ppvObject = new int /*long*/[1]; 77 int /*long*/[] ppvObject = new int /*long*/[1];
148 /* CreateStdAccessibleObject([in] hwnd, [in] idObject, [in] riidInterface, [out] ppvObject). 78 /* CreateStdAccessibleObject([in] hwnd, [in] idObject, [in] riidInterface, [out] ppvObject).
149 * AddRef has already been called on ppvObject by the callee and must be released by the caller. 79 * AddRef has already been called on ppvObject by the callee and must be released by the caller.
150 */ 80 */
151 int result = (int)/*64*/COM.CreateStdAccessibleObject(control.handle, COM.OBJID_CLIENT, COM.IIDIAccessible, ppvObject); 81 HRESULT result = COM.CreateStdAccessibleObject(control.handle, COM.OBJID_CLIENT, &COM.IIDIAccessible, cast(void**)&iaccessible);
152 /* The object needs to be checked, because if the CreateStdAccessibleObject() 82 /* The object needs to be checked, because if the CreateStdAccessibleObject()
153 * symbol is not found, the return value is S_OK. 83 * symbol is not found, the return value is S_OK.
154 */ 84 */
155 if (ppvObject[0] is 0) return; 85 if (iaccessible is null) return;
156 if (result !is COM.S_OK) OLE.error(OLE.ERROR_CANNOT_CREATE_OBJECT, result); 86 if (result !is COM.S_OK) OLE.error(OLE.ERROR_CANNOT_CREATE_OBJECT, result);
157 iaccessible = new IAccessible(ppvObject[0]); 87
158 88 objIAccessible = new _IAccessibleImpl(this);
159 objIAccessible = new COMObject(new int[] {2,0,0,1,3,5,8,1,1,2,2,2,2,2,2,2,3,2,1,1,2,2,5,3,3,1,2,2}) { 89
160 public int /*long*/ method0(int /*long*/[] args) {return QueryInterface(args[0], args[1]);} 90 //PORTING_FIXME: i don't understand this...
161 public int /*long*/ method1(int /*long*/[] args) {return AddRef();} 91 /+
162 public int /*long*/ method2(int /*long*/[] args) {return Release();}
163 // method3 GetTypeInfoCount - not implemented
164 // method4 GetTypeInfo - not implemented
165 // method5 GetIDsOfNames - not implemented
166 // method6 Invoke - not implemented
167 public int /*long*/ method7(int /*long*/[] args) {return get_accParent(args[0]);}
168 public int /*long*/ method8(int /*long*/[] args) {return get_accChildCount(args[0]);}
169 public int /*long*/ method9(int /*long*/[] args) {return get_accChild(args[0], args[1]);}
170 public int /*long*/ method10(int /*long*/[] args) {return get_accName(args[0], args[1]);}
171 public int /*long*/ method11(int /*long*/[] args) {return get_accValue(args[0], args[1]);}
172 public int /*long*/ method12(int /*long*/[] args) {return get_accDescription(args[0], args[1]);}
173 public int /*long*/ method13(int /*long*/[] args) {return get_accRole(args[0], args[1]);}
174 public int /*long*/ method14(int /*long*/[] args) {return get_accState(args[0], args[1]);}
175 public int /*long*/ method15(int /*long*/[] args) {return get_accHelp(args[0], args[1]);}
176 public int /*long*/ method16(int /*long*/[] args) {return get_accHelpTopic(args[0], args[1], args[2]);}
177 public int /*long*/ method17(int /*long*/[] args) {return get_accKeyboardShortcut(args[0], args[1]);}
178 public int /*long*/ method18(int /*long*/[] args) {return get_accFocus(args[0]);}
179 public int /*long*/ method19(int /*long*/[] args) {return get_accSelection(args[0]);}
180 public int /*long*/ method20(int /*long*/[] args) {return get_accDefaultAction(args[0], args[1]);}
181 public int /*long*/ method21(int /*long*/[] args) {return accSelect((int)/*64*/args[0], args[1]);}
182 public int /*long*/ method22(int /*long*/[] args) {return accLocation(args[0], args[1], args[2], args[3], args[4]);}
183 public int /*long*/ method23(int /*long*/[] args) {return accNavigate((int)/*64*/args[0], args[1], args[2]);}
184 public int /*long*/ method24(int /*long*/[] args) {return accHitTest((int)/*64*/args[0], (int)/*64*/args[1], args[2]);}
185 public int /*long*/ method25(int /*long*/[] args) {return accDoDefaultAction(args[0]);}
186 public int /*long*/ method26(int /*long*/[] args) {return put_accName(args[0], args[1]);}
187 public int /*long*/ method27(int /*long*/[] args) {return put_accValue(args[0], args[1]);}
188 };
189
190 int /*long*/ ppVtable = objIAccessible.ppVtable; 92 int /*long*/ ppVtable = objIAccessible.ppVtable;
191 int /*long*/[] pVtable = new int /*long*/[1]; 93 int /*long*/[] pVtable = new int /*long*/[1];
192 COM.MoveMemory(pVtable, ppVtable, OS.PTR_SIZEOF); 94 COM.MoveMemory(pVtable, ppVtable, OS.PTR_SIZEOF);
193 int /*long*/[] funcs = new int /*long*/[28]; 95 int /*long*/[] funcs = new int /*long*/[28];
194 COM.MoveMemory(funcs, pVtable[0], OS.PTR_SIZEOF * funcs.length); 96 COM.MoveMemory(funcs, pVtable[0], OS.PTR_SIZEOF * funcs.length);
207 funcs[23] = COM.accNavigate_CALLBACK(funcs[23]); 109 funcs[23] = COM.accNavigate_CALLBACK(funcs[23]);
208 funcs[25] = COM.accDoDefaultAction_CALLBACK(funcs[25]); 110 funcs[25] = COM.accDoDefaultAction_CALLBACK(funcs[25]);
209 funcs[26] = COM.put_accName_CALLBACK(funcs[26]); 111 funcs[26] = COM.put_accName_CALLBACK(funcs[26]);
210 funcs[27] = COM.put_accValue_CALLBACK(funcs[27]); 112 funcs[27] = COM.put_accValue_CALLBACK(funcs[27]);
211 COM.MoveMemory(pVtable[0], funcs, OS.PTR_SIZEOF * funcs.length); 113 COM.MoveMemory(pVtable[0], funcs, OS.PTR_SIZEOF * funcs.length);
212 114 +/
213 objIEnumVARIANT = new COMObject(new int[] {2,0,0,3,1,0,1}) { 115
214 public int /*long*/ method0(int /*long*/[] args) {return QueryInterface(args[0], args[1]);} 116 objIEnumVARIANT = new _IEnumVARIANTImpl(this) ;
215 public int /*long*/ method1(int /*long*/[] args) {return AddRef();}
216 public int /*long*/ method2(int /*long*/[] args) {return Release();}
217 public int /*long*/ method3(int /*long*/[] args) {return Next((int)args[0], args[1], args[2]);}
218 public int /*long*/ method4(int /*long*/[] args) {return Skip((int)args[0]);}
219 public int /*long*/ method5(int /*long*/[] args) {return Reset();}
220 public int /*long*/ method6(int /*long*/[] args) {return Clone(args[0]);}
221 };
222 AddRef(); 117 AddRef();
223 } 118 }
224 119
225 /** 120 /**
226 * Invokes platform specific functionality to allocate a new accessible object. 121 * Invokes platform specific functionality to allocate a new accessible object.
260 * @see AccessibleListener 155 * @see AccessibleListener
261 * @see #removeAccessibleListener 156 * @see #removeAccessibleListener
262 */ 157 */
263 public void addAccessibleListener(AccessibleListener listener) { 158 public void addAccessibleListener(AccessibleListener listener) {
264 checkWidget(); 159 checkWidget();
265 if (listener is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); 160 if (listener is null) DWT.error(__FILE__, __LINE__, DWT.ERROR_NULL_ARGUMENT);
266 accessibleListeners.addElement(listener); 161 accessibleListeners ~= listener;
267 } 162 }
268 163
269 /** 164 /**
270 * Adds the listener to the collection of listeners who will 165 * Adds the listener to the collection of listeners who will
271 * be notified when an accessible client asks for custom control 166 * be notified when an accessible client asks for custom control
287 * @see AccessibleControlListener 182 * @see AccessibleControlListener
288 * @see #removeAccessibleControlListener 183 * @see #removeAccessibleControlListener
289 */ 184 */
290 public void addAccessibleControlListener(AccessibleControlListener listener) { 185 public void addAccessibleControlListener(AccessibleControlListener listener) {
291 checkWidget(); 186 checkWidget();
292 if (listener is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); 187 if (listener is null) DWT.error(__FILE__, __LINE__, DWT.ERROR_NULL_ARGUMENT);
293 accessibleControlListeners.addElement(listener); 188 accessibleControlListeners ~= listener;
294 } 189 }
295 190
296 /** 191 /**
297 * Adds the listener to the collection of listeners who will 192 * Adds the listener to the collection of listeners who will
298 * be notified when an accessible client asks for custom text control 193 * be notified when an accessible client asks for custom text control
317 * @since 3.0 212 * @since 3.0
318 */ 213 */
319 public void addAccessibleTextListener (AccessibleTextListener listener) { 214 public void addAccessibleTextListener (AccessibleTextListener listener) {
320 checkWidget (); 215 checkWidget ();
321 if (listener is null) DWT.error (DWT.ERROR_NULL_ARGUMENT); 216 if (listener is null) DWT.error (DWT.ERROR_NULL_ARGUMENT);
322 textListeners.addElement (listener); 217 textListeners ~= listener;
323 } 218 }
324 219
325 /** 220 /**
326 * Returns the control for this Accessible object. 221 * Returns the control for this Accessible object.
327 * 222 *
360 * application code. 255 * application code.
361 * </p> 256 * </p>
362 */ 257 */
363 public int /*long*/ internal_WM_GETOBJECT (int /*long*/ wParam, int /*long*/ lParam) { 258 public int /*long*/ internal_WM_GETOBJECT (int /*long*/ wParam, int /*long*/ lParam) {
364 if (objIAccessible is null) return 0; 259 if (objIAccessible is null) return 0;
365 if ((int)/*64*/lParam is COM.OBJID_CLIENT) { 260 if (cast(int)/*64*/lParam is COM.OBJID_CLIENT) {
366 /* LresultFromObject([in] riid, [in] wParam, [in] pAcc) 261 /* LresultFromObject([in] riid, [in] wParam, [in] pAcc)
367 * The argument pAcc is owned by the caller so reference count does not 262 * The argument pAcc is owned by the caller so reference count does not
368 * need to be incremented. 263 * need to be incremented.
369 */ 264 */
370 return COM.LresultFromObject(COM.IIDIAccessible, wParam, objIAccessible.getAddress()); 265 return COM.LresultFromObject(&COM.IIDIAccessible, wParam, cast(IAccessible)objIAccessible);
371 } 266 }
372 return 0; 267 return 0;
373 } 268 }
374 269
375 /** 270 /**
391 * @see AccessibleListener 286 * @see AccessibleListener
392 * @see #addAccessibleListener 287 * @see #addAccessibleListener
393 */ 288 */
394 public void removeAccessibleListener(AccessibleListener listener) { 289 public void removeAccessibleListener(AccessibleListener listener) {
395 checkWidget(); 290 checkWidget();
396 if (listener is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); 291 if (listener is null) DWT.error(__FILE__, __LINE__, DWT.ERROR_NULL_ARGUMENT);
397 accessibleListeners.removeElement(listener); 292 accessibleListeners.remove(listener);
398 } 293 }
399 294
400 /** 295 /**
401 * Removes the listener from the collection of listeners who will 296 * Removes the listener from the collection of listeners who will
402 * be notified when an accessible client asks for custom control 297 * be notified when an accessible client asks for custom control
416 * @see AccessibleControlListener 311 * @see AccessibleControlListener
417 * @see #addAccessibleControlListener 312 * @see #addAccessibleControlListener
418 */ 313 */
419 public void removeAccessibleControlListener(AccessibleControlListener listener) { 314 public void removeAccessibleControlListener(AccessibleControlListener listener) {
420 checkWidget(); 315 checkWidget();
421 if (listener is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); 316 if (listener is null) DWT.error(__FILE__, __LINE__, DWT.ERROR_NULL_ARGUMENT);
422 accessibleControlListeners.removeElement(listener); 317 accessibleControlListeners.remove(listener);
423 } 318 }
424 319
425 /** 320 /**
426 * Removes the listener from the collection of listeners who will 321 * Removes the listener from the collection of listeners who will
427 * be notified when an accessible client asks for custom text control 322 * be notified when an accessible client asks for custom text control
444 * @since 3.0 339 * @since 3.0
445 */ 340 */
446 public void removeAccessibleTextListener (AccessibleTextListener listener) { 341 public void removeAccessibleTextListener (AccessibleTextListener listener) {
447 checkWidget (); 342 checkWidget ();
448 if (listener is null) DWT.error (DWT.ERROR_NULL_ARGUMENT); 343 if (listener is null) DWT.error (DWT.ERROR_NULL_ARGUMENT);
449 textListeners.removeElement (listener); 344 textListeners.remove (listener);
450 } 345 }
451 346
452 /** 347 /**
453 * Sends a message to accessible clients that the child selection 348 * Sends a message to accessible clients that the child selection
454 * within a custom container control has changed. 349 * within a custom container control has changed.
541 436
542 /* QueryInterface([in] iid, [out] ppvObject) 437 /* QueryInterface([in] iid, [out] ppvObject)
543 * Ownership of ppvObject transfers from callee to caller so reference count on ppvObject 438 * Ownership of ppvObject transfers from callee to caller so reference count on ppvObject
544 * must be incremented before returning. Caller is responsible for releasing ppvObject. 439 * must be incremented before returning. Caller is responsible for releasing ppvObject.
545 */ 440 */
546 int QueryInterface(int /*long*/ iid, int /*long*/ ppvObject) { 441 HRESULT QueryInterface(REFIID riid, void** ppvObject) {
547 if (iaccessible is null) return COM.CO_E_OBJNOTCONNECTED; 442 if (iaccessible is null) return COM.CO_E_OBJNOTCONNECTED;
548 GUID guid = new GUID(); 443
549 COM.MoveMemory(guid, iid, GUID.sizeof); 444 if (COM.IsEqualGUID(riid, &COM.IIDIUnknown)) {
550 445 *ppvObject = cast(void*)cast(IUnknown) objIAccessible;
551 if (COM.IsEqualGUID(guid, COM.IIDIUnknown)) {
552 COM.MoveMemory(ppvObject, new int /*long*/[] { objIAccessible.getAddress()}, OS.PTR_SIZEOF);
553 AddRef(); 446 AddRef();
554 return COM.S_OK; 447 return COM.S_OK;
555 } 448 }
556 449
557 if (COM.IsEqualGUID(guid, COM.IIDIDispatch)) { 450 if (COM.IsEqualGUID(riid, &COM.IIDIDispatch)) {
558 COM.MoveMemory(ppvObject, new int /*long*/[] { objIAccessible.getAddress()}, OS.PTR_SIZEOF); 451 *ppvObject = cast(void*)cast(IDispatch) objIAccessible;
559 AddRef(); 452 AddRef();
560 return COM.S_OK; 453 return COM.S_OK;
561 } 454 }
562 455
563 if (COM.IsEqualGUID(guid, COM.IIDIAccessible)) { 456 if (COM.IsEqualGUID(riid, &COM.IIDIAccessible)) {
564 COM.MoveMemory(ppvObject, new int /*long*/[] { objIAccessible.getAddress()}, OS.PTR_SIZEOF); 457 *ppvObject = cast(void*)cast(IAccessible) objIAccessible;
565 AddRef(); 458 AddRef();
566 return COM.S_OK; 459 return COM.S_OK;
567 } 460 }
568 461
569 if (COM.IsEqualGUID(guid, COM.IIDIEnumVARIANT)) { 462 if (COM.IsEqualGUID(riid, &COM.IIDIEnumVARIANT)) {
570 COM.MoveMemory(ppvObject, new int /*long*/[] { objIEnumVARIANT.getAddress()}, OS.PTR_SIZEOF); 463 *ppvObject = cast(void*)cast(IEnumVARIANT) objIEnumVARIANT;
571 AddRef(); 464 AddRef();
572 enumIndex = 0; 465 enumIndex = 0;
573 return COM.S_OK; 466 return COM.S_OK;
574 } 467 }
575 468
576 int /*long*/[] ppv = new int /*long*/[1]; 469 HRESULT result = iaccessible.QueryInterface(riid, ppvObject);
577 int result = iaccessible.QueryInterface(guid, ppv);
578 COM.MoveMemory(ppvObject, ppv, OS.PTR_SIZEOF);
579 return result; 470 return result;
580 } 471 }
581 472
582 int AddRef() { 473 ULONG AddRef() {
583 refCount++; 474 refCount++;
584 return refCount; 475 return refCount;
585 } 476 }
586 477
587 int Release() { 478 ULONG Release() {
588 refCount--; 479 refCount--;
589 480
590 if (refCount is 0) { 481 if (refCount is 0) {
591 if (objIAccessible !is null)
592 objIAccessible.dispose();
593 objIAccessible = null; 482 objIAccessible = null;
594
595 if (objIEnumVARIANT !is null)
596 objIEnumVARIANT.dispose();
597 objIEnumVARIANT = null; 483 objIEnumVARIANT = null;
598 } 484 }
599 return refCount; 485 return refCount;
600 } 486 }
601 487
602 int accDoDefaultAction(int /*long*/ variant) { 488 HRESULT accDoDefaultAction(VARIANT variant) {
603 if (iaccessible is null) return COM.CO_E_OBJNOTCONNECTED; 489 if (iaccessible is null) return COM.CO_E_OBJNOTCONNECTED;
604 // Currently, we don't let the application override this. Forward to the proxy. 490 // Currently, we don't let the application override this. Forward to the proxy.
605 int code = iaccessible.accDoDefaultAction(variant); 491 int code = iaccessible.accDoDefaultAction(variant);
606 if (code is COM.E_INVALIDARG) code = COM.S_FALSE; // proxy doesn't know about app childID 492 if (code is COM.E_INVALIDARG) code = COM.S_FALSE; // proxy doesn't know about app childID
607 return code; 493 return code;
608 } 494 }
609 495
610 int accHitTest(int xLeft, int yTop, int /*long*/ pvarChild) { 496 HRESULT accHitTest(LONG xLeft, LONG yTop, VARIANT* pvarChild) {
611 if (iaccessible is null) return COM.CO_E_OBJNOTCONNECTED; 497 if (iaccessible is null) return COM.CO_E_OBJNOTCONNECTED;
612 if (accessibleControlListeners.size() is 0) { 498 if (accessibleControlListeners.length is 0) {
613 return iaccessible.accHitTest(xLeft, yTop, pvarChild); 499 return iaccessible.accHitTest(xLeft, yTop, pvarChild);
614 } 500 }
615 501
616 AccessibleControlEvent event = new AccessibleControlEvent(this); 502 AccessibleControlEvent event = new AccessibleControlEvent(this);
617 event.childID = ACC.CHILDID_NONE; 503 event.childID = ACC.CHILDID_NONE;
618 event.x = xLeft; 504 event.x = xLeft;
619 event.y = yTop; 505 event.y = yTop;
620 for (int i = 0; i < accessibleControlListeners.size(); i++) { 506 for (int i = 0; i < accessibleControlListeners.length; i++) {
621 AccessibleControlListener listener = (AccessibleControlListener) accessibleControlListeners.elementAt(i); 507 AccessibleControlListener listener = cast(AccessibleControlListener) accessibleControlListeners[i];
622 listener.getChildAtPoint(event); 508 listener.getChildAtPoint(event);
623 } 509 }
624 int childID = event.childID; 510 int childID = event.childID;
625 if (childID is ACC.CHILDID_NONE) { 511 if (childID is ACC.CHILDID_NONE) {
626 return iaccessible.accHitTest(xLeft, yTop, pvarChild); 512 return iaccessible.accHitTest(xLeft, yTop, pvarChild);
627 } 513 }
628 COM.MoveMemory(pvarChild, new short[] { COM.VT_I4 }, 2); 514 pvarChild.vt = COM.VT_I4;
629 COM.MoveMemory(pvarChild + 8, new int[] { childIDToOs(childID) }, 4); 515 pvarChild.lVal = childIDToOs(childID);
630 return COM.S_OK; 516 return COM.S_OK;
631 } 517 }
632 518
633 int accLocation(int /*long*/ pxLeft, int /*long*/ pyTop, int /*long*/ pcxWidth, int /*long*/ pcyHeight, int /*long*/ variant) { 519 HRESULT accLocation(LONG* pxLeft, LONG* pyTop, LONG* pcxWidth, LONG* pcyHeight, VARIANT variant) {
634 if (iaccessible is null) return COM.CO_E_OBJNOTCONNECTED; 520 if (iaccessible is null) return COM.CO_E_OBJNOTCONNECTED;
635 VARIANT v = new VARIANT(); 521 VARIANT* v = &variant;
636 COM.MoveMemory(v, variant, VARIANT.sizeof); 522 //COM.MoveMemory(v, variant, VARIANT.sizeof);
637 if ((v.vt & 0xFFFF) !is COM.VT_I4) return COM.E_INVALIDARG; 523 if ((v.vt & 0xFFFF) !is COM.VT_I4) return COM.E_INVALIDARG;
638 524
639 /* Get the default location from the OS. */ 525 /* Get the default location from the OS. */
640 int osLeft = 0, osTop = 0, osWidth = 0, osHeight = 0; 526 int osLeft = 0, osTop = 0, osWidth = 0, osHeight = 0;
641 int code = iaccessible.accLocation(pxLeft, pyTop, pcxWidth, pcyHeight, variant); 527 int code = iaccessible.accLocation(pxLeft, pyTop, pcxWidth, pcyHeight, variant);
642 if (code is COM.E_INVALIDARG) code = COM.S_FALSE; // proxy doesn't know about app childID 528 if (code is COM.E_INVALIDARG) code = COM.S_FALSE; // proxy doesn't know about app childID
643 if (accessibleControlListeners.size() is 0) return code; 529 if (accessibleControlListeners.length is 0) return code;
644 if (code is COM.S_OK) { 530 if (code is COM.S_OK) {
645 int[] pLeft = new int[1], pTop = new int[1], pWidth = new int[1], pHeight = new int[1]; 531 int[1] pLeft, pTop, pWidth, pHeight;
646 COM.MoveMemory(pLeft, pxLeft, 4); 532 COM.MoveMemory(pLeft.ptr, pxLeft, 4);
647 COM.MoveMemory(pTop, pyTop, 4); 533 COM.MoveMemory(pTop.ptr, pyTop, 4);
648 COM.MoveMemory(pWidth, pcxWidth, 4); 534 COM.MoveMemory(pWidth.ptr, pcxWidth, 4);
649 COM.MoveMemory(pHeight, pcyHeight, 4); 535 COM.MoveMemory(pHeight.ptr, pcyHeight, 4);
650 osLeft = pLeft[0]; osTop = pTop[0]; osWidth = pWidth[0]; osHeight = pHeight[0]; 536 osLeft = pLeft[0]; osTop = pTop[0]; osWidth = pWidth[0]; osHeight = pHeight[0];
651 } 537 }
652 538
653 AccessibleControlEvent event = new AccessibleControlEvent(this); 539 AccessibleControlEvent event = new AccessibleControlEvent(this);
654 event.childID = osToChildID((int)/*64*/v.lVal); 540 event.childID = osToChildID(cast(int)/*64*/v.lVal);
655 event.x = osLeft; 541 event.x = osLeft;
656 event.y = osTop; 542 event.y = osTop;
657 event.width = osWidth; 543 event.width = osWidth;
658 event.height = osHeight; 544 event.height = osHeight;
659 for (int i = 0; i < accessibleControlListeners.size(); i++) { 545 for (int i = 0; i < accessibleControlListeners.length; i++) {
660 AccessibleControlListener listener = (AccessibleControlListener) accessibleControlListeners.elementAt(i); 546 AccessibleControlListener listener = cast(AccessibleControlListener) accessibleControlListeners[i];
661 listener.getLocation(event); 547 listener.getLocation(event);
662 } 548 }
663 OS.MoveMemory(pxLeft, new int[] { event.x }, 4); 549 OS.MoveMemory(pxLeft, &event.x, 4);
664 OS.MoveMemory(pyTop, new int[] { event.y }, 4); 550 OS.MoveMemory(pyTop, &event.y, 4);
665 OS.MoveMemory(pcxWidth, new int[] { event.width }, 4); 551 OS.MoveMemory(pcxWidth, &event.width, 4);
666 OS.MoveMemory(pcyHeight, new int[] { event.height }, 4); 552 OS.MoveMemory(pcyHeight, &event.height, 4);
667 return COM.S_OK; 553 return COM.S_OK;
668 } 554 }
669 555
670 int accNavigate(int navDir, int /*long*/ variant, int /*long*/ pvarEndUpAt) { 556 HRESULT accNavigate(LONG navDir, VARIANT variant, VARIANT* pvarEndUpAt) {
671 if (iaccessible is null) return COM.CO_E_OBJNOTCONNECTED; 557 if (iaccessible is null) return COM.CO_E_OBJNOTCONNECTED;
672 // Currently, we don't let the application override this. Forward to the proxy. 558 // Currently, we don't let the application override this. Forward to the proxy.
673 int code = iaccessible.accNavigate(navDir, variant, pvarEndUpAt); 559 int code = iaccessible.accNavigate(navDir, variant, pvarEndUpAt);
674 if (code is COM.E_INVALIDARG) code = COM.S_FALSE; // proxy doesn't know about app childID 560 if (code is COM.E_INVALIDARG) code = COM.S_FALSE; // proxy doesn't know about app childID
675 return code; 561 return code;
676 } 562 }
677 563
678 int accSelect(int flagsSelect, int /*long*/ variant) { 564 HRESULT accSelect(LONG flagsSelect, VARIANT variant) {
679 if (iaccessible is null) return COM.CO_E_OBJNOTCONNECTED; 565 if (iaccessible is null) return COM.CO_E_OBJNOTCONNECTED;
680 // Currently, we don't let the application override this. Forward to the proxy. 566 // Currently, we don't let the application override this. Forward to the proxy.
681 int code = iaccessible.accSelect(flagsSelect, variant); 567 int code = iaccessible.accSelect(flagsSelect, variant);
682 if (code is COM.E_INVALIDARG) code = COM.S_FALSE; // proxy doesn't know about app childID 568 if (code is COM.E_INVALIDARG) code = COM.S_FALSE; // proxy doesn't know about app childID
683 return code; 569 return code;
685 571
686 /* get_accChild([in] varChild, [out] ppdispChild) 572 /* get_accChild([in] varChild, [out] ppdispChild)
687 * Ownership of ppdispChild transfers from callee to caller so reference count on ppdispChild 573 * Ownership of ppdispChild transfers from callee to caller so reference count on ppdispChild
688 * must be incremented before returning. The caller is responsible for releasing ppdispChild. 574 * must be incremented before returning. The caller is responsible for releasing ppdispChild.
689 */ 575 */
690 int get_accChild(int /*long*/ variant, int /*long*/ ppdispChild) { 576 HRESULT get_accChild(VARIANT variant, LPDISPATCH* ppdispChild) {
691 if (iaccessible is null) return COM.CO_E_OBJNOTCONNECTED; 577 if (iaccessible is null) return COM.CO_E_OBJNOTCONNECTED;
692 VARIANT v = new VARIANT(); 578 VARIANT* v = &variant;
693 COM.MoveMemory(v, variant, VARIANT.sizeof); 579 //COM.MoveMemory(v, variant, VARIANT.sizeof);
694 if ((v.vt & 0xFFFF) !is COM.VT_I4) return COM.E_INVALIDARG; 580 if ((v.vt & 0xFFFF) !is COM.VT_I4) return COM.E_INVALIDARG;
695 if (accessibleControlListeners.size() is 0) { 581 if (accessibleControlListeners.length is 0) {
696 int code = iaccessible.get_accChild(variant, ppdispChild); 582 int code = iaccessible.get_accChild(variant, ppdispChild);
697 if (code is COM.E_INVALIDARG) code = COM.S_FALSE; // proxy doesn't know about app childID 583 if (code is COM.E_INVALIDARG) code = COM.S_FALSE; // proxy doesn't know about app childID
698 return code; 584 return code;
699 } 585 }
700 586
701 AccessibleControlEvent event = new AccessibleControlEvent(this); 587 AccessibleControlEvent event = new AccessibleControlEvent(this);
702 event.childID = osToChildID((int)/*64*/v.lVal); 588 event.childID = osToChildID(cast(int)/*64*/v.lVal);
703 for (int i = 0; i < accessibleControlListeners.size(); i++) { 589 for (int i = 0; i < accessibleControlListeners.length; i++) {
704 AccessibleControlListener listener = (AccessibleControlListener) accessibleControlListeners.elementAt(i); 590 AccessibleControlListener listener = cast(AccessibleControlListener) accessibleControlListeners[i];
705 listener.getChild(event); 591 listener.getChild(event);
706 } 592 }
707 Accessible accessible = event.accessible; 593 Accessible accessible = event.accessible;
708 if (accessible !is null) { 594 if (accessible !is null) {
709 accessible.AddRef(); 595 accessible.AddRef();
710 COM.MoveMemory(ppdispChild, new int /*long*/[] { accessible.objIAccessible.getAddress() }, OS.PTR_SIZEOF); 596 *ppdispChild = accessible.objIAccessible;
711 return COM.S_OK; 597 return COM.S_OK;
712 } 598 }
713 return COM.S_FALSE; 599 return COM.S_FALSE;
714 } 600 }
715 601
716 int get_accChildCount(int /*long*/ pcountChildren) { 602 HRESULT get_accChildCount(LONG* pcountChildren) {
717 if (iaccessible is null) return COM.CO_E_OBJNOTCONNECTED; 603 if (iaccessible is null) return COM.CO_E_OBJNOTCONNECTED;
718 604
719 /* Get the default child count from the OS. */ 605 /* Get the default child count from the OS. */
720 int osChildCount = 0; 606 int osChildCount = 0;
721 int code = iaccessible.get_accChildCount(pcountChildren); 607 int code = iaccessible.get_accChildCount(pcountChildren);
722 if (accessibleControlListeners.size() is 0) return code; 608 if (accessibleControlListeners.length is 0) return code;
723 if (code is COM.S_OK) { 609 if (code is COM.S_OK) {
724 int[] pChildCount = new int[1]; 610 int[1] pChildCount;
725 COM.MoveMemory(pChildCount, pcountChildren, 4); 611 COM.MoveMemory(pChildCount.ptr, pcountChildren, 4);
726 osChildCount = pChildCount[0]; 612 osChildCount = pChildCount[0];
727 } 613 }
728 614
729 AccessibleControlEvent event = new AccessibleControlEvent(this); 615 AccessibleControlEvent event = new AccessibleControlEvent(this);
730 event.childID = ACC.CHILDID_SELF; 616 event.childID = ACC.CHILDID_SELF;
731 event.detail = osChildCount; 617 event.detail = osChildCount;
732 for (int i = 0; i < accessibleControlListeners.size(); i++) { 618 for (int i = 0; i < accessibleControlListeners.length; i++) {
733 AccessibleControlListener listener = (AccessibleControlListener) accessibleControlListeners.elementAt(i); 619 AccessibleControlListener listener = cast(AccessibleControlListener) accessibleControlListeners[i];
734 listener.getChildCount(event); 620 listener.getChildCount(event);
735 } 621 }
736 622
737 COM.MoveMemory(pcountChildren, new int[] { event.detail }, 4); 623 *pcountChildren = event.detail;
738 return COM.S_OK; 624 return COM.S_OK;
739 } 625 }
740 626
741 int get_accDefaultAction(int /*long*/ variant, int /*long*/ pszDefaultAction) { 627 HRESULT get_accDefaultAction(VARIANT variant, BSTR* pszDefaultAction) {
742 if (iaccessible is null) return COM.CO_E_OBJNOTCONNECTED; 628 if (iaccessible is null) return COM.CO_E_OBJNOTCONNECTED;
743 VARIANT v = new VARIANT(); 629 VARIANT* v = &variant;
744 COM.MoveMemory(v, variant, VARIANT.sizeof); 630 //COM.MoveMemory(v, variant, VARIANT.sizeof);
745 if ((v.vt & 0xFFFF) !is COM.VT_I4) return COM.E_INVALIDARG; 631 if ((v.vt & 0xFFFF) !is COM.VT_I4) return COM.E_INVALIDARG;
746 632
747 /* Get the default defaultAction from the OS. */ 633 /* Get the default defaultAction from the OS. */
748 String osDefaultAction = null; 634 char[] osDefaultAction = null;
749 int code = iaccessible.get_accDefaultAction(variant, pszDefaultAction); 635 int code = iaccessible.get_accDefaultAction(variant, pszDefaultAction);
750 if (code is COM.E_INVALIDARG) code = COM.S_FALSE; // proxy doesn't know about app childID 636 if (code is COM.E_INVALIDARG) code = COM.S_FALSE; // proxy doesn't know about app childID
751 if (accessibleControlListeners.size() is 0) return code; 637 if (accessibleControlListeners.length is 0) return code;
752 if (code is COM.S_OK) { 638 if (code is COM.S_OK) {
753 int /*long*/[] pDefaultAction = new int /*long*/[1]; 639 osDefaultAction = BSTRToStr( *pszDefaultAction, true );
754 COM.MoveMemory(pDefaultAction, pszDefaultAction, OS.PTR_SIZEOF);
755 int size = COM.SysStringByteLen(pDefaultAction[0]);
756 if (size > 0) {
757 char[] buffer = new char[(size + 1) /2];
758 COM.MoveMemory(buffer, pDefaultAction[0], size);
759 osDefaultAction = new String(buffer);
760 }
761 } 640 }
762 641
763 AccessibleControlEvent event = new AccessibleControlEvent(this); 642 AccessibleControlEvent event = new AccessibleControlEvent(this);
764 event.childID = osToChildID((int)/*64*/v.lVal); 643 event.childID = osToChildID(cast(int)/*64*/v.lVal);
765 event.result = osDefaultAction; 644 event.result = osDefaultAction;
766 for (int i = 0; i < accessibleControlListeners.size(); i++) { 645 for (int i = 0; i < accessibleControlListeners.length; i++) {
767 AccessibleControlListener listener = (AccessibleControlListener) accessibleControlListeners.elementAt(i); 646 AccessibleControlListener listener = cast(AccessibleControlListener) accessibleControlListeners[i];
768 listener.getDefaultAction(event); 647 listener.getDefaultAction(event);
769 } 648 }
770 if (event.result is null) return code; 649 if (event.result is null) return code;
771 char[] data = (event.result + "\0").toCharArray(); 650 auto ptr = COM.SysAllocString(StrToWCHARz(event.result));
772 int /*long*/ ptr = COM.SysAllocString(data); 651 *pszDefaultAction = ptr;
773 COM.MoveMemory(pszDefaultAction, new int /*long*/[] { ptr }, OS.PTR_SIZEOF); 652 return COM.S_OK;
774 return COM.S_OK; 653 }
775 } 654
776 655 HRESULT get_accDescription(VARIANT variant, BSTR* pszDescription) {
777 int get_accDescription(int /*long*/ variant, int /*long*/ pszDescription) { 656 if (iaccessible is null) return COM.CO_E_OBJNOTCONNECTED;
778 if (iaccessible is null) return COM.CO_E_OBJNOTCONNECTED; 657 VARIANT* v = &variant;
779 VARIANT v = new VARIANT(); 658 //COM.MoveMemory(v, variant, VARIANT.sizeof);
780 COM.MoveMemory(v, variant, VARIANT.sizeof);
781 if ((v.vt & 0xFFFF) !is COM.VT_I4) return COM.E_INVALIDARG; 659 if ((v.vt & 0xFFFF) !is COM.VT_I4) return COM.E_INVALIDARG;
782 660
783 /* Get the default description from the OS. */ 661 /* Get the default description from the OS. */
784 String osDescription = null; 662 char[] osDescription = null;
785 int code = iaccessible.get_accDescription(variant, pszDescription); 663 int code = iaccessible.get_accDescription(variant, pszDescription);
786 if (code is COM.E_INVALIDARG) code = COM.S_FALSE; // proxy doesn't know about app childID 664 if (code is COM.E_INVALIDARG) code = COM.S_FALSE; // proxy doesn't know about app childID
787 // TEMPORARY CODE - process tree even if there are no apps listening 665 // TEMPORARY CODE - process tree even if there are no apps listening
788 if (accessibleListeners.size() is 0 && !(control instanceof Tree)) return code; 666 if (accessibleListeners.length is 0 && !( null is cast(Tree)control )) return code;
789 if (code is COM.S_OK) { 667 if (code is COM.S_OK) {
790 int /*long*/[] pDescription = new int /*long*/[1]; 668 int size = COM.SysStringByteLen(*pszDescription);
791 COM.MoveMemory(pDescription, pszDescription, OS.PTR_SIZEOF);
792 int size = COM.SysStringByteLen(pDescription[0]);
793 if (size > 0) { 669 if (size > 0) {
794 char[] buffer = new char[(size + 1) /2]; 670 size = (size + 1) /2;
795 COM.MoveMemory(buffer, pDescription[0], size); 671 osDescription = WCHARzToStr(*pszDescription, size);
796 osDescription = new String(buffer);
797 } 672 }
798 } 673 }
799 674
800 AccessibleEvent event = new AccessibleEvent(this); 675 AccessibleEvent event = new AccessibleEvent(this);
801 event.childID = osToChildID((int)/*64*/v.lVal); 676 event.childID = osToChildID(cast(int)/*64*/v.lVal);
802 event.result = osDescription; 677 event.result = osDescription;
803 678
804 // TEMPORARY CODE 679 // TEMPORARY CODE
805 /* Currently our tree columns are emulated using custom draw, 680 /* Currently our tree columns are emulated using custom draw,
806 * so we need to create the description using the tree column 681 * so we need to create the description using the tree column
807 * header text and tree item text. */ 682 * header text and tree item text. */
808 if (v.lVal !is COM.CHILDID_SELF) { 683 if (v.lVal !is COM.CHILDID_SELF) {
809 if (control instanceof Tree) { 684 if (auto tree = cast(Tree)control ) {
810 Tree tree = (Tree) control;
811 int columnCount = tree.getColumnCount (); 685 int columnCount = tree.getColumnCount ();
812 if (columnCount > 1) { 686 if (columnCount > 1) {
813 int /*long*/ hwnd = control.handle, hItem = 0; 687 HWND hwnd = control.handle;
688 int hItem;
814 if (OS.COMCTL32_MAJOR >= 6) { 689 if (OS.COMCTL32_MAJOR >= 6) {
815 hItem = OS.SendMessage (hwnd, OS.TVM_MAPACCIDTOHTREEITEM, v.lVal, 0); 690 hItem = OS.SendMessage (hwnd, OS.TVM_MAPACCIDTOHTREEITEM, v.lVal, 0);
816 } else { 691 } else {
817 hItem = v.lVal; 692 hItem = v.lVal;
818 } 693 }
819 Widget widget = tree.getDisplay ().findWidget (hwnd, hItem); 694 Widget widget = tree.getDisplay ().findWidget (hwnd, hItem);
820 event.result = ""; 695 event.result = "";
821 if (widget !is null && widget instanceof TreeItem) { 696 if (widget !is null ) if( auto item = cast(TreeItem) widget ) {
822 TreeItem item = (TreeItem) widget;
823 for (int i = 1; i < columnCount; i++) { 697 for (int i = 1; i < columnCount; i++) {
824 event.result += tree.getColumn(i).getText() + ": " + item.getText(i); 698 event.result ~= tree.getColumn(i).getText() ~ ": " ~ item.getText(i);
825 if (i + 1 < columnCount) event.result += ", "; 699 if (i + 1 < columnCount) event.result ~= ", ";
826 } 700 }
827 } 701 }
828 } 702 }
829 } 703 }
830 } 704 }
831 for (int i = 0; i < accessibleListeners.size(); i++) { 705 for (int i = 0; i < accessibleListeners.length; i++) {
832 AccessibleListener listener = (AccessibleListener) accessibleListeners.elementAt(i); 706 AccessibleListener listener = cast(AccessibleListener) accessibleListeners[i];
833 listener.getDescription(event); 707 listener.getDescription(event);
834 } 708 }
835 if (event.result is null) return code; 709 if (event.result is null) return code;
836 char[] data = (event.result + "\0").toCharArray(); 710 auto ptr = COM.SysAllocString(StrToWCHARz(event.result));
837 int /*long*/ ptr = COM.SysAllocString(data); 711 *pszDescription = ptr;
838 COM.MoveMemory(pszDescription, new int /*long*/[] { ptr }, OS.PTR_SIZEOF);
839 return COM.S_OK; 712 return COM.S_OK;
840 } 713 }
841 714
842 /* get_accFocus([out] int pvarChild) 715 /* get_accFocus([out] int pvarChild)
843 * Ownership of pvarChild transfers from callee to caller so reference count on pvarChild 716 * Ownership of pvarChild transfers from callee to caller so reference count on pvarChild
844 * must be incremented before returning. The caller is responsible for releasing pvarChild. 717 * must be incremented before returning. The caller is responsible for releasing pvarChild.
845 */ 718 */
846 int get_accFocus(int /*long*/ pvarChild) { 719 HRESULT get_accFocus(VARIANT* pvarChild) {
847 if (iaccessible is null) return COM.CO_E_OBJNOTCONNECTED; 720 if (iaccessible is null) return COM.CO_E_OBJNOTCONNECTED;
848 721
849 /* Get the default focus child from the OS. */ 722 /* Get the default focus child from the OS. */
850 int osChild = ACC.CHILDID_NONE; 723 int osChild = ACC.CHILDID_NONE;
851 int code = iaccessible.get_accFocus(pvarChild); 724 int code = iaccessible.get_accFocus(pvarChild);
852 if (accessibleControlListeners.size() is 0) return code; 725 if (accessibleControlListeners.length is 0) return code;
853 if (code is COM.S_OK) { 726 if (code is COM.S_OK) {
854 short[] pvt = new short[1]; 727 short[1] pvt;
855 COM.MoveMemory(pvt, pvarChild, 2); 728 COM.MoveMemory(pvt.ptr, pvarChild, 2);
856 if (pvt[0] is COM.VT_I4) { 729 if (pvt[0] is COM.VT_I4) {
857 int[] pChild = new int[1]; 730 int[1] pChild;
858 COM.MoveMemory(pChild, pvarChild + 8, 4); 731 COM.MoveMemory(pChild.ptr, pvarChild + 8, 4);
859 osChild = osToChildID(pChild[0]); 732 osChild = osToChildID(pChild[0]);
860 } 733 }
861 } 734 }
862 735
863 AccessibleControlEvent event = new AccessibleControlEvent(this); 736 AccessibleControlEvent event = new AccessibleControlEvent(this);
864 event.childID = osChild; 737 event.childID = osChild;
865 for (int i = 0; i < accessibleControlListeners.size(); i++) { 738 for (int i = 0; i < accessibleControlListeners.length; i++) {
866 AccessibleControlListener listener = (AccessibleControlListener) accessibleControlListeners.elementAt(i); 739 AccessibleControlListener listener = cast(AccessibleControlListener) accessibleControlListeners[i];
867 listener.getFocus(event); 740 listener.getFocus(event);
868 } 741 }
869 Accessible accessible = event.accessible; 742 Accessible accessible = event.accessible;
870 if (accessible !is null) { 743 if (accessible !is null) {
871 accessible.AddRef(); 744 accessible.AddRef();
872 COM.MoveMemory(pvarChild, new short[] { COM.VT_DISPATCH }, 2); 745 pvarChild.vt = COM.VT_DISPATCH;
873 COM.MoveMemory(pvarChild + 8, new int /*long*/[] { accessible.objIAccessible.getAddress() }, OS.PTR_SIZEOF); 746 pvarChild.byRef = cast(void*)cast(IDispatch)accessible.objIAccessible;
874 return COM.S_OK; 747 return COM.S_OK;
875 } 748 }
876 int childID = event.childID; 749 int childID = event.childID;
877 if (childID is ACC.CHILDID_NONE) { 750 if (childID is ACC.CHILDID_NONE) {
878 COM.MoveMemory(pvarChild, new short[] { COM.VT_EMPTY }, 2); 751 pvarChild.vt = COM.VT_EMPTY;
879 return COM.S_FALSE; 752 return COM.S_FALSE;
880 } 753 }
881 if (childID is ACC.CHILDID_SELF) { 754 if (childID is ACC.CHILDID_SELF) {
882 AddRef(); 755 AddRef();
883 COM.MoveMemory(pvarChild, new short[] { COM.VT_DISPATCH }, 2); 756 pvarChild.vt = COM.VT_DISPATCH;
884 COM.MoveMemory(pvarChild + 8, new int /*long*/[] { objIAccessible.getAddress() }, OS.PTR_SIZEOF); 757 pvarChild.byRef = cast(void*)cast(IDispatch)objIAccessible;
885 return COM.S_OK; 758 return COM.S_OK;
886 } 759 }
887 COM.MoveMemory(pvarChild, new short[] { COM.VT_I4 }, 2); 760 pvarChild.vt = COM.VT_I4;
888 COM.MoveMemory(pvarChild + 8, new int[] { childIDToOs(childID) }, 4); 761 pvarChild.lVal = childIDToOs(childID);
889 return COM.S_OK; 762 return COM.S_OK;
890 } 763 }
891 764
892 int get_accHelp(int /*long*/ variant, int /*long*/ pszHelp) { 765 HRESULT get_accHelp(VARIANT variant, BSTR* pszHelp) {
893 if (iaccessible is null) return COM.CO_E_OBJNOTCONNECTED; 766 if (iaccessible is null) return COM.CO_E_OBJNOTCONNECTED;
894 VARIANT v = new VARIANT(); 767 VARIANT* v = &variant;
895 COM.MoveMemory(v, variant, VARIANT.sizeof); 768 //COM.MoveMemory(v, variant, VARIANT.sizeof);
896 if ((v.vt & 0xFFFF) !is COM.VT_I4) return COM.E_INVALIDARG; 769 if ((v.vt & 0xFFFF) !is COM.VT_I4) return COM.E_INVALIDARG;
897 770
898 /* Get the default help string from the OS. */ 771 /* Get the default help string from the OS. */
899 String osHelp = null; 772 char[] osHelp = null;
900 int code = iaccessible.get_accHelp(variant, pszHelp); 773 int code = iaccessible.get_accHelp(variant, pszHelp);
901 if (code is COM.E_INVALIDARG) code = COM.S_FALSE; // proxy doesn't know about app childID 774 if (code is COM.E_INVALIDARG) code = COM.S_FALSE; // proxy doesn't know about app childID
902 if (accessibleListeners.size() is 0) return code; 775 if (accessibleListeners.length is 0) return code;
903 if (code is COM.S_OK) { 776 if (code is COM.S_OK) {
904 int /*long*/[] pHelp = new int /*long*/[1]; 777 // the original SysString is clearuped and bstr set to null
905 COM.MoveMemory(pHelp, pszHelp, OS.PTR_SIZEOF); 778 osHelp = BSTRToStr(*pszHelp, true);
906 int size = COM.SysStringByteLen(pHelp[0]);
907 if (size > 0) {
908 char[] buffer = new char[(size + 1) /2];
909 COM.MoveMemory(buffer, pHelp[0], size);
910 osHelp = new String(buffer);
911 }
912 } 779 }
913 780
914 AccessibleEvent event = new AccessibleEvent(this); 781 AccessibleEvent event = new AccessibleEvent(this);
915 event.childID = osToChildID((int)/*64*/v.lVal); 782 event.childID = osToChildID(cast(int)/*64*/v.lVal);
916 event.result = osHelp; 783 event.result = osHelp;
917 for (int i = 0; i < accessibleListeners.size(); i++) { 784 for (int i = 0; i < accessibleListeners.length; i++) {
918 AccessibleListener listener = (AccessibleListener) accessibleListeners.elementAt(i); 785 AccessibleListener listener = cast(AccessibleListener) accessibleListeners[i];
919 listener.getHelp(event); 786 listener.getHelp(event);
920 } 787 }
921 if (event.result is null) return code; 788 if (event.result is null) return code;
922 char[] data = (event.result + "\0").toCharArray(); 789 auto ptr = COM.SysAllocString(StrToWCHARz(event.result));
923 int /*long*/ ptr = COM.SysAllocString(data); 790 *pszHelp = ptr;
924 COM.MoveMemory(pszHelp, new int /*long*/[] { ptr }, OS.PTR_SIZEOF); 791 return COM.S_OK;
925 return COM.S_OK; 792 }
926 } 793
927 794 HRESULT get_accHelpTopic(BSTR* pszHelpFile, VARIANT variant, LONG* pidTopic) {
928 int get_accHelpTopic(int /*long*/ pszHelpFile, int /*long*/ variant, int /*long*/ pidTopic) {
929 if (iaccessible is null) return COM.CO_E_OBJNOTCONNECTED; 795 if (iaccessible is null) return COM.CO_E_OBJNOTCONNECTED;
930 // Currently, we don't let the application override this. Forward to the proxy. 796 // Currently, we don't let the application override this. Forward to the proxy.
931 int code = iaccessible.get_accHelpTopic(pszHelpFile, variant, pidTopic); 797 int code = iaccessible.get_accHelpTopic(pszHelpFile, variant, pidTopic);
932 if (code is COM.E_INVALIDARG) code = COM.S_FALSE; // proxy doesn't know about app childID 798 if (code is COM.E_INVALIDARG) code = COM.S_FALSE; // proxy doesn't know about app childID
933 return code; 799 return code;
934 } 800 }
935 801
936 int get_accKeyboardShortcut(int /*long*/ variant, int /*long*/ pszKeyboardShortcut) { 802 HRESULT get_accKeyboardShortcut(VARIANT variant, BSTR* pszKeyboardShortcut) {
937 if (iaccessible is null) return COM.CO_E_OBJNOTCONNECTED; 803 if (iaccessible is null) return COM.CO_E_OBJNOTCONNECTED;
938 VARIANT v = new VARIANT(); 804 VARIANT* v = &variant;
939 COM.MoveMemory(v, variant, VARIANT.sizeof); 805 //COM.MoveMemory(v, variant, VARIANT.sizeof);
940 if ((v.vt & 0xFFFF) !is COM.VT_I4) return COM.E_INVALIDARG; 806 if ((v.vt & 0xFFFF) !is COM.VT_I4) return COM.E_INVALIDARG;
941 807
942 /* Get the default keyboard shortcut from the OS. */ 808 /* Get the default keyboard shortcut from the OS. */
943 String osKeyboardShortcut = null; 809 char[] osKeyboardShortcut = null;
944 int code = iaccessible.get_accKeyboardShortcut(variant, pszKeyboardShortcut); 810 int code = iaccessible.get_accKeyboardShortcut(variant, pszKeyboardShortcut);
945 if (code is COM.E_INVALIDARG) code = COM.S_FALSE; // proxy doesn't know about app childID 811 if (code is COM.E_INVALIDARG) code = COM.S_FALSE; // proxy doesn't know about app childID
946 if (accessibleListeners.size() is 0) return code; 812 if (accessibleListeners.length is 0) return code;
947 if (code is COM.S_OK) { 813 if (code is COM.S_OK) {
948 int /*long*/[] pKeyboardShortcut = new int /*long*/[1]; 814 // the original SysString is clearuped and bstr set to null
949 COM.MoveMemory(pKeyboardShortcut, pszKeyboardShortcut, OS.PTR_SIZEOF); 815 osKeyboardShortcut = BSTRToStr(*pszKeyboardShortcut, true);
950 int size = COM.SysStringByteLen(pKeyboardShortcut[0]);
951 if (size > 0) {
952 char[] buffer = new char[(size + 1) /2];
953 COM.MoveMemory(buffer, pKeyboardShortcut[0], size);
954 osKeyboardShortcut = new String(buffer);
955 }
956 } 816 }
957 817
958 AccessibleEvent event = new AccessibleEvent(this); 818 AccessibleEvent event = new AccessibleEvent(this);
959 event.childID = osToChildID((int)/*64*/v.lVal); 819 event.childID = osToChildID(cast(int)/*64*/v.lVal);
960 event.result = osKeyboardShortcut; 820 event.result = osKeyboardShortcut;
961 for (int i = 0; i < accessibleListeners.size(); i++) { 821 for (int i = 0; i < accessibleListeners.length; i++) {
962 AccessibleListener listener = (AccessibleListener) accessibleListeners.elementAt(i); 822 AccessibleListener listener = cast(AccessibleListener) accessibleListeners[i];
963 listener.getKeyboardShortcut(event); 823 listener.getKeyboardShortcut(event);
964 } 824 }
965 if (event.result is null) return code; 825 if (event.result is null) return code;
966 char[] data = (event.result + "\0").toCharArray(); 826 auto ptr = COM.SysAllocString(StrToWCHARz(event.result));
967 int /*long*/ ptr = COM.SysAllocString(data); 827 *pszKeyboardShortcut = ptr;
968 COM.MoveMemory(pszKeyboardShortcut, new int /*long*/[] { ptr }, OS.PTR_SIZEOF); 828 return COM.S_OK;
969 return COM.S_OK; 829 }
970 } 830
971 831 HRESULT get_accName(VARIANT variant, BSTR* pszName) {
972 int get_accName(int /*long*/ variant, int /*long*/ pszName) { 832 if (iaccessible is null) return COM.CO_E_OBJNOTCONNECTED;
973 if (iaccessible is null) return COM.CO_E_OBJNOTCONNECTED; 833 VARIANT* v = &variant;
974 VARIANT v = new VARIANT(); 834 //COM.MoveMemory(v, variant, VARIANT.sizeof);
975 COM.MoveMemory(v, variant, VARIANT.sizeof);
976 if ((v.vt & 0xFFFF) !is COM.VT_I4) return COM.E_INVALIDARG; 835 if ((v.vt & 0xFFFF) !is COM.VT_I4) return COM.E_INVALIDARG;
977 836
978 /* Get the default name from the OS. */ 837 /* Get the default name from the OS. */
979 String osName = null; 838 char[] osName = null;
980 int code = iaccessible.get_accName(variant, pszName); 839 int code = iaccessible.get_accName(variant, pszName);
981 if (code is COM.E_INVALIDARG) code = COM.S_FALSE; // proxy doesn't know about app childID 840 if (code is COM.E_INVALIDARG) code = COM.S_FALSE; // proxy doesn't know about app childID
982 if (accessibleListeners.size() is 0) return code; 841 if (accessibleListeners.length is 0) return code;
983 if (code is COM.S_OK) { 842 if (code is COM.S_OK) {
984 int /*long*/[] pName = new int /*long*/[1]; 843 // the original SysString is clearuped and bstr set to null
985 COM.MoveMemory(pName, pszName, OS.PTR_SIZEOF); 844 osName = BSTRToStr(*pszName, true);
986 int size = COM.SysStringByteLen(pName[0]);
987 if (size > 0) {
988 char[] buffer = new char[(size + 1) /2];
989 COM.MoveMemory(buffer, pName[0], size);
990 osName = new String(buffer);
991 }
992 } 845 }
993 846
994 AccessibleEvent event = new AccessibleEvent(this); 847 AccessibleEvent event = new AccessibleEvent(this);
995 event.childID = osToChildID((int)/*64*/v.lVal); 848 event.childID = osToChildID(cast(int)/*64*/v.lVal);
996 event.result = osName; 849 event.result = osName;
997 for (int i = 0; i < accessibleListeners.size(); i++) { 850 for (int i = 0; i < accessibleListeners.length; i++) {
998 AccessibleListener listener = (AccessibleListener) accessibleListeners.elementAt(i); 851 AccessibleListener listener = cast(AccessibleListener) accessibleListeners[i];
999 listener.getName(event); 852 listener.getName(event);
1000 } 853 }
1001 if (event.result is null) return code; 854 if (event.result is null) return code;
1002 char[] data = (event.result + "\0").toCharArray(); 855 auto ptr = COM.SysAllocString(StrToWCHARz(event.result));
1003 int /*long*/ ptr = COM.SysAllocString(data); 856 *pszName = ptr;
1004 COM.MoveMemory(pszName, new int /*long*/[] { ptr }, OS.PTR_SIZEOF);
1005 return COM.S_OK; 857 return COM.S_OK;
1006 } 858 }
1007 859
1008 /* get_accParent([out] ppdispParent) 860 /* get_accParent([out] ppdispParent)
1009 * Ownership of ppdispParent transfers from callee to caller so reference count on ppdispParent 861 * Ownership of ppdispParent transfers from callee to caller so reference count on ppdispParent
1010 * must be incremented before returning. The caller is responsible for releasing ppdispParent. 862 * must be incremented before returning. The caller is responsible for releasing ppdispParent.
1011 */ 863 */
1012 int get_accParent(int /*long*/ ppdispParent) { 864 HRESULT get_accParent(LPDISPATCH* ppdispParent) {
1013 if (iaccessible is null) return COM.CO_E_OBJNOTCONNECTED; 865 if (iaccessible is null) return COM.CO_E_OBJNOTCONNECTED;
1014 // Currently, we don't let the application override this. Forward to the proxy. 866 // Currently, we don't let the application override this. Forward to the proxy.
1015 return iaccessible.get_accParent(ppdispParent); 867 return iaccessible.get_accParent(ppdispParent);
1016 } 868 }
1017 869
1018 int get_accRole(int /*long*/ variant, int /*long*/ pvarRole) { 870 HRESULT get_accRole(VARIANT variant, VARIANT* pvarRole) {
1019 if (iaccessible is null) return COM.CO_E_OBJNOTCONNECTED; 871 if (iaccessible is null) return COM.CO_E_OBJNOTCONNECTED;
1020 VARIANT v = new VARIANT(); 872 VARIANT* v = &variant;
1021 COM.MoveMemory(v, variant, VARIANT.sizeof); 873 //COM.MoveMemory(v, variant, VARIANT.sizeof);
1022 if ((v.vt & 0xFFFF) !is COM.VT_I4) return COM.E_INVALIDARG; 874 if ((v.vt & 0xFFFF) !is COM.VT_I4) return COM.E_INVALIDARG;
1023 875
1024 /* Get the default role from the OS. */ 876 /* Get the default role from the OS. */
1025 int osRole = COM.ROLE_SYSTEM_CLIENT; 877 int osRole = COM.ROLE_SYSTEM_CLIENT;
1026 int code = iaccessible.get_accRole(variant, pvarRole); 878 int code = iaccessible.get_accRole(variant, pvarRole);
1027 if (code is COM.E_INVALIDARG) code = COM.S_FALSE; // proxy doesn't know about app childID 879 if (code is COM.E_INVALIDARG) code = COM.S_FALSE; // proxy doesn't know about app childID
1028 // TEMPORARY CODE - process tree and table even if there are no apps listening 880 // TEMPORARY CODE - process tree and table even if there are no apps listening
1029 if (accessibleControlListeners.size() is 0 && !(control instanceof Tree || control instanceof Table)) return code; 881 if (accessibleControlListeners.length is 0 && !( null !is cast(Tree)control || null !is cast(Table)control )) return code;
1030 if (code is COM.S_OK) { 882 if (code is COM.S_OK) {
1031 short[] pvt = new short[1]; 883 short[1] pvt;
1032 COM.MoveMemory(pvt, pvarRole, 2); 884 COM.MoveMemory(pvt.ptr, pvarRole, 2);
1033 if (pvt[0] is COM.VT_I4) { 885 if (pvt[0] is COM.VT_I4) {
1034 int[] pRole = new int[1]; 886 int[1] pRole;
1035 COM.MoveMemory(pRole, pvarRole + 8, 4); 887 COM.MoveMemory(pRole.ptr, pvarRole + 8, 4);
1036 osRole = pRole[0]; 888 osRole = pRole[0];
1037 } 889 }
1038 } 890 }
1039 891
1040 AccessibleControlEvent event = new AccessibleControlEvent(this); 892 AccessibleControlEvent event = new AccessibleControlEvent(this);
1041 event.childID = osToChildID((int)/*64*/v.lVal); 893 event.childID = osToChildID(cast(int)/*64*/v.lVal);
1042 event.detail = osToRole(osRole); 894 event.detail = osToRole(osRole);
1043 // TEMPORARY CODE 895 // TEMPORARY CODE
1044 /* Currently our checkbox table and tree are emulated using state mask 896 /* Currently our checkbox table and tree are emulated using state mask
1045 * images, so we need to specify 'checkbox' role for the items. */ 897 * images, so we need to specify 'checkbox' role for the items. */
1046 if (v.lVal !is COM.CHILDID_SELF) { 898 if (v.lVal !is COM.CHILDID_SELF) {
1047 if (control instanceof Tree || control instanceof Table) { 899 if ( null !is cast(Tree)control || null !is cast(Table)control ) {
1048 if ((control.getStyle() & DWT.CHECK) !is 0) event.detail = ACC.ROLE_CHECKBUTTON; 900 if ((control.getStyle() & DWT.CHECK) !is 0) event.detail = ACC.ROLE_CHECKBUTTON;
1049 } 901 }
1050 } 902 }
1051 for (int i = 0; i < accessibleControlListeners.size(); i++) { 903 for (int i = 0; i < accessibleControlListeners.length; i++) {
1052 AccessibleControlListener listener = (AccessibleControlListener) accessibleControlListeners.elementAt(i); 904 AccessibleControlListener listener = cast(AccessibleControlListener) accessibleControlListeners[i];
1053 listener.getRole(event); 905 listener.getRole(event);
1054 } 906 }
1055 int role = roleToOs(event.detail); 907 int role = roleToOs(event.detail);
1056 COM.MoveMemory(pvarRole, new short[] { COM.VT_I4 }, 2); 908 pvarRole.vt = COM.VT_I4;
1057 COM.MoveMemory(pvarRole + 8, new int[] { role }, 4); 909 pvarRole.lVal = role;
1058 return COM.S_OK; 910 return COM.S_OK;
1059 } 911 }
1060 912
1061 /* get_accSelection([out] pvarChildren) 913 /* get_accSelection([out] pvarChildren)
1062 * Ownership of pvarChildren transfers from callee to caller so reference count on pvarChildren 914 * Ownership of pvarChildren transfers from callee to caller so reference count on pvarChildren
1063 * must be incremented before returning. The caller is responsible for releasing pvarChildren. 915 * must be incremented before returning. The caller is responsible for releasing pvarChildren.
1064 */ 916 */
1065 int get_accSelection(int /*long*/ pvarChildren) { 917 HRESULT get_accSelection(VARIANT* pvarChildren) {
1066 if (iaccessible is null) return COM.CO_E_OBJNOTCONNECTED; 918 if (iaccessible is null) return COM.CO_E_OBJNOTCONNECTED;
1067 919
1068 /* Get the default selection from the OS. */ 920 /* Get the default selection from the OS. */
1069 int osChild = ACC.CHILDID_NONE; 921 int osChild = ACC.CHILDID_NONE;
1070 int code = iaccessible.get_accSelection(pvarChildren); 922 int code = iaccessible.get_accSelection(pvarChildren);
1071 if (accessibleControlListeners.size() is 0) return code; 923 if (accessibleControlListeners.length is 0) return code;
1072 if (code is COM.S_OK) { 924 if (code is COM.S_OK) {
1073 short[] pvt = new short[1]; 925 short[1] pvt;
1074 COM.MoveMemory(pvt, pvarChildren, 2); 926 COM.MoveMemory(pvt.ptr, pvarChildren, 2);
1075 if (pvt[0] is COM.VT_I4) { 927 if (pvt[0] is COM.VT_I4) {
1076 int[] pChild = new int[1]; 928 int[1] pChild;
1077 COM.MoveMemory(pChild, pvarChildren + 8, 4); 929 COM.MoveMemory(pChild.ptr, pvarChildren + 8, 4);
1078 osChild = osToChildID(pChild[0]); 930 osChild = osToChildID(pChild[0]);
1079 } else if (pvt[0] is COM.VT_UNKNOWN) { 931 } else if (pvt[0] is COM.VT_UNKNOWN) {
1080 osChild = ACC.CHILDID_MULTIPLE; 932 osChild = ACC.CHILDID_MULTIPLE;
1081 /* Should get IEnumVARIANT from punkVal field, and enumerate children... */ 933 /* Should get IEnumVARIANT from punkVal field, and enumerate children... */
1082 } 934 }
1083 } 935 }
1084 936
1085 AccessibleControlEvent event = new AccessibleControlEvent(this); 937 AccessibleControlEvent event = new AccessibleControlEvent(this);
1086 event.childID = osChild; 938 event.childID = osChild;
1087 for (int i = 0; i < accessibleControlListeners.size(); i++) { 939 for (int i = 0; i < accessibleControlListeners.length; i++) {
1088 AccessibleControlListener listener = (AccessibleControlListener) accessibleControlListeners.elementAt(i); 940 AccessibleControlListener listener = cast(AccessibleControlListener) accessibleControlListeners[i];
1089 listener.getSelection(event); 941 listener.getSelection(event);
1090 } 942 }
1091 Accessible accessible = event.accessible; 943 Accessible accessible = event.accessible;
1092 if (accessible !is null) { 944 if (accessible !is null) {
1093 accessible.AddRef(); 945 accessible.AddRef();
1094 COM.MoveMemory(pvarChildren, new short[] { COM.VT_DISPATCH }, 2); 946 pvarChildren.vt = COM.VT_DISPATCH;
1095 COM.MoveMemory(pvarChildren + 8, new int /*long*/[] { accessible.objIAccessible.getAddress() }, OS.PTR_SIZEOF); 947 pvarChildren.byRef = cast(void*)cast(IDispatch)accessible.objIAccessible;
1096 return COM.S_OK; 948 return COM.S_OK;
1097 } 949 }
1098 int childID = event.childID; 950 int childID = event.childID;
1099 if (childID is ACC.CHILDID_NONE) { 951 if (childID is ACC.CHILDID_NONE) {
1100 COM.MoveMemory(pvarChildren, new short[] { COM.VT_EMPTY }, 2); 952 pvarChildren.vt = COM.VT_EMPTY;
1101 return COM.S_FALSE; 953 return COM.S_FALSE;
1102 } 954 }
1103 if (childID is ACC.CHILDID_MULTIPLE) { 955 if (childID is ACC.CHILDID_MULTIPLE) {
1104 AddRef(); 956 AddRef();
1105 COM.MoveMemory(pvarChildren, new short[] { COM.VT_UNKNOWN }, 2); 957 pvarChildren.vt = COM.VT_UNKNOWN;
1106 COM.MoveMemory(pvarChildren + 8, new int /*long*/[] { objIAccessible.getAddress() }, OS.PTR_SIZEOF); 958 pvarChildren.byRef = cast(void*)cast(IUnknown)objIAccessible;
1107 return COM.S_OK; 959 return COM.S_OK;
1108 } 960 }
1109 if (childID is ACC.CHILDID_SELF) { 961 if (childID is ACC.CHILDID_SELF) {
1110 AddRef(); 962 AddRef();
1111 COM.MoveMemory(pvarChildren, new short[] { COM.VT_DISPATCH }, 2); 963 pvarChildren.vt = COM.VT_DISPATCH;
1112 COM.MoveMemory(pvarChildren + 8, new int /*long*/[] { objIAccessible.getAddress() }, OS.PTR_SIZEOF); 964 pvarChildren.byRef = cast(void*)cast(IDispatch)objIAccessible;
1113 return COM.S_OK; 965 return COM.S_OK;
1114 } 966 }
1115 COM.MoveMemory(pvarChildren, new short[] { COM.VT_I4 }, 2); 967 pvarChildren.vt = COM.VT_I4;
1116 COM.MoveMemory(pvarChildren + 8, new int[] { childIDToOs(childID) }, 4); 968 pvarChildren.lVal = childIDToOs(childID);
1117 return COM.S_OK; 969 return COM.S_OK;
1118 } 970 }
1119 971
1120 int get_accState(int /*long*/ variant, int /*long*/ pvarState) { 972 HRESULT get_accState(VARIANT variant, VARIANT* pvarState) {
1121 if (iaccessible is null) return COM.CO_E_OBJNOTCONNECTED; 973 if (iaccessible is null) return COM.CO_E_OBJNOTCONNECTED;
1122 VARIANT v = new VARIANT(); 974 VARIANT* v = &variant;
1123 COM.MoveMemory(v, variant, VARIANT.sizeof); 975 //COM.MoveMemory(v, variant, VARIANT.sizeof);
1124 if ((v.vt & 0xFFFF) !is COM.VT_I4) return COM.E_INVALIDARG; 976 if ((v.vt & 0xFFFF) !is COM.VT_I4) return COM.E_INVALIDARG;
1125 977
1126 /* Get the default state from the OS. */ 978 /* Get the default state from the OS. */
1127 int osState = 0; 979 int osState = 0;
1128 int code = iaccessible.get_accState(variant, pvarState); 980 int code = iaccessible.get_accState(variant, pvarState);
1129 if (code is COM.E_INVALIDARG) code = COM.S_FALSE; // proxy doesn't know about app childID 981 if (code is COM.E_INVALIDARG) code = COM.S_FALSE; // proxy doesn't know about app childID
1130 // TEMPORARY CODE - process tree and table even if there are no apps listening 982 // TEMPORARY CODE - process tree and table even if there are no apps listening
1131 if (accessibleControlListeners.size() is 0 && !(control instanceof Tree || control instanceof Table)) return code; 983 if (accessibleControlListeners.length is 0 && !( null !is cast(Tree)control || null !is cast(Table)control )) return code;
1132 if (code is COM.S_OK) { 984 if (code is COM.S_OK) {
1133 short[] pvt = new short[1]; 985 short[1] pvt;
1134 COM.MoveMemory(pvt, pvarState, 2); 986 COM.MoveMemory(pvt.ptr, pvarState, 2);
1135 if (pvt[0] is COM.VT_I4) { 987 if (pvt[0] is COM.VT_I4) {
1136 int[] pState = new int[1]; 988 int[1] pState;
1137 COM.MoveMemory(pState, pvarState + 8, 4); 989 COM.MoveMemory(pState.ptr, pvarState + 8, 4);
1138 osState = pState[0]; 990 osState = pState[0];
1139 } 991 }
1140 } 992 }
1141 993
1142 AccessibleControlEvent event = new AccessibleControlEvent(this); 994 AccessibleControlEvent event = new AccessibleControlEvent(this);
1143 event.childID = osToChildID((int)/*64*/v.lVal); 995 event.childID = osToChildID(cast(int)/*64*/v.lVal);
1144 event.detail = osToState(osState); 996 event.detail = osToState(osState);
1145 // TEMPORARY CODE 997 // TEMPORARY CODE
1146 /* Currently our checkbox table and tree are emulated using state mask 998 /* Currently our checkbox table and tree are emulated using state mask
1147 * images, so we need to determine if the item state is 'checked'. */ 999 * images, so we need to determine if the item state is 'checked'. */
1148 if (v.lVal !is COM.CHILDID_SELF) { 1000 if (v.lVal !is COM.CHILDID_SELF) {
1149 if (control instanceof Tree && (control.getStyle() & DWT.CHECK) !is 0) { 1001 if (null !is cast(Tree)control && (control.getStyle() & DWT.CHECK) !is 0) {
1150 int /*long*/ hwnd = control.handle; 1002 auto hwnd = control.handle;
1151 TVITEM tvItem = new TVITEM (); 1003 TVITEM tvItem;
1152 tvItem.mask = OS.TVIF_HANDLE | OS.TVIF_STATE; 1004 tvItem.mask = OS.TVIF_HANDLE | OS.TVIF_STATE;
1153 tvItem.stateMask = OS.TVIS_STATEIMAGEMASK; 1005 tvItem.stateMask = OS.TVIS_STATEIMAGEMASK;
1154 if (OS.COMCTL32_MAJOR >= 6) { 1006 if (OS.COMCTL32_MAJOR >= 6) {
1155 tvItem.hItem = OS.SendMessage (hwnd, OS.TVM_MAPACCIDTOHTREEITEM, v.lVal, 0); 1007 tvItem.hItem = cast(HANDLE) OS.SendMessage (hwnd, OS.TVM_MAPACCIDTOHTREEITEM, v.lVal, 0);
1156 } else { 1008 } else {
1157 tvItem.hItem = v.lVal; 1009 tvItem.hItem = cast(HANDLE) v.lVal;
1158 } 1010 }
1159 int /*long*/ result = OS.SendMessage (hwnd, OS.TVM_GETITEM, 0, tvItem); 1011 auto result = OS.SendMessage (hwnd, OS.TVM_GETITEM, 0, &tvItem);
1160 bool checked = (result !is 0) && (((tvItem.state >> 12) & 1) is 0); 1012 bool checked = (result !is 0) && (((tvItem.state >> 12) & 1) is 0);
1161 if (checked) event.detail |= ACC.STATE_CHECKED; 1013 if (checked) event.detail |= ACC.STATE_CHECKED;
1162 } else if (control instanceof Table && (control.getStyle() & DWT.CHECK) !is 0) { 1014 } else if (null !is cast(Table)control && (control.getStyle() & DWT.CHECK) !is 0) {
1163 Table table = (Table) control; 1015 Table table = cast(Table) control;
1164 TableItem item = table.getItem(event.childID); 1016 TableItem item = table.getItem(event.childID);
1165 if (item !is null) { 1017 if (item !is null) {
1166 if (item.getChecked()) event.detail |= ACC.STATE_CHECKED; 1018 if (item.getChecked()) event.detail |= ACC.STATE_CHECKED;
1167 } 1019 }
1168 } 1020 }
1169 } 1021 }
1170 for (int i = 0; i < accessibleControlListeners.size(); i++) { 1022 for (int i = 0; i < accessibleControlListeners.length; i++) {
1171 AccessibleControlListener listener = (AccessibleControlListener) accessibleControlListeners.elementAt(i); 1023 AccessibleControlListener listener = cast(AccessibleControlListener) accessibleControlListeners[i];
1172 listener.getState(event); 1024 listener.getState(event);
1173 } 1025 }
1174 int state = stateToOs(event.detail); 1026 int state = stateToOs(event.detail);
1175 COM.MoveMemory(pvarState, new short[] { COM.VT_I4 }, 2); 1027 pvarState.vt = COM.VT_I4;
1176 COM.MoveMemory(pvarState + 8, new int[] { state }, 4); 1028 pvarState.lVal = state;
1177 return COM.S_OK; 1029 return COM.S_OK;
1178 } 1030 }
1179 1031
1180 int get_accValue(int /*long*/ variant, int /*long*/ pszValue) { 1032 HRESULT get_accValue(VARIANT variant, BSTR* pszValue) {
1181 if (iaccessible is null) return COM.CO_E_OBJNOTCONNECTED; 1033 if (iaccessible is null) return COM.CO_E_OBJNOTCONNECTED;
1182 VARIANT v = new VARIANT(); 1034 VARIANT* v = &variant;
1183 COM.MoveMemory(v, variant, VARIANT.sizeof); 1035 //COM.MoveMemory(v, variant, VARIANT.sizeof);
1184 if ((v.vt & 0xFFFF) !is COM.VT_I4) return COM.E_INVALIDARG; 1036 if ((v.vt & 0xFFFF) !is COM.VT_I4) return COM.E_INVALIDARG;
1185 1037
1186 /* Get the default value string from the OS. */ 1038 /* Get the default value string from the OS. */
1187 String osValue = null; 1039 char[] osValue = null;
1188 int code = iaccessible.get_accValue(variant, pszValue); 1040 int code = iaccessible.get_accValue(variant, pszValue);
1189 if (code is COM.E_INVALIDARG) code = COM.S_FALSE; // proxy doesn't know about app childID 1041 if (code is COM.E_INVALIDARG) code = COM.S_FALSE; // proxy doesn't know about app childID
1190 if (accessibleControlListeners.size() is 0) return code; 1042 if (accessibleControlListeners.length is 0) return code;
1191 if (code is COM.S_OK) { 1043 if (code is COM.S_OK) {
1192 int /*long*/[] pValue = new int /*long*/[1]; 1044 int size = COM.SysStringByteLen(*pszValue);
1193 COM.MoveMemory(pValue, pszValue, OS.PTR_SIZEOF);
1194 int size = COM.SysStringByteLen(pValue[0]);
1195 if (size > 0) { 1045 if (size > 0) {
1196 char[] buffer = new char[(size + 1) /2]; 1046 osValue = WCHARsToStr((*pszValue)[ 0 .. size ]);
1197 COM.MoveMemory(buffer, pValue[0], size);
1198 osValue = new String(buffer);
1199 } 1047 }
1200 } 1048 }
1201 1049
1202 AccessibleControlEvent event = new AccessibleControlEvent(this); 1050 AccessibleControlEvent event = new AccessibleControlEvent(this);
1203 event.childID = osToChildID((int)/*64*/v.lVal); 1051 event.childID = osToChildID(cast(int)/*64*/v.lVal);
1204 event.result = osValue; 1052 event.result = osValue;
1205 for (int i = 0; i < accessibleControlListeners.size(); i++) { 1053 for (int i = 0; i < accessibleControlListeners.length; i++) {
1206 AccessibleControlListener listener = (AccessibleControlListener) accessibleControlListeners.elementAt(i); 1054 AccessibleControlListener listener = cast(AccessibleControlListener) accessibleControlListeners[i];
1207 listener.getValue(event); 1055 listener.getValue(event);
1208 } 1056 }
1209 if (event.result is null) return code; 1057 if (event.result is null) return code;
1210 char[] data = (event.result + "\0").toCharArray(); 1058 auto ptr = COM.SysAllocString(StrToWCHARz(event.result));
1211 int /*long*/ ptr = COM.SysAllocString(data); 1059 *pszValue = ptr;
1212 COM.MoveMemory(pszValue, new int /*long*/[] { ptr }, OS.PTR_SIZEOF); 1060 return COM.S_OK;
1213 return COM.S_OK; 1061 }
1214 } 1062
1215 1063 HRESULT put_accName(VARIANT variant, BSTR* szName) {
1216 int put_accName(int /*long*/ variant, int /*long*/ szName) {
1217 // MSAA: this method is no longer supported 1064 // MSAA: this method is no longer supported
1218 if (iaccessible is null) return COM.CO_E_OBJNOTCONNECTED; 1065 if (iaccessible is null) return COM.CO_E_OBJNOTCONNECTED;
1219 // We don't implement this. Forward to the proxy. 1066 // We don't implement this. Forward to the proxy.
1220 int code = iaccessible.put_accName(variant, szName); 1067 int code = iaccessible.put_accName(variant, szName);
1221 if (code is COM.E_INVALIDARG) code = COM.S_FALSE; // proxy doesn't know about app childID 1068 if (code is COM.E_INVALIDARG) code = COM.S_FALSE; // proxy doesn't know about app childID
1222 return code; 1069 return code;
1223 } 1070 }
1224 1071
1225 int put_accValue(int /*long*/ variant, int /*long*/ szValue) { 1072 HRESULT put_accValue(VARIANT variant, BSTR* szValue) {
1226 // MSAA: this method is typically only used for edit controls 1073 // MSAA: this method is typically only used for edit controls
1227 if (iaccessible is null) return COM.CO_E_OBJNOTCONNECTED; 1074 if (iaccessible is null) return COM.CO_E_OBJNOTCONNECTED;
1228 // We don't implement this. Forward to the proxy. 1075 // We don't implement this. Forward to the proxy.
1229 int code = iaccessible.put_accValue(variant, szValue); 1076 int code = iaccessible.put_accValue(variant, szValue);
1230 if (code is COM.E_INVALIDARG) code = COM.S_FALSE; // proxy doesn't know about app childID 1077 if (code is COM.E_INVALIDARG) code = COM.S_FALSE; // proxy doesn't know about app childID
1241 1088
1242 /* Next([in] celt, [out] rgvar, [in, out] pceltFetched) 1089 /* Next([in] celt, [out] rgvar, [in, out] pceltFetched)
1243 * Ownership of rgvar transfers from callee to caller so reference count on rgvar 1090 * Ownership of rgvar transfers from callee to caller so reference count on rgvar
1244 * must be incremented before returning. The caller is responsible for releasing rgvar. 1091 * must be incremented before returning. The caller is responsible for releasing rgvar.
1245 */ 1092 */
1246 int Next(int celt, int /*long*/ rgvar, int /*long*/ pceltFetched) { 1093 HRESULT Next(ULONG celt, VARIANT *rgvar, ULONG *pceltFetched) {
1247 /* If there are no listeners, query the proxy for 1094 /* If there are no listeners, query the proxy for
1248 * its IEnumVariant, and get the Next items from it. 1095 * its IEnumVariant, and get the Next items from it.
1249 */ 1096 */
1250 if (accessibleControlListeners.size() is 0) { 1097 if (accessibleControlListeners.length is 0) {
1251 int /*long*/[] ppvObject = new int /*long*/[1]; 1098 IEnumVARIANT ienumvariant;
1252 int code = iaccessible.QueryInterface(COM.IIDIEnumVARIANT, ppvObject); 1099 int code = iaccessible.QueryInterface(&COM.IIDIEnumVARIANT, cast(void**)&ienumvariant);
1253 if (code !is COM.S_OK) return code; 1100 if (code !is COM.S_OK) return code;
1254 IEnumVARIANT ienumvariant = new IEnumVARIANT(ppvObject[0]); 1101 uint[1] celtFetched;
1255 int[] celtFetched = new int[1]; 1102 code = ienumvariant.Next(celt, rgvar, celtFetched.ptr);
1256 code = ienumvariant.Next(celt, rgvar, celtFetched);
1257 ienumvariant.Release(); 1103 ienumvariant.Release();
1258 COM.MoveMemory(pceltFetched, celtFetched, 4); 1104 COM.MoveMemory(pceltFetched, celtFetched.ptr, 4);
1259 return code; 1105 return code;
1260 } 1106 }
1261 1107
1262 if (rgvar is 0) return COM.E_INVALIDARG; 1108 if (rgvar is null) return COM.E_INVALIDARG;
1263 if (pceltFetched is 0 && celt !is 1) return COM.E_INVALIDARG; 1109 if (pceltFetched is null && celt !is 1) return COM.E_INVALIDARG;
1264 if (enumIndex is 0) { 1110 if (enumIndex is 0) {
1265 AccessibleControlEvent event = new AccessibleControlEvent(this); 1111 AccessibleControlEvent event = new AccessibleControlEvent(this);
1266 event.childID = ACC.CHILDID_SELF; 1112 event.childID = ACC.CHILDID_SELF;
1267 for (int i = 0; i < accessibleControlListeners.size(); i++) { 1113 for (int i = 0; i < accessibleControlListeners.length; i++) {
1268 AccessibleControlListener listener = (AccessibleControlListener) accessibleControlListeners.elementAt(i); 1114 AccessibleControlListener listener = cast(AccessibleControlListener) accessibleControlListeners[i];
1269 listener.getChildren(event); 1115 listener.getChildren(event);
1270 } 1116 }
1271 variants = event.children; 1117 variants = event.children;
1272 } 1118 }
1273 Object[] nextItems = null; 1119 Object[] nextItems = null;
1276 if (endIndex > (variants.length - 1)) endIndex = variants.length - 1; 1122 if (endIndex > (variants.length - 1)) endIndex = variants.length - 1;
1277 if (enumIndex <= endIndex) { 1123 if (enumIndex <= endIndex) {
1278 nextItems = new Object[endIndex - enumIndex + 1]; 1124 nextItems = new Object[endIndex - enumIndex + 1];
1279 for (int i = 0; i < nextItems.length; i++) { 1125 for (int i = 0; i < nextItems.length; i++) {
1280 Object child = variants[enumIndex]; 1126 Object child = variants[enumIndex];
1281 if (child instanceof Integer) { 1127 if (auto val = cast(ValueWrapperInt)child ) {
1282 nextItems[i] = new Integer(childIDToOs(((Integer)child).intValue())); 1128 nextItems[i] = new ValueWrapperInt(childIDToOs(val.value));
1283 } else { 1129 } else {
1284 nextItems[i] = child; 1130 nextItems[i] = child;
1285 } 1131 }
1286 enumIndex++; 1132 enumIndex++;
1287 } 1133 }
1288 } 1134 }
1289 } 1135 }
1290 if (nextItems !is null) { 1136 if (nextItems !is null) {
1291 for (int i = 0; i < nextItems.length; i++) { 1137 for (int i = 0; i < nextItems.length; i++) {
1292 Object nextItem = nextItems[i]; 1138 Object nextItem = nextItems[i];
1293 if (nextItem instanceof Integer) { 1139 if (auto val = cast(ValueWrapperInt)nextItem ) {
1294 int item = ((Integer) nextItem).intValue(); 1140 int item = val.value;
1295 COM.MoveMemory(rgvar + i * 16, new short[] { COM.VT_I4 }, 2); 1141 rgvar[i].vt = COM.VT_I4;
1296 COM.MoveMemory(rgvar + i * 16 + 8, new int[] { item }, 4); 1142 rgvar[i].byRef = cast(void*)item;
1297 } else { 1143 } else {
1298 Accessible accessible = (Accessible) nextItem; 1144 Accessible accessible = cast(Accessible) nextItem;
1299 accessible.AddRef(); 1145 accessible.AddRef();
1300 COM.MoveMemory(rgvar + i * 16, new short[] { COM.VT_DISPATCH }, 2); 1146 rgvar[i].vt = COM.VT_DISPATCH;
1301 COM.MoveMemory(rgvar + i * 16 + 8, new int /*long*/[] { accessible.objIAccessible.getAddress() }, OS.PTR_SIZEOF); 1147 rgvar[i].byRef = cast(void*)accessible.objIAccessible;
1302 } 1148 }
1303 } 1149 }
1304 if (pceltFetched !is 0) 1150 if (pceltFetched !is null)
1305 COM.MoveMemory(pceltFetched, new int[] {nextItems.length}, 4); 1151 *pceltFetched = nextItems.length;
1306 if (nextItems.length is celt) return COM.S_OK; 1152 if (nextItems.length is celt) return COM.S_OK;
1307 } else { 1153 } else {
1308 if (pceltFetched !is 0) 1154 if (pceltFetched !is null){
1309 COM.MoveMemory(pceltFetched, new int[] {0}, 4); 1155 int zero = 0;
1156 *pceltFetched = 0;
1157 }
1310 } 1158 }
1311 return COM.S_FALSE; 1159 return COM.S_FALSE;
1312 } 1160 }
1313 1161
1314 /* Skip over the specified number of elements in the enumeration sequence. */ 1162 /* Skip over the specified number of elements in the enumeration sequence. */
1315 int Skip(int celt) { 1163 HRESULT Skip(ULONG celt) {
1316 /* If there are no listeners, query the proxy 1164 /* If there are no listeners, query the proxy
1317 * for its IEnumVariant, and tell it to Skip. 1165 * for its IEnumVariant, and tell it to Skip.
1318 */ 1166 */
1319 if (accessibleControlListeners.size() is 0) { 1167 if (accessibleControlListeners.length is 0) {
1320 int /*long*/[] ppvObject = new int /*long*/[1]; 1168 IEnumVARIANT ienumvariant;
1321 int code = iaccessible.QueryInterface(COM.IIDIEnumVARIANT, ppvObject); 1169 int code = iaccessible.QueryInterface(&COM.IIDIEnumVARIANT, cast(void**)&ienumvariant);
1322 if (code !is COM.S_OK) return code; 1170 if (code !is COM.S_OK) return code;
1323 IEnumVARIANT ienumvariant = new IEnumVARIANT(ppvObject[0]);
1324 code = ienumvariant.Skip(celt); 1171 code = ienumvariant.Skip(celt);
1325 ienumvariant.Release(); 1172 ienumvariant.Release();
1326 return code; 1173 return code;
1327 } 1174 }
1328 1175
1334 } 1181 }
1335 return COM.S_OK; 1182 return COM.S_OK;
1336 } 1183 }
1337 1184
1338 /* Reset the enumeration sequence to the beginning. */ 1185 /* Reset the enumeration sequence to the beginning. */
1339 int Reset() { 1186 HRESULT Reset() {
1340 /* If there are no listeners, query the proxy 1187 /* If there are no listeners, query the proxy
1341 * for its IEnumVariant, and tell it to Reset. 1188 * for its IEnumVariant, and tell it to Reset.
1342 */ 1189 */
1343 if (accessibleControlListeners.size() is 0) { 1190 if (accessibleControlListeners.length is 0) {
1344 int /*long*/[] ppvObject = new int /*long*/[1]; 1191 IEnumVARIANT ienumvariant;
1345 int code = (int)/*64*/iaccessible.QueryInterface(COM.IIDIEnumVARIANT, ppvObject); 1192 int code = cast(int)/*64*/iaccessible.QueryInterface(&COM.IIDIEnumVARIANT, cast(void**)&ienumvariant);
1346 if (code !is COM.S_OK) return code; 1193 if (code !is COM.S_OK) return code;
1347 IEnumVARIANT ienumvariant = new IEnumVARIANT(ppvObject[0]);
1348 code = ienumvariant.Reset(); 1194 code = ienumvariant.Reset();
1349 ienumvariant.Release(); 1195 ienumvariant.Release();
1350 return code; 1196 return code;
1351 } 1197 }
1352 1198
1356 1202
1357 /* Clone([out] ppEnum) 1203 /* Clone([out] ppEnum)
1358 * Ownership of ppEnum transfers from callee to caller so reference count on ppEnum 1204 * Ownership of ppEnum transfers from callee to caller so reference count on ppEnum
1359 * must be incremented before returning. The caller is responsible for releasing ppEnum. 1205 * must be incremented before returning. The caller is responsible for releasing ppEnum.
1360 */ 1206 */
1361 int Clone(int /*long*/ ppEnum) { 1207 int Clone(IEnumVARIANT* ppEnum) {
1362 /* If there are no listeners, query the proxy for 1208 /* If there are no listeners, query the proxy for
1363 * its IEnumVariant, and get the Clone from it. 1209 * its IEnumVariant, and get the Clone from it.
1364 */ 1210 */
1365 if (accessibleControlListeners.size() is 0) { 1211 if (accessibleControlListeners.length is 0) {
1366 int /*long*/[] ppvObject = new int /*long*/[1]; 1212 IEnumVARIANT ienumvariant;
1367 int code = iaccessible.QueryInterface(COM.IIDIEnumVARIANT, ppvObject); 1213 int code = iaccessible.QueryInterface(&COM.IIDIEnumVARIANT, cast(void**)&ienumvariant);
1368 if (code !is COM.S_OK) return code; 1214 if (code !is COM.S_OK) return code;
1369 IEnumVARIANT ienumvariant = new IEnumVARIANT(ppvObject[0]); 1215 IEnumVARIANT[1] pEnum;
1370 int[] pEnum = new int[1]; 1216 code = ienumvariant.Clone(pEnum.ptr);
1371 code = ienumvariant.Clone(pEnum);
1372 ienumvariant.Release(); 1217 ienumvariant.Release();
1373 COM.MoveMemory(ppEnum, pEnum, 4); 1218 COM.MoveMemory(ppEnum, pEnum.ptr, 4);
1374 return code; 1219 return code;
1375 } 1220 }
1376 1221
1377 if (ppEnum is 0) return COM.E_INVALIDARG; 1222 if (ppEnum is null) return COM.E_INVALIDARG;
1378 COM.MoveMemory(ppEnum, new int /*long*/[] { objIEnumVARIANT.getAddress()}, OS.PTR_SIZEOF); 1223 *ppEnum = objIEnumVARIANT;
1379 AddRef(); 1224 AddRef();
1380 return COM.S_OK; 1225 return COM.S_OK;
1381 } 1226 }
1382 1227
1383 int childIDToOs(int childID) { 1228 int childIDToOs(int childID) {
1387 * In Windows XP, tree item ids are 1-based indices. Previous versions 1232 * In Windows XP, tree item ids are 1-based indices. Previous versions
1388 * of Windows use the tree item handle for the accessible child ID. 1233 * of Windows use the tree item handle for the accessible child ID.
1389 * For backward compatibility, we still take a handle childID for tree 1234 * For backward compatibility, we still take a handle childID for tree
1390 * items on XP. All other childIDs are 1-based indices. 1235 * items on XP. All other childIDs are 1-based indices.
1391 */ 1236 */
1392 if (!(control instanceof Tree)) return childID + 1; 1237 if (!(cast(Tree)control )) return childID + 1;
1393 if (OS.COMCTL32_MAJOR < 6) return childID; 1238 if (OS.COMCTL32_MAJOR < 6) return childID;
1394 return (int)/*64*/OS.SendMessage (control.handle, OS.TVM_MAPHTREEITEMTOACCID, childID, 0); 1239 return cast(int)/*64*/OS.SendMessage (control.handle, OS.TVM_MAPHTREEITEMTOACCID, childID, 0);
1395 } 1240 }
1396 1241
1397 int osToChildID(int osChildID) { 1242 int osToChildID(int osChildID) {
1398 if (osChildID is COM.CHILDID_SELF) return ACC.CHILDID_SELF; 1243 if (osChildID is COM.CHILDID_SELF) return ACC.CHILDID_SELF;
1399 /* 1244 /*
1401 * In Windows XP, tree item ids are 1-based indices. Previous versions 1246 * In Windows XP, tree item ids are 1-based indices. Previous versions
1402 * of Windows use the tree item handle for the accessible child ID. 1247 * of Windows use the tree item handle for the accessible child ID.
1403 * For backward compatibility, we still take a handle childID for tree 1248 * For backward compatibility, we still take a handle childID for tree
1404 * items on XP. All other childIDs are 1-based indices. 1249 * items on XP. All other childIDs are 1-based indices.
1405 */ 1250 */
1406 if (!(control instanceof Tree)) return osChildID - 1; 1251 if (!(cast(Tree)control )) return osChildID - 1;
1407 if (OS.COMCTL32_MAJOR < 6) return osChildID; 1252 if (OS.COMCTL32_MAJOR < 6) return osChildID;
1408 return (int)/*64*/OS.SendMessage (control.handle, OS.TVM_MAPACCIDTOHTREEITEM, osChildID, 0); 1253 return cast(int)/*64*/OS.SendMessage (control.handle, OS.TVM_MAPACCIDTOHTREEITEM, osChildID, 0);
1409 } 1254 }
1410 1255
1411 int stateToOs(int state) { 1256 int stateToOs(int state) {
1412 int osState = 0; 1257 int osState = 0;
1413 if ((state & ACC.STATE_SELECTED) !is 0) osState |= COM.STATE_SYSTEM_SELECTED; 1258 if ((state & ACC.STATE_SELECTED) !is 0) osState |= COM.STATE_SYSTEM_SELECTED;
1479 case ACC.ROLE_TABFOLDER: return COM.ROLE_SYSTEM_PAGETABLIST; 1324 case ACC.ROLE_TABFOLDER: return COM.ROLE_SYSTEM_PAGETABLIST;
1480 case ACC.ROLE_TABITEM: return COM.ROLE_SYSTEM_PAGETAB; 1325 case ACC.ROLE_TABITEM: return COM.ROLE_SYSTEM_PAGETAB;
1481 case ACC.ROLE_PROGRESSBAR: return COM.ROLE_SYSTEM_PROGRESSBAR; 1326 case ACC.ROLE_PROGRESSBAR: return COM.ROLE_SYSTEM_PROGRESSBAR;
1482 case ACC.ROLE_SLIDER: return COM.ROLE_SYSTEM_SLIDER; 1327 case ACC.ROLE_SLIDER: return COM.ROLE_SYSTEM_SLIDER;
1483 case ACC.ROLE_LINK: return COM.ROLE_SYSTEM_LINK; 1328 case ACC.ROLE_LINK: return COM.ROLE_SYSTEM_LINK;
1329 default:
1484 } 1330 }
1485 return COM.ROLE_SYSTEM_CLIENT; 1331 return COM.ROLE_SYSTEM_CLIENT;
1486 } 1332 }
1487 1333
1488 int osToRole(int osRole) { 1334 int osToRole(int osRole) {
1514 case COM.ROLE_SYSTEM_PAGETABLIST: return ACC.ROLE_TABFOLDER; 1360 case COM.ROLE_SYSTEM_PAGETABLIST: return ACC.ROLE_TABFOLDER;
1515 case COM.ROLE_SYSTEM_PAGETAB: return ACC.ROLE_TABITEM; 1361 case COM.ROLE_SYSTEM_PAGETAB: return ACC.ROLE_TABITEM;
1516 case COM.ROLE_SYSTEM_PROGRESSBAR: return ACC.ROLE_PROGRESSBAR; 1362 case COM.ROLE_SYSTEM_PROGRESSBAR: return ACC.ROLE_PROGRESSBAR;
1517 case COM.ROLE_SYSTEM_SLIDER: return ACC.ROLE_SLIDER; 1363 case COM.ROLE_SYSTEM_SLIDER: return ACC.ROLE_SLIDER;
1518 case COM.ROLE_SYSTEM_LINK: return ACC.ROLE_LINK; 1364 case COM.ROLE_SYSTEM_LINK: return ACC.ROLE_LINK;
1365 default:
1519 } 1366 }
1520 return ACC.ROLE_CLIENT_AREA; 1367 return ACC.ROLE_CLIENT_AREA;
1521 } 1368 }
1522 1369
1523 /* checkWidget was copied from Widget, and rewritten to work in this package */ 1370 /* checkWidget was copied from Widget, and rewritten to work in this package */
1525 if (!isValidThread ()) DWT.error (DWT.ERROR_THREAD_INVALID_ACCESS); 1372 if (!isValidThread ()) DWT.error (DWT.ERROR_THREAD_INVALID_ACCESS);
1526 if (control.isDisposed ()) DWT.error (DWT.ERROR_WIDGET_DISPOSED); 1373 if (control.isDisposed ()) DWT.error (DWT.ERROR_WIDGET_DISPOSED);
1527 } 1374 }
1528 1375
1529 /* isValidThread was copied from Widget, and rewritten to work in this package */ 1376 /* isValidThread was copied from Widget, and rewritten to work in this package */
1530 bool isValidThread () { 1377 WINBOOL isValidThread () {
1531 return control.getDisplay ().getThread () is Thread.currentThread (); 1378 return control.getDisplay ().getThread () is Thread.getThis ();
1532 } 1379 }
1533 } 1380 }
1534 ++/ 1381
1382 class _IAccessibleImpl : IAccessible {
1383
1384 Accessible parent;
1385 this(Accessible p) { parent = p; }
1386 extern (Windows):
1387 // interface of IUnknown
1388 HRESULT QueryInterface(REFIID riid, void ** ppvObject) { return parent.QueryInterface(riid, ppvObject); }
1389 ULONG AddRef() { return parent.AddRef(); }
1390 ULONG Release() { return parent.Release(); }
1391
1392 // interface of IDispatch
1393 HRESULT GetTypeInfoCount(UINT * pctinfo) { return COM.E_NOTIMPL; }
1394 HRESULT GetTypeInfo(UINT iTInfo, LCID lcid, ITypeInfo * ppTInfo) { return COM.E_NOTIMPL; }
1395 HRESULT GetIDsOfNames(REFIID riid, LPOLESTR * rgszNames, UINT cNames, LCID lcid, DISPID * rgDispId) { return COM.E_NOTIMPL; }
1396 HRESULT Invoke(DISPID dispIdMember,REFIID riid,LCID lcid,WORD wFlags,DISPPARAMS* pDispParams,VARIANT* pVarResult,EXCEPINFO* pExcepInfo,UINT* puArgErr) { return COM.E_NOTIMPL; }
1397
1398 // interface of IAccessible
1399 HRESULT get_accParent(LPDISPATCH * ppdispParent) { return parent.get_accParent(ppdispParent); }
1400 HRESULT get_accChildCount(LONG* pcountChildren) { return parent.get_accChildCount(pcountChildren); }
1401 HRESULT get_accChild(VARIANT varChildID, LPDISPATCH* ppdispChild) {
1402 return parent.get_accChild(varChildID, ppdispChild);
1403 }
1404 HRESULT get_accName(VARIANT varID, BSTR* pszName) {
1405 return parent.get_accName(varID, pszName);
1406 }
1407 HRESULT get_accValue(VARIANT varID, BSTR* pszValue) {
1408 return parent.get_accValue(varID, pszValue);
1409 }
1410 HRESULT get_accDescription(VARIANT varID,BSTR* pszDescription) {
1411 return parent.get_accDescription(varID, pszDescription);
1412 }
1413 HRESULT get_accRole(VARIANT varID, VARIANT* pvarRole) {
1414 return parent.get_accRole(varID, pvarRole);
1415 }
1416 HRESULT get_accState(VARIANT varID, VARIANT* pvarState) {
1417 return parent.get_accState(varID, pvarState);
1418 }
1419 HRESULT get_accHelp(VARIANT varID, BSTR* pszHelp) {
1420 return parent.get_accHelp(varID, pszHelp);
1421 }
1422 HRESULT get_accHelpTopic(BSTR* pszHelpFile, VARIANT varChild, LONG* pidTopic) {
1423 return parent.get_accHelpTopic(pszHelpFile, varChild, pidTopic);
1424 }
1425 HRESULT get_accKeyboardShortcut(VARIANT varID, BSTR* pszKeyboardShortcut) {
1426 return parent.get_accKeyboardShortcut(varID, pszKeyboardShortcut);
1427 }
1428 HRESULT get_accFocus(VARIANT* pvarID) { return parent.get_accFocus(pvarID); }
1429 HRESULT get_accSelection(VARIANT* pvarChildren) { return parent.get_accSelection(pvarChildren); }
1430 HRESULT get_accDefaultAction(VARIANT varID,BSTR* pszDefaultAction) {
1431 return parent.get_accDefaultAction(varID, pszDefaultAction);
1432 }
1433 HRESULT accSelect(LONG flagsSelect, VARIANT varID) {
1434 return parent.accSelect(flagsSelect, varID);
1435 }
1436 HRESULT accLocation(LONG* pxLeft, LONG* pyTop, LONG* pcxWidth, LONG* pcyHeight, VARIANT varID) {
1437 return parent.accLocation(pxLeft, pyTop, pcxWidth, pcyHeight, varID);
1438 }
1439 HRESULT accNavigate(LONG navDir, VARIANT varStart, VARIANT* pvarEnd) {
1440 return parent.accNavigate(navDir, varStart, pvarEnd);
1441 }
1442 HRESULT accHitTest(LONG xLeft, LONG yTop, VARIANT* pvarID) {
1443 return parent.accHitTest(xLeft, yTop, pvarID);
1444 }
1445 HRESULT accDoDefaultAction(VARIANT varID) {
1446 return parent.accDoDefaultAction(varID);
1447 }
1448 HRESULT put_accName(VARIANT varID, BSTR* szName) {
1449 return parent.put_accName(varID, szName);
1450 }
1451 HRESULT put_accValue(VARIANT varID, BSTR* szValue) {
1452 return parent.put_accValue(varID, szValue);
1453 }
1454 }
1455
1456 class _IEnumVARIANTImpl : IEnumVARIANT {
1457
1458 Accessible parent;
1459 this(Accessible a) { parent = a; }
1460 extern (Windows):
1461 // interface of IUnknown
1462 HRESULT QueryInterface(REFIID riid, void ** ppvObject) { return parent.QueryInterface(riid, ppvObject); }
1463 ULONG AddRef() { return parent.AddRef(); }
1464 ULONG Release() { return parent.Release(); }
1465
1466 // interface of IEnumVARIANT
1467 HRESULT Next(ULONG celt, VARIANT *rgvar, ULONG *pceltFetched) { return parent.Next(celt, rgvar, pceltFetched); }
1468 HRESULT Skip(ULONG celt) { return parent.Skip(celt); }
1469 HRESULT Reset() { return parent.Reset(); }
1470 HRESULT Clone(LPENUMVARIANT * ppenum) { return COM.E_NOTIMPL;}
1471 }
1472