incubator-flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t...@apache.org
Subject svn commit: r1303614 - in /incubator/flex/whiteboard/quetwo/MobileAlert/src/org/apache/spark: components/Alert.as skins/ skins/AlertSkin.mxml
Date Wed, 21 Mar 2012 23:05:28 GMT
Author: tink
Date: Wed Mar 21 23:05:28 2012
New Revision: 1303614

URL: http://svn.apache.org/viewvc?rev=1303614&view=rev
Log:
Initial import of how I would approach a Spark Alert component. Skinning is still very rough.

Added:
    incubator/flex/whiteboard/quetwo/MobileAlert/src/org/apache/spark/components/Alert.as
    incubator/flex/whiteboard/quetwo/MobileAlert/src/org/apache/spark/skins/
    incubator/flex/whiteboard/quetwo/MobileAlert/src/org/apache/spark/skins/AlertSkin.mxml

Added: incubator/flex/whiteboard/quetwo/MobileAlert/src/org/apache/spark/components/Alert.as
URL: http://svn.apache.org/viewvc/incubator/flex/whiteboard/quetwo/MobileAlert/src/org/apache/spark/components/Alert.as?rev=1303614&view=auto
==============================================================================
--- incubator/flex/whiteboard/quetwo/MobileAlert/src/org/apache/spark/components/Alert.as
(added)
+++ incubator/flex/whiteboard/quetwo/MobileAlert/src/org/apache/spark/components/Alert.as
Wed Mar 21 23:05:28 2012
@@ -0,0 +1,281 @@
+package org.apache.spark.components
+{
+	import flash.display.DisplayObjectContainer;
+	
+	import mx.collections.ArrayList;
+	
+	import org.apache.spark.components.supportClasses.SkinnablePopUpComponent;
+	
+	import spark.components.ButtonBar;
+	import spark.core.IDisplayText;
+	import spark.events.IndexChangeEvent;
+	import spark.primitives.BitmapImage;
+
+	public class Alert extends SkinnablePopUpComponent
+	{
+		
+		
+		//--------------------------------------------------------------------------
+		//
+		//  Constructor
+		//
+		//--------------------------------------------------------------------------
+		
+		/**
+		 *  Constructor.
+		 *
+		 *  @langversion 3.0
+		 *  @playerversion Flash 10
+		 *  @playerversion AIR 2.5
+		 *  @productversion Flex 4.5
+		 */
+		public function Alert()
+		{
+			super();
+		}
+		
+		
+		//--------------------------------------------------------------------------
+		//
+		//  Skin Parts
+		//
+		//--------------------------------------------------------------------------
+		
+		[SkinPart(required="false")]
+		public var titleDisplay:IDisplayText;
+		
+		[SkinPart(required="false")]
+		public var messageDisplay:IDisplayText;
+		
+		[SkinPart(required="false")]
+		public var iconDisplay:BitmapImage;
+		
+		[SkinPart(required="true")]
+		public var buttonBar:ButtonBar;
+		
+		
+		
+		//--------------------------------------------------------------------------
+		//
+		//  Properties
+		//
+		//--------------------------------------------------------------------------
+		
+		//----------------------------------
+		//  title
+		//----------------------------------
+		
+		/**
+		 *  @private
+		 */
+		private var _title:String;
+		
+		/**
+		 *  Text string that appears in the title bar.
+		 *  This text is in the title area of the alert dialog box.
+		 * 
+		 *  @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( _title == value ) return;
+			
+			_title = value;
+			if( titleDisplay ) titleDisplay.text = title;
+		}
+		
+		
+		//----------------------------------
+		//  message
+		//----------------------------------
+		
+		/**
+		 *  @private
+		 */
+		private var _message:String;
+		
+		/**
+		 *  Text string that appears in the MobileAlert control.
+		 *  This text is the main text within the alert dialog box.
+		 * 
+		 *  @langversion 3.0
+		 *  @playerversion Flash 10
+		 *  @playerversion AIR 2.5
+		 *  @productversion Flex 4.5
+		 */
+		public function get message():String
+		{
+			return _message;
+		}
+		/**
+		 *  @private
+		 */
+		public function set message( value:String ):void
+		{
+			if( _message == value ) return;
+			
+			_message = value;
+			if( messageDisplay ) messageDisplay.text = message;
+		}
+		
+		
+		//----------------------------------
+		//  icon
+		//----------------------------------
+		
+		/**
+		 *  @private
+		 */
+		private var _icon:Object;
+		
+		/**
+		 *  @copy spark.primitives.BitmapImage#source
+		 * 
+		 *  @langversion 3.0
+		 *  @playerversion Flash 10
+		 *  @playerversion AIR 2.5
+		 *  @productversion Flex 4.5
+		 */
+		public function get icon():Object
+		{
+			return _icon;
+		}
+		/**
+		 *  @private
+		 */
+		public function set icon( value:Object ):void
+		{
+			if( _icon == value ) return;
+			
+			_icon = value;
+			if( iconDisplay ) iconDisplay.source = icon;
+		}
+		
+		
+		//----------------------------------
+		//  buttonLabels
+		//----------------------------------
+		
+		/**
+		 *  @private
+		 */
+		private var _buttonLabels:Array;
+		
+		/**
+		 *  Text string that appears in the MobileAlert control.
+		 *  This text is the main text within the alert dialog box.
+		 * 
+		 *  @langversion 3.0
+		 *  @playerversion Flash 10
+		 *  @playerversion AIR 2.5
+		 *  @productversion Flex 4.5
+		 */
+		public function get buttonLabels():Array
+		{
+			return _buttonLabels;
+		}
+		/**
+		 *  @private
+		 */
+		public function set buttonLabels( value:Array ):void
+		{
+			if( _buttonLabels == value ) return;
+			
+			_buttonLabels = value;
+			if( buttonBar ) buttonBar.dataProvider = new ArrayList( buttonLabels );
+		}
+		
+		
+		
+		//--------------------------------------------------------------------------
+		//
+		//  Methods
+		//
+		//--------------------------------------------------------------------------
+		
+		/**
+		 *  @inheritDoc
+		 */
+		override public function open( owner:DisplayObjectContainer, modal:Boolean = true ):void
+		{
+			super.open( owner, modal );
+		}
+		
+		/**
+		 *  @private
+		 */
+		override protected function partAdded( partName:String, instance:Object ):void
+		{
+			super.partAdded( partName, instance );
+			
+			switch( instance )
+			{
+				case titleDisplay :
+				{
+					titleDisplay.text = title;
+					break;
+				}
+				case messageDisplay :
+				{
+					messageDisplay.text = message;
+					break;
+				}
+				case iconDisplay :
+				{
+					iconDisplay.source = icon;
+					break;
+				}
+				case buttonBar :
+				{
+					buttonBar.addEventListener( IndexChangeEvent.CHANGE, buttonBar_changeHandler, false,
0, true );
+					buttonBar.dataProvider = new ArrayList( _buttonLabels );
+					break;
+				}
+			}
+		}
+		
+		/**
+		 *  @private
+		 */
+		override protected function partRemoved( partName:String, instance:Object ):void
+		{
+			super.partRemoved( partName, instance );
+			
+			switch( instance )
+			{
+				case buttonBar :
+				{
+					buttonBar.removeEventListener( IndexChangeEvent.CHANGE, buttonBar_changeHandler, false
);
+					break;
+				}
+			}
+		}
+		
+		
+		
+		//--------------------------------------------------------------------------
+		//
+		//  Event Handlers
+		//
+		//--------------------------------------------------------------------------
+		
+		/**
+		 *  @private
+		 */
+		private function buttonBar_changeHandler( event:IndexChangeEvent ):void
+		{
+			close( true, buttonBar.selectedItem );
+		}
+		
+	}
+}
\ No newline at end of file

