first commit

This commit is contained in:
2020-10-20 00:58:15 +02:00
commit 7f1b9bfca5
222 changed files with 56918 additions and 0 deletions

View File

@ -0,0 +1,182 @@
/*
Copyright (c) 2009 Yahoo! Inc. All rights reserved.
The copyrights embodied in the content of this file are licensed under the BSD (revised) open source license
*/
package com.yahoo.astra.fl.accessibility
{
import com.yahoo.astra.accessibility.EventTypes;
import com.yahoo.astra.accessibility.ObjectRoles;
import com.yahoo.astra.accessibility.ObjectStates;
import com.yahoo.astra.fl.controls.Carousel;
import fl.accessibility.SelectableListAccImpl;
import fl.core.UIComponent;
/**
* The CarouselAccImpl class is used to make a Carousel component accessible.
*
* <p>A Carousel reports the role <code>ROLE_SYSTEM_LIST</code> (0x21) to a screen
* reader. Its items report the role <code>ROLE_SYSTEM_LISTITEM</code> (0x22).</p>
*
* @see com.yahoo.astra.fl.controls.Carousel
*
* @author Alaric Cole
*/
public class CarouselAccImpl extends SelectableListAccImpl
{
/**
* @private
* Static variable triggering the <code>hookAccessibility()</code> method.
* This is used for initializing CarouselAccImpl class to hook its
* <code>createAccessibilityImplementation()</code> method to Carousel class
* before it gets called from UIComponent.
*
*/
private static var accessibilityHooked:Boolean = hookAccessibility();
/**
* @private
* Static method for swapping the <code>createAccessibilityImplementation()</code>
* method of Carousel with the CarouselAccImpl class.
*
*/
private static function hookAccessibility():Boolean
{
Carousel.createAccessibilityImplementation = createAccessibilityImplementation;
return true;
}
/**
* @private
* Method for creating the Accessibility class.
* This method is called from UIComponent.
*
* @param component The UIComponent instance that this AccImpl instance
* is making accessible.
*
*/
public static function createAccessibilityImplementation(component:UIComponent):void
{
component.accessibilityImplementation = new CarouselAccImpl(component);
}
/**
* Enables accessibility for a Carousel component.
* This method is required for the compiler to activate
* the accessibility classes for a component.
*/
public static function enableAccessibility():void
{
//
}
//--------------------------------------------------------------------------
// Constructor
//--------------------------------------------------------------------------
/**
* Creates a new Carousel Accessibility Implementation.
*
* @param master The UIComponent instance that this AccImpl instance
* is making accessible.
*
*/
public function CarouselAccImpl(master:UIComponent)
{
super(master);
}
//--------------------------------------------------------------------------
// Name
//--------------------------------------------------------------------------
/**
* @inheritDoc
*
*/
override protected function getName(childID:uint):String
{
if (childID == 0) {
return "";
}
var list:Carousel = Carousel(master);
if(list.dataProvider)
{
var index:int = childID - 1;
if (index > -1)
{
var item:Object = list.getItemAt(index);
var ext:String = " " + childID + " of " + list.dataProvider.length;
if (item is String) {
return item + ext;
} else {
return list.itemToLabel(item) + ext;
}
}
}
return "";
}
//--------------------------------------------------------------------------
// Value
//--------------------------------------------------------------------------
/**
* @inheritDoc
*/
override public function get_accValue(childID:uint):String
{
var accValue:String;
var list:Carousel = Carousel(master);
var index:int = list.selectedIndex;
if (childID == 0) {
if (index > -1) {
var ext:String = " " + (index + 1) + " of " + list.dataProvider.length;
var item:Object = list.getItemAt(index);
if (item is String) {
accValue = item + ext;
} else {
accValue = list.itemToLabel(item) + ext;
}
}
}
return accValue;
}
//--------------------------------------------------------------------------
// State
//--------------------------------------------------------------------------
/**
* @inheritDoc
*/
override public function get_accState(childID:uint):uint
{
var accState:uint = getState(childID);
if (childID > 0) {
var list:Carousel = Carousel(master);
var index:uint = childID - 1;
if (index < list.horizontalScrollPosition || index >= list.horizontalScrollPosition + list.columnCount) {
accState |= (ObjectStates.STATE_SYSTEM_OFFSCREEN | ObjectStates.STATE_SYSTEM_INVISIBLE);
} else {
accState |= ObjectStates.STATE_SYSTEM_SELECTABLE;
var item:Object = list.getItemAt(index);
var selItems:Array = list.selectedIndices;
for(var i:int = 0; i < selItems.length; i++) {
if(selItems[i] == index) {
accState |= ObjectStates.STATE_SYSTEM_SELECTED | ObjectStates.STATE_SYSTEM_FOCUSED;
break;
}
}
}
}
return accState;
}
}
}

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,5 @@
/*
Copyright (c) 2009 Yahoo! Inc. All rights reserved.
The copyrights embodied in the content of this file are licensed under the BSD (revised) open source license
*/
package com.yahoo.astra.fl.accessibility

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,353 @@
/*
Copyright (c) 2009 Yahoo! Inc. All rights reserved.
The copyrights embodied in the content of this file are licensed under the BSD (revised) open source license
*/
package com.yahoo.astra.fl.accessibility
{
import com.yahoo.astra.accessibility.EventTypes;
import com.yahoo.astra.accessibility.ObjectRoles;
import com.yahoo.astra.accessibility.ObjectStates;
import com.yahoo.astra.fl.controls.TabBar;
import com.yahoo.astra.fl.controls.tabBarClasses.TabButton;
import fl.accessibility.AccImpl;
import fl.core.UIComponent;
import flash.accessibility.Accessibility;
import flash.events.Event;
/**
* The TabBarAccImpl class, also called the TabBar Accessibility Implementation class,
* is used to make a TabBar component accessible.
*
* @see com.yahoo.astra.fl.controls.TabBar
*/
public class TabBarAccImpl extends AccImpl
{
//--------------------------------------
// Class Properties
//--------------------------------------
/**
* @private
* Static variable triggering the <code>hookAccessibility()</code> method.
* This is used for initializing TabBarAccImpl class to hook its
* <code>createAccessibilityImplementation()</code> method to TabBar class
* before it gets called from UIComponent.
*/
private static var accessibilityHooked:Boolean = hookAccessibility();
//--------------------------------------
// Class Methods
//--------------------------------------
/**
* @private
* Static method for swapping the <code>createAccessibilityImplementation()</code>
* method of TabBar with the TabBarAccImpl class.
*/
private static function hookAccessibility():Boolean
{
TabBar.createAccessibilityImplementation = createAccessibilityImplementation;
return true;
}
/**
* @private
* Method for creating the Accessibility class.
* This method is called from UIComponent.
*
* @param component The UIComponent instance that this AccImpl instance
* is making accessible.
*/
public static function createAccessibilityImplementation(component:UIComponent):void
{
component.accessibilityImplementation = new TabBarAccImpl(component);
}
/**
* Enables accessibility for a TabBar component.
* This method is required for the compiler to activate
* the accessibility classes for a component.
*/
public static function enableAccessibility():void
{
//do nothing
}
//--------------------------------------
// Constants
//--------------------------------------
/**
* @private
*/
private static const MAX_NUM:uint = 100000;
//--------------------------------------
// Constructor
//--------------------------------------
/**
* @private
*
* Creates a new TabBar Accessibility Implementation.
*
* @param master The UIComponent instance that this AccImpl instance
* is making accessible.
*/
public function TabBarAccImpl(master:UIComponent)
{
super(master);
this.role = ObjectRoles.ROLE_SYSTEM_PAGETABLIST;
}
//--------------------------------------
// Properties
//--------------------------------------
/**
* @private
* Array of events that we should listen for from the master component.
*/
override protected function get eventsToHandle():Array
{
return super.eventsToHandle.concat([ Event.CHANGE, "focusUpdate" ]);
}
//--------------------------------------
// Public Methods
//--------------------------------------
/**
* @private
* Gets the role for the component.
*
* @param childID The child id.
*
* @return Role.
*/
override public function get_accRole(childID:uint):uint
{
if(childID == 0)
{
return this.role;
}
//tabs use this role:
return ObjectRoles.ROLE_SYSTEM_PAGETAB;
}
/**
* @private
* IAccessible method for returning the state of the Tabs.
* States are predefined for all the components in MSAA. Values are assigned to each state.
* Depending upon the Tab being Focusable, Focused and Moveable, a value is returned.
*
* @param childID The child id.
*
* @return State.
*/
override public function get_accState(childID:uint):uint
{
var accState:uint = getState(childID);
var tabBar:TabBar = TabBar(master);
if(childID > 0)
{
accState = ObjectStates.STATE_SYSTEM_SELECTABLE | ObjectStates.STATE_SYSTEM_FOCUSABLE;
var index:int = childID < MAX_NUM ? childID - 1 : childID - MAX_NUM - 1;
if(index == tabBar.selectedIndex)
{
accState |= ObjectStates.STATE_SYSTEM_SELECTED;
}
if(index == tabBar.focusIndex)
{
accState |= ObjectStates.STATE_SYSTEM_FOCUSED;
}
}
return accState;
}
/**
* @private
* IAccessible method for returning the Default Action.
*
* @param childID uint
*
* @return DefaultAction.
*/
override public function get_accDefaultAction(childID:uint):String
{
return "Switch";
}
/**
* @private
* IAccessible method for executing the Default Action.
*
* @param childID uint
*/
override public function accDoDefaultAction(childID:uint):void
{
if(childID > 0)
{
var index:int = childID < MAX_NUM ?
childID - 1 :
childID - MAX_NUM - 1;
TabBar(master).selectedIndex = index;
}
}
/**
* @private
* Method to return the childID Array.
*
* @return Array
*/
override public function getChildIDArray():Array
{
var childIDs:Array = [];
var n:int = TabBar(master).numChildren;
for(var i:int = 0; i < n; i++)
{
childIDs[i] = i + 1;
}
return childIDs;
}
/**
* @private
* IAccessible method for returning the bounding box of the Tabs.
*
* @param childID The child id
*
* @return Object Location
*/
override public function accLocation(childID:uint):*
{
var index:int = childID < MAX_NUM ?
childID - 1 :
childID - MAX_NUM - 1;
return TabBar(master).getChildAt(index);
}
/**
* @private
* IAccessible method for returning the childFocus of the TabBar.
*
* @param childID uint
*
* @return focused childID.
*/
override public function get_accFocus():uint
{
var index:int = TabBar(master).focusIndex;
if(index >= 0)
{
return index + 1;
}
return 0;
}
//--------------------------------------
// Protected Methods
//--------------------------------------
/**
* @private
* method for returning the name of the Tab
* which is spoken out by the screen reader.
*
* @param childID The child id.
*
* @return Name
*/
override protected function getName(childID:uint):String
{
if(childID == 0)
{
return "";
}
var name:String;
var tabBar:TabBar = TabBar(master);
// Assuming childID is always ItemID + 1
// because getChildIDArray is not always invoked.
var index:int = childID < MAX_NUM ?
childID - 1 :
childID - MAX_NUM - 1;
var item:TabButton = TabButton(tabBar.getChildAt(index));
name = item.label;
return name;
}
/**
* @private
* Override the generic event handler.
* All AccImpl must implement this to listen for events
* from its master component.
*/
override protected function eventHandler(event:Event):void
{
switch (event.type)
{
case "change":
this.updateSelection(TabBar(master).selectedIndex);
break;
case "focusUpdate":
this.updateFocus(TabBar(master).focusIndex);
break;
}
}
/**
* @private
* Tells the client that a tab has been selected.
*/
protected function updateSelection(index:int):void
{
if(index < 0 || !Accessibility.active)
{
return;
}
var childID:uint = index + 1;
Accessibility.sendEvent(master, childID, EventTypes.EVENT_OBJECT_FOCUS);
Accessibility.sendEvent(master, childID, EventTypes.EVENT_OBJECT_SELECTION);
//Accessibility.updateProperties();
}
/**
* @private
* Tells the client that a tab has been focused.
*/
protected function updateFocus(index:int):void
{
if(index < 0 || !Accessibility.active)
{
return;
}
var childID:uint = index + 1;
Accessibility.sendEvent(master, childID, EventTypes.EVENT_OBJECT_FOCUS);
//Accessibility.updateProperties();
}
}
}

View File

@ -0,0 +1,431 @@
/*
Copyright (c) 2009 Yahoo! Inc. All rights reserved.
The copyrights embodied in the content of this file are licensed under the BSD (revised) open source license
*/
package com.yahoo.astra.fl.accessibility
{
import com.yahoo.astra.accessibility.EventTypes;
import com.yahoo.astra.accessibility.ObjectRoles;
import com.yahoo.astra.accessibility.ObjectStates;
import com.yahoo.astra.fl.controls.Tree;
import com.yahoo.astra.fl.controls.treeClasses.BranchNode;
import com.yahoo.astra.fl.controls.treeClasses.TNode;
import com.yahoo.astra.fl.events.TreeEvent;
import fl.accessibility.SelectableListAccImpl;
import fl.controls.listClasses.ICellRenderer;
import fl.core.UIComponent;
import flash.accessibility.Accessibility;
import flash.events.Event;
/**
* The TreeAccImpl class, also called the Tree Accessiblity Implementation class,
* is used to make a Tree component accessible.
*
* <p>The TreeAccImpl class supports system roles, object-based events, and states.</p>
*
* <p>A Tree reports the role <code>ObjectRoles.ROLE_SYSTEM_OUTLINE</code> (0x23) to a screen
* reader. Items of a Tree report the role <code>ObjectRoles.ROLE_SYSTEM_OUTLINEITEM</code> (0x24).</p>
*
*
* @see com.yahoo.astra.fl.controls.Tree
* @see http://msdn.microsoft.com/en-us/library/ms697605(VS.85).aspx Microsoft Accessibility Developer Center User Interface Element Reference: Tree View Control
*
* @author Alaric Cole
*/
public class TreeAccImpl extends SelectableListAccImpl
{
//--------------------------------------------------------------------------
//
// Class initialization
//
//--------------------------------------------------------------------------
/**
* Static variable triggering the <code>hookAccessibility()</code> method.
* This is used for initializing <code>TreeAccImpl</code> class to hook its
* <code>createAccessibilityImplementation()</code> method to the <code>Tree</code> class
* before it gets called when <code>UIComponent</code> invokes the <code>initializeAccessibility()</code> method.
*
* @see fl.accessibility.UIComponent#createAccessibilityImplementation()
* @see fl.accessibility.UIComponent#initializeAccessibility()
* @see fl.accessibility.UIComponent#initialize()
*/
private static var accessibilityHooked:Boolean = hookAccessibility();
/**
* Static method that swaps the <code>createAccessibilityImplementation()</code>
* method of <code>UIComponent</code> subclass with the appropriate <code>AccImpl</code> subclass.
*
* @see fl.accessibility.UIComponent#createAccessibilityImplementation()
* @see fl.accessibility.UIComponent#initializeAccessibility()
* @see fl.accessibility.UIComponent#initialize()
*/
private static function hookAccessibility():Boolean
{
Tree.createAccessibilityImplementation = createAccessibilityImplementation;
return true;
}
//--------------------------------------------------------------------------
//
// Enabling Accessibility
//
//--------------------------------------------------------------------------
/**
* Method for creating the Accessibility Implementation class for a component.
* <p>This method is called by the <code>initializeAccessibility()</code> method for the <code>UIComponent</code>
* subclass when the component initializes.</p>
* <p>All <code>AccImpl</code> subclasses must implement this method</p>
*
* @param component The UIComponent instance that this TreeAccImpl instance makes accessible.
*
* @see fl.accessibility.AccImpl#createAccessibilityImplementation()
* @see fl.core.UIComponent#createAccessibilityImplementation()
* @see fl.core.UIComponent#initalizeAccessibility()
* @see fl.core.UIComponent#initialize()
*/
public static function createAccessibilityImplementation(component:UIComponent):void
{
component.accessibilityImplementation = new TreeAccImpl(component);
}
/**
* Method call for enabling accessibility for a component.
* This method is required for the compiler to activate the accessibility classes for a component.
*/
public static function enableAccessibility():void
{
//empty
}
//--------------------------------------------------------------------------
//
// Constructor
//
//--------------------------------------------------------------------------
/**
* Creates a new TreeAccImpl instance for the specified Tree component.
*
* @param master The UIComponent instance that this TreeAccImpl instance is making accessible.
*
*/
public function TreeAccImpl(master:UIComponent)
{
super(master);
role = ObjectRoles.ROLE_SYSTEM_OUTLINE;
}
//--------------------------------------------------------------------------
// Role
//--------------------------------------------------------------------------
/**
* @inheritDoc
* @see http://msdn.microsoft.com/en-us/library/ms697605(VS.85).aspx Microsoft Accessibility Developer Center User Interface Element Reference: Tree View Control
*
*/
override public function get_accRole(childID:uint):uint
{
//return the Tree's role itself, or the role of the items
if (childID == 0)
{
return role;
}
return ObjectRoles.ROLE_SYSTEM_OUTLINEITEM;
}
//--------------------------------------------------------------------------
// Name
//--------------------------------------------------------------------------
/**
* @inheritDoc
*/
override protected function getName(childID:uint):String
{
if (childID == 0)
return "";
var name:String = "";
var tree:Tree = Tree(master);
var index:int = childID - 1;
if (index > -1)
{
var item:Object = tree.dataProvider.getItemAt(index);
if (!item)
return name;
if (tree.itemToLabel(item))
name = tree.itemToLabel(item);
name += getLocationDescription(item);
}
return name;
}
//--------------------------------------------------------------------------
// Value
//--------------------------------------------------------------------------
/**
* @inheritDoc
* @see http://msdn.microsoft.com/en-us/library/ms697605(VS.85).aspx Microsoft Accessibility Developer Center User Interface Element Reference: Tree View Control
*/
override public function get_accValue(childID:uint):String
{
var accValue:String = "";
var tree:Tree = Tree(master);
var index:int;
var item:Object;
if (childID == 0)
{
index = tree.selectedIndex;
if (index > -1)
{
item = tree.dataProvider.getItemAt(index);
if (!item)
return accValue;
if (tree.itemToLabel(item))
accValue = tree.itemToLabel(item)
//return the item plus its location
accValue += getLocationDescription(item);
}
}
else
{
index = childID - 1;
if (index > -1)
{
item = tree.dataProvider.getItemAt(index);
if (!item)
return accValue;
var node:TNode = item as TNode;
accValue = node.nodeLevel + 1 + "";
}
}
return accValue;
}
//--------------------------------------------------------------------------
// State
//--------------------------------------------------------------------------
/**
* @inheritDoc
* @see http://msdn.microsoft.com/en-us/library/ms697605(VS.85).aspx Microsoft Accessibility Developer Center User Interface Element Reference: Tree View Control
*/
override public function get_accState(childID:uint):uint
{
var accState:uint = getState(childID);
if (childID > 0)
{
var tree:Tree = Tree(master);
var index:int = childID - 1;
if (index < tree.verticalScrollPosition ||
index >= tree.verticalScrollPosition + tree.rowCount)
{
accState |= ObjectStates.STATE_SYSTEM_INVISIBLE;
}
else
{
accState |= ObjectStates.STATE_SYSTEM_SELECTABLE;
var item:Object = tree.dataProvider.getItemAt(index);
var node:TNode = item as TNode;
if (item && item is BranchNode)
{
if (BranchNode(item).isOpen())
accState |= ObjectStates.STATE_SYSTEM_EXPANDED;
else
accState |= ObjectStates.STATE_SYSTEM_COLLAPSED;
}
var renderer:ICellRenderer = tree.itemToCellRenderer(item);
if (renderer != null && tree.isItemSelected(renderer.data))
accState |= ObjectStates.STATE_SYSTEM_SELECTED | ObjectStates.STATE_SYSTEM_FOCUSED;
}
}
return accState;
}
/**
* @inheritDoc
*/
override protected function get eventsToHandle():Array
{
return super.eventsToHandle.concat([TreeEvent.ITEM_CLOSE, TreeEvent.ITEM_OPEN]);
}
//--------------------------------------------------------------------------
//
// Event Handler
//
//--------------------------------------------------------------------------
/**
* @private
* Override the generic event handler.
* All AccImpl must implement this to listen for events from its master component.
* Here we add a few events.
*
* @param event The event object
*/
override protected function eventHandler(event:Event):void
{
var index:int = Tree(master).selectedIndex;
var childID:uint = index + 1;
switch (event.type)
{
case Event.CHANGE:
{
if (index >= -1)
{
if(Accessibility.active)
{
Accessibility.sendEvent(master, childID,
EventTypes.EVENT_OBJECT_FOCUS);
Accessibility.sendEvent(master, childID,
EventTypes.EVENT_OBJECT_SELECTION);
}
}
break;
}
case TreeEvent.ITEM_OPEN:
case TreeEvent.ITEM_CLOSE:
{
if (index >= -1)
{
if(Accessibility.active)
{
Accessibility.sendEvent(master, childID,
EventTypes.EVENT_OBJECT_STATECHANGE);
}
}
break;
}
}
}
//--------------------------------------------------------------------------
// Default Action
//--------------------------------------------------------------------------
/**
* @inheritDoc
*/
override public function get_accDefaultAction(childID:uint):String
{
if (childID == 0)
return null;
var tree:Tree = Tree(master);
var item:Object = tree.dataProvider.getItemAt(childID - 1);
if (!item)
return null;
if ( item is BranchNode)
return BranchNode(item).isOpen() ? "Collapse" : "Expand";
return null;
}
/**
* @inheritDoc
*/
override public function accDoDefaultAction(childID:uint):void
{
var tree:Tree = Tree(master);
if (childID == 0 || !tree.enabled)
return;
var item:Object = tree.dataProvider.getItemAt(childID - 1);
if (!item)
return;
if (item is BranchNode)
{
var node:BranchNode = item as BranchNode;
if(node.isOpen()) node.closeNode();
else node.openNode();
}
}
/**
* Returns a string with information about the location of a node within a tree structure.
*
* <p>E.g. "[item] 2 of 12 [items]"</p>
*
* @param item Object
*
* @return String.
*/
private function getLocationDescription(item:Object):String
{
var tree:Tree = Tree(master);
var i:int = 0;
var n:int = 0;
var node:TNode = item as TNode;
var parent:BranchNode = node.parentNode;
var childNodes:Array = parent.children;
if (childNodes)
{
n = childNodes.length;
for (i = 0; i < n; i++)
{
//get the index of this node, in relation to sibling nodes
if (item == childNodes[i])
break;
}
}
if (i == n)
i = 0;
//make it 1-based.
if (n > 0)
i++;
return ", " + i + " of " + n;
}
}
}

View File

@ -0,0 +1,5 @@
/*
Copyright (c) 2009 Yahoo! Inc. All rights reserved.
The copyrights embodied in the content of this file are licensed under the BSD (revised) open source license
*/
package com.yahoo.astra.fl.accessibility