package com.magic.component { import flash.events.MouseEvent; import mx.controls.ToggleButtonBar; import mx.core.ClassFactory; import mx.core.IFlexDisplayObject; import mx.core.IUITextField; import mx.styles.CSSStyleDeclaration; import flash.events.KeyboardEvent; import mx.styles.StyleManager; public class ShadowedTextToggleButtonBar extends ToggleButtonBar { private var navItemFactory:ClassFactory; private var buttonStyleNameProp:String = "buttonStyleName"; /** * @private * Name of style used to specify buttonStyleName. * Overridden by TabBar. */ private var firstButtonStyleNameProp:String = "firstButtonStyleName"; /** * @private * Name of style used to specify buttonStyleName. * Overridden by TabBar. */ private var lastButtonStyleNameProp:String = "lastButtonStyleName"; /** * @private * Name of style used to specify buttonWidth. * Overridden by TabBar. */ private var buttonWidthProp:String = "buttonWidth"; /** * @private * Name of style used to specify buttonHeight. * Overridden by TabBar. */ private var buttonHeightProp:String = "buttonHeight"; private var recalcButtonWidths:Boolean = false; /** * @private * Flag indicating whether buttons heights should be recalculated. */ private var recalcButtonHeights:Boolean = false; public function ShadowedTextToggleButtonBar() { //TODO: implement function super(); navItemFactory = new ClassFactory(ShadowedTextButton); } // overridden to block keyboard temporarily. override protected function keyDownHandler(event:KeyboardEvent):void { //do nothing } override protected function createNavItem(strLabel:String, clsIcon:Class=null):IFlexDisplayObject { var newButton:ShadowedTextButton = ShadowedTextButton(navItemFactory.newInstance()); // Set tabEnabled to false so individual buttons don't get focus. newButton.focusEnabled = false; var buttonStyleName:String = getStyle(buttonStyleNameProp); var firstButtonStyleName:String = getStyle(firstButtonStyleNameProp); var lastButtonStyleName:String = getStyle(lastButtonStyleNameProp); if (!buttonStyleName) buttonStyleName = "ButtonBarButton"; if (!firstButtonStyleName) firstButtonStyleName = buttonStyleName; if (!lastButtonStyleName) lastButtonStyleName = buttonStyleName; var n:int = numChildren; if (n == 0) { newButton.styleName = buttonStyleName; } else { if(strLabel!="Curriculum Builder"){ newButton.styleName = lastButtonStyleName; //var CBuilderButton:ShadowedTextButton = ShadowedTextButton(getChildAt(6)); //CBuilderButton.setStyle("color","#000000"); } else{ newButton.setStyle("color","#0000FF"); } var cssStyleDeclaration:CSSStyleDeclaration = StyleManager.getStyleDeclaration("." + lastButtonStyleName); if (cssStyleDeclaration && !cssStyleDeclaration.getStyle("focusRoundedCorners")) { newButton.setStyle("focusRoundedCorners", "tr br"); } // Refresh the skins for the last button that was in this position. var first:Boolean = (n == 1); var lastButton:ShadowedTextButton = ShadowedTextButton(getChildAt(first ? 0 : n - 1)); if (first) { lastButton.styleName = firstButtonStyleName; cssStyleDeclaration = StyleManager.getStyleDeclaration("." + firstButtonStyleName); if (cssStyleDeclaration && !cssStyleDeclaration.getStyle("focusRoundedCorners")) { lastButton.setStyle("focusRoundedCorners", "tl bl"); } } else { lastButton.styleName = buttonStyleName; cssStyleDeclaration = StyleManager.getStyleDeclaration("." + buttonStyleName); if (cssStyleDeclaration && !cssStyleDeclaration.getStyle("focusRoundedCorners")) { lastButton.setStyle("focusRoundedCorners", ""); } } // lastButton.changeSkins(); lastButton.invalidateDisplayList(); } newButton.label = strLabel; // newButton.setStyle("icon", icon); newButton.minHeight=35; //newButton.maxHeight=38; newButton.addEventListener(MouseEvent.CLICK, clickHandler); this.addChild(newButton); recalcButtonWidths = recalcButtonHeights = true; newButton.addTextFilter(); return newButton; } } }