You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by ft...@apache.org on 2012/12/16 05:39:00 UTC
svn commit: r1422462 [3/3] - in
/incubator/flex/sdk/branches/develop/frameworks/projects/experimental: ./
assets/ assets/dividers/ bundles/en_US/ src/
src/org/apache/flex/components/ src/org/apache/flex/components/sparkAlert/
src/org/apache/flex/compon...
Added: incubator/flex/sdk/branches/develop/frameworks/projects/experimental/src/org/apache/flex/components/sparkMenu/events/MenuEvent.as
URL: http://svn.apache.org/viewvc/incubator/flex/sdk/branches/develop/frameworks/projects/experimental/src/org/apache/flex/components/sparkMenu/events/MenuEvent.as?rev=1422462&view=auto
==============================================================================
--- incubator/flex/sdk/branches/develop/frameworks/projects/experimental/src/org/apache/flex/components/sparkMenu/events/MenuEvent.as (added)
+++ incubator/flex/sdk/branches/develop/frameworks/projects/experimental/src/org/apache/flex/components/sparkMenu/events/MenuEvent.as Sun Dec 16 04:38:49 2012
@@ -0,0 +1,60 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// Licensed to the Apache Software Foundation (ASF) under one or more
+// contributor license agreements. See the NOTICE file distributed with
+// this work for additional information regarding copyright ownership.
+// The ASF licenses this file to You under the Apache License, Version 2.0
+// (the "License"); you may not use this file except in compliance with
+// the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.components.sparkMenu.events
+{
+ import flash.events.Event;
+
+ import spark.components.List;
+ import spark.events.IndexChangeEvent;
+
+ import org.apache.flex.components.sparkMenu.Menu;
+
+ /**
+ * @author Bogdan Dinu (http://www.badu.ro)
+ */
+ public class MenuEvent extends IndexChangeEvent
+ {
+ public static const SELECTED:String = "selected";
+ public static const CHECKED:String = "checked";
+
+ public var menu:List;
+ public var item:Object;
+
+ public function MenuEvent(type:String,
+ bubbles:Boolean=false,
+ cancelable:Boolean = false,
+ owner:List = null,
+ selectedItem:Object = null)
+ {
+ super(type, bubbles, cancelable);
+ menu = owner;
+ item = selectedItem;
+ }
+
+ override public function clone():Event
+ {
+ return new MenuEvent(type, bubbles, cancelable, menu, item);
+ }
+
+ public static function convert(event:IndexChangeEvent, menu:Menu, item:Object):Event
+ {
+ return new MenuEvent(event.type, event.bubbles, event.cancelable, menu, item);
+ }
+ }
+}
Added: incubator/flex/sdk/branches/develop/frameworks/projects/experimental/src/org/apache/flex/components/sparkMenu/skin/MenuBarItemRenderer.mxml
URL: http://svn.apache.org/viewvc/incubator/flex/sdk/branches/develop/frameworks/projects/experimental/src/org/apache/flex/components/sparkMenu/skin/MenuBarItemRenderer.mxml?rev=1422462&view=auto
==============================================================================
--- incubator/flex/sdk/branches/develop/frameworks/projects/experimental/src/org/apache/flex/components/sparkMenu/skin/MenuBarItemRenderer.mxml (added)
+++ incubator/flex/sdk/branches/develop/frameworks/projects/experimental/src/org/apache/flex/components/sparkMenu/skin/MenuBarItemRenderer.mxml Sun Dec 16 04:38:49 2012
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="utf-8"?>
+<menu:MenuCoreItemRenderer
+ xmlns:fx="http://ns.adobe.com/mxml/2009"
+ xmlns:s="library://ns.adobe.com/flex/spark"
+ xmlns:mx="library://ns.adobe.com/flex/mx"
+ xmlns:menu="org.apache.flex.components.sparkMenu.*"
+ minWidth="100" minHeight="20"
+ rollOut="onRollOut(event)"
+ useHandCursor="true" mouseChildren="false" buttonMode="true">
+ <!--
+ ////////////////////////////////////////////////////////////////////////////////
+ //
+ // Licensed to the Apache Software Foundation (ASF) under one or more
+ // contributor license agreements. See the NOTICE file distributed with
+ // this work for additional information regarding copyright ownership.
+ // The ASF licenses this file to You under the Apache License, Version 2.0
+ // (the "License"); you may not use this file except in compliance with
+ // the License. You may obtain a copy of the License at
+ //
+ // http://www.apache.org/licenses/LICENSE-2.0
+ //
+ // Unless required by applicable law or agreed to in writing, software
+ // distributed under the License is distributed on an "AS IS" BASIS,
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ // See the License for the specific language governing permissions and
+ // limitations under the License.
+ //
+ ////////////////////////////////////////////////////////////////////////////////
+ @author Bogdan Dinu (http://www.badu.ro)
+ -->
+ <s:BitmapImage left="0" top="0" id="icon" source="{iconSource}" includeInLayout="{hasIcon}" visible="{hasIcon}" />
+ <s:Label id="labelDisplay" textAlign="center" height="100%" width="100%" verticalAlign="middle" />
+
+ <fx:Script>
+ <![CDATA[
+ protected function onRollOut(event:MouseEvent):void
+ {
+ if (event.relatedObject == null || owner.contains(event.relatedObject))
+ {
+ hovered = false;
+ }
+ }
+ ]]>
+ </fx:Script>
+</menu:MenuCoreItemRenderer>
\ No newline at end of file
Added: incubator/flex/sdk/branches/develop/frameworks/projects/experimental/src/org/apache/flex/components/sparkMenu/skin/MenuBarSkin.mxml
URL: http://svn.apache.org/viewvc/incubator/flex/sdk/branches/develop/frameworks/projects/experimental/src/org/apache/flex/components/sparkMenu/skin/MenuBarSkin.mxml?rev=1422462&view=auto
==============================================================================
--- incubator/flex/sdk/branches/develop/frameworks/projects/experimental/src/org/apache/flex/components/sparkMenu/skin/MenuBarSkin.mxml (added)
+++ incubator/flex/sdk/branches/develop/frameworks/projects/experimental/src/org/apache/flex/components/sparkMenu/skin/MenuBarSkin.mxml Sun Dec 16 04:38:49 2012
@@ -0,0 +1,122 @@
+<?xml version="1.0" encoding="utf-8"?>
+<s:SparkSkin xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark"
+ xmlns:fb="http://ns.adobe.com/flashbuilder/2009"
+ minWidth="112" minHeight="30"
+ alpha.disabled="0.5" blendMode="normal">
+ <!--
+ ////////////////////////////////////////////////////////////////////////////////
+ //
+ // Licensed to the Apache Software Foundation (ASF) under one or more
+ // contributor license agreements. See the NOTICE file distributed with
+ // this work for additional information regarding copyright ownership.
+ // The ASF licenses this file to You under the Apache License, Version 2.0
+ // (the "License"); you may not use this file except in compliance with
+ // the License. You may obtain a copy of the License at
+ //
+ // http://www.apache.org/licenses/LICENSE-2.0
+ //
+ // Unless required by applicable law or agreed to in writing, software
+ // distributed under the License is distributed on an "AS IS" BASIS,
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ // See the License for the specific language governing permissions and
+ // limitations under the License.
+ //
+ ////////////////////////////////////////////////////////////////////////////////
+ @author Bogdan Dinu (http://www.badu.ro)
+ -->
+ <fx:Metadata>
+ <![CDATA[
+ /**
+ * @copy spark.skins.spark.ApplicationSkin#hostComponent
+ */
+ [HostComponent("spark.components.List")]
+ ]]>
+ </fx:Metadata>
+
+ <s:states>
+ <s:State name="normal" />
+ <s:State name="disabled" />
+ </s:states>
+
+ <!-- border -->
+ <!--- @private -->
+ <s:Rect left="0" right="0" top="0" bottom="0" id="border">
+ <s:stroke>
+ <!--- @private -->
+ <s:SolidColorStroke id="borderStroke" weight="1"/>
+ </s:stroke>
+ </s:Rect>
+
+ <!-- fill -->
+ <!--- Defines the background appearance of the list-based component. -->
+ <s:Rect id="background" left="1" right="1" top="1" bottom="1" >
+ <s:fill>
+ <!--- Defines the color of the background. The default color is 0xFFFFFF. -->
+ <s:SolidColor id="bgFill" color="0xFFFFFF" />
+ </s:fill>
+ </s:Rect>
+
+ <s:DataGroup id="dataGroup" left="0" top="0" right="0" bottom="0"
+ itemRenderer="org.apache.flex.components.sparkMenu.skin.MenuBarItemRenderer">
+ <s:layout>
+ <!--- The default layout is vertical and measures at least for 5 rows.
+ When switching to a different layout, HorizontalLayout for example,
+ make sure to adjust the minWidth, minHeihgt sizes of the skin -->
+ <s:VerticalLayout gap="0" horizontalAlign="contentJustify" requestedMinRowCount="1" />
+ </s:layout>
+ </s:DataGroup>
+
+ <fx:Script fb:purpose="styling">
+ /* Define the skin elements that should not be colorized.
+ For list, the skin itself is colorized but the individual parts are not. */
+ static private const exclusions:Array = ["background"];
+
+ /**
+ * @private
+ */
+ override public function get colorizeExclusions():Array {return exclusions;}
+
+ /* Define the content fill items that should be colored by the "contentBackgroundColor" style. */
+ static private const contentFill:Array = ["bgFill"];
+
+ /**
+ * @private
+ */
+ override public function get contentItems():Array {return contentFill};
+
+ /**
+ * @private
+ */
+ override protected function initializationComplete():void
+ {
+ useChromeColor = true;
+ super.initializationComplete();
+ }
+ /**
+ * @langversion 3.0
+ * @playerversion Flash 10.1
+ * @playerversion AIR 2.5
+ * @productversion Flex 4.5
+ */
+ override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void
+ {
+ if (getStyle("borderVisible") == true)
+ {
+ border.visible = true;
+ background.left = background.top = background.right = background.bottom = 1;
+ dataGroup.left = dataGroup.top = dataGroup.right = dataGroup.bottom = 1;
+ }
+ else
+ {
+ border.visible = false;
+ background.left = background.top = background.right = background.bottom = 0;
+ dataGroup.left = dataGroup.top = dataGroup.right = dataGroup.bottom = 0;
+ }
+
+ borderStroke.color = getStyle("borderColor");
+ borderStroke.alpha = getStyle("borderAlpha");
+
+ super.updateDisplayList(unscaledWidth, unscaledHeight);
+ }
+ </fx:Script>
+</s:SparkSkin>
Added: incubator/flex/sdk/branches/develop/frameworks/projects/experimental/src/org/apache/flex/components/sparkMenu/skin/MenuItemRenderer.mxml
URL: http://svn.apache.org/viewvc/incubator/flex/sdk/branches/develop/frameworks/projects/experimental/src/org/apache/flex/components/sparkMenu/skin/MenuItemRenderer.mxml?rev=1422462&view=auto
==============================================================================
--- incubator/flex/sdk/branches/develop/frameworks/projects/experimental/src/org/apache/flex/components/sparkMenu/skin/MenuItemRenderer.mxml (added)
+++ incubator/flex/sdk/branches/develop/frameworks/projects/experimental/src/org/apache/flex/components/sparkMenu/skin/MenuItemRenderer.mxml Sun Dec 16 04:38:49 2012
@@ -0,0 +1,69 @@
+<?xml version="1.0" encoding="utf-8"?>
+<menu:MenuCoreItemRenderer
+ xmlns:fx="http://ns.adobe.com/mxml/2009"
+ xmlns:s="library://ns.adobe.com/flex/spark"
+ xmlns:mx="library://ns.adobe.com/flex/mx"
+ autoDrawBackground="{!isSeparator}"
+ xmlns:menu="org.apache.flex.components.sparkMenu.*"
+ minWidth="150" minHeight="20"
+ useHandCursor="true" mouseChildren="false" buttonMode="true">
+ <!--
+ ////////////////////////////////////////////////////////////////////////////////
+ //
+ // Licensed to the Apache Software Foundation (ASF) under one or more
+ // contributor license agreements. See the NOTICE file distributed with
+ // this work for additional information regarding copyright ownership.
+ // The ASF licenses this file to You under the Apache License, Version 2.0
+ // (the "License"); you may not use this file except in compliance with
+ // the License. You may obtain a copy of the License at
+ //
+ // http://www.apache.org/licenses/LICENSE-2.0
+ //
+ // Unless required by applicable law or agreed to in writing, software
+ // distributed under the License is distributed on an "AS IS" BASIS,
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ // See the License for the specific language governing permissions and
+ // limitations under the License.
+ //
+ ////////////////////////////////////////////////////////////////////////////////
+ @author Bogdan Dinu (http://www.badu.ro)
+ -->
+ <s:Group visible="{!isSeparator}" includeInLayout="{!isSeparator}" left="0" right="0" height="100%">
+ <s:BitmapImage left="0" top="0" id="icon" source="{iconSource}" includeInLayout="{hasIcon}" visible="{hasIcon}" />
+ <s:Label id="labelDisplay" left="16" right="10" height="100%" verticalAlign="middle" />
+ <s:Group id="menuIcon" visible="{dataProvider.length > 0}" right="3" top="5" >
+ <s:Path data="M 0 2 L 6 6 L 0 10 L 0 2" >
+ <s:fill>
+ <s:SolidColor color="0x000000" />
+ </s:fill>
+ </s:Path>
+ </s:Group>
+ <s:Group id="checkIcon" visible="{isChecked}" includeInLayout="{isCheckable}" right="3" top="5" >
+ <s:Path left="2" top="0"
+ data="M 9.2 0.1 L 4.05 6.55 L 3.15 5.0 L 0.05 5.0 L 4.6 9.7 L 12.05 0.1 L 9.2 0.1">
+ <s:fill>
+ <s:SolidColor color="0" alpha="0.8" />
+ </s:fill>
+ </s:Path>
+ </s:Group>
+ </s:Group>
+
+
+ <s:Group id="separator"
+ includeInLayout="{isSeparator}"
+ visible="{isSeparator}" left="0" right="0" verticalCenter="0" >
+ <s:Rect left="0" right="0" height="1" >
+ <s:fill>
+ <s:SolidColor color="0x4F4F4F" />
+ </s:fill>
+ </s:Rect>
+ </s:Group>
+ <fx:Script>
+ <![CDATA[
+ override public function get isSubMenuRenderer() : Boolean
+ {
+ return true;
+ }
+ ]]>
+ </fx:Script>
+</menu:MenuCoreItemRenderer>
\ No newline at end of file
Added: incubator/flex/sdk/branches/develop/frameworks/projects/experimental/src/org/apache/flex/components/sparkMenu/skin/MenuSkin.mxml
URL: http://svn.apache.org/viewvc/incubator/flex/sdk/branches/develop/frameworks/projects/experimental/src/org/apache/flex/components/sparkMenu/skin/MenuSkin.mxml?rev=1422462&view=auto
==============================================================================
--- incubator/flex/sdk/branches/develop/frameworks/projects/experimental/src/org/apache/flex/components/sparkMenu/skin/MenuSkin.mxml (added)
+++ incubator/flex/sdk/branches/develop/frameworks/projects/experimental/src/org/apache/flex/components/sparkMenu/skin/MenuSkin.mxml Sun Dec 16 04:38:49 2012
@@ -0,0 +1,122 @@
+<?xml version="1.0" encoding="utf-8"?>
+<s:SparkSkin xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark"
+ xmlns:fb="http://ns.adobe.com/flashbuilder/2009"
+ minWidth="112" minHeight="30"
+ alpha.disabled="0.5" blendMode="normal">
+ <!--
+ ////////////////////////////////////////////////////////////////////////////////
+ //
+ // Licensed to the Apache Software Foundation (ASF) under one or more
+ // contributor license agreements. See the NOTICE file distributed with
+ // this work for additional information regarding copyright ownership.
+ // The ASF licenses this file to You under the Apache License, Version 2.0
+ // (the "License"); you may not use this file except in compliance with
+ // the License. You may obtain a copy of the License at
+ //
+ // http://www.apache.org/licenses/LICENSE-2.0
+ //
+ // Unless required by applicable law or agreed to in writing, software
+ // distributed under the License is distributed on an "AS IS" BASIS,
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ // See the License for the specific language governing permissions and
+ // limitations under the License.
+ //
+ ////////////////////////////////////////////////////////////////////////////////
+ @author Bogdan Dinu (http://www.badu.ro)
+ -->
+ <fx:Metadata>
+ <![CDATA[
+ /**
+ * @copy spark.skins.spark.ApplicationSkin#hostComponent
+ */
+ [HostComponent("spark.components.List")]
+ ]]>
+ </fx:Metadata>
+
+ <s:states>
+ <s:State name="normal" />
+ <s:State name="disabled" />
+ </s:states>
+
+ <!-- border -->
+ <!--- @private -->
+ <s:Rect left="0" right="0" top="0" bottom="0" id="border">
+ <s:stroke>
+ <!--- @private -->
+ <s:SolidColorStroke id="borderStroke" weight="1"/>
+ </s:stroke>
+ </s:Rect>
+
+ <!-- fill -->
+ <!--- Defines the background appearance of the list-based component. -->
+ <s:Rect id="background" left="1" right="1" top="1" bottom="1" >
+ <s:fill>
+ <!--- Defines the color of the background. The default color is 0xFFFFFF. -->
+ <s:SolidColor id="bgFill" color="0xFFFFFF" />
+ </s:fill>
+ </s:Rect>
+
+ <s:DataGroup id="dataGroup" left="0" top="0" right="0" bottom="0"
+ itemRenderer="org.apache.flex.components.sparkMenu.skin.MenuItemRenderer">
+ <s:layout>
+ <!--- The default layout is vertical and measures at least for 5 rows.
+ When switching to a different layout, HorizontalLayout for example,
+ make sure to adjust the minWidth, minHeihgt sizes of the skin -->
+ <s:VerticalLayout gap="0" horizontalAlign="contentJustify" requestedMinRowCount="1" />
+ </s:layout>
+ </s:DataGroup>
+
+ <fx:Script fb:purpose="styling">
+ /* Define the skin elements that should not be colorized.
+ For list, the skin itself is colorized but the individual parts are not. */
+ static private const exclusions:Array = ["background"];
+
+ /**
+ * @private
+ */
+ override public function get colorizeExclusions():Array {return exclusions;}
+
+ /* Define the content fill items that should be colored by the "contentBackgroundColor" style. */
+ static private const contentFill:Array = ["bgFill"];
+
+ /**
+ * @private
+ */
+ override public function get contentItems():Array {return contentFill};
+
+ /**
+ * @private
+ */
+ override protected function initializationComplete():void
+ {
+ useChromeColor = true;
+ super.initializationComplete();
+ }
+ /**
+ * @langversion 3.0
+ * @playerversion Flash 10.1
+ * @playerversion AIR 2.5
+ * @productversion Flex 4.5
+ */
+ override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void
+ {
+ if (getStyle("borderVisible") == true)
+ {
+ border.visible = true;
+ background.left = background.top = background.right = background.bottom = 1;
+ dataGroup.left = dataGroup.top = dataGroup.right = dataGroup.bottom = 1;
+ }
+ else
+ {
+ border.visible = false;
+ background.left = background.top = background.right = background.bottom = 0;
+ dataGroup.left = dataGroup.top = dataGroup.right = dataGroup.bottom = 0;
+ }
+
+ borderStroke.color = getStyle("borderColor");
+ borderStroke.alpha = getStyle("borderAlpha");
+
+ super.updateDisplayList(unscaledWidth, unscaledHeight);
+ }
+ </fx:Script>
+</s:SparkSkin>
Added: incubator/flex/sdk/branches/develop/frameworks/projects/experimental/src/org/apache/flex/components/sparkProgressBar/ProgressBar.as
URL: http://svn.apache.org/viewvc/incubator/flex/sdk/branches/develop/frameworks/projects/experimental/src/org/apache/flex/components/sparkProgressBar/ProgressBar.as?rev=1422462&view=auto
==============================================================================
--- incubator/flex/sdk/branches/develop/frameworks/projects/experimental/src/org/apache/flex/components/sparkProgressBar/ProgressBar.as (added)
+++ incubator/flex/sdk/branches/develop/frameworks/projects/experimental/src/org/apache/flex/components/sparkProgressBar/ProgressBar.as Sun Dec 16 04:38:49 2012
@@ -0,0 +1,281 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// Licensed to the Apache Software Foundation (ASF) under one or more
+// contributor license agreements. See the NOTICE file distributed with
+// this work for additional information regarding copyright ownership.
+// The ASF licenses this file to You under the Apache License, Version 2.0
+// (the "License"); you may not use this file except in compliance with
+// the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.components.sparkProgressBar
+{
+ import flash.utils.getQualifiedClassName;
+
+ import mx.core.IFlexModuleFactory;
+ import mx.core.IVisualElement;
+ import mx.events.PropertyChangeEvent;
+ import mx.styles.CSSStyleDeclaration;
+ import mx.styles.IStyleManager2;
+ import mx.styles.StyleManager;
+
+ import spark.components.supportClasses.SkinnableComponent;
+ import spark.core.IDisplayText;
+
+ import org.apache.flex.components.sparkProgressBar.skin.ProgressBarSkin;
+
+ /**
+ * Plain and simple progress bar
+ *
+ * @author Bogdan Dinu (http://www.badu.ro)
+ */
+ public class ProgressBar extends SkinnableComponent
+ {
+ [SkinPart(required="false")]
+ public var progressGroup:IVisualElement;
+
+ [SkinPart(required="false")]
+ public var percentDisplay:IDisplayText;
+
+ public function ProgressBar()
+ {
+ super();
+ }
+ /**
+ *
+ **/
+ [Inspectable(enumeration="left,right", defaultValue="right")]
+ protected var _direction : String;
+ public function get direction():String
+ {
+ return _direction;
+ }
+ [Bindable(event="propertyChange")]
+ public function set direction(value:String):void
+ {
+ if (_direction !== value)
+ {
+ var oldValue : String = _direction;
+ _direction = value;
+ if (hasEventListener("propertyChange"))
+ {
+ dispatchEvent(PropertyChangeEvent.createUpdateEvent(this, "direction", oldValue, value));
+ }
+ }
+ }
+ /**
+ * totalProgress
+ **/
+ private var _totalProgressUpdated:Boolean = false;
+ protected var _totalProgress : Number;
+ public function get totalProgress():Number
+ {
+ return _totalProgress;
+ }
+ [Bindable(event="propertyChange")]
+ public function set totalProgress(value:Number):void
+ {
+ if (_totalProgress !== value)
+ {
+ var oldValue : Number = _totalProgress;
+ _totalProgress = value;
+ if (hasEventListener("propertyChange"))
+ {
+ dispatchEvent(PropertyChangeEvent.createUpdateEvent(this, "totalProgress", oldValue, value));
+ }
+ _totalProgressUpdated = true;
+ invalidateProperties();
+ }
+ }
+ /**
+ * currentProgress property
+ **/
+ private var _currentProgressUpdated : Boolean;
+ protected var _currentProgress : Number;
+ public function get currentProgress():Number
+ {
+ return _currentProgress;
+ }
+ [Bindable(event="propertyChange")]
+ public function set currentProgress(value:Number):void
+ {
+ if (_currentProgress !== value)
+ {
+ var oldValue : Number = _currentProgress;
+ _currentProgress = value;
+ if (hasEventListener("propertyChange"))
+ {
+ dispatchEvent(PropertyChangeEvent.createUpdateEvent(this, "currentProgress", oldValue, value));
+ }
+ _currentProgressUpdated = true;
+ invalidateProperties();
+ }
+ }
+ /**
+ * if you don't want percents, set this to false
+ **/
+ protected var _displayPercents : Boolean = true;
+ public function get displayPercents():Boolean
+ {
+ return _displayPercents;
+ }
+ [Bindable(event="propertyChange")]
+ public function set displayPercents(value:Boolean):void
+ {
+ if (_displayPercents !== value)
+ {
+ var oldValue : Boolean = _displayPercents;
+ _displayPercents = value;
+ if (hasEventListener("propertyChange"))
+ {
+ dispatchEvent(PropertyChangeEvent.createUpdateEvent(this, "displayPercents", oldValue, value));
+ }
+ }
+ }
+ /**
+ * Suffix that is added, in case you don't use percents
+ * Example : "bytes" , will display "33 / 100000 bytes"
+ **/
+ protected var _suffix : String = "";
+ public function get suffix():String
+ {
+ return _suffix;
+ }
+ [Bindable(event="propertyChange")]
+ public function set suffix(value:String):void
+ {
+ if (_suffix !== value)
+ {
+ var oldValue : String = _suffix;
+ _suffix = value;
+ if (hasEventListener("propertyChange"))
+ {
+ dispatchEvent(PropertyChangeEvent.createUpdateEvent(this, "suffix", oldValue, value));
+ }
+ }
+ }
+ /**
+ * In case you want to use your own label function
+ * which will override any suffix or display percents properties
+ **/
+ protected var _labelFunction : Function;
+ public function get labelFunction():Function
+ {
+ return _labelFunction;
+ }
+ [Bindable(event="propertyChange")]
+ public function set labelFunction(value:Function):void
+ {
+ if (_labelFunction !== value)
+ {
+ var oldValue : Function = _labelFunction;
+ _labelFunction = value;
+ if (hasEventListener("propertyChange"))
+ {
+ dispatchEvent(PropertyChangeEvent.createUpdateEvent(this, "labelFunction", oldValue, value));
+ }
+ }
+ }
+ /**
+ //--------------------------------------------------------------------------
+ // Methods
+ //--------------------------------------------------------------------------
+ **/
+ protected function updateProgressBox():void
+ {
+ if (progressGroup)
+ {
+ progressGroup.percentWidth = (_currentProgress / _totalProgress) * 100;
+ }
+
+ if (_labelFunction != null)
+ {
+ _labelFunction();
+ }
+ else
+ {
+ if (percentDisplay)
+ {
+ if (_displayPercents)
+ {
+ percentDisplay.text = Math.floor((_currentProgress / _totalProgress) * 100).toString() + "%";
+ }
+ else
+ {
+ percentDisplay.text = _currentProgress.toFixed(0) +" / "+ _totalProgress.toFixed(0) + _suffix;
+ }
+ }
+ }
+ }
+ /**
+ //--------------------------------------------------------------------------
+ // Overriden methods
+ //--------------------------------------------------------------------------
+ */
+ override protected function commitProperties():void
+ {
+ super.commitProperties();
+ if (_currentProgressUpdated || _totalProgressUpdated)
+ {
+ updateProgressBox();
+ _currentProgressUpdated = false;
+ _totalProgressUpdated = false;
+ }
+ }
+
+ override protected function partAdded(partName:String, instance:Object) : void
+ {
+ super.partAdded(partName, instance);
+ if (instance == progressGroup || instance == percentDisplay)
+ {
+ updateProgressBox();
+ }
+ }
+
+ override protected function partRemoved(partName:String, instance:Object) : void
+ {
+ super.partRemoved(partName, instance);
+ }
+
+ //--------------------------------------------------------------------------
+ // Factory and default skin
+ //--------------------------------------------------------------------------
+
+ protected static var defaultStylesSet:Boolean;
+
+ override public function set moduleFactory(factory:IFlexModuleFactory):void
+ {
+ super.moduleFactory = factory;
+ prototype.constructor.setDefaultStyles( factory );
+ }
+
+ protected static function setDefaultStyles(factory:IFlexModuleFactory):void
+ {
+ if( defaultStylesSet ) return;
+ defaultStylesSet = true;
+ var defaultStyleName:String = getQualifiedClassName( prototype.constructor ).replace( /::/, "." );
+ var styleManager:IStyleManager2 = StyleManager.getStyleManager( factory );
+ var style:CSSStyleDeclaration = styleManager.getStyleDeclaration( defaultStyleName );
+ if( !style )
+ {
+ style = new CSSStyleDeclaration();
+ styleManager.setStyleDeclaration( defaultStyleName, style, true );
+ }
+ if( style.defaultFactory == null )
+ {
+ style.defaultFactory = function():void
+ {
+ this.skinClass = org.apache.flex.components.sparkProgressBar.skin.ProgressBarSkin;
+ };
+ }
+ }
+ }
+}
\ No newline at end of file
Added: incubator/flex/sdk/branches/develop/frameworks/projects/experimental/src/org/apache/flex/components/sparkProgressBar/skin/ProgressBarSkin.mxml
URL: http://svn.apache.org/viewvc/incubator/flex/sdk/branches/develop/frameworks/projects/experimental/src/org/apache/flex/components/sparkProgressBar/skin/ProgressBarSkin.mxml?rev=1422462&view=auto
==============================================================================
--- incubator/flex/sdk/branches/develop/frameworks/projects/experimental/src/org/apache/flex/components/sparkProgressBar/skin/ProgressBarSkin.mxml (added)
+++ incubator/flex/sdk/branches/develop/frameworks/projects/experimental/src/org/apache/flex/components/sparkProgressBar/skin/ProgressBarSkin.mxml Sun Dec 16 04:38:49 2012
@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="utf-8"?>
+<s:Skin xmlns:fx="http://ns.adobe.com/mxml/2009"
+ xmlns:s="library://ns.adobe.com/flex/spark">
+ <!--
+ ////////////////////////////////////////////////////////////////////////////////
+ //
+ // Licensed to the Apache Software Foundation (ASF) under one or more
+ // contributor license agreements. See the NOTICE file distributed with
+ // this work for additional information regarding copyright ownership.
+ // The ASF licenses this file to You under the Apache License, Version 2.0
+ // (the "License"); you may not use this file except in compliance with
+ // the License. You may obtain a copy of the License at
+ //
+ // http://www.apache.org/licenses/LICENSE-2.0
+ //
+ // Unless required by applicable law or agreed to in writing, software
+ // distributed under the License is distributed on an "AS IS" BASIS,
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ // See the License for the specific language governing permissions and
+ // limitations under the License.
+ //
+ ////////////////////////////////////////////////////////////////////////////////
+ @author Bogdan Dinu (http://www.badu.ro)
+ -->
+ <fx:Metadata>
+ [HostComponent("org.apache.flex.components.sparkProgressBar.ProgressBar")]
+ </fx:Metadata>
+
+ <s:BorderContainer
+ borderColor="#000000"
+ height="20"
+ top="0" left="0" right="0">
+ <s:Group id="progressGroup" top="0" bottom="0"
+ left="{hostComponent.direction=='left' ? 0 : NaN}"
+ right="{hostComponent.direction=='right' ? 0 : NaN}">
+ <s:Rect left="0" top="0" bottom="0" right="0">
+ <s:fill>
+ <s:SolidColor color="#FF0000" />
+ </s:fill>
+ </s:Rect>
+ <!--
+ Variant #2 (looks nicer) - uncomment this and remove last Label declaration
+ <s:Label id="percentDisplay"
+ right="2" verticalCenter="0" verticalAlign="middle"
+ visible="{progressBox.width > percentDisplay.width + 4}"
+ includeInLayout="{progressBox.width > percentDisplay.width + 4}"/>
+ -->
+ </s:Group>
+ <s:Label id="percentDisplay"
+ left="2" right="2" verticalCenter="0" verticalAlign="middle" textAlign="center" />
+ </s:BorderContainer>
+</s:Skin>