Mercurial > projects > dwt-mac
annotate dwt/accessibility/Accessible.d @ 151:0ba75290f8ce
Added a bunch of missing defaults to switch statements
author | Jacob Carlborg <doob@me.com> |
---|---|
date | Wed, 10 Jun 2009 21:52:31 +0200 |
parents | ad4e1fe71a5a |
children |
rev | line source |
---|---|
45 | 1 /******************************************************************************* |
2 * Copyright (c) 2000, 2008 IBM Corporation and others. | |
0
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
3 * All rights reserved. This program and the accompanying materials |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
4 * are made available under the terms of the Eclipse Public License v1.0 |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
5 * which accompanies this distribution, and is available at |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
6 * http://www.eclipse.org/legal/epl-v10.html |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
7 * |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
8 * Contributors: |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
9 * IBM Corporation - initial API and implementation |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
10 * |
13
f565d3a95c0a
Ported dwt.internal
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
0
diff
changeset
|
11 * Port to the D programming language: |
45 | 12 * Jacob Carlborg <doob@me.com> |
0
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
13 *******************************************************************************/ |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
14 module dwt.accessibility.Accessible; |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
15 |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
16 import dwt.dwthelper.utils; |
45 | 17 |
18 import dwt.DWT; | |
0
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
19 import dwt.DWTException; |
45 | 20 import dwt.graphics.Point; |
21 import dwt.graphics.Rectangle; | |
22 import dwt.internal.cocoa.NSArray; | |
23 import dwt.internal.cocoa.NSMutableArray; | |
24 import dwt.internal.cocoa.NSNumber; | |
25 import dwt.internal.cocoa.NSObject; | |
26 import dwt.internal.cocoa.NSPoint; | |
27 import dwt.internal.cocoa.NSRange; | |
28 import dwt.internal.cocoa.NSSize; | |
29 import dwt.internal.cocoa.NSString; | |
30 import dwt.internal.cocoa.NSValue; | |
31 import dwt.internal.cocoa.OS; | |
58 | 32 import cocoa = dwt.internal.cocoa.id; |
45 | 33 import dwt.widgets.Composite; |
0
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
34 import dwt.widgets.Control; |
45 | 35 import dwt.widgets.Display; |
36 import dwt.widgets.Monitor; | |
37 import dwt.widgets.Shell; | |
0
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
38 |
60
62202ce0039f
Updated and fixed many modules to 3.514
Jacob Carlborg <doob@me.com>
parents:
59
diff
changeset
|
39 import tango.core.Thread; |
58 | 40 import tango.util.container.HashMap; |
41 | |
60
62202ce0039f
Updated and fixed many modules to 3.514
Jacob Carlborg <doob@me.com>
parents:
59
diff
changeset
|
42 import dwt.accessibility.ACC; |
62202ce0039f
Updated and fixed many modules to 3.514
Jacob Carlborg <doob@me.com>
parents:
59
diff
changeset
|
43 import dwt.accessibility.AccessibleControlEvent; |
62202ce0039f
Updated and fixed many modules to 3.514
Jacob Carlborg <doob@me.com>
parents:
59
diff
changeset
|
44 import dwt.accessibility.AccessibleEvent; |
0
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
45 import dwt.accessibility.AccessibleListener; |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
46 import dwt.accessibility.AccessibleControlListener; |
60
62202ce0039f
Updated and fixed many modules to 3.514
Jacob Carlborg <doob@me.com>
parents:
59
diff
changeset
|
47 import dwt.accessibility.AccessibleTextEvent; |
0
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
48 import dwt.accessibility.AccessibleTextListener; |
58 | 49 import dwt.accessibility.SWTAccessibleDelegate; |
129 | 50 import dwt.dwthelper.associativearray; |
0
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
51 |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
52 /** |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
53 * Instances of this class provide a bridge between application |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
54 * code and assistive technology clients. Many platforms provide |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
55 * default accessible behavior for most widgets, and this class |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
56 * allows that default behavior to be overridden. Applications |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
57 * can get the default Accessible object for a control by sending |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
58 * it <code>getAccessible</code>, and then add an accessible listener |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
59 * to override simple items like the name and help string, or they |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
60 * can add an accessible control listener to override complex items. |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
61 * As a rule of thumb, an application would only want to use the |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
62 * accessible control listener to implement accessibility for a |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
63 * custom control. |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
64 * |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
65 * @see Control#getAccessible |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
66 * @see AccessibleListener |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
67 * @see AccessibleEvent |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
68 * @see AccessibleControlListener |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
69 * @see AccessibleControlEvent |
45 | 70 * @see <a href="http://www.eclipse.org/swt/snippets/#accessibility">Accessibility snippets</a> |
71 * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a> | |
0
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
72 * |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
73 * @since 2.0 |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
74 */ |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
75 public class Accessible { |
123 | 76 |
58 | 77 static NSString[] baseAttributes; |
123 | 78 |
58 | 79 static NSString[] baseTextAttributes; |
45 | 80 |
58 | 81 static NSString[] baseParameterizedAttributes; |
45 | 82 |
123 | 83 |
45 | 84 NSMutableArray attributeNames = null; |
85 NSMutableArray parameterizedAttributeNames = null; | |
86 NSMutableArray actionNames = null; | |
123 | 87 |
58 | 88 AccessibleListener[] accessibleListeners; |
89 AccessibleControlListener[] accessibleControlListeners; | |
90 AccessibleTextListener[] accessibleTextListeners; | |
0
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
91 Control control; |
123 | 92 |
129 | 93 SWTAccessibleDelegate[int] children; |
45 | 94 |
0
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
95 this (Control control) { |
123 | 96 |
0
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
97 this.control = control; |
58 | 98 |
99 baseAttributes = [ | |
100 OS.NSAccessibilityRoleAttribute, | |
101 OS.NSAccessibilityRoleDescriptionAttribute, | |
102 OS.NSAccessibilityHelpAttribute, | |
103 OS.NSAccessibilityFocusedAttribute, | |
104 OS.NSAccessibilityParentAttribute, | |
105 OS.NSAccessibilityChildrenAttribute, | |
106 OS.NSAccessibilityPositionAttribute, | |
107 OS.NSAccessibilitySizeAttribute, | |
108 OS.NSAccessibilityWindowAttribute, | |
109 OS.NSAccessibilityTopLevelUIElementAttribute | |
123 | 110 ]; |
58 | 111 |
112 baseTextAttributes = [ | |
113 OS.NSAccessibilityNumberOfCharactersAttribute, | |
114 OS.NSAccessibilitySelectedTextAttribute, | |
115 OS.NSAccessibilitySelectedTextRangeAttribute, | |
116 OS.NSAccessibilityInsertionPointLineNumberAttribute, | |
117 OS.NSAccessibilitySelectedTextRangesAttribute, | |
118 OS.NSAccessibilityVisibleCharacterRangeAttribute, | |
119 OS.NSAccessibilityValueAttribute | |
123 | 120 ]; |
58 | 121 |
122 baseParameterizedAttributes = [ | |
123 OS.NSAccessibilityStringForRangeParameterizedAttribute, | |
124 OS.NSAccessibilityRangeForLineParameterizedAttribute | |
123 | 125 ]; |
0
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
126 } |
37
642f460a0908
Fixed a lot of compile errors, a "hello world" app compiles now
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
13
diff
changeset
|
127 |
642f460a0908
Fixed a lot of compile errors, a "hello world" app compiles now
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
13
diff
changeset
|
128 /** |
642f460a0908
Fixed a lot of compile errors, a "hello world" app compiles now
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
13
diff
changeset
|
129 * Invokes platform specific functionality to allocate a new accessible object. |
642f460a0908
Fixed a lot of compile errors, a "hello world" app compiles now
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
13
diff
changeset
|
130 * <p> |
642f460a0908
Fixed a lot of compile errors, a "hello world" app compiles now
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
13
diff
changeset
|
131 * <b>IMPORTANT:</b> This method is <em>not</em> part of the public |
642f460a0908
Fixed a lot of compile errors, a "hello world" app compiles now
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
13
diff
changeset
|
132 * API for <code>Accessible</code>. It is marked public only so that it |
642f460a0908
Fixed a lot of compile errors, a "hello world" app compiles now
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
13
diff
changeset
|
133 * can be shared within the packages provided by SWT. It is not |
642f460a0908
Fixed a lot of compile errors, a "hello world" app compiles now
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
13
diff
changeset
|
134 * available on all platforms, and should never be called from |
642f460a0908
Fixed a lot of compile errors, a "hello world" app compiles now
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
13
diff
changeset
|
135 * application code. |
642f460a0908
Fixed a lot of compile errors, a "hello world" app compiles now
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
13
diff
changeset
|
136 * </p> |
642f460a0908
Fixed a lot of compile errors, a "hello world" app compiles now
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
13
diff
changeset
|
137 * |
642f460a0908
Fixed a lot of compile errors, a "hello world" app compiles now
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
13
diff
changeset
|
138 * @param control the control to get the accessible object for |
642f460a0908
Fixed a lot of compile errors, a "hello world" app compiles now
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
13
diff
changeset
|
139 * @return the platform specific accessible object |
642f460a0908
Fixed a lot of compile errors, a "hello world" app compiles now
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
13
diff
changeset
|
140 */ |
642f460a0908
Fixed a lot of compile errors, a "hello world" app compiles now
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
13
diff
changeset
|
141 public static Accessible internal_new_Accessible(Control control) { |
642f460a0908
Fixed a lot of compile errors, a "hello world" app compiles now
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
13
diff
changeset
|
142 return new Accessible(control); |
642f460a0908
Fixed a lot of compile errors, a "hello world" app compiles now
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
13
diff
changeset
|
143 } |
123 | 144 |
0
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
145 /** |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
146 * Adds the listener to the collection of listeners who will |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
147 * be notified when an accessible client asks for certain strings, |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
148 * such as name, description, help, or keyboard shortcut. The |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
149 * listener is notified by sending it one of the messages defined |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
150 * in the <code>AccessibleListener</code> interface. |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
151 * |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
152 * @param listener the listener that should be notified when the receiver |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
153 * is asked for a name, description, help, or keyboard shortcut string |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
154 * |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
155 * @exception IllegalArgumentException <ul> |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
156 * <li>ERROR_NULL_ARGUMENT - if the listener is null</li> |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
157 * </ul> |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
158 * @exception DWTException <ul> |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
159 * <li>ERROR_WIDGET_DISPOSED - if the receiver's control has been disposed</li> |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
160 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver's control</li> |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
161 * </ul> |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
162 * |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
163 * @see AccessibleListener |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
164 * @see #removeAccessibleListener |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
165 */ |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
166 public void addAccessibleListener (AccessibleListener listener) { |
45 | 167 checkWidget(); |
168 if (listener is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); | |
169 accessibleListeners.addElement(listener); | |
0
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
170 } |
123 | 171 |
0
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
172 /** |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
173 * Adds the listener to the collection of listeners who will |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
174 * be notified when an accessible client asks for custom control |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
175 * specific information. The listener is notified by sending it |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
176 * one of the messages defined in the <code>AccessibleControlListener</code> |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
177 * interface. |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
178 * |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
179 * @param listener the listener that should be notified when the receiver |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
180 * is asked for custom control specific information |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
181 * |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
182 * @exception IllegalArgumentException <ul> |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
183 * <li>ERROR_NULL_ARGUMENT - if the listener is null</li> |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
184 * </ul> |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
185 * @exception DWTException <ul> |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
186 * <li>ERROR_WIDGET_DISPOSED - if the receiver's control has been disposed</li> |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
187 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver's control</li> |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
188 * </ul> |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
189 * |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
190 * @see AccessibleControlListener |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
191 * @see #removeAccessibleControlListener |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
192 */ |
45 | 193 public void addAccessibleControlListener(AccessibleControlListener listener) { |
194 checkWidget(); | |
195 if (listener is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); | |
196 accessibleControlListeners.addElement(listener); | |
0
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
197 } |
123 | 198 |
0
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
199 /** |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
200 * Adds the listener to the collection of listeners who will |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
201 * be notified when an accessible client asks for custom text control |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
202 * specific information. The listener is notified by sending it |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
203 * one of the messages defined in the <code>AccessibleTextListener</code> |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
204 * interface. |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
205 * |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
206 * @param listener the listener that should be notified when the receiver |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
207 * is asked for custom text control specific information |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
208 * |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
209 * @exception IllegalArgumentException <ul> |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
210 * <li>ERROR_NULL_ARGUMENT - if the listener is null</li> |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
211 * </ul> |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
212 * @exception DWTException <ul> |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
213 * <li>ERROR_WIDGET_DISPOSED - if the receiver's control has been disposed</li> |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
214 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver's control</li> |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
215 * </ul> |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
216 * |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
217 * @see AccessibleTextListener |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
218 * @see #removeAccessibleTextListener |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
219 * |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
220 * @since 3.0 |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
221 */ |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
222 public void addAccessibleTextListener (AccessibleTextListener listener) { |
45 | 223 checkWidget (); |
224 if (listener is null) DWT.error (DWT.ERROR_NULL_ARGUMENT); | |
225 accessibleTextListeners.addElement (listener); | |
226 } | |
227 | |
58 | 228 public cocoa.id internal_accessibilityActionDescription(NSString action, int childID) { |
45 | 229 // TODO No action support for now. |
230 return NSString.stringWith(""); | |
231 } | |
123 | 232 |
45 | 233 public NSArray internal_accessibilityActionNames(int childID) { |
234 // The supported action list depends on the role played by the control. | |
235 AccessibleControlEvent event = new AccessibleControlEvent(this); | |
236 event.childID = childID; | |
237 event.detail = -1; | |
238 for (int i = 0; i < accessibleControlListeners.size(); i++) { | |
60
62202ce0039f
Updated and fixed many modules to 3.514
Jacob Carlborg <doob@me.com>
parents:
59
diff
changeset
|
239 AccessibleControlListener listener = elementAt(accessibleControlListeners, i); |
45 | 240 listener.getRole(event); |
241 } | |
123 | 242 |
45 | 243 // No accessible listener is overriding the role of the control, so let Cocoa return the default set for the control. |
244 if (event.detail is -1) { | |
245 return null; | |
246 } | |
247 | |
248 if ((childID is ACC.CHILDID_SELF) && (actionNames !is null)) { | |
249 return retainedAutoreleased(actionNames); | |
250 } | |
251 | |
252 NSMutableArray returnValue = NSMutableArray.arrayWithCapacity(5); | |
253 | |
254 switch (event.detail) { | |
123 | 255 case ACC.ROLE_PUSHBUTTON: |
256 case ACC.ROLE_RADIOBUTTON: | |
257 case ACC.ROLE_CHECKBUTTON: | |
258 case ACC.ROLE_TABITEM: | |
259 returnValue.addObject(OS.NSAccessibilityPressAction); | |
260 break; | |
151
0ba75290f8ce
Added a bunch of missing defaults to switch statements
Jacob Carlborg <doob@me.com>
parents:
129
diff
changeset
|
261 default: |
45 | 262 } |
123 | 263 |
45 | 264 switch (event.detail) { |
123 | 265 case ACC.ROLE_COMBOBOX: |
266 returnValue.addObject(OS.NSAccessibilityConfirmAction); | |
267 break; | |
151
0ba75290f8ce
Added a bunch of missing defaults to switch statements
Jacob Carlborg <doob@me.com>
parents:
129
diff
changeset
|
268 default: |
45 | 269 } |
123 | 270 |
271 | |
45 | 272 if (childID is ACC.CHILDID_SELF) { |
273 actionNames = returnValue; | |
274 actionNames.retain(); | |
275 return retainedAutoreleased(actionNames); | |
276 } else { | |
277 // Caller must retain if they want to hold on to it. | |
278 return returnValue; | |
279 } | |
280 } | |
123 | 281 |
45 | 282 public NSArray internal_accessibilityAttributeNames(int childID) { |
283 // The supported attribute set depends on the role played by the control. | |
284 // We may need to add or remove from the base set as needed. | |
285 AccessibleControlEvent event = new AccessibleControlEvent(this); | |
286 event.childID = childID; | |
287 event.detail = -1; | |
288 for (int i = 0; i < accessibleControlListeners.size(); i++) { | |
58 | 289 AccessibleControlListener listener = accessibleControlListeners.elementAt(i); |
45 | 290 listener.getRole(event); |
291 } | |
123 | 292 |
45 | 293 // No accessible listener is overriding the role of the control, so let Cocoa |
294 // return the default set for the control. | |
295 if (event.detail is -1) | |
296 return null; | |
297 | |
298 if ((childID is ACC.CHILDID_SELF) && (attributeNames !is null)) { | |
299 return retainedAutoreleased(attributeNames); | |
300 } | |
301 | |
302 NSMutableArray returnValue = NSMutableArray.arrayWithCapacity(baseAttributes.length); | |
123 | 303 |
45 | 304 /* Add our list of supported attributes to the array. |
305 * Make sure each attribute name is not already in the array before appending. | |
306 */ | |
307 for (int i = 0; i < baseAttributes.length; i++) { | |
308 if (!returnValue.containsObject(baseAttributes[i])) { | |
309 returnValue.addObject(baseAttributes[i]); | |
310 } | |
311 } | |
312 | |
313 if (accessibleTextListeners.size() > 0) { | |
314 for (int i = 0; i < baseTextAttributes.length; i++) { | |
315 if (!returnValue.containsObject(baseTextAttributes[i])) { | |
316 returnValue.addObject(baseTextAttributes[i]); | |
317 } | |
318 } | |
319 } | |
320 | |
321 // The following are expected to have a value (AXValue) | |
322 switch (event.detail) { | |
123 | 323 case ACC.ROLE_CHECKBUTTON: |
324 case ACC.ROLE_RADIOBUTTON: | |
325 case ACC.ROLE_LABEL: | |
326 case ACC.ROLE_TABITEM: | |
327 case ACC.ROLE_TABFOLDER: | |
328 returnValue.addObject(OS.NSAccessibilityValueAttribute); | |
329 break; | |
151
0ba75290f8ce
Added a bunch of missing defaults to switch statements
Jacob Carlborg <doob@me.com>
parents:
129
diff
changeset
|
330 default: |
45 | 331 } |
332 | |
333 // The following are expected to report their enabled status (AXEnabled) | |
334 switch (event.detail) { | |
123 | 335 case ACC.ROLE_CHECKBUTTON: |
336 case ACC.ROLE_RADIOBUTTON: | |
337 case ACC.ROLE_LABEL: | |
338 case ACC.ROLE_TABITEM: | |
339 case ACC.ROLE_PUSHBUTTON: | |
340 case ACC.ROLE_COMBOBOX: | |
341 returnValue.addObject(OS.NSAccessibilityEnabledAttribute); | |
342 break; | |
151
0ba75290f8ce
Added a bunch of missing defaults to switch statements
Jacob Carlborg <doob@me.com>
parents:
129
diff
changeset
|
343 default: |
45 | 344 } |
345 | |
346 // The following are expected to report a title (AXTitle) | |
347 switch (event.detail) { | |
123 | 348 case ACC.ROLE_CHECKBUTTON: |
349 case ACC.ROLE_RADIOBUTTON: | |
350 case ACC.ROLE_PUSHBUTTON: | |
351 case ACC.ROLE_TABITEM: | |
352 returnValue.addObject(OS.NSAccessibilityTitleAttribute); | |
353 break; | |
151
0ba75290f8ce
Added a bunch of missing defaults to switch statements
Jacob Carlborg <doob@me.com>
parents:
129
diff
changeset
|
354 default: |
45 | 355 } |
123 | 356 |
45 | 357 // Accessibility verifier says these attributes must be reported for combo boxes. |
358 if (event.detail is ACC.ROLE_COMBOBOX) { | |
359 returnValue.addObject(OS.NSAccessibilityExpandedAttribute); | |
360 } | |
361 | |
362 // Accessibility verifier says these attributes must be reported for tab folders. | |
363 if (event.detail is ACC.ROLE_TABFOLDER) { | |
364 returnValue.addObject(OS.NSAccessibilityContentsAttribute); | |
365 returnValue.addObject(OS.NSAccessibilityTabsAttribute); | |
366 } | |
123 | 367 |
45 | 368 /* |
369 * Only report back sub-roles when the DWT role maps to a sub-role. | |
370 */ | |
371 if (event.detail !is -1) { | |
372 String osRole = roleToOs(event.detail); | |
373 | |
60
62202ce0039f
Updated and fixed many modules to 3.514
Jacob Carlborg <doob@me.com>
parents:
59
diff
changeset
|
374 if (dwt.dwthelper.utils.indexOf(osRole, ':') is -1) |
45 | 375 returnValue.removeObject(OS.NSAccessibilitySubroleAttribute); |
376 } | |
123 | 377 |
45 | 378 /* |
379 * Children never return their own children, so remove that attribute. | |
380 */ | |
381 if (childID !is ACC.CHILDID_SELF) { | |
382 returnValue.removeObject(OS.NSAccessibilityChildrenAttribute); | |
383 } | |
384 | |
385 if (childID is ACC.CHILDID_SELF) { | |
386 attributeNames = returnValue; | |
387 attributeNames.retain(); | |
388 return retainedAutoreleased(attributeNames); | |
389 } else { | |
390 // Caller must retain if necessary. | |
391 return returnValue; | |
392 } | |
393 } | |
123 | 394 |
58 | 395 public cocoa.id internal_accessibilityAttributeValue(NSString attribute, int childID) { |
45 | 396 if (attribute.isEqualToString(OS.NSAccessibilityRoleAttribute)) return getRoleAttribute(childID); |
397 if (attribute.isEqualToString(OS.NSAccessibilitySubroleAttribute)) return getSubroleAttribute(childID); | |
398 if (attribute.isEqualToString(OS.NSAccessibilityRoleDescriptionAttribute)) return getRoleDescriptionAttribute(childID); | |
399 if (attribute.isEqualToString(OS.NSAccessibilityExpandedAttribute)) return getExpandedAttribute(childID); | |
400 if (attribute.isEqualToString(OS.NSAccessibilityHelpAttribute)) return getHelpAttribute(childID); | |
401 if (attribute.isEqualToString(OS.NSAccessibilityTitleAttribute)) return getTitleAttribute(childID); | |
402 if (attribute.isEqualToString(OS.NSAccessibilityValueAttribute)) return getValueAttribute(childID); | |
403 if (attribute.isEqualToString(OS.NSAccessibilityEnabledAttribute)) return getEnabledAttribute(childID); | |
404 if (attribute.isEqualToString(OS.NSAccessibilityFocusedAttribute)) return getFocusedAttribute(childID); | |
405 if (attribute.isEqualToString(OS.NSAccessibilityParentAttribute)) return getParentAttribute(childID); | |
406 if (attribute.isEqualToString(OS.NSAccessibilityChildrenAttribute)) return getChildrenAttribute(childID); | |
407 if (attribute.isEqualToString(OS.NSAccessibilityContentsAttribute)) return getChildrenAttribute(childID); | |
408 // FIXME: There's no specific API just for tabs, which won't include the buttons (if any.) | |
409 if (attribute.isEqualToString(OS.NSAccessibilityTabsAttribute)) return getTabsAttribute(childID); | |
410 if (attribute.isEqualToString(OS.NSAccessibilityWindowAttribute)) return getWindowAttribute(childID); | |
411 if (attribute.isEqualToString(OS.NSAccessibilityTopLevelUIElementAttribute)) return getTopLevelUIElementAttribute(childID); | |
412 if (attribute.isEqualToString(OS.NSAccessibilityPositionAttribute)) return getPositionAttribute(childID); | |
413 if (attribute.isEqualToString(OS.NSAccessibilitySizeAttribute)) return getSizeAttribute(childID); | |
414 if (attribute.isEqualToString(OS.NSAccessibilityDescriptionAttribute)) return getDescriptionAttribute(childID); | |
415 if (attribute.isEqualToString(OS.NSAccessibilityNumberOfCharactersAttribute)) return getNumberOfCharactersAttribute(childID); | |
416 if (attribute.isEqualToString(OS.NSAccessibilitySelectedTextAttribute)) return getSelectedTextAttribute(childID); | |
417 if (attribute.isEqualToString(OS.NSAccessibilitySelectedTextRangeAttribute)) return getSelectedTextRangeAttribute(childID); | |
418 if (attribute.isEqualToString(OS.NSAccessibilityInsertionPointLineNumberAttribute)) return getInsertionPointLineNumberAttribute(childID); | |
419 if (attribute.isEqualToString(OS.NSAccessibilitySelectedTextRangesAttribute)) return getSelectedTextRangesAttribute(childID); | |
420 if (attribute.isEqualToString(OS.NSAccessibilityVisibleCharacterRangeAttribute)) return getVisibleCharacterRangeAttribute(childID); | |
421 | |
422 // If this object don't know how to get the value it's up to the control itself to return an attribute value. | |
423 return null; | |
424 } | |
425 | |
59 | 426 public cocoa.id internal_accessibilityAttributeValue_forParameter(NSString attribute, cocoa.id parameter, int childID) { |
45 | 427 if (attribute.isEqualToString(OS.NSAccessibilityStringForRangeParameterizedAttribute)) return getStringForRangeAttribute(parameter, childID); |
428 if (attribute.isEqualToString(OS.NSAccessibilityRangeForLineParameterizedAttribute)) return getRangeForLineParameterizedAttribute(parameter, childID); | |
429 return null; | |
430 } | |
123 | 431 |
45 | 432 // Returns the UI Element that has the focus. You can assume that the search for the focus has already been narrowed down to the receiver. |
433 // Override this method to do a deeper search with a UIElement - e.g. a NSMatrix would determine if one of its cells has the focus. | |
58 | 434 public cocoa.id internal_accessibilityFocusedUIElement(int childID) { |
45 | 435 AccessibleControlEvent event = new AccessibleControlEvent(this); |
436 event.childID = ACC.CHILDID_MULTIPLE; // set to invalid value, to test if the application sets it in getFocus() | |
437 event.accessible = null; | |
438 for (int i = 0; i < accessibleControlListeners.size(); i++) { | |
58 | 439 AccessibleControlListener listener = accessibleControlListeners.elementAt(i); |
45 | 440 listener.getFocus(event); |
441 } | |
442 | |
443 // The listener did not respond, so let Cocoa figure it out. | |
444 if (event.childID is ACC.CHILDID_MULTIPLE) | |
445 return null; | |
446 | |
447 /* The application can optionally answer an accessible. */ | |
448 if (event.accessible !is null) { | |
58 | 449 return new cocoa.id(OS.NSAccessibilityUnignoredAncestor(event.accessible.control.view.id)); |
45 | 450 } |
451 | |
452 /* Or the application can answer a valid child ID, including CHILDID_SELF and CHILDID_NONE. */ | |
453 if (event.childID is ACC.CHILDID_SELF || event.childID is ACC.CHILDID_NONE) { | |
58 | 454 return new cocoa.id(OS.NSAccessibilityUnignoredAncestor(control.view.id)); |
45 | 455 } |
123 | 456 |
58 | 457 return new cocoa.id(OS.NSAccessibilityUnignoredAncestor(childIDToOs(event.childID).id)); |
45 | 458 } |
123 | 459 |
45 | 460 // Returns the deepest descendant of the UIElement hierarchy that contains the point. |
461 // You can assume the point has already been determined to lie within the receiver. | |
462 // Override this method to do deeper hit testing within a UIElement - e.g. a NSMatrix would test its cells. The point is bottom-left relative screen coordinates. | |
58 | 463 public cocoa.id internal_accessibilityHitTest(NSPoint point, int childID) { |
45 | 464 AccessibleControlEvent event = new AccessibleControlEvent(this); |
58 | 465 event.x = cast(int) point.x; |
60
62202ce0039f
Updated and fixed many modules to 3.514
Jacob Carlborg <doob@me.com>
parents:
59
diff
changeset
|
466 dwt.widgets.Monitor.Monitor primaryMonitor = Display.getCurrent().getPrimaryMonitor(); |
58 | 467 event.y = cast(int) (primaryMonitor.getBounds().height - point.y); |
123 | 468 |
45 | 469 // Set an impossible value to determine if anything responded to the event. |
470 event.childID = ACC.CHILDID_MULTIPLE; | |
471 for (int i = 0; i < accessibleControlListeners.size(); i++) { | |
58 | 472 AccessibleControlListener listener = accessibleControlListeners.elementAt(i); |
45 | 473 listener.getChildAtPoint(event); |
474 } | |
475 | |
476 // The listener did not respond, so let Cocoa figure it out. | |
477 if (event.childID is ACC.CHILDID_MULTIPLE) | |
478 return null; | |
479 | |
480 if (event.accessible !is null) { | |
58 | 481 return new cocoa.id(OS.NSAccessibilityUnignoredAncestor(event.accessible.control.view.id)); |
45 | 482 } |
123 | 483 |
45 | 484 if (event.childID is ACC.CHILDID_SELF || event.childID is ACC.CHILDID_NONE) { |
58 | 485 return new cocoa.id(OS.NSAccessibilityUnignoredAncestor(control.view.id)); |
45 | 486 } |
123 | 487 |
58 | 488 return new cocoa.id(OS.NSAccessibilityUnignoredAncestor(childIDToOs(event.childID).id)); |
45 | 489 } |
123 | 490 |
45 | 491 public bool internal_accessibilityIsAttributeSettable(NSString attribute, int childID) { |
492 return false; | |
493 } | |
123 | 494 |
45 | 495 // 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. |
496 public bool internal_accessibilityIsIgnored(int childID) { | |
497 return false; | |
498 } | |
123 | 499 |
45 | 500 // parameterized attribute methods |
501 public NSArray internal_accessibilityParameterizedAttributeNames(int childID) { | |
123 | 502 |
45 | 503 if ((childID is ACC.CHILDID_SELF) && (parameterizedAttributeNames !is null)) { |
504 return retainedAutoreleased(parameterizedAttributeNames); | |
505 } | |
123 | 506 |
45 | 507 NSMutableArray returnValue = NSMutableArray.arrayWithCapacity(4); |
123 | 508 |
45 | 509 if (accessibleTextListeners.size() > 0) { |
510 for (int i = 0; i < baseParameterizedAttributes.length; i++) { | |
511 if (!returnValue.containsObject(baseParameterizedAttributes[i])) { | |
512 returnValue.addObject(baseParameterizedAttributes[i]); | |
513 } | |
514 } | |
123 | 515 |
45 | 516 } |
123 | 517 |
45 | 518 if (childID is ACC.CHILDID_SELF) { |
519 parameterizedAttributeNames = returnValue; | |
520 parameterizedAttributeNames.retain(); | |
521 return retainedAutoreleased(parameterizedAttributeNames); | |
522 } else { | |
523 // Caller must retain if they want to keep it. | |
524 return returnValue; | |
525 } | |
526 } | |
123 | 527 |
45 | 528 public void internal_accessibilityPerformAction(NSString action, int childID) { |
529 // TODO Auto-generated method stub | |
530 // No action support for now. | |
531 } | |
123 | 532 |
45 | 533 /** |
534 * Returns the control for this Accessible object. | |
535 * | |
536 * @return the receiver's control | |
537 * @since 3.0 | |
538 */ | |
539 public Control getControl() { | |
540 return control; | |
541 } | |
123 | 542 |
45 | 543 /** |
544 * Invokes platform specific functionality to dispose an accessible object. | |
545 * <p> | |
546 * <b>IMPORTANT:</b> This method is <em>not</em> part of the public | |
547 * API for <code>Accessible</code>. It is marked public only so that it | |
548 * can be shared within the packages provided by DWT. It is not | |
549 * available on all platforms, and should never be called from | |
550 * application code. | |
551 * </p> | |
552 */ | |
553 public void internal_dispose_Accessible() { | |
554 if (actionNames !is null) actionNames.release(); | |
555 actionNames = null; | |
556 if (attributeNames !is null) attributeNames.release(); | |
557 attributeNames = null; | |
558 if (parameterizedAttributeNames !is null) parameterizedAttributeNames.release(); | |
58 | 559 parameterizedAttributeNames = null; |
45 | 560 |
58 | 561 foreach (childDelegate ; children) |
129 | 562 childDelegate.internal_dispose_SWTAccessibleDelegate(); |
45 | 563 |
564 children.clear(); | |
565 } | |
566 | |
58 | 567 cocoa.id getExpandedAttribute(int childID) { |
45 | 568 // TODO: May need to expand the API so the combo box state can be reported. |
569 return NSNumber.numberWithBool(false); | |
570 } | |
123 | 571 |
58 | 572 cocoa.id getHelpAttribute (int childID) { |
573 cocoa.id returnValue = null; | |
45 | 574 AccessibleEvent event = new AccessibleEvent(this); |
575 event.childID = childID; | |
576 for (int i = 0; i < accessibleListeners.size(); i++) { | |
58 | 577 AccessibleListener listener = accessibleListeners.elementAt(i); |
45 | 578 listener.getHelp(event); |
579 } | |
580 | |
581 if (event.result !is null) { | |
582 returnValue = NSString.stringWith(event.result); | |
583 } | |
584 | |
585 return returnValue; | |
586 } | |
587 | |
588 NSString getRoleAttribute(int childID) { | |
589 NSString returnValue = null; | |
590 AccessibleControlEvent event = new AccessibleControlEvent(this); | |
591 event.childID = childID; | |
592 event.detail = -1; | |
593 for (int i = 0; i < accessibleControlListeners.size(); i++) { | |
58 | 594 AccessibleControlListener listener = accessibleControlListeners.elementAt(i); |
45 | 595 listener.getRole(event); |
596 } | |
597 if (event.detail !is -1) { | |
598 String appRole = roleToOs (event.detail); | |
60
62202ce0039f
Updated and fixed many modules to 3.514
Jacob Carlborg <doob@me.com>
parents:
59
diff
changeset
|
599 int index = dwt.dwthelper.utils.indexOf(appRole, ':'); |
45 | 600 if (index !is -1) appRole = appRole.substring(0, index); |
601 returnValue = NSString.stringWith(appRole); | |
602 } | |
123 | 603 |
45 | 604 return returnValue; |
605 } | |
606 | |
58 | 607 cocoa.id getSubroleAttribute (int childID) { |
608 cocoa.id returnValue = null; | |
45 | 609 AccessibleControlEvent event = new AccessibleControlEvent(this); |
610 event.childID = childID; | |
611 event.detail = -1; | |
612 for (int i = 0; i < accessibleControlListeners.size(); i++) { | |
58 | 613 AccessibleControlListener listener = accessibleControlListeners.elementAt(i); |
45 | 614 listener.getRole(event); |
615 } | |
616 if (event.detail !is -1) { | |
617 String appRole = roleToOs (event.detail); | |
60
62202ce0039f
Updated and fixed many modules to 3.514
Jacob Carlborg <doob@me.com>
parents:
59
diff
changeset
|
618 int index = dwt.dwthelper.utils.indexOf(appRole, ':'); |
45 | 619 if (index !is -1) { |
620 appRole = appRole.substring(index + 1); | |
621 returnValue = NSString.stringWith(appRole); | |
622 } | |
623 } | |
624 return returnValue; | |
625 } | |
626 | |
58 | 627 cocoa.id getRoleDescriptionAttribute (int childID) { |
628 cocoa.id returnValue = null; | |
45 | 629 AccessibleControlEvent event = new AccessibleControlEvent(this); |
630 event.childID = childID; | |
631 event.detail = -1; | |
632 for (int i = 0; i < accessibleControlListeners.size(); i++) { | |
58 | 633 AccessibleControlListener listener = accessibleControlListeners.elementAt(i); |
45 | 634 listener.getRole(event); |
635 } | |
636 if (event.detail !is -1) { | |
637 String appRole = roleToOs (event.detail); | |
638 String appSubrole = null; | |
60
62202ce0039f
Updated and fixed many modules to 3.514
Jacob Carlborg <doob@me.com>
parents:
59
diff
changeset
|
639 int index = dwt.dwthelper.utils.indexOf(appRole, ':'); |
45 | 640 if (index !is -1) { |
641 appSubrole = appRole.substring(index + 1); | |
642 appRole = appRole.substring(0, index); | |
643 } | |
644 NSString nsAppRole = NSString.stringWith(appRole); | |
645 NSString nsAppSubrole = null; | |
646 | |
647 if (appSubrole !is null) nsAppSubrole = NSString.stringWith(appSubrole); | |
58 | 648 returnValue = new NSString(OS.NSAccessibilityRoleDescription (((nsAppRole !is null) ? nsAppRole.id : null), (nsAppSubrole !is null) ? nsAppSubrole.id : null)); |
45 | 649 } |
650 return returnValue; | |
651 } | |
652 | |
58 | 653 cocoa.id getTitleAttribute (int childID) { |
45 | 654 |
58 | 655 cocoa.id returnValue = null;//NSString.stringWith(""); |
45 | 656 |
657 /* | |
123 | 658 * Feature of the Macintosh. The text of a Label is returned in its value, |
659 * not its title, so ensure that the role is not Label before asking for the title. | |
660 */ | |
45 | 661 AccessibleControlEvent roleEvent = new AccessibleControlEvent(this); |
662 roleEvent.childID = childID; | |
663 roleEvent.detail = -1; | |
664 for (int i = 0; i < accessibleControlListeners.size(); i++) { | |
58 | 665 AccessibleControlListener listener = accessibleControlListeners.elementAt(i); |
45 | 666 listener.getRole(roleEvent); |
667 } | |
668 if (roleEvent.detail !is ACC.ROLE_LABEL) { | |
669 AccessibleEvent event = new AccessibleEvent(this); | |
670 event.childID = childID; | |
671 event.result = null; | |
672 for (int i = 0; i < accessibleListeners.size(); i++) { | |
58 | 673 AccessibleListener listener = accessibleListeners.elementAt(i); |
45 | 674 listener.getName(event); |
675 } | |
676 | |
677 if (event.result !is null) | |
678 returnValue = NSString.stringWith(event.result); | |
679 } | |
680 return returnValue; | |
681 } | |
682 | |
58 | 683 cocoa.id getValueAttribute (int childID) { |
60
62202ce0039f
Updated and fixed many modules to 3.514
Jacob Carlborg <doob@me.com>
parents:
59
diff
changeset
|
684 cocoa.id returnValue = null; |
45 | 685 AccessibleControlEvent event = new AccessibleControlEvent(this); |
686 event.childID = childID; | |
687 event.detail = -1; | |
688 event.result = null; //TODO: could pass the OS value to the app | |
689 for (int i = 0; i < accessibleControlListeners.size(); i++) { | |
58 | 690 AccessibleControlListener listener = accessibleControlListeners.elementAt(i); |
45 | 691 listener.getRole(event); |
692 listener.getValue(event); | |
693 } | |
694 int role = event.detail; | |
695 String value = event.result; | |
123 | 696 |
45 | 697 switch (role) { |
123 | 698 case ACC.ROLE_RADIOBUTTON: // 1 = on, 0 = off |
699 case ACC.ROLE_CHECKBUTTON: // 1 = checked, 0 = unchecked, 2 = mixed | |
700 case ACC.ROLE_SCROLLBAR: // numeric value representing the position of the scroller | |
701 case ACC.ROLE_SLIDER: // the value associated with the position of the slider thumb | |
702 case ACC.ROLE_PROGRESSBAR: // the value associated with the fill level of the progress bar | |
703 if (value !is null) { | |
704 try { | |
705 int number = Integer.parseInt(value); | |
706 returnValue = NSNumber.numberWithInt(number); | |
707 } catch (NumberFormatException ex) { | |
708 if (value.equalsIgnoreCase("true")) { | |
709 returnValue = NSNumber.numberWithBool(true); | |
710 } else if (value.equalsIgnoreCase("false")) { | |
711 returnValue = NSNumber.numberWithBool(false); | |
712 } | |
45 | 713 } |
123 | 714 } else { |
715 returnValue = NSNumber.numberWithBool(false); | |
716 } | |
717 break; | |
718 case ACC.ROLE_TABFOLDER: // the accessibility object representing the currently selected tab item | |
719 case ACC.ROLE_TABITEM: // 1 = selected, 0 = not selected | |
720 AccessibleControlEvent ace = new AccessibleControlEvent(this); | |
721 ace.childID = -4; | |
722 for (int i = 0; i < accessibleControlListeners.size(); i++) { | |
723 AccessibleControlListener listener = accessibleControlListeners.elementAt(i); | |
724 listener.getSelection(ace); | |
45 | 725 } |
123 | 726 if (ace.childID >= ACC.CHILDID_SELF) { |
727 if (role is ACC.ROLE_TABITEM) { | |
728 returnValue = NSNumber.numberWithBool(ace.childID is childID); | |
729 } else { | |
730 returnValue = new cocoa.id(OS.NSAccessibilityUnignoredAncestor(childIDToOs(ace.childID).id)); | |
731 } | |
45 | 732 } else { |
123 | 733 returnValue = NSNumber.numberWithBool(false); |
45 | 734 } |
123 | 735 break; |
736 case ACC.ROLE_COMBOBOX: // text of the currently selected item | |
737 case ACC.ROLE_TEXT: // text in the text field | |
45 | 738 if (value !is null) returnValue = NSString.stringWith(value); |
123 | 739 break; |
740 case ACC.ROLE_LABEL: // text in the label | |
741 /* On a Mac, the 'value' of a label is the same as the 'name' of the label. */ | |
742 AccessibleEvent e = new AccessibleEvent(this); | |
743 e.childID = childID; | |
744 e.result = null; | |
745 for (int i = 0; i < accessibleListeners.size(); i++) { | |
746 AccessibleListener listener = accessibleListeners.elementAt(i); | |
747 listener.getName(e); | |
748 } | |
749 if (e.result !is null) { | |
750 returnValue = NSString.stringWith(e.result); | |
751 } else { | |
752 if (value !is null) returnValue = NSString.stringWith(value); | |
753 } | |
754 break; | |
151
0ba75290f8ce
Added a bunch of missing defaults to switch statements
Jacob Carlborg <doob@me.com>
parents:
129
diff
changeset
|
755 default: |
45 | 756 } |
757 | |
758 return returnValue; | |
759 } | |
760 | |
58 | 761 cocoa.id getEnabledAttribute (int childID) { |
45 | 762 AccessibleControlEvent event = new AccessibleControlEvent(this); |
763 event.detail = -1; | |
764 for (int i = 0; i < accessibleControlListeners.size(); i++) { | |
58 | 765 AccessibleControlListener listener = accessibleControlListeners.elementAt(i); |
45 | 766 listener.getState(event); |
767 } | |
123 | 768 |
45 | 769 return NSNumber.numberWithBool(control.isEnabled()); |
770 } | |
771 | |
58 | 772 cocoa.id getFocusedAttribute (int childID) { |
45 | 773 AccessibleControlEvent event = new AccessibleControlEvent(this); |
774 event.childID = ACC.CHILDID_MULTIPLE; // set to invalid value, to test if the application sets it in getFocus() | |
775 event.accessible = null; | |
776 for (int i = 0; i < accessibleControlListeners.size(); i++) { | |
58 | 777 AccessibleControlListener listener = accessibleControlListeners.elementAt(i); |
45 | 778 listener.getFocus(event); |
779 } | |
123 | 780 |
45 | 781 /* The application can optionally answer an accessible. */ |
782 // FIXME: | |
123 | 783 // if (event.accessible !is null) { |
784 // bool hasFocus = (event.accessible.childID is childID) && (event.accessible.control is this.control); | |
785 // return NSNumber.numberWithBool(hasFocus); | |
786 // } | |
45 | 787 |
788 /* Or the application can answer a valid child ID, including CHILDID_SELF and CHILDID_NONE. */ | |
789 if (event.childID is ACC.CHILDID_SELF) { | |
790 bool hasFocus = (event.childID is childID); | |
791 return NSNumber.numberWithBool(hasFocus); | |
792 } | |
793 if (event.childID is ACC.CHILDID_NONE) { | |
794 return NSNumber.numberWithBool(false); | |
795 } | |
796 if (event.childID !is ACC.CHILDID_MULTIPLE) { | |
797 /* Other valid childID. */ | |
798 return NSNumber.numberWithBool(event.childID is childID); | |
799 } | |
123 | 800 |
45 | 801 // Invalid childID at this point means the application did not implement getFocus, so |
802 // let the default handler return the native focus. | |
803 bool hasFocus = (this.control.view.window().firstResponder() is control.view); | |
804 return NSNumber.numberWithBool(hasFocus); | |
805 } | |
806 | |
58 | 807 cocoa.id getParentAttribute (int childID) { |
45 | 808 // Returning null here means 'let Cocoa figure it out.' |
809 if (childID is ACC.CHILDID_SELF) | |
810 return null; | |
811 else | |
60
62202ce0039f
Updated and fixed many modules to 3.514
Jacob Carlborg <doob@me.com>
parents:
59
diff
changeset
|
812 return new cocoa.id(OS.NSAccessibilityUnignoredAncestor(control.view.id)); |
45 | 813 } |
814 | |
58 | 815 cocoa.id getChildrenAttribute (int childID) { |
816 cocoa.id returnValue = null; | |
45 | 817 if (childID is ACC.CHILDID_SELF) { |
818 AccessibleControlEvent event = new AccessibleControlEvent(this); | |
819 event.childID = childID; | |
820 event.detail = -1; // set to impossible value to test if app resets | |
821 for (int i = 0; i < accessibleControlListeners.size(); i++) { | |
58 | 822 AccessibleControlListener listener = accessibleControlListeners.elementAt(i); |
45 | 823 listener.getChildCount(event); |
824 } | |
825 if (event.detail > 0) { | |
826 for (int i = 0; i < accessibleControlListeners.size(); i++) { | |
58 | 827 AccessibleControlListener listener = accessibleControlListeners.elementAt(i); |
45 | 828 listener.getChildren(event); |
829 } | |
830 Object [] appChildren = event.children; | |
831 if (appChildren !is null && appChildren.length > 0) { | |
832 /* return an NSArray of NSAccessible objects. */ | |
833 NSMutableArray childArray = NSMutableArray.arrayWithCapacity(appChildren.length); | |
123 | 834 |
45 | 835 for (int i = 0; i < appChildren.length; i++) { |
836 Object child = appChildren[i]; | |
58 | 837 if (cast(Integer) child) { |
60
62202ce0039f
Updated and fixed many modules to 3.514
Jacob Carlborg <doob@me.com>
parents:
59
diff
changeset
|
838 cocoa.id accChild = childIDToOs((cast(Integer)child).intValue()); |
45 | 839 childArray.addObject(accChild); |
840 } else { | |
58 | 841 childArray.addObject((cast(Accessible)child).control.view); |
45 | 842 } |
843 } | |
123 | 844 |
58 | 845 returnValue = new cocoa.id(OS.NSAccessibilityUnignoredChildren(childArray.id)); |
45 | 846 } |
847 } | |
848 } else { | |
849 // Lightweight children have no children of their own. | |
850 // Don't return null if there are no children -- always return an empty array. | |
851 returnValue = NSArray.array(); | |
852 } | |
123 | 853 |
45 | 854 // Returning null here means we want the control itself to determine its children. If the accessible listener |
855 // implemented getChildCount/getChildren, references to those objects would have been returned above. | |
856 return returnValue; | |
857 } | |
858 | |
58 | 859 cocoa.id getTabsAttribute (int childID) { |
860 cocoa.id returnValue = null; | |
45 | 861 if (childID is ACC.CHILDID_SELF) { |
862 AccessibleControlEvent event = new AccessibleControlEvent(this); | |
863 event.childID = childID; | |
864 event.detail = -1; // set to impossible value to test if app resets | |
865 for (int i = 0; i < accessibleControlListeners.size(); i++) { | |
58 | 866 AccessibleControlListener listener = accessibleControlListeners.elementAt(i); |
45 | 867 listener.getChildCount(event); |
868 } | |
869 if (event.detail > 0) { | |
870 for (int i = 0; i < accessibleControlListeners.size(); i++) { | |
58 | 871 AccessibleControlListener listener = accessibleControlListeners.elementAt(i); |
45 | 872 listener.getChildren(event); |
873 } | |
874 Object [] appChildren = event.children; | |
875 if (appChildren !is null && appChildren.length > 0) { | |
876 /* return an NSArray of NSAccessible objects. */ | |
877 NSMutableArray childArray = NSMutableArray.arrayWithCapacity(appChildren.length); | |
123 | 878 |
45 | 879 for (int i = 0; i < appChildren.length; i++) { |
880 Object child = appChildren[i]; | |
58 | 881 if (cast(Integer)child) { |
882 int subChildID = (cast(Integer)child).intValue(); | |
45 | 883 event.childID = subChildID; |
884 event.detail = -1; | |
885 for (int j = 0; j < accessibleControlListeners.size(); j++) { | |
58 | 886 AccessibleControlListener listener = accessibleControlListeners.elementAt(j); |
45 | 887 listener.getRole(event); |
888 } | |
889 | |
890 if (event.detail is ACC.ROLE_TABITEM) { | |
58 | 891 cocoa.id accChild = childIDToOs((cast(Integer)child).intValue()); |
45 | 892 childArray.addObject(accChild); |
893 } | |
894 } else { | |
58 | 895 childArray.addObject((cast(Accessible)child).control.view); |
45 | 896 } |
897 } | |
123 | 898 |
58 | 899 returnValue = new cocoa.id(OS.NSAccessibilityUnignoredChildren(childArray.id)); |
45 | 900 } |
901 } | |
902 } else { | |
903 // Lightweight children have no children of their own. | |
904 // Don't return null if there are no children -- always return an empty array. | |
905 returnValue = NSArray.array(); | |
906 } | |
123 | 907 |
45 | 908 // Returning null here means we want the control itself to determine its children. If the accessible listener |
909 // implemented getChildCount/getChildren, references to those objects would have been returned above. | |
910 return returnValue; | |
911 } | |
912 | |
58 | 913 cocoa.id getWindowAttribute (int childID) { |
45 | 914 return control.view.window(); |
915 } | |
916 | |
58 | 917 cocoa.id getTopLevelUIElementAttribute (int childID) { |
45 | 918 return control.view.window(); |
919 } | |
920 | |
58 | 921 cocoa.id getPositionAttribute (int childID) { |
922 cocoa.id returnValue = null; | |
45 | 923 AccessibleControlEvent event = new AccessibleControlEvent(this); |
924 event.childID = childID; | |
925 event.width = -1; | |
926 | |
927 for (int i = 0; i < accessibleControlListeners.size(); i++) { | |
58 | 928 AccessibleControlListener listener = accessibleControlListeners.elementAt(i); |
45 | 929 listener.getLocation(event); |
930 } | |
123 | 931 |
60
62202ce0039f
Updated and fixed many modules to 3.514
Jacob Carlborg <doob@me.com>
parents:
59
diff
changeset
|
932 dwt.widgets.Monitor.Monitor primaryMonitor = Display.getCurrent().getPrimaryMonitor(); |
45 | 933 |
58 | 934 NSPoint osPositionAttribute = NSPoint (); |
45 | 935 if (event.width !is -1) { |
936 // The point returned is the lower-left coordinate of the widget in lower-left relative screen coordinates. | |
937 osPositionAttribute.x = event.x; | |
938 osPositionAttribute.y = primaryMonitor.getBounds().height - event.y - event.height; | |
939 returnValue = NSValue.valueWithPoint(osPositionAttribute); | |
940 } else { | |
941 if (childID !is ACC.CHILDID_SELF) { | |
942 Point pt = null; | |
943 Rectangle location = control.getBounds(); | |
123 | 944 |
45 | 945 if (control.getParent() !is null) |
946 pt = control.getParent().toDisplay(location.x, location.y); | |
947 else | |
58 | 948 pt = (cast(Shell)control).toDisplay(location.x, location.y); |
123 | 949 |
45 | 950 osPositionAttribute.x = pt.x; |
951 osPositionAttribute.y = pt.y; | |
952 returnValue = NSValue.valueWithPoint(osPositionAttribute); | |
953 } | |
954 } | |
955 | |
956 return returnValue; | |
957 } | |
958 | |
58 | 959 cocoa.id getSizeAttribute (int childID) { |
960 cocoa.id returnValue = null; | |
45 | 961 AccessibleControlEvent event = new AccessibleControlEvent(this); |
962 event.childID = childID; | |
963 event.width = -1; | |
123 | 964 |
45 | 965 for (int i = 0; i < accessibleControlListeners.size(); i++) { |
58 | 966 AccessibleControlListener listener = accessibleControlListeners.elementAt(i); |
45 | 967 listener.getLocation(event); |
968 } | |
123 | 969 |
58 | 970 NSSize controlSize = NSSize (); |
45 | 971 if (event.width !is -1) { |
972 controlSize.width = event.width; | |
973 controlSize.height = event.height; | |
974 returnValue = NSValue.valueWithSize(controlSize); | |
975 } else { | |
976 if (childID !is ACC.CHILDID_SELF) { | |
977 controlSize.width = controlSize.height = 0; | |
978 returnValue = NSValue.valueWithSize(controlSize); | |
979 } | |
980 } | |
981 | |
982 return returnValue; | |
983 } | |
984 | |
58 | 985 cocoa.id getDescriptionAttribute (int childID) { |
45 | 986 AccessibleEvent event = new AccessibleEvent(this); |
987 event.childID = childID; | |
988 event.result = null; | |
58 | 989 cocoa.id returnValue = null; |
45 | 990 for (int i = 0; i < accessibleListeners.size(); i++) { |
58 | 991 AccessibleListener listener = accessibleListeners.elementAt(i); |
45 | 992 listener.getDescription(event); |
993 } | |
123 | 994 |
45 | 995 returnValue = (event.result !is null ? NSString.stringWith(event.result) : null); |
123 | 996 |
45 | 997 // If no description was provided, try the name. |
998 if (returnValue is null) { | |
58 | 999 if (cast(Composite) control) returnValue = NSString.stringWith(""); |
45 | 1000 } |
123 | 1001 |
45 | 1002 return returnValue; |
1003 } | |
1004 | |
58 | 1005 cocoa.id getInsertionPointLineNumberAttribute (int childID) { |
1006 cocoa.id returnValue = null; | |
45 | 1007 AccessibleControlEvent controlEvent = new AccessibleControlEvent(this); |
1008 controlEvent.childID = childID; | |
1009 controlEvent.result = null; | |
1010 for (int i = 0; i < accessibleControlListeners.size(); i++) { | |
58 | 1011 AccessibleControlListener listener = accessibleControlListeners.elementAt(i); |
45 | 1012 listener.getValue(controlEvent); |
1013 } | |
1014 AccessibleTextEvent textEvent = new AccessibleTextEvent(this); | |
1015 textEvent.childID = childID; | |
1016 textEvent.offset = -1; | |
1017 for (int i = 0; i < accessibleTextListeners.size(); i++) { | |
58 | 1018 AccessibleTextListener listener = accessibleTextListeners.elementAt(i); |
45 | 1019 listener.getCaretOffset(textEvent); |
1020 } | |
1021 if (controlEvent.result !is null && textEvent.offset !is -1) { | |
1022 int lineNumber = lineNumberForOffset (controlEvent.result, textEvent.offset); | |
1023 returnValue = NSNumber.numberWithInt(lineNumber); | |
1024 } | |
1025 return returnValue; | |
1026 } | |
1027 | |
58 | 1028 cocoa.id getNumberOfCharactersAttribute (int childID) { |
1029 cocoa.id returnValue = null; | |
45 | 1030 AccessibleControlEvent event = new AccessibleControlEvent(this); |
1031 event.childID = childID; | |
1032 event.result = null; | |
1033 for (int i = 0; i < accessibleControlListeners.size(); i++) { | |
58 | 1034 AccessibleControlListener listener = accessibleControlListeners.elementAt(i); |
45 | 1035 listener.getValue(event); |
1036 } | |
1037 String appValue = event.result; | |
1038 if (appValue !is null) { | |
1039 returnValue = NSNumber.numberWithInt(appValue.length()); | |
1040 } | |
1041 return returnValue; | |
1042 } | |
1043 | |
58 | 1044 cocoa.id getRangeForLineParameterizedAttribute (cocoa.id parameter, int childID) { |
1045 cocoa.id returnValue = null; | |
123 | 1046 |
45 | 1047 // The parameter is an NSNumber with the line number. |
1048 NSNumber lineNumberObj = new NSNumber(parameter.id); | |
1049 int lineNumber = lineNumberObj.intValue(); | |
61
c74ba20de292
Fix: The application responds to events now
Jacob Carlborg <doob@me.com>
parents:
60
diff
changeset
|
1050 System.out_.println("Line number = " ~ Integer.toString(lineNumber)); |
45 | 1051 AccessibleControlEvent event = new AccessibleControlEvent(this); |
1052 event.childID = childID; | |
1053 event.result = null; | |
1054 for (int i = 0; i < accessibleControlListeners.size(); i++) { | |
58 | 1055 AccessibleControlListener listener = accessibleControlListeners.elementAt(i); |
45 | 1056 listener.getValue(event); |
1057 } | |
1058 if (event.result !is null) { | |
1059 NSRange range = rangeForLineNumber (lineNumber, event.result); | |
1060 if (range.location !is -1) { | |
1061 returnValue = NSValue.valueWithRange(range); | |
1062 } | |
1063 } | |
1064 return returnValue; | |
1065 } | |
1066 | |
58 | 1067 cocoa.id getSelectedTextAttribute (int childID) { |
1068 cocoa.id returnValue = NSString.stringWith(""); | |
45 | 1069 AccessibleTextEvent event = new AccessibleTextEvent(this); |
1070 event.childID = childID; | |
1071 event.offset = -1; | |
1072 event.length = -1; | |
1073 for (int i = 0; i < accessibleTextListeners.size(); i++) { | |
58 | 1074 AccessibleTextListener listener = accessibleTextListeners.elementAt(i); |
45 | 1075 listener.getSelectionRange(event); |
1076 } | |
1077 int offset = event.offset; | |
1078 int length = event.length; | |
1079 if (offset !is -1 && length !is -1 && length !is 0) { // TODO: do we need the && length !is 0 ? | |
1080 AccessibleControlEvent event2 = new AccessibleControlEvent(this); | |
1081 event2.childID = event.childID; | |
1082 event2.result = null; | |
1083 for (int i = 0; i < accessibleControlListeners.size(); i++) { | |
58 | 1084 AccessibleControlListener listener = accessibleControlListeners.elementAt(i); |
45 | 1085 listener.getValue(event2); |
1086 } | |
1087 String appValue = event2.result; | |
1088 if (appValue !is null) { | |
1089 returnValue = NSString.stringWith(appValue.substring(offset, offset + length)); | |
1090 } | |
1091 } | |
1092 return returnValue; | |
1093 } | |
1094 | |
58 | 1095 cocoa.id getSelectedTextRangeAttribute (int childID) { |
1096 cocoa.id returnValue = null; | |
45 | 1097 AccessibleTextEvent event = new AccessibleTextEvent(this); |
1098 event.childID = childID; | |
1099 event.offset = -1; | |
1100 event.length = 0; | |
1101 for (int i = 0; i < accessibleTextListeners.size(); i++) { | |
58 | 1102 AccessibleTextListener listener = accessibleTextListeners.elementAt(i); |
45 | 1103 listener.getSelectionRange(event); |
1104 } | |
1105 if (event.offset !is -1) { | |
46
cfa563df4fdd
Updated Widget and Display to 3.514
Jacob Carlborg <doob@me.com>
parents:
45
diff
changeset
|
1106 NSRange range = NSRange(); |
45 | 1107 range.location = event.offset; |
1108 range.length = event.length; | |
1109 returnValue = NSValue.valueWithRange(range); | |
1110 } | |
1111 return returnValue; | |
1112 } | |
1113 | |
58 | 1114 cocoa.id getStringForRangeAttribute (cocoa.id parameter, int childID) { |
1115 cocoa.id returnValue = null; | |
45 | 1116 |
1117 // Parameter is an NSRange wrapped in an NSValue. | |
1118 NSValue parameterObject = new NSValue(parameter.id); | |
1119 NSRange range = parameterObject.rangeValue(); | |
1120 AccessibleControlEvent event = new AccessibleControlEvent(this); | |
1121 event.childID = childID; | |
1122 event.result = null; | |
1123 for (int i = 0; i < accessibleControlListeners.size(); i++) { | |
58 | 1124 AccessibleControlListener listener = accessibleControlListeners.elementAt(i); |
45 | 1125 listener.getValue(event); |
1126 } | |
1127 String appValue = event.result; | |
123 | 1128 |
45 | 1129 if (appValue !is null) { |
1130 returnValue = NSString.stringWith(appValue.substring(range.location, range.location + range.length)); | |
1131 } | |
123 | 1132 |
45 | 1133 return returnValue; |
1134 } | |
1135 | |
58 | 1136 cocoa.id getSelectedTextRangesAttribute (int childID) { |
45 | 1137 NSMutableArray returnValue = null; |
1138 AccessibleTextEvent event = new AccessibleTextEvent(this); | |
1139 event.childID = childID; | |
1140 event.offset = -1; | |
1141 event.length = 0; | |
1142 | |
1143 for (int i = 0; i < accessibleTextListeners.size(); i++) { | |
58 | 1144 AccessibleTextListener listener = accessibleTextListeners.elementAt(i); |
45 | 1145 listener.getSelectionRange(event); |
1146 } | |
1147 | |
1148 if (event.offset !is -1) { | |
1149 returnValue = NSMutableArray.arrayWithCapacity(1); | |
46
cfa563df4fdd
Updated Widget and Display to 3.514
Jacob Carlborg <doob@me.com>
parents:
45
diff
changeset
|
1150 NSRange range = NSRange(); |
45 | 1151 range.location = event.offset; |
1152 range.length = event.length; | |
1153 returnValue.addObject(NSValue.valueWithRange(range)); | |
1154 } | |
1155 | |
1156 return returnValue; | |
1157 } | |
1158 | |
58 | 1159 cocoa.id getVisibleCharacterRangeAttribute (int childID) { |
45 | 1160 AccessibleControlEvent event = new AccessibleControlEvent(this); |
1161 event.childID = childID; | |
1162 event.result = null; | |
1163 for (int i = 0; i < accessibleControlListeners.size(); i++) { | |
58 | 1164 AccessibleControlListener listener = accessibleControlListeners.elementAt(i); |
45 | 1165 listener.getValue(event); |
1166 } | |
1167 | |
46
cfa563df4fdd
Updated Widget and Display to 3.514
Jacob Carlborg <doob@me.com>
parents:
45
diff
changeset
|
1168 NSRange range = NSRange(); |
123 | 1169 |
45 | 1170 if (event.result !is null) { |
1171 range.location = 0; | |
1172 range.length = event.result.length(); | |
1173 } else { | |
1174 return null; | |
123 | 1175 // range.location = range.length = 0; |
45 | 1176 } |
123 | 1177 |
45 | 1178 return NSValue.valueWithRange(range); |
1179 } | |
123 | 1180 |
45 | 1181 int lineNumberForOffset (String text, int offset) { |
1182 int lineNumber = 1; | |
1183 int length = text.length(); | |
1184 for (int i = 0; i < offset; i++) { | |
1185 switch (text.charAt (i)) { | |
1186 case '\r': | |
1187 if (i + 1 < length) { | |
1188 if (text.charAt (i + 1) is '\n') ++i; | |
1189 } | |
1190 // FALL THROUGH | |
1191 case '\n': | |
1192 lineNumber++; | |
151
0ba75290f8ce
Added a bunch of missing defaults to switch statements
Jacob Carlborg <doob@me.com>
parents:
129
diff
changeset
|
1193 default: |
45 | 1194 } |
1195 } | |
1196 return lineNumber; | |
1197 } | |
123 | 1198 |
45 | 1199 NSRange rangeForLineNumber (int lineNumber, String text) { |
46
cfa563df4fdd
Updated Widget and Display to 3.514
Jacob Carlborg <doob@me.com>
parents:
45
diff
changeset
|
1200 NSRange range = NSRange(); |
45 | 1201 range.location = -1; |
1202 int line = 1; | |
1203 int count = 0; | |
1204 int length = text.length (); | |
1205 for (int i = 0; i < length; i++) { | |
1206 if (line is lineNumber) { | |
1207 if (count is 0) { | |
1208 range.location = i; | |
1209 } | |
1210 count++; | |
1211 } | |
1212 if (line > lineNumber) break; | |
1213 switch (text.charAt (i)) { | |
1214 case '\r': | |
1215 if (i + 1 < length && text.charAt (i + 1) is '\n') i++; | |
1216 // FALL THROUGH | |
1217 case '\n': | |
1218 line++; | |
151
0ba75290f8ce
Added a bunch of missing defaults to switch statements
Jacob Carlborg <doob@me.com>
parents:
129
diff
changeset
|
1219 default: |
45 | 1220 } |
1221 } | |
1222 range.length = count; | |
1223 return range; | |
1224 } | |
123 | 1225 |
45 | 1226 /** |
1227 * Removes the listener from the collection of listeners who will | |
1228 * be notified when an accessible client asks for certain strings, | |
1229 * such as name, description, help, or keyboard shortcut. | |
1230 * | |
1231 * @param listener the listener that should no longer be notified when the receiver | |
1232 * is asked for a name, description, help, or keyboard shortcut string | |
1233 * | |
1234 * @exception IllegalArgumentException <ul> | |
1235 * <li>ERROR_NULL_ARGUMENT - if the listener is null</li> | |
1236 * </ul> | |
1237 * @exception DWTException <ul> | |
1238 * <li>ERROR_WIDGET_DISPOSED - if the receiver's control has been disposed</li> | |
1239 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver's control</li> | |
1240 * </ul> | |
1241 * | |
1242 * @see AccessibleListener | |
1243 * @see #addAccessibleListener | |
1244 */ | |
1245 public void removeAccessibleListener(AccessibleListener listener) { | |
1246 checkWidget(); | |
1247 if (listener is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); | |
1248 accessibleListeners.removeElement(listener); | |
1249 } | |
123 | 1250 |
45 | 1251 /** |
1252 * Removes the listener from the collection of listeners who will | |
1253 * be notified when an accessible client asks for custom control | |
1254 * specific information. | |
1255 * | |
1256 * @param listener the listener that should no longer be notified when the receiver | |
1257 * is asked for custom control specific information | |
1258 * | |
1259 * @exception IllegalArgumentException <ul> | |
1260 * <li>ERROR_NULL_ARGUMENT - if the listener is null</li> | |
1261 * </ul> | |
1262 * @exception DWTException <ul> | |
1263 * <li>ERROR_WIDGET_DISPOSED - if the receiver's control has been disposed</li> | |
1264 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver's control</li> | |
1265 * </ul> | |
1266 * | |
1267 * @see AccessibleControlListener | |
1268 * @see #addAccessibleControlListener | |
1269 */ | |
1270 public void removeAccessibleControlListener(AccessibleControlListener listener) { | |
1271 checkWidget(); | |
1272 if (listener is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); | |
1273 accessibleControlListeners.removeElement(listener); | |
0
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
1274 } |
123 | 1275 |
0
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
1276 /** |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
1277 * Removes the listener from the collection of listeners who will |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
1278 * be notified when an accessible client asks for custom text control |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
1279 * specific information. |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
1280 * |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
1281 * @param listener the listener that should no longer be notified when the receiver |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
1282 * is asked for custom text control specific information |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
1283 * |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
1284 * @exception IllegalArgumentException <ul> |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
1285 * <li>ERROR_NULL_ARGUMENT - if the listener is null</li> |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
1286 * </ul> |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
1287 * @exception DWTException <ul> |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
1288 * <li>ERROR_WIDGET_DISPOSED - if the receiver's control has been disposed</li> |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
1289 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver's control</li> |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
1290 * </ul> |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
1291 * |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
1292 * @see AccessibleTextListener |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
1293 * @see #addAccessibleTextListener |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
1294 * |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
1295 * @since 3.0 |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
1296 */ |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
1297 public void removeAccessibleTextListener (AccessibleTextListener listener) { |
45 | 1298 checkWidget (); |
1299 if (listener is null) DWT.error (DWT.ERROR_NULL_ARGUMENT); | |
1300 accessibleTextListeners.removeElement (listener); | |
0
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
1301 } |
123 | 1302 |
45 | 1303 static NSArray retainedAutoreleased(NSArray inObject) { |
58 | 1304 cocoa.id temp = inObject.retain(); |
1305 cocoa.id temp2 = (new NSObject(temp.id)).autorelease(); | |
45 | 1306 return new NSArray(temp2.id); |
0
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
1307 } |
45 | 1308 |
0
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
1309 /** |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
1310 * Sends a message to accessible clients that the child selection |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
1311 * within a custom container control has changed. |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
1312 * |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
1313 * @exception DWTException <ul> |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
1314 * <li>ERROR_WIDGET_DISPOSED - if the receiver's control has been disposed</li> |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
1315 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver's control</li> |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
1316 * </ul> |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
1317 * |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
1318 * @since 3.0 |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
1319 */ |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
1320 public void selectionChanged () { |
45 | 1321 checkWidget(); |
1322 OS.NSAccessibilityPostNotification(control.view.id, OS.NSAccessibilitySelectedChildrenChangedNotification.id); | |
1323 } | |
123 | 1324 |
45 | 1325 /** |
1326 * Sends a message to accessible clients indicating that the focus | |
1327 * has changed within a custom control. | |
1328 * | |
1329 * @param childID an identifier specifying a child of the control | |
1330 * | |
1331 * @exception DWTException <ul> | |
1332 * <li>ERROR_WIDGET_DISPOSED - if the receiver's control has been disposed</li> | |
1333 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver's control</li> | |
1334 * </ul> | |
1335 */ | |
1336 public void setFocus(int childID) { | |
1337 checkWidget(); | |
1338 OS.NSAccessibilityPostNotification(control.view.id, OS.NSAccessibilityFocusedUIElementChangedNotification.id); | |
0
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
1339 } |
123 | 1340 |
0
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
1341 /** |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
1342 * Sends a message to accessible clients that the text |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
1343 * caret has moved within a custom control. |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
1344 * |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
1345 * @param index the new caret index within the control |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
1346 * |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
1347 * @exception DWTException <ul> |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
1348 * <li>ERROR_WIDGET_DISPOSED - if the receiver's control has been disposed</li> |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
1349 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver's control</li> |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
1350 * </ul> |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
1351 * |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
1352 * @since 3.0 |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
1353 */ |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
1354 public void textCaretMoved (int index) { |
45 | 1355 checkWidget(); |
1356 OS.NSAccessibilityPostNotification(control.view.id, OS.NSAccessibilitySelectedTextChangedNotification.id); | |
0
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
1357 } |
123 | 1358 |
0
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
1359 /** |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
1360 * Sends a message to accessible clients that the text |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
1361 * within a custom control has changed. |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
1362 * |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
1363 * @param type the type of change, one of <code>ACC.NOTIFY_TEXT_INSERT</code> |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
1364 * or <code>ACC.NOTIFY_TEXT_DELETE</code> |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
1365 * @param startIndex the text index within the control where the insertion or deletion begins |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
1366 * @param length the non-negative length in characters of the insertion or deletion |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
1367 * |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
1368 * @exception DWTException <ul> |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
1369 * <li>ERROR_WIDGET_DISPOSED - if the receiver's control has been disposed</li> |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
1370 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver's control</li> |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
1371 * </ul> |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
1372 * |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
1373 * @see ACC#TEXT_INSERT |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
1374 * @see ACC#TEXT_DELETE |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
1375 * |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
1376 * @since 3.0 |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
1377 */ |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
1378 public void textChanged (int type, int startIndex, int length) { |
45 | 1379 checkWidget(); |
1380 OS.NSAccessibilityPostNotification(control.view.id, OS.NSAccessibilityValueChangedNotification.id); | |
0
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
1381 } |
123 | 1382 |
0
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
1383 /** |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
1384 * Sends a message to accessible clients that the text |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
1385 * selection has changed within a custom control. |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
1386 * |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
1387 * @exception DWTException <ul> |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
1388 * <li>ERROR_WIDGET_DISPOSED - if the receiver's control has been disposed</li> |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
1389 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver's control</li> |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
1390 * </ul> |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
1391 * |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
1392 * @since 3.0 |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
1393 */ |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
1394 public void textSelectionChanged () { |
45 | 1395 checkWidget(); |
1396 OS.NSAccessibilityPostNotification(control.view.id, OS.NSAccessibilitySelectedTextChangedNotification.id); | |
0
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
1397 } |
45 | 1398 |
58 | 1399 cocoa.id childIDToOs(int childID) { |
45 | 1400 if (childID is ACC.CHILDID_SELF) { |
1401 return control.view; | |
1402 } | |
123 | 1403 |
45 | 1404 /* Check cache for childID, if found, return corresponding osChildID. */ |
60
62202ce0039f
Updated and fixed many modules to 3.514
Jacob Carlborg <doob@me.com>
parents:
59
diff
changeset
|
1405 SWTAccessibleDelegate childRef = children[childID]; |
45 | 1406 |
1407 if (childRef is null) { | |
1408 childRef = new SWTAccessibleDelegate(this, childID); | |
129 | 1409 children.put(childID, childRef); |
45 | 1410 } |
1411 | |
1412 return childRef; | |
0
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
1413 } |
123 | 1414 |
45 | 1415 NSString concatStringsAsRole(NSString str1, NSString str2) { |
1416 NSString returnValue = str1; | |
1417 returnValue = returnValue.stringByAppendingString(NSString.stringWith(":")); | |
1418 returnValue = returnValue.stringByAppendingString(str2); | |
1419 return returnValue; | |
1420 } | |
1421 | |
1422 String roleToOs(int role) { | |
1423 NSString nsReturnValue = null; //OS.NSAccessibilityUnknownRole; | |
1424 | |
1425 switch (role) { | |
1426 case ACC.ROLE_CLIENT_AREA: nsReturnValue = OS.NSAccessibilityGroupRole; break; | |
1427 case ACC.ROLE_WINDOW: nsReturnValue = OS.NSAccessibilityWindowRole; break; | |
1428 case ACC.ROLE_MENUBAR: nsReturnValue = OS.NSAccessibilityMenuBarRole; break; | |
1429 case ACC.ROLE_MENU: nsReturnValue = OS.NSAccessibilityMenuRole; break; | |
1430 case ACC.ROLE_MENUITEM: nsReturnValue = OS.NSAccessibilityMenuItemRole; break; | |
1431 case ACC.ROLE_SEPARATOR: nsReturnValue = OS.NSAccessibilitySplitterRole; break; | |
1432 case ACC.ROLE_TOOLTIP: nsReturnValue = OS.NSAccessibilityHelpTagRole; break; | |
1433 case ACC.ROLE_SCROLLBAR: nsReturnValue = OS.NSAccessibilityScrollBarRole; break; | |
1434 case ACC.ROLE_DIALOG: nsReturnValue = concatStringsAsRole(OS.NSAccessibilityWindowRole, OS.NSAccessibilityDialogSubrole); break; | |
1435 case ACC.ROLE_LABEL: nsReturnValue = OS.NSAccessibilityStaticTextRole; break; | |
1436 case ACC.ROLE_PUSHBUTTON: nsReturnValue = OS.NSAccessibilityButtonRole; break; | |
1437 case ACC.ROLE_CHECKBUTTON: nsReturnValue = OS.NSAccessibilityCheckBoxRole; break; | |
1438 case ACC.ROLE_RADIOBUTTON: nsReturnValue = OS.NSAccessibilityRadioButtonRole; break; | |
1439 case ACC.ROLE_COMBOBOX: nsReturnValue = OS.NSAccessibilityComboBoxRole; break; | |
1440 case ACC.ROLE_TEXT: { | |
1441 int style = control.getStyle(); | |
1442 | |
1443 if ((style & DWT.MULTI) !is 0) { | |
1444 nsReturnValue = OS.NSAccessibilityTextAreaRole; | |
1445 } else { | |
1446 nsReturnValue = OS.NSAccessibilityTextFieldRole; | |
1447 } | |
1448 | |
1449 break; | |
1450 } | |
1451 case ACC.ROLE_TOOLBAR: nsReturnValue = OS.NSAccessibilityToolbarRole; break; | |
1452 case ACC.ROLE_LIST: nsReturnValue = OS.NSAccessibilityOutlineRole; break; | |
1453 case ACC.ROLE_LISTITEM: nsReturnValue = OS.NSAccessibilityStaticTextRole; break; | |
1454 case ACC.ROLE_TABLE: nsReturnValue = OS.NSAccessibilityTableRole; break; | |
1455 case ACC.ROLE_TABLECELL: nsReturnValue = concatStringsAsRole(OS.NSAccessibilityRowRole, OS.NSAccessibilityTableRowSubrole); break; | |
1456 case ACC.ROLE_TABLECOLUMNHEADER: nsReturnValue = OS.NSAccessibilitySortButtonRole; break; | |
1457 case ACC.ROLE_TABLEROWHEADER: nsReturnValue = concatStringsAsRole(OS.NSAccessibilityRowRole, OS.NSAccessibilityTableRowSubrole); break; | |
1458 case ACC.ROLE_TREE: nsReturnValue = OS.NSAccessibilityOutlineRole; break; | |
1459 case ACC.ROLE_TREEITEM: nsReturnValue = concatStringsAsRole(OS.NSAccessibilityOutlineRole, OS.NSAccessibilityOutlineRowSubrole); break; | |
1460 case ACC.ROLE_TABFOLDER: nsReturnValue = OS.NSAccessibilityTabGroupRole; break; | |
1461 case ACC.ROLE_TABITEM: nsReturnValue = OS.NSAccessibilityRadioButtonRole; break; | |
1462 case ACC.ROLE_PROGRESSBAR: nsReturnValue = OS.NSAccessibilityProgressIndicatorRole; break; | |
1463 case ACC.ROLE_SLIDER: nsReturnValue = OS.NSAccessibilitySliderRole; break; | |
1464 case ACC.ROLE_LINK: nsReturnValue = OS.NSAccessibilityLinkRole; break; | |
151
0ba75290f8ce
Added a bunch of missing defaults to switch statements
Jacob Carlborg <doob@me.com>
parents:
129
diff
changeset
|
1465 default: |
45 | 1466 } |
123 | 1467 |
45 | 1468 return nsReturnValue.getString(); |
0
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
1469 } |
123 | 1470 |
45 | 1471 int osToRole(NSString osRole) { |
1472 if (osRole is null) return 0; | |
1473 if (osRole.isEqualToString(OS.NSAccessibilityWindowRole)) return ACC.ROLE_WINDOW; | |
1474 if (osRole.isEqualToString(OS.NSAccessibilityMenuBarRole)) return ACC.ROLE_MENUBAR; | |
1475 if (osRole.isEqualToString(OS.NSAccessibilityMenuRole)) return ACC.ROLE_MENU; | |
1476 if (osRole.isEqualToString(OS.NSAccessibilityMenuItemRole)) return ACC.ROLE_MENUITEM; | |
1477 if (osRole.isEqualToString(OS.NSAccessibilitySplitterRole)) return ACC.ROLE_SEPARATOR; | |
1478 if (osRole.isEqualToString(OS.NSAccessibilityHelpTagRole)) return ACC.ROLE_TOOLTIP; | |
1479 if (osRole.isEqualToString(OS.NSAccessibilityScrollBarRole)) return ACC.ROLE_SCROLLBAR; | |
1480 if (osRole.isEqualToString(OS.NSAccessibilityScrollAreaRole)) return ACC.ROLE_LIST; | |
1481 if (osRole.isEqualToString(concatStringsAsRole(OS.NSAccessibilityWindowRole, OS.NSAccessibilityDialogSubrole))) return ACC.ROLE_DIALOG; | |
1482 if (osRole.isEqualToString(concatStringsAsRole(OS.NSAccessibilityWindowRole, OS.NSAccessibilitySystemDialogSubrole))) return ACC.ROLE_DIALOG; | |
1483 if (osRole.isEqualToString(OS.NSAccessibilityStaticTextRole)) return ACC.ROLE_LABEL; | |
1484 if (osRole.isEqualToString(OS.NSAccessibilityButtonRole)) return ACC.ROLE_PUSHBUTTON; | |
1485 if (osRole.isEqualToString(OS.NSAccessibilityCheckBoxRole)) return ACC.ROLE_CHECKBUTTON; | |
1486 if (osRole.isEqualToString(OS.NSAccessibilityRadioButtonRole)) return ACC.ROLE_RADIOBUTTON; | |
1487 if (osRole.isEqualToString(OS.NSAccessibilityComboBoxRole)) return ACC.ROLE_COMBOBOX; | |
1488 if (osRole.isEqualToString(OS.NSAccessibilityTextFieldRole)) return ACC.ROLE_TEXT; | |
1489 if (osRole.isEqualToString(OS.NSAccessibilityTextAreaRole)) return ACC.ROLE_TEXT; | |
1490 if (osRole.isEqualToString(OS.NSAccessibilityToolbarRole)) return ACC.ROLE_TOOLBAR; | |
1491 if (osRole.isEqualToString(OS.NSAccessibilityListRole)) return ACC.ROLE_LIST; | |
1492 if (osRole.isEqualToString(OS.NSAccessibilityTableRole)) return ACC.ROLE_TABLE; | |
1493 if (osRole.isEqualToString(OS.NSAccessibilityColumnRole)) return ACC.ROLE_TABLECOLUMNHEADER; | |
1494 if (osRole.isEqualToString(concatStringsAsRole(OS.NSAccessibilityButtonRole, OS.NSAccessibilitySortButtonRole))) return ACC.ROLE_TABLECOLUMNHEADER; | |
1495 if (osRole.isEqualToString(concatStringsAsRole(OS.NSAccessibilityRowRole, OS.NSAccessibilityTableRowSubrole))) return ACC.ROLE_TABLEROWHEADER; | |
1496 if (osRole.isEqualToString(OS.NSAccessibilityOutlineRole)) return ACC.ROLE_TREE; | |
1497 if (osRole.isEqualToString(concatStringsAsRole(OS.NSAccessibilityOutlineRole, OS.NSAccessibilityOutlineRowSubrole))) return ACC.ROLE_TREEITEM; | |
1498 if (osRole.isEqualToString(OS.NSAccessibilityTabGroupRole)) return ACC.ROLE_TABFOLDER; | |
1499 if (osRole.isEqualToString(OS.NSAccessibilityProgressIndicatorRole)) return ACC.ROLE_PROGRESSBAR; | |
1500 if (osRole.isEqualToString(OS.NSAccessibilitySliderRole)) return ACC.ROLE_SLIDER; | |
1501 if (osRole.isEqualToString(OS.NSAccessibilityLinkRole)) return ACC.ROLE_LINK; | |
1502 return ACC.ROLE_CLIENT_AREA; | |
0
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
1503 } |
45 | 1504 |
1505 /* checkWidget was copied from Widget, and rewritten to work in this package */ | |
1506 void checkWidget () { | |
1507 if (!isValidThread ()) DWT.error (DWT.ERROR_THREAD_INVALID_ACCESS); | |
1508 if (control.isDisposed ()) DWT.error (DWT.ERROR_WIDGET_DISPOSED); | |
1509 } | |
123 | 1510 |
45 | 1511 /* isValidThread was copied from Widget, and rewritten to work in this package */ |
1512 bool isValidThread () { | |
60
62202ce0039f
Updated and fixed many modules to 3.514
Jacob Carlborg <doob@me.com>
parents:
59
diff
changeset
|
1513 return control.getDisplay ().getThread () is Thread.getThis (); |
45 | 1514 } |
123 | 1515 |
0
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
1516 } |