Added: incubator/flex/whiteboard/quetwo/MobileAlert/src/org/apache/spark/skins/AlertSkin.mxml
URL: http://svn.apache.org/viewvc/incubator/flex/whiteboard/quetwo/MobileAlert/src/org/apache/spark/skins/AlertSkin.mxml?rev=1303614&view=auto
==============================================================================
--- incubator/flex/whiteboard/quetwo/MobileAlert/src/org/apache/spark/skins/AlertSkin.mxml
(added)
+++ incubator/flex/whiteboard/quetwo/MobileAlert/src/org/apache/spark/skins/AlertSkin.mxml
Wed Mar 21 23:05:28 2012
@@ -0,0 +1,115 @@
+<?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" 
+		xmlns:mx="library://ns.adobe.com/flex/mx">
+	
+	<!-- host component -->
+	<fx:Metadata>
+		/** 
+		*  @copy spark.skins.spark.ApplicationSkin#hostComponent
+		*/
+		[HostComponent("org.apache.spark.components.Alert")]
+	</fx:Metadata>
+	
+	<!-- states -->
+	<s:states>
+		<s:State name="normal"/>
+		<s:State name="closed" />
+	</s:states>
+	
+	<!-- Transitions for open and close -->
+	<s:transitions>
+		<s:Transition fromState="closed" toState="normal" autoReverse="true">
+			<s:Fade duration="150" target="{this}"/>
+		</s:Transition>
+
+		<s:Transition fromState="normal" toState="closed" autoReverse="true">
+			<s:Fade duration="150" target="{this}"/>
+		</s:Transition>
+	</s:transitions>
+	
+	
+	<!-- drop shadow can't be hittable so it stays sibling of other graphics -->
+	<!--- @private -->
+	<s:RectangularDropShadow id="dropShadow" blurX="20" blurY="20" alpha="0.32" distance="11"

