Changeset 134:fa7d7d66b9ed
- Timestamp:
- 02/12/08 21:22:44 (10 months ago)
- Files:
-
- dwt/accessibility/Accessible.d (modified) (59 diffs)
- dwt/internal/ole/win32/COM.d (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
dwt/accessibility/Accessible.d
r77 r134 13 13 module dwt.accessibility.Accessible; 14 14 15 import dwt.widgets.Control;16 //PORTING_TYPE17 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 15 import dwt.DWT; 97 16 import dwt.DWTException; 98 17 import dwt.internal.ole.win32.COM; 99 import dwt.internal.ole.win32.COMObject; 100 import dwt.internal.ole.win32.GUID; 101 import dwt.internal.ole.win32.IAccessible; 102 import dwt.internal.ole.win32.IEnumVARIANT; 103 import dwt.internal.ole.win32.VARIANT; 18 import dwt.internal.ole.win32.OAIDL; 19 import dwt.internal.ole.win32.ifs; 20 import dwt.internal.ole.win32.extras; 104 21 import dwt.internal.win32.OS; 105 import dwt.internal. win32.TVITEM;22 import dwt.internal.DWTEventListener; 106 23 import dwt.ole.win32.OLE; 24 import dwt.ole.win32.Variant; 107 25 import dwt.widgets.Control; 108 26 import dwt.widgets.Table; … … 111 29 import dwt.widgets.TreeItem; 112 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 /** … … 135 64 public class Accessible { 136 65 int refCount = 0, enumIndex = 0; 137 COMObject objIAccessible, objIEnumVARIANT; 66 _IAccessibleImpl objIAccessible; 67 _IEnumVARIANTImpl objIEnumVARIANT; 138 68 IAccessible iaccessible; 139 Vector accessibleListeners = new Vector();140 Vector accessibleControlListeners = new Vector();141 Vector textListeners = new Vector ();69 DWTEventListener[] accessibleListeners; 70 DWTEventListener[] accessibleControlListeners; 71 DWTEventListener[] textListeners; 142 72 Object[] variants; 143 73 Control control; 144 74 145 Accessible(Control control) {75 this(Control control) { 146 76 this.control = control; 147 77 int /*long*/[] ppvObject = new int /*long*/[1]; … … 149 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 82 /* The object needs to be checked, because if the CreateStdAccessibleObject() 153 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 86 if (result !is COM.S_OK) OLE.error(OLE.ERROR_CANNOT_CREATE_OBJECT, result); 157 iaccessible = new IAccessible(ppvObject[0]); 158 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}) { 160 public int /*long*/ method0(int /*long*/[] args) {return QueryInterface(args[0], args[1]);} 161 public int /*long*/ method1(int /*long*/[] args) {return AddRef();} 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 87 88 objIAccessible = new _IAccessibleImpl(this); 89 90 //PORTING_FIXME: i don't understand this... 91 /+ 190 92 int /*long*/ ppVtable = objIAccessible.ppVtable; 191 93 int /*long*/[] pVtable = new int /*long*/[1]; … … 210 112 funcs[27] = COM.put_accValue_CALLBACK(funcs[27]); 211 113 COM.MoveMemory(pVtable[0], funcs, OS.PTR_SIZEOF * funcs.length); 212 213 objIEnumVARIANT = new COMObject(new int[] {2,0,0,3,1,0,1}) { 214 public int /*long*/ method0(int /*long*/[] args) {return QueryInterface(args[0], args[1]);} 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 }; 114 +/ 115 116 objIEnumVARIANT = new _IEnumVARIANTImpl(this) ; 222 117 AddRef(); 223 118 } … … 263 158 public void addAccessibleListener(AccessibleListener listener) { 264 159 checkWidget(); 265 if (listener is null) DWT.error( DWT.ERROR_NULL_ARGUMENT);266 accessibleListeners .addElement(listener);160 if (listener is null) DWT.error(__FILE__, __LINE__, DWT.ERROR_NULL_ARGUMENT); 161 accessibleListeners ~= listener; 267 162 } 268 163 … … 290 185 public void addAccessibleControlListener(AccessibleControlListener listener) { 291 186 checkWidget(); 292 if (listener is null) DWT.error( DWT.ERROR_NULL_ARGUMENT);293 accessibleControlListeners .addElement(listener);187 if (listener is null) DWT.error(__FILE__, __LINE__, DWT.ERROR_NULL_ARGUMENT); 188 accessibleControlListeners ~= listener; 294 189 } 295 190 … … 320 215 checkWidget (); 321 216 if (listener is null) DWT.error (DWT.ERROR_NULL_ARGUMENT); 322 textListeners .addElement (listener);217 textListeners ~= listener; 323 218 } 324 219 … … 363 258 public int /*long*/ internal_WM_GETOBJECT (int /*long*/ wParam, int /*long*/ lParam) { 364 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 261 /* LresultFromObject([in] riid, [in] wParam, [in] pAcc) 367 262 * The argument pAcc is owned by the caller so reference count does not 368 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 267 return 0; … … 394 289 public void removeAccessibleListener(AccessibleListener listener) { 395 290 checkWidget(); 396 if (listener is null) DWT.error( DWT.ERROR_NULL_ARGUMENT);397 accessibleListeners.remove Element(listener);291 if (listener is null) DWT.error(__FILE__, __LINE__, DWT.ERROR_NULL_ARGUMENT); 292 accessibleListeners.remove(listener); 398 293 } 399 294 … … 419 314 public void removeAccessibleControlListener(AccessibleControlListener listener) { 420 315 checkWidget(); 421 if (listener is null) DWT.error( DWT.ERROR_NULL_ARGUMENT);422 accessibleControlListeners.remove Element(listener);316 if (listener is null) DWT.error(__FILE__, __LINE__, DWT.ERROR_NULL_ARGUMENT); 317 accessibleControlListeners.remove(listener); 423 318 } 424 319 … … 447 342 checkWidget (); 448 343 if (listener is null) DWT.error (DWT.ERROR_NULL_ARGUMENT); 449 textListeners.remove Element(listener);344 textListeners.remove (listener); 450 345 } 451 346 … … 544 439 * must be incremented before returning. Caller is responsible for releasing ppvObject. 545 440 */ 546 int QueryInterface(int /*long*/ iid, int /*long*/ ppvObject) { 547 if (iaccessible is null) return COM.CO_E_OBJNOTCONNECTED; 548 GUID guid = new GUID(); 549 COM.MoveMemory(guid, iid, GUID.sizeof); 550 551 if (COM.IsEqualGUID(guid, COM.IIDIUnknown)) { 552 COM.MoveMemory(ppvObject, new int /*long*/[] { objIAccessible.getAddress()}, OS.PTR_SIZEOF); 441 HRESULT QueryInterface(REFIID riid, void** ppvObject) { 442 if (iaccessible is null) return COM.CO_E_OBJNOTCONNECTED; 443 444 if (COM.IsEqualGUID(riid, &COM.IIDIUnknown)) { 445 *ppvObject = cast(void*)cast(IUnknown) objIAccessible; 553 446 AddRef(); 554 447 return COM.S_OK; 555 448 } 556 449 557 if (COM.IsEqualGUID( guid,COM.IIDIDispatch)) {558 COM.MoveMemory(ppvObject, new int /*long*/[] { objIAccessible.getAddress()}, OS.PTR_SIZEOF);450 if (COM.IsEqualGUID(riid, &COM.IIDIDispatch)) { 451 *ppvObject = cast(void*)cast(IDispatch) objIAccessible; 559 452 AddRef(); 560 453 return COM.S_OK; 561 454 } 562 455 563 if (COM.IsEqualGUID( guid,COM.IIDIAccessible)) {564 COM.MoveMemory(ppvObject, new int /*long*/[] { objIAccessible.getAddress()}, OS.PTR_SIZEOF);456 if (COM.IsEqualGUID(riid, &COM.IIDIAccessible)) { 457 *ppvObject = cast(void*)cast(IAccessible) objIAccessible; 565 458 AddRef(); 566 459 return COM.S_OK; 567 460 } 568 461 569 if (COM.IsEqualGUID( guid,COM.IIDIEnumVARIANT)) {570 COM.MoveMemory(ppvObject, new int /*long*/[] { objIEnumVARIANT.getAddress()}, OS.PTR_SIZEOF);462 if (COM.IsEqualGUID(riid, &COM.IIDIEnumVARIANT)) { 463 *ppvObject = cast(void*)cast(IEnumVARIANT) objIEnumVARIANT; 571 464 AddRef(); 572 465 enumIndex = 0; … … 574 467 } 575 468 576 int /*long*/[] ppv = new int /*long*/[1]; 577 int result = iaccessible.QueryInterface(guid, ppv); 578 COM.MoveMemory(ppvObject, ppv, OS.PTR_SIZEOF); 469 HRESULT result = iaccessible.QueryInterface(riid, ppvObject); 579 470 return result; 580 471 } 581 472 582 intAddRef() {473 ULONG AddRef() { 583 474 refCount++; 584 475 return refCount; 585 476 } 586 477 587 intRelease() {478 ULONG Release() { 588 479 refCount--; 589 480 590 481 if (refCount is 0) { 591 if (objIAccessible !is null)592 objIAccessible.dispose();593 482 objIAccessible = null; 594 595 if (objIEnumVARIANT !is null)596 objIEnumVARIANT.dispose();597 483 objIEnumVARIANT = null; 598 484 } … … 600 486 } 601 487 602 int accDoDefaultAction(int /*long*/variant) {488 HRESULT accDoDefaultAction(VARIANT variant) { 603 489 if (iaccessible is null) return COM.CO_E_OBJNOTCONNECTED; 604 490 // Currently, we don't let the application override this. Forward to the proxy. … … 608 494 } 609 495 610 int accHitTest(int xLeft, int yTop, int /*long*/pvarChild) {611 if (iaccessible is null) return COM.CO_E_OBJNOTCONNECTED; 612 if (accessibleControlListeners. size()is 0) {496 HRESULT accHitTest(LONG xLeft, LONG yTop, VARIANT* pvarChild) { 497 if (iaccessible is null) return COM.CO_E_OBJNOTCONNECTED; 498 if (accessibleControlListeners.length is 0) { 613 499 return iaccessible.accHitTest(xLeft, yTop, pvarChild); 614 500 } … … 618 504 event.x = xLeft; 619 505 event.y = yTop; 620 for (int i = 0; i < accessibleControlListeners. size(); i++) {621 AccessibleControlListener listener = (AccessibleControlListener) accessibleControlListeners.elementAt(i);506 for (int i = 0; i < accessibleControlListeners.length; i++) { 507 AccessibleControlListener listener = cast(AccessibleControlListener) accessibleControlListeners[i]; 622 508 listener.getChildAtPoint(event); 623 509 } … … 626 512 return iaccessible.accHitTest(xLeft, yTop, pvarChild); 627 513 } 628 COM.MoveMemory(pvarChild, new short[] { COM.VT_I4 }, 2);629 COM.MoveMemory(pvarChild + 8, new int[] { childIDToOs(childID) }, 4);630 return COM.S_OK; 631 } 632 633 int accLocation(int /*long*/ pxLeft, int /*long*/ pyTop, int /*long*/ pcxWidth, int /*long*/ pcyHeight, int /*long*/variant) {634 if (iaccessible is null) return COM.CO_E_OBJNOTCONNECTED; 635 VARIANT v = new VARIANT();636 COM.MoveMemory(v, variant, VARIANT.sizeof);514 pvarChild.vt = COM.VT_I4; 515 pvarChild.lVal = childIDToOs(childID); 516 return COM.S_OK; 517 } 518 519 HRESULT accLocation(LONG* pxLeft, LONG* pyTop, LONG* pcxWidth, LONG* pcyHeight, VARIANT variant) { 520 if (iaccessible is null) return COM.CO_E_OBJNOTCONNECTED; 521 VARIANT* v = &variant; 522 //COM.MoveMemory(v, variant, VARIANT.sizeof); 637 523 if ((v.vt & 0xFFFF) !is COM.VT_I4) return COM.E_INVALIDARG; 638 524 … … 641 527 int code = iaccessible.accLocation(pxLeft, pyTop, pcxWidth, pcyHeight, variant); 642 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 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];646 COM.MoveMemory(pLeft , pxLeft, 4);647 COM.MoveMemory(pTop , pyTop, 4);648 COM.MoveMemory(pWidth , pcxWidth, 4);649 COM.MoveMemory(pHeight , pcyHeight, 4);531 int[1] pLeft, pTop, pWidth, pHeight; 532 COM.MoveMemory(pLeft.ptr, pxLeft, 4); 533 COM.MoveMemory(pTop.ptr, pyTop, 4); 534 COM.MoveMemory(pWidth.ptr, pcxWidth, 4); 535 COM.MoveMemory(pHeight.ptr, pcyHeight, 4); 650 536 osLeft = pLeft[0]; osTop = pTop[0]; osWidth = pWidth[0]; osHeight = pHeight[0]; 651 537 } 652 538 653 539 AccessibleControlEvent event = new AccessibleControlEvent(this); 654 event.childID = osToChildID( (int)/*64*/v.lVal);540 event.childID = osToChildID(cast(int)/*64*/v.lVal); 655 541 event.x = osLeft; 656 542 event.y = osTop; 657 543 event.width = osWidth; 658 544 event.height = osHeight; 659 for (int i = 0; i < accessibleControlListeners. size(); i++) {660 AccessibleControlListener listener = (AccessibleControlListener) accessibleControlListeners.elementAt(i);545 for (int i = 0; i < accessibleControlListeners.length; i++) { 546 AccessibleControlListener listener = cast(AccessibleControlListener) accessibleControlListeners[i]; 661 547 listener.getLocation(event); 662 548 } 663 OS.MoveMemory(pxLeft, new int[] { event.x }, 4);664 OS.MoveMemory(pyTop, new int[] { event.y }, 4);665 OS.MoveMemory(pcxWidth, new int[] { event.width }, 4);666 OS.MoveMemory(pcyHeight, new int[] { event.height }, 4);667 return COM.S_OK; 668 } 669 670 int accNavigate(int navDir, int /*long*/ variant, int /*long*/pvarEndUpAt) {549 OS.MoveMemory(pxLeft, &event.x, 4); 550 OS.MoveMemory(pyTop, &event.y, 4); 551 OS.MoveMemory(pcxWidth, &event.width, 4); 552 OS.MoveMemory(pcyHeight, &event.height, 4); 553 return COM.S_OK; 554 } 555 556 HRESULT accNavigate(LONG navDir, VARIANT variant, VARIANT* pvarEndUpAt) { 671 557 if (iaccessible is null) return COM.CO_E_OBJNOTCONNECTED; 672 558 // Currently, we don't let the application override this. Forward to the proxy. … … 676 562 } 677 563 678 int accSelect(int flagsSelect, int /*long*/variant) {564 HRESULT accSelect(LONG flagsSelect, VARIANT variant) { 679 565 if (iaccessible is null) return COM.CO_E_OBJNOTCONNECTED; 680 566 // Currently, we don't let the application override this. Forward to the proxy. … … 688 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) {691 if (iaccessible is null) return COM.CO_E_OBJNOTCONNECTED; 692 VARIANT v = new VARIANT();693 COM.MoveMemory(v, variant, VARIANT.sizeof);576 HRESULT get_accChild(VARIANT variant, LPDISPATCH* ppdispChild) { 577 if (iaccessible is null) return COM.CO_E_OBJNOTCONNECTED; 578 VARIANT* v = &variant; 579 //COM.MoveMemory(v, variant, VARIANT.sizeof); 694 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 582 int code = iaccessible.get_accChild(variant, ppdispChild); 697 583 if (code is COM.E_INVALIDARG) code = COM.S_FALSE; // proxy doesn't know about app childID … … 700 586 701 587 AccessibleControlEvent event = new AccessibleControlEvent(this); 702 event.childID = osToChildID( (int)/*64*/v.lVal);703 for (int i = 0; i < accessibleControlListeners. size(); i++) {704 AccessibleControlListener listener = (AccessibleControlListener) accessibleControlListeners.elementAt(i);588 event.childID = osToChildID(cast(int)/*64*/v.lVal); 589 for (int i = 0; i < accessibleControlListeners.length; i++) { 590 AccessibleControlListener listener = cast(AccessibleControlListener) accessibleControlListeners[i]; 705 591 listener.getChild(event); 706 592 } … … 708 594 if (accessible !is null) { 709 595 accessible.AddRef(); 710 COM.MoveMemory(ppdispChild, new int /*long*/[] { accessible.objIAccessible.getAddress() }, OS.PTR_SIZEOF);596 *ppdispChild = accessible.objIAccessible; 711 597 return COM.S_OK; 712 598 } … … 714 600 } 715 601 716 int get_accChildCount(int /*long*/pcountChildren) {602 HRESULT get_accChildCount(LONG* pcountChildren) { 717 603 if (iaccessible is null) return COM.CO_E_OBJNOTCONNECTED; 718 604 … … 720 606 int osChildCount = 0; 721 607 int code = iaccessible.get_accChildCount(pcountChildren); 722 if (accessibleControlListeners. size()is 0) return code;608 if (accessibleControlListeners.length is 0) return code; 723 609 if (code is COM.S_OK) { 724 int[ ] pChildCount = new int[1];725 COM.MoveMemory(pChildCount , pcountChildren, 4);610 int[1] pChildCount; 611 COM.MoveMemory(pChildCount.ptr, pcountChildren, 4); 726 612 osChildCount = pChildCount[0]; 727 613 } … … 730 616 event.childID = ACC.CHILDID_SELF; 731 617 event.detail = osChildCount; 732 for (int i = 0; i < accessibleControlListeners. size(); i++) {733 AccessibleControlListener listener = (AccessibleControlListener) accessibleControlListeners.elementAt(i);618 for (int i = 0; i < accessibleControlListeners.length; i++) { 619 AccessibleControlListener listener = cast(AccessibleControlListener) accessibleControlListeners[i]; 734 620 listener.getChildCount(event); 735 621 } 736 622 737 COM.MoveMemory(pcountChildren, new int[] { event.detail }, 4);738 return COM.S_OK; 739 } 740 741 int get_accDefaultAction(int /*long*/ variant, int /*long*/pszDefaultAction) {742 if (iaccessible is null) return COM.CO_E_OBJNOTCONNECTED; 743 VARIANT v = new VARIANT();744 COM.MoveMemory(v, variant, VARIANT.sizeof);623 *pcountChildren = event.detail; 624 return COM.S_OK; 625 } 626 627 HRESULT get_accDefaultAction(VARIANT variant, BSTR* pszDefaultAction) { 628 if (iaccessible is null) return COM.CO_E_OBJNOTCONNECTED; 629 VARIANT* v = &variant; 630 //COM.MoveMemory(v, variant, VARIANT.sizeof); 745 631 if ((v.vt & 0xFFFF) !is COM.VT_I4) return COM.E_INVALIDARG; 746 632 747 633 /* Get the default defaultAction from the OS. */ 748 StringosDefaultAction = null;634 char[] osDefaultAction = null; 749 635 int code = iaccessible.get_accDefaultAction(variant, pszDefaultAction); 750 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 638 if (code is COM.S_OK) { 753 int /*long*/[] pDefaultAction = new int /*long*/[1]; 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 } 639 osDefaultAction = BSTRToStr( *pszDefaultAction, true ); 761 640 } 762 641 763 642 AccessibleControlEvent event = new AccessibleControlEvent(this); 764 event.childID = osToChildID( (int)/*64*/v.lVal);643 event.childID = osToChildID(cast(int)/*64*/v.lVal); 765 644 event.result = osDefaultAction; 766 for (int i = 0; i < accessibleControlListeners. size(); i++) {767 AccessibleControlListener listener = (AccessibleControlListener) accessibleControlListeners.elementAt(i);645 for (int i = 0; i < accessibleControlListeners.length; i++) { 646 AccessibleControlListener listener = cast(AccessibleControlListener) accessibleControlListeners[i]; 768 647 listener.getDefaultAction(event); 769 648 } 770 649 if (event.result is null) return code; 771 char[] data = (event.result + "\0").toCharArray(); 772 int /*long*/ ptr = COM.SysAllocString(data); 773 COM.MoveMemory(pszDefaultAction, new int /*long*/[] { ptr }, OS.PTR_SIZEOF); 774 return COM.S_OK; 775 } 776 777 int get_accDescription(int /*long*/ variant, int /*long*/ pszDescription) { 778 if (iaccessible is null) return COM.CO_E_OBJNOTCONNECTED; 779 VARIANT v = new VARIANT(); 780 COM.MoveMemory(v, variant, VARIANT.sizeof); 650 auto ptr = COM.SysAllocString(StrToWCHARz(event.result)); 651 *pszDefaultAction = ptr; 652 return COM.S_OK; 653 } 654 655 HRESULT get_accDescription(VARIANT variant, BSTR* pszDescription) { 656 if (iaccessible is null) return COM.CO_E_OBJNOTCONNECTED; 657 VARIANT* v = &variant; 658 //COM.MoveMemory(v, variant, VARIANT.sizeof); 781 659 if ((v.vt & 0xFFFF) !is COM.VT_I4) return COM.E_INVALIDARG; 782 660 783 661 /* Get the default description from the OS. */ 784 StringosDescription = null;662 char[] osDescription = null; 785 663 int code = iaccessible.get_accDescription(variant, pszDescription); 786 664 if (code is COM.E_INVALIDARG) code = COM.S_FALSE; // proxy doesn't know about app childID 787 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 667 if (code is COM.S_OK) { 790 int /*long*/[] pDescription = new int /*long*/[1]; 791 COM.MoveMemory(pDescription, pszDescription, OS.PTR_SIZEOF); 792 int size = COM.SysStringByteLen(pDescription[0]); 668 int size = COM.SysStringByteLen(*pszDescription); 793 669 if (size > 0) { 794 char[] buffer = new char[(size + 1) /2]; 795 COM.MoveMemory(buffer, pDescription[0], size); 796 osDescription = new String(buffer); 670 size = (size + 1) /2; 671 osDescription = WCHARzToStr(*pszDescription, size); 797 672 } 798 673 } 799 674 800 675 AccessibleEvent event = new AccessibleEvent(this); 801 event.childID = osToChildID( (int)/*64*/v.lVal);676 event.childID = osToChildID(cast(int)/*64*/v.lVal); 802 677 event.result = osDescription; 803 678 … … 807 682 * header text and tree item text. */ 808 683 if (v.lVal !is COM.CHILDID_SELF) { 809 if (control instanceof Tree) { 810 Tree tree = (Tree) control; 684 if (auto tree = cast(Tree)control ) { 811 685 int columnCount = tree.getColumnCount (); 812 686 if (columnCount > 1) { 813 int /*long*/ hwnd = control.handle, hItem = 0; 687 HWND hwnd = control.handle; 688 int hItem; 814 689 if (OS.COMCTL32_MAJOR >= 6) { 815 690 hItem = OS.SendMessage (hwnd, OS.TVM_MAPACCIDTOHTREEITEM, v.lVal, 0); … … 819 694 Widget widget = tree.getDisplay ().findWidget (hwnd, hItem); 820 695 event.result = ""; 821 if (widget !is null && widget instanceof TreeItem) { 822 TreeItem item = (TreeItem) widget; 696 if (widget !is null ) if( auto item = cast(TreeItem) widget ) { 823 697 for (int i = 1; i < columnCount; i++) { 824 event.result += tree.getColumn(i).getText() + ": " +item.getText(i);825 if (i + 1 < columnCount) event.result += ", ";698 event.result ~= tree.getColumn(i).getText() ~ ": " ~ item.getText(i); 699 if (i + 1 < columnCount) event.result ~= ", "; 826 700 } 827 701 } … … 829 703 } 830 704 } 831 for (int i = 0; i < accessibleListeners. size(); i++) {832 AccessibleListener listener = (AccessibleListener) accessibleListeners.elementAt(i);705 for (int i = 0; i < accessibleListeners.length; i++) { 706 AccessibleListener listener = cast(AccessibleListener) accessibleListeners[i]; 833 707 listener.getDescription(event); 834 708 } 835 709 if (event.result is null) return code; 836 char[] data = (event.result + "\0").toCharArray(); 837 int /*long*/ ptr = COM.SysAllocString(data); 838 COM.MoveMemory(pszDescription, new int /*long*/[] { ptr }, OS.PTR_SIZEOF); 710 auto ptr = COM.SysAllocString(StrToWCHARz(event.result)); 711 *pszDescription = ptr; 839 712 return COM.S_OK; 840 713 } … … 844 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 720 if (iaccessible is null) return COM.CO_E_OBJNOTCONNECTED; 848 721 … … 850 723 int osChild = ACC.CHILDID_NONE; 851 724 int code = iaccessible.get_accFocus(pvarChild); 852 if (accessibleControlListeners. size()is 0) return code;725 if (accessibleControlListeners.length is 0) return code; 853 726 if (code is COM.S_OK) { 854 short[ ] pvt = new short[1];855 COM.MoveMemory(pvt , pvarChild, 2);727 short[1] pvt; 728 COM.MoveMemory(pvt.ptr, pvarChild, 2); 856 729 if (pvt[0] is COM.VT_I4) { 857 int[ ] pChild = new int[1];858 COM.MoveMemory(pChild , pvarChild + 8, 4);730 int[1] pChild; 731 COM.MoveMemory(pChild.ptr, pvarChild + 8, 4); 859 732 osChild = osToChildID(pChild[0]); 860 733 } … … 863 736 AccessibleControlEvent event = new AccessibleControlEvent(this); 864 737 event.childID = osChild; 865 for (int i = 0; i < accessibleControlListeners. size(); i++) {866 AccessibleControlListener listener = (AccessibleControlListener) accessibleControlListeners.elementAt(i);738 for (int i = 0; i < accessibleControlListeners.length; i++) { 739 AccessibleControlListener listener = cast(AccessibleControlListener) accessibleControlListeners[i]; 867 740 listener.getFocus(event); 868 741 } … … 870 743 if (accessible !is null) { 871 744 accessible.AddRef(); 872 COM.MoveMemory(pvarChild, new short[] { COM.VT_DISPATCH }, 2);873 COM.MoveMemory(pvarChild + 8, new int /*long*/[] { accessible.objIAccessible.getAddress() }, OS.PTR_SIZEOF);745 pvarChild.vt = COM.VT_DISPATCH; 746 pvarChild.byRef = cast(void*)cast(IDispatch)accessible.objIAccessible; 874 747 return COM.S_OK; 875 748 } 876 749 int childID = event.childID; 877 750 if (childID is ACC.CHILDID_NONE) { 878 COM.MoveMemory(pvarChild, new short[] { COM.VT_EMPTY }, 2);751 pvarChild.vt = COM.VT_EMPTY; 879 752 return COM.S_FALSE; 880 753 } 881 754 if (childID is ACC.CHILDID_SELF) { 882 755 AddRef(); 883 COM.MoveMemory(pvarChild, new short[] { COM.VT_DISPATCH }, 2);884 COM.MoveMemory(pvarChild + 8, new int /*long*/[] { objIAccessible.getAddress() }, OS.PTR_SIZEOF);756 pvarChild.vt = COM.VT_DISPATCH; 757 pvarChild.byRef = cast(void*)cast(IDispatch)objIAccessible; 885 758 return COM.S_OK; 886 759 } 887 COM.MoveMemory(pvarChild, new short[] { COM.VT_I4 }, 2);888 COM.MoveMemory(pvarChild + 8, new int[] { childIDToOs(childID) }, 4);889 return COM.S_OK; 890 } 891 892 int get_accHelp(int /*long*/ variant, int /*long*/pszHelp) {893 if (iaccessible is null) return COM.CO_E_OBJNOTCONNECTED; 894 VARIANT v = new VARIANT();895 COM.MoveMemory(v, variant, VARIANT.sizeof);760 pvarChild.vt = COM.VT_I4; 761 pvarChild.lVal = childIDToOs(childID); 762 return COM.S_OK; 763 } 764 765 HRESULT get_accHelp(VARIANT variant, BSTR* pszHelp) { 766 if (iaccessible is null) return COM.CO_E_OBJNOTCONNECTED; 767 VARIANT* v = &variant; 768 //COM.MoveMemory(v, variant, VARIANT.sizeof); 896 769 if ((v.vt & 0xFFFF) !is COM.VT_I4) return COM.E_INVALIDARG; 897 770 898 771 /* Get the default help string from the OS. */ 899 StringosHelp = null;772 char[] osHelp = null; 900 773 int code = iaccessible.get_accHelp(variant, pszHelp); 901 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 776 if (code is COM.S_OK) { 904 int /*long*/[] pHelp = new int /*long*/[1]; 905 COM.MoveMemory(pHelp, pszHelp, OS.PTR_SIZEOF); 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 } 777 // the original SysString is clearuped and bstr set to null 778 osHelp = BSTRToStr(*pszHelp, true); 912 779 } 913 780 914 781 AccessibleEvent event = new AccessibleEvent(this); 915 event.childID = osToChildID( (int)/*64*/v.lVal);782 event.childID = osToChildID(cast(int)/*64*/v.lVal); 916 783 event.result = osHelp; 917 for (int i = 0; i < accessibleListeners. size(); i++) {918 AccessibleListener listener = (AccessibleListener) accessibleListeners.elementAt(i);784 for (int i = 0; i < accessibleListeners.length; i++) { 785 AccessibleListener listener = cast(AccessibleListener) accessibleListeners[i]; 919 786 listener.getHelp(event); 920 787 } 921 788 if (event.result is null) return code; 922 char[] data = (event.result + "\0").toCharArray(); 923 int /*long*/ ptr = COM.SysAllocString(data); 924 COM.MoveMemory(pszHelp, new int /*long*/[] { ptr }, OS.PTR_SIZEOF); 925 return COM.S_OK; 926 } 927 928 int get_accHelpTopic(int /*long*/ pszHelpFile, int /*long*/ variant, int /*long*/ pidTopic) { 789 auto ptr = COM.SysAllocString(StrToWCHARz(event.result)); 790 *pszHelp = ptr; 791 return COM.S_OK; 792 } 793 794 HRESULT get_accHelpTopic(BSTR* pszHelpFile, VARIANT variant, LONG* pidTopic) { 929 795 if (iaccessible is null) return COM.CO_E_OBJNOTCONNECTED; 930 796 // Currently, we don't let the application override this. Forward to the proxy. … … 934 800 } 935 801 936 int get_accKeyboardShortcut(int /*long*/ variant, int /*long*/pszKeyboardShortcut) {937 if (iaccessible is null) return COM.CO_E_OBJNOTCONNECTED; 938 VARIANT v = new VARIANT();939 COM.MoveMemory(v, variant, VARIANT.sizeof);802 HRESULT get_accKeyboardShortcut(VARIANT variant, BSTR* pszKeyboardShortcut) { 803 if (iaccessible is null) return COM.CO_E_OBJNOTCONNECTED; 804 VARIANT* v = &variant; 805 //COM.MoveMemory(v, variant, VARIANT.sizeof); 940 806 if ((v.vt & 0xFFFF) !is COM.VT_I4) return COM.E_INVALIDARG; 941 807 942 808 /* Get the default keyboard shortcut from the OS. */ 943 StringosKeyboardShortcut = null;809 char[] osKeyboardShortcut = null; 944 810 int code = iaccessible.get_accKeyboardShortcut(variant, pszKeyboardShortcut); 945 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 813 if (code is COM.S_OK) { 948 int /*long*/[] pKeyboardShortcut = new int /*long*/[1]; 949 COM.MoveMemory(pKeyboardShortcut, pszKeyboardShortcut, OS.PTR_SIZEOF); 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 } 814 // the original SysString is clearuped and bstr set to null 815 osKeyboardShortcut = BSTRToStr(*pszKeyboardShortcut, true); 956 816 } 957 817 958 818 AccessibleEvent event = new AccessibleEvent(this); 959 event.childID = osToChildID( (int)/*64*/v.lVal);819 event.childID = osToChildID(cast(int)/*64*/v.lVal); 960 820 event.result = osKeyboardShortcut; 961 for (int i = 0; i < accessibleListeners. size(); i++) {962 AccessibleListener listener = (AccessibleListener) accessibleListeners.elementAt(i);821 for (int i = 0; i < accessibleListeners.length; i++) { 822 AccessibleListener listener = cast(AccessibleListener) accessibleListeners[i]; 963 823 listener.getKeyboardShortcut(event); 964 824 } 965 825 if (event.result is null) return code; 966 char[] data = (event.result + "\0").toCharArray(); 967 int /*long*/ ptr = COM.SysAllocString(data); 968 COM.MoveMemory(pszKeyboardShortcut, new int /*long*/[] { ptr }, OS.PTR_SIZEOF); 969 return COM.S_OK; 970 } 971 972 int get_accName(int /*long*/ variant, int /*long*/ pszName) { 973 if (iaccessible is null) return COM.CO_E_OBJNOTCONNECTED; 974 VARIANT v = new VARIANT(); 975 COM.MoveMemory(v, variant, VARIANT.sizeof); 826 auto ptr = COM.SysAllocString(StrToWCHARz(event.result)); 827 *pszKeyboardShortcut = ptr; 828 return COM.S_OK; 829 } 830 831 HRESULT get_accName(VARIANT variant, BSTR* pszName) { 832 if (iaccessible is null) return COM.CO_E_OBJNOTCONNECTED; 833 VARIANT* v = &variant; 834 //COM.MoveMemory(v, variant, VARIANT.sizeof); 976 835 if ((v.vt & 0xFFFF) !is COM.VT_I4) return COM.E_INVALIDARG; 977 836 978 837 /* Get the default name from the OS. */ 979 StringosName = null;838 char[] osName = null; 980 839 int code = iaccessible.get_accName(variant, pszName); 981 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 842 if (code is COM.S_OK) { 984 int /*long*/[] pName = new int /*long*/[1]; 985 COM.MoveMemory(pName, pszName, OS.PTR_SIZEOF); 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 } 843 // the original SysString is clearuped and bstr set to null 844 osName = BSTRToStr(*pszName, true); 992 845 } 993 846 994 847 AccessibleEvent event = new AccessibleEvent(this); 995 event.childID = osToChildID( (int)/*64*/v.lVal);848 event.childID = osToChildID(cast(int)/*64*/v.lVal); 996 849 event.result = osName; 997 for (int i = 0; i < accessibleListeners. size(); i++) {998 AccessibleListener listener = (AccessibleListener) accessibleListeners.elementAt(i);850 for (int i = 0; i < accessibleListeners.length; i++) { 851 AccessibleListener listener = cast(AccessibleListener) accessibleListeners[i]; 999 852 listener.getName(event); 1000 853 } 1001 854 if (event.result is nu
