<commit_before>////////////////////////////////////////////////////////////////////////////////
//
//  ADOBE SYSTEMS INCORPORATED
//  Copyright 2010 Adobe Systems Incorporated
//  All Rights Reserved.
//
//  NOTICE: Adobe permits you to use, modify, and distribute this file
//  in accordance with the terms of the license agreement accompanying it.
//
////////////////////////////////////////////////////////////////////////////////

package spark.components
{
import mx.core.IVisualElement;
import mx.core.mx_internal;
import mx.utils.BitFlagUtil;

import spark.components.supportClasses.SkinnableComponent;
import spark.core.IDisplayText;
import spark.layouts.supportClasses.LayoutBase;

use namespace mx_internal;

//--------------------------------------
//  Styles
//--------------------------------------

include "../styles/metadata/StyleableTextFieldTextStyles.as"

/**
 *  Alignment of the title relative to the ActionBar dimensions.
 *  Possible values are <code>"left"</code>, <code>"right"</code>,
 *  and <code>"center"</code>.
 * 
 *  @default "center"
 *  
 *  @langversion 3.0
 *  @playerversion Flash 10
 *  @playerversion AIR 2.5
 *  @productversion Flex 4.5
 */
[Style(name="titleAlign", type="String", enumeration="left,right,center", inherit="no", theme="mobile")]

/**
 *  @copy spark.components.supportClasses.GroupBase#style:accentColor
 * 
 *  @default 0x0099FF
 * 
 *  @langversion 3.0
 *  @playerversion Flash 10
 *  @playerversion AIR 2.5
 *  @productversion Flex 4.5
 */
[Style(name="accentColor", type="uint", format="Color", inherit="yes", theme="mobile")]

/**
 *  @copy spark.components.SkinnableContainer#style:backgroundAlpha
 *  
 *  @default 1.0
 *  
 *  @langversion 3.0
 *  @playerversion Flash 10
 *  @playerversion AIR 2.5
 *  @productversion Flex 4.5
 */
[Style(name="backgroundAlpha", type="Number", inherit="no", theme="mobile", minValue="0.0", maxValue="1.0")]

/**
 *  @copy spark.components.SkinnableContainer#style:contentBackgroundAlpha
 *
 *  @default 1.0
 * 
 *  @langversion 3.0
 *  @playerversion Flash 10
 *  @playerversion AIR 2.5
 *  @productversion Flex 4.5
 */
[Style(name="contentBackgroundAlpha", type="Number", inherit="yes", theme="mobile")]

/**
 *  @copy spark.components.supportClasses.GroupBase#style:contentBackgroundColor
 *
 *  @default 0xFFFFFF
 *  
 *  @langversion 3.0
 *  @playerversion Flash 10
 *  @playerversion AIR 2.5
 *  @productversion Flex 4.5
 */ 
[Style(name="contentBackgroundColor", type="uint", format="Color", inherit="yes", theme="mobile")]

/**
 *  @copy spark.components.supportClasses.GroupBase#style:focusColor
 *
 *  @default 0x70B2EE
 *  
 *  @langversion 3.0
 *  @playerversion Flash 10
 *  @playerversion AIR 2.5
 *  @productversion Flex 4.5
 */ 
[Style(name="focusColor", type="uint", format="Color", inherit="yes", theme="mobile")]

/**
 *  Color of text shadows.
 * 
 *  @default 0xFFFFFF
 * 
 *  @langversion 3.0
 *  @playerversion Flash 10
 *  @playerversion AIR 1.5
 *  @productversion Flex 4
 */
[Style(name="textShadowColor", type="uint", format="Color", inherit="yes", theme="mobile")]

/**
 *  Alpha of text shadows.
 * 
 *  @default 0.55
 * 
 *  @langversion 3.0
 *  @playerversion Flash 10
 *  @playerversion AIR 1.5
 *  @productversion Flex 4
 */
[Style(name="textShadowAlpha", type="Number",inherit="yes", minValue="0.0", maxValue="1.0", theme="mobile")]

//--------------------------------------
//  Skin states
//--------------------------------------

/**
 *  Base state of ActionBar with the <code>titleDisplay</code> 
 *  skin part and no content
 *  
 *  @langversion 3.0
 *  @playerversion Flash 10
 *  @playerversion AIR 2.5
 *  @productversion Flex 4.5
 */
[SkinState("title")]

/**
 *  ActionBar with content defined for the <code>titleDisplay</code> 
 *  skin part, and components defined in the <code>actionContent</code> 
 *  property for display in the <code>actionGroup</code> skin part.
 *  
 *  @langversion 3.0
 *  @playerversion Flash 10
 *  @playerversion AIR 2.5
 *  @productversion Flex 4.5
 */
[SkinState("titleWithAction")]

/**
 *  ActionBar with content defined for the <code>titleDisplay</code> 
 *  skin part, and components defined in the <code>navigationContent</code> 
 *  property for display in the <code>navigationGroup</code> skin part.
 *  
 *  @langversion 3.0
 *  @playerversion Flash 10
 *  @playerversion AIR 2.5
 *  @productversion Flex 4.5
 */
[SkinState("titleWithNavigation")]

/**
 *  ActionBar with content defined for the <code>titleDisplay</code> 
 *  skin part, and components for display in 
 *  the <code>actionGroup</code> skin part and in 
 *  the <code>navigationGroup</code> skin part.
 *  
 *  @langversion 3.0
 *  @playerversion Flash 10
 *  @playerversion AIR 2.5
 *  @productversion Flex 4.5
 */
[SkinState("titleWithActionAndNavigation")]

/**
 *  ActionBar with content in the <code>titleContent</code>
 *  skin part, but not in the <code>titleDisplay</code> skin part.
 *  
 *  @langversion 3.0
 *  @playerversion Flash 10
 *  @playerversion AIR 2.5
 *  @productversion Flex 4.5
 */
[SkinState("titleContent")]

/**
 *  ActionBar with content in the <code>titleContent</code>
 *  skin part, and components defined in the <code>actionContent</code> 
 *  property for display in the <code>actionGroup</code> skin part.
 *  
 *  @langversion 3.0
 *  @playerversion Flash 10
 *  @playerversion AIR 2.5
 *  @productversion Flex 4.5
 */
[SkinState("titleContentWithAction")]


/**
 *  ActionBar with content in the <code>titleContent</code>
 *  skin part, and components defined in the <code>navigationContent</code> 
 *  property for display in the <code>navigationGroup</code> skin part.
 *  
 *  @langversion 3.0
 *  @playerversion Flash 10
 *  @playerversion AIR 2.5
 *  @productversion Flex 4.5
 */
[SkinState("titleContentWithNavigation")]

/**
 *  ActionBar with content defined for the <code>titleContent</code> 
 *  skin part, and components for display in 
 *  the <code>actionGroup</code> skin part and in 
 *  the <code>navigationGroup</code> skin part.
 *  
 *  @langversion 3.0
 *  @playerversion Flash 10
 *  @playerversion AIR 2.5
 *  @productversion Flex 4.5
 */
[SkinState("titleContentWithActionAndNavigation")]

/**
 *  The ActionBar class defines a component that includes title, navigation, 
 *  and action content groups. 
 *  The ActionBar control provides a standard area for navigation and action controls. 
 *  It lets you define global controls that can be used from anywhere in the application, 
 *  or controls specific to a view. 
 *
 *  <p>The ActionBar control defines three distinct areas: </p>
 *
 *  <ul>
 *    <li>Navigation area
 *        <p>Contains components that let the user navigate the section. 
 *         For example, you can define a home button in the navigation area. 
 *         Use the <code>navigationContent</code> property to define 
 *         the components that appear in the navigation area. 
 *         Use the <code>navigationLayout</code> property to define 
 *         the layout of the navigation area. </p></li>
 *     <li>Title area
 *         <p>Contains either a String containing title text, or components. 
 *         If you specify components, you cannot specify a title String. 
 *         Use the <code>title</code> property to specify the String to appear in 
 *         the title area. 
 *         Use the <code>titleContent</code> property to define the 
 *         components that appear in the title area. 
 *         Use the <code>titleLayout</code> property to define the 
 *         layout of the title area. 
 *         If you specify a value for the <code>titleContent</code> property, 
 *         the ActionBar skin ignores the <code>title</code> property.</p></li> 
 *      <li>Action area 
 *         <p>Contains components that define actions the user can take in a view. 
 *         For example, you might define a search or refresh button as part of 
 *         the action area. 
 *         Use the <code>actionContent</code> property to define the components 
 *         that appear in the action area. 
 *         Use the <code>actionLayout</code> property to define the layout 
 *         of the action area.</p></li>
 *  </ul>
 *
 *  <p>For a mobile application with a single section, meaning a single  
 *  ViewNavigator container, all views share the same action bar. 
 *  For a mobile application with multiple sections, meaning one with multiple 
 *  ViewNavigator containers, each section defines its own action bar.</p>
 *
 *  @mxml
 *  
 *  <p>The <code>&lt;s:ActionBar&gt;</code> tag inherits all of the tag 
 *  attributes of its superclass and adds the following tag attributes:</p>
 *  
 *  <pre>
 *  &lt;s:ActionBar
 *   <strong>Properties</strong>
 *    actionContent="null"
 *    actionLayout="HorizontalLayout"
 *    navigationContent="null"
 *    navigationLayout="HorizontalLayout"
 *    title=""
 *    titleContent="null"
 *    titleLayout="HorizontalLayout"
 * 
 *   <strong>Common Styles</strong>
 *    color="<i>Theme dependent</i>"
 *    fontFamily="<i>Theme dependent</i>"
 *    fontSize="<i>Theme dependent</i>"
 *    fontStyle="normal"
 *    fontWeight="normal"
 *    leading="0"
 *    letterSpacing="0"
 *    textAlign="center"
 *    textDecoration="none"
 *    textIndent="0"
 * 
 *   <strong>Mobile Styles</strong>
 *    accentColor="0x0099FF"
 *    backgroundAlpha="1.0"
 *    color="<i>Theme dependent</i>"
 *    contentBackgroundAlpha="1.0"
 *    contentBackgroundColor="0xFFFFFF"
 *    focusColor="0x70B2EE"
 *    textShadowAlpha="0.55"
 *    textShadowColor="0xFFFFFF"
 *    titleAlign="center"
 * 
 *  &gt;
 *  </pre>
 *
 *  @see spark.components.SkinnableContainer    
 *  @see ViewNavigator
 *  @see View
 *  @see ViewNavigatorApplication
 *  @see spark.skins.mobile.ActionBarSkin
 *  
 *  @langversion 3.0
 *  @playerversion Flash 10
 *  @playerversion AIR 2.5
 *  @productversion Flex 4.5
 */
public class ActionBar extends SkinnableComponent
{
    
    //--------------------------------------------------------------------------
    //
    //  Class constants
    //
    //--------------------------------------------------------------------------
    
    /**
     *  @private
     */
    mx_internal static const CONTENT_PROPERTY_FLAG:uint = 1 << 0;
    
    /**
     *  @private
     */
    mx_internal static const LAYOUT_PROPERTY_FLAG:uint = 1 << 1;
    
    /**
     *  @private
     */
    mx_internal static const NAVIGATION_GROUP_PROPERTIES_INDEX:uint = 0;
    
    /**
     *  @private
     */
    mx_internal static const TITLE_GROUP_PROPERTIES_INDEX:uint = 1;
    
    /**
     *  @private
     */
    mx_internal static const ACTION_GROUP_PROPERTIES_INDEX:uint = 2
    
    /**
     *  @private
     */
    mx_internal var contentGroupProperties:Array = [{}, {}, {}];
    
    /**
     * Cache original skin layouts
     * @private
     */
    mx_internal var contentGroupLayouts:Array = [null, null, null];
    
    //--------------------------------------------------------------------------
    //
    //  Constructor
    //
    //--------------------------------------------------------------------------
    
    /**
     *  Constructor
     *  @langversion 3.0
     *  @playerversion Flash 10
     *  @playerversion AIR 2.5
     *  @productversion Flex 4.5
     */
    public function ActionBar()
    {
        super();
    }
    
    //--------------------------------------------------------------------------
    //
    //  Variables
    //
    //--------------------------------------------------------------------------
    
    //--------------------------------------------------------------------------
    //
    //  Skin parts 
    //
    //--------------------------------------------------------------------------
    
    [SkinPart(required="false")]
    
    /**
     *  The skin part that defines the appearance of the 
     *  navigation area of the component.
     *  By default, the ActionBarSkin class defines the navigation area to appear 
     *  to the left of the title area.
     *
     *  @see spark.skins.mobile.ActionBarSkin
     * 
     *  @langversion 3.0
     *  @playerversion Flash 10
     *  @playerversion AIR 2.5
     *  @productversion Flex 4.5
     */
    public var navigationGroup:Group;
    
    [SkinPart(required="false")]
    
    /**
     *  The skin part that defines the appearance of the 
     *  title area of the component.
     *  By default, the ActionBarSkin class defines the title area to appear 
     *  between the navigation and action areas.
     *
     *  @see spark.skins.mobile.ActionBarSkin
     * 
     *  @langversion 3.0
     *  @playerversion Flash 10
     *  @playerversion AIR 2.5
     *  @productversion Flex 4.5
     */
    public var titleGroup:Group;
    
    [SkinPart(required="false")]
    
    /**
     *  The skin part that defines the appearance of the 
     *  action area of the component.
     *  By default, the ActionBarSkin class defines the action area to appear 
     *  to the right of the title area.
     *
     *  @see spark.skins.mobile.ActionBarSkin
     * 
     *  @langversion 3.0
     *  @playerversion Flash 10
     *  @playerversion AIR 2.5
     *  @productversion Flex 4.5
     */
    public var actionGroup:Group;
    
    [SkinPart(required="false")]
    
    /**
     *  The skin part that defines the appearance of the 
     *  title text in the component.
     *
     *  @see spark.skins.mobile.ActionBarSkin
     *  
     *  @langversion 3.0
     *  @playerversion Flash 10
     *  @playerversion AIR 2.5
     *  @productversion Flex 4
     */
    public var titleDisplay:IDisplayText;
    
    //----------------------------------
    //  title
    //----------------------------------
    
    private var _title:String = "";
    
    [Bindable]
    
    /**
     *  Title or caption displayed in the title area. 
     *
     *  <p>Use the <code>titleContent</code> property to define 
     *  the components that appear in the title area. 
     *  If you specify a value for the <code>titleContent</code> property, 
     *  the ActionBar skin ignores the <code>title</code> property.</p>
     *
     *  @default ""
     *
     *  @see #titleContent
     * 
     *  @langversion 3.0
     *  @playerversion Flash 10
     *  @playerversion AIR 2.5
     *  @productversion Flex 4.5
     */
    public function get title():String
    {
        return _title;
    }
    
    /**
     *  @private
     */
    public function set title(value:String):void
    {
        if (value == _title)
            return;
        
        _title = value;
        
        if (titleDisplay)
            titleDisplay.text = title;
        
        invalidateSkinState();
    }
    
    
    //----------------------------------
    //  navigationContent
    //---------------------------------- 
    
    [ArrayElementType("mx.core.IVisualElement")]
    
    /**
     *  The components that define navigation for the user. 
     *  These components appear in the navigation area of the control,  
     *  in the <code>navigationGroup</code> skin part. 
     *
     *  <p>The location and appearance of the <code>navigationGroup</code> 
     *  skin part is determined by the ActionBarSkin class.
     *  The default ActionBarSkin class defines the <code>navigationGroup</code>
     *  to appear to the left of the <code>titleGroup</code> area of the ActionBar.</p>
     * 
     *  <p>Create a custom ActionBarSkin skin class to change the default location 
     *  and appearance of the <code>navigationGroup</code> skin part.</p>
     *  
     *  @default null
     *
     *  @see spark.skins.mobile.ActionBarSkin
     *  @see #navigationLayout
     *  
     *  @langversion 3.0
     *  @playerversion Flash 10
     *  @playerversion AIR 2.5
     *  @productversion Flex 4.5
     */
    public function get navigationContent():Array
    {
        if (navigationGroup)
            return navigationGroup.getMXMLContent();
        else
            return contentGroupProperties[NAVIGATION_GROUP_PROPERTIES_INDEX].content
    }
    
    /**
     *  @private
     */
    public function set navigationContent(value:Array):void
    {
        if (navigationGroup)
        {
            navigationGroup.mxmlContent = value;
            contentGroupProperties[NAVIGATION_GROUP_PROPERTIES_INDEX] = 
                BitFlagUtil.update(contentGroupProperties[NAVIGATION_GROUP_PROPERTIES_INDEX] as uint,
                    CONTENT_PROPERTY_FLAG, value != null);
        }
        else
            contentGroupProperties[NAVIGATION_GROUP_PROPERTIES_INDEX].content = value;
        
        invalidateSkinState();
    }
    
    //----------------------------------
    //  navigationLayout
    //---------------------------------- 
    
    /**
     *  Defines the layout of the components contained in 
     *  the <code>navigationGroup</code> skin part.
     *
     *  @default HorizontalLayout
     *
     *  @see #navigationContent
     *  
     *  @langversion 3.0
     *  @playerversion Flash 10
     *  @playerversion AIR 2.5
     *  @productversion Flex 4.5
     */
    public function get navigationLayout():LayoutBase
    {
        if (navigationGroup)
            return navigationGroup.layout;
        else
            return contentGroupProperties[NAVIGATION_GROUP_PROPERTIES_INDEX].layout;
    }
    
    /**
     *  @private
     */
    public function set navigationLayout(value:LayoutBase):void
    {
        if (navigationGroup)
        {
            navigationGroup.layout = (value) ? value : contentGroupLayouts[NAVIGATION_GROUP_PROPERTIES_INDEX];
            contentGroupProperties[NAVIGATION_GROUP_PROPERTIES_INDEX] =
                BitFlagUtil.update(contentGroupProperties[NAVIGATION_GROUP_PROPERTIES_INDEX] as uint, 
                    LAYOUT_PROPERTY_FLAG, true);
        }
        else
            contentGroupProperties[NAVIGATION_GROUP_PROPERTIES_INDEX].layout = value;
    }
    
    //----------------------------------
    //  titleContent
    //---------------------------------- 
    
    [ArrayElementType("mx.core.IVisualElement")]
    
    /**
     *  The components that appear in the title area of the control. 
     *  These components appear in the <code>titleGroup</code> 
     *  skin part of the ActionBar control.
     *
     *  <p>The location and appearance of the <code>titleGroup</code> 
     *  skin part is determined by the ActionBarSkin class.
     *  The default ActionBarSkin class defines the <code>titleGroup</code>
     *  to appear in the center of the ActionBar,
     *  using the space remaining between <code>navigationGroup</code> 
     *  and <code>actionGroup</code> skin parts.</p>
     * 
     *  <p>If <code>titleContent</code> is null, the
     *  <code>titleDisplay</code> skin part, if present, is displayed 
     *  in place of the <code>titleGroup</code> skin part.</p> 
     * 
     *  <p>Create a custom ActionBarSkin skin class to change the default 
     *  location and appearance of the <code>titleGroup</code> skin part.</p>
     *  
     *  @default null
     *
     *  @see spark.skins.mobile.ActionBarSkin
     *  @see #title
     *  @see #titleLayout
     * 
     *  @langversion 3.0
     *  @playerversion Flash 10
     *  @playerversion AIR 2.5
     *  @productversion Flex 4.5
     */
    public function get titleContent():Array
    {
        if (titleGroup)
            return titleGroup.getMXMLContent();
        else
            return contentGroupProperties[TITLE_GROUP_PROPERTIES_INDEX].content;
    }
    
    /**
     *  @private
     */
    public function set titleContent(value:Array):void
    {
        if (titleGroup)
        {
            titleGroup.mxmlContent = value;
            contentGroupProperties[TITLE_GROUP_PROPERTIES_INDEX] = 
                BitFlagUtil.update(contentGroupProperties[TITLE_GROUP_PROPERTIES_INDEX] as uint,
                    CONTENT_PROPERTY_FLAG, value != null);
        }
        else
        {
            contentGroupProperties[TITLE_GROUP_PROPERTIES_INDEX].content = value;
        }
        
        invalidateSkinState();
    }
    
    //----------------------------------
    //  titleLayout
    //---------------------------------- 
    
    /**
     *  Defines the layout of the <code>titleGroup</code> 
     *  and <code>titleDisplay</code> skin parts.
     * 
     *  <p>If the <code>titleContent</code> property is null, 
     *  the <code>titleDisplay</code> skin part is displayed  
     *  in place of the <code>titleGroup</code> skin part. 
     *  The <code>titleDisplay</code> skin part is positioned 
     *  in the center of the ActionBar control
     *  by using the <code>paddingLeft</code> and 
     *  <code>paddingRight</code> properties  of the layout 
     *  class specified by the <code>titleLayout</code> property.</p>
     *
     *  @default HorizontalLayout
     *  @see #titleContent
     *  
     *  @langversion 3.0
     *  @playerversion Flash 10
     *  @playerversion AIR 2.5
     *  @productversion Flex 4.5
     */
    public function get titleLayout():LayoutBase
    {
        if (titleGroup)
            return titleGroup.layout;
        else
            return contentGroupProperties[TITLE_GROUP_PROPERTIES_INDEX].layout;
    }
    
    /**
     *  @private
     */
    public function set titleLayout(value:LayoutBase):void
    {
        if (titleGroup)
        {
            titleGroup.layout = (value) ? value : contentGroupLayouts[TITLE_GROUP_PROPERTIES_INDEX];
            contentGroupProperties[TITLE_GROUP_PROPERTIES_INDEX] =
                BitFlagUtil.update(contentGroupProperties[TITLE_GROUP_PROPERTIES_INDEX] as uint, 
                    LAYOUT_PROPERTY_FLAG, true);
        }
        else
            contentGroupProperties[TITLE_GROUP_PROPERTIES_INDEX].layout = value;
    }
    
    //----------------------------------
    //  actionContent
    //---------------------------------- 
    
    [ArrayElementType("mx.core.IVisualElement")]
    
    /**
     *  The components that define actions the user can take in a view. 
     *  These components appear in the action area of the control,
     *  using the <code>actionGroup</code> skin part. 
     * 
     *  <p>The location and appearance of the <code>actionGroup</code> 
     *  skin part is determined by the ActionBarSkin class.
     *  The default ActionBarSkin class defines the <code>actionGroup</code>
     *  to appear to the right of the title display area of the ActionBar.</p>
     * 
     *  <p>Create a custom ActionBarSkin skin class to change the default location 
     *  and appearance of the <code>actionGroup</code> skin part.</p>
     *  
     *  @default null
     *
     *  @see spark.skins.mobile.ActionBarSkin
     *  @see #actionLayout
     *
     *  @langversion 3.0
     *  @playerversion Flash 10
     *  @playerversion AIR 2.5
     *  @productversion Flex 4.5
     */
    public function get actionContent():Array
    {
        if (actionGroup)
            return actionGroup.getMXMLContent();
        else
            return contentGroupProperties[ACTION_GROUP_PROPERTIES_INDEX].content
    }
    
    /**
     *  @private
     */
    public function set actionContent(value:Array):void
    {
        if (actionGroup)
        {
            actionGroup.mxmlContent = value;
            contentGroupProperties[ACTION_GROUP_PROPERTIES_INDEX] = 
                BitFlagUtil.update(contentGroupProperties[ACTION_GROUP_PROPERTIES_INDEX] as uint,
                    CONTENT_PROPERTY_FLAG, value != null);
        }
        else
            contentGroupProperties[ACTION_GROUP_PROPERTIES_INDEX].content = value;
        
        invalidateSkinState();
    }
    
    //----------------------------------
    //  actionLayout
    //---------------------------------- 
    
    /**
     *  Defines the layout of the components defined in the 
     *  action area by the <code>actionGroup</code> property.
     *
     *  @default HorizontalLayout
     *
     *  @see #actionContent
     *  
     *  @langversion 3.0
     *  @playerversion Flash 10
     *  @playerversion AIR 2.5
     *  @productversion Flex 4.5
     */
    public function get actionLayout():LayoutBase
    {
        if (actionGroup)
            return actionGroup.layout;
        else 
            return contentGroupProperties[ACTION_GROUP_PROPERTIES_INDEX].layout;
    }
    
    /**
     *  @private
     */
    public function set actionLayout(value:LayoutBase):void
    {
        if (actionGroup)
        {
            actionGroup.layout = (value) ? value : contentGroupLayouts[ACTION_GROUP_PROPERTIES_INDEX];
            contentGroupProperties[ACTION_GROUP_PROPERTIES_INDEX] =
                BitFlagUtil.update(contentGroupProperties[ACTION_GROUP_PROPERTIES_INDEX] as uint, 
                    LAYOUT_PROPERTY_FLAG, true);
        }
        else
            contentGroupProperties[ACTION_GROUP_PROPERTIES_INDEX].layout = value;
    }
    
    //--------------------------------------------------------------------------
    //
    //  Overridden methods
    //
    //--------------------------------------------------------------------------
    
    /**
     *  @private
     *  
     *  @langversion 3.0
     *  @playerversion Flash 10
     *  @playerversion AIR 1.5
     *  @productversion Flex 4
     */
    override protected function getCurrentSkinState():String
    {
        var state:String = (titleContent) ? "titleContent" : "title";
        
        if (actionContent && navigationContent)
        {
            state += "WithActionAndNavigation";
        }
        else if (actionContent)
        {
            state += "WithAction";
        }
        else if (navigationContent)
        {
            state += "WithNavigation";
        }
        
        return state;
    }
    
    /**
     *  @private
     */
    override protected function partAdded(partName:String, instance:Object):void
    {
        super.partAdded(partName, instance);
        
        var group:Group;
        var index:int = -1;
        
        // set ID for CSS selectors
        // (e.g. to style actionContent Buttons: s|ActionBar s|Group#actionGroup s|Button)
        if (instance == navigationGroup)
        {
            group = navigationGroup;
            index = NAVIGATION_GROUP_PROPERTIES_INDEX;
        }
        else if (instance == titleGroup)
        {
            group = titleGroup;
            index = TITLE_GROUP_PROPERTIES_INDEX;
        }
        else if (instance == actionGroup)
        {
            group = actionGroup;
            index = ACTION_GROUP_PROPERTIES_INDEX;
        }
        else if (instance == titleDisplay)
        {
            titleDisplay.text = title;
        }
        
        if (index > -1)
        {
            // cache original layout
            contentGroupLayouts[index] = group.layout;
            
            var newContentGroupProperties:uint = 0;
            
            if (contentGroupProperties[index].content !== undefined)
            {
                group.mxmlContent = contentGroupProperties[index].content;
                newContentGroupProperties = BitFlagUtil.update(newContentGroupProperties, 
                    CONTENT_PROPERTY_FLAG, true);
            }
            
            if (contentGroupProperties[index].layout !== undefined)
            {
                group.layout = contentGroupProperties[index].layout;
                newContentGroupProperties = BitFlagUtil.update(newContentGroupProperties, 
                    LAYOUT_PROPERTY_FLAG, true);
            }
            
            contentGroupProperties[index] = newContentGroupProperties;
        }
    }
    
    /**
     *  @private
     */
    override protected function partRemoved(partName:String, instance:Object):void
    {
        super.partRemoved(partName, instance);
        
        var group:Group;
        var index:int = -1;
        
        if (instance == navigationGroup)
        {
            group = navigationGroup;
            index = NAVIGATION_GROUP_PROPERTIES_INDEX;
        }
        else if (instance == titleGroup)
        {
            group = titleGroup;
            index = TITLE_GROUP_PROPERTIES_INDEX;   
        }
        else if (instance == actionGroup)
        {
            group = actionGroup;
            index = ACTION_GROUP_PROPERTIES_INDEX;
        }
        
        if (index > -1)
        {
            var newContentGroupProperties:Object = {};
            
            if (BitFlagUtil.isSet(contentGroupProperties[index] as uint, CONTENT_PROPERTY_FLAG))
                newContentGroupProperties.content = group.getMXMLContent();
            
            if (BitFlagUtil.isSet(contentGroupProperties[index] as uint, LAYOUT_PROPERTY_FLAG))
                newContentGroupProperties.layout = group.layout;
            
            contentGroupProperties[index] = newContentGroupProperties;
            
            group.mxmlContent = null;
            group.layout = null;
        }
    }
}
}<commit_msg>Transferred from the Adobe Open Source Subversion Repository<commit_after>////////////////////////////////////////////////////////////////////////////////
//
//  ADOBE SYSTEMS INCORPORATED
//  Copyright 2010 Adobe Systems Incorporated
//  All Rights Reserved.
//
//  NOTICE: Adobe permits you to use, modify, and distribute this file
//  in accordance with the terms of the license agreement accompanying it.
//
////////////////////////////////////////////////////////////////////////////////

