comparison dwt/accessibility/Accessible.d @ 123:63a09873578e

Fixed compile errors
author Jacob Carlborg <doob@me.com>
date Thu, 15 Jan 2009 23:08:54 +0100
parents c74ba20de292
children 07399639c0c8
comparison
equal deleted inserted replaced
122:2e671fa40eec 123:63a09873578e
71 * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a> 71 * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
72 * 72 *
73 * @since 2.0 73 * @since 2.0
74 */ 74 */
75 public class Accessible { 75 public class Accessible {
76 76
77 static NSString[] baseAttributes; 77 static NSString[] baseAttributes;
78 78
79 static NSString[] baseTextAttributes; 79 static NSString[] baseTextAttributes;
80 80
81 static NSString[] baseParameterizedAttributes; 81 static NSString[] baseParameterizedAttributes;
82 82
83 83
84 NSMutableArray attributeNames = null; 84 NSMutableArray attributeNames = null;
85 NSMutableArray parameterizedAttributeNames = null; 85 NSMutableArray parameterizedAttributeNames = null;
86 NSMutableArray actionNames = null; 86 NSMutableArray actionNames = null;
87 87
88 AccessibleListener[] accessibleListeners; 88 AccessibleListener[] accessibleListeners;
89 AccessibleControlListener[] accessibleControlListeners; 89 AccessibleControlListener[] accessibleControlListeners;
90 AccessibleTextListener[] accessibleTextListeners; 90 AccessibleTextListener[] accessibleTextListeners;
91 Control control; 91 Control control;
92 92
93 HashMap!(int, SWTAccessibleDelegate) children; 93 HashMap!(int, SWTAccessibleDelegate) children;
94 94
95 this (Control control) { 95 this (Control control) {
96 96
97 this.control = control; 97 this.control = control;
98 98
99 baseAttributes = [ 99 baseAttributes = [
100 OS.NSAccessibilityRoleAttribute, 100 OS.NSAccessibilityRoleAttribute,
101 OS.NSAccessibilityRoleDescriptionAttribute, 101 OS.NSAccessibilityRoleDescriptionAttribute,
105 OS.NSAccessibilityChildrenAttribute, 105 OS.NSAccessibilityChildrenAttribute,
106 OS.NSAccessibilityPositionAttribute, 106 OS.NSAccessibilityPositionAttribute,
107 OS.NSAccessibilitySizeAttribute, 107 OS.NSAccessibilitySizeAttribute,
108 OS.NSAccessibilityWindowAttribute, 108 OS.NSAccessibilityWindowAttribute,
109 OS.NSAccessibilityTopLevelUIElementAttribute 109 OS.NSAccessibilityTopLevelUIElementAttribute
110 ]; 110 ];
111 111
112 baseTextAttributes = [ 112 baseTextAttributes = [
113 OS.NSAccessibilityNumberOfCharactersAttribute, 113 OS.NSAccessibilityNumberOfCharactersAttribute,
114 OS.NSAccessibilitySelectedTextAttribute, 114 OS.NSAccessibilitySelectedTextAttribute,
115 OS.NSAccessibilitySelectedTextRangeAttribute, 115 OS.NSAccessibilitySelectedTextRangeAttribute,
116 OS.NSAccessibilityInsertionPointLineNumberAttribute, 116 OS.NSAccessibilityInsertionPointLineNumberAttribute,
117 OS.NSAccessibilitySelectedTextRangesAttribute, 117 OS.NSAccessibilitySelectedTextRangesAttribute,
118 OS.NSAccessibilityVisibleCharacterRangeAttribute, 118 OS.NSAccessibilityVisibleCharacterRangeAttribute,
119 OS.NSAccessibilityValueAttribute 119 OS.NSAccessibilityValueAttribute
120 ]; 120 ];
121 121
122 baseParameterizedAttributes = [ 122 baseParameterizedAttributes = [
123 OS.NSAccessibilityStringForRangeParameterizedAttribute, 123 OS.NSAccessibilityStringForRangeParameterizedAttribute,
124 OS.NSAccessibilityRangeForLineParameterizedAttribute 124 OS.NSAccessibilityRangeForLineParameterizedAttribute
125 ]; 125 ];
126 } 126 }
127 127
128 /** 128 /**
129 * Invokes platform specific functionality to allocate a new accessible object. 129 * Invokes platform specific functionality to allocate a new accessible object.
130 * <p> 130 * <p>
139 * @return the platform specific accessible object 139 * @return the platform specific accessible object
140 */ 140 */
141 public static Accessible internal_new_Accessible(Control control) { 141 public static Accessible internal_new_Accessible(Control control) {
142 return new Accessible(control); 142 return new Accessible(control);
143 } 143 }
144 144
145 /** 145 /**
146 * Adds the listener to the collection of listeners who will 146 * Adds the listener to the collection of listeners who will
147 * be notified when an accessible client asks for certain strings, 147 * be notified when an accessible client asks for certain strings,
148 * such as name, description, help, or keyboard shortcut. The 148 * such as name, description, help, or keyboard shortcut. The
149 * listener is notified by sending it one of the messages defined 149 * listener is notified by sending it one of the messages defined
166 public void addAccessibleListener (AccessibleListener listener) { 166 public void addAccessibleListener (AccessibleListener listener) {
167 checkWidget(); 167 checkWidget();
168 if (listener is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); 168 if (listener is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
169 accessibleListeners.addElement(listener); 169 accessibleListeners.addElement(listener);
170 } 170 }
171 171
172 /** 172 /**
173 * Adds the listener to the collection of listeners who will 173 * Adds the listener to the collection of listeners who will
174 * be notified when an accessible client asks for custom control 174 * be notified when an accessible client asks for custom control
175 * specific information. The listener is notified by sending it 175 * specific information. The listener is notified by sending it
176 * one of the messages defined in the <code>AccessibleControlListener</code> 176 * one of the messages defined in the <code>AccessibleControlListener</code>
193 public void addAccessibleControlListener(AccessibleControlListener listener) { 193 public void addAccessibleControlListener(AccessibleControlListener listener) {
194 checkWidget(); 194 checkWidget();
195 if (listener is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); 195 if (listener is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
196 accessibleControlListeners.addElement(listener); 196 accessibleControlListeners.addElement(listener);
197 } 197 }
198 198
199 /** 199 /**
200 * Adds the listener to the collection of listeners who will 200 * Adds the listener to the collection of listeners who will
201 * be notified when an accessible client asks for custom text control 201 * be notified when an accessible client asks for custom text control
202 * specific information. The listener is notified by sending it 202 * specific information. The listener is notified by sending it
203 * one of the messages defined in the <code>AccessibleTextListener</code> 203 * one of the messages defined in the <code>AccessibleTextListener</code>
227 227
228 public cocoa.id internal_accessibilityActionDescription(NSString action, int childID) { 228 public cocoa.id internal_accessibilityActionDescription(NSString action, int childID) {
229 // TODO No action support for now. 229 // TODO No action support for now.
230 return NSString.stringWith(""); 230 return NSString.stringWith("");
231 } 231 }
232 232
233 public NSArray internal_accessibilityActionNames(int childID) { 233 public NSArray internal_accessibilityActionNames(int childID) {
234 // The supported action list depends on the role played by the control. 234 // The supported action list depends on the role played by the control.
235 AccessibleControlEvent event = new AccessibleControlEvent(this); 235 AccessibleControlEvent event = new AccessibleControlEvent(this);
236 event.childID = childID; 236 event.childID = childID;
237 event.detail = -1; 237 event.detail = -1;
238 for (int i = 0; i < accessibleControlListeners.size(); i++) { 238 for (int i = 0; i < accessibleControlListeners.size(); i++) {
239 AccessibleControlListener listener = elementAt(accessibleControlListeners, i); 239 AccessibleControlListener listener = elementAt(accessibleControlListeners, i);
240 listener.getRole(event); 240 listener.getRole(event);
241 } 241 }
242 242
243 // No accessible listener is overriding the role of the control, so let Cocoa return the default set for the control. 243 // No accessible listener is overriding the role of the control, so let Cocoa return the default set for the control.
244 if (event.detail is -1) { 244 if (event.detail is -1) {
245 return null; 245 return null;
246 } 246 }
247 247
250 } 250 }
251 251
252 NSMutableArray returnValue = NSMutableArray.arrayWithCapacity(5); 252 NSMutableArray returnValue = NSMutableArray.arrayWithCapacity(5);
253 253
254 switch (event.detail) { 254 switch (event.detail) {
255 case ACC.ROLE_PUSHBUTTON: 255 case ACC.ROLE_PUSHBUTTON:
256 case ACC.ROLE_RADIOBUTTON: 256 case ACC.ROLE_RADIOBUTTON:
257 case ACC.ROLE_CHECKBUTTON: 257 case ACC.ROLE_CHECKBUTTON:
258 case ACC.ROLE_TABITEM: 258 case ACC.ROLE_TABITEM:
259 returnValue.addObject(OS.NSAccessibilityPressAction); 259 returnValue.addObject(OS.NSAccessibilityPressAction);
260 break; 260 break;
261 } 261 }
262 262
263 switch (event.detail) { 263 switch (event.detail) {
264 case ACC.ROLE_COMBOBOX: 264 case ACC.ROLE_COMBOBOX:
265 returnValue.addObject(OS.NSAccessibilityConfirmAction); 265 returnValue.addObject(OS.NSAccessibilityConfirmAction);
266 break; 266 break;
267 } 267 }
268 268
269 269
270 if (childID is ACC.CHILDID_SELF) { 270 if (childID is ACC.CHILDID_SELF) {
271 actionNames = returnValue; 271 actionNames = returnValue;
272 actionNames.retain(); 272 actionNames.retain();
273 return retainedAutoreleased(actionNames); 273 return retainedAutoreleased(actionNames);
274 } else { 274 } else {
275 // Caller must retain if they want to hold on to it. 275 // Caller must retain if they want to hold on to it.
276 return returnValue; 276 return returnValue;
277 } 277 }
278 } 278 }
279 279
280 public NSArray internal_accessibilityAttributeNames(int childID) { 280 public NSArray internal_accessibilityAttributeNames(int childID) {
281 // The supported attribute set depends on the role played by the control. 281 // The supported attribute set depends on the role played by the control.
282 // We may need to add or remove from the base set as needed. 282 // We may need to add or remove from the base set as needed.
283 AccessibleControlEvent event = new AccessibleControlEvent(this); 283 AccessibleControlEvent event = new AccessibleControlEvent(this);
284 event.childID = childID; 284 event.childID = childID;
285 event.detail = -1; 285 event.detail = -1;
286 for (int i = 0; i < accessibleControlListeners.size(); i++) { 286 for (int i = 0; i < accessibleControlListeners.size(); i++) {
287 AccessibleControlListener listener = accessibleControlListeners.elementAt(i); 287 AccessibleControlListener listener = accessibleControlListeners.elementAt(i);
288 listener.getRole(event); 288 listener.getRole(event);
289 } 289 }
290 290
291 // No accessible listener is overriding the role of the control, so let Cocoa 291 // No accessible listener is overriding the role of the control, so let Cocoa
292 // return the default set for the control. 292 // return the default set for the control.
293 if (event.detail is -1) 293 if (event.detail is -1)
294 return null; 294 return null;
295 295
296 if ((childID is ACC.CHILDID_SELF) && (attributeNames !is null)) { 296 if ((childID is ACC.CHILDID_SELF) && (attributeNames !is null)) {
297 return retainedAutoreleased(attributeNames); 297 return retainedAutoreleased(attributeNames);
298 } 298 }
299 299
300 NSMutableArray returnValue = NSMutableArray.arrayWithCapacity(baseAttributes.length); 300 NSMutableArray returnValue = NSMutableArray.arrayWithCapacity(baseAttributes.length);
301 301
302 /* Add our list of supported attributes to the array. 302 /* Add our list of supported attributes to the array.
303 * Make sure each attribute name is not already in the array before appending. 303 * Make sure each attribute name is not already in the array before appending.
304 */ 304 */
305 for (int i = 0; i < baseAttributes.length; i++) { 305 for (int i = 0; i < baseAttributes.length; i++) {
306 if (!returnValue.containsObject(baseAttributes[i])) { 306 if (!returnValue.containsObject(baseAttributes[i])) {
316 } 316 }
317 } 317 }
318 318
319 // The following are expected to have a value (AXValue) 319 // The following are expected to have a value (AXValue)
320 switch (event.detail) { 320 switch (event.detail) {
321 case ACC.ROLE_CHECKBUTTON: 321 case ACC.ROLE_CHECKBUTTON:
322 case ACC.ROLE_RADIOBUTTON: 322 case ACC.ROLE_RADIOBUTTON:
323 case ACC.ROLE_LABEL: 323 case ACC.ROLE_LABEL:
324 case ACC.ROLE_TABITEM: 324 case ACC.ROLE_TABITEM:
325 case ACC.ROLE_TABFOLDER: 325 case ACC.ROLE_TABFOLDER:
326 returnValue.addObject(OS.NSAccessibilityValueAttribute); 326 returnValue.addObject(OS.NSAccessibilityValueAttribute);
327 break; 327 break;
328 } 328 }
329 329
330 // The following are expected to report their enabled status (AXEnabled) 330 // The following are expected to report their enabled status (AXEnabled)
331 switch (event.detail) { 331 switch (event.detail) {
332 case ACC.ROLE_CHECKBUTTON: 332 case ACC.ROLE_CHECKBUTTON:
333 case ACC.ROLE_RADIOBUTTON: 333 case ACC.ROLE_RADIOBUTTON:
334 case ACC.ROLE_LABEL: 334 case ACC.ROLE_LABEL:
335 case ACC.ROLE_TABITEM: 335 case ACC.ROLE_TABITEM:
336 case ACC.ROLE_PUSHBUTTON: 336 case ACC.ROLE_PUSHBUTTON:
337 case ACC.ROLE_COMBOBOX: 337 case ACC.ROLE_COMBOBOX:
338 returnValue.addObject(OS.NSAccessibilityEnabledAttribute); 338 returnValue.addObject(OS.NSAccessibilityEnabledAttribute);
339 break; 339 break;
340 } 340 }
341 341
342 // The following are expected to report a title (AXTitle) 342 // The following are expected to report a title (AXTitle)
343 switch (event.detail) { 343 switch (event.detail) {
344 case ACC.ROLE_CHECKBUTTON: 344 case ACC.ROLE_CHECKBUTTON:
345 case ACC.ROLE_RADIOBUTTON: 345 case ACC.ROLE_RADIOBUTTON:
346 case ACC.ROLE_PUSHBUTTON: 346 case ACC.ROLE_PUSHBUTTON:
347 case ACC.ROLE_TABITEM: 347 case ACC.ROLE_TABITEM:
348 returnValue.addObject(OS.NSAccessibilityTitleAttribute); 348 returnValue.addObject(OS.NSAccessibilityTitleAttribute);
349 break; 349 break;
350 } 350 }
351 351
352 // Accessibility verifier says these attributes must be reported for combo boxes. 352 // Accessibility verifier says these attributes must be reported for combo boxes.
353 if (event.detail is ACC.ROLE_COMBOBOX) { 353 if (event.detail is ACC.ROLE_COMBOBOX) {
354 returnValue.addObject(OS.NSAccessibilityExpandedAttribute); 354 returnValue.addObject(OS.NSAccessibilityExpandedAttribute);
355 } 355 }
356 356
357 // Accessibility verifier says these attributes must be reported for tab folders. 357 // Accessibility verifier says these attributes must be reported for tab folders.
358 if (event.detail is ACC.ROLE_TABFOLDER) { 358 if (event.detail is ACC.ROLE_TABFOLDER) {
359 returnValue.addObject(OS.NSAccessibilityContentsAttribute); 359 returnValue.addObject(OS.NSAccessibilityContentsAttribute);
360 returnValue.addObject(OS.NSAccessibilityTabsAttribute); 360 returnValue.addObject(OS.NSAccessibilityTabsAttribute);
361 } 361 }
362 362
363 /* 363 /*
364 * Only report back sub-roles when the DWT role maps to a sub-role. 364 * Only report back sub-roles when the DWT role maps to a sub-role.
365 */ 365 */
366 if (event.detail !is -1) { 366 if (event.detail !is -1) {
367 String osRole = roleToOs(event.detail); 367 String osRole = roleToOs(event.detail);
368 368
369 if (dwt.dwthelper.utils.indexOf(osRole, ':') is -1) 369 if (dwt.dwthelper.utils.indexOf(osRole, ':') is -1)
370 returnValue.removeObject(OS.NSAccessibilitySubroleAttribute); 370 returnValue.removeObject(OS.NSAccessibilitySubroleAttribute);
371 } 371 }
372 372
373 /* 373 /*
374 * Children never return their own children, so remove that attribute. 374 * Children never return their own children, so remove that attribute.
375 */ 375 */
376 if (childID !is ACC.CHILDID_SELF) { 376 if (childID !is ACC.CHILDID_SELF) {
377 returnValue.removeObject(OS.NSAccessibilityChildrenAttribute); 377 returnValue.removeObject(OS.NSAccessibilityChildrenAttribute);
384 } else { 384 } else {
385 // Caller must retain if necessary. 385 // Caller must retain if necessary.
386 return returnValue; 386 return returnValue;
387 } 387 }
388 } 388 }
389 389
390 public cocoa.id internal_accessibilityAttributeValue(NSString attribute, int childID) { 390 public cocoa.id internal_accessibilityAttributeValue(NSString attribute, int childID) {
391 if (attribute.isEqualToString(OS.NSAccessibilityRoleAttribute)) return getRoleAttribute(childID); 391 if (attribute.isEqualToString(OS.NSAccessibilityRoleAttribute)) return getRoleAttribute(childID);
392 if (attribute.isEqualToString(OS.NSAccessibilitySubroleAttribute)) return getSubroleAttribute(childID); 392 if (attribute.isEqualToString(OS.NSAccessibilitySubroleAttribute)) return getSubroleAttribute(childID);
393 if (attribute.isEqualToString(OS.NSAccessibilityRoleDescriptionAttribute)) return getRoleDescriptionAttribute(childID); 393 if (attribute.isEqualToString(OS.NSAccessibilityRoleDescriptionAttribute)) return getRoleDescriptionAttribute(childID);
394 if (attribute.isEqualToString(OS.NSAccessibilityExpandedAttribute)) return getExpandedAttribute(childID); 394 if (attribute.isEqualToString(OS.NSAccessibilityExpandedAttribute)) return getExpandedAttribute(childID);
421 public cocoa.id internal_accessibilityAttributeValue_forParameter(NSString attribute, cocoa.id parameter, int childID) { 421 public cocoa.id internal_accessibilityAttributeValue_forParameter(NSString attribute, cocoa.id parameter, int childID) {
422 if (attribute.isEqualToString(OS.NSAccessibilityStringForRangeParameterizedAttribute)) return getStringForRangeAttribute(parameter, childID); 422 if (attribute.isEqualToString(OS.NSAccessibilityStringForRangeParameterizedAttribute)) return getStringForRangeAttribute(parameter, childID);
423 if (attribute.isEqualToString(OS.NSAccessibilityRangeForLineParameterizedAttribute)) return getRangeForLineParameterizedAttribute(parameter, childID); 423 if (attribute.isEqualToString(OS.NSAccessibilityRangeForLineParameterizedAttribute)) return getRangeForLineParameterizedAttribute(parameter, childID);
424 return null; 424 return null;
425 } 425 }
426 426
427 // Returns the UI Element that has the focus. You can assume that the search for the focus has already been narrowed down to the receiver. 427 // Returns the UI Element that has the focus. You can assume that the search for the focus has already been narrowed down to the receiver.
428 // Override this method to do a deeper search with a UIElement - e.g. a NSMatrix would determine if one of its cells has the focus. 428 // Override this method to do a deeper search with a UIElement - e.g. a NSMatrix would determine if one of its cells has the focus.
429 public cocoa.id internal_accessibilityFocusedUIElement(int childID) { 429 public cocoa.id internal_accessibilityFocusedUIElement(int childID) {
430 AccessibleControlEvent event = new AccessibleControlEvent(this); 430 AccessibleControlEvent event = new AccessibleControlEvent(this);
431 event.childID = ACC.CHILDID_MULTIPLE; // set to invalid value, to test if the application sets it in getFocus() 431 event.childID = ACC.CHILDID_MULTIPLE; // set to invalid value, to test if the application sets it in getFocus()
446 446
447 /* Or the application can answer a valid child ID, including CHILDID_SELF and CHILDID_NONE. */ 447 /* Or the application can answer a valid child ID, including CHILDID_SELF and CHILDID_NONE. */
448 if (event.childID is ACC.CHILDID_SELF || event.childID is ACC.CHILDID_NONE) { 448 if (event.childID is ACC.CHILDID_SELF || event.childID is ACC.CHILDID_NONE) {
449 return new cocoa.id(OS.NSAccessibilityUnignoredAncestor(control.view.id)); 449 return new cocoa.id(OS.NSAccessibilityUnignoredAncestor(control.view.id));
450 } 450 }
451 451
452 return new cocoa.id(OS.NSAccessibilityUnignoredAncestor(childIDToOs(event.childID).id)); 452 return new cocoa.id(OS.NSAccessibilityUnignoredAncestor(childIDToOs(event.childID).id));
453 } 453 }
454 454
455 // Returns the deepest descendant of the UIElement hierarchy that contains the point. 455 // Returns the deepest descendant of the UIElement hierarchy that contains the point.
456 // You can assume the point has already been determined to lie within the receiver. 456 // You can assume the point has already been determined to lie within the receiver.
457 // Override this method to do deeper hit testing within a UIElement - e.g. a NSMatrix would test its cells. The point is bottom-left relative screen coordinates. 457 // Override this method to do deeper hit testing within a UIElement - e.g. a NSMatrix would test its cells. The point is bottom-left relative screen coordinates.
458 public cocoa.id internal_accessibilityHitTest(NSPoint point, int childID) { 458 public cocoa.id internal_accessibilityHitTest(NSPoint point, int childID) {
459 AccessibleControlEvent event = new AccessibleControlEvent(this); 459 AccessibleControlEvent event = new AccessibleControlEvent(this);
460 event.x = cast(int) point.x; 460 event.x = cast(int) point.x;
461 dwt.widgets.Monitor.Monitor primaryMonitor = Display.getCurrent().getPrimaryMonitor(); 461 dwt.widgets.Monitor.Monitor primaryMonitor = Display.getCurrent().getPrimaryMonitor();
462 event.y = cast(int) (primaryMonitor.getBounds().height - point.y); 462 event.y = cast(int) (primaryMonitor.getBounds().height - point.y);
463 463
464 // Set an impossible value to determine if anything responded to the event. 464 // Set an impossible value to determine if anything responded to the event.
465 event.childID = ACC.CHILDID_MULTIPLE; 465 event.childID = ACC.CHILDID_MULTIPLE;
466 for (int i = 0; i < accessibleControlListeners.size(); i++) { 466 for (int i = 0; i < accessibleControlListeners.size(); i++) {
467 AccessibleControlListener listener = accessibleControlListeners.elementAt(i); 467 AccessibleControlListener listener = accessibleControlListeners.elementAt(i);
468 listener.getChildAtPoint(event); 468 listener.getChildAtPoint(event);
473 return null; 473 return null;
474 474
475 if (event.accessible !is null) { 475 if (event.accessible !is null) {
476 return new cocoa.id(OS.NSAccessibilityUnignoredAncestor(event.accessible.control.view.id)); 476 return new cocoa.id(OS.NSAccessibilityUnignoredAncestor(event.accessible.control.view.id));
477 } 477 }
478 478
479 if (event.childID is ACC.CHILDID_SELF || event.childID is ACC.CHILDID_NONE) { 479 if (event.childID is ACC.CHILDID_SELF || event.childID is ACC.CHILDID_NONE) {
480 return new cocoa.id(OS.NSAccessibilityUnignoredAncestor(control.view.id)); 480 return new cocoa.id(OS.NSAccessibilityUnignoredAncestor(control.view.id));
481 } 481 }
482 482
483 return new cocoa.id(OS.NSAccessibilityUnignoredAncestor(childIDToOs(event.childID).id)); 483 return new cocoa.id(OS.NSAccessibilityUnignoredAncestor(childIDToOs(event.childID).id));
484 } 484 }
485 485
486 public bool internal_accessibilityIsAttributeSettable(NSString attribute, int childID) { 486 public bool internal_accessibilityIsAttributeSettable(NSString attribute, int childID) {
487 return false; 487 return false;
488 } 488 }
489 489
490 // Return YES if the UIElement doesn't show up to the outside world - i.e. its parent should return the UIElement's children as its own - cutting the UIElement out. E.g. NSControls are ignored when they are single-celled. 490 // Return YES if the UIElement doesn't show up to the outside world - i.e. its parent should return the UIElement's children as its own - cutting the UIElement out. E.g. NSControls are ignored when they are single-celled.
491 public bool internal_accessibilityIsIgnored(int childID) { 491 public bool internal_accessibilityIsIgnored(int childID) {
492 return false; 492 return false;
493 } 493 }
494 494
495 // parameterized attribute methods 495 // parameterized attribute methods
496 public NSArray internal_accessibilityParameterizedAttributeNames(int childID) { 496 public NSArray internal_accessibilityParameterizedAttributeNames(int childID) {
497 497
498 if ((childID is ACC.CHILDID_SELF) && (parameterizedAttributeNames !is null)) { 498 if ((childID is ACC.CHILDID_SELF) && (parameterizedAttributeNames !is null)) {
499 return retainedAutoreleased(parameterizedAttributeNames); 499 return retainedAutoreleased(parameterizedAttributeNames);
500 } 500 }
501 501
502 NSMutableArray returnValue = NSMutableArray.arrayWithCapacity(4); 502 NSMutableArray returnValue = NSMutableArray.arrayWithCapacity(4);
503 503
504 if (accessibleTextListeners.size() > 0) { 504 if (accessibleTextListeners.size() > 0) {
505 for (int i = 0; i < baseParameterizedAttributes.length; i++) { 505 for (int i = 0; i < baseParameterizedAttributes.length; i++) {
506 if (!returnValue.containsObject(baseParameterizedAttributes[i])) { 506 if (!returnValue.containsObject(baseParameterizedAttributes[i])) {
507 returnValue.addObject(baseParameterizedAttributes[i]); 507 returnValue.addObject(baseParameterizedAttributes[i]);
508 } 508 }
509 } 509 }
510 510
511 } 511 }
512 512
513 if (childID is ACC.CHILDID_SELF) { 513 if (childID is ACC.CHILDID_SELF) {
514 parameterizedAttributeNames = returnValue; 514 parameterizedAttributeNames = returnValue;
515 parameterizedAttributeNames.retain(); 515 parameterizedAttributeNames.retain();
516 return retainedAutoreleased(parameterizedAttributeNames); 516 return retainedAutoreleased(parameterizedAttributeNames);
517 } else { 517 } else {
518 // Caller must retain if they want to keep it. 518 // Caller must retain if they want to keep it.
519 return returnValue; 519 return returnValue;
520 } 520 }
521 } 521 }
522 522
523 public void internal_accessibilityPerformAction(NSString action, int childID) { 523 public void internal_accessibilityPerformAction(NSString action, int childID) {
524 // TODO Auto-generated method stub 524 // TODO Auto-generated method stub
525 // No action support for now. 525 // No action support for now.
526 } 526 }
527 527
528 /** 528 /**
529 * Returns the control for this Accessible object. 529 * Returns the control for this Accessible object.
530 * 530 *
531 * @return the receiver's control 531 * @return the receiver's control
532 * @since 3.0 532 * @since 3.0
533 */ 533 */
534 public Control getControl() { 534 public Control getControl() {
535 return control; 535 return control;
536 } 536 }
537 537
538 /** 538 /**
539 * Invokes platform specific functionality to dispose an accessible object. 539 * Invokes platform specific functionality to dispose an accessible object.
540 * <p> 540 * <p>
541 * <b>IMPORTANT:</b> This method is <em>not</em> part of the public 541 * <b>IMPORTANT:</b> This method is <em>not</em> part of the public
542 * API for <code>Accessible</code>. It is marked public only so that it 542 * API for <code>Accessible</code>. It is marked public only so that it
552 attributeNames = null; 552 attributeNames = null;
553 if (parameterizedAttributeNames !is null) parameterizedAttributeNames.release(); 553 if (parameterizedAttributeNames !is null) parameterizedAttributeNames.release();
554 parameterizedAttributeNames = null; 554 parameterizedAttributeNames = null;
555 555
556 foreach (childDelegate ; children) 556 foreach (childDelegate ; children)
557 childDelegate.internal_dispose_SWTAccessibleDelegate(); 557 childDelegate.internal_dispose_SWTAccessibleDelegate();
558 558
559 children.clear(); 559 children.clear();
560 } 560 }
561 561
562 cocoa.id getExpandedAttribute(int childID) { 562 cocoa.id getExpandedAttribute(int childID) {
563 // TODO: May need to expand the API so the combo box state can be reported. 563 // TODO: May need to expand the API so the combo box state can be reported.
564 return NSNumber.numberWithBool(false); 564 return NSNumber.numberWithBool(false);
565 } 565 }
566 566
567 cocoa.id getHelpAttribute (int childID) { 567 cocoa.id getHelpAttribute (int childID) {
568 cocoa.id returnValue = null; 568 cocoa.id returnValue = null;
569 AccessibleEvent event = new AccessibleEvent(this); 569 AccessibleEvent event = new AccessibleEvent(this);
570 event.childID = childID; 570 event.childID = childID;
571 for (int i = 0; i < accessibleListeners.size(); i++) { 571 for (int i = 0; i < accessibleListeners.size(); i++) {
593 String appRole = roleToOs (event.detail); 593 String appRole = roleToOs (event.detail);
594 int index = dwt.dwthelper.utils.indexOf(appRole, ':'); 594 int index = dwt.dwthelper.utils.indexOf(appRole, ':');
595 if (index !is -1) appRole = appRole.substring(0, index); 595 if (index !is -1) appRole = appRole.substring(0, index);
596 returnValue = NSString.stringWith(appRole); 596 returnValue = NSString.stringWith(appRole);
597 } 597 }
598 598
599 return returnValue; 599 return returnValue;
600 } 600 }
601 601
602 cocoa.id getSubroleAttribute (int childID) { 602 cocoa.id getSubroleAttribute (int childID) {
603 cocoa.id returnValue = null; 603 cocoa.id returnValue = null;
648 cocoa.id getTitleAttribute (int childID) { 648 cocoa.id getTitleAttribute (int childID) {
649 649
650 cocoa.id returnValue = null;//NSString.stringWith(""); 650 cocoa.id returnValue = null;//NSString.stringWith("");
651 651
652 /* 652 /*
653 * Feature of the Macintosh. The text of a Label is returned in its value, 653 * Feature of the Macintosh. The text of a Label is returned in its value,
654 * not its title, so ensure that the role is not Label before asking for the title. 654 * not its title, so ensure that the role is not Label before asking for the title.
655 */ 655 */
656 AccessibleControlEvent roleEvent = new AccessibleControlEvent(this); 656 AccessibleControlEvent roleEvent = new AccessibleControlEvent(this);
657 roleEvent.childID = childID; 657 roleEvent.childID = childID;
658 roleEvent.detail = -1; 658 roleEvent.detail = -1;
659 for (int i = 0; i < accessibleControlListeners.size(); i++) { 659 for (int i = 0; i < accessibleControlListeners.size(); i++) {
660 AccessibleControlListener listener = accessibleControlListeners.elementAt(i); 660 AccessibleControlListener listener = accessibleControlListeners.elementAt(i);
686 listener.getRole(event); 686 listener.getRole(event);
687 listener.getValue(event); 687 listener.getValue(event);
688 } 688 }
689 int role = event.detail; 689 int role = event.detail;
690 String value = event.result; 690 String value = event.result;
691 691
692 switch (role) { 692 switch (role) {
693 case ACC.ROLE_RADIOBUTTON: // 1 = on, 0 = off 693 case ACC.ROLE_RADIOBUTTON: // 1 = on, 0 = off
694 case ACC.ROLE_CHECKBUTTON: // 1 = checked, 0 = unchecked, 2 = mixed 694 case ACC.ROLE_CHECKBUTTON: // 1 = checked, 0 = unchecked, 2 = mixed
695 case ACC.ROLE_SCROLLBAR: // numeric value representing the position of the scroller 695 case ACC.ROLE_SCROLLBAR: // numeric value representing the position of the scroller
696 case ACC.ROLE_SLIDER: // the value associated with the position of the slider thumb 696 case ACC.ROLE_SLIDER: // the value associated with the position of the slider thumb
697 case ACC.ROLE_PROGRESSBAR: // the value associated with the fill level of the progress bar 697 case ACC.ROLE_PROGRESSBAR: // the value associated with the fill level of the progress bar
698 if (value !is null) { 698 if (value !is null) {
699 try { 699 try {
700 int number = Integer.parseInt(value); 700 int number = Integer.parseInt(value);
701 returnValue = NSNumber.numberWithInt(number); 701 returnValue = NSNumber.numberWithInt(number);
702 } catch (NumberFormatException ex) { 702 } catch (NumberFormatException ex) {
703 if (value.equalsIgnoreCase("true")) { 703 if (value.equalsIgnoreCase("true")) {
704 returnValue = NSNumber.numberWithBool(true); 704 returnValue = NSNumber.numberWithBool(true);
705 } else if (value.equalsIgnoreCase("false")) { 705 } else if (value.equalsIgnoreCase("false")) {
706 returnValue = NSNumber.numberWithBool(false); 706 returnValue = NSNumber.numberWithBool(false);
707 }
707 } 708 }
709 } else {
710 returnValue = NSNumber.numberWithBool(false);
708 } 711 }
709 } else { 712 break;
710 returnValue = NSNumber.numberWithBool(false); 713 case ACC.ROLE_TABFOLDER: // the accessibility object representing the currently selected tab item
711 } 714 case ACC.ROLE_TABITEM: // 1 = selected, 0 = not selected
712 break; 715 AccessibleControlEvent ace = new AccessibleControlEvent(this);
713 case ACC.ROLE_TABFOLDER: // the accessibility object representing the currently selected tab item 716 ace.childID = -4;
714 case ACC.ROLE_TABITEM: // 1 = selected, 0 = not selected 717 for (int i = 0; i < accessibleControlListeners.size(); i++) {
715 AccessibleControlEvent ace = new AccessibleControlEvent(this); 718 AccessibleControlListener listener = accessibleControlListeners.elementAt(i);
716 ace.childID = -4; 719 listener.getSelection(ace);
717 for (int i = 0; i < accessibleControlListeners.size(); i++) { 720 }
718 AccessibleControlListener listener = accessibleControlListeners.elementAt(i); 721 if (ace.childID >= ACC.CHILDID_SELF) {
719 listener.getSelection(ace); 722 if (role is ACC.ROLE_TABITEM) {
720 } 723 returnValue = NSNumber.numberWithBool(ace.childID is childID);
721 if (ace.childID >= ACC.CHILDID_SELF) { 724 } else {
722 if (role is ACC.ROLE_TABITEM) { 725 returnValue = new cocoa.id(OS.NSAccessibilityUnignoredAncestor(childIDToOs(ace.childID).id));
723 returnValue = NSNumber.numberWithBool(ace.childID is childID); 726 }
724 } else { 727 } else {
725 returnValue = new cocoa.id(OS.NSAccessibilityUnignoredAncestor(childIDToOs(ace.childID).id)); 728 returnValue = NSNumber.numberWithBool(false);
726 } 729 }
727 } else { 730 break;
728 returnValue = NSNumber.numberWithBool(false); 731 case ACC.ROLE_COMBOBOX: // text of the currently selected item
729 } 732 case ACC.ROLE_TEXT: // text in the text field
730 break;
731 case ACC.ROLE_COMBOBOX: // text of the currently selected item
732 case ACC.ROLE_TEXT: // text in the text field
733 if (value !is null) returnValue = NSString.stringWith(value);
734 break;
735 case ACC.ROLE_LABEL: // text in the label
736 /* On a Mac, the 'value' of a label is the same as the 'name' of the label. */
737 AccessibleEvent e = new AccessibleEvent(this);
738 e.childID = childID;
739 e.result = null;
740 for (int i = 0; i < accessibleListeners.size(); i++) {
741 AccessibleListener listener = accessibleListeners.elementAt(i);
742 listener.getName(e);
743 }
744 if (e.result !is null) {
745 returnValue = NSString.stringWith(e.result);
746 } else {
747 if (value !is null) returnValue = NSString.stringWith(value); 733 if (value !is null) returnValue = NSString.stringWith(value);
748 } 734 break;
749 break; 735 case ACC.ROLE_LABEL: // text in the label
736 /* On a Mac, the 'value' of a label is the same as the 'name' of the label. */
737 AccessibleEvent e = new AccessibleEvent(this);
738 e.childID = childID;
739 e.result = null;
740 for (int i = 0; i < accessibleListeners.size(); i++) {
741 AccessibleListener listener = accessibleListeners.elementAt(i);
742 listener.getName(e);
743 }
744 if (e.result !is null) {
745 returnValue = NSString.stringWith(e.result);
746 } else {
747 if (value !is null) returnValue = NSString.stringWith(value);
748 }
749 break;
750 } 750 }
751 751
752 return returnValue; 752 return returnValue;
753 } 753 }
754 754
757 event.detail = -1; 757 event.detail = -1;
758 for (int i = 0; i < accessibleControlListeners.size(); i++) { 758 for (int i = 0; i < accessibleControlListeners.size(); i++) {
759 AccessibleControlListener listener = accessibleControlListeners.elementAt(i); 759 AccessibleControlListener listener = accessibleControlListeners.elementAt(i);
760 listener.getState(event); 760 listener.getState(event);
761 } 761 }
762 762
763 return NSNumber.numberWithBool(control.isEnabled()); 763 return NSNumber.numberWithBool(control.isEnabled());
764 } 764 }
765 765
766 cocoa.id getFocusedAttribute (int childID) { 766 cocoa.id getFocusedAttribute (int childID) {
767 AccessibleControlEvent event = new AccessibleControlEvent(this); 767 AccessibleControlEvent event = new AccessibleControlEvent(this);
769 event.accessible = null; 769 event.accessible = null;
770 for (int i = 0; i < accessibleControlListeners.size(); i++) { 770 for (int i = 0; i < accessibleControlListeners.size(); i++) {
771 AccessibleControlListener listener = accessibleControlListeners.elementAt(i); 771 AccessibleControlListener listener = accessibleControlListeners.elementAt(i);
772 listener.getFocus(event); 772 listener.getFocus(event);
773 } 773 }
774 774
775 /* The application can optionally answer an accessible. */ 775 /* The application can optionally answer an accessible. */
776 // FIXME: 776 // FIXME:
777 // if (event.accessible !is null) { 777 // if (event.accessible !is null) {
778 // bool hasFocus = (event.accessible.childID is childID) && (event.accessible.control is this.control); 778 // bool hasFocus = (event.accessible.childID is childID) && (event.accessible.control is this.control);
779 // return NSNumber.numberWithBool(hasFocus); 779 // return NSNumber.numberWithBool(hasFocus);
780 // } 780 // }
781 781
782 /* Or the application can answer a valid child ID, including CHILDID_SELF and CHILDID_NONE. */ 782 /* Or the application can answer a valid child ID, including CHILDID_SELF and CHILDID_NONE. */
783 if (event.childID is ACC.CHILDID_SELF) { 783 if (event.childID is ACC.CHILDID_SELF) {
784 bool hasFocus = (event.childID is childID); 784 bool hasFocus = (event.childID is childID);
785 return NSNumber.numberWithBool(hasFocus); 785 return NSNumber.numberWithBool(hasFocus);
789 } 789 }
790 if (event.childID !is ACC.CHILDID_MULTIPLE) { 790 if (event.childID !is ACC.CHILDID_MULTIPLE) {
791 /* Other valid childID. */ 791 /* Other valid childID. */
792 return NSNumber.numberWithBool(event.childID is childID); 792 return NSNumber.numberWithBool(event.childID is childID);
793 } 793 }
794 794
795 // Invalid childID at this point means the application did not implement getFocus, so 795 // Invalid childID at this point means the application did not implement getFocus, so
796 // let the default handler return the native focus. 796 // let the default handler return the native focus.
797 bool hasFocus = (this.control.view.window().firstResponder() is control.view); 797 bool hasFocus = (this.control.view.window().firstResponder() is control.view);
798 return NSNumber.numberWithBool(hasFocus); 798 return NSNumber.numberWithBool(hasFocus);
799 } 799 }
823 } 823 }
824 Object [] appChildren = event.children; 824 Object [] appChildren = event.children;
825 if (appChildren !is null && appChildren.length > 0) { 825 if (appChildren !is null && appChildren.length > 0) {
826 /* return an NSArray of NSAccessible objects. */ 826 /* return an NSArray of NSAccessible objects. */
827 NSMutableArray childArray = NSMutableArray.arrayWithCapacity(appChildren.length); 827 NSMutableArray childArray = NSMutableArray.arrayWithCapacity(appChildren.length);
828 828
829 for (int i = 0; i < appChildren.length; i++) { 829 for (int i = 0; i < appChildren.length; i++) {
830 Object child = appChildren[i]; 830 Object child = appChildren[i];
831 if (cast(Integer) child) { 831 if (cast(Integer) child) {
832 cocoa.id accChild = childIDToOs((cast(Integer)child).intValue()); 832 cocoa.id accChild = childIDToOs((cast(Integer)child).intValue());
833 childArray.addObject(accChild); 833 childArray.addObject(accChild);
834 } else { 834 } else {
835 childArray.addObject((cast(Accessible)child).control.view); 835 childArray.addObject((cast(Accessible)child).control.view);
836 } 836 }
837 } 837 }
838 838
839 returnValue = new cocoa.id(OS.NSAccessibilityUnignoredChildren(childArray.id)); 839 returnValue = new cocoa.id(OS.NSAccessibilityUnignoredChildren(childArray.id));
840 } 840 }
841 } 841 }
842 } else { 842 } else {
843 // Lightweight children have no children of their own. 843 // Lightweight children have no children of their own.
844 // Don't return null if there are no children -- always return an empty array. 844 // Don't return null if there are no children -- always return an empty array.
845 returnValue = NSArray.array(); 845 returnValue = NSArray.array();
846 } 846 }
847 847
848 // Returning null here means we want the control itself to determine its children. If the accessible listener 848 // Returning null here means we want the control itself to determine its children. If the accessible listener
849 // implemented getChildCount/getChildren, references to those objects would have been returned above. 849 // implemented getChildCount/getChildren, references to those objects would have been returned above.
850 return returnValue; 850 return returnValue;
851 } 851 }
852 852
867 } 867 }
868 Object [] appChildren = event.children; 868 Object [] appChildren = event.children;
869 if (appChildren !is null && appChildren.length > 0) { 869 if (appChildren !is null && appChildren.length > 0) {
870 /* return an NSArray of NSAccessible objects. */ 870 /* return an NSArray of NSAccessible objects. */
871 NSMutableArray childArray = NSMutableArray.arrayWithCapacity(appChildren.length); 871 NSMutableArray childArray = NSMutableArray.arrayWithCapacity(appChildren.length);
872 872
873 for (int i = 0; i < appChildren.length; i++) { 873 for (int i = 0; i < appChildren.length; i++) {
874 Object child = appChildren[i]; 874 Object child = appChildren[i];
875 if (cast(Integer)child) { 875 if (cast(Integer)child) {
876 int subChildID = (cast(Integer)child).intValue(); 876 int subChildID = (cast(Integer)child).intValue();
877 event.childID = subChildID; 877 event.childID = subChildID;
887 } 887 }
888 } else { 888 } else {
889 childArray.addObject((cast(Accessible)child).control.view); 889 childArray.addObject((cast(Accessible)child).control.view);
890 } 890 }
891 } 891 }
892 892
893 returnValue = new cocoa.id(OS.NSAccessibilityUnignoredChildren(childArray.id)); 893 returnValue = new cocoa.id(OS.NSAccessibilityUnignoredChildren(childArray.id));
894 } 894 }
895 } 895 }
896 } else { 896 } else {
897 // Lightweight children have no children of their own. 897 // Lightweight children have no children of their own.
898 // Don't return null if there are no children -- always return an empty array. 898 // Don't return null if there are no children -- always return an empty array.
899 returnValue = NSArray.array(); 899 returnValue = NSArray.array();
900 } 900 }
901 901
902 // Returning null here means we want the control itself to determine its children. If the accessible listener 902 // Returning null here means we want the control itself to determine its children. If the accessible listener
903 // implemented getChildCount/getChildren, references to those objects would have been returned above. 903 // implemented getChildCount/getChildren, references to those objects would have been returned above.
904 return returnValue; 904 return returnValue;
905 } 905 }
906 906
920 920
921 for (int i = 0; i < accessibleControlListeners.size(); i++) { 921 for (int i = 0; i < accessibleControlListeners.size(); i++) {
922 AccessibleControlListener listener = accessibleControlListeners.elementAt(i); 922 AccessibleControlListener listener = accessibleControlListeners.elementAt(i);
923 listener.getLocation(event); 923 listener.getLocation(event);
924 } 924 }
925 925
926 dwt.widgets.Monitor.Monitor primaryMonitor = Display.getCurrent().getPrimaryMonitor(); 926 dwt.widgets.Monitor.Monitor primaryMonitor = Display.getCurrent().getPrimaryMonitor();
927 927
928 NSPoint osPositionAttribute = NSPoint (); 928 NSPoint osPositionAttribute = NSPoint ();
929 if (event.width !is -1) { 929 if (event.width !is -1) {
930 // The point returned is the lower-left coordinate of the widget in lower-left relative screen coordinates. 930 // The point returned is the lower-left coordinate of the widget in lower-left relative screen coordinates.
933 returnValue = NSValue.valueWithPoint(osPositionAttribute); 933 returnValue = NSValue.valueWithPoint(osPositionAttribute);
934 } else { 934 } else {
935 if (childID !is ACC.CHILDID_SELF) { 935 if (childID !is ACC.CHILDID_SELF) {
936 Point pt = null; 936 Point pt = null;
937 Rectangle location = control.getBounds(); 937 Rectangle location = control.getBounds();
938 938
939 if (control.getParent() !is null) 939 if (control.getParent() !is null)
940 pt = control.getParent().toDisplay(location.x, location.y); 940 pt = control.getParent().toDisplay(location.x, location.y);
941 else 941 else
942 pt = (cast(Shell)control).toDisplay(location.x, location.y); 942 pt = (cast(Shell)control).toDisplay(location.x, location.y);
943 943
944 osPositionAttribute.x = pt.x; 944 osPositionAttribute.x = pt.x;
945 osPositionAttribute.y = pt.y; 945 osPositionAttribute.y = pt.y;
946 returnValue = NSValue.valueWithPoint(osPositionAttribute); 946 returnValue = NSValue.valueWithPoint(osPositionAttribute);
947 } 947 }
948 } 948 }
953 cocoa.id getSizeAttribute (int childID) { 953 cocoa.id getSizeAttribute (int childID) {
954 cocoa.id returnValue = null; 954 cocoa.id returnValue = null;
955 AccessibleControlEvent event = new AccessibleControlEvent(this); 955 AccessibleControlEvent event = new AccessibleControlEvent(this);
956 event.childID = childID; 956 event.childID = childID;
957 event.width = -1; 957 event.width = -1;
958 958
959 for (int i = 0; i < accessibleControlListeners.size(); i++) { 959 for (int i = 0; i < accessibleControlListeners.size(); i++) {
960 AccessibleControlListener listener = accessibleControlListeners.elementAt(i); 960 AccessibleControlListener listener = accessibleControlListeners.elementAt(i);
961 listener.getLocation(event); 961 listener.getLocation(event);
962 } 962 }
963 963
964 NSSize controlSize = NSSize (); 964 NSSize controlSize = NSSize ();
965 if (event.width !is -1) { 965 if (event.width !is -1) {
966 controlSize.width = event.width; 966 controlSize.width = event.width;
967 controlSize.height = event.height; 967 controlSize.height = event.height;
968 returnValue = NSValue.valueWithSize(controlSize); 968 returnValue = NSValue.valueWithSize(controlSize);
983 cocoa.id returnValue = null; 983 cocoa.id returnValue = null;
984 for (int i = 0; i < accessibleListeners.size(); i++) { 984 for (int i = 0; i < accessibleListeners.size(); i++) {
985 AccessibleListener listener = accessibleListeners.elementAt(i); 985 AccessibleListener listener = accessibleListeners.elementAt(i);
986 listener.getDescription(event); 986 listener.getDescription(event);
987 } 987 }
988 988
989 returnValue = (event.result !is null ? NSString.stringWith(event.result) : null); 989 returnValue = (event.result !is null ? NSString.stringWith(event.result) : null);
990 990
991 // If no description was provided, try the name. 991 // If no description was provided, try the name.
992 if (returnValue is null) { 992 if (returnValue is null) {
993 if (cast(Composite) control) returnValue = NSString.stringWith(""); 993 if (cast(Composite) control) returnValue = NSString.stringWith("");
994 } 994 }
995 995
996 return returnValue; 996 return returnValue;
997 } 997 }
998 998
999 cocoa.id getInsertionPointLineNumberAttribute (int childID) { 999 cocoa.id getInsertionPointLineNumberAttribute (int childID) {
1000 cocoa.id returnValue = null; 1000 cocoa.id returnValue = null;
1035 return returnValue; 1035 return returnValue;
1036 } 1036 }
1037 1037
1038 cocoa.id getRangeForLineParameterizedAttribute (cocoa.id parameter, int childID) { 1038 cocoa.id getRangeForLineParameterizedAttribute (cocoa.id parameter, int childID) {
1039 cocoa.id returnValue = null; 1039 cocoa.id returnValue = null;
1040 1040
1041 // The parameter is an NSNumber with the line number. 1041 // The parameter is an NSNumber with the line number.
1042 NSNumber lineNumberObj = new NSNumber(parameter.id); 1042 NSNumber lineNumberObj = new NSNumber(parameter.id);
1043 int lineNumber = lineNumberObj.intValue(); 1043 int lineNumber = lineNumberObj.intValue();
1044 System.out_.println("Line number = " ~ Integer.toString(lineNumber)); 1044 System.out_.println("Line number = " ~ Integer.toString(lineNumber));
1045 AccessibleControlEvent event = new AccessibleControlEvent(this); 1045 AccessibleControlEvent event = new AccessibleControlEvent(this);
1117 for (int i = 0; i < accessibleControlListeners.size(); i++) { 1117 for (int i = 0; i < accessibleControlListeners.size(); i++) {
1118 AccessibleControlListener listener = accessibleControlListeners.elementAt(i); 1118 AccessibleControlListener listener = accessibleControlListeners.elementAt(i);
1119 listener.getValue(event); 1119 listener.getValue(event);
1120 } 1120 }
1121 String appValue = event.result; 1121 String appValue = event.result;
1122 1122
1123 if (appValue !is null) { 1123 if (appValue !is null) {
1124 returnValue = NSString.stringWith(appValue.substring(range.location, range.location + range.length)); 1124 returnValue = NSString.stringWith(appValue.substring(range.location, range.location + range.length));
1125 } 1125 }
1126 1126
1127 return returnValue; 1127 return returnValue;
1128 } 1128 }
1129 1129
1130 cocoa.id getSelectedTextRangesAttribute (int childID) { 1130 cocoa.id getSelectedTextRangesAttribute (int childID) {
1131 NSMutableArray returnValue = null; 1131 NSMutableArray returnValue = null;
1158 AccessibleControlListener listener = accessibleControlListeners.elementAt(i); 1158 AccessibleControlListener listener = accessibleControlListeners.elementAt(i);
1159 listener.getValue(event); 1159 listener.getValue(event);
1160 } 1160 }
1161 1161
1162 NSRange range = NSRange(); 1162 NSRange range = NSRange();
1163 1163
1164 if (event.result !is null) { 1164 if (event.result !is null) {
1165 range.location = 0; 1165 range.location = 0;
1166 range.length = event.result.length(); 1166 range.length = event.result.length();
1167 } else { 1167 } else {
1168 return null; 1168 return null;
1169 // range.location = range.length = 0; 1169 // range.location = range.length = 0;
1170 } 1170 }
1171 1171
1172 return NSValue.valueWithRange(range); 1172 return NSValue.valueWithRange(range);
1173 } 1173 }
1174 1174
1175 int lineNumberForOffset (String text, int offset) { 1175 int lineNumberForOffset (String text, int offset) {
1176 int lineNumber = 1; 1176 int lineNumber = 1;
1177 int length = text.length(); 1177 int length = text.length();
1178 for (int i = 0; i < offset; i++) { 1178 for (int i = 0; i < offset; i++) {
1179 switch (text.charAt (i)) { 1179 switch (text.charAt (i)) {
1186 lineNumber++; 1186 lineNumber++;
1187 } 1187 }
1188 } 1188 }
1189 return lineNumber; 1189 return lineNumber;
1190 } 1190 }
1191 1191
1192 NSRange rangeForLineNumber (int lineNumber, String text) { 1192 NSRange rangeForLineNumber (int lineNumber, String text) {
1193 NSRange range = NSRange(); 1193 NSRange range = NSRange();
1194 range.location = -1; 1194 range.location = -1;
1195 int line = 1; 1195 int line = 1;
1196 int count = 0; 1196 int count = 0;
1212 } 1212 }
1213 } 1213 }
1214 range.length = count; 1214 range.length = count;
1215 return range; 1215 return range;
1216 } 1216 }
1217 1217
1218 /** 1218 /**
1219 * Removes the listener from the collection of listeners who will 1219 * Removes the listener from the collection of listeners who will
1220 * be notified when an accessible client asks for certain strings, 1220 * be notified when an accessible client asks for certain strings,
1221 * such as name, description, help, or keyboard shortcut. 1221 * such as name, description, help, or keyboard shortcut.
1222 * 1222 *
1237 public void removeAccessibleListener(AccessibleListener listener) { 1237 public void removeAccessibleListener(AccessibleListener listener) {
1238 checkWidget(); 1238 checkWidget();
1239 if (listener is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); 1239 if (listener is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
1240 accessibleListeners.removeElement(listener); 1240 accessibleListeners.removeElement(listener);
1241 } 1241 }
1242 1242
1243 /** 1243 /**
1244 * Removes the listener from the collection of listeners who will 1244 * Removes the listener from the collection of listeners who will
1245 * be notified when an accessible client asks for custom control 1245 * be notified when an accessible client asks for custom control
1246 * specific information. 1246 * specific information.
1247 * 1247 *
1262 public void removeAccessibleControlListener(AccessibleControlListener listener) { 1262 public void removeAccessibleControlListener(AccessibleControlListener listener) {
1263 checkWidget(); 1263 checkWidget();
1264 if (listener is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); 1264 if (listener is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
1265 accessibleControlListeners.removeElement(listener); 1265 accessibleControlListeners.removeElement(listener);
1266 } 1266 }
1267 1267
1268 /** 1268 /**
1269 * Removes the listener from the collection of listeners who will 1269 * Removes the listener from the collection of listeners who will
1270 * be notified when an accessible client asks for custom text control 1270 * be notified when an accessible client asks for custom text control
1271 * specific information. 1271 * specific information.
1272 * 1272 *
1289 public void removeAccessibleTextListener (AccessibleTextListener listener) { 1289 public void removeAccessibleTextListener (AccessibleTextListener listener) {
1290 checkWidget (); 1290 checkWidget ();
1291 if (listener is null) DWT.error (DWT.ERROR_NULL_ARGUMENT); 1291 if (listener is null) DWT.error (DWT.ERROR_NULL_ARGUMENT);
1292 accessibleTextListeners.removeElement (listener); 1292 accessibleTextListeners.removeElement (listener);
1293 } 1293 }
1294 1294
1295 static NSArray retainedAutoreleased(NSArray inObject) { 1295 static NSArray retainedAutoreleased(NSArray inObject) {
1296 cocoa.id temp = inObject.retain(); 1296 cocoa.id temp = inObject.retain();
1297 cocoa.id temp2 = (new NSObject(temp.id)).autorelease(); 1297 cocoa.id temp2 = (new NSObject(temp.id)).autorelease();
1298 return new NSArray(temp2.id); 1298 return new NSArray(temp2.id);
1299 } 1299 }
1311 */ 1311 */
1312 public void selectionChanged () { 1312 public void selectionChanged () {
1313 checkWidget(); 1313 checkWidget();
1314 OS.NSAccessibilityPostNotification(control.view.id, OS.NSAccessibilitySelectedChildrenChangedNotification.id); 1314 OS.NSAccessibilityPostNotification(control.view.id, OS.NSAccessibilitySelectedChildrenChangedNotification.id);
1315 } 1315 }
1316 1316
1317 /** 1317 /**
1318 * Sends a message to accessible clients indicating that the focus 1318 * Sends a message to accessible clients indicating that the focus
1319 * has changed within a custom control. 1319 * has changed within a custom control.
1320 * 1320 *
1321 * @param childID an identifier specifying a child of the control 1321 * @param childID an identifier specifying a child of the control
1327 */ 1327 */
1328 public void setFocus(int childID) { 1328 public void setFocus(int childID) {
1329 checkWidget(); 1329 checkWidget();
1330 OS.NSAccessibilityPostNotification(control.view.id, OS.NSAccessibilityFocusedUIElementChangedNotification.id); 1330 OS.NSAccessibilityPostNotification(control.view.id, OS.NSAccessibilityFocusedUIElementChangedNotification.id);
1331 } 1331 }
1332 1332
1333 /** 1333 /**
1334 * Sends a message to accessible clients that the text 1334 * Sends a message to accessible clients that the text
1335 * caret has moved within a custom control. 1335 * caret has moved within a custom control.
1336 * 1336 *
1337 * @param index the new caret index within the control 1337 * @param index the new caret index within the control
1345 */ 1345 */
1346 public void textCaretMoved (int index) { 1346 public void textCaretMoved (int index) {
1347 checkWidget(); 1347 checkWidget();
1348 OS.NSAccessibilityPostNotification(control.view.id, OS.NSAccessibilitySelectedTextChangedNotification.id); 1348 OS.NSAccessibilityPostNotification(control.view.id, OS.NSAccessibilitySelectedTextChangedNotification.id);
1349 } 1349 }
1350 1350
1351 /** 1351 /**
1352 * Sends a message to accessible clients that the text 1352 * Sends a message to accessible clients that the text
1353 * within a custom control has changed. 1353 * within a custom control has changed.
1354 * 1354 *
1355 * @param type the type of change, one of <code>ACC.NOTIFY_TEXT_INSERT</code> 1355 * @param type the type of change, one of <code>ACC.NOTIFY_TEXT_INSERT</code>
1369 */ 1369 */
1370 public void textChanged (int type, int startIndex, int length) { 1370 public void textChanged (int type, int startIndex, int length) {
1371 checkWidget(); 1371 checkWidget();
1372 OS.NSAccessibilityPostNotification(control.view.id, OS.NSAccessibilityValueChangedNotification.id); 1372 OS.NSAccessibilityPostNotification(control.view.id, OS.NSAccessibilityValueChangedNotification.id);
1373 } 1373 }
1374 1374
1375 /** 1375 /**
1376 * Sends a message to accessible clients that the text 1376 * Sends a message to accessible clients that the text
1377 * selection has changed within a custom control. 1377 * selection has changed within a custom control.
1378 * 1378 *
1379 * @exception DWTException <ul> 1379 * @exception DWTException <ul>
1390 1390
1391 cocoa.id childIDToOs(int childID) { 1391 cocoa.id childIDToOs(int childID) {
1392 if (childID is ACC.CHILDID_SELF) { 1392 if (childID is ACC.CHILDID_SELF) {
1393 return control.view; 1393 return control.view;
1394 } 1394 }
1395 1395
1396 /* Check cache for childID, if found, return corresponding osChildID. */ 1396 /* Check cache for childID, if found, return corresponding osChildID. */
1397 SWTAccessibleDelegate childRef = children[childID]; 1397 SWTAccessibleDelegate childRef = children[childID];
1398 1398
1399 if (childRef is null) { 1399 if (childRef is null) {
1400 childRef = new SWTAccessibleDelegate(this, childID); 1400 childRef = new SWTAccessibleDelegate(this, childID);
1401 children.add(childID, childRef); 1401 children.add(childID, childRef);
1402 } 1402 }
1403 1403
1404 return childRef; 1404 return childRef;
1405 } 1405 }
1406 1406
1407 NSString concatStringsAsRole(NSString str1, NSString str2) { 1407 NSString concatStringsAsRole(NSString str1, NSString str2) {
1408 NSString returnValue = str1; 1408 NSString returnValue = str1;
1409 returnValue = returnValue.stringByAppendingString(NSString.stringWith(":")); 1409 returnValue = returnValue.stringByAppendingString(NSString.stringWith(":"));
1410 returnValue = returnValue.stringByAppendingString(str2); 1410 returnValue = returnValue.stringByAppendingString(str2);
1411 return returnValue; 1411 return returnValue;
1453 case ACC.ROLE_TABITEM: nsReturnValue = OS.NSAccessibilityRadioButtonRole; break; 1453 case ACC.ROLE_TABITEM: nsReturnValue = OS.NSAccessibilityRadioButtonRole; break;
1454 case ACC.ROLE_PROGRESSBAR: nsReturnValue = OS.NSAccessibilityProgressIndicatorRole; break; 1454 case ACC.ROLE_PROGRESSBAR: nsReturnValue = OS.NSAccessibilityProgressIndicatorRole; break;
1455 case ACC.ROLE_SLIDER: nsReturnValue = OS.NSAccessibilitySliderRole; break; 1455 case ACC.ROLE_SLIDER: nsReturnValue = OS.NSAccessibilitySliderRole; break;
1456 case ACC.ROLE_LINK: nsReturnValue = OS.NSAccessibilityLinkRole; break; 1456 case ACC.ROLE_LINK: nsReturnValue = OS.NSAccessibilityLinkRole; break;
1457 } 1457 }
1458 1458
1459 return nsReturnValue.getString(); 1459 return nsReturnValue.getString();
1460 } 1460 }
1461 1461
1462 int osToRole(NSString osRole) { 1462 int osToRole(NSString osRole) {
1463 if (osRole is null) return 0; 1463 if (osRole is null) return 0;
1464 if (osRole.isEqualToString(OS.NSAccessibilityWindowRole)) return ACC.ROLE_WINDOW; 1464 if (osRole.isEqualToString(OS.NSAccessibilityWindowRole)) return ACC.ROLE_WINDOW;
1465 if (osRole.isEqualToString(OS.NSAccessibilityMenuBarRole)) return ACC.ROLE_MENUBAR; 1465 if (osRole.isEqualToString(OS.NSAccessibilityMenuBarRole)) return ACC.ROLE_MENUBAR;
1466 if (osRole.isEqualToString(OS.NSAccessibilityMenuRole)) return ACC.ROLE_MENU; 1466 if (osRole.isEqualToString(OS.NSAccessibilityMenuRole)) return ACC.ROLE_MENU;
1496 /* checkWidget was copied from Widget, and rewritten to work in this package */ 1496 /* checkWidget was copied from Widget, and rewritten to work in this package */
1497 void checkWidget () { 1497 void checkWidget () {
1498 if (!isValidThread ()) DWT.error (DWT.ERROR_THREAD_INVALID_ACCESS); 1498 if (!isValidThread ()) DWT.error (DWT.ERROR_THREAD_INVALID_ACCESS);
1499 if (control.isDisposed ()) DWT.error (DWT.ERROR_WIDGET_DISPOSED); 1499 if (control.isDisposed ()) DWT.error (DWT.ERROR_WIDGET_DISPOSED);
1500 } 1500 }
1501 1501
1502 /* isValidThread was copied from Widget, and rewritten to work in this package */ 1502 /* isValidThread was copied from Widget, and rewritten to work in this package */
1503 bool isValidThread () { 1503 bool isValidThread () {
1504 return control.getDisplay ().getThread () is Thread.getThis (); 1504 return control.getDisplay ().getThread () is Thread.getThis ();
1505 } 1505 }
1506 1506
1507 } 1507 }