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