From 7777133105278b62778195d71e7ea90eeecb4f82 Mon Sep 17 00:00:00 2001 From: Carolyn MacLeod Date: Thu, 7 Feb 2002 21:32:39 +0000 Subject: *** empty log message *** --- .../swt/accessibility/AccessibleAdapter.java | 46 +- .../accessibility/AccessibleControlAdapter.java | 35 +- .../swt/accessibility/AccessibleControlEvent.java | 2 + .../accessibility/AccessibleControlListener.java | 38 +- .../swt/accessibility/AccessibleListener.java | 49 +- .../win32/org/eclipse/swt/accessibility/ACC.java | 1 + .../org/eclipse/swt/accessibility/Accessible.java | 572 ------------------- .../common/org/eclipse/swt/custom/CLabel.java | 63 +- .../common/org/eclipse/swt/custom/CTabFolder.java | 50 +- .../win32/org/eclipse/swt/widgets/Accessible.java | 634 +++++++++++++++++++++ .../win32/org/eclipse/swt/widgets/Control.java | 44 +- 11 files changed, 885 insertions(+), 649 deletions(-) delete mode 100644 bundles/org.eclipse.swt/Eclipse SWT Accessibility/win32/org/eclipse/swt/accessibility/Accessible.java create mode 100644 bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Accessible.java diff --git a/bundles/org.eclipse.swt/Eclipse SWT Accessibility/common/org/eclipse/swt/accessibility/AccessibleAdapter.java b/bundles/org.eclipse.swt/Eclipse SWT Accessibility/common/org/eclipse/swt/accessibility/AccessibleAdapter.java index fb3330d125..4207d0389d 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT Accessibility/common/org/eclipse/swt/accessibility/AccessibleAdapter.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Accessibility/common/org/eclipse/swt/accessibility/AccessibleAdapter.java @@ -12,6 +12,11 @@ package org.eclipse.swt.accessibility; * Classes that wish to deal with AccessibleEvents can * extend this class and override only the methods that they are * interested in. + *

+ * Note: Accessibility clients use child identifiers to specify + * whether they want information about a control or one of its children. + * Child identifiers are positive integers > 0. + * The identifier CHILDID_SELF (0) represents the control. *