+							 angle="90" color="#000000" left="0" top="0" right="0" bottom="0"/>
+	
+	<!-- drop shadow can't be hittable so all other graphics go in this group -->
+	<s:Group left="0" right="0" top="0" bottom="0">
+		
+		<!-- layer 1: border -->
+		<!--- @private -->
+		<s:Rect id="border" left="0" right="0" top="0" bottom="0" >
+			<s:stroke>
+				<!--- @private -->
+				<s:SolidColorStroke id="borderStroke" weight="1" />
+			</s:stroke>
+		</s:Rect>
+		
+		<!-- layer 2: background fill -->
+		<!--- Defines the appearance of the PanelSkin class's background. -->
+		<s:Rect id="background" left="1" top="1" right="1" bottom="1">
+			<s:fill>
+				<!--- @private
+				Defines the  PanelSkin class's background fill. The default color is 0xFFFFFF. -->
+				<s:SolidColor id="backgroundFill" color="#FFFFFF"/>
+			</s:fill>
+		</s:Rect>
+		
+		<s:Group left="1" right="1" top="1" bottom="1" maxWidth="200">
+			<s:layout>
+				<s:VerticalLayout gap="0" horizontalAlign="justify" />
+			</s:layout>
+			
+			<!--- @private -->
+			<s:Group id="topGroup" width="100%">
+				
+				<!-- layer 0: title bar fill -->
+				<!--- @private -->
+				<s:Rect id="tbFill" left="0" right="0" top="0" bottom="1">
+					<s:fill>
+						<s:LinearGradient rotation="90">
+							<s:GradientEntry color="0xE2E2E2" />
+							<s:GradientEntry color="0xD9D9D9" />
+						</s:LinearGradient>
+					</s:fill>
+				</s:Rect>
+				
+				<!-- layer 1: title bar highlight -->
+				<!--- @private -->
+				<s:Rect id="tbHilite" left="0" right="0" top="0" bottom="0">
+					<s:stroke>
+						<s:LinearGradientStroke rotation="90" weight="1">
+							<s:GradientEntry color="0xEAEAEA" />
+							<s:GradientEntry color="0xD9D9D9" />
+						</s:LinearGradientStroke>
+					</s:stroke>
+				</s:Rect>
+				
+				<!-- layer 2: title bar divider -->
+				<!--- @private -->
+				<s:Rect id="tbDiv" left="0" right="0" height="1" bottom="0">
+					<s:fill>
+						<s:SolidColor color="0xC0C0C0" />
+					</s:fill>
+				</s:Rect>
+				
+				<!-- layer 3: text -->
+				<!--- @copy spark.components.Panel#titleDisplay -->
+				<s:Label id="titleDisplay" maxDisplayedLines="1"
+						 left="9" right="3" top="1" bottom="0" minHeight="30"
+						 verticalAlign="middle" textAlign="start" fontWeight="bold">
+				</s:Label>
+			</s:Group>
+		
+			<!--- @copy spark.components.Panel#messageDisplay -->
+			<s:Label id="messageDisplay" left="9" right="3" maxDisplayedLines="-1"/>
+				
+			<!--- @copy spark.components.Panel#buttonBar -->
+			<s:ButtonBar id="buttonBar" left="9" right="3" />
+			
+			
+		</s:Group>
+	</s:Group>
+	
+</s:Skin>



Mime
View raw message