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