1 11 package org.eclipse.swt.accessibility; 12 13 14 import java.util.Vector ; 15 import org.eclipse.swt.*; 16 import org.eclipse.swt.widgets.*; 17 import org.eclipse.swt.internal.win32.*; 18 import org.eclipse.swt.ole.win32.*; 19 import org.eclipse.swt.internal.ole.win32.*; 20 21 42 public class Accessible { 43 int refCount = 0, enumIndex = 0; 44 COMObject objIAccessible, objIEnumVARIANT; 45 IAccessible iaccessible; 46 Vector accessibleListeners = new Vector (); 47 Vector accessibleControlListeners = new Vector (); 48 Vector textListeners = new Vector (); 49 Object [] variants; 50 Control control; 51 52 Accessible(Control control) { 53 this.control = control; 54 int [] ppvObject = new int [1]; 55 58 int result = (int)COM.CreateStdAccessibleObject(control.handle, COM.OBJID_CLIENT, COM.IIDIAccessible, ppvObject); 59 62 if (ppvObject[0] == 0) return; 63 if (result != COM.S_OK) OLE.error(OLE.ERROR_CANNOT_CREATE_OBJECT, result); 64 iaccessible = new IAccessible(ppvObject[0]); 65 66 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}) { 67 public int method0(int [] args) {return QueryInterface(args[0], args[1]);} 68 public int method1(int [] args) {return AddRef();} 69 public int method2(int [] args) {return Release();} 70 public int method7(int [] args) {return get_accParent(args[0]);} 75 public int method8(int [] args) {return get_accChildCount(args[0]);} 76 public int method9(int [] args) {return get_accChild(args[0], args[1]);} 77 public int method10(int [] args) {return get_accName(args[0], args[1]);} 78 public int method11(int [] args) {return get_accValue(args[0], args[1]);} 79 public int method12(int [] args) {return get_accDescription(args[0], args[1]);} 80 public int method13(int [] args) {return get_accRole(args[0], args[1]);} 81 public int method14(int [] args) {return get_accState(args[0], args[1]);} 82 public int method15(int [] args) {return get_accHelp(args[0], args[1]);} 83 public int method16(int [] args) {return get_accHelpTopic(args[0], args[1], args[2]);} 84 public int method17(int [] args) {return get_accKeyboardShortcut(args[0], args[1]);} 85 public int method18(int [] args) {return get_accFocus(args[0]);} 86 public int method19(int [] args) {return get_accSelection(args[0]);} 87 public int method20(int [] args) {return get_accDefaultAction(args[0], args[1]);} 88 public int method21(int [] args) {return accSelect((int)args[0], args[1]);} 89 public int method22(int [] args) {return accLocation(args[0], args[1], args[2], args[3], args[4]);} 90 public int method23(int [] args) {return accNavigate((int)args[0], args[1], args[2]);} 91 public int method24(int [] args) {return accHitTest((int)args[0], (int)args[1], args[2]);} 92 public int method25(int [] args) {return accDoDefaultAction(args[0]);} 93 public int method26(int [] args) {return put_accName(args[0], args[1]);} 94 public int method27(int [] args) {return put_accValue(args[0], args[1]);} 95 }; 96 97 int ppVtable = objIAccessible.ppVtable; 98 int [] pVtable = new int [1]; 99 COM.MoveMemory(pVtable, ppVtable, OS.PTR_SIZEOF); 100 int [] funcs = new int [28]; 101 COM.MoveMemory(funcs, pVtable[0], OS.PTR_SIZEOF * funcs.length); 102 funcs[9] = COM.get_accChild_CALLBACK(funcs[9]); 103 funcs[10] = COM.get_accName_CALLBACK(funcs[10]); 104 funcs[11] = COM.get_accValue_CALLBACK(funcs[11]); 105 funcs[12] = COM.get_accDescription_CALLBACK(funcs[12]); 106 funcs[13] = COM.get_accRole_CALLBACK(funcs[13]); 107 funcs[14] = COM.get_accState_CALLBACK(funcs[14]); 108 funcs[15] = COM.get_accHelp_CALLBACK(funcs[15]); 109 funcs[16] = COM.get_accHelpTopic_CALLBACK(funcs[16]); 110 funcs[17] = COM.get_accKeyboardShortcut_CALLBACK(funcs[17]); 111 funcs[20] = COM.get_accDefaultAction_CALLBACK(funcs[20]); 112 funcs[21] = COM.accSelect_CALLBACK(funcs[21]); 113 funcs[22] = COM.accLocation_CALLBACK(funcs[22]); 114 funcs[23] = COM.accNavigate_CALLBACK(funcs[23]); 115 funcs[25] = COM.accDoDefaultAction_CALLBACK(funcs[25]); 116 funcs[26] = COM.put_accName_CALLBACK(funcs[26]); 117 funcs[27] = COM.put_accValue_CALLBACK(funcs[27]); 118 COM.MoveMemory(pVtable[0], funcs, OS.PTR_SIZEOF * funcs.length); 119 120 objIEnumVARIANT = new COMObject(new int[] {2,0,0,3,1,0,1}) { 121 public int method0(int [] args) {return QueryInterface(args[0], args[1]);} 122 public int method1(int [] args) {return AddRef();} 123 public int method2(int [] args) {return Release();} 124 public int method3(int [] args) {return Next((int)args[0], args[1], args[2]);} 125 public int method4(int [] args) {return Skip((int)args[0]);} 126 public int method5(int [] args) {return Reset();} 127 public int method6(int [] args) {return Clone(args[0]);} 128 }; 129 AddRef(); 130 } 131 132 145 public static Accessible internal_new_Accessible(Control control) { 146 return new Accessible(control); 147 } 148 149 170 public void addAccessibleListener(AccessibleListener listener) { 171 checkWidget(); 172 if (listener == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); 173 accessibleListeners.addElement(listener); 174 } 175 176 197 public void addAccessibleControlListener(AccessibleControlListener listener) { 198 checkWidget(); 199 if (listener == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); 200 accessibleControlListeners.addElement(listener); 201 } 202 203 226 public void addAccessibleTextListener (AccessibleTextListener listener) { 227 checkWidget (); 228 if (listener == null) SWT.error (SWT.ERROR_NULL_ARGUMENT); 229 textListeners.addElement (listener); 230 } 231 232 238 public Control getControl() { 239 return control; 240 } 241 242 252 public void internal_dispose_Accessible() { 253 if (iaccessible != null) { 254 iaccessible.Release(); 255 } 256 iaccessible = null; 257 Release(); 258 } 259 260 270 public int internal_WM_GETOBJECT (int wParam, int lParam) { 271 if (objIAccessible == null) return 0; 272 if ((int)lParam == COM.OBJID_CLIENT) { 273 277 return COM.LresultFromObject(COM.IIDIAccessible, wParam, objIAccessible.getAddress()); 278 } 279 return 0; 280 } 281 282 301 public void removeAccessibleListener(AccessibleListener listener) { 302 checkWidget(); 303 if (listener == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); 304 accessibleListeners.removeElement(listener); 305 } 306 307 326 public void removeAccessibleControlListener(AccessibleControlListener listener) { 327 checkWidget(); 328 if (listener == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); 329 accessibleControlListeners.removeElement(listener); 330 } 331 332 353 public void removeAccessibleTextListener (AccessibleTextListener listener) { 354 checkWidget (); 355 if (listener == null) SWT.error (SWT.ERROR_NULL_ARGUMENT); 356 textListeners.removeElement (listener); 357 } 358 359 370 public void selectionChanged () { 371 checkWidget(); 372 COM.NotifyWinEvent (COM.EVENT_OBJECT_SELECTIONWITHIN, control.handle, COM.OBJID_CLIENT, COM.CHILDID_SELF); 373 } 374 375 386 public void setFocus(int childID) { 387 checkWidget(); 388 COM.NotifyWinEvent (COM.EVENT_OBJECT_FOCUS, control.handle, COM.OBJID_CLIENT, childIDToOs(childID)); 389 } 390 391 404 public void textCaretMoved (int index) { 405 checkWidget(); 406 COM.NotifyWinEvent (COM.EVENT_OBJECT_LOCATIONCHANGE, control.handle, COM.OBJID_CARET, COM.CHILDID_SELF); 407 } 408 409 428 public void textChanged (int type, int startIndex, int length) { 429 checkWidget(); 430 COM.NotifyWinEvent (COM.EVENT_OBJECT_VALUECHANGE, control.handle, COM.OBJID_CLIENT, COM.CHILDID_SELF); 431 } 432 433 444 public void textSelectionChanged () { 445 checkWidget(); 446 } 448 449 453 int QueryInterface(int iid, int ppvObject) { 454 if (iaccessible == null) return COM.CO_E_OBJNOTCONNECTED; 455 GUID guid = new GUID(); 456 COM.MoveMemory(guid, iid, GUID.sizeof); 457 458 if (COM.IsEqualGUID(guid, COM.IIDIUnknown)) { 459 COM.MoveMemory(ppvObject, new int [] { objIAccessible.getAddress()}, OS.PTR_SIZEOF); 460 AddRef(); 461 return COM.S_OK; 462 } 463 464 if (COM.IsEqualGUID(guid, COM.IIDIDispatch)) { 465 COM.MoveMemory(ppvObject, new int [] { objIAccessible.getAddress()}, OS.PTR_SIZEOF); 466 AddRef(); 467 return COM.S_OK; 468 } 469 470 if (COM.IsEqualGUID(guid, COM.IIDIAccessible)) { 471 COM.MoveMemory(ppvObject, new int [] { objIAccessible.getAddress()}, OS.PTR_SIZEOF); 472 AddRef(); 473 return COM.S_OK; 474 } 475 476 if (COM.IsEqualGUID(guid, COM.IIDIEnumVARIANT)) { 477 COM.MoveMemory(ppvObject, new int [] { objIEnumVARIANT.getAddress()}, OS.PTR_SIZEOF); 478 AddRef(); 479 enumIndex = 0; 480 return COM.S_OK; 481 } 482 483 int [] ppv = new int [1]; 484 int result = iaccessible.QueryInterface(guid, ppv); 485 COM.MoveMemory(ppvObject, ppv, OS.PTR_SIZEOF); 486 return result; 487 } 488 489 int AddRef() { 490 refCount++; 491 return refCount; 492 } 493 494 int Release() { 495 refCount--; 496 497 if (refCount == 0) { 498 if (objIAccessible != null) 499 objIAccessible.dispose(); 500 objIAccessible = null; 501 502 if (objIEnumVARIANT != null) 503 objIEnumVARIANT.dispose(); 504 objIEnumVARIANT = null; 505 } 506 return refCount; 507 } 508 509 int accDoDefaultAction(int variant) { 510 if (iaccessible == null) return COM.CO_E_OBJNOTCONNECTED; 511 int code = iaccessible.accDoDefaultAction(variant); 513 if (code == COM.E_INVALIDARG) code = COM.S_FALSE; return code; 515 } 516 517 int accHitTest(int xLeft, int yTop, int pvarChild) { 518 if (iaccessible == null) return COM.CO_E_OBJNOTCONNECTED; 519 if (accessibleControlListeners.size() == 0) { 520 return iaccessible.accHitTest(xLeft, yTop, pvarChild); 521 } 522 523 AccessibleControlEvent event = new AccessibleControlEvent(this); 524 event.childID = ACC.CHILDID_NONE; 525 event.x = xLeft; 526 event.y = yTop; 527 for (int i = 0; i < accessibleControlListeners.size(); i++) { 528 AccessibleControlListener listener = (AccessibleControlListener) accessibleControlListeners.elementAt(i); 529 listener.getChildAtPoint(event); 530 } 531 int childID = event.childID; 532 if (childID == ACC.CHILDID_NONE) { 533 return iaccessible.accHitTest(xLeft, yTop, pvarChild); 534 } 535 COM.MoveMemory(pvarChild, new short[] { COM.VT_I4 }, 2); 536 COM.MoveMemory(pvarChild + 8, new int[] { childIDToOs(childID) }, 4); 537 return COM.S_OK; 538 } 539 540 int accLocation(int pxLeft, int pyTop, int pcxWidth, int pcyHeight, int variant) { 541 if (iaccessible == null) return COM.CO_E_OBJNOTCONNECTED; 542 VARIANT v = new VARIANT(); 543 COM.MoveMemory(v, variant, VARIANT.sizeof); 544 if ((v.vt & 0xFFFF) != COM.VT_I4) return COM.E_INVALIDARG; 545 546 547 int osLeft = 0, osTop = 0, osWidth = 0, osHeight = 0; 548 int code = iaccessible.accLocation(pxLeft, pyTop, pcxWidth, pcyHeight, variant); 549 if (code == COM.E_INVALIDARG) code = COM.S_FALSE; if (accessibleControlListeners.size() == 0) return code; 551 if (code == COM.S_OK) { 552 int[] pLeft = new int[1], pTop = new int[1], pWidth = new int[1], pHeight = new int[1]; 553 COM.MoveMemory(pLeft, pxLeft, 4); 554 COM.MoveMemory(pTop, pyTop, 4); 555 COM.MoveMemory(pWidth, pcxWidth, 4); 556 COM.MoveMemory(pHeight, pcyHeight, 4); 557 osLeft = pLeft[0]; osTop = pTop[0]; osWidth = pWidth[0]; osHeight = pHeight[0]; 558 } 559 560 AccessibleControlEvent event = new AccessibleControlEvent(this); 561 event.childID = osToChildID((int)v.lVal); 562 event.x = osLeft; 563 event.y = osTop; 564 event.width = osWidth; 565 event.height = osHeight; 566 for (int i = 0; i < accessibleControlListeners.size(); i++) { 567 AccessibleControlListener listener = (AccessibleControlListener) accessibleControlListeners.elementAt(i); 568 listener.getLocation(event); 569 } 570 OS.MoveMemory(pxLeft, new int[] { event.x }, 4); 571 OS.MoveMemory(pyTop, new int[] { event.y }, 4); 572 OS.MoveMemory(pcxWidth, new int[] { event.width }, 4); 573 OS.MoveMemory(pcyHeight, new int[] { event.height }, 4); 574 return COM.S_OK; 575 } 576 577 int accNavigate(int navDir, int variant, int pvarEndUpAt) { 578 if (iaccessible == null) return COM.CO_E_OBJNOTCONNECTED; 579 int code = iaccessible.accNavigate(navDir, variant, pvarEndUpAt); 581 if (code == COM.E_INVALIDARG) code = COM.S_FALSE; return code; 583 } 584 585 int accSelect(int flagsSelect, int variant) { 586 if (iaccessible == null) return COM.CO_E_OBJNOTCONNECTED; 587 int code = iaccessible.accSelect(flagsSelect, variant); 589 if (code == COM.E_INVALIDARG) code = COM.S_FALSE; return code; 591 } 592 593 597 int get_accChild(int variant, int ppdispChild) { 598 if (iaccessible == null) return COM.CO_E_OBJNOTCONNECTED; 599 VARIANT v = new VARIANT(); 600 COM.MoveMemory(v, variant, VARIANT.sizeof); 601 if ((v.vt & 0xFFFF) != COM.VT_I4) return COM.E_INVALIDARG; 602 if (accessibleControlListeners.size() == 0) { 603 int code = iaccessible.get_accChild(variant, ppdispChild); 604 if (code == COM.E_INVALIDARG) code = COM.S_FALSE; return code; 606 } 607 608 AccessibleControlEvent event = new AccessibleControlEvent(this); 609 event.childID = osToChildID((int)v.lVal); 610 for (int i = 0; i < accessibleControlListeners.size(); i++) { 611 AccessibleControlListener listener = (AccessibleControlListener) accessibleControlListeners.elementAt(i); 612 listener.getChild(event); 613 } 614 Accessible accessible = event.accessible; 615 if (accessible != null) { 616 accessible.AddRef(); 617 COM.MoveMemory(ppdispChild, new int [] { accessible.objIAccessible.getAddress() }, OS.PTR_SIZEOF); 618 return COM.S_OK; 619 } 620 return COM.S_FALSE; 621 } 622 623 int get_accChildCount(int pcountChildren) { 624 if (iaccessible == null) return COM.CO_E_OBJNOTCONNECTED; 625 626 627 int osChildCount = 0; 628 int code = iaccessible.get_accChildCount(pcountChildren); 629 if (accessibleControlListeners.size() == 0) return code; 630 if (code == COM.S_OK) { 631 int[] pChildCount = new int[1]; 632 COM.MoveMemory(pChildCount, pcountChildren, 4); 633 osChildCount = pChildCount[0]; 634 } 635 636 AccessibleControlEvent event = new AccessibleControlEvent(this); 637 event.childID = ACC.CHILDID_SELF; 638 event.detail = osChildCount; 639 for (int i = 0; i < accessibleControlListeners.size(); i++) { 640 AccessibleControlListener listener = (AccessibleControlListener) accessibleControlListeners.elementAt(i); 641 listener.getChildCount(event); 642 } 643 644 COM.MoveMemory(pcountChildren, new int[] { event.detail }, 4); 645 return COM.S_OK; 646 } 647 648 int get_accDefaultAction(int variant, int pszDefaultAction) { 649 if (iaccessible == null) return COM.CO_E_OBJNOTCONNECTED; 650 VARIANT v = new VARIANT(); 651 COM.MoveMemory(v, variant, VARIANT.sizeof); 652 if ((v.vt & 0xFFFF) != COM.VT_I4) return COM.E_INVALIDARG; 653 654 655 String osDefaultAction = null; 656 int code = iaccessible.get_accDefaultAction(variant, pszDefaultAction); 657 if (code == COM.E_INVALIDARG) code = COM.S_FALSE; if (accessibleControlListeners.size() == 0) return code; 659 if (code == COM.S_OK) { 660 int [] pDefaultAction = new int [1]; 661 COM.MoveMemory(pDefaultAction, pszDefaultAction, OS.PTR_SIZEOF); 662 int size = COM.SysStringByteLen(pDefaultAction[0]); 663 if (size > 0) { 664 char[] buffer = new char[(size + 1) /2]; 665 COM.MoveMemory(buffer, pDefaultAction[0], size); 666 osDefaultAction = new String (buffer); 667 } 668 } 669 670 AccessibleControlEvent event = new AccessibleControlEvent(this); 671 event.childID = osToChildID((int)v.lVal); 672 event.result = osDefaultAction; 673 for (int i = 0; i < accessibleControlListeners.size(); i++) { 674 AccessibleControlListener listener = (AccessibleControlListener) accessibleControlListeners.elementAt(i); 675 listener.getDefaultAction(event); 676 } 677 if (event.result == null) return code; 678 char[] data = (event.result + "\0").toCharArray(); 679 int ptr = COM.SysAllocString(data); 680 COM.MoveMemory(pszDefaultAction, new int [] { ptr }, OS.PTR_SIZEOF); 681 return COM.S_OK; 682 } 683 684 int get_accDescription(int variant, int pszDescription) { 685 if (iaccessible == null) return COM.CO_E_OBJNOTCONNECTED; 686 VARIANT v = new VARIANT(); 687 COM.MoveMemory(v, variant, VARIANT.sizeof); 688 if ((v.vt & 0xFFFF) != COM.VT_I4) return COM.E_INVALIDARG; 689 690 691 String osDescription = null; 692 int code = iaccessible.get_accDescription(variant, pszDescription); 693 if (code == COM.E_INVALIDARG) code = COM.S_FALSE; if (accessibleListeners.size() == 0 && !(control instanceof Tree)) return code; 696 if (code == COM.S_OK) { 697 int [] pDescription = new int [1]; 698 COM.MoveMemory(pDescription, pszDescription, OS.PTR_SIZEOF); 699 int size = COM.SysStringByteLen(pDescription[0]); 700 if (size > 0) { 701 char[] buffer = new char[(size + 1) /2]; 702 COM.MoveMemory(buffer, pDescription[0], size); 703 osDescription = new String (buffer); 704 } 705 } 706 707 AccessibleEvent event = new AccessibleEvent(this); 708 event.childID = osToChildID((int)v.lVal); 709 event.result = osDescription; 710 711 715 if (v.lVal != COM.CHILDID_SELF) { 716 if (control instanceof Tree) { 717 Tree tree = (Tree) control; 718 int columnCount = tree.getColumnCount (); 719 if (columnCount > 1) { 720 int hwnd = control.handle, hItem = 0; 721 if (OS.COMCTL32_MAJOR >= 6) { 722 hItem = OS.SendMessage (hwnd, OS.TVM_MAPACCIDTOHTREEITEM, v.lVal, 0); 723 } else { 724 hItem = v.lVal; 725 } 726 Widget widget = tree.getDisplay ().findWidget (hwnd, hItem); 727 event.result = ""; 728 if (widget != null && widget instanceof TreeItem) { 729 TreeItem item = (TreeItem) widget; 730 for (int i = 1; i < columnCount; i++) { 731 event.result += tree.getColumn(i).getText() + ": " + item.getText(i); 732 if (i + 1 < columnCount) event.result += ", "; 733 } 734 } 735 } 736 } 737 } 738 for (int i = 0; i < accessibleListeners.size(); i++) { 739 AccessibleListener listener = (AccessibleListener) accessibleListeners.elementAt(i); 740 listener.getDescription(event); 741 } 742 if (event.result == null) return code; 743 char[] data = (event.result + "\0").toCharArray(); 744 int ptr = COM.SysAllocString(data); 745 COM.MoveMemory(pszDescription, new int [] { ptr }, OS.PTR_SIZEOF); 746 return COM.S_OK; 747 } 748 749 753 int get_accFocus(int pvarChild) { 754 if (iaccessible == null) return COM.CO_E_OBJNOTCONNECTED; 755 756 757 int osChild = ACC.CHILDID_NONE; 758 int code = iaccessible.get_accFocus(pvarChild); 759 if (accessibleControlListeners.size() == 0) return code; 760 if (code == COM.S_OK) { 761 short[] pvt = new short[1]; 762 COM.MoveMemory(pvt, pvarChild, 2); 763 if (pvt[0] == COM.VT_I4) { 764 int[] pChild = new int[1]; 765 COM.MoveMemory(pChild, pvarChild + 8, 4); 766 osChild = osToChildID(pChild[0]); 767 } 768 } 769 770 AccessibleControlEvent event = new AccessibleControlEvent(this); 771 event.childID = osChild; 772 for (int i = 0; i < accessibleControlListeners.size(); i++) { 773 AccessibleControlListener listener = (AccessibleControlListener) accessibleControlListeners.elementAt(i); 774 listener.getFocus(event); 775 } 776 Accessible accessible = event.accessible; 777 if (accessible != null) { 778 accessible.AddRef(); 779 COM.MoveMemory(pvarChild, new short[] { COM.VT_DISPATCH }, 2); 780 COM.MoveMemory(pvarChild + 8, new int [] { accessible.objIAccessible.getAddress() }, OS.PTR_SIZEOF); 781 return COM.S_OK; 782 } 783 int childID = event.childID; 784 if (childID == ACC.CHILDID_NONE) { 785 COM.MoveMemory(pvarChild, new short[] { COM.VT_EMPTY }, 2); 786 return COM.S_FALSE; 787 } 788 if (childID == ACC.CHILDID_SELF) { 789 AddRef(); 790 COM.MoveMemory(pvarChild, new short[] { COM.VT_DISPATCH }, 2); 791 COM.MoveMemory(pvarChild + 8, new int [] { objIAccessible.getAddress() }, OS.PTR_SIZEOF); 792 return COM.S_OK; 793 } 794 COM.MoveMemory(pvarChild, new short[] { COM.VT_I4 }, 2); 795 COM.MoveMemory(pvarChild + 8, new int[] { childIDToOs(childID) }, 4); 796 return COM.S_OK; 797 } 798 799 int get_accHelp(int variant, int pszHelp) { 800 if (iaccessible == null) return COM.CO_E_OBJNOTCONNECTED; 801 VARIANT v = new VARIANT(); 802 COM.MoveMemory(v, variant, VARIANT.sizeof); 803 if ((v.vt & 0xFFFF) != COM.VT_I4) return COM.E_INVALIDARG; 804 805 806 String osHelp = null; 807 int code = iaccessible.get_accHelp(variant, pszHelp); 808 if (code == COM.E_INVALIDARG) code = COM.S_FALSE; if (accessibleListeners.size() == 0) return code; 810 if (code == COM.S_OK) { 811 int [] pHelp = new int [1]; 812 COM.MoveMemory(pHelp, pszHelp, OS.PTR_SIZEOF); 813 int size = COM.SysStringByteLen(pHelp[0]); 814 if (size > 0) { 815 char[] buffer = new char[(size + 1) /2]; 816 COM.MoveMemory(buffer, pHelp[0], size); 817 osHelp = new String (buffer); 818 } 819 } 820 821 AccessibleEvent event = new AccessibleEvent(this); 822 event.childID = osToChildID((int)v.lVal); 823 event.result = osHelp; 824 for (int i = 0; i < accessibleListeners.size(); i++) { 825 AccessibleListener listener = (AccessibleListener) accessibleListeners.elementAt(i); 826 listener.getHelp(event); 827 } 828 if (event.result == null) return code; 829 char[] data = (event.result + "\0").toCharArray(); 830 int ptr = COM.SysAllocString(data); 831 COM.MoveMemory(pszHelp, new int [] { ptr }, OS.PTR_SIZEOF); 832 return COM.S_OK; 833 } 834 835 int get_accHelpTopic(int pszHelpFile, int variant, int pidTopic) { 836 if (iaccessible == null) return COM.CO_E_OBJNOTCONNECTED; 837 int code = iaccessible.get_accHelpTopic(pszHelpFile, variant, pidTopic); 839 if (code == COM.E_INVALIDARG) code = COM.S_FALSE; return code; 841 } 842 843 int get_accKeyboardShortcut(int variant, int pszKeyboardShortcut) { 844 if (iaccessible == null) return COM.CO_E_OBJNOTCONNECTED; 845 VARIANT v = new VARIANT(); 846 COM.MoveMemory(v, variant, VARIANT.sizeof); 847 if ((v.vt & 0xFFFF) != COM.VT_I4) return COM.E_INVALIDARG; 848 849 850 String osKeyboardShortcut = null; 851 int code = iaccessible.get_accKeyboardShortcut(variant, pszKeyboardShortcut); 852 if (code == COM.E_INVALIDARG) code = COM.S_FALSE; if (accessibleListeners.size() == 0) return code; 854 if (code == COM.S_OK) { 855 int [] pKeyboardShortcut = new int [1]; 856 COM.MoveMemory(pKeyboardShortcut, pszKeyboardShortcut, OS.PTR_SIZEOF); 857 int size = COM.SysStringByteLen(pKeyboardShortcut[0]); 858 if (size > 0) { 859 char[] buffer = new char[(size + 1) /2]; 860 COM.MoveMemory(buffer, pKeyboardShortcut[0], size); 861 osKeyboardShortcut = new String (buffer); 862 } 863 } 864 865 AccessibleEvent event = new AccessibleEvent(this); 866 event.childID = osToChildID((int)v.lVal); 867 event.result = osKeyboardShortcut; 868 for (int i = 0; i < accessibleListeners.size(); i++) { 869 AccessibleListener listener = (AccessibleListener) accessibleListeners.elementAt(i); 870 listener.getKeyboardShortcut(event); 871 } 872 if (event.result == null) return code; 873 char[] data = (event.result + "\0").toCharArray(); 874 int ptr = COM.SysAllocString(data); 875 COM.MoveMemory(pszKeyboardShortcut, new int [] { ptr }, OS.PTR_SIZEOF); 876 return COM.S_OK; 877 } 878 879 int get_accName(int variant, int pszName) { 880 if (iaccessible == null) return COM.CO_E_OBJNOTCONNECTED; 881 VARIANT v = new VARIANT(); 882 COM.MoveMemory(v, variant, VARIANT.sizeof); 883 if ((v.vt & 0xFFFF) != COM.VT_I4) return COM.E_INVALIDARG; 884 885 886 String osName = null; 887 int code = iaccessible.get_accName(variant, pszName); 888 if (code == COM.E_INVALIDARG) code = COM.S_FALSE; if (accessibleListeners.size() == 0) return code; 890 if (code == COM.S_OK) { 891 int [] pName = new int [1]; 892 COM.MoveMemory(pName, pszName, OS.PTR_SIZEOF); 893 int size = COM.SysStringByteLen(pName[0]); 894 if (size > 0) { 895 char[] buffer = new char[(size + 1) /2]; 896 COM.MoveMemory(buffer, pName[0], size); 897 osName = new String (buffer); 898 } 899 } 900 901 AccessibleEvent event = new AccessibleEvent(this); 902 event.childID = osToChildID((int)v.lVal); 903 event.result = osName; 904 for (int i = 0; i < accessibleListeners.size(); i++) { 905 AccessibleListener listener = (AccessibleListener) accessibleListeners.elementAt(i); 906 listener.getName(event); 907 } 908 if (event.result == null) return code; 909 char[] data = (event.result + "\0").toCharArray(); 910 int ptr = COM.SysAllocString(data); 911 COM.MoveMemory(pszName, new int [] { ptr }, OS.PTR_SIZEOF); 912 return COM.S_OK; 913 } 914 915 919 int get_accParent(int ppdispParent) { 920 if (iaccessible == null) return COM.CO_E_OBJNOTCONNECTED; 921 return iaccessible.get_accParent(ppdispParent); 923 } 924 925 int get_accRole(int variant, int pvarRole) { 926 if (iaccessible == null) return COM.CO_E_OBJNOTCONNECTED; 927 VARIANT v = new VARIANT(); 928 COM.MoveMemory(v, variant, VARIANT.sizeof); 929 if ((v.vt & 0xFFFF) != COM.VT_I4) return COM.E_INVALIDARG; 930 931 932 int osRole = COM.ROLE_SYSTEM_CLIENT; 933 int code = iaccessible.get_accRole(variant, pvarRole); 934 if (code == COM.E_INVALIDARG) code = COM.S_FALSE; if (accessibleControlListeners.size() == 0 && !(control instanceof Tree || control instanceof Table)) return code; 937 if (code == COM.S_OK) { 938 short[] pvt = new short[1]; 939 COM.MoveMemory(pvt, pvarRole, 2); 940 if (pvt[0] == COM.VT_I4) { 941 int[] pRole = new int[1]; 942 COM.MoveMemory(pRole, pvarRole + 8, 4); 943 osRole = pRole[0]; 944 } 945 } 946 947 AccessibleControlEvent event = new AccessibleControlEvent(this); 948 event.childID = osToChildID((int)v.lVal); 949 event.detail = osToRole(osRole); 950 953 if (v.lVal != COM.CHILDID_SELF) { 954 if (control instanceof Tree || control instanceof Table) { 955 if ((control.getStyle() & SWT.CHECK) != 0) event.detail = ACC.ROLE_CHECKBUTTON; 956 } 957 } 958 for (int i = 0; i < accessibleControlListeners.size(); i++) { 959 AccessibleControlListener listener = (AccessibleControlListener) accessibleControlListeners.elementAt(i); 960 listener.getRole(event); 961 } 962 int role = roleToOs(event.detail); 963 COM.MoveMemory(pvarRole, new short[] { COM.VT_I4 }, 2); 964 COM.MoveMemory(pvarRole + 8, new int[] { role }, 4); 965 return COM.S_OK; 966 } 967 968 972 int get_accSelection(int pvarChildren) { 973 if (iaccessible == null) return COM.CO_E_OBJNOTCONNECTED; 974 975 976 int osChild = ACC.CHILDID_NONE; 977 int code = iaccessible.get_accSelection(pvarChildren); 978 if (accessibleControlListeners.size() == 0) return code; 979 if (code == COM.S_OK) { 980 short[] pvt = new short[1]; 981 COM.MoveMemory(pvt, pvarChildren, 2); 982 if (pvt[0] == COM.VT_I4) { 983 int[] pChild = new int[1]; 984 COM.MoveMemory(pChild, pvarChildren + 8, 4); 985 osChild = osToChildID(pChild[0]); 986 } else if (pvt[0] == COM.VT_UNKNOWN) { 987 osChild = ACC.CHILDID_MULTIPLE; 988 989 } 990 } 991 992 AccessibleControlEvent event = new AccessibleControlEvent(this); 993 event.childID = osChild; 994 for (int i = 0; i < accessibleControlListeners.size(); i++) { 995 AccessibleControlListener listener = (AccessibleControlListener) accessibleControlListeners.elementAt(i); 996 listener.getSelection(event); 997 } 998 Accessible accessible = event.accessible; 999 if (accessible != null) { 1000 accessible.AddRef(); 1001 COM.MoveMemory(pvarChildren, new short[] { COM.VT_DISPATCH }, 2); 1002 COM.MoveMemory(pvarChildren + 8, new int [] { accessible.objIAccessible.getAddress() }, OS.PTR_SIZEOF); 1003 return COM.S_OK; 1004 } 1005 int childID = event.childID; 1006 if (childID == ACC.CHILDID_NONE) { 1007 COM.MoveMemory(pvarChildren, new short[] { COM.VT_EMPTY }, 2); 1008 return COM.S_FALSE; 1009 } 1010 if (childID == ACC.CHILDID_MULTIPLE) { 1011 AddRef(); 1012 COM.MoveMemory(pvarChildren, new short[] { COM.VT_UNKNOWN }, 2); 1013 COM.MoveMemory(pvarChildren + 8, new int [] { objIAccessible.getAddress() }, OS.PTR_SIZEOF); 1014 return COM.S_OK; 1015 } 1016 if (childID == ACC.CHILDID_SELF) { 1017 AddRef(); 1018 COM.MoveMemory(pvarChildren, new short[] { COM.VT_DISPATCH }, 2); 1019 COM.MoveMemory(pvarChildren + 8, new int [] { objIAccessible.getAddress() }, OS.PTR_SIZEOF); 1020 return COM.S_OK; 1021 } 1022 COM.MoveMemory(pvarChildren, new short[] { COM.VT_I4 }, 2); 1023 COM.MoveMemory(pvarChildren + 8, new int[] { childIDToOs(childID) }, 4); 1024 return COM.S_OK; 1025 } 1026 1027 int get_accState(int variant, int pvarState) { 1028 if (iaccessible == null) return COM.CO_E_OBJNOTCONNECTED; 1029 VARIANT v = new VARIANT(); 1030 COM.MoveMemory(v, variant, VARIANT.sizeof); 1031 if ((v.vt & 0xFFFF) != COM.VT_I4) return COM.E_INVALIDARG; 1032 1033 1034 int osState = 0; 1035 int code = iaccessible.get_accState(variant, pvarState); 1036 if (code == COM.E_INVALIDARG) code = COM.S_FALSE; if (accessibleControlListeners.size() == 0 && !(control instanceof Tree || control instanceof Table)) return code; 1039 if (code == COM.S_OK) { 1040 short[] pvt = new short[1]; 1041 COM.MoveMemory(pvt, pvarState, 2); 1042 if (pvt[0] == COM.VT_I4) { 1043 int[] pState = new int[1]; 1044 COM.MoveMemory(pState, pvarState + 8, 4); 1045 osState = pState[0]; 1046 } 1047 } 1048 1049 AccessibleControlEvent event = new AccessibleControlEvent(this); 1050 event.childID = osToChildID((int)v.lVal); 1051 event.detail = osToState(osState); 1052 1055 if (v.lVal != COM.CHILDID_SELF) { 1056 if (control instanceof Tree && (control.getStyle() & SWT.CHECK) != 0) { 1057 int hwnd = control.handle; 1058 TVITEM tvItem = new TVITEM (); 1059 tvItem.mask = OS.TVIF_HANDLE | OS.TVIF_STATE; 1060 tvItem.stateMask = OS.TVIS_STATEIMAGEMASK; 1061 if (OS.COMCTL32_MAJOR >= 6) { 1062 tvItem.hItem = OS.SendMessage (hwnd, OS.TVM_MAPACCIDTOHTREEITEM, v.lVal, 0); 1063 } else { 1064 tvItem.hItem = v.lVal; 1065 } 1066 int result = OS.SendMessage (hwnd, OS.TVM_GETITEM, 0, tvItem); 1067 boolean checked = (result != 0) && (((tvItem.state >> 12) & 1) == 0); 1068 if (checked) event.detail |= ACC.STATE_CHECKED; 1069 } else if (control instanceof Table && (control.getStyle() & SWT.CHECK) != 0) { 1070 Table table = (Table) control; 1071 TableItem item = table.getItem(event.childID); 1072 if (item != null) { 1073 if (item.getChecked()) event.detail |= ACC.STATE_CHECKED; 1074 } 1075 } 1076 } 1077 for (int i = 0; i < accessibleControlListeners.size(); i++) { 1078 AccessibleControlListener listener = (AccessibleControlListener) accessibleControlListeners.elementAt(i); 1079 listener.getState(event); 1080 } 1081 int state = stateToOs(event.detail); 1082 COM.MoveMemory(pvarState, new short[] { COM.VT_I4 }, 2); 1083 COM.MoveMemory(pvarState + 8, new int[] { state }, 4); 1084 return COM.S_OK; 1085 } 1086 1087 int get_accValue(int variant, int pszValue) { 1088 if (iaccessible == null) return COM.CO_E_OBJNOTCONNECTED; 1089 VARIANT v = new VARIANT(); 1090 COM.MoveMemory(v, variant, VARIANT.sizeof); 1091 if ((v.vt & 0xFFFF) != COM.VT_I4) return COM.E_INVALIDARG; 1092 1093 1094 String osValue = null; 1095 int code = iaccessible.get_accValue(variant, pszValue); 1096 if (code == COM.E_INVALIDARG) code = COM.S_FALSE; if (accessibleControlListeners.size() == 0) return code; 1098 if (code == COM.S_OK) { 1099 int [] pValue = new int [1]; 1100 COM.MoveMemory(pValue, pszValue, OS.PTR_SIZEOF); 1101 int size = COM.SysStringByteLen(pValue[0]); 1102 if (size > 0) { 1103 char[] buffer = new char[(size + 1) /2]; 1104 COM.MoveMemory(buffer, pValue[0], size); 1105 osValue = new String (buffer); 1106 } 1107 } 1108 1109 AccessibleControlEvent event = new AccessibleControlEvent(this); 1110 event.childID = osToChildID((int)v.lVal); 1111 event.result = osValue; 1112 for (int i = 0; i < accessibleControlListeners.size(); i++) { 1113 AccessibleControlListener listener = (AccessibleControlListener) accessibleControlListeners.elementAt(i); 1114 listener.getValue(event); 1115 } 1116 if (event.result == null) return code; 1117 char[] data = (event.result + "\0").toCharArray(); 1118 int ptr = COM.SysAllocString(data); 1119 COM.MoveMemory(pszValue, new int [] { ptr }, OS.PTR_SIZEOF); 1120 return COM.S_OK; 1121 } 1122 1123 int put_accName(int variant, int szName) { 1124 if (iaccessible == null) return COM.CO_E_OBJNOTCONNECTED; 1126 int code = iaccessible.put_accName(variant, szName); 1128 if (code == COM.E_INVALIDARG) code = COM.S_FALSE; return code; 1130 } 1131 1132 int put_accValue(int variant, int szValue) { 1133 if (iaccessible == null) return COM.CO_E_OBJNOTCONNECTED; 1135 int code = iaccessible.put_accValue(variant, szValue); 1137 if (code == COM.E_INVALIDARG) code = COM.S_FALSE; return code; 1139 } 1140 1141 1142 1148 1149 1153 int Next(int celt, int rgvar, int pceltFetched) { 1154 1157 if (accessibleControlListeners.size() == 0) { 1158 int [] ppvObject = new int [1]; 1159 int code = iaccessible.QueryInterface(COM.IIDIEnumVARIANT, ppvObject); 1160 if (code != COM.S_OK) return code; 1161 IEnumVARIANT ienumvariant = new IEnumVARIANT(ppvObject[0]); 1162 int[] celtFetched = new int[1]; 1163 code = ienumvariant.Next(celt, rgvar, celtFetched); 1164 ienumvariant.Release(); 1165 COM.MoveMemory(pceltFetched, celtFetched, 4); 1166 return code; 1167 } 1168 1169 if (rgvar == 0) return COM.E_INVALIDARG; 1170 if (pceltFetched == 0 && celt != 1) return COM.E_INVALIDARG; 1171 if (enumIndex == 0) { 1172 AccessibleControlEvent event = new AccessibleControlEvent(this); 1173 event.childID = ACC.CHILDID_SELF; 1174 for (int i = 0; i < accessibleControlListeners.size(); i++) { 1175 AccessibleControlListener listener = (AccessibleControlListener) accessibleControlListeners.elementAt(i); 1176 listener.getChildren(event); 1177 } 1178 variants = event.children; 1179 } 1180 Object [] nextItems = null; 1181 if (variants != null && celt >= 1) { 1182 int endIndex = enumIndex + celt - 1; 1183 if (endIndex > (variants.length - 1)) endIndex = variants.length - 1; 1184 if (enumIndex <= endIndex) { 1185 nextItems = new Object [endIndex - enumIndex + 1]; 1186 for (int i = 0; i < nextItems.length; i++) { 1187 Object child = variants[enumIndex]; 1188 if (child instanceof Integer ) { 1189 nextItems[i] = new Integer (childIDToOs(((Integer )child).intValue())); 1190 } else { 1191 nextItems[i] = child; 1192 } 1193 enumIndex++; 1194 } 1195 } 1196 } 1197 if (nextItems != null) { 1198 for (int i = 0; i < nextItems.length; i++) { 1199 Object nextItem = nextItems[i]; 1200 if (nextItem instanceof Integer ) { 1201 int item = ((Integer ) nextItem).intValue(); 1202 COM.MoveMemory(rgvar + i * 16, new short[] { COM.VT_I4 }, 2); 1203 COM.MoveMemory(rgvar + i * 16 + 8, new int[] { item }, 4); 1204 } else { 1205 Accessible accessible = (Accessible) nextItem; 1206 accessible.AddRef(); 1207 COM.MoveMemory(rgvar + i * 16, new short[] { COM.VT_DISPATCH }, 2); 1208 COM.MoveMemory(rgvar + i * 16 + 8, new int [] { accessible.objIAccessible.getAddress() }, OS.PTR_SIZEOF); 1209 } 1210 } 1211 if (pceltFetched != 0) 1212 COM.MoveMemory(pceltFetched, new int[] {nextItems.length}, 4); 1213 if (nextItems.length == celt) return COM.S_OK; 1214 } else { 1215 if (pceltFetched != 0) 1216 COM.MoveMemory(pceltFetched, new int[] {0}, 4); 1217 } 1218 return COM.S_FALSE; 1219 } 1220 1221 1222 int Skip(int celt) { 1223 1226 if (accessibleControlListeners.size() == 0) { 1227 int [] ppvObject = new int [1]; 1228 int code = iaccessible.QueryInterface(COM.IIDIEnumVARIANT, ppvObject); 1229 if (code != COM.S_OK) return code; 1230 IEnumVARIANT ienumvariant = new IEnumVARIANT(ppvObject[0]); 1231 code = ienumvariant.Skip(celt); 1232 ienumvariant.Release(); 1233 return code; 1234 } 1235 1236 if (celt < 1 ) return COM.E_INVALIDARG; 1237 enumIndex += celt; 1238 if (enumIndex > (variants.length - 1)) { 1239 enumIndex = variants.length - 1; 1240 return COM.S_FALSE; 1241 } 1242 return COM.S_OK; 1243 } 1244 1245 1246 int Reset() { 1247 1250 if (accessibleControlListeners.size() == 0) { 1251 int [] ppvObject = new int [1]; 1252 int code = (int)iaccessible.QueryInterface(COM.IIDIEnumVARIANT, ppvObject); 1253 if (code != COM.S_OK) return code; 1254 IEnumVARIANT ienumvariant = new IEnumVARIANT(ppvObject[0]); 1255 code = ienumvariant.Reset(); 1256 ienumvariant.Release(); 1257 return code; 1258 } 1259 1260 enumIndex = 0; 1261 return COM.S_OK; 1262 } 1263 1264 1268 int Clone(int ppEnum) { 1269 1272 if (accessibleControlListeners.size() == 0) { 1273 int [] ppvObject = new int [1]; 1274 int code = iaccessible.QueryInterface(COM.IIDIEnumVARIANT, ppvObject); 1275 if (code != COM.S_OK) return code; 1276 IEnumVARIANT ienumvariant = new IEnumVARIANT(ppvObject[0]); 1277 int[] pEnum = new int[1]; 1278 code = ienumvariant.Clone(pEnum); 1279 ienumvariant.Release(); 1280 COM.MoveMemory(ppEnum, pEnum, 4); 1281 return code; 1282 } 1283 1284 if (ppEnum == 0) return COM.E_INVALIDARG; 1285 COM.MoveMemory(ppEnum, new int [] { objIEnumVARIANT.getAddress()}, OS.PTR_SIZEOF); 1286 AddRef(); 1287 return COM.S_OK; 1288 } 1289 1290 int childIDToOs(int childID) { 1291 if (childID == ACC.CHILDID_SELF) return COM.CHILDID_SELF; 1292 1299 if (!(control instanceof Tree)) return childID + 1; 1300 if (OS.COMCTL32_MAJOR < 6) return childID; 1301 return (int)OS.SendMessage (control.handle, OS.TVM_MAPHTREEITEMTOACCID, childID, 0); 1302 } 1303 1304 int osToChildID(int osChildID) { 1305 if (osChildID == COM.CHILDID_SELF) return ACC.CHILDID_SELF; 1306 1313 if (!(control instanceof Tree)) return osChildID - 1; 1314 if (OS.COMCTL32_MAJOR < 6) return osChildID; 1315 return (int)OS.SendMessage (control.handle, OS.TVM_MAPACCIDTOHTREEITEM, osChildID, 0); 1316 } 1317 1318 int stateToOs(int state) { 1319 int osState = 0; 1320 if ((state & ACC.STATE_SELECTED) != 0) osState |= COM.STATE_SYSTEM_SELECTED; 1321 if ((state & ACC.STATE_SELECTABLE) != 0) osState |= COM.STATE_SYSTEM_SELECTABLE; 1322 if ((state & ACC.STATE_MULTISELECTABLE) != 0) osState |= COM.STATE_SYSTEM_MULTISELECTABLE; 1323 if ((state & ACC.STATE_FOCUSED) != 0) osState |= COM.STATE_SYSTEM_FOCUSED; 1324 if ((state & ACC.STATE_FOCUSABLE) != 0) osState |= COM.STATE_SYSTEM_FOCUSABLE; 1325 if ((state & ACC.STATE_PRESSED) != 0) osState |= COM.STATE_SYSTEM_PRESSED; 1326 if ((state & ACC.STATE_CHECKED) != 0) osState |= COM.STATE_SYSTEM_CHECKED; 1327 if ((state & ACC.STATE_EXPANDED) != 0) osState |= COM.STATE_SYSTEM_EXPANDED; 1328 if ((state & ACC.STATE_COLLAPSED) != 0) osState |= COM.STATE_SYSTEM_COLLAPSED; 1329 if ((state & ACC.STATE_HOTTRACKED) != 0) osState |= COM.STATE_SYSTEM_HOTTRACKED; 1330 if ((state & ACC.STATE_BUSY) != 0) osState |= COM.STATE_SYSTEM_BUSY; 1331 if ((state & ACC.STATE_READONLY) != 0) osState |= COM.STATE_SYSTEM_READONLY; 1332 if ((state & ACC.STATE_INVISIBLE) != 0) osState |= COM.STATE_SYSTEM_INVISIBLE; 1333 if ((state & ACC.STATE_OFFSCREEN) != 0) osState |= COM.STATE_SYSTEM_OFFSCREEN; 1334 if ((state & ACC.STATE_SIZEABLE) != 0) osState |= COM.STATE_SYSTEM_SIZEABLE; 1335 if ((state & ACC.STATE_LINKED) != 0) osState |= COM.STATE_SYSTEM_LINKED; 1336 return osState; 1337 } 1338 1339 int osToState(int osState) { 1340 int state = ACC.STATE_NORMAL; 1341 if ((osState & COM.STATE_SYSTEM_SELECTED) != 0) state |= ACC.STATE_SELECTED; 1342 if ((osState & COM.STATE_SYSTEM_SELECTABLE) != 0) state |= ACC.STATE_SELECTABLE; 1343 if ((osState & COM.STATE_SYSTEM_MULTISELECTABLE) != 0) state |= ACC.STATE_MULTISELECTABLE; 1344 if ((osState & COM.STATE_SYSTEM_FOCUSED) != 0) state |= ACC.STATE_FOCUSED; 1345 if ((osState & COM.STATE_SYSTEM_FOCUSABLE) != 0) state |= ACC.STATE_FOCUSABLE; 1346 if ((osState & COM.STATE_SYSTEM_PRESSED) != 0) state |= ACC.STATE_PRESSED; 1347 if ((osState & COM.STATE_SYSTEM_CHECKED) != 0) state |= ACC.STATE_CHECKED; 1348 if ((osState & COM.STATE_SYSTEM_EXPANDED) != 0) state |= ACC.STATE_EXPANDED; 1349 if ((osState & COM.STATE_SYSTEM_COLLAPSED) != 0) state |= ACC.STATE_COLLAPSED; 1350 if ((osState & COM.STATE_SYSTEM_HOTTRACKED) != 0) state |= ACC.STATE_HOTTRACKED; 1351 if ((osState & COM.STATE_SYSTEM_BUSY) != 0) state |= ACC.STATE_BUSY; 1352 if ((osState & COM.STATE_SYSTEM_READONLY) != 0) state |= ACC.STATE_READONLY; 1353 if ((osState & COM.STATE_SYSTEM_INVISIBLE) != 0) state |= ACC.STATE_INVISIBLE; 1354 if ((osState & COM.STATE_SYSTEM_OFFSCREEN) != 0) state |= ACC.STATE_OFFSCREEN; 1355 if ((osState & COM.STATE_SYSTEM_SIZEABLE) != 0) state |= ACC.STATE_SIZEABLE; 1356 if ((osState & COM.STATE_SYSTEM_LINKED) != 0) state |= ACC.STATE_LINKED; 1357 return state; 1358 } 1359 1360 int roleToOs(int role) { 1361 switch (role) { 1362 case ACC.ROLE_CLIENT_AREA: return COM.ROLE_SYSTEM_CLIENT; 1363 case ACC.ROLE_WINDOW: return COM.ROLE_SYSTEM_WINDOW; 1364 case ACC.ROLE_MENUBAR: return COM.ROLE_SYSTEM_MENUBAR; 1365 case ACC.ROLE_MENU: return COM.ROLE_SYSTEM_MENUPOPUP; 1366 case ACC.ROLE_MENUITEM: return COM.ROLE_SYSTEM_MENUITEM; 1367 case ACC.ROLE_SEPARATOR: return COM.ROLE_SYSTEM_SEPARATOR; 1368 case ACC.ROLE_TOOLTIP: return COM.ROLE_SYSTEM_TOOLTIP; 1369 case ACC.ROLE_SCROLLBAR: return COM.ROLE_SYSTEM_SCROLLBAR; 1370 case ACC.ROLE_DIALOG: return COM.ROLE_SYSTEM_DIALOG; 1371 case ACC.ROLE_LABEL: return COM.ROLE_SYSTEM_STATICTEXT; 1372 case ACC.ROLE_PUSHBUTTON: return COM.ROLE_SYSTEM_PUSHBUTTON; 1373 case ACC.ROLE_CHECKBUTTON: return COM.ROLE_SYSTEM_CHECKBUTTON; 1374 case ACC.ROLE_RADIOBUTTON: return COM.ROLE_SYSTEM_RADIOBUTTON; 1375 case ACC.ROLE_COMBOBOX: return COM.ROLE_SYSTEM_COMBOBOX; 1376 case ACC.ROLE_TEXT: return COM.ROLE_SYSTEM_TEXT; 1377 case ACC.ROLE_TOOLBAR: return COM.ROLE_SYSTEM_TOOLBAR; 1378 case ACC.ROLE_LIST: return COM.ROLE_SYSTEM_LIST; 1379 case ACC.ROLE_LISTITEM: return COM.ROLE_SYSTEM_LISTITEM; 1380 case ACC.ROLE_TABLE: return COM.ROLE_SYSTEM_TABLE; 1381 case ACC.ROLE_TABLECELL: return COM.ROLE_SYSTEM_CELL; 1382 case ACC.ROLE_TABLECOLUMNHEADER: return COM.ROLE_SYSTEM_COLUMNHEADER; 1383 case ACC.ROLE_TABLEROWHEADER: return COM.ROLE_SYSTEM_ROWHEADER; 1384 case ACC.ROLE_TREE: return COM.ROLE_SYSTEM_OUTLINE; 1385 case ACC.ROLE_TREEITEM: return COM.ROLE_SYSTEM_OUTLINEITEM; 1386 case ACC.ROLE_TABFOLDER: return COM.ROLE_SYSTEM_PAGETABLIST; 1387 case ACC.ROLE_TABITEM: return COM.ROLE_SYSTEM_PAGETAB; 1388 case ACC.ROLE_PROGRESSBAR: return COM.ROLE_SYSTEM_PROGRESSBAR; 1389 case ACC.ROLE_SLIDER: return COM.ROLE_SYSTEM_SLIDER; 1390 case ACC.ROLE_LINK: return COM.ROLE_SYSTEM_LINK; 1391 } 1392 return COM.ROLE_SYSTEM_CLIENT; 1393 } 1394 1395 int osToRole(int osRole) { 1396 switch (osRole) { 1397 case COM.ROLE_SYSTEM_CLIENT: return ACC.ROLE_CLIENT_AREA; 1398 case COM.ROLE_SYSTEM_WINDOW: return ACC.ROLE_WINDOW; 1399 case COM.ROLE_SYSTEM_MENUBAR: return ACC.ROLE_MENUBAR; 1400 case COM.ROLE_SYSTEM_MENUPOPUP: return ACC.ROLE_MENU; 1401 case COM.ROLE_SYSTEM_MENUITEM: return ACC.ROLE_MENUITEM; 1402 case COM.ROLE_SYSTEM_SEPARATOR: return ACC.ROLE_SEPARATOR; 1403 case COM.ROLE_SYSTEM_TOOLTIP: return ACC.ROLE_TOOLTIP; 1404 case COM.ROLE_SYSTEM_SCROLLBAR: return ACC.ROLE_SCROLLBAR; 1405 case COM.ROLE_SYSTEM_DIALOG: return ACC.ROLE_DIALOG; 1406 case COM.ROLE_SYSTEM_STATICTEXT: return ACC.ROLE_LABEL; 1407 case COM.ROLE_SYSTEM_PUSHBUTTON: return ACC.ROLE_PUSHBUTTON; 1408 case COM.ROLE_SYSTEM_CHECKBUTTON: return ACC.ROLE_CHECKBUTTON; 1409 case COM.ROLE_SYSTEM_RADIOBUTTON: return ACC.ROLE_RADIOBUTTON; 1410 case COM.ROLE_SYSTEM_COMBOBOX: return ACC.ROLE_COMBOBOX; 1411 case COM.ROLE_SYSTEM_TEXT: return ACC.ROLE_TEXT; 1412 case COM.ROLE_SYSTEM_TOOLBAR: return ACC.ROLE_TOOLBAR; 1413 case COM.ROLE_SYSTEM_LIST: return ACC.ROLE_LIST; 1414 case COM.ROLE_SYSTEM_LISTITEM: return ACC.ROLE_LISTITEM; 1415 case COM.ROLE_SYSTEM_TABLE: return ACC.ROLE_TABLE; 1416 case COM.ROLE_SYSTEM_CELL: return ACC.ROLE_TABLECELL; 1417 case COM.ROLE_SYSTEM_COLUMNHEADER: return ACC.ROLE_TABLECOLUMNHEADER; 1418 case COM.ROLE_SYSTEM_ROWHEADER: return ACC.ROLE_TABLEROWHEADER; 1419 case COM.ROLE_SYSTEM_OUTLINE: return ACC.ROLE_TREE; 1420 case COM.ROLE_SYSTEM_OUTLINEITEM: return ACC.ROLE_TREEITEM; 1421 case COM.ROLE_SYSTEM_PAGETABLIST: return ACC.ROLE_TABFOLDER; 1422 case COM.ROLE_SYSTEM_PAGETAB: return ACC.ROLE_TABITEM; 1423 case COM.ROLE_SYSTEM_PROGRESSBAR: return ACC.ROLE_PROGRESSBAR; 1424 case COM.ROLE_SYSTEM_SLIDER: return ACC.ROLE_SLIDER; 1425 case COM.ROLE_SYSTEM_LINK: return ACC.ROLE_LINK; 1426 } 1427 return ACC.ROLE_CLIENT_AREA; 1428 } 1429 1430 1431 void checkWidget () { 1432 if (!isValidThread ()) SWT.error (SWT.ERROR_THREAD_INVALID_ACCESS); 1433 if (control.isDisposed ()) SWT.error (SWT.ERROR_WIDGET_DISPOSED); 1434 } 1435 1436 1437 boolean isValidThread () { 1438 return control.getDisplay ().getThread () == Thread.currentThread (); 1439 } 1440} 1441 | Popular Tags |