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 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); }
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 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; }
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; } } }
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; }
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 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; }
static int /*long*/ atkObject_get_n_children (int /*long*/ atkObject) { if (DEBUG) print ("-->atkObject_get_n_children: " + atkObject); AccessibleObject object = getAccessibleObject (atkObject); int /*long*/ parentResult = 0; AtkObjectClass objectClass = getObjectClass (atkObject); if (objectClass.get_n_children != 0) { parentResult = ATK.call (objectClass.get_n_children, atkObject); } if (object != null && object.id == ACC.CHILDID_SELF) { Accessible accessible = object.accessible; List<AccessibleControlListener> listeners = accessible.accessibleControlListeners; int length = size(listeners); if (length > 0) { AccessibleControlEvent event = new AccessibleControlEvent (accessible); event.childID = object.id; event.detail = (int)/*64*/parentResult; for (int i = 0; i < length; i++) { AccessibleControlListener listener = listeners.get (i); listener.getChildCount (event); } if (DEBUG) print ("--->" + event.detail); return event.detail; } } return parentResult; }
String getText () { List<AccessibleControlListener> listeners = accessible.accessibleControlListeners; int length = size(listeners); if (length > 0) { String parentText = ""; //$NON-NLS-1$ AtkTextIface iface = getTextIface (handle); if (iface != null && iface.get_character_count != 0) { long /*int*/ characterCount = ATK.call (iface.get_character_count, handle); if (characterCount > 0 && iface.get_text != 0) { long /*int*/ parentResult = ATK.call (iface.get_text, handle, 0, characterCount); if (parentResult != 0) { parentText = getString (parentResult); OS.g_free(parentResult); } } } AccessibleControlEvent event = new AccessibleControlEvent (accessible); event.childID = id; event.result = parentText; for (int i = 0; i < length; i++) { AccessibleControlListener listener = listeners.get (i); listener.getValue (event); } return event.result; } return null; }
String getText () { List<AccessibleControlListener> listeners = accessible.accessibleControlListeners; int length = size(listeners); if (length > 0) { String parentText = ""; //$NON-NLS-1$ AtkTextIface iface = getTextIface (handle); if (iface != null && iface.get_character_count != 0) { int /*long*/ characterCount = ATK.call (iface.get_character_count, handle); if (characterCount > 0 && iface.get_text != 0) { int /*long*/ parentResult = ATK.call (iface.get_text, handle, 0, characterCount); if (parentResult != 0) { parentText = getString (parentResult); OS.g_free(parentResult); } } } AccessibleControlEvent event = new AccessibleControlEvent (accessible); event.childID = id; event.result = parentText; for (int i = 0; i < length; i++) { AccessibleControlListener listener = listeners.get (i); listener.getValue (event); } return event.result; } return null; }
static int /*long*/ atkObject_get_n_children (int /*long*/ atkObject) { if (DEBUG) print ("-->atkObject_get_n_children: " + atkObject); AccessibleObject object = getAccessibleObject (atkObject); int /*long*/ parentResult = 0; AtkObjectClass objectClass = getObjectClass (atkObject); if (objectClass.get_n_children != 0) { parentResult = ATK.call (objectClass.get_n_children, atkObject); } if (object != null && object.id == ACC.CHILDID_SELF) { Accessible accessible = object.accessible; List<AccessibleControlListener> listeners = accessible.accessibleControlListeners; int length = size(listeners); if (length > 0) { AccessibleControlEvent event = new AccessibleControlEvent (accessible); event.childID = object.id; event.detail = (int)/*64*/parentResult; for (int i = 0; i < length; i++) { AccessibleControlListener listener = listeners.get (i); listener.getChildCount (event); } if (DEBUG) print ("--->" + event.detail); return event.detail; } } return parentResult; }
static long /*int*/ atkObject_get_n_children (long /*int*/ atkObject) { if (DEBUG) print ("-->atkObject_get_n_children: " + atkObject); AccessibleObject object = getAccessibleObject (atkObject); long /*int*/ parentResult = 0; AtkObjectClass objectClass = getObjectClass (atkObject); if (objectClass.get_n_children != 0) { parentResult = ATK.call (objectClass.get_n_children, atkObject); } if (object != null && object.id == ACC.CHILDID_SELF) { Accessible accessible = object.accessible; List<AccessibleControlListener> listeners = accessible.accessibleControlListeners; int length = size(listeners); if (length > 0) { AccessibleControlEvent event = new AccessibleControlEvent (accessible); event.childID = object.id; event.detail = (int)/*64*/parentResult; for (int i = 0; i < length; i++) { AccessibleControlListener listener = listeners.get (i); listener.getChildCount (event); } if (DEBUG) print ("--->" + event.detail); return event.detail; } } return parentResult; }