int getRole() { AccessibleControlEvent event = new AccessibleControlEvent(this); event.childID = ACC.CHILDID_SELF; for (int i = 0; i < accessibleControlListenersSize(); i++) { AccessibleControlListener listener = accessibleControlListeners.get(i); listener.getRole(event); } return event.detail; }
void checkUniqueID(int childID) { /* If the application is using child ids, check whether there's a corresponding * accessible, and if so, use the child id as that accessible's unique id. */ AccessibleControlEvent event = new AccessibleControlEvent(this); event.childID = childID; for (int l = 0; l < accessibleControlListenersSize(); l++) { AccessibleControlListener listener = accessibleControlListeners.get(l); listener.getChild(event); } Accessible accessible = event.accessible; if (accessible != null && accessible.uniqueID == -1) { accessible.uniqueID = childID; } }
NSString getRoleAttribute(int childID) { NSString returnValue = null; AccessibleControlEvent event = new AccessibleControlEvent(this); event.childID = childID; event.detail = -1; for (int i = 0; i < accessibleControlListenersSize(); i++) { AccessibleControlListener listener = (AccessibleControlListener) accessibleControlListeners.elementAt(i); listener.getRole(event); } if (event.detail != -1) { String appRole = roleToOs (event.detail); int index = appRole.indexOf(':'); if (index != -1) appRole = appRole.substring(0, index); returnValue = NSString.stringWith(appRole); } return returnValue; }
id getSubroleAttribute (int childID) { id returnValue = null; AccessibleControlEvent event = new AccessibleControlEvent(this); event.childID = childID; event.detail = -1; for (int i = 0; i < accessibleControlListenersSize(); i++) { AccessibleControlListener listener = (AccessibleControlListener) accessibleControlListeners.elementAt(i); listener.getRole(event); } if (event.detail != -1) { String appRole = roleToOs (event.detail); int index = appRole.indexOf(':'); if (index != -1) { appRole = appRole.substring(index + 1); returnValue = NSString.stringWith(appRole); } } return returnValue; }
id getEnabledAttribute (int childID) { AccessibleControlEvent event = new AccessibleControlEvent(this); event.detail = ACC.STATE_NORMAL; event.childID = childID; for (int i = 0; i < accessibleControlListenersSize(); i++) { AccessibleControlListener listener = (AccessibleControlListener) accessibleControlListeners.elementAt(i); listener.getState(event); } boolean enabled = (event.detail & ACC.STATE_DISABLED) == 0; if (!enabled && delegate == null) enabled = control.isEnabled(); return NSNumber.numberWithBool(enabled); }
int get_accChildCount(int /*long*/ pcountChildren) { int osChildCount = 0; if (iaccessible != null) { /* Get the default child count from the OS. */ int code = iaccessible.get_accChildCount(pcountChildren); if (code == COM.S_OK) { int[] pChildCount = new int[1]; COM.MoveMemory(pChildCount, pcountChildren, 4); osChildCount = pChildCount[0]; } if (accessibleControlListenersSize() == 0) { if (DEBUG) print(this + ".IAccessible::get_accChildCount() returning " + osChildCount + " from super" + hresult(code)); return code; } } AccessibleControlEvent event = new AccessibleControlEvent(this); event.childID = ACC.CHILDID_SELF; event.detail = osChildCount; for (int i = 0; i < accessibleControlListenersSize(); i++) { AccessibleControlListener listener = accessibleControlListeners.get(i); listener.getChildCount(event); } if (DEBUG) print(this + ".IAccessible::get_accChildCount() returning " + event.detail + hresult(COM.S_OK)); COM.MoveMemory(pcountChildren, new int[] { event.detail }, 4); return COM.S_OK; }
int getCharacterCount() { AccessibleTextEvent event = new AccessibleTextEvent(this); event.count = -1; for (int i = 0; i < accessibleTextExtendedListenersSize(); i++) { AccessibleTextExtendedListener listener = accessibleTextExtendedListeners.get(i); listener.getCharacterCount(event); } if (event.count == -1) { AccessibleControlEvent e = new AccessibleControlEvent(this); e.childID = ACC.CHILDID_SELF; for (int i = 0; i < accessibleControlListenersSize(); i++) { AccessibleControlListener listener = accessibleControlListeners.get(i); listener.getRole(e); listener.getValue(e); } // TODO: Consider passing the value through for other roles as well (i.e. combo, etc). Keep in sync with get_text. event.count = e.detail == ACC.ROLE_TEXT && e.result != null ? e.result.length() : 0; } return event.count; }
id getNumberOfCharactersAttribute (int childID) { id returnValue = null; AccessibleTextEvent event = new AccessibleTextEvent(this); event.count = -1; for (int i = 0; i < accessibleTextExtendedListenersSize(); i++) { AccessibleTextExtendedListener listener = (AccessibleTextExtendedListener) accessibleTextExtendedListeners.elementAt(i); listener.getCharacterCount(event); } if (event.count != -1) { AccessibleControlEvent e = new AccessibleControlEvent(this); e.childID = ACC.CHILDID_SELF; for (int i = 0; i < accessibleControlListenersSize(); i++) { AccessibleControlListener listener = (AccessibleControlListener) accessibleControlListeners.elementAt(i); listener.getRole(e); listener.getValue(e); } // TODO: Consider passing the value through for other roles as well (i.e. combo, etc). Keep in sync with get_text. event.count = e.detail == ACC.ROLE_TEXT && e.result != null ? e.result.length() : 0; returnValue = NSNumber.numberWithInt(event.count); } return returnValue; }
id getVisibleCharacterRangeAttribute (int childID) { NSRange range = null; if (accessibleTextExtendedListenersSize() > 0) { AccessibleTextEvent event = new AccessibleTextEvent(this); event.childID = childID; for (int i=0; i<accessibleTextExtendedListenersSize(); i++) { AccessibleTextExtendedListener listener = (AccessibleTextExtendedListener) accessibleTextExtendedListeners.elementAt(i); listener.getVisibleRanges(event); } range = new NSRange(); range.location = event.start; range.length = event.end - event.start; } else if (accessibleControlListenersSize() > 0) { AccessibleControlEvent event = new AccessibleControlEvent(this); event.childID = childID; event.result = null; for (int i = 0; i < accessibleControlListenersSize(); i++) { AccessibleControlListener listener = (AccessibleControlListener) accessibleControlListeners.elementAt(i); listener.getValue(event); } if (event.result != null) { range = new NSRange(); range.location = 0; range.length = event.result.length(); } } return (range != null) ? NSValue.valueWithRange(range) : null; }
id getSizeAttribute (int childID) { id returnValue = null; AccessibleControlEvent event = new AccessibleControlEvent(this); event.childID = childID; event.width = -1; for (int i = 0; i < accessibleControlListenersSize(); i++) { AccessibleControlListener listener = (AccessibleControlListener) accessibleControlListeners.elementAt(i); listener.getLocation(event); } NSSize controlSize = new NSSize (); if (event.width != -1) { controlSize.width = event.width; controlSize.height = event.height; returnValue = NSValue.valueWithSize(controlSize); } else { if (childID != ACC.CHILDID_SELF) { controlSize.width = controlSize.height = 0; returnValue = NSValue.valueWithSize(controlSize); } } return returnValue; }
int Reset() { if (DEBUG) print(this + ".IEnumVARIANT::Reset"); /* If there are no listeners, query the proxy * for its IEnumVariant, and tell it to Reset. */ if (iaccessible != null && accessibleControlListenersSize() == 0) { int /*long*/[] ppvObject = new int /*long*/[1]; int code = (int)/*64*/iaccessible.QueryInterface(COM.IIDIEnumVARIANT, ppvObject); if (code != COM.S_OK) return code; IEnumVARIANT ienumvariant = new IEnumVARIANT(ppvObject[0]); code = ienumvariant.Reset(); ienumvariant.Release(); return code; } enumIndex = 0; return COM.S_OK; }
id getTitleAttribute (int childID) { id returnValue = null; /* * Feature of the Macintosh. The text of a Label is returned in its value, * not its title, so ensure that the role is not Label before asking for the title. */ AccessibleControlEvent roleEvent = new AccessibleControlEvent(this); roleEvent.childID = childID; roleEvent.detail = -1; for (int i = 0; i < accessibleControlListenersSize(); i++) { AccessibleControlListener listener = (AccessibleControlListener) accessibleControlListeners.elementAt(i); listener.getRole(roleEvent); } if (roleEvent.detail != ACC.ROLE_LABEL) { AccessibleEvent event = new AccessibleEvent(this); event.childID = childID; event.result = null; for (int i = 0; i < accessibleListenersSize(); i++) { AccessibleListener listener = (AccessibleListener) accessibleListeners.elementAt(i); listener.getName(event); } if (event.result != null) returnValue = NSString.stringWith(event.result); } return returnValue; }
int Skip(int celt) { if (DEBUG) print(this + ".IEnumVARIANT::Skip"); /* If there are no listeners, query the proxy * for its IEnumVariant, and tell it to Skip. */ if (iaccessible != null && accessibleControlListenersSize() == 0) { int /*long*/[] ppvObject = new int /*long*/[1]; int code = iaccessible.QueryInterface(COM.IIDIEnumVARIANT, ppvObject); if (code != COM.S_OK) return code; IEnumVARIANT ienumvariant = new IEnumVARIANT(ppvObject[0]); code = ienumvariant.Skip(celt); ienumvariant.Release(); return code; } 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; }
/** * Return YES if the UIElement doesn't show up to the outside world - * i.e. its parent should return the UIElement's children as its own - * cutting the UIElement out. E.g. NSControls are ignored when they are single-celled. * * <b>IMPORTANT:</b> This field is <em>not</em> part of the SWT * public API. It is marked public only so that it can be shared * within the packages provided by SWT. It is not available on all * platforms and should never be accessed from application code. * </p> * * @noreference This method is not intended to be referenced by clients. */ public boolean internal_accessibilityIsIgnored(int childID) { AccessibleControlEvent event = new AccessibleControlEvent(this); event.childID = childID; event.detail = -1; for (int i = 0; i < accessibleControlListenersSize(); i++) { AccessibleControlListener listener = (AccessibleControlListener) accessibleControlListeners.elementAt(i); listener.getRole(event); } boolean shouldIgnore = (event.detail == -1); if (shouldIgnore) { shouldIgnore = getTitleAttribute(childID) == null && getHelpAttribute(childID) == null && getDescriptionAttribute(childID) == null; } return shouldIgnore; }
int get_states(int /*long*/ pStates) { AccessibleControlEvent event = new AccessibleControlEvent(this); event.childID = ACC.CHILDID_SELF; for (int i = 0; i < accessibleControlListenersSize(); i++) { AccessibleControlListener listener = accessibleControlListeners.get(i); listener.getState(event); } int states = event.detail; int ia2States = 0; if ((states & ACC.STATE_ACTIVE) != 0) ia2States |= COM.IA2_STATE_ACTIVE; if ((states & ACC.STATE_SINGLELINE) != 0) ia2States |= COM.IA2_STATE_SINGLE_LINE; if ((states & ACC.STATE_MULTILINE) != 0) ia2States |= COM.IA2_STATE_MULTI_LINE; if ((states & ACC.STATE_REQUIRED) != 0) ia2States |= COM.IA2_STATE_REQUIRED; if ((states & ACC.STATE_INVALID_ENTRY) != 0) ia2States |= COM.IA2_STATE_INVALID_ENTRY; if ((states & ACC.STATE_SUPPORTS_AUTOCOMPLETION) != 0) ia2States |= COM.IA2_STATE_SUPPORTS_AUTOCOMPLETION; /* If the role is text and there are TextExtendedListeners, then set IA2_STATE_EDITABLE. * Note that IA2_STATE_EDITABLE is not the opposite of STATE_READONLY. * Instead, it means: "has a caret, supports IAccessibleText, and is a text editing environment". */ if (getRole() == ACC.ROLE_TEXT && accessibleTextExtendedListenersSize() > 0) { ia2States |= COM.IA2_STATE_EDITABLE; } if (DEBUG) print(this + ".IAccessible2::get_states returning" + getIA2StatesString(ia2States) + hresult(COM.S_OK)); COM.MoveMemory(pStates, new int [] { ia2States }, 4); return COM.S_OK; }
id getRoleDescriptionAttribute (int childID) { id returnValue = null; AccessibleControlEvent event = new AccessibleControlEvent(this); event.childID = childID; event.detail = -1; for (int i = 0; i < accessibleControlListenersSize(); i++) { AccessibleControlListener listener = (AccessibleControlListener) accessibleControlListeners.elementAt(i); listener.getRole(event); } if (event.detail != -1) { if (event.detail == ACC.ROLE_TABITEM) { returnValue = new NSString(OS.NSAccessibilityRoleDescription (NSString.stringWith("AXTab").id, 0)); } else { String appRole = roleToOs (event.detail); String appSubrole = null; int index = appRole.indexOf(':'); if (index != -1) { appSubrole = appRole.substring(index + 1); appRole = appRole.substring(0, index); } NSString nsAppRole = NSString.stringWith(appRole); NSString nsAppSubrole = null; if (appSubrole != null) nsAppSubrole = NSString.stringWith(appSubrole); returnValue = new NSString(OS.NSAccessibilityRoleDescription (((nsAppRole != null) ? nsAppRole.id : 0), (nsAppSubrole != null) ? nsAppSubrole.id : 0)); } } return returnValue; }
id getFocusedAttribute (int childID) { AccessibleControlEvent event = new AccessibleControlEvent(this); event.childID = ACC.CHILDID_MULTIPLE; // set to invalid value, to test if the application sets it in getFocus() for (int i = 0; i < accessibleControlListenersSize(); i++) { AccessibleControlListener listener = (AccessibleControlListener) accessibleControlListeners.elementAt(i); listener.getFocus(event); } /* The application can optionally answer an accessible. */ if (event.accessible != null) { boolean hasFocus = (event.accessible.index == childID) && (event.accessible.control == this.control); return NSNumber.numberWithBool(hasFocus); } /* Or the application can answer a valid child ID, including CHILDID_SELF and CHILDID_NONE. */ if (event.childID == ACC.CHILDID_SELF) { return NSNumber.numberWithBool(true); } if (event.childID == ACC.CHILDID_NONE) { return NSNumber.numberWithBool(false); } if (event.childID != ACC.CHILDID_MULTIPLE) { /* Other valid childID. */ return NSNumber.numberWithBool(event.childID == childID); } // Invalid childID at this point means the application did not implement getFocus, so // let the default handler return the native focus. return null; }
id getLineForIndexParameterizedAttribute (id parameter, int childID) { id returnValue = null; NSNumber charNumberObj = new NSNumber(parameter.id); int charNumber = charNumberObj.intValue(); if (accessibleTextExtendedListenersSize() > 0) { AccessibleTextEvent event = new AccessibleTextEvent(this); event.childID = childID; event.start = charNumber; event.end = charNumber; event.count = Integer.MIN_VALUE; event.type = ACC.TEXT_BOUNDARY_LINE; for (int i = 0; i < accessibleTextExtendedListenersSize(); i++) { AccessibleTextExtendedListener listener = (AccessibleTextExtendedListener) accessibleTextExtendedListeners.elementAt(i); listener.getText(event); } returnValue = NSNumber.numberWithInt(Math.max(0, -event.count)); } else { AccessibleControlEvent controlEvent = new AccessibleControlEvent(this); controlEvent.childID = childID; controlEvent.result = null; for (int i = 0; i < accessibleControlListenersSize(); i++) { AccessibleControlListener listener = (AccessibleControlListener) accessibleControlListeners.elementAt(i); listener.getValue(controlEvent); } String text = controlEvent.result; if (text != null) returnValue = NSNumber.numberWithInt(lineNumberForOffset(text, charNumber)); } return returnValue; }
int Clone(int /*long*/ ppEnum) { if (DEBUG) print(this + ".IEnumVARIANT::Clone"); /* If there are no listeners, query the proxy for * its IEnumVariant, and get the Clone from it. */ if (iaccessible != null && accessibleControlListenersSize() == 0) { int /*long*/[] ppvObject = new int /*long*/[1]; int code = iaccessible.QueryInterface(COM.IIDIEnumVARIANT, ppvObject); if (code != COM.S_OK) return code; IEnumVARIANT ienumvariant = new IEnumVARIANT(ppvObject[0]); int /*long*/ [] pEnum = new int /*long*/ [1]; code = ienumvariant.Clone(pEnum); ienumvariant.Release(); COM.MoveMemory(ppEnum, pEnum, OS.PTR_SIZEOF); return code; } if (ppEnum == 0) return COM.E_INVALIDARG; COM.MoveMemory(ppEnum, new int /*long*/[] { objIEnumVARIANT.getAddress() }, OS.PTR_SIZEOF); AddRef(); return COM.S_OK; }
event.width = -1; for (int i = 0; i < accessibleControlListenersSize(); i++) { AccessibleControlListener listener = (AccessibleControlListener) accessibleControlListeners.elementAt(i); listener.getLocation(event);