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