Mercurial > projects > dwt2
comparison org.eclipse.swt.win32.win32.x86/src/org/eclipse/swt/accessibility/Accessible.d @ 11:43904fec5dca
Readded the use of Vector to omit tango.core.Array dependency.
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Fri, 13 Mar 2009 17:44:24 +0100 |
parents | 950d84783eac |
children | 52184e4b815c |
comparison
equal
deleted
inserted
replaced
10:eb8ff453285d | 11:43904fec5dca |
---|---|
35 import org.eclipse.swt.accessibility.AccessibleTextListener; | 35 import org.eclipse.swt.accessibility.AccessibleTextListener; |
36 import org.eclipse.swt.accessibility.AccessibleControlEvent; | 36 import org.eclipse.swt.accessibility.AccessibleControlEvent; |
37 import org.eclipse.swt.accessibility.AccessibleEvent; | 37 import org.eclipse.swt.accessibility.AccessibleEvent; |
38 | 38 |
39 import java.lang.all; | 39 import java.lang.all; |
40 import java.util.Vector; | |
40 import tango.core.Thread; | 41 import tango.core.Thread; |
41 | 42 |
42 /** | 43 /** |
43 * Instances of this class provide a bridge between application | 44 * Instances of this class provide a bridge between application |
44 * code and assistive technology clients. Many platforms provide | 45 * code and assistive technology clients. Many platforms provide |
65 public class Accessible { | 66 public class Accessible { |
66 int refCount = 0, enumIndex = 0; | 67 int refCount = 0, enumIndex = 0; |
67 _IAccessibleImpl objIAccessible; | 68 _IAccessibleImpl objIAccessible; |
68 _IEnumVARIANTImpl objIEnumVARIANT; | 69 _IEnumVARIANTImpl objIEnumVARIANT; |
69 IAccessible iaccessible; | 70 IAccessible iaccessible; |
70 SWTEventListener[] accessibleListeners; | 71 Vector accessibleListeners; |
71 SWTEventListener[] accessibleControlListeners; | 72 Vector accessibleControlListeners; |
72 SWTEventListener[] textListeners; | 73 Vector textListeners; |
73 Object[] variants; | 74 Object[] variants; |
74 Control control; | 75 Control control; |
75 | 76 |
76 this(Control control) { | 77 this(Control control) { |
78 accessibleListeners = new Vector(); | |
79 accessibleControlListeners = new Vector(); | |
80 textListeners = new Vector (); | |
77 this.control = control; | 81 this.control = control; |
78 int /*long*/[] ppvObject = new int /*long*/[1]; | 82 int /*long*/[] ppvObject = new int /*long*/[1]; |
79 /* CreateStdAccessibleObject([in] hwnd, [in] idObject, [in] riidInterface, [out] ppvObject). | 83 /* CreateStdAccessibleObject([in] hwnd, [in] idObject, [in] riidInterface, [out] ppvObject). |
80 * AddRef has already been called on ppvObject by the callee and must be released by the caller. | 84 * AddRef has already been called on ppvObject by the callee and must be released by the caller. |
81 */ | 85 */ |
157 * @see #removeAccessibleListener | 161 * @see #removeAccessibleListener |
158 */ | 162 */ |
159 public void addAccessibleListener(AccessibleListener listener) { | 163 public void addAccessibleListener(AccessibleListener listener) { |
160 checkWidget(); | 164 checkWidget(); |
161 if (listener is null) SWT.error(__FILE__, __LINE__, SWT.ERROR_NULL_ARGUMENT); | 165 if (listener is null) SWT.error(__FILE__, __LINE__, SWT.ERROR_NULL_ARGUMENT); |
162 accessibleListeners ~= listener; | 166 accessibleListeners.addElement(cast(Object)listener); |
163 } | 167 } |
164 | 168 |
165 /** | 169 /** |
166 * Adds the listener to the collection of listeners who will | 170 * Adds the listener to the collection of listeners who will |
167 * be notified when an accessible client asks for custom control | 171 * be notified when an accessible client asks for custom control |
184 * @see #removeAccessibleControlListener | 188 * @see #removeAccessibleControlListener |
185 */ | 189 */ |
186 public void addAccessibleControlListener(AccessibleControlListener listener) { | 190 public void addAccessibleControlListener(AccessibleControlListener listener) { |
187 checkWidget(); | 191 checkWidget(); |
188 if (listener is null) SWT.error(__FILE__, __LINE__, SWT.ERROR_NULL_ARGUMENT); | 192 if (listener is null) SWT.error(__FILE__, __LINE__, SWT.ERROR_NULL_ARGUMENT); |
189 accessibleControlListeners ~= listener; | 193 accessibleControlListeners.addElement(cast(Object)listener); |
190 } | 194 } |
191 | 195 |
192 /** | 196 /** |
193 * Adds the listener to the collection of listeners who will | 197 * Adds the listener to the collection of listeners who will |
194 * be notified when an accessible client asks for custom text control | 198 * be notified when an accessible client asks for custom text control |
213 * @since 3.0 | 217 * @since 3.0 |
214 */ | 218 */ |
215 public void addAccessibleTextListener (AccessibleTextListener listener) { | 219 public void addAccessibleTextListener (AccessibleTextListener listener) { |
216 checkWidget (); | 220 checkWidget (); |
217 if (listener is null) SWT.error (SWT.ERROR_NULL_ARGUMENT); | 221 if (listener is null) SWT.error (SWT.ERROR_NULL_ARGUMENT); |
218 textListeners ~= listener; | 222 textListeners.addElement(cast(Object)listener); |
219 } | 223 } |
220 | 224 |
221 /** | 225 /** |
222 * Returns the control for this Accessible object. | 226 * Returns the control for this Accessible object. |
223 * | 227 * |
288 * @see #addAccessibleListener | 292 * @see #addAccessibleListener |
289 */ | 293 */ |
290 public void removeAccessibleListener(AccessibleListener listener) { | 294 public void removeAccessibleListener(AccessibleListener listener) { |
291 checkWidget(); | 295 checkWidget(); |
292 if (listener is null) SWT.error(__FILE__, __LINE__, SWT.ERROR_NULL_ARGUMENT); | 296 if (listener is null) SWT.error(__FILE__, __LINE__, SWT.ERROR_NULL_ARGUMENT); |
293 accessibleListeners.length = accessibleListeners.remove(listener); | 297 accessibleListeners.removeElement(cast(Object)listener); |
294 } | 298 } |
295 | 299 |
296 /** | 300 /** |
297 * Removes the listener from the collection of listeners who will | 301 * Removes the listener from the collection of listeners who will |
298 * be notified when an accessible client asks for custom control | 302 * be notified when an accessible client asks for custom control |
313 * @see #addAccessibleControlListener | 317 * @see #addAccessibleControlListener |
314 */ | 318 */ |
315 public void removeAccessibleControlListener(AccessibleControlListener listener) { | 319 public void removeAccessibleControlListener(AccessibleControlListener listener) { |
316 checkWidget(); | 320 checkWidget(); |
317 if (listener is null) SWT.error(__FILE__, __LINE__, SWT.ERROR_NULL_ARGUMENT); | 321 if (listener is null) SWT.error(__FILE__, __LINE__, SWT.ERROR_NULL_ARGUMENT); |
318 accessibleControlListeners.length = accessibleControlListeners.remove(listener); | 322 accessibleControlListeners.removeElement(cast(Object)listener); |
319 } | 323 } |
320 | 324 |
321 /** | 325 /** |
322 * Removes the listener from the collection of listeners who will | 326 * Removes the listener from the collection of listeners who will |
323 * be notified when an accessible client asks for custom text control | 327 * be notified when an accessible client asks for custom text control |
340 * @since 3.0 | 344 * @since 3.0 |
341 */ | 345 */ |
342 public void removeAccessibleTextListener (AccessibleTextListener listener) { | 346 public void removeAccessibleTextListener (AccessibleTextListener listener) { |
343 checkWidget (); | 347 checkWidget (); |
344 if (listener is null) SWT.error (SWT.ERROR_NULL_ARGUMENT); | 348 if (listener is null) SWT.error (SWT.ERROR_NULL_ARGUMENT); |
345 textListeners.length = textListeners.remove (listener); | 349 textListeners.removeElement (cast(Object)listener); |
346 } | 350 } |
347 | 351 |
348 /** | 352 /** |
349 * Sends a message to accessible clients that the child selection | 353 * Sends a message to accessible clients that the child selection |
350 * within a custom container control has changed. | 354 * within a custom container control has changed. |
494 return code; | 498 return code; |
495 } | 499 } |
496 | 500 |
497 HRESULT accHitTest(LONG xLeft, LONG yTop, VARIANT* pvarChild) { | 501 HRESULT accHitTest(LONG xLeft, LONG yTop, VARIANT* pvarChild) { |
498 if (iaccessible is null) return COM.CO_E_OBJNOTCONNECTED; | 502 if (iaccessible is null) return COM.CO_E_OBJNOTCONNECTED; |
499 if (accessibleControlListeners.length is 0) { | 503 if (accessibleControlListeners.size() is 0) { |
500 return iaccessible.accHitTest(xLeft, yTop, pvarChild); | 504 return iaccessible.accHitTest(xLeft, yTop, pvarChild); |
501 } | 505 } |
502 | 506 |
503 AccessibleControlEvent event = new AccessibleControlEvent(this); | 507 AccessibleControlEvent event = new AccessibleControlEvent(this); |
504 event.childID = ACC.CHILDID_NONE; | 508 event.childID = ACC.CHILDID_NONE; |
505 event.x = xLeft; | 509 event.x = xLeft; |
506 event.y = yTop; | 510 event.y = yTop; |
507 for (int i = 0; i < accessibleControlListeners.length; i++) { | 511 for (int i = 0; i < accessibleControlListeners.size(); i++) { |
508 AccessibleControlListener listener = cast(AccessibleControlListener) accessibleControlListeners[i]; | 512 AccessibleControlListener listener = cast(AccessibleControlListener) accessibleControlListeners.elementAt(i); |
509 listener.getChildAtPoint(event); | 513 listener.getChildAtPoint(event); |
510 } | 514 } |
511 int childID = event.childID; | 515 int childID = event.childID; |
512 if (childID is ACC.CHILDID_NONE) { | 516 if (childID is ACC.CHILDID_NONE) { |
513 return iaccessible.accHitTest(xLeft, yTop, pvarChild); | 517 return iaccessible.accHitTest(xLeft, yTop, pvarChild); |
526 | 530 |
527 /* Get the default location from the OS. */ | 531 /* Get the default location from the OS. */ |
528 int osLeft = 0, osTop = 0, osWidth = 0, osHeight = 0; | 532 int osLeft = 0, osTop = 0, osWidth = 0, osHeight = 0; |
529 int code = iaccessible.accLocation(pxLeft, pyTop, pcxWidth, pcyHeight, variant); | 533 int code = iaccessible.accLocation(pxLeft, pyTop, pcxWidth, pcyHeight, variant); |
530 if (code is COM.E_INVALIDARG) code = COM.S_FALSE; // proxy doesn't know about app childID | 534 if (code is COM.E_INVALIDARG) code = COM.S_FALSE; // proxy doesn't know about app childID |
531 if (accessibleControlListeners.length is 0) return code; | 535 if (accessibleControlListeners.size() is 0) return code; |
532 if (code is COM.S_OK) { | 536 if (code is COM.S_OK) { |
533 int[1] pLeft, pTop, pWidth, pHeight; | 537 int[1] pLeft, pTop, pWidth, pHeight; |
534 COM.MoveMemory(pLeft.ptr, pxLeft, 4); | 538 COM.MoveMemory(pLeft.ptr, pxLeft, 4); |
535 COM.MoveMemory(pTop.ptr, pyTop, 4); | 539 COM.MoveMemory(pTop.ptr, pyTop, 4); |
536 COM.MoveMemory(pWidth.ptr, pcxWidth, 4); | 540 COM.MoveMemory(pWidth.ptr, pcxWidth, 4); |
542 event.childID = osToChildID(v.lVal); | 546 event.childID = osToChildID(v.lVal); |
543 event.x = osLeft; | 547 event.x = osLeft; |
544 event.y = osTop; | 548 event.y = osTop; |
545 event.width = osWidth; | 549 event.width = osWidth; |
546 event.height = osHeight; | 550 event.height = osHeight; |
547 for (int i = 0; i < accessibleControlListeners.length; i++) { | 551 for (int i = 0; i < accessibleControlListeners.size(); i++) { |
548 AccessibleControlListener listener = cast(AccessibleControlListener) accessibleControlListeners[i]; | 552 AccessibleControlListener listener = cast(AccessibleControlListener) accessibleControlListeners.elementAt(i); |
549 listener.getLocation(event); | 553 listener.getLocation(event); |
550 } | 554 } |
551 OS.MoveMemory(pxLeft, &event.x, 4); | 555 OS.MoveMemory(pxLeft, &event.x, 4); |
552 OS.MoveMemory(pyTop, &event.y, 4); | 556 OS.MoveMemory(pyTop, &event.y, 4); |
553 OS.MoveMemory(pcxWidth, &event.width, 4); | 557 OS.MoveMemory(pcxWidth, &event.width, 4); |
578 HRESULT get_accChild(VARIANT variant, LPDISPATCH* ppdispChild) { | 582 HRESULT get_accChild(VARIANT variant, LPDISPATCH* ppdispChild) { |
579 if (iaccessible is null) return COM.CO_E_OBJNOTCONNECTED; | 583 if (iaccessible is null) return COM.CO_E_OBJNOTCONNECTED; |
580 VARIANT* v = &variant; | 584 VARIANT* v = &variant; |
581 //COM.MoveMemory(v, variant, VARIANT.sizeof); | 585 //COM.MoveMemory(v, variant, VARIANT.sizeof); |
582 if ((v.vt & 0xFFFF) !is COM.VT_I4) return COM.E_INVALIDARG; | 586 if ((v.vt & 0xFFFF) !is COM.VT_I4) return COM.E_INVALIDARG; |
583 if (accessibleControlListeners.length is 0) { | 587 if (accessibleControlListeners.size() is 0) { |
584 int code = iaccessible.get_accChild(variant, ppdispChild); | 588 int code = iaccessible.get_accChild(variant, ppdispChild); |
585 if (code is COM.E_INVALIDARG) code = COM.S_FALSE; // proxy doesn't know about app childID | 589 if (code is COM.E_INVALIDARG) code = COM.S_FALSE; // proxy doesn't know about app childID |
586 return code; | 590 return code; |
587 } | 591 } |
588 | 592 |
589 AccessibleControlEvent event = new AccessibleControlEvent(this); | 593 AccessibleControlEvent event = new AccessibleControlEvent(this); |
590 event.childID = osToChildID(v.lVal); | 594 event.childID = osToChildID(v.lVal); |
591 for (int i = 0; i < accessibleControlListeners.length; i++) { | 595 for (int i = 0; i < accessibleControlListeners.size(); i++) { |
592 AccessibleControlListener listener = cast(AccessibleControlListener) accessibleControlListeners[i]; | 596 AccessibleControlListener listener = cast(AccessibleControlListener) accessibleControlListeners.elementAt(i); |
593 listener.getChild(event); | 597 listener.getChild(event); |
594 } | 598 } |
595 Accessible accessible = event.accessible; | 599 Accessible accessible = event.accessible; |
596 if (accessible !is null) { | 600 if (accessible !is null) { |
597 accessible.AddRef(); | 601 accessible.AddRef(); |
605 if (iaccessible is null) return COM.CO_E_OBJNOTCONNECTED; | 609 if (iaccessible is null) return COM.CO_E_OBJNOTCONNECTED; |
606 | 610 |
607 /* Get the default child count from the OS. */ | 611 /* Get the default child count from the OS. */ |
608 int osChildCount = 0; | 612 int osChildCount = 0; |
609 int code = iaccessible.get_accChildCount(pcountChildren); | 613 int code = iaccessible.get_accChildCount(pcountChildren); |
610 if (accessibleControlListeners.length is 0) return code; | 614 if (accessibleControlListeners.size() is 0) return code; |
611 if (code is COM.S_OK) { | 615 if (code is COM.S_OK) { |
612 int[1] pChildCount; | 616 int[1] pChildCount; |
613 COM.MoveMemory(pChildCount.ptr, pcountChildren, 4); | 617 COM.MoveMemory(pChildCount.ptr, pcountChildren, 4); |
614 osChildCount = pChildCount[0]; | 618 osChildCount = pChildCount[0]; |
615 } | 619 } |
616 | 620 |
617 AccessibleControlEvent event = new AccessibleControlEvent(this); | 621 AccessibleControlEvent event = new AccessibleControlEvent(this); |
618 event.childID = ACC.CHILDID_SELF; | 622 event.childID = ACC.CHILDID_SELF; |
619 event.detail = osChildCount; | 623 event.detail = osChildCount; |
620 for (int i = 0; i < accessibleControlListeners.length; i++) { | 624 for (int i = 0; i < accessibleControlListeners.size(); i++) { |
621 AccessibleControlListener listener = cast(AccessibleControlListener) accessibleControlListeners[i]; | 625 AccessibleControlListener listener = cast(AccessibleControlListener) accessibleControlListeners.elementAt(i); |
622 listener.getChildCount(event); | 626 listener.getChildCount(event); |
623 } | 627 } |
624 | 628 |
625 *pcountChildren = event.detail; | 629 *pcountChildren = event.detail; |
626 return COM.S_OK; | 630 return COM.S_OK; |
634 | 638 |
635 /* Get the default defaultAction from the OS. */ | 639 /* Get the default defaultAction from the OS. */ |
636 String osDefaultAction = null; | 640 String osDefaultAction = null; |
637 int code = iaccessible.get_accDefaultAction(variant, pszDefaultAction); | 641 int code = iaccessible.get_accDefaultAction(variant, pszDefaultAction); |
638 if (code is COM.E_INVALIDARG) code = COM.S_FALSE; // proxy doesn't know about app childID | 642 if (code is COM.E_INVALIDARG) code = COM.S_FALSE; // proxy doesn't know about app childID |
639 if (accessibleControlListeners.length is 0) return code; | 643 if (accessibleControlListeners.size() is 0) return code; |
640 if (code is COM.S_OK) { | 644 if (code is COM.S_OK) { |
641 osDefaultAction = BSTRToStr( *pszDefaultAction, true ); | 645 osDefaultAction = BSTRToStr( *pszDefaultAction, true ); |
642 } | 646 } |
643 | 647 |
644 AccessibleControlEvent event = new AccessibleControlEvent(this); | 648 AccessibleControlEvent event = new AccessibleControlEvent(this); |
645 event.childID = osToChildID(v.lVal); | 649 event.childID = osToChildID(v.lVal); |
646 event.result = osDefaultAction; | 650 event.result = osDefaultAction; |
647 for (int i = 0; i < accessibleControlListeners.length; i++) { | 651 for (int i = 0; i < accessibleControlListeners.size(); i++) { |
648 AccessibleControlListener listener = cast(AccessibleControlListener) accessibleControlListeners[i]; | 652 AccessibleControlListener listener = cast(AccessibleControlListener) accessibleControlListeners.elementAt(i); |
649 listener.getDefaultAction(event); | 653 listener.getDefaultAction(event); |
650 } | 654 } |
651 if (event.result is null) return code; | 655 if (event.result is null) return code; |
652 auto ptr = COM.SysAllocString(StrToWCHARz(event.result)); | 656 auto ptr = COM.SysAllocString(StrToWCHARz(event.result)); |
653 *pszDefaultAction = ptr; | 657 *pszDefaultAction = ptr; |
663 /* Get the default description from the OS. */ | 667 /* Get the default description from the OS. */ |
664 String osDescription = null; | 668 String osDescription = null; |
665 int code = iaccessible.get_accDescription(variant, pszDescription); | 669 int code = iaccessible.get_accDescription(variant, pszDescription); |
666 if (code is COM.E_INVALIDARG) code = COM.S_FALSE; // proxy doesn't know about app childID | 670 if (code is COM.E_INVALIDARG) code = COM.S_FALSE; // proxy doesn't know about app childID |
667 // TEMPORARY CODE - process tree even if there are no apps listening | 671 // TEMPORARY CODE - process tree even if there are no apps listening |
668 if (accessibleListeners.length is 0 && !( null is cast(Tree)control )) return code; | 672 if (accessibleListeners.size() is 0 && !( null is cast(Tree)control )) return code; |
669 if (code is COM.S_OK) { | 673 if (code is COM.S_OK) { |
670 int size = COM.SysStringByteLen(*pszDescription); | 674 int size = COM.SysStringByteLen(*pszDescription); |
671 if (size > 0) { | 675 if (size > 0) { |
672 size = (size + 1) /2; | 676 size = (size + 1) /2; |
673 osDescription = WCHARzToStr(*pszDescription, size); | 677 osDescription = WCHARzToStr(*pszDescription, size); |
702 } | 706 } |
703 } | 707 } |
704 } | 708 } |
705 } | 709 } |
706 } | 710 } |
707 for (int i = 0; i < accessibleListeners.length; i++) { | 711 for (int i = 0; i < accessibleListeners.size(); i++) { |
708 AccessibleListener listener = cast(AccessibleListener) accessibleListeners[i]; | 712 AccessibleListener listener = cast(AccessibleListener) accessibleListeners.elementAt(i); |
709 listener.getDescription(event); | 713 listener.getDescription(event); |
710 } | 714 } |
711 if (event.result is null) return code; | 715 if (event.result is null) return code; |
712 auto ptr = COM.SysAllocString(StrToWCHARz(event.result)); | 716 auto ptr = COM.SysAllocString(StrToWCHARz(event.result)); |
713 *pszDescription = ptr; | 717 *pszDescription = ptr; |
722 if (iaccessible is null) return COM.CO_E_OBJNOTCONNECTED; | 726 if (iaccessible is null) return COM.CO_E_OBJNOTCONNECTED; |
723 | 727 |
724 /* Get the default focus child from the OS. */ | 728 /* Get the default focus child from the OS. */ |
725 int osChild = ACC.CHILDID_NONE; | 729 int osChild = ACC.CHILDID_NONE; |
726 int code = iaccessible.get_accFocus(pvarChild); | 730 int code = iaccessible.get_accFocus(pvarChild); |
727 if (accessibleControlListeners.length is 0) return code; | 731 if (accessibleControlListeners.size() is 0) return code; |
728 if (code is COM.S_OK) { | 732 if (code is COM.S_OK) { |
729 //TODO - use VARIANT structure | 733 //TODO - use VARIANT structure |
730 short[1] pvt; | 734 short[1] pvt; |
731 COM.MoveMemory(pvt.ptr, pvarChild, 2); | 735 COM.MoveMemory(pvt.ptr, pvarChild, 2); |
732 if (pvt[0] is COM.VT_I4) { | 736 if (pvt[0] is COM.VT_I4) { |
736 } | 740 } |
737 } | 741 } |
738 | 742 |
739 AccessibleControlEvent event = new AccessibleControlEvent(this); | 743 AccessibleControlEvent event = new AccessibleControlEvent(this); |
740 event.childID = osChild; | 744 event.childID = osChild; |
741 for (int i = 0; i < accessibleControlListeners.length; i++) { | 745 for (int i = 0; i < accessibleControlListeners.size(); i++) { |
742 AccessibleControlListener listener = cast(AccessibleControlListener) accessibleControlListeners[i]; | 746 AccessibleControlListener listener = cast(AccessibleControlListener) accessibleControlListeners.elementAt(i); |
743 listener.getFocus(event); | 747 listener.getFocus(event); |
744 } | 748 } |
745 Accessible accessible = event.accessible; | 749 Accessible accessible = event.accessible; |
746 if (accessible !is null) { | 750 if (accessible !is null) { |
747 accessible.AddRef(); | 751 accessible.AddRef(); |
773 | 777 |
774 /* Get the default help string from the OS. */ | 778 /* Get the default help string from the OS. */ |
775 String osHelp = null; | 779 String osHelp = null; |
776 int code = iaccessible.get_accHelp(variant, pszHelp); | 780 int code = iaccessible.get_accHelp(variant, pszHelp); |
777 if (code is COM.E_INVALIDARG) code = COM.S_FALSE; // proxy doesn't know about app childID | 781 if (code is COM.E_INVALIDARG) code = COM.S_FALSE; // proxy doesn't know about app childID |
778 if (accessibleListeners.length is 0) return code; | 782 if (accessibleListeners.size() is 0) return code; |
779 if (code is COM.S_OK) { | 783 if (code is COM.S_OK) { |
780 // the original SysString is clearuped and bstr set to null | 784 // the original SysString is clearuped and bstr set to null |
781 osHelp = BSTRToStr(*pszHelp, true); | 785 osHelp = BSTRToStr(*pszHelp, true); |
782 } | 786 } |
783 | 787 |
784 AccessibleEvent event = new AccessibleEvent(this); | 788 AccessibleEvent event = new AccessibleEvent(this); |
785 event.childID = osToChildID(v.lVal); | 789 event.childID = osToChildID(v.lVal); |
786 event.result = osHelp; | 790 event.result = osHelp; |
787 for (int i = 0; i < accessibleListeners.length; i++) { | 791 for (int i = 0; i < accessibleListeners.size(); i++) { |
788 AccessibleListener listener = cast(AccessibleListener) accessibleListeners[i]; | 792 AccessibleListener listener = cast(AccessibleListener) accessibleListeners.elementAt(i); |
789 listener.getHelp(event); | 793 listener.getHelp(event); |
790 } | 794 } |
791 if (event.result is null) return code; | 795 if (event.result is null) return code; |
792 auto ptr = COM.SysAllocString(StrToWCHARz(event.result)); | 796 auto ptr = COM.SysAllocString(StrToWCHARz(event.result)); |
793 *pszHelp = ptr; | 797 *pszHelp = ptr; |
810 | 814 |
811 /* Get the default keyboard shortcut from the OS. */ | 815 /* Get the default keyboard shortcut from the OS. */ |
812 String osKeyboardShortcut = null; | 816 String osKeyboardShortcut = null; |
813 int code = iaccessible.get_accKeyboardShortcut(variant, pszKeyboardShortcut); | 817 int code = iaccessible.get_accKeyboardShortcut(variant, pszKeyboardShortcut); |
814 if (code is COM.E_INVALIDARG) code = COM.S_FALSE; // proxy doesn't know about app childID | 818 if (code is COM.E_INVALIDARG) code = COM.S_FALSE; // proxy doesn't know about app childID |
815 if (accessibleListeners.length is 0) return code; | 819 if (accessibleListeners.size() is 0) return code; |
816 if (code is COM.S_OK) { | 820 if (code is COM.S_OK) { |
817 // the original SysString is clearuped and bstr set to null | 821 // the original SysString is clearuped and bstr set to null |
818 osKeyboardShortcut = BSTRToStr(*pszKeyboardShortcut, true); | 822 osKeyboardShortcut = BSTRToStr(*pszKeyboardShortcut, true); |
819 } | 823 } |
820 | 824 |
821 AccessibleEvent event = new AccessibleEvent(this); | 825 AccessibleEvent event = new AccessibleEvent(this); |
822 event.childID = osToChildID(v.lVal); | 826 event.childID = osToChildID(v.lVal); |
823 event.result = osKeyboardShortcut; | 827 event.result = osKeyboardShortcut; |
824 for (int i = 0; i < accessibleListeners.length; i++) { | 828 for (int i = 0; i < accessibleListeners.size(); i++) { |
825 AccessibleListener listener = cast(AccessibleListener) accessibleListeners[i]; | 829 AccessibleListener listener = cast(AccessibleListener) accessibleListeners.elementAt(i); |
826 listener.getKeyboardShortcut(event); | 830 listener.getKeyboardShortcut(event); |
827 } | 831 } |
828 if (event.result is null) return code; | 832 if (event.result is null) return code; |
829 auto ptr = COM.SysAllocString(StrToWCHARz(event.result)); | 833 auto ptr = COM.SysAllocString(StrToWCHARz(event.result)); |
830 *pszKeyboardShortcut = ptr; | 834 *pszKeyboardShortcut = ptr; |
839 | 843 |
840 /* Get the default name from the OS. */ | 844 /* Get the default name from the OS. */ |
841 String osName = null; | 845 String osName = null; |
842 int code = iaccessible.get_accName(variant, pszName); | 846 int code = iaccessible.get_accName(variant, pszName); |
843 if (code is COM.E_INVALIDARG) code = COM.S_FALSE; // proxy doesn't know about app childID | 847 if (code is COM.E_INVALIDARG) code = COM.S_FALSE; // proxy doesn't know about app childID |
844 if (accessibleListeners.length is 0) return code; | 848 if (accessibleListeners.size() is 0) return code; |
845 if (code is COM.S_OK) { | 849 if (code is COM.S_OK) { |
846 // the original SysString is clearuped and bstr set to null | 850 // the original SysString is clearuped and bstr set to null |
847 osName = BSTRToStr(*pszName, true); | 851 osName = BSTRToStr(*pszName, true); |
848 } | 852 } |
849 | 853 |
850 AccessibleEvent event = new AccessibleEvent(this); | 854 AccessibleEvent event = new AccessibleEvent(this); |
851 event.childID = osToChildID(v.lVal); | 855 event.childID = osToChildID(v.lVal); |
852 event.result = osName; | 856 event.result = osName; |
853 for (int i = 0; i < accessibleListeners.length; i++) { | 857 for (int i = 0; i < accessibleListeners.size(); i++) { |
854 AccessibleListener listener = cast(AccessibleListener) accessibleListeners[i]; | 858 AccessibleListener listener = cast(AccessibleListener) accessibleListeners.elementAt(i); |
855 listener.getName(event); | 859 listener.getName(event); |
856 } | 860 } |
857 if (event.result is null) return code; | 861 if (event.result is null) return code; |
858 auto ptr = COM.SysAllocString(StrToWCHARz(event.result)); | 862 auto ptr = COM.SysAllocString(StrToWCHARz(event.result)); |
859 *pszName = ptr; | 863 *pszName = ptr; |
879 /* Get the default role from the OS. */ | 883 /* Get the default role from the OS. */ |
880 int osRole = COM.ROLE_SYSTEM_CLIENT; | 884 int osRole = COM.ROLE_SYSTEM_CLIENT; |
881 int code = iaccessible.get_accRole(variant, pvarRole); | 885 int code = iaccessible.get_accRole(variant, pvarRole); |
882 if (code is COM.E_INVALIDARG) code = COM.S_FALSE; // proxy doesn't know about app childID | 886 if (code is COM.E_INVALIDARG) code = COM.S_FALSE; // proxy doesn't know about app childID |
883 // TEMPORARY CODE - process tree and table even if there are no apps listening | 887 // TEMPORARY CODE - process tree and table even if there are no apps listening |
884 if (accessibleControlListeners.length is 0 && !( null !is cast(Tree)control || null !is cast(Table)control )) return code; | 888 if (accessibleControlListeners.size() is 0 && !( null !is cast(Tree)control || null !is cast(Table)control )) return code; |
885 if (code is COM.S_OK) { | 889 if (code is COM.S_OK) { |
886 //TODO - use VARIANT structure | 890 //TODO - use VARIANT structure |
887 short[1] pvt; | 891 short[1] pvt; |
888 COM.MoveMemory(pvt.ptr, pvarRole, 2); | 892 COM.MoveMemory(pvt.ptr, pvarRole, 2); |
889 if (pvt[0] is COM.VT_I4) { | 893 if (pvt[0] is COM.VT_I4) { |
902 if (v.lVal !is COM.CHILDID_SELF) { | 906 if (v.lVal !is COM.CHILDID_SELF) { |
903 if ( null !is cast(Tree)control || null !is cast(Table)control ) { | 907 if ( null !is cast(Tree)control || null !is cast(Table)control ) { |
904 if ((control.getStyle() & SWT.CHECK) !is 0) event.detail = ACC.ROLE_CHECKBUTTON; | 908 if ((control.getStyle() & SWT.CHECK) !is 0) event.detail = ACC.ROLE_CHECKBUTTON; |
905 } | 909 } |
906 } | 910 } |
907 for (int i = 0; i < accessibleControlListeners.length; i++) { | 911 for (int i = 0; i < accessibleControlListeners.size(); i++) { |
908 AccessibleControlListener listener = cast(AccessibleControlListener) accessibleControlListeners[i]; | 912 AccessibleControlListener listener = cast(AccessibleControlListener) accessibleControlListeners.elementAt(i); |
909 listener.getRole(event); | 913 listener.getRole(event); |
910 } | 914 } |
911 int role = roleToOs(event.detail); | 915 int role = roleToOs(event.detail); |
912 pvarRole.vt = COM.VT_I4; | 916 pvarRole.vt = COM.VT_I4; |
913 pvarRole.lVal = role; | 917 pvarRole.lVal = role; |
922 if (iaccessible is null) return COM.CO_E_OBJNOTCONNECTED; | 926 if (iaccessible is null) return COM.CO_E_OBJNOTCONNECTED; |
923 | 927 |
924 /* Get the default selection from the OS. */ | 928 /* Get the default selection from the OS. */ |
925 int osChild = ACC.CHILDID_NONE; | 929 int osChild = ACC.CHILDID_NONE; |
926 int code = iaccessible.get_accSelection(pvarChildren); | 930 int code = iaccessible.get_accSelection(pvarChildren); |
927 if (accessibleControlListeners.length is 0) return code; | 931 if (accessibleControlListeners.size() is 0) return code; |
928 if (code is COM.S_OK) { | 932 if (code is COM.S_OK) { |
929 //TODO - use VARIANT structure | 933 //TODO - use VARIANT structure |
930 short[1] pvt; | 934 short[1] pvt; |
931 COM.MoveMemory(pvt.ptr, pvarChildren, 2); | 935 COM.MoveMemory(pvt.ptr, pvarChildren, 2); |
932 if (pvt[0] is COM.VT_I4) { | 936 if (pvt[0] is COM.VT_I4) { |
939 } | 943 } |
940 } | 944 } |
941 | 945 |
942 AccessibleControlEvent event = new AccessibleControlEvent(this); | 946 AccessibleControlEvent event = new AccessibleControlEvent(this); |
943 event.childID = osChild; | 947 event.childID = osChild; |
944 for (int i = 0; i < accessibleControlListeners.length; i++) { | 948 for (int i = 0; i < accessibleControlListeners.size(); i++) { |
945 AccessibleControlListener listener = cast(AccessibleControlListener) accessibleControlListeners[i]; | 949 AccessibleControlListener listener = cast(AccessibleControlListener) accessibleControlListeners.elementAt(i); |
946 listener.getSelection(event); | 950 listener.getSelection(event); |
947 } | 951 } |
948 Accessible accessible = event.accessible; | 952 Accessible accessible = event.accessible; |
949 if (accessible !is null) { | 953 if (accessible !is null) { |
950 accessible.AddRef(); | 954 accessible.AddRef(); |
983 /* Get the default state from the OS. */ | 987 /* Get the default state from the OS. */ |
984 int osState = 0; | 988 int osState = 0; |
985 int code = iaccessible.get_accState(variant, pvarState); | 989 int code = iaccessible.get_accState(variant, pvarState); |
986 if (code is COM.E_INVALIDARG) code = COM.S_FALSE; // proxy doesn't know about app childID | 990 if (code is COM.E_INVALIDARG) code = COM.S_FALSE; // proxy doesn't know about app childID |
987 // TEMPORARY CODE - process tree and table even if there are no apps listening | 991 // TEMPORARY CODE - process tree and table even if there are no apps listening |
988 if (accessibleControlListeners.length is 0 && !( null !is cast(Tree)control || null !is cast(Table)control )) return code; | 992 if (accessibleControlListeners.size() is 0 && !( null !is cast(Tree)control || null !is cast(Table)control )) return code; |
989 if (code is COM.S_OK) { | 993 if (code is COM.S_OK) { |
990 //TODO - use VARIANT structure | 994 //TODO - use VARIANT structure |
991 short[1] pvt; | 995 short[1] pvt; |
992 COM.MoveMemory(pvt.ptr, pvarState, 2); | 996 COM.MoveMemory(pvt.ptr, pvarState, 2); |
993 if (pvt[0] is COM.VT_I4) { | 997 if (pvt[0] is COM.VT_I4) { |
1026 if (item.getChecked()) event.detail |= ACC.STATE_CHECKED; | 1030 if (item.getChecked()) event.detail |= ACC.STATE_CHECKED; |
1027 if (item.getGrayed()) grayed = true; | 1031 if (item.getGrayed()) grayed = true; |
1028 } | 1032 } |
1029 } | 1033 } |
1030 } | 1034 } |
1031 for (int i = 0; i < accessibleControlListeners.length; i++) { | 1035 for (int i = 0; i < accessibleControlListeners.size(); i++) { |
1032 AccessibleControlListener listener = cast(AccessibleControlListener) accessibleControlListeners[i]; | 1036 AccessibleControlListener listener = cast(AccessibleControlListener) accessibleControlListeners.elementAt(i); |
1033 listener.getState(event); | 1037 listener.getState(event); |
1034 } | 1038 } |
1035 int state = stateToOs(event.detail); | 1039 int state = stateToOs(event.detail); |
1036 if ((state & ACC.STATE_CHECKED) !is 0 && grayed) { | 1040 if ((state & ACC.STATE_CHECKED) !is 0 && grayed) { |
1037 state &= ~ COM.STATE_SYSTEM_CHECKED; | 1041 state &= ~ COM.STATE_SYSTEM_CHECKED; |
1050 | 1054 |
1051 /* Get the default value string from the OS. */ | 1055 /* Get the default value string from the OS. */ |
1052 String osValue = null; | 1056 String osValue = null; |
1053 int code = iaccessible.get_accValue(variant, pszValue); | 1057 int code = iaccessible.get_accValue(variant, pszValue); |
1054 if (code is COM.E_INVALIDARG) code = COM.S_FALSE; // proxy doesn't know about app childID | 1058 if (code is COM.E_INVALIDARG) code = COM.S_FALSE; // proxy doesn't know about app childID |
1055 if (accessibleControlListeners.length is 0) return code; | 1059 if (accessibleControlListeners.size() is 0) return code; |
1056 if (code is COM.S_OK) { | 1060 if (code is COM.S_OK) { |
1057 int size = COM.SysStringByteLen(*pszValue); | 1061 int size = COM.SysStringByteLen(*pszValue); |
1058 if (size > 0) { | 1062 if (size > 0) { |
1059 osValue = WCHARsToStr((*pszValue)[ 0 .. size ]); | 1063 osValue = WCHARsToStr((*pszValue)[ 0 .. size ]); |
1060 } | 1064 } |
1061 } | 1065 } |
1062 | 1066 |
1063 AccessibleControlEvent event = new AccessibleControlEvent(this); | 1067 AccessibleControlEvent event = new AccessibleControlEvent(this); |
1064 event.childID = osToChildID(v.lVal); | 1068 event.childID = osToChildID(v.lVal); |
1065 event.result = osValue; | 1069 event.result = osValue; |
1066 for (int i = 0; i < accessibleControlListeners.length; i++) { | 1070 for (int i = 0; i < accessibleControlListeners.size(); i++) { |
1067 AccessibleControlListener listener = cast(AccessibleControlListener) accessibleControlListeners[i]; | 1071 AccessibleControlListener listener = cast(AccessibleControlListener) accessibleControlListeners.elementAt(i); |
1068 listener.getValue(event); | 1072 listener.getValue(event); |
1069 } | 1073 } |
1070 if (event.result is null) return code; | 1074 if (event.result is null) return code; |
1071 auto ptr = COM.SysAllocString(StrToWCHARz(event.result)); | 1075 auto ptr = COM.SysAllocString(StrToWCHARz(event.result)); |
1072 *pszValue = ptr; | 1076 *pszValue = ptr; |
1105 */ | 1109 */ |
1106 HRESULT Next(ULONG celt, VARIANT *rgvar, ULONG *pceltFetched) { | 1110 HRESULT Next(ULONG celt, VARIANT *rgvar, ULONG *pceltFetched) { |
1107 /* If there are no listeners, query the proxy for | 1111 /* If there are no listeners, query the proxy for |
1108 * its IEnumVariant, and get the Next items from it. | 1112 * its IEnumVariant, and get the Next items from it. |
1109 */ | 1113 */ |
1110 if (accessibleControlListeners.length is 0) { | 1114 if (accessibleControlListeners.size() is 0) { |
1111 IEnumVARIANT ienumvariant; | 1115 IEnumVARIANT ienumvariant; |
1112 int code = iaccessible.QueryInterface(&COM.IIDIEnumVARIANT, cast(void**)&ienumvariant); | 1116 int code = iaccessible.QueryInterface(&COM.IIDIEnumVARIANT, cast(void**)&ienumvariant); |
1113 if (code !is COM.S_OK) return code; | 1117 if (code !is COM.S_OK) return code; |
1114 uint[1] celtFetched; | 1118 uint[1] celtFetched; |
1115 code = ienumvariant.Next(celt, rgvar, celtFetched.ptr); | 1119 code = ienumvariant.Next(celt, rgvar, celtFetched.ptr); |
1121 if (rgvar is null) return COM.E_INVALIDARG; | 1125 if (rgvar is null) return COM.E_INVALIDARG; |
1122 if (pceltFetched is null && celt !is 1) return COM.E_INVALIDARG; | 1126 if (pceltFetched is null && celt !is 1) return COM.E_INVALIDARG; |
1123 if (enumIndex is 0) { | 1127 if (enumIndex is 0) { |
1124 AccessibleControlEvent event = new AccessibleControlEvent(this); | 1128 AccessibleControlEvent event = new AccessibleControlEvent(this); |
1125 event.childID = ACC.CHILDID_SELF; | 1129 event.childID = ACC.CHILDID_SELF; |
1126 for (int i = 0; i < accessibleControlListeners.length; i++) { | 1130 for (int i = 0; i < accessibleControlListeners.size(); i++) { |
1127 AccessibleControlListener listener = cast(AccessibleControlListener) accessibleControlListeners[i]; | 1131 AccessibleControlListener listener = cast(AccessibleControlListener) accessibleControlListeners.elementAt(i); |
1128 listener.getChildren(event); | 1132 listener.getChildren(event); |
1129 } | 1133 } |
1130 variants = event.children; | 1134 variants = event.children; |
1131 } | 1135 } |
1132 Object[] nextItems = null; | 1136 Object[] nextItems = null; |
1176 /* Skip over the specified number of elements in the enumeration sequence. */ | 1180 /* Skip over the specified number of elements in the enumeration sequence. */ |
1177 HRESULT Skip(ULONG celt) { | 1181 HRESULT Skip(ULONG celt) { |
1178 /* If there are no listeners, query the proxy | 1182 /* If there are no listeners, query the proxy |
1179 * for its IEnumVariant, and tell it to Skip. | 1183 * for its IEnumVariant, and tell it to Skip. |
1180 */ | 1184 */ |
1181 if (accessibleControlListeners.length is 0) { | 1185 if (accessibleControlListeners.size() is 0) { |
1182 IEnumVARIANT ienumvariant; | 1186 IEnumVARIANT ienumvariant; |
1183 int code = iaccessible.QueryInterface(&COM.IIDIEnumVARIANT, cast(void**)&ienumvariant); | 1187 int code = iaccessible.QueryInterface(&COM.IIDIEnumVARIANT, cast(void**)&ienumvariant); |
1184 if (code !is COM.S_OK) return code; | 1188 if (code !is COM.S_OK) return code; |
1185 code = ienumvariant.Skip(celt); | 1189 code = ienumvariant.Skip(celt); |
1186 ienumvariant.Release(); | 1190 ienumvariant.Release(); |
1199 /* Reset the enumeration sequence to the beginning. */ | 1203 /* Reset the enumeration sequence to the beginning. */ |
1200 HRESULT Reset() { | 1204 HRESULT Reset() { |
1201 /* If there are no listeners, query the proxy | 1205 /* If there are no listeners, query the proxy |
1202 * for its IEnumVariant, and tell it to Reset. | 1206 * for its IEnumVariant, and tell it to Reset. |
1203 */ | 1207 */ |
1204 if (accessibleControlListeners.length is 0) { | 1208 if (accessibleControlListeners.size() is 0) { |
1205 IEnumVARIANT ienumvariant; | 1209 IEnumVARIANT ienumvariant; |
1206 int code = iaccessible.QueryInterface(&COM.IIDIEnumVARIANT, cast(void**)&ienumvariant); | 1210 int code = iaccessible.QueryInterface(&COM.IIDIEnumVARIANT, cast(void**)&ienumvariant); |
1207 if (code !is COM.S_OK) return code; | 1211 if (code !is COM.S_OK) return code; |
1208 code = ienumvariant.Reset(); | 1212 code = ienumvariant.Reset(); |
1209 ienumvariant.Release(); | 1213 ienumvariant.Release(); |
1220 */ | 1224 */ |
1221 int Clone(IEnumVARIANT* ppEnum) { | 1225 int Clone(IEnumVARIANT* ppEnum) { |
1222 /* If there are no listeners, query the proxy for | 1226 /* If there are no listeners, query the proxy for |
1223 * its IEnumVariant, and get the Clone from it. | 1227 * its IEnumVariant, and get the Clone from it. |
1224 */ | 1228 */ |
1225 if (accessibleControlListeners.length is 0) { | 1229 if (accessibleControlListeners.size() is 0) { |
1226 IEnumVARIANT ienumvariant; | 1230 IEnumVARIANT ienumvariant; |
1227 int code = iaccessible.QueryInterface(&COM.IIDIEnumVARIANT, cast(void**)&ienumvariant); | 1231 int code = iaccessible.QueryInterface(&COM.IIDIEnumVARIANT, cast(void**)&ienumvariant); |
1228 if (code !is COM.S_OK) return code; | 1232 if (code !is COM.S_OK) return code; |
1229 IEnumVARIANT[1] pEnum; | 1233 IEnumVARIANT[1] pEnum; |
1230 code = ienumvariant.Clone(pEnum.ptr); | 1234 code = ienumvariant.Clone(pEnum.ptr); |