* * @see AccessibleListener @@ -21,22 +26,49 @@ public abstract class AccessibleAdapter implements AccessibleListener { /** * Sent when an accessibility client requests the name - * of a control, or the specified child of a control. + * of the control, or the name of a child of the control. * The default behavior is to do nothing. * * @param e an event object containing the following fields: - * childID [IN] - the specified child identifier, or CHILDID_SELF - * result [OUT] - the string representing the requested name + * childID [IN] - an identifier specifying the control or one of its children + * result [OUT] - the requested name string */ - public void get_accName(AccessibleEvent e) { + public void getName(AccessibleEvent e) { } - public void get_accHelp(AccessibleEvent e) { + /** + * Sent when an accessibility client requests the help string + * of the control, or the help string of a child of the control. + * The default behavior is to do nothing. + * + * @param e an event object containing the following fields: + * childID [IN] - an identifier specifying the control or one of its children + * result [OUT] - the requested help string + */ + public void getHelp(AccessibleEvent e) { } - public void get_accKeyboardShortcut(AccessibleEvent e) { + /** + * Sent when an accessibility client requests the keyboard shortcut + * of the control, or the keyboard shortcut of a child of the control. + * The default behavior is to do nothing. + * + * @param e an event object containing the following fields: + * childID [IN] - an identifier specifying the control or one of its children + * result [OUT] - the requested keyboard shortcut string (example: "CTRL+C") + */ + public void getKeyboardShortcut(AccessibleEvent e) { } - public void get_accDescription(AccessibleEvent e) { + /** + * Sent when an accessibility client requests a description + * of the control, or a description of a child of the control. + * The default behavior is to do nothing. + * + * @param e an event object containing the following fields: + * childID [IN] - an identifier specifying the control or one of its children + * result [OUT] - the requested description string + */ + public void getDescription(AccessibleEvent e) { } } diff --git a/bundles/org.eclipse.swt/Eclipse SWT Accessibility/common/org/eclipse/swt/accessibility/AccessibleControlAdapter.java b/bundles/org.eclipse.swt/Eclipse SWT Accessibility/common/org/eclipse/swt/accessibility/AccessibleControlAdapter.java index db07c89a83..a09da7ce14 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT Accessibility/common/org/eclipse/swt/accessibility/AccessibleControlAdapter.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Accessibility/common/org/eclipse/swt/accessibility/AccessibleControlAdapter.java @@ -12,6 +12,17 @@ package org.eclipse.swt.accessibility; * Classes that wish to deal with AccessibleControlEvents can * extend this class and override only the methods that they are * interested in. + *

+ * Accessibility clients use child identifiers to specify + * whether they want information about a control or one of its children. + * Child identifiers are positive integers > 0. + * The identifier CHILDID_SELF (0) represents the control. + * When returning a child identifier to a client, you may use CHILDID_NONE + * to indicate that no child or control has the required information. + *

+ * Note: This adapter is typically used by implementors of + * a custom control to provide very detailed information about + * the control instance to accessibility clients. *

* * @see AccessibleControlListener @@ -37,35 +48,31 @@ public abstract class AccessibleControlAdapter implements AccessibleControlListe public void accNavigate(AccessibleControlEvent e) { } - public void get_accChild(AccessibleControlEvent e) { + public void getChild(AccessibleControlEvent e) { } - public void get_accChildCount(AccessibleControlEvent e) { + public void getChildCount(AccessibleControlEvent e) { } - public void get_accDefaultAction(AccessibleControlEvent e) { + public void getDefaultAction(AccessibleControlEvent e) { } - public void get_accFocus(AccessibleControlEvent e) { + public void getFocus(AccessibleControlEvent e) { } - public void get_accRole(AccessibleControlEvent e) { + public void getRole(AccessibleControlEvent e) { } - public void get_accSelection(AccessibleControlEvent e) { + public void getSelection(AccessibleControlEvent e) { } - public void get_accState(AccessibleControlEvent e) { + public void getState(AccessibleControlEvent e) { } - public void get_accValue(AccessibleControlEvent e) { + public void getValue(AccessibleControlEvent e) { } - // May not implement - public void accDoDefaultAction(AccessibleControlEvent e) { - } - public void accSelect(AccessibleControlEvent e) { - } - public void get_accParent(AccessibleControlEvent e) { + // May need to implement for IEnumVARIANT + public void getChildren(AccessibleControlEvent e) { } } diff --git a/bundles/org.eclipse.swt/Eclipse SWT Accessibility/common/org/eclipse/swt/accessibility/AccessibleControlEvent.java b/bundles/org.eclipse.swt/Eclipse SWT Accessibility/common/org/eclipse/swt/accessibility/AccessibleControlEvent.java index d6cffad3aa..545e4b6401 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT Accessibility/common/org/eclipse/swt/accessibility/AccessibleControlEvent.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Accessibility/common/org/eclipse/swt/accessibility/AccessibleControlEvent.java @@ -6,6 +6,7 @@ package org.eclipse.swt.accessibility; */ import org.eclipse.swt.internal.SWTEventObject; +import org.eclipse.swt.widgets.*; /** * Instances of this class are sent as a result of @@ -27,6 +28,7 @@ public class AccessibleControlEvent extends SWTEventObject { public int width, height; // OUT public int code; // IN/OUT public String result; // OUT + public Object children[]; // [OUT] - may need this for IEnumVARIANT public AccessibleControlEvent(Object source) { super(source); diff --git a/bundles/org.eclipse.swt/Eclipse SWT Accessibility/common/org/eclipse/swt/accessibility/AccessibleControlListener.java b/bundles/org.eclipse.swt/Eclipse SWT Accessibility/common/org/eclipse/swt/accessibility/AccessibleControlListener.java index 688ab99ca0..30496c6ca0 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT Accessibility/common/org/eclipse/swt/accessibility/AccessibleControlListener.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Accessibility/common/org/eclipse/swt/accessibility/AccessibleControlListener.java @@ -19,6 +19,11 @@ import org.eclipse.swt.internal.SWTEventListener; * When a client requests information the appropriate method * will be invoked. *

+ * Accessibility clients use child identifiers to specify + * whether they want information about a control or one of its children. + * Child identifiers are positive integers > 0. + * The identifier CHILDID_SELF (0) represents the control. + *

* Note: This interface is typically used by implementors of * a custom control to provide very detailed information about * the control instance to accessibility clients. @@ -31,22 +36,27 @@ public interface AccessibleControlListener extends SWTEventListener { public void accHitTest(AccessibleControlEvent e); public void accLocation(AccessibleControlEvent e); + public void getChild(AccessibleControlEvent e); + public void getChildCount(AccessibleControlEvent e); + public void getDefaultAction(AccessibleControlEvent e); + public void getFocus(AccessibleControlEvent e); + public void getRole(AccessibleControlEvent e); + public void getSelection(AccessibleControlEvent e); + public void getState(AccessibleControlEvent e); + public void getValue(AccessibleControlEvent e); + + // May need to implement for IEnumVARIANT + public void getChildren(AccessibleControlEvent e); + + // May not implement - not sure what clients use these - likely testing clients, not accesibility (but not sure) public void accNavigate(AccessibleControlEvent e); - public void get_accChild(AccessibleControlEvent e); - public void get_accChildCount(AccessibleControlEvent e); - public void get_accDefaultAction(AccessibleControlEvent e); - public void get_accFocus(AccessibleControlEvent e); - public void get_accRole(AccessibleControlEvent e); - public void get_accSelection(AccessibleControlEvent e); - public void get_accState(AccessibleControlEvent e); - public void get_accValue(AccessibleControlEvent e); + //public void accDoDefaultAction(AccessibleControlEvent e); + //public void accSelect(AccessibleControlEvent e); - // May not implement - public void accDoDefaultAction(AccessibleControlEvent e); - public void accSelect(AccessibleControlEvent e); - public void get_accParent(AccessibleControlEvent e); + // Probably won't implement - the usual parent is probably good enough + //public void getParent(AccessibleControlEvent e); // Will not implement - //public void put_accName(AccessibleControlEvent e); - //public void put_accValue(AccessibleControlEvent e); + //public void putName(AccessibleControlEvent e); + //public void putValue(AccessibleControlEvent e); } diff --git a/bundles/org.eclipse.swt/Eclipse SWT Accessibility/common/org/eclipse/swt/accessibility/AccessibleListener.java b/bundles/org.eclipse.swt/Eclipse SWT Accessibility/common/org/eclipse/swt/accessibility/AccessibleListener.java index 3b7fdeeaee..dd02c0b0c5 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT Accessibility/common/org/eclipse/swt/accessibility/AccessibleListener.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Accessibility/common/org/eclipse/swt/accessibility/AccessibleListener.java @@ -18,6 +18,11 @@ import org.eclipse.swt.internal.SWTEventListener; * using the removeAccessibleListener method. * When a client requests information the appropriate method * will be invoked. + *

+ * Note: Accessibility clients use child identifiers to specify + * whether they want information about a control or one of its children. + * Child identifiers are positive integers > 0. + * The identifier CHILDID_SELF (0) represents the control. *

* * @see AccessibleAdapter @@ -25,11 +30,43 @@ import org.eclipse.swt.internal.SWTEventListener; */ public interface AccessibleListener extends SWTEventListener { - public void get_accName(AccessibleEvent e); - public void get_accHelp(AccessibleEvent e); - public void get_accKeyboardShortcut(AccessibleEvent e); - public void get_accDescription(AccessibleEvent e); + /** + * Sent when an accessibility client requests the name + * of the control, or the name of a child of the control. + * + * @param e an event object containing the following fields: + * childID [IN] - an identifier specifying the control or one of its children + * result [OUT] - the requested name string + */ + public void getName(AccessibleEvent e); - // Will not implement (Windows-specific) - //public void get_accHelpTopic(AccessibleEvent e); + /** + * Sent when an accessibility client requests the help string + * of the control, or the help string of a child of the control. + * + * @param e an event object containing the following fields: + * childID [IN] - an identifier specifying the control or one of its children + * result [OUT] - the requested help string + */ + public void getHelp(AccessibleEvent e); + + /** + * Sent when an accessibility client requests the keyboard shortcut + * of the control, or the keyboard shortcut of a child of the control. + * + * @param e an event object containing the following fields: + * childID [IN] - an identifier specifying the control or one of its children + * result [OUT] - the requested keyboard shortcut string (example: "CTRL+C") + */ + public void getKeyboardShortcut(AccessibleEvent e); + + /** + * Sent when an accessibility client requests a description + * of the control, or a description of a child of the control. + * + * @param e an event object containing the following fields: + * childID [IN] - an identifier specifying the control or one of its children + * result [OUT] - the requested description string + */ + public void getDescription(AccessibleEvent e); } diff --git a/bundles/org.eclipse.swt/Eclipse SWT Accessibility/win32/org/eclipse/swt/accessibility/ACC.java b/bundles/org.eclipse.swt/Eclipse SWT Accessibility/win32/org/eclipse/swt/accessibility/ACC.java index 16e4b982bf..e515f54872 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT Accessibility/win32/org/eclipse/swt/accessibility/ACC.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Accessibility/win32/org/eclipse/swt/accessibility/ACC.java @@ -24,6 +24,7 @@ public class ACC extends COM { public static final int ROLE_SYSTEM_PUSHBUTTON = 0x2b; public static final int ROLE_SYSTEM_PAGETAB = 0x25; public static final int ROLE_SYSTEM_PAGETABLIST = 0x3c; + public static final int ROLE_SYSTEM_STATICTEXT = 0x29; public static final int CO_E_OBJNOTCONNECTED = 0x800401FD; public static final int NAVDIR_UP = 0x1; public static final int NAVDIR_DOWN = 0x2; diff --git a/bundles/org.eclipse.swt/Eclipse SWT Accessibility/win32/org/eclipse/swt/accessibility/Accessible.java b/bundles/org.eclipse.swt/Eclipse SWT Accessibility/win32/org/eclipse/swt/accessibility/Accessible.java deleted file mode 100644 index ece0d139eb..0000000000 --- a/bundles/org.eclipse.swt/Eclipse SWT Accessibility/win32/org/eclipse/swt/accessibility/Accessible.java +++ /dev/null @@ -1,572 +0,0 @@ -package org.eclipse.swt.accessibility; - -import java.util.Vector; -import org.eclipse.swt.*; -import org.eclipse.swt.widgets.*; -import org.eclipse.swt.internal.win32.*; -import org.eclipse.swt.ole.win32.*; -import org.eclipse.swt.internal.ole.win32.*; - -public class Accessible { - static final boolean debug = true; - Control control; - int refCount = 0; - COMObject objIAccessible; - IAccessible iaccessible; - Vector accessibleListeners, accessibleControlListeners; - - public Accessible(Control control) { - this.control = control; - control.addListener(SWT.AccessAccessibility, new Listener() { - public void handleEvent(Event event) { - int lParam = ((int []) event.data)[0]; - int wParam = ((int []) event.data)[1]; - if (lParam == COM.OBJID_CLIENT) { - event.detail = ACC.LresultFromObject(COM.IIDIAccessible, wParam, objIAccessible.getAddress()); - } - } - }); - objIAccessible = new COMObject(new int[] { 2, 0, 0, 1, 3, 5, 8, 1, 1, 5, 5, 5, 5, 5, 5, 5, 6, 5, 1, 1, 5, 5, 8, 6, 3, 4, 5, 5 }) { - public int method0(int[] args) { - return QueryInterface(args[0], args[1]); - } - public int method1(int[] args) { - return AddRef(); - } - public int method2(int[] args) { - return Release(); - } - public int method3(int[] args) { - return GetTypeInfoCount(args[0]); - } - public int method4(int[] args) { - return GetTypeInfo(args[0], args[1], args[2]); - } - public int method5(int[] args) { - return GetIDsOfNames(args[0], args[1], args[2], args[3], args[4]); - } - public int method6(int[] args) { - return Invoke(args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7]); - } - public int method7(int[] args) { - return get_accParent(args[0]); - } - public int method8(int[] args) { - return get_accChildCount(args[0]); - } - public int method9(int[] args) { - return get_accChild(args[0], args[1], args[2], args[3], args[4]); - } - public int method10(int[] args) { - return get_accName(args[0], args[1], args[2], args[3], args[4]); - } - public int method11(int[] args) { - return get_accValue(args[0], args[1], args[2], args[3], args[4]); - } - public int method12(int[] args) { - return get_accDescription(args[0], args[1], args[2], args[3], args[4]); - } - public int method13(int[] args) { - return get_accRole(args[0], args[1], args[2], args[3], args[4]); - } - public int method14(int[] args) { - return get_accState(args[0], args[1], args[2], args[3], args[4]); - } - public int method15(int[] args) { - return get_accHelp(args[0], args[1], args[2], args[3], args[4]); - } - public int method16(int[] args) { - return get_accHelpTopic(args[0], args[1], args[2], args[3], args[4], args[5]); - } - public int method17(int[] args) { - return get_accKeyboardShortcut(args[0], args[1], args[2], args[3], args[4]); - } - public int method18(int[] args) { - return get_accFocus(args[0]); - } - public int method19(int[] args) { - return get_accSelection(args[0]); - } - public int method20(int[] args) { - return get_accDefaultAction(args[0], args[1], args[2], args[3], args[4]); - } - public int method21(int[] args) { - return accSelect(args[0], args[1], args[2], args[3], args[4]); - } - public int method22(int[] args) { - return accLocation(args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7]); - } - public int method23(int[] args) { - return accNavigate(args[0], args[1], args[2], args[3], args[4], args[5]); - } - public int method24(int[] args) { - return accHitTest(args[0], args[1], args[2]); - } - public int method25(int[] args) { - return accDoDefaultAction(args[0], args[1], args[2], args[3]); - } - public int method26(int[] args) { - return put_accName(args[0], args[1], args[2], args[3], args[4]); - } - public int method27(int[] args) { - return put_accValue(args[0], args[1], args[2], args[3], args[4]); - } - }; - - int[] ppvObject = new int[1]; - int result = ACC.CreateStdAccessibleObject(control.handle, COM.OBJID_CLIENT, COM.IIDIAccessible, ppvObject); - if (result != COM.S_OK) - OLE.error(OLE.ERROR_CANNOT_CREATE_OBJECT, result); - iaccessible = new IAccessible(ppvObject[0]); - iaccessible.AddRef(); - //new TypeInfoBrowser(ppvObject[0]); - } - - public void addAccessibleListener(AccessibleListener listener) { - if (listener == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); - if (accessibleListeners == null) { - accessibleListeners = new Vector(); - } - accessibleListeners.addElement(listener); - } - - // need removeAccessibleListener also - - public void addAccessibleControlListener(AccessibleControlListener listener) { - if (listener == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); - if (accessibleControlListeners == null) { - accessibleControlListeners = new Vector(); - } - accessibleControlListeners.addElement(listener); - } - - // need removeAccessibleControlListener also - - int QueryInterface(int arg1, int arg2) { - if (debug) - System.out.println("QueryInterface"); - - GUID guid = new GUID(); - COM.MoveMemory(guid, arg1, GUID.sizeof); - - if (COM.IsEqualGUID(guid, COM.IIDIUnknown)) { - if (debug) - System.out.println("IUnknown"); - COM.MoveMemory(arg2, new int[] { objIAccessible.getAddress()}, 4); - return COM.S_OK; - } - - if (COM.IsEqualGUID(guid, COM.IIDIDispatch)) { - if (debug) - System.out.println("IDispatch"); - COM.MoveMemory(arg2, new int[] { objIAccessible.getAddress()}, 4); - return COM.S_OK; - } - - if (COM.IsEqualGUID(guid, COM.IIDIAccessible)) { - if (debug) - System.out.println("IAccessible"); - COM.MoveMemory(arg2, new int[] { objIAccessible.getAddress()}, 4); - return COM.S_OK; - } - - int[] ppvObject = new int[1]; - int result = iaccessible.QueryInterface(guid, ppvObject); - COM.MoveMemory(arg2, ppvObject, 4); - if (debug) - System.out.println("QI other " + result); - return result; - } - - int AddRef() { - if (debug) - System.out.println("AddRef"); - refCount++; - return refCount; - } - - int Release() { - if (debug) - System.out.println("Release"); - refCount--; - - if (refCount == 0) { - //disposeCOMInterfaces(); - } - return refCount; - } - - int GetTypeInfoCount(int pctinfo) { - if (debug) - System.out.println("GetTypeInfoCount"); - return COM.E_NOTIMPL; - } - - int GetTypeInfo(int iTInfo, int lcid, int ppTInfo) { - if (debug) - System.out.println("GetTypeInfo"); - return COM.E_NOTIMPL; - } - - int GetIDsOfNames(int riid, int rgszNames, int cNames, int lcid, int rgDispId) { - if (debug) - System.out.println("GetIDsOfNames"); - return COM.E_NOTIMPL; - } - - int Invoke(int dispIdMember, int riid, int lcid, int dwFlags, int pDispParams, int pVarResult, int pExcepInfo, int pArgErr) { - if (debug) - System.out.println("Invoke"); - return COM.E_NOTIMPL; - } - - int accDoDefaultAction(int varChild_vt, int varChild_reserved1, int varChild_lVal, int varChild_reserved2) { - if (debug) - System.out.println("accDoDefaultAction " + varChild_vt + " " + varChild_lVal); - // must implement this for the items because they have a default action - return iaccessible.accDoDefaultAction(varChild_vt, varChild_reserved1, varChild_lVal, varChild_reserved2); - } - - int accHitTest(int xLeft, int yTop, int pvarChild) { - if (debug) - System.out.println("accHitTest " + xLeft + " " + yTop + " " + pvarChild); - - AccessibleControlEvent event = new AccessibleControlEvent(this); - event.x = xLeft; - event.y = yTop; - for (int i = 0; i < accessibleControlListeners.size(); i++) { - AccessibleControlListener listener = (AccessibleControlListener) accessibleControlListeners.elementAt(i); - listener.accHitTest(event); - } - int childID = event.childID; - if (childID == ACC.CHILDID_NONE) { - COM.MoveMemory(pvarChild, new short[] { COM.VT_EMPTY }, 2); - return COM.S_FALSE; - } - COM.MoveMemory(pvarChild, new short[] { COM.VT_I4 }, 2); - COM.MoveMemory(pvarChild + 8, new int[] { childID }, 4); - return COM.S_OK; - } - - int accLocation(int pxLeft, int pyTop, int pcxWidth, int pcyHeight, int varChild_vt, int varChild_reserved1, int varChild_lVal, int varChild_reserved2) { - if (debug) - System.out.println("accLocation " + pxLeft + " " + pyTop + " " + pcxWidth + " " + pcyHeight + " " + varChild_vt + " " + varChild_lVal); - - if (varChild_vt != COM.VT_I4) return COM.E_INVALIDARG; - AccessibleControlEvent event = new AccessibleControlEvent(this); - event.childID = varChild_lVal; - for (int i = 0; i < accessibleControlListeners.size(); i++) { - AccessibleControlListener listener = (AccessibleControlListener) accessibleControlListeners.elementAt(i); - listener.accLocation(event); - } - OS.MoveMemory(pxLeft, new int[] { event.x }, 4); - OS.MoveMemory(pyTop, new int[] { event.y }, 4); - OS.MoveMemory(pcxWidth, new int[] { event.width }, 4); - OS.MoveMemory(pcyHeight, new int[] { event.height }, 4); - return COM.S_OK; - } - - int accNavigate(int navDir, int varStart_vt, int varStart_reserved1, int varStart_lVal, int varStart_reserved2, int pvarEndUpAt) { - if (debug) - System.out.println("accNavigate " + navDir + " " + varStart_vt + " " + varStart_lVal + " " + pvarEndUpAt); - - if (varStart_vt != COM.VT_I4) return COM.E_INVALIDARG; - AccessibleControlEvent event = new AccessibleControlEvent(this); - event.code = navDir; - event.childID = varStart_lVal; - for (int i = 0; i < accessibleControlListeners.size(); i++) { - AccessibleControlListener listener = (AccessibleControlListener) accessibleControlListeners.elementAt(i); - listener.accNavigate(event); - } - Accessible accessible = event.accessible; - if (accessible != null) { - COM.MoveMemory(pvarEndUpAt, new short[] { COM.VT_DISPATCH }, 2); - COM.MoveMemory(pvarEndUpAt + 8, new int[] { accessible.objIAccessible.getAddress() }, 4); - return COM.S_OK; - } - int childID = event.childID; - if (childID == ACC.CHILDID_NONE) { - COM.MoveMemory(pvarEndUpAt, new short[] { COM.VT_EMPTY }, 2); - return COM.S_FALSE; - } - if (childID == ACC.CHILDID_SELF) { - COM.MoveMemory(pvarEndUpAt, new short[] { COM.VT_DISPATCH }, 2); - COM.MoveMemory(pvarEndUpAt + 8, new int[] { objIAccessible.getAddress() }, 4); - return COM.S_OK; - } - COM.MoveMemory(pvarEndUpAt, new short[] { COM.VT_I4 }, 2); - COM.MoveMemory(pvarEndUpAt + 8, new int[] { childID }, 4); - return COM.S_OK; - } - - int accSelect(int flagsSelect, int varChild_vt, int varChild_reserved1, int varChild_lVal, int varChild_reserved2) { - if (debug) - System.out.println("accSelect " + flagsSelect + " " + varChild_vt + " " + varChild_lVal); - // must implement for the items because they support selection - return iaccessible.accSelect(flagsSelect, varChild_vt, varChild_reserved1, varChild_lVal, varChild_reserved2); - } - - int get_accChild(int varChild_vt, int varChild_reserved1, int varChild_lVal, int varChild_reserved2, int ppdispChild) { - if (debug) - System.out.println("get_accChild " + varChild_vt + " " + varChild_lVal + " " + ppdispChild); - - if (varChild_vt != COM.VT_I4) return COM.E_INVALIDARG; - AccessibleControlEvent event = new AccessibleControlEvent(this); - event.childID = varChild_lVal; - for (int i = 0; i < accessibleControlListeners.size(); i++) { - AccessibleControlListener listener = (AccessibleControlListener) accessibleControlListeners.elementAt(i); - listener.get_accChild(event); - } - Accessible accessible = event.accessible; - if (accessible != null) { - COM.MoveMemory(ppdispChild, new int[] { accessible.objIAccessible.getAddress() }, 4); - return COM.S_OK; - } - return COM.S_FALSE; - } - - int get_accChildCount(int pcountChildren) { - if (debug) - System.out.println("get_accChildCount " + pcountChildren); - - AccessibleControlEvent event = new AccessibleControlEvent(this); - for (int i = 0; i < accessibleControlListeners.size(); i++) { - AccessibleControlListener listener = (AccessibleControlListener) accessibleControlListeners.elementAt(i); - listener.get_accChildCount(event); - } - - COM.MoveMemory(pcountChildren, new int[] { event.code }, 4); - return COM.S_OK; - } - - int get_accDefaultAction(int varChild_vt, int varChild_reserved1, int varChild_lVal, int varChild_reserved2, int pszDefaultAction) { - if (debug) - System.out.println("get_accDefaultAction " + varChild_vt + " " + varChild_lVal + " " + pszDefaultAction); - - if (varChild_vt != COM.VT_I4) return COM.E_INVALIDARG; - AccessibleControlEvent event = new AccessibleControlEvent(this); - event.childID = varChild_lVal; - for (int i = 0; i < accessibleControlListeners.size(); i++) { - AccessibleControlListener listener = (AccessibleControlListener) accessibleControlListeners.elementAt(i); - listener.get_accDefaultAction(event); - } - if (event.result == null) return COM.S_FALSE; - char[] data = (event.result + "\0").toCharArray(); - int ptr = COM.SysAllocString(data); - COM.MoveMemory(pszDefaultAction, new int[] { ptr }, 4); - return COM.S_OK; - } - - int get_accDescription(int varChild_vt, int varChild_reserved1, int varChild_lVal, int varChild_reserved2, int pszDescription) { - if (debug) - System.out.println("get_accDescription " + varChild_vt + " " + varChild_lVal + " " + pszDescription); - - if (varChild_vt != COM.VT_I4) return COM.E_INVALIDARG; - AccessibleEvent event = new AccessibleEvent(this); - event.childID = varChild_lVal; - for (int i = 0; i < accessibleListeners.size(); i++) { - AccessibleListener listener = (AccessibleListener) accessibleListeners.elementAt(i); - listener.get_accDescription(event); - } - if (event.result == null) return COM.S_FALSE; - char[] data = (event.result + "\0").toCharArray(); - int ptr = COM.SysAllocString(data); - COM.MoveMemory(pszDescription, new int[] { ptr }, 4); - return COM.S_OK; - } - - int get_accFocus(int pvarChild) { - if (debug) - System.out.println("get_accFocus " + pvarChild); - - AccessibleControlEvent event = new AccessibleControlEvent(this); - for (int i = 0; i < accessibleControlListeners.size(); i++) { - AccessibleControlListener listener = (AccessibleControlListener) accessibleControlListeners.elementAt(i); - listener.get_accFocus(event); - } - Accessible accessible = event.accessible; - if (accessible != null) { - COM.MoveMemory(pvarChild, new short[] { COM.VT_DISPATCH }, 2); - COM.MoveMemory(pvarChild + 8, new int[] { accessible.objIAccessible.getAddress() }, 4); - return COM.S_OK; - } - int childID = event.childID; - if (childID == ACC.CHILDID_NONE) { - COM.MoveMemory(pvarChild, new short[] { COM.VT_EMPTY }, 2); - return COM.S_FALSE; - } - if (childID == ACC.CHILDID_SELF) { - COM.MoveMemory(pvarChild, new short[] { COM.VT_DISPATCH }, 2); - COM.MoveMemory(pvarChild + 8, new int[] { objIAccessible.getAddress() }, 4); - return COM.S_OK; - } - COM.MoveMemory(pvarChild, new short[] { COM.VT_I4 }, 2); - COM.MoveMemory(pvarChild + 8, new int[] { childID }, 4); - return COM.S_OK; - } - - int get_accHelp(int varChild_vt, int varChild_reserved1, int varChild_lVal, int varChild_reserved2, int pszHelp) { - if (debug) - System.out.println("get_accHelp " + varChild_vt + " " + varChild_lVal + " " + pszHelp); - - if (varChild_vt != COM.VT_I4) return COM.E_INVALIDARG; - AccessibleEvent event = new AccessibleEvent(this); - event.childID = varChild_lVal; - for (int i = 0; i < accessibleListeners.size(); i++) { - AccessibleListener listener = (AccessibleListener) accessibleListeners.elementAt(i); - listener.get_accHelp(event); - } - if (event.result == null) return COM.S_FALSE; - char[] data = (event.result + "\0").toCharArray(); - int ptr = COM.SysAllocString(data); - COM.MoveMemory(pszHelp, new int[] { ptr }, 4); - return COM.S_OK; - } - - int get_accHelpTopic(int pszHelpFile, int varChild_vt, int varChild_reserved1, int varChild_lVal, int varChild_reserved2, int pidTopic) { - if (debug) - System.out.println("get_accHelpTopic " + pszHelpFile + " " + varChild_vt + " " + varChild_lVal + " " + pidTopic); - return COM.S_FALSE; - } - - int get_accKeyboardShortcut(int varChild_vt, int varChild_reserved1, int varChild_lVal, int varChild_reserved2, int pszKeyboardShortcut) { - if (debug) - System.out.println("get_accKeyboardShortcut " + pszKeyboardShortcut); - - if (varChild_vt != COM.VT_I4) return COM.E_INVALIDARG; - AccessibleEvent event = new AccessibleEvent(this); - event.childID = varChild_lVal; - for (int i = 0; i < accessibleListeners.size(); i++) { - AccessibleListener listener = (AccessibleListener) accessibleListeners.elementAt(i); - listener.get_accKeyboardShortcut(event); - } - if (event.result == null) return COM.S_FALSE; - char[] data = (event.result + "\0").toCharArray(); - int ptr = COM.SysAllocString(data); - COM.MoveMemory(pszKeyboardShortcut, new int[] { ptr }, 4); - return COM.S_OK; - } - - int get_accName(int varChild_vt, int varChild_reserved1, int varChild_lVal, int varChild_reserved2, int pszName) { - if (debug) - System.out.println("get_accName " + varChild_vt + " " + varChild_lVal + " " + pszName); - - if (varChild_vt != COM.VT_I4) return COM.E_INVALIDARG; - AccessibleEvent event = new AccessibleEvent(this); - event.childID = varChild_lVal; - for (int i = 0; i < accessibleListeners.size(); i++) { - AccessibleListener listener = (AccessibleListener) accessibleListeners.elementAt(i); - listener.get_accName(event); - } - if (event.result == null) return COM.S_FALSE; - char[] data = (event.result + "\0").toCharArray(); - int ptr = COM.SysAllocString(data); - COM.MoveMemory(pszName, new int[] { ptr }, 4); - return COM.S_OK; - } - - int get_accParent(int ppdispParent) { - return iaccessible.get_accParent(ppdispParent); - } - - int get_accRole(int varChild_vt, int varChild_reserved1, int varChild_lVal, int varChild_reserved2, int pvarRole) { - if (debug) - System.out.println("get_accRole " + varChild_vt + " " + varChild_lVal + " " + pvarRole); - - if (varChild_vt != COM.VT_I4) return COM.E_INVALIDARG; - AccessibleControlEvent event = new AccessibleControlEvent(this); - event.childID = varChild_lVal; - for (int i = 0; i < accessibleControlListeners.size(); i++) { - AccessibleControlListener listener = (AccessibleControlListener) accessibleControlListeners.elementAt(i); - listener.get_accRole(event); - } - int role = event.code; - COM.MoveMemory(pvarRole, new short[] { COM.VT_I4 }, 2); - COM.MoveMemory(pvarRole + 8, new int[] { role }, 4); - return COM.S_OK; - } - - int get_accSelection(int pvarChildren) { - if (debug) - System.out.println("get_accSelection " + pvarChildren); - - AccessibleControlEvent event = new AccessibleControlEvent(this); - for (int i = 0; i < accessibleControlListeners.size(); i++) { - AccessibleControlListener listener = (AccessibleControlListener) accessibleControlListeners.elementAt(i); - listener.get_accSelection(event); - } - Accessible accessible = event.accessible; - if (accessible != null) { - COM.MoveMemory(pvarChildren, new short[] { COM.VT_DISPATCH }, 2); - COM.MoveMemory(pvarChildren + 8, new int[] { accessible.objIAccessible.getAddress() }, 4); - return COM.S_OK; - } - int childID = event.childID; - if (childID == ACC.CHILDID_NONE) { - COM.MoveMemory(pvarChildren, new short[] { COM.VT_EMPTY }, 2); - return COM.S_FALSE; - } - if (childID == ACC.CHILDID_MULTIPLE) { - COM.MoveMemory(pvarChildren, new short[] { COM.VT_UNKNOWN }, 2); - /* Supposed to return an IEnumVARIANT for this... so the next line is wrong... need a better API here... */ - COM.MoveMemory(pvarChildren + 8, new int[] { objIAccessible.getAddress() }, 4); - return COM.S_OK; - } - if (childID == ACC.CHILDID_SELF) { - COM.MoveMemory(pvarChildren, new short[] { COM.VT_DISPATCH }, 2); - COM.MoveMemory(pvarChildren + 8, new int[] { objIAccessible.getAddress() }, 4); - return COM.S_OK; - } - COM.MoveMemory(pvarChildren, new short[] { COM.VT_I4 }, 2); - COM.MoveMemory(pvarChildren + 8, new int[] { childID }, 4); - return COM.S_OK; - } - - int get_accState(int varChild_vt, int varChild_reserved1, int varChild_lVal, int varChild_reserved2, int pvarState) { - if (debug) - System.out.println("get_accState " + varChild_vt + " " + varChild_lVal + " " + pvarState); - - if (varChild_vt != COM.VT_I4) return COM.E_INVALIDARG; - AccessibleControlEvent event = new AccessibleControlEvent(this); - event.childID = varChild_lVal; - for (int i = 0; i < accessibleControlListeners.size(); i++) { - AccessibleControlListener listener = (AccessibleControlListener) accessibleControlListeners.elementAt(i); - listener.get_accState(event); - } - int state = event.code; - COM.MoveMemory(pvarState, new short[] { COM.VT_I4 }, 2); - COM.MoveMemory(pvarState + 8, new int[] { state }, 4); - return COM.S_OK; - } - - int get_accValue(int varChild_vt, int varChild_reserved1, int varChild_lVal, int varChild_reserved2, int pszValue) { - if (debug) - System.out.println("get_accValue " + varChild_vt + " " + varChild_lVal + " " + pszValue); - - AccessibleControlEvent event = new AccessibleControlEvent(this); - event.childID = varChild_lVal; - for (int i = 0; i < accessibleControlListeners.size(); i++) { - AccessibleControlListener listener = (AccessibleControlListener) accessibleControlListeners.elementAt(i); - listener.get_accValue(event); - } - if (event.result == null) return COM.S_FALSE; - char[] data = (event.result + "\0").toCharArray(); - int ptr = COM.SysAllocString(data); - COM.MoveMemory(pszValue, new int[] { ptr }, 4); - return COM.S_OK; - } - - int put_accName(int varChild_vt, int varChild_reserved1, int varChild_lVal, int varChild_reserved2, int szName) { - // this method is no longer supported - if (debug) - System.out.println("put_accName " + varChild_vt + " " + varChild_lVal + " " + szName); - return iaccessible.put_accName(varChild_vt, varChild_reserved1, varChild_lVal, varChild_reserved2, szName); - } - - int put_accValue(int varChild_vt, int varChild_reserved1, int varChild_lVal, int varChild_reserved2, int szValue) { - // this method is typically only used for edit controls - if (debug) - System.out.println("put_accValue " + varChild_vt + " " + varChild_lVal + " " + szValue); - return iaccessible.put_accValue(varChild_vt, varChild_reserved1, varChild_lVal, varChild_reserved2, szValue); - } -} diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CLabel.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CLabel.java index 799891d8fa..37839ae3d7 100755 --- a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CLabel.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CLabel.java @@ -10,6 +10,10 @@ import org.eclipse.swt.widgets.*; import org.eclipse.swt.graphics.*; import org.eclipse.swt.events.*; +/* Start ACCESSIBILITY */ +import org.eclipse.swt.accessibility.*; +/* End ACCESSIBILITY */ + /** * A Label which supports aligned text and/or an image and different border styles. *

@@ -56,7 +60,6 @@ public class CLabel extends Canvas { private Color[] gradientColors; private int[] gradientPercents; - /** * Create a CLabel with the given border style as a child of parent. */ @@ -79,6 +82,64 @@ public CLabel(Composite parent, int style) { } }); +/* Start ACCESSIBILITY */ + getAccessibleObject().addAccessibleListener(new AccessibleAdapter() { + public void getName(AccessibleEvent e) { + if (e.childID == ACC.CHILDID_SELF) { + e.result = getText(); + } + } + + public void getHelp(AccessibleEvent e) { + if (e.childID == ACC.CHILDID_SELF) { + e.result = getToolTipText(); + } + } + + public void getDescription(AccessibleEvent e) { + if (e.childID == ACC.CHILDID_SELF) { + e.result = "This is a CLabel"; + } + } + }); + + getAccessibleObject().addAccessibleControlListener(new AccessibleControlAdapter() { + public void accHitTest(AccessibleControlEvent e) { + Point testPoint = toControl(new Point(e.x, e.y)); + if (getBounds().contains(testPoint)) { + e.childID = ACC.CHILDID_SELF; + } + } + + public void accLocation(AccessibleControlEvent e) { + if (e.childID == ACC.CHILDID_SELF) { + Rectangle location = getBounds(); + Point pt = toDisplay(new Point(location.x, location.y)); + e.x = pt.x; + e.y = pt.y; + e.width = location.width; + e.height = location.height; + } + } + + public void getChildCount(AccessibleControlEvent e) { + e.code = 0; + } + + public void getRole(AccessibleControlEvent e) { + if (e.childID == ACC.CHILDID_SELF) { + e.code = ACC.ROLE_SYSTEM_STATICTEXT; + } + } + + public void getState(AccessibleControlEvent e) { + if (e.childID == ACC.CHILDID_SELF) { + e.code = ACC.STATE_SYSTEM_NORMAL; + } + } + }); +/* End ACCESSIBILITY */ + } /** * Check the style bits to ensure that no invalid styles are applied. diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabFolder.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabFolder.java index adc7314741..5a5ca687cb 100755 --- a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabFolder.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabFolder.java @@ -139,12 +139,6 @@ public class CTabFolder extends Composite { // tool tip private Shell tip; - -/* Start ACCESSIBILITY */ - Accessible accessible; -/* End ACCESSIBILITY */ - - /** * Construct a CTabFolder with the specified parent and style. * @param parent org.eclipse.swt.widgets.Composite @@ -217,9 +211,8 @@ public CTabFolder(Composite parent, int style) { /* Start ACCESSIBILITY */ - accessible = new Accessible(this); - accessible.addAccessibleListener(new AccessibleAdapter() { - public void get_accDescription(AccessibleEvent e) { + getAccessibleObject().addAccessibleListener(new AccessibleAdapter() { + public void getDescription(AccessibleEvent e) { int childID = e.childID; if (childID > items.length) return; if (childID == ACC.CHILDID_SELF) { @@ -229,7 +222,7 @@ public CTabFolder(Composite parent, int style) { } } - public void get_accHelp(AccessibleEvent e) { + public void getHelp(AccessibleEvent e) { int childID = e.childID; if (childID > items.length) return; if (childID == ACC.CHILDID_SELF) { @@ -240,7 +233,7 @@ public CTabFolder(Composite parent, int style) { } } - public void get_accKeyboardShortcut(AccessibleEvent e) { + public void getKeyboardShortcut(AccessibleEvent e) { int childID = e.childID; if (childID > items.length) return; if (childID != ACC.CHILDID_SELF) { @@ -248,7 +241,7 @@ public CTabFolder(Composite parent, int style) { } } - public void get_accName(AccessibleEvent e) { + public void getName(AccessibleEvent e) { int childID = e.childID; if (childID > items.length) return; if (childID == ACC.CHILDID_SELF) { @@ -260,7 +253,7 @@ public CTabFolder(Composite parent, int style) { } }); - accessible.addAccessibleControlListener(new AccessibleControlAdapter() { + getAccessibleObject().addAccessibleControlListener(new AccessibleControlAdapter() { public void accHitTest(AccessibleControlEvent e) { Point testPoint = toControl(new Point(e.x, e.y)); int childID = ACC.CHILDID_SELF; @@ -302,11 +295,9 @@ public CTabFolder(Composite parent, int style) { if (childID == ACC.CHILDID_SELF) childID = ACC.CHILDID_SELF; break; case ACC.NAVDIR_FIRSTCHILD: - if (childID != ACC.CHILDID_SELF) return; // do this check in Accessible if (items.length > 0) childID = 1; break; case ACC.NAVDIR_LASTCHILD: - if (childID != ACC.CHILDID_SELF) return; // do this check in Accessible if (items.length > 0) childID = items.length; break; case ACC.NAVDIR_LEFT: @@ -319,23 +310,15 @@ public CTabFolder(Composite parent, int style) { if (childID == ACC.CHILDID_SELF) childID = ACC.CHILDID_SELF; if (items.length > 0 && childID < items.length) childID = childID + 1; break; - default: return; // do this check in Accessible - } - } - - public void get_accChild(AccessibleControlEvent e) { - int childID = e.childID; - if (childID > items.length) return; - if (childID == ACC.CHILDID_SELF) { - e.accessible = accessible; } + e.childID = childID; } - public void get_accChildCount(AccessibleControlEvent e) { + public void getChildCount(AccessibleControlEvent e) { e.code = items.length; } - public void get_accDefaultAction(AccessibleControlEvent e) { + public void getDefaultAction(AccessibleControlEvent e) { int childID = e.childID; if (childID > items.length) return; if (childID != ACC.CHILDID_SELF) { @@ -343,7 +326,7 @@ public CTabFolder(Composite parent, int style) { } } - public void get_accRole(AccessibleControlEvent e) { + public void getRole(AccessibleControlEvent e) { int childID = e.childID; if (childID > items.length) return; if (childID == ACC.CHILDID_SELF) { @@ -353,7 +336,7 @@ public CTabFolder(Composite parent, int style) { } } - public void get_accSelection(AccessibleControlEvent e) { + public void getSelection(AccessibleControlEvent e) { if (selectedIndex == -1) { e.childID = ACC.CHILDID_NONE; } else { @@ -361,7 +344,7 @@ public CTabFolder(Composite parent, int style) { } } - public void get_accState(AccessibleControlEvent e) { + public void getState(AccessibleControlEvent e) { int childID = e.childID; if (childID > items.length) return; int state; @@ -375,6 +358,15 @@ public CTabFolder(Composite parent, int style) { } e.code = state; } + + // May need this for IEnumVARIANT + public void getChildren(AccessibleControlEvent e) { + Object[] children = new Object[items.length]; + for (int i = 0; i < items.length; i++) { + children[i] = new Integer(i + 1); + } + e.children = children; + } }); /* End ACCESSIBILITY */ } diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Accessible.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Accessible.java new file mode 100644 index 0000000000..8a931f394a --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Accessible.java @@ -0,0 +1,634 @@ +package org.eclipse.swt.widgets; + +import java.util.Vector; +import org.eclipse.swt.*; +import org.eclipse.swt.internal.win32.*; +import org.eclipse.swt.ole.win32.*; +import org.eclipse.swt.accessibility.*; +import org.eclipse.swt.internal.ole.win32.*; + +public class Accessible { + static final boolean debug = true; + Control control; + int refCount = 0, enumIndex = 0; + COMObject objIAccessible, objIEnumVARIANT; + IAccessible iaccessible; + Vector accessibleListeners, accessibleControlListeners; + Object[] variants; + + public Accessible(Control control) { + this.control = control; + objIAccessible = new COMObject(new int[] {2,0,0,1,3,5,8,1,1,5,5,5,5,5,5,5,6,5,1,1,5,5,8,6,3,4,5,5}) { + public int method0(int[] args) {return QueryInterface(args[0], args[1]);} + public int method1(int[] args) {return AddRef();} + public int method2(int[] args) {return Release();} + public int method3(int[] args) {return GetTypeInfoCount(args[0]);} + public int method4(int[] args) {return GetTypeInfo(args[0], args[1], args[2]);} + public int method5(int[] args) {return GetIDsOfNames(args[0], args[1], args[2], args[3], args[4]);} + public int method6(int[] args) {return Invoke(args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7]);} + public int method7(int[] args) {return get_accParent(args[0]);} + public int method8(int[] args) {return get_accChildCount(args[0]);} + public int method9(int[] args) {return get_accChild(args[0], args[1], args[2], args[3], args[4]);} + public int method10(int[] args) {return get_accName(args[0], args[1], args[2], args[3], args[4]);} + public int method11(int[] args) {return get_accValue(args[0], args[1], args[2], args[3], args[4]);} + public int method12(int[] args) {return get_accDescription(args[0], args[1], args[2], args[3], args[4]);} + public int method13(int[] args) {return get_accRole(args[0], args[1], args[2], args[3], args[4]);} + public int method14(int[] args) {return get_accState(args[0], args[1], args[2], args[3], args[4]);} + public int method15(int[] args) {return get_accHelp(args[0], args[1], args[2], args[3], args[4]);} + public int method16(int[] args) {return get_accHelpTopic(args[0], args[1], args[2], args[3], args[4], args[5]);} + public int method17(int[] args) {return get_accKeyboardShortcut(args[0], args[1], args[2], args[3], args[4]);} + public int method18(int[] args) {return get_accFocus(args[0]);} + public int method19(int[] args) {return get_accSelection(args[0]);} + public int method20(int[] args) {return get_accDefaultAction(args[0], args[1], args[2], args[3], args[4]);} + public int method21(int[] args) {return accSelect(args[0], args[1], args[2], args[3], args[4]);} + public int method22(int[] args) {return accLocation(args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7]);} + public int method23(int[] args) {return accNavigate(args[0], args[1], args[2], args[3], args[4], args[5]);} + public int method24(int[] args) {return accHitTest(args[0], args[1], args[2]);} + public int method25(int[] args) {return accDoDefaultAction(args[0], args[1], args[2], args[3]);} + public int method26(int[] args) {return put_accName(args[0], args[1], args[2], args[3], args[4]);} + public int method27(int[] args) {return put_accValue(args[0], args[1], args[2], args[3], args[4]);} + }; + int[] ppvObject = new int[1]; + int result = ACC.CreateStdAccessibleObject(control.handle, COM.OBJID_CLIENT, COM.IIDIAccessible, ppvObject); + if (result != COM.S_OK) + OLE.error(OLE.ERROR_CANNOT_CREATE_OBJECT, result); + iaccessible = new IAccessible(ppvObject[0]); + iaccessible.AddRef(); + //new TypeInfoBrowser(ppvObject[0]); + + objIEnumVARIANT = new COMObject(new int[] {2,0,0,3,1,0,1}) { + public int method0(int[] args) {return QueryInterface(args[0], args[1]);} + public int method1(int[] args) {return AddRef();} + public int method2(int[] args) {return Release();} + public int method3(int[] args) {return Next(args[0], args[1], args[2]);} + public int method4(int[] args) {return Skip(args[0]);} + public int method5(int[] args) {return Reset();} + // method6 Clone - not implemented + }; + } + + public void addAccessibleListener(AccessibleListener listener) { + if (listener == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); + if (accessibleListeners == null) { + accessibleListeners = new Vector(); + } + accessibleListeners.addElement(listener); + } + + // need removeAccessibleListener also + + public void addAccessibleControlListener(AccessibleControlListener listener) { + if (listener == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); + if (accessibleControlListeners == null) { + accessibleControlListeners = new Vector(); + } + accessibleControlListeners.addElement(listener); + } + + // need removeAccessibleControlListener also + + int WM_GETOBJECT (int wParam, int lParam) { + if (lParam == COM.OBJID_CLIENT) { + return ACC.LresultFromObject(COM.IIDIAccessible, wParam, objIAccessible.getAddress()); + } + return 0; + } + + int QueryInterface(int arg1, int arg2) { + if (debug) + System.out.print("QueryInterface: "); + + GUID guid = new GUID(); + COM.MoveMemory(guid, arg1, GUID.sizeof); + + if (COM.IsEqualGUID(guid, COM.IIDIUnknown)) { + if (debug) + System.out.println("IUnknown"); + COM.MoveMemory(arg2, new int[] { objIAccessible.getAddress()}, 4); + return COM.S_OK; + } + + if (COM.IsEqualGUID(guid, COM.IIDIDispatch)) { + if (debug) + System.out.println("IDispatch"); + COM.MoveMemory(arg2, new int[] { objIAccessible.getAddress()}, 4); + return COM.S_OK; + } + + if (COM.IsEqualGUID(guid, COM.IIDIAccessible)) { + if (debug) + System.out.println("IAccessible"); + COM.MoveMemory(arg2, new int[] { objIAccessible.getAddress()}, 4); + return COM.S_OK; + } + + if (COM.IsEqualGUID(guid, COM.IIDIEnumVARIANT)) { + if (debug) + System.out.println("IEnumVARIANT"); + AccessibleControlEvent event = new AccessibleControlEvent(this); + for (int i = 0; i < accessibleControlListeners.size(); i++) { + AccessibleControlListener listener = (AccessibleControlListener) accessibleControlListeners.elementAt(i); + listener.getChildren(event); + } + variants = event.children; + enumIndex = 0; + COM.MoveMemory(arg2, new int[] { objIEnumVARIANT.getAddress()}, 4); + return COM.S_OK; + } + + int[] ppvObject = new int[1]; + int result = iaccessible.QueryInterface(guid, ppvObject); + COM.MoveMemory(arg2, ppvObject, 4); + if (debug) + System.out.println("other (" + result + ")"); + return result; + } + + int AddRef() { + if (debug) + System.out.println("AddRef"); + refCount++; + return refCount; + } + + int Release() { + if (debug) + System.out.println("Release"); + refCount--; + + if (refCount == 0) { + //disposeCOMInterfaces(); + } + return refCount; + } + + int GetTypeInfoCount(int pctinfo) { + if (debug) + System.out.println("GetTypeInfoCount"); + return COM.E_NOTIMPL; + } + + int GetTypeInfo(int iTInfo, int lcid, int ppTInfo) { + if (debug) + System.out.println("GetTypeInfo"); + return COM.E_NOTIMPL; + } + + int GetIDsOfNames(int riid, int rgszNames, int cNames, int lcid, int rgDispId) { + if (debug) + System.out.println("GetIDsOfNames"); + return COM.E_NOTIMPL; + } + + int Invoke(int dispIdMember, int riid, int lcid, int dwFlags, int pDispParams, int pVarResult, int pExcepInfo, int pArgErr) { + if (debug) + System.out.println("Invoke"); + return COM.E_NOTIMPL; + } + + int accDoDefaultAction(int varChild_vt, int varChild_reserved1, int varChild_lVal, int varChild_reserved2) { + if (debug) + System.out.println("accDoDefaultAction " + varChild_vt + " " + varChild_lVal); + // must implement this for the items because they have a default action + return iaccessible.accDoDefaultAction(varChild_vt, varChild_reserved1, varChild_lVal, varChild_reserved2); + } + + int accHitTest(int xLeft, int yTop, int pvarChild) { + if (debug) + System.out.println("accHitTest " + xLeft + " " + yTop + " " + pvarChild); + + AccessibleControlEvent event = new AccessibleControlEvent(this); + event.x = xLeft; + event.y = yTop; + for (int i = 0; i < accessibleControlListeners.size(); i++) { + AccessibleControlListener listener = (AccessibleControlListener) accessibleControlListeners.elementAt(i); + listener.accHitTest(event); + } + int childID = event.childID; + if (childID == ACC.CHILDID_NONE) { + COM.MoveMemory(pvarChild, new short[] { COM.VT_EMPTY }, 2); + return COM.S_FALSE; + } + COM.MoveMemory(pvarChild, new short[] { COM.VT_I4 }, 2); + COM.MoveMemory(pvarChild + 8, new int[] { childID }, 4); + return COM.S_OK; + } + + int accLocation(int pxLeft, int pyTop, int pcxWidth, int pcyHeight, int varChild_vt, int varChild_reserved1, int varChild_lVal, int varChild_reserved2) { + if (debug) + System.out.println("accLocation " + pxLeft + " " + pyTop + " " + pcxWidth + " " + pcyHeight + " " + varChild_vt + " " + varChild_lVal); + + if ((varChild_vt & 0xFFFF) != COM.VT_I4) return COM.E_INVALIDARG; + AccessibleControlEvent event = new AccessibleControlEvent(this); + event.childID = varChild_lVal; + for (int i = 0; i < accessibleControlListeners.size(); i++) { + AccessibleControlListener listener = (AccessibleControlListener) accessibleControlListeners.elementAt(i); + listener.accLocation(event); + } + OS.MoveMemory(pxLeft, new int[] { event.x }, 4); + OS.MoveMemory(pyTop, new int[] { event.y }, 4); + OS.MoveMemory(pcxWidth, new int[] { event.width }, 4); + OS.MoveMemory(pcyHeight, new int[] { event.height }, 4); + return COM.S_OK; + } + + int accNavigate(int navDir, int varStart_vt, int varStart_reserved1, int varStart_lVal, int varStart_reserved2, int pvarEndUpAt) { + if (debug) + System.out.println("accNavigate " + navDir + " " + varStart_vt + " " + varStart_lVal + " " + pvarEndUpAt); + + if (varStart_vt != COM.VT_I4) return COM.E_INVALIDARG; + switch (navDir) { + case ACC.NAVDIR_FIRSTCHILD: + case ACC.NAVDIR_LASTCHILD: + if (varStart_lVal != ACC.CHILDID_SELF) return COM.E_INVALIDARG; + case ACC.NAVDIR_UP: + case ACC.NAVDIR_DOWN: + case ACC.NAVDIR_LEFT: + case ACC.NAVDIR_PREVIOUS: + case ACC.NAVDIR_RIGHT: + case ACC.NAVDIR_NEXT: + break; + default: return COM.E_INVALIDARG; + } + AccessibleControlEvent event = new AccessibleControlEvent(this); + event.code = navDir; + event.childID = varStart_lVal; + for (int i = 0; i < accessibleControlListeners.size(); i++) { + AccessibleControlListener listener = (AccessibleControlListener) accessibleControlListeners.elementAt(i); + listener.accNavigate(event); + } + Accessible accessible = event.accessible; + if (accessible != null) { + COM.MoveMemory(pvarEndUpAt, new short[] { COM.VT_DISPATCH }, 2); + COM.MoveMemory(pvarEndUpAt + 8, new int[] { accessible.objIAccessible.getAddress() }, 4); + return COM.S_OK; + } + int childID = event.childID; + if (childID == ACC.CHILDID_NONE) { + COM.MoveMemory(pvarEndUpAt, new short[] { COM.VT_EMPTY }, 2); + return COM.S_FALSE; + } + if (childID == ACC.CHILDID_SELF) { + COM.MoveMemory(pvarEndUpAt, new short[] { COM.VT_DISPATCH }, 2); + COM.MoveMemory(pvarEndUpAt + 8, new int[] { objIAccessible.getAddress() }, 4); + return COM.S_OK; + } + COM.MoveMemory(pvarEndUpAt, new short[] { COM.VT_I4 }, 2); + COM.MoveMemory(pvarEndUpAt + 8, new int[] { childID }, 4); + return COM.S_OK; + } + + int accSelect(int flagsSelect, int varChild_vt, int varChild_reserved1, int varChild_lVal, int varChild_reserved2) { + if (debug) + System.out.println("accSelect " + flagsSelect + " " + varChild_vt + " " + varChild_lVal); + // must implement for the items because they support selection + return iaccessible.accSelect(flagsSelect, varChild_vt, varChild_reserved1, varChild_lVal, varChild_reserved2); + } + + int get_accChild(int varChild_vt, int varChild_reserved1, int varChild_lVal, int varChild_reserved2, int ppdispChild) { + if (debug) + System.out.println("get_accChild " + varChild_vt + " " + varChild_lVal + " " + ppdispChild); + + if ((varChild_vt & 0xFFFF) != COM.VT_I4) return COM.E_INVALIDARG; + AccessibleControlEvent event = new AccessibleControlEvent(this); + event.childID = varChild_lVal; + for (int i = 0; i < accessibleControlListeners.size(); i++) { + AccessibleControlListener listener = (AccessibleControlListener) accessibleControlListeners.elementAt(i); + listener.getChild(event); + } + if (debug) + System.out.println("get_accChild returned: " + event); + Accessible accessible = event.accessible; + if (accessible != null) { + COM.MoveMemory(ppdispChild, new int[] { accessible.objIAccessible.getAddress() }, 4); + return COM.S_OK; + } + return COM.S_FALSE; + } + + int get_accChildCount(int pcountChildren) { + if (debug) + System.out.println("get_accChildCount " + pcountChildren); + + AccessibleControlEvent event = new AccessibleControlEvent(this); + for (int i = 0; i < accessibleControlListeners.size(); i++) { + AccessibleControlListener listener = (AccessibleControlListener) accessibleControlListeners.elementAt(i); + listener.getChildCount(event); + } + + COM.MoveMemory(pcountChildren, new int[] { event.code }, 4); + return COM.S_OK; + } + + int get_accDefaultAction(int varChild_vt, int varChild_reserved1, int varChild_lVal, int varChild_reserved2, int pszDefaultAction) { + if (debug) + System.out.println("get_accDefaultAction " + varChild_vt + " " + varChild_lVal + " " + pszDefaultAction); + + if ((varChild_vt & 0xFFFF) != COM.VT_I4) return COM.E_INVALIDARG; + AccessibleControlEvent event = new AccessibleControlEvent(this); + event.childID = varChild_lVal; + for (int i = 0; i < accessibleControlListeners.size(); i++) { + AccessibleControlListener listener = (AccessibleControlListener) accessibleControlListeners.elementAt(i); + listener.getDefaultAction(event); + } + if (event.result == null) return COM.S_FALSE; + char[] data = (event.result + "\0").toCharArray(); + int ptr = COM.SysAllocString(data); + COM.MoveMemory(pszDefaultAction, new int[] { ptr }, 4); + return COM.S_OK; + } + + int get_accDescription(int varChild_vt, int varChild_reserved1, int varChild_lVal, int varChild_reserved2, int pszDescription) { + if (debug) + System.out.println("get_accDescription " + varChild_vt + " " + varChild_lVal + " " + pszDescription); + + if ((varChild_vt & 0xFFFF) != COM.VT_I4) return COM.E_INVALIDARG; + AccessibleEvent event = new AccessibleEvent(this); + event.childID = varChild_lVal; + for (int i = 0; i < accessibleListeners.size(); i++) { + AccessibleListener listener = (AccessibleListener) accessibleListeners.elementAt(i); + listener.getDescription(event); + } + if (event.result == null) return COM.S_FALSE; + char[] data = (event.result + "\0").toCharArray(); + int ptr = COM.SysAllocString(data); + COM.MoveMemory(pszDescription, new int[] { ptr }, 4); + return COM.S_OK; + } + + int get_accFocus(int pvarChild) { + if (debug) + System.out.println("get_accFocus " + pvarChild); + + AccessibleControlEvent event = new AccessibleControlEvent(this); + for (int i = 0; i < accessibleControlListeners.size(); i++) { + AccessibleControlListener listener = (AccessibleControlListener) accessibleControlListeners.elementAt(i); + listener.getFocus(event); + } + Accessible accessible = event.accessible; + if (accessible != null) { + COM.MoveMemory(pvarChild, new short[] { COM.VT_DISPATCH }, 2); + COM.MoveMemory(pvarChild + 8, new int[] { accessible.objIAccessible.getAddress() }, 4); + return COM.S_OK; + } + int childID = event.childID; + if (childID == ACC.CHILDID_NONE) { + COM.MoveMemory(pvarChild, new short[] { COM.VT_EMPTY }, 2); + return COM.S_FALSE; + } + if (childID == ACC.CHILDID_SELF) { + COM.MoveMemory(pvarChild, new short[] { COM.VT_DISPATCH }, 2); + COM.MoveMemory(pvarChild + 8, new int[] { objIAccessible.getAddress() }, 4); + return COM.S_OK; + } + COM.MoveMemory(pvarChild, new short[] { COM.VT_I4 }, 2); + COM.MoveMemory(pvarChild + 8, new int[] { childID }, 4); + return COM.S_OK; + } + + int get_accHelp(int varChild_vt, int varChild_reserved1, int varChild_lVal, int varChild_reserved2, int pszHelp) { + if (debug) + System.out.println("get_accHelp " + varChild_vt + " " + varChild_lVal + " " + pszHelp); + + if ((varChild_vt & 0xFFFF) != COM.VT_I4) return COM.E_INVALIDARG; + AccessibleEvent event = new AccessibleEvent(this); + event.childID = varChild_lVal; + for (int i = 0; i < accessibleListeners.size(); i++) { + AccessibleListener listener = (AccessibleListener) accessibleListeners.elementAt(i); + listener.getHelp(event); + } + if (event.result == null) return COM.S_FALSE; + char[] data = (event.result + "\0").toCharArray(); + int ptr = COM.SysAllocString(data); + COM.MoveMemory(pszHelp, new int[] { ptr }, 4); + return COM.S_OK; + } + + int get_accHelpTopic(int pszHelpFile, int varChild_vt, int varChild_reserved1, int varChild_lVal, int varChild_reserved2, int pidTopic) { + if (debug) + System.out.println("get_accHelpTopic " + pszHelpFile + " " + varChild_vt + " " + varChild_lVal + " " + pidTopic); + return COM.S_FALSE; + } + + int get_accKeyboardShortcut(int varChild_vt, int varChild_reserved1, int varChild_lVal, int varChild_reserved2, int pszKeyboardShortcut) { + if (debug) + System.out.println("get_accKeyboardShortcut " + pszKeyboardShortcut); + + if ((varChild_vt & 0xFFFF) != COM.VT_I4) return COM.E_INVALIDARG; + AccessibleEvent event = new AccessibleEvent(this); + event.childID = varChild_lVal; + for (int i = 0; i < accessibleListeners.size(); i++) { + AccessibleListener listener = (AccessibleListener) accessibleListeners.elementAt(i); + listener.getKeyboardShortcut(event); + } + if (event.result == null) return COM.S_FALSE; + char[] data = (event.result + "\0").toCharArray(); + int ptr = COM.SysAllocString(data); + COM.MoveMemory(pszKeyboardShortcut, new int[] { ptr }, 4); + return COM.S_OK; + } + + int get_accName(int varChild_vt, int varChild_reserved1, int varChild_lVal, int varChild_reserved2, int pszName) { + if (debug) + System.out.println("get_accName " + varChild_vt + " " + varChild_lVal + " " + pszName); + + if ((varChild_vt & 0xFFFF) != COM.VT_I4) return COM.E_INVALIDARG; + AccessibleEvent event = new AccessibleEvent(this); + event.childID = varChild_lVal; + for (int i = 0; i < accessibleListeners.size(); i++) { + AccessibleListener listener = (AccessibleListener) accessibleListeners.elementAt(i); + listener.getName(event); + } + if (debug) + System.out.println("get_accName returned: " + event); + if (event.result == null) return COM.S_FALSE; + char[] data = (event.result + "\0").toCharArray(); + int ptr = COM.SysAllocString(data); + COM.MoveMemory(pszName, new int[] { ptr }, 4); + return COM.S_OK; + } + + int get_accParent(int ppdispParent) { + return iaccessible.get_accParent(ppdispParent); + } + + int get_accRole(int varChild_vt, int varChild_reserved1, int varChild_lVal, int varChild_reserved2, int pvarRole) { + if (debug) + System.out.println("get_accRole " + varChild_vt + " " + varChild_lVal + " " + pvarRole); + + if ((varChild_vt & 0xFFFF) != COM.VT_I4) return COM.E_INVALIDARG; + AccessibleControlEvent event = new AccessibleControlEvent(this); + event.childID = varChild_lVal; + for (int i = 0; i < accessibleControlListeners.size(); i++) { + AccessibleControlListener listener = (AccessibleControlListener) accessibleControlListeners.elementAt(i); + listener.getRole(event); + } + if (debug) + System.out.println("get_accRole returned: " + event); + int role = event.code; + COM.MoveMemory(pvarRole, new short[] { COM.VT_I4 }, 2); + COM.MoveMemory(pvarRole + 8, new int[] { role }, 4); + return COM.S_OK; + } + + int get_accSelection(int pvarChildren) { + if (debug) + System.out.println("get_accSelection " + pvarChildren); + + AccessibleControlEvent event = new AccessibleControlEvent(this); + event.childID = ACC.CHILDID_NONE; + for (int i = 0; i < accessibleControlListeners.size(); i++) { + AccessibleControlListener listener = (AccessibleControlListener) accessibleControlListeners.elementAt(i); + listener.getSelection(event); + } + if (debug) + System.out.println("get_accSelection returned: " + event); + Accessible accessible = event.accessible; + if (accessible != null) { + COM.MoveMemory(pvarChildren, new short[] { COM.VT_DISPATCH }, 2); + COM.MoveMemory(pvarChildren + 8, new int[] { accessible.objIAccessible.getAddress() }, 4); + return COM.S_OK; + } + int childID = event.childID; + if (childID == ACC.CHILDID_NONE) { + COM.MoveMemory(pvarChildren, new short[] { COM.VT_EMPTY }, 2); + return COM.S_FALSE; + } + if (childID == ACC.CHILDID_MULTIPLE) { + COM.MoveMemory(pvarChildren, new short[] { COM.VT_UNKNOWN }, 2); + /* Supposed to return an IEnumVARIANT for this... so the next line is wrong... need a better API here... */ + COM.MoveMemory(pvarChildren + 8, new int[] { objIAccessible.getAddress() }, 4); + return COM.S_OK; + } + if (childID == ACC.CHILDID_SELF) { + COM.MoveMemory(pvarChildren, new short[] { COM.VT_DISPATCH }, 2); + COM.MoveMemory(pvarChildren + 8, new int[] { objIAccessible.getAddress() }, 4); + return COM.S_OK; + } + COM.MoveMemory(pvarChildren, new short[] { COM.VT_I4 }, 2); + COM.MoveMemory(pvarChildren + 8, new int[] { childID }, 4); + return COM.S_OK; + } + + int get_accState(int varChild_vt, int varChild_reserved1, int varChild_lVal, int varChild_reserved2, int pvarState) { + if (debug) + System.out.println("get_accState " + varChild_vt + " " + varChild_lVal + " " + pvarState); + + if ((varChild_vt & 0xFFFF) != COM.VT_I4) return COM.E_INVALIDARG; + AccessibleControlEvent event = new AccessibleControlEvent(this); + event.childID = varChild_lVal; + for (int i = 0; i < accessibleControlListeners.size(); i++) { + AccessibleControlListener listener = (AccessibleControlListener) accessibleControlListeners.elementAt(i); + listener.getState(event); + } + if (debug) + System.out.println("get_accState returned: " + event); + int state = event.code; + COM.MoveMemory(pvarState, new short[] { COM.VT_I4 }, 2); + COM.MoveMemory(pvarState + 8, new int[] { state }, 4); + return COM.S_OK; + } + + int get_accValue(int varChild_vt, int varChild_reserved1, int varChild_lVal, int varChild_reserved2, int pszValue) { + if (debug) + System.out.println("get_accValue " + varChild_vt + " " + varChild_lVal + " " + pszValue); + + AccessibleControlEvent event = new AccessibleControlEvent(this); + event.childID = varChild_lVal; + for (int i = 0; i < accessibleControlListeners.size(); i++) { + AccessibleControlListener listener = (AccessibleControlListener) accessibleControlListeners.elementAt(i); + listener.getValue(event); + } + if (event.result == null) return COM.S_FALSE; + char[] data = (event.result + "\0").toCharArray(); + int ptr = COM.SysAllocString(data); + COM.MoveMemory(pszValue, new int[] { ptr }, 4); + return COM.S_OK; + } + + int put_accName(int varChild_vt, int varChild_reserved1, int varChild_lVal, int varChild_reserved2, int szName) { + // this method is no longer supported + if (debug) + System.out.println("put_accName " + varChild_vt + " " + varChild_lVal + " " + szName); + return iaccessible.put_accName(varChild_vt, varChild_reserved1, varChild_lVal, varChild_reserved2, szName); + } + + int put_accValue(int varChild_vt, int varChild_reserved1, int varChild_lVal, int varChild_reserved2, int szValue) { + // this method is typically only used for edit controls + if (debug) + System.out.println("put_accValue " + varChild_vt + " " + varChild_lVal + " " + szValue); + return iaccessible.put_accValue(varChild_vt, varChild_reserved1, varChild_lVal, varChild_reserved2, szValue); + } + + /* IEnumVARIANT methods: Next, Skip, Reset */ + int Next(int celt, int rgvar, int pceltFetched) { + /* Retrieve the next celt items in the enumeration sequence. + * If there are fewer than the requested number of elements left + * in the sequence, retrieve the remaining elements. + * The number of elements actually retrieved is returned in pceltFetched + * (unless the caller passed in NULL for that parameter). + */ + if (debug) + System.out.println("Next " + celt + " " + rgvar + " " + pceltFetched); + + if (rgvar == 0) return COM.E_INVALIDARG; + if (pceltFetched == 0 && celt != 1) return COM.E_INVALIDARG; + + Object[] nextItems = null; + if (variants != null && celt >= 1) { + int endIndex = enumIndex + celt - 1; + if (endIndex > (variants.length - 1)) endIndex = variants.length - 1; + if (enumIndex <= endIndex) { + nextItems = new Object[endIndex - enumIndex + 1]; + for (int i = 0; i < nextItems.length; i++) { + nextItems[i] = variants[enumIndex]; + enumIndex++; + } + } + } + if (nextItems != null) { + for (int i = 0; i < nextItems.length; i++) { + Object nextItem = nextItems[i]; + if (nextItem instanceof Integer) { + int item = ((Integer) nextItem).intValue(); + COM.MoveMemory(rgvar + i * 16, new short[] { COM.VT_I4 }, 2); + COM.MoveMemory(rgvar + i * 16 + 8, new int[] { item }, 4); + } else { + int address = ((Accessible) nextItem).objIAccessible.getAddress(); + COM.MoveMemory(rgvar + i * 16, new short[] { COM.VT_DISPATCH }, 2); + COM.MoveMemory(rgvar + i * 16 + 8, new int[] { address }, 4); + } + } + if (pceltFetched != 0) + COM.MoveMemory(pceltFetched, new int[] {nextItems.length}, 4); + if (nextItems.length == celt) return COM.S_OK; + } else { + if (pceltFetched != 0) + COM.MoveMemory(pceltFetched, new int[] {0}, 4); + } + return COM.S_FALSE; + } + + int Skip(int celt) { + /* Skip over the specified number of elements in the enumeration sequence. */ + if (debug) + System.out.println("Skip " + celt); + + if (celt < 1 ) return COM.E_INVALIDARG; + enumIndex += celt; + if (enumIndex > (variants.length - 1)) { + enumIndex = variants.length - 1; + return COM.S_FALSE; + } + return COM.S_OK; + } + + int Reset() { + /* Reset the enumeration sequence to the beginning. */ + if (debug) + System.out.println("Reset"); + + enumIndex = 0; + return COM.S_OK; + } +} diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Control.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Control.java index 517c5058b3..424a5cb119 100755 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Control.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Control.java @@ -10,8 +10,6 @@ import org.eclipse.swt.graphics.*; import org.eclipse.swt.*; import org.eclipse.swt.events.*; -import org.eclipse.swt.accessibility.*; - /** * Control is the abstract superclass of all windowed user interface classes. *

@@ -42,6 +40,11 @@ public abstract class Control extends Widget implements Drawable { String toolTipText; Object layoutData; +/* Start ACCESSIBILITY */ + Accessible accessible; +/* End ACCESSIBILITY */ + + /** * Prevents uninitialized instances from being created outside the package. */ @@ -569,6 +572,28 @@ public boolean forceFocus () { return true; } +/* Start ACCESSIBILITY */ +/** + * Returns the accessible object for the receiver. + * If this is the first time this object is requested, + * then the object is created and returned. + * + * @return the accessible object + * + * @exception SWTException

+ */ +public Accessible getAccessibleObject () { + checkWidget (); + if (accessible == null) { + accessible = new Accessible(this); + } + return accessible; +} +/* End ACCESSIBILITY */ + /** * Returns the receiver's background color. * @@ -2634,7 +2659,9 @@ int windowProc (int msg, int wParam, int lParam) { case OS.WM_IME_COMPOSITION: result = WM_IME_COMPOSITION (wParam, lParam); break; case OS.WM_INITMENUPOPUP: result = WM_INITMENUPOPUP (wParam, lParam); break; case OS.WM_GETFONT: result = WM_GETFONT (wParam, lParam); break; +/* Start ACCESSIBILITY */ case OS.WM_GETOBJECT: result = WM_GETOBJECT (wParam, lParam); break; +/* End ACCESSIBILITY */ case OS.WM_KEYDOWN: result = WM_KEYDOWN (wParam, lParam); break; case OS.WM_KEYUP: result = WM_KEYUP (wParam, lParam); break; case OS.WM_KILLFOCUS: result = WM_KILLFOCUS (wParam, lParam); break; @@ -2816,12 +2843,17 @@ LRESULT WM_GETFONT (int wParam, int lParam) { return null; } +/* Start ACCESSIBILITY */ LRESULT WM_GETOBJECT (int wParam, int lParam) { - Event event = new Event (); - event.data = new int [] {lParam, wParam}; - sendEvent (SWT.AccessAccessibility, event); - return new LRESULT(event.detail); + if (accessible != null) { + int result = accessible.WM_GETOBJECT (wParam, lParam); + if (result != 0) { + return new LRESULT(result); + } + } + return null; } +/* End ACCESSIBILITY */ LRESULT WM_HELP (int wParam, int lParam) { if (OS.IsWinCE) return null; -- cgit v1.2.3