/*
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.controls
{
import flash.events.Event;
import flash.events.KeyboardEvent;
import fl.core.UIComponent;
import fl.data.DataProvider;
import fl.data.SimpleCollectionItem;
import fl.events.DataChangeEvent;
import fl.controls.Button;
/**
* Abstract class that extends UIComponent and creates a row of buttons.
*
* @see fl.core.UIComponent
*
* @langversion 3.0
* @playerversion Flash 9.0.28.0
* @author Dwight Bridges
*/
public class AbstractButtonRow extends UIComponent
{
//--------------------------------------
// Constructor
//--------------------------------------
/**
* Constructor
*/
public function AbstractButtonRow()
{
super();
}
//--------------------------------------
// Class Methods
//--------------------------------------
/**
* @private
* Creates the Accessibility class.
* This method is called from UIComponent.
*
* @langversion 3.0
* @playerversion Flash 9.0.28.0
*/
public static var createAccessibilityImplementation:Function;
//--------------------------------------
// Properties
//--------------------------------------
/**
* @private (protected)
*/
//When redrawing, buttons are saved in this cache for reuse.
protected var _cachedButtons:Array = [];
/**
* @private (protected)
*/
//Storage for the buttons displayed in the AbstractButtonRow.
protected var _buttons:Array = [];
/**
* @private (protected)
*/
protected var _focusIndex:int = 0;
/**
* Gets or sets the index of the currently focused tab (used for keyboard navigation).
*/
public function get focusIndex():int
{
return this._focusIndex;
}
/**
* @private (setter)
*/
public function set focusIndex(value:int):void
{
this._focusIndex = value;
if(this._focusIndex >= 0)
{
var button:Button = this._buttons[this._focusIndex];
button.setFocus();
//internal event used for accessibility
//similar implementation in Flex TabBar control.
this.dispatchEvent(new Event("focusUpdate"));
}
this.invalidate();
}
/**
* @private
*/
//Like fl.controls.List, the purpose of this variable is
//only to make sure the SimpleCollectionItem is included.
private var collectionItemImport:SimpleCollectionItem;
/**
* @private (protected)
*/
//Storage for the dataProvider property.
protected var _dataProvider:DataProvider;
[Collection(collectionClass="fl.data.DataProvider", collectionItem="fl.data.SimpleCollectionItem", identifier="item")]
/**
* Gets or sets the data model of the list of items to be viewed. A data provider
* can be shared by multiple list-based components. Changes to the data provider
* are immediately available to all components that use it as a data source.
*
* @default null
*
* @langversion 3.0
* @playerversion Flash 9.0.28.0
*/
public function get dataProvider():DataProvider
{
return this._dataProvider;
}
/**
* @private (setter)
*
* @langversion 3.0
* @playerversion Flash 9.0.28.0
*/
public function set dataProvider(value:DataProvider):void
{
if(this._dataProvider)
{
this._dataProvider.removeEventListener(DataChangeEvent.DATA_CHANGE, dataChangeHandler);
}
this._dataProvider = value;
if(this._dataProvider)
{
this._dataProvider.addEventListener(DataChangeEvent.DATA_CHANGE, dataChangeHandler, false, 0, true);
}
this.invalidate();
}
/**
* @private (protected)
* Storage for the labelField property.
*/
protected var _labelField:String = "label";
/**
* Gets or sets the name of the field in the dataProvider
object
* to be displayed as the label in the tabs.
*
*
By default, the component displays the label
property
* of each dataProvider
item. If the dataProvider
* items do not contain a label
property, you can set the
* labelField
property to use a different property.
Note: The labelField
property is not used
* if the labelFunction
property is set to a callback function.
By default, the component displays the label
property
* for a dataProvider
item. But some data sets may not have
* a label
field or may not have a field whose value
* can be used as a label without modification. For example, a given data
* set might store full names but maintain them in lastName
and
* firstName
fields. In such a case, this property could be
* used to set a callback function that concatenates the values of the
* lastName
and firstName
fields into a full
* name string to be displayed.
Note: The labelField
property is not used
* if the labelFunction
property is set to a callback function.
A value of -1 indicates that no tab is selected.
* *When ActionScript is used to set this property, the item at the specified index
* replaces the current selection. When the selection is changed programmatically,
* a change
event object is not dispatched.
If no selection is made, the value of this property is null
.
labelField
and labelFunction
properties.
*
* Note: The labelField
is not used
* if the labelFunction
property is set to a callback function.