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; }
public void getChildAtPoint(AccessibleControlEvent e) { NSPoint testPoint = new NSPoint(); testPoint.x = e.x; Monitor primaryMonitor = Display.getCurrent().getPrimaryMonitor(); testPoint.y = (int) (primaryMonitor.getBounds().height - e.y); Iterator iter = childRowToIdMap.values().iterator(); while (iter.hasNext()) { AccessibleTableRow row = (AccessibleTableRow) iter.next(); NSValue locationValue = new NSValue(row.getPositionAttribute(ACC.CHILDID_SELF).id); NSPoint location = locationValue.pointValue(); NSValue sizeValue = new NSValue(row.getSizeAttribute(ACC.CHILDID_SELF)); NSSize size = sizeValue.sizeValue(); if (location.y < testPoint.y && testPoint.y < (location.y + size.height)) { AccessibleControlEvent e2 = new AccessibleControlEvent(e.getSource()); e2.x = (int) testPoint.x; e2.y = (int) testPoint.y; row.getChildAtPoint(e); break; } } }
public void getChildren(AccessibleControlEvent e) { int validColumnCount = Math.max (1, parent.getColumnCount()); Accessible[] children = new Accessible[validColumnCount]; AccessibleControlEvent event = new AccessibleControlEvent(this); for (int i = 0; i < validColumnCount; i++) { event.childID = i; event.detail = ACC.CHILDID_CHILD_AT_INDEX; for (int j = 0; j < parent.accessibleControlListeners.size(); j++) { AccessibleControlListener listener = (AccessibleControlListener) parent.accessibleControlListeners.elementAt(j); listener.getChild(event); } event.accessible.parent = AccessibleTableHeader.this; children[i] = event.accessible; } e.children = children; } public void getChildCount(AccessibleControlEvent e) {
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); }
public void getLocation(AccessibleControlEvent e) { Accessible[] cells = AccessibleTableColumn.this.getColumnCells(); // Ask first row for position. AccessibleControlEvent event = new AccessibleControlEvent(this); event.childID = ACC.CHILDID_SELF; event.width = -1; Accessible child = cells[0]; for (int i = 0; i < child.accessibleControlListeners.size(); i++) { AccessibleControlListener listener = (AccessibleControlListener) child.accessibleControlListeners.elementAt(i); listener.getLocation(event); } // Ask all children for size. int height = 0; int width = 0; for (int j = 0; j < cells.length; j++) { NSValue sizeObj = (NSValue)cells[j].getSizeAttribute(ACC.CHILDID_SELF); NSSize size = sizeObj.sizeValue(); if (size.width > width) width = (int) size.width; height += size.height; } e.x = event.x; e.y = event.y; e.width = width; e.height = height; } public void getRole(AccessibleControlEvent e) {
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; }
int get_indexInParent(int /*long*/ pIndexInParent) { AccessibleControlEvent event = new AccessibleControlEvent(this); event.childID = ACC.CHILDID_CHILD_INDEX; event.detail = -1;
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; }
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; }
/** * 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; }
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; }
void updateChildren () { List<AccessibleControlListener> listeners = accessible.accessibleControlListeners; int length = size(listeners); AccessibleControlEvent event = new AccessibleControlEvent (accessible); event.childID = id; for (int i = 0; i < length; i++) { object = oldChildren != null && i < oldChildren.length ? oldChildren [i] : null; if (object == null || object.id != id) { event = new AccessibleControlEvent (accessible); event.childID = id; for (int j = 0; j < length; j++) {
void updateChildren () { List<AccessibleControlListener> listeners = accessible.accessibleControlListeners; int length = size(listeners); AccessibleControlEvent event = new AccessibleControlEvent (accessible); event.childID = id; for (int i = 0; i < length; i++) { object = oldChildren != null && i < oldChildren.length ? oldChildren [i] : null; if (object == null || object.id != id) { event = new AccessibleControlEvent (accessible); event.childID = id; for (int j = 0; j < length; j++) {
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; }