 
     //--------------------------------------------------------------------------
     //
-    //  Constants
-    //
-    //--------------------------------------------------------------------------
-    
-    //--------------------------------------------------------------------------
-    //
     //  Class mixins
     //
     //--------------------------------------------------------------------------


use namespace mx_internal;  //ListBase and List share selection properties that are mx_internal

[IconFile("ButtonBar.png")]

[AccessibilityClass(implementation="spark.accessibility.ButtonBarAccImpl")]

/**
 *  The ButtonBar control defines a horizontal group of 

                    renderer.depth = 0;
            }
        }
    }

    //--------------------------------------------------------------------------
    //
    //  Event handlers
    //
    //--------------------------------------------------------------------------
    
    /**
     *  @private
     */
    private function navigationChangeHandler(event:Event):void
    {
        if (ISelectableList(dataProvider).selectedIndex != selectedIndex)
            selectedIndex = ISelectableList(dataProvider).selectedIndex;
    }

    /**
     *  @private
     */
    private function resetCollectionChangeHandler(event:Event):void
    {
        if (event is CollectionEvent)
        {
            var ce:CollectionEvent = CollectionEvent(event);

            if (ce.kind == CollectionEventKind.ADD || 
                ce.kind == CollectionEventKind.REMOVE)
            {
                // force reset here so first/middle/last skins
                // get reassigned
                ce = new CollectionEvent(CollectionEvent.COLLECTION_CHANGE);
                ce.kind = CollectionEventKind.RESET;
                dataProvider.dispatchEvent(ce);
            }
        }
    }

    /**
     *  @private
     *  Called when an item has been added to this component.
     */
    private function dataGroup_rendererAddHandler(event:RendererExistenceEvent):void
    {
        var renderer:IVisualElement = event.renderer; 
        var index:int = event.index;
        
        if (renderer)
        {
            renderer.addEventListener(MouseEvent.CLICK, item_clickHandler);
            if (renderer is IFocusManagerComponent)
                IFocusManagerComponent(renderer).focusEnabled = false;
            if (renderer is ButtonBarButton)
                ButtonBarButton(renderer).allowDeselection = !requireSelection;
        }
    }
    
    /**
     *  @private
     *  Called when an item has been removed from this component.
     */
    private function dataGroup_rendererRemoveHandler(event:RendererExistenceEvent):void
    {        
        var renderer:IVisualElement = event.renderer;
        
        if (renderer)
            renderer.removeEventListener(MouseEvent.CLICK, item_clickHandler);
    }
    
    /**
     *  @private
     *  Called when an item is clicked.
     */
    private function item_clickHandler(event:MouseEvent):void
    {
        var newIndex:int
        if (event.currentTarget is IItemRenderer)
            newIndex = IItemRenderer(event.currentTarget).index;
        else
            newIndex = dataGroup.getElementIndex(event.currentTarget as IVisualElement);

        var currentRenderer:IItemRenderer;
        if (caretIndex >= 0 && !inKeyUpHandler) // don't remove caret when keybd nav
        {
            currentRenderer = dataGroup.getElementAt(caretIndex) as IItemRenderer;
            currentRenderer.showsCaret = false;
        }

        if (newIndex == selectedIndex)
        {
            if (!requireSelection)
                selectedIndex = NO_SELECTION;
        }
        else
        {
            selectedIndex = newIndex;
        }

    }
    
    /**
     *  @private
     */
    private function caretChangeHandler(event:Event):void
    {
        adjustLayering(caretIndex);
    }

    /**