package spark.components
{
import mx.core.IVisualElement;
import mx.core.mx_internal;
import mx.utils.BitFlagUtil;

import spark.components.supportClasses.SkinnableComponent;
import spark.core.IDisplayText;
import spark.layouts.supportClasses.LayoutBase;

use namespace mx_internal;

//--------------------------------------
//  Styles
//--------------------------------------

include "../styles/metadata/StyleableTextFieldTextStyles.as"

/**
 *  Alignment of the title relative to the ActionBar dimensions.
 *  Possible values are <code>"left"</code>, <code>"right"</code>,
 *  and <code>"center"</code>.
 * 
 *  @default "center"
 *  
 *  @langversion 3.0
 *  @playerversion Flash 10
 *  @playerversion AIR 2.5
 *  @productversion Flex 4.5
 */
[Style(name="titleAlign", type="String", enumeration="left,right,center", inherit="no", theme="mobile")]

/**
 *  @copy spark.components.supportClasses.GroupBase#style:accentColor
 * 
 *  @default 0x0099FF
 * 
 *  @langversion 3.0
 *  @playerversion Flash 10
 *  @playerversion AIR 2.5
 *  @productversion Flex 4.5
 */
[Style(name="accentColor", type="uint", format="Color", inherit="yes", theme="mobile")]

/**
 *  @copy spark.components.SkinnableContainer#style:backgroundAlpha
 *  
 *  @default 1.0
 *  
 *  @langversion 3.0
 *  @playerversion Flash 10
 *  @playerversion AIR 2.5
 *  @productversion Flex 4.5
 */
[Style(name="backgroundAlpha", type="Number", inherit="no", theme="mobile", minValue="0.0", maxValue="1.0")]

/**
 *  @copy spark.components.SkinnableContainer#style:contentBackgroundAlpha
 *
 *  @default 1.0
 * 
 *  @langversion 3.0
 *  @playerversion Flash 10
 *  @playerversion AIR 2.5
 *  @productversion Flex 4.5
 */
[Style(name="contentBackgroundAlpha", type="Number", inherit="yes", theme="mobile")]

/**
 *  @copy spark.components.supportClasses.GroupBase#style:contentBackgroundColor
 *
 *  @default 0xFFFFFF
 *  
 *  @langversion 3.0
 *  @playerversion Flash 10
 *  @playerversion AIR 2.5
 *  @productversion Flex 4.5
 */ 
[Style(name="contentBackgroundColor", type="uint", format="Color", inherit="yes", theme="mobile")]

/**
 *  @copy spark.components.supportClasses.GroupBase#style:focusColor
 *
 *  @default 0x70B2EE
 *  
 *  @langversion 3.0
 *  @playerversion Flash 10
 *  @playerversion AIR 2.5
 *  @productversion Flex 4.5
 */ 
[Style(name="focusColor", type="uint", format="Color", inherit="yes", theme="mobile")]

/**
 *  Color of text shadows.
 * 
 *  @default 0xFFFFFF
 * 
 *  @langversion 3.0
 *  @playerversion Flash 10
 *  @playerversion AIR 1.5
 *  @productversion Flex 4
 */
[Style(name="textShadowColor", type="uint", format="Color", inherit="yes", theme="mobile")]

/**
 *  Alpha of text shadows.
 * 
 *  @default 0.55
 * 
 *  @langversion 3.0
 *  @playerversion Flash 10
 *  @playerversion AIR 1.5
 *  @productversion Flex 4
 */
[Style(name="textShadowAlpha", type="Number",inherit="yes", minValue="0.0", maxValue="1.0", theme="mobile")]

//--------------------------------------
//  Skin states
//--------------------------------------

/**
 *  Base state of ActionBar with the <code>titleDisplay</code> 
 *  skin part and no content
 *  
 *  @langversion 3.0
 *  @playerversion Flash 10
 *  @playerversion AIR 2.5
 *  @productversion Flex 4.5
 */
[SkinState("title")]

/**
 *  ActionBar with content defined for the <code>titleDisplay</code> 
 *  skin part, and components defined in the <code>actionContent</code> 
 *  property for display in the <code>actionGroup</code> skin part.
 *  
 *  @langversion 3.0
 *  @playerversion Flash 10
 *  @playerversion AIR 2.5
 *  @productversion Flex 4.5
 */
[SkinState("titleWithAction")]

/**
 *  ActionBar with content defined for the <code>titleDisplay</code> 
 *  skin part, and components defined in the <code>navigationContent</code> 
 *  property for display in the <code>navigationGroup</code> skin part.
 *  
 *  @langversion 3.0
 *  @playerversion Flash 10
 *  @playerversion AIR 2.5
 *  @productversion Flex 4.5
 */
[SkinState("titleWithNavigation")]

/**
 *  ActionBar with content defined for the <code>titleDisplay</code> 
 *  skin part, and components for display in 
 *  the <code>actionGroup</code> skin part and in 
 *  the <code>navigationGroup</code> skin part.
 *  
 *  @langversion 3.0
 *  @playerversion Flash 10
 *  @playerversion AIR 2.5
 *  @productversion Flex 4.5
 */
[SkinState("titleWithActionAndNavigation")]

/**
 *  ActionBar with content in the <code>titleContent</code>
 *  skin part, but not in the <code>titleDisplay</code> skin part.
 *  
 *  @langversion 3.0
 *  @playerversion Flash 10
 *  @playerversion AIR 2.5
 *  @productversion Flex 4.5
 */
[SkinState("titleContent")]

/**
 *  ActionBar with content in the <code>titleContent</code>
 *  skin part, and components defined in the <code>actionContent</code> 
 *  property for display in the <code>actionGroup</code> skin part.
 *  
 *  @langversion 3.0
 *  @playerversion Flash 10
 *  @playerversion AIR 2.5
 *  @productversion Flex 4.5
 */
[SkinState("titleContentWithAction")]


/**
 *  ActionBar with content in the <code>titleContent</code>
 *  skin part, and components defined in the <code>navigationContent</code> 
 *  property for display in the <code>navigationGroup</code> skin part.
 *  
 *  @langversion 3.0
 *  @playerversion Flash 10
 *  @playerversion AIR 2.5
 *  @productversion Flex 4.5
 */
[SkinState("titleContentWithNavigation")]

/**
 *  ActionBar with content defined for the <code>titleContent</code> 
 *  skin part, and components for display in 
 *  the <code>actionGroup</code> skin part and in 
 *  the <code>navigationGroup</code> skin part.
 *  
 *  @langversion 3.0
 *  @playerversion Flash 10
 *  @playerversion AIR 2.5
 *  @productversion Flex 4.5
 */
[SkinState("titleContentWithActionAndNavigation")]

/**
 *  The ActionBar class defines a component that includes title, navigation, 
 *  and action content groups. 
 *  The ActionBar control provides a standard area for navigation and action controls. 
 *  It lets you define global controls that can be used from anywhere in the application, 
 *  or controls specific to a view. 
 *
 *  <p>The ActionBar control defines three distinct areas: </p>
 *
 *  <ul>
 *    <li>Navigation area
 *        <p>Contains components that let the user navigate the section. 
 *         For example, you can define a home button in the navigation area. 
 *         Use the <code>navigationContent</code> property to define 
 *         the components that appear in the navigation area. 
 *         Use the <code>navigationLayout</code> property to define 
 *         the layout of the navigation area. </p></li>
 *     <li>Title area
 *         <p>Contains either a String containing title text, or components. 
 *         If you specify components, you cannot specify a title String. 
 *         Use the <code>title</code> property to specify the String to appear in 
 *         the title area. 
 *         Use the <code>titleContent</code> property to define the 
 *         components that appear in the title area. 
 *         Use the <code>titleLayout</code> property to define the 
 *         layout of the title area. 
 *         If you specify a value for the <code>titleContent</code> property, 
 *         the ActionBar skin ignores the <code>title</code> property.</p></li> 
 *      <li>Action area 
 *         <p>Contains components that define actions the user can take in a view. 
 *         For example, you might define a search or refresh button as part of 
 *         the action area. 
 *         Use the <code>actionContent</code> property to define the components 
 *         that appear in the action area. 
 *         Use the <code>actionLayout</code> property to define the layout 
 *         of the action area.</p></li>
 *  </ul>
 *
 *  <p>For a mobile application with a single section, meaning a single  
 *  ViewNavigator container, all views share the same action bar. 
 *  For a mobile application with multiple sections, meaning one with multiple 
 *  ViewNavigator containers, each section defines its own action bar.</p>
 *
 *  @mxml
 *  
 *  <p>The <code>&lt;s:ActionBar&gt;</code> tag inherits all of the tag 
 *  attributes of its superclass and adds the following tag attributes:</p>
 *  
 *  <pre>
 *  &lt;s:ActionBar
 *   <strong>Properties</strong>
 *    actionContent="null"
 *    actionLayout="HorizontalLayout"
 *    navigationContent="null"
 *    navigationLayout="HorizontalLayout"
 *    title=""
 *    titleContent="null"
 *    titleLayout="HorizontalLayout"
 * 
 *   <strong>Common Styles</strong>
 *    color="<i>Theme dependent</i>"
 *    fontFamily="<i>Theme dependent</i>"
 *    fontSize="<i>Theme dependent</i>"
 *    fontStyle="normal"
 *    fontWeight="normal"
 *    leading="0"
 *    letterSpacing="0"
 *    textAlign="center"
 *    textDecoration="none"
 *    textIndent="0"
 * 
 *   <strong>Mobile Styles</strong>
 *    accentColor="0x0099FF"
 *    backgroundAlpha="1.0"
 *    color="<i>Theme dependent</i>"
 *    contentBackgroundAlpha="1.0"
 *    contentBackgroundColor="0xFFFFFF"
 *    focusColor="0x70B2EE"
 *    textShadowAlpha="0.55"
 *    textShadowColor="0xFFFFFF"
 *    titleAlign="center"
 * 
 *  &gt;
 *  </pre>
 *
 *  @see spark.components.SkinnableContainer    
 *  @see ViewNavigator
 *  @see View
 *  @see ViewNavigatorApplication
 *  @see spark.skins.mobile.ActionBarSkin
 *  
 *  @langversion 3.0
 *  @playerversion Flash 10
 *  @playerversion AIR 2.5
 *  @productversion Flex 4.5
 */
public class ActionBar extends SkinnableComponent
{
    
    //--------------------------------------------------------------------------
    //
    //  Class constants
    //
    //--------------------------------------------------------------------------
    
    /**
     *  @private
     */
    mx_internal static const CONTENT_PROPERTY_FLAG:uint = 1 << 0;
    
    /**
     *  @private
     */
    mx_internal static const LAYOUT_PROPERTY_FLAG:uint = 1 << 1;
    
    /**
     *  @private
     */
    mx_internal static const NAVIGATION_GROUP_PROPERTIES_INDEX:uint = 0;
    
    /**
     *  @private
     */
    mx_internal static const TITLE_GROUP_PROPERTIES_INDEX:uint = 1;
    
    /**
     *  @private
     */
    mx_internal static const ACTION_GROUP_PROPERTIES_INDEX:uint = 2
    
    /**
     *  @private
     */
    mx_internal var contentGroupProperties:Array = [{}, {}, {}];
    
    /**
     * Cache original skin layouts
     * @private
     */
    mx_internal var contentGroupLayouts:Array = [null, null, null];
    
    //--------------------------------------------------------------------------
    //
    //  Constructor
    //
    //--------------------------------------------------------------------------
    
    /**
     *  Constructor.
     *  
     *  @langversion 3.0
     *  @playerversion Flash 10
     *  @playerversion AIR 2.5
     *  @productversion Flex 4.5
     */
    public function ActionBar()
    {
        super();
    }
    
    //--------------------------------------------------------------------------
    //
    //  Variables
    //
    //--------------------------------------------------------------------------
    
    //--------------------------------------------------------------------------
    //
    //  Skin parts 
    //
    //--------------------------------------------------------------------------
    
    [SkinPart(required="false")]
    
    /**
     *  The skin part that defines the appearance of the 
     *  navigation area of the component.
     *  By default, the ActionBarSkin class defines the navigation area to appear 
     *  to the left of the title area.
     *
     *  @see spark.skins.mobile.ActionBarSkin
     * 
     *  @langversion 3.0
     *  @playerversion Flash 10
     *  @playerversion AIR 2.5
     *  @productversion Flex 4.5
     */
    public var navigationGroup:Group;
    
    [SkinPart(required="false")]
    
    /**
     *  The skin part that defines the appearance of the 
     *  title area of the component.
     *  By default, the ActionBarSkin class defines the title area to appear 
     *  between the navigation and action areas.
     *
     *  @see spark.skins.mobile.ActionBarSkin
     * 
     *  @langversion 3.0
     *  @playerversion Flash 10
     *  @playerversion AIR 2.5
     *  @productversion Flex 4.5
     */
    public var titleGroup:Group;
    
    [SkinPart(required="false")]
    
    /**
     *  The skin part that defines the appearance of the 
     *  action area of the component.
     *  By default, the ActionBarSkin class defines the action area to appear 
     *  to the right of the title area.
     *
     *  @see spark.skins.mobile.ActionBarSkin
     * 
     *  @langversion 3.0
     *  @playerversion Flash 10
     *  @playerversion AIR 2.5
     *  @productversion Flex 4.5
     */
    public var actionGroup:Group;
    
    [SkinPart(required="false")]
    
    /**
     *  The skin part that defines the appearance of the 
     *  title text in the component.
     * 
     *  You can use CSS to declare styles on the ActionBar's titleDisplay skin part, as the following example shows:
     *  
     *  <pre>
     *  &#64;namespace s "library://ns.adobe.com/flex/spark"; 
     *  s|ActionBar #titleDisplay { 
     *     color:red; 
     *  }
     * </pre>
     * 
     *  @see spark.skins.mobile.ActionBarSkin
     *  
     *  @langversion 3.0
     *  @playerversion Flash 10
     *  @playerversion AIR 2.5
     *  @productversion Flex 4
     */
    public var titleDisplay:IDisplayText;
    
    //----------------------------------
    //  title
    //----------------------------------
    
    private var _title:String = "";
    
    [Bindable]
    
    /**
     *  Title or caption displayed in the title area. 
     *
     *  <p>Use the <code>titleContent</code> property to define 
     *  the components that appear in the title area. 
     *  If you specify a value for the <code>titleContent</code> property, 
     *  the ActionBar skin ignores the <code>title</code> property.</p>
     *
     *  @default ""
     *
     *  @see #titleContent
     * 
     *  @langversion 3.0
     *  @playerversion Flash 10
     *  @playerversion AIR 2.5
     *  @productversion Flex 4.5
     */
    public function get title():String
    {
        return _title;
    }
    
    /**
     *  @private
     */
    public function set title(value:String):void
    {
        if (value == _title)
            return;
        
        _title = value;
        
        if (titleDisplay)
            titleDisplay.text = title;
        
        invalidateSkinState();
    }
    
    
    //----------------------------------
    //  navigationContent
    //---------------------------------- 
    
    [ArrayElementType("mx.core.IVisualElement")]
    
    /**
     *  The components that define navigation for the user. 
     *  These components appear in the navigation area of the control,  
     *  in the <code>navigationGroup</code> skin part. 
     *
     *  <p>The location and appearance of the <code>navigationGroup</code> 
     *  skin part is determined by the ActionBarSkin class.
     *  The default ActionBarSkin class defines the <code>navigationGroup</code>
     *  to appear to the left of the <code>titleGroup</code> area of the ActionBar.</p>
     * 
     *  <p>Create a custom ActionBarSkin skin class to change the default location 
     *  and appearance of the <code>navigationGroup</code> skin part.</p>
     *  
     *  @default null
     *
     *  @see spark.skins.mobile.ActionBarSkin
     *  @see #navigationLayout
     *  
     *  @langversion 3.0
     *  @playerversion Flash 10
     *  @playerversion AIR 2.5
     *  @productversion Flex 4.5
     */
    public function get navigationContent():Array
    {
        if (navigationGroup)
            return navigationGroup.getMXMLContent();
        else
            return contentGroupProperties[NAVIGATION_GROUP_PROPERTIES_INDEX].content
    }
    
    /**
     *  @private
     */
    public function set navigationContent(value:Array):void
    {
        if (navigationGroup)
        {
            navigationGroup.mxmlContent = value;
            contentGroupProperties[NAVIGATION_GROUP_PROPERTIES_INDEX] = 
                BitFlagUtil.update(contentGroupProperties[NAVIGATION_GROUP_PROPERTIES_INDEX] as uint,
                    CONTENT_PROPERTY_FLAG, value != null);
        }
        else
            contentGroupProperties[NAVIGATION_GROUP_PROPERTIES_INDEX].content = value;
        
        invalidateSkinState();
    }
    
    //----------------------------------
    //  navigationLayout
    //---------------------------------- 
    
    /**
     *  Defines the layout of the components contained in 
     *  the <code>navigationGroup</code> skin part.
     *
     *  @default HorizontalLayout
     *
     *  @see #navigationContent
     *  
     *  @langversion 3.0
     *  @playerversion Flash 10
     *  @playerversion AIR 2.5
     *  @productversion Flex 4.5
     */
    public function get navigationLayout():LayoutBase
    {
        if (navigationGroup)
            return navigationGroup.layout;
        else
            return contentGroupProperties[NAVIGATION_GROUP_PROPERTIES_INDEX].layout;
    }
    
    /**
     *  @private
     */
    public function set navigationLayout(value:LayoutBase):void
    {
        if (navigationGroup)
        {
            navigationGroup.layout = (value) ? value : contentGroupLayouts[NAVIGATION_GROUP_PROPERTIES_INDEX];
            contentGroupProperties[NAVIGATION_GROUP_PROPERTIES_INDEX] =
                BitFlagUtil.update(contentGroupProperties[NAVIGATION_GROUP_PROPERTIES_INDEX] as uint, 
                    LAYOUT_PROPERTY_FLAG, true);
        }
        else
            contentGroupProperties[NAVIGATION_GROUP_PROPERTIES_INDEX].layout = value;
    }
    
    //----------------------------------
    //  titleContent
    //---------------------------------- 
    
    [ArrayElementType("mx.core.IVisualElement")]
    
    /**
     *  The components that appear in the title area of the control. 
     *  These components appear in the <code>titleGroup</code> 
     *  skin part of the ActionBar control.
     *
     *  <p>The location and appearance of the <code>titleGroup</code> 
     *  skin part is determined by the ActionBarSkin class.
     *  The default ActionBarSkin class defines the <code>titleGroup</code>
     *  to appear in the center of the ActionBar,
     *  using the space remaining between <code>navigationGroup</code> 
     *  and <code>actionGroup</code> skin parts.</p>
     * 
     *  <p>If <code>titleContent</code> is null, the
     *  <code>titleDisplay</code> skin part, if present, is displayed 
     *  in place of the <code>titleGroup</code> skin part.</p> 
     * 
     *  <p>Create a custom ActionBarSkin skin class to change the default 
     *  location and appearance of the <code>titleGroup</code> skin part.</p>
     *  
     *  @default null
     *
     *  @see spark.skins.mobile.ActionBarSkin
     *  @see #title
     *  @see #titleLayout
     * 
     *  @langversion 3.0
     *  @playerversion Flash 10
     *  @playerversion AIR 2.5
     *  @productversion Flex 4.5
     */
    public function get titleContent():Array
    {
        if (titleGroup)
            return titleGroup.getMXMLContent();
        else
            return contentGroupProperties[TITLE_GROUP_PROPERTIES_INDEX].content;
    }
    
    /**
     *  @private
     */
    public function set titleContent(value:Array):void
    {
        if (titleGroup)
        {
            titleGroup.mxmlContent = value;
            contentGroupProperties[TITLE_GROUP_PROPERTIES_INDEX] = 
                BitFlagUtil.update(contentGroupProperties[TITLE_GROUP_PROPERTIES_INDEX] as uint,
                    CONTENT_PROPERTY_FLAG, value != null);
        }
        else
        {
            contentGroupProperties[TITLE_GROUP_PROPERTIES_INDEX].content = value;
        }
        
        invalidateSkinState();
    }
    
    //----------------------------------
    //  titleLayout
    //---------------------------------- 
    
    /**
     *  Defines the layout of the <code>titleGroup</code> 
     *  and <code>titleDisplay</code> skin parts.
     * 
     *  <p>If the <code>titleContent</code> property is null, 
     *  the <code>titleDisplay</code> skin part is displayed  
     *  in place of the <code>titleGroup</code> skin part. 
     *  The <code>titleDisplay</code> skin part is positioned 
     *  in the center of the ActionBar control
     *  by using the <code>paddingLeft</code> and 
     *  <code>paddingRight</code> properties  of the layout 
     *  class specified by the <code>titleLayout</code> property.</p>
     *
     *  @default HorizontalLayout
     *  @see #titleContent
     *  
     *  @langversion 3.0
     *  @playerversion Flash 10
     *  @playerversion AIR 2.5
     *  @productversion Flex 4.5
     */
    public function get titleLayout():LayoutBase
    {
        if (titleGroup)
            return titleGroup.layout;
        else
            return contentGroupProperties[TITLE_GROUP_PROPERTIES_INDEX].layout;
    }
    
    /**
     *  @private
     */
    public function set titleLayout(value:LayoutBase):void
    {
        if (titleGroup)
        {
            titleGroup.layout = (value) ? value : contentGroupLayouts[TITLE_GROUP_PROPERTIES_INDEX];
            contentGroupProperties[TITLE_GROUP_PROPERTIES_INDEX] =
                BitFlagUtil.update(contentGroupProperties[TITLE_GROUP_PROPERTIES_INDEX] as uint, 
                    LAYOUT_PROPERTY_FLAG, true);
        }
        else
            contentGroupProperties[TITLE_GROUP_PROPERTIES_INDEX].layout = value;
    }
    
    //----------------------------------
    //  actionContent
    //---------------------------------- 
    
    [ArrayElementType("mx.core.IVisualElement")]
    
    /**
     *  The components that define actions the user can take in a view. 
     *  These components appear in the action area of the control,
     *  using the <code>actionGroup</code> skin part. 
     * 
     *  <p>The location and appearance of the <code>actionGroup</code> 
     *  skin part is determined by the ActionBarSkin class.
     *  The default ActionBarSkin class defines the <code>actionGroup</code>
     *  to appear to the right of the title display area of the ActionBar.</p>
     * 
     *  <p>Create a custom ActionBarSkin skin class to change the default location 
     *  and appearance of the <code>actionGroup</code> skin part.</p>
     *  
     *  @default null
     *
     *  @see spark.skins.mobile.ActionBarSkin
     *  @see #actionLayout
     *
     *  @langversion 3.0
     *  @playerversion Flash 10
     *  @playerversion AIR 2.5
     *  @productversion Flex 4.5
     */
    public function get actionContent():Array
    {
        if (actionGroup)
            return actionGroup.getMXMLContent();
        else
            return contentGroupProperties[ACTION_GROUP_PROPERTIES_INDEX].content
    }
    
    /**
     *  @private
     */
    public function set actionContent(value:Array):void
    {
        if (actionGroup)
        {
            actionGroup.mxmlContent = value;
            contentGroupProperties[ACTION_GROUP_PROPERTIES_INDEX] = 
                BitFlagUtil.update(contentGroupProperties[ACTION_GROUP_PROPERTIES_INDEX] as uint,
                    CONTENT_PROPERTY_FLAG, value != null);
        }
        else
            contentGroupProperties[ACTION_GROUP_PROPERTIES_INDEX].content = value;
        
        invalidateSkinState();
    }
    
    //----------------------------------
    //  actionLayout
    //---------------------------------- 
    
    /**
     *  Defines the layout of the components defined in the 
     *  action area by the <code>actionGroup</code> property.
     *
     *  @default HorizontalLayout
     *
     *  @see #actionContent
     *  
     *  @langversion 3.0
     *  @playerversion Flash 10
     *  @playerversion AIR 2.5
     *  @productversion Flex 4.5
     */
    public function get actionLayout():LayoutBase
    {
        if (actionGroup)
            return actionGroup.layout;
        else 
            return contentGroupProperties[ACTION_GROUP_PROPERTIES_INDEX].layout;
    }
    
    /**
     *  @private
     */
    public function set actionLayout(value:LayoutBase):void
    {
        if (actionGroup)
        {
            actionGroup.layout = (value) ? value : contentGroupLayouts[ACTION_GROUP_PROPERTIES_INDEX];
            contentGroupProperties[ACTION_GROUP_PROPERTIES_INDEX] =
                BitFlagUtil.update(contentGroupProperties[ACTION_GROUP_PROPERTIES_INDEX] as uint, 
                    LAYOUT_PROPERTY_FLAG, true);
        }
        else
            contentGroupProperties[ACTION_GROUP_PROPERTIES_INDEX].layout = value;
    }
    
    //--------------------------------------------------------------------------
    //
    //  Overridden methods
    //
    //--------------------------------------------------------------------------
    
    /**
     *  @private
     *  
     *  @langversion 3.0
     *  @playerversion Flash 10
     *  @playerversion AIR 1.5
     *  @productversion Flex 4
     */
    override protected function getCurrentSkinState():String
    {
        var state:String = (titleContent) ? "titleContent" : "title";
        
        if (actionContent && navigationContent)
        {
            state += "WithActionAndNavigation";
        }
        else if (actionContent)
        {
            state += "WithAction";
        }
        else if (navigationContent)
        {
            state += "WithNavigation";
        }
        
        return state;
    }
    
    /**
     *  @private
     */
    override protected function partAdded(partName:String, instance:Object):void
    {
        super.partAdded(partName, instance);
        
        var group:Group;
        var index:int = -1;
        
        // set ID for CSS selectors
        // (e.g. to style actionContent Buttons: s|ActionBar s|Group#actionGroup s|Button)
        if (instance == navigationGroup)
        {
            group = navigationGroup;
            index = NAVIGATION_GROUP_PROPERTIES_INDEX;
        }
        else if (instance == titleGroup)
        {
            group = titleGroup;
            index = TITLE_GROUP_PROPERTIES_INDEX;
        }
        else if (instance == actionGroup)
        {
            group = actionGroup;
            index = ACTION_GROUP_PROPERTIES_INDEX;
        }
        else if (instance == titleDisplay)
        {
            titleDisplay.text = title;
        }
        
        if (index > -1)
        {
            // cache original layout
            contentGroupLayouts[index] = group.layout;
            
            var newContentGroupProperties:uint = 0;
            
            if (contentGroupProperties[index].content !== undefined)
            {
                group.mxmlContent = contentGroupProperties[index].content;
                newContentGroupProperties = BitFlagUtil.update(newContentGroupProperties, 
                    CONTENT_PROPERTY_FLAG, true);
            }
            
            if (contentGroupProperties[index].layout !== undefined)
            {
                group.layout = contentGroupProperties[index].layout;
                newContentGroupProperties = BitFlagUtil.update(newContentGroupProperties, 
                    LAYOUT_PROPERTY_FLAG, true);
            }
            
            contentGroupProperties[index] = newContentGroupProperties;
        }
    }
    
    /**
     *  @private
     */
    override protected function partRemoved(partName:String, instance:Object):void
    {
        super.partRemoved(partName, instance);
        
        var group:Group;
        var index:int = -1;
        
        if (instance == navigationGroup)
        {
            group = navigationGroup;
            index = NAVIGATION_GROUP_PROPERTIES_INDEX;
        }
        else if (instance == titleGroup)
        {
            group = titleGroup;
            index = TITLE_GROUP_PROPERTIES_INDEX;   
        }
        else if (instance == actionGroup)
        {
            group = actionGroup;
            index = ACTION_GROUP_PROPERTIES_INDEX;
        }
        
        if (index > -1)
        {
            var newContentGroupProperties:Object = {};
            
            if (BitFlagUtil.isSet(contentGroupProperties[index] as uint, CONTENT_PROPERTY_FLAG))
                newContentGroupProperties.content = group.getMXMLContent();
            
            if (BitFlagUtil.isSet(contentGroupProperties[index] as uint, LAYOUT_PROPERTY_FLAG))
                newContentGroupProperties.layout = group.layout;
            
            contentGroupProperties[index] = newContentGroupProperties;
            
            group.mxmlContent = null;
            group.layout = null;
        }
    }
}
}
{'fraction_non_alphanumeric': 0.14756154123649357, 'fraction_numerical': 0.01030697610499373, 'mean_word_length': 1.899392369757944, 'pattern_counts': {'":': 0, '<': 385, '<?xml version=': 0, '>': 381, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 12}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6542299', 'n_tokens_mistral': 16830, 'n_tokens_neox': 16025, 'n_words': 4043}