You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by ti...@apache.org on 2012/01/13 00:15:19 UTC
svn commit: r1230830 [3/4] - in /incubator/flex/whiteboard/tink/iview: ./
examples/ examples/libs/ examples/src/ src/ src/org/ src/org/apache/
src/org/apache/spark/ src/org/apache/spark/components/
src/org/apache/spark/components/supportClasses/ src/or...
Added: incubator/flex/whiteboard/tink/iview/src/org/apache/spark/components/ViewSkinnableComponent.as
URL: http://svn.apache.org/viewvc/incubator/flex/whiteboard/tink/iview/src/org/apache/spark/components/ViewSkinnableComponent.as?rev=1230830&view=auto
==============================================================================
--- incubator/flex/whiteboard/tink/iview/src/org/apache/spark/components/ViewSkinnableComponent.as (added)
+++ incubator/flex/whiteboard/tink/iview/src/org/apache/spark/components/ViewSkinnableComponent.as Thu Jan 12 23:15:17 2012
@@ -0,0 +1,678 @@
+package org.apache.spark.components
+{
+ import flash.events.Event;
+
+ import mx.core.FlexGlobals;
+ import mx.core.IDataRenderer;
+ import mx.core.mx_internal;
+ import mx.events.FlexEvent;
+ import mx.events.PropertyChangeEvent;
+
+ import spark.components.Group;
+ import spark.components.supportClasses.SkinnableComponent;
+ import spark.core.ContainerDestructionPolicy;
+ import spark.events.ViewNavigatorEvent;
+ import spark.layouts.supportClasses.LayoutBase;
+
+ use namespace mx_internal;
+
+ public class ViewSkinnableComponent extends SkinnableComponent implements IView, IDataRenderer
+ {
+ public function ViewSkinnableComponent()
+ {
+ super();
+ }
+
+ //----------------------------------
+ // navigator
+ //----------------------------------
+
+ private var _navigator:ViewNavigator = null;
+
+ /**
+ * The view navigator that this view resides in.
+ *
+ * @langversion 3.0
+ * @playerversion AIR 2.5
+ * @productversion Flex 4.5
+ */
+
+ [Bindable("navigatorChanged")]
+ public function get navigator():ViewNavigator
+ {
+ return _navigator;
+ }
+
+ //----------------------------------
+ // destructionPolicy
+ //----------------------------------
+
+ private var _destructionPolicy:String = ContainerDestructionPolicy.AUTO;
+
+ [Inspectable(category="General", enumeration="auto,never", defaultValue="auto")]
+ /**
+ * Defines the destruction policy the view's navigator should use
+ * when this view is removed. If set to "auto", the navigator will
+ * destroy the view when it isn't active. If set to "never", the
+ * view will be cached in memory.
+ *
+ * @default auto
+ *
+ * @langversion 3.0
+ * @playerversion AIR 2.5
+ * @productversion Flex 4.5
+ */
+ public function get destructionPolicy():String
+ {
+ return _destructionPolicy;
+ }
+
+ /**
+ * @private
+ */
+ public function set destructionPolicy(value:String):void
+ {
+ _destructionPolicy = value;
+ }
+
+ //----------------------------------
+ // tabBarVisible
+ //----------------------------------
+ private var _tabBarVisible:Boolean = true;
+
+ [Inspectable(category="General", defaultValue="true")]
+ /**
+ * Specifies whether a view should show the tab bar or not.
+ * This property does not necessarily correlate to the
+ * <code>visible</code> property of the navigator's TabBar control.
+ *
+ * @default true
+ *
+ * @langversion 3.0
+ * @playerversion AIR 2.5
+ * @productversion Flex 4.5
+ */
+ public function get tabBarVisible():Boolean
+ {
+ return _tabBarVisible;
+ }
+
+ /**
+ * @private
+ */
+ public function set tabBarVisible(value:Boolean):void
+ {
+ var oldValue:Boolean = _tabBarVisible;
+ _tabBarVisible = value;
+
+ // Immediately request actionBar's visibility be toggled
+ if (isActive && navigator)
+ {
+ if (hasEventListener(PropertyChangeEvent.PROPERTY_CHANGE))
+ {
+ var changeEvent:PropertyChangeEvent =
+ PropertyChangeEvent.createUpdateEvent(this, "tabBarVisible", oldValue, value);
+
+ dispatchEvent(changeEvent);
+ }
+ }
+ }
+
+ //----------------------------------
+ // actionBarVisible
+ //----------------------------------
+ private var _actionBarVisible:Boolean = true;
+
+ [Inspectable(category="General", defaultValue="true")]
+ /**
+ * Specifies whether a view should show the action bar or not.
+ * This property does not necessarily correlate to the
+ * <code>visible</code> property of the view navigator's ActionBar control.
+ *
+ * @default true
+ *
+ * @langversion 3.0
+ * @playerversion AIR 2.5
+ * @productversion Flex 4.5
+ */
+ public function get actionBarVisible():Boolean
+ {
+ return _actionBarVisible;
+ }
+
+ /**
+ * @private
+ */
+ public function set actionBarVisible(value:Boolean):void
+ {
+ _actionBarVisible = value;
+
+ // Immediately request actionBar's visibility be toggled
+ if (isActive && navigator)
+ {
+ if (_actionBarVisible)
+ navigator.showActionBar();
+ else
+ navigator.hideActionBar();
+ }
+ }
+
+ //----------------------------------
+ // overlayControls
+ //----------------------------------
+
+ private var _overlayControls:Boolean = false;
+
+ [Inspectable(category="General", defaultValue="false")]
+ /**
+ * By default, the TabBar and ActionBar controls of a
+ * mobile application define an area that cannot be used
+ * by the views of an application.
+ * That means your content cannot use the full screen size
+ * of the mobile device.
+ * If you set this property to <code>true</code>, the content area
+ * of the application spans the entire width and height of the screen.
+ * The ActionBar and TabBar controls hover over the content area with
+ * an <code>alpha</code> value of 0.5 so that they are partially transparent.
+ *
+ * @default false
+ *
+ * @langversion 3.0
+ * @playerversion AIR 2.5
+ * @productversion Flex 4.5
+ */
+ public function get overlayControls():Boolean
+ {
+ return _overlayControls;
+ }
+
+ /**
+ * @private
+ */
+ public function set overlayControls(value:Boolean):void
+ {
+ if (_overlayControls != value)
+ {
+ var oldValue:Boolean = _overlayControls;
+ _overlayControls = value;
+
+ if (hasEventListener(PropertyChangeEvent.PROPERTY_CHANGE))
+ {
+ var changeEvent:PropertyChangeEvent =
+ PropertyChangeEvent.createUpdateEvent(this, "overlayControls", oldValue, _overlayControls);
+
+ dispatchEvent(changeEvent);
+ }
+ }
+ }
+
+ //----------------------------------
+ // actionContent
+ //----------------------------------
+
+ private var _actionContent:Array;
+
+ [ArrayElementType("mx.core.IVisualElement")]
+ /**
+ * This property overrides the <code>actionContent</code>
+ * property in the ActionBar, ViewNavigator, and
+ * ViewNavigatorApplication components.
+ *
+ * @copy ActionBar#actionContent
+ *
+ * @default null
+ *
+ * @see ActionBar#actionContent
+ * @see spark.skins.mobile.ActionBarSkin
+ *
+ * @langversion 3.0
+ * @playerversion AIR 2.5
+ * @productversion Flex 4.5
+ */
+ public function get actionContent():Array
+ {
+ return _actionContent;
+ }
+ /**
+ * @private
+ */
+ public function set actionContent(value:Array):void
+ {
+ var oldValue:Array = _actionContent;
+ _actionContent = value;
+
+ if (hasEventListener(PropertyChangeEvent.PROPERTY_CHANGE))
+ {
+ var changeEvent:PropertyChangeEvent =
+ PropertyChangeEvent.createUpdateEvent(this, "actionContent", oldValue, _actionContent);
+
+ dispatchEvent(changeEvent);
+ }
+ }
+
+ //----------------------------------
+ // actionLayout
+ //----------------------------------
+
+ private var _actionLayout:LayoutBase;
+
+ /**
+ * @copy ActionBar#actionLayout
+ *
+ * @default null
+ *
+ * @langversion 3.0
+ * @playerversion AIR 2.5
+ * @productversion Flex 4.5
+ */
+ public function get actionLayout():LayoutBase
+ {
+ return _actionLayout;
+ }
+ /**
+ * @private
+ */
+ public function set actionLayout(value:LayoutBase):void
+ {
+ var oldValue:LayoutBase = value;
+ _actionLayout = value;
+
+ if (hasEventListener(PropertyChangeEvent.PROPERTY_CHANGE))
+ {
+ var changeEvent:PropertyChangeEvent =
+ PropertyChangeEvent.createUpdateEvent(this, "actionLayout", oldValue, _actionLayout);
+
+ dispatchEvent(changeEvent);
+ }
+ }
+
+ //----------------------------------
+ // navigationContent
+ //----------------------------------
+
+ private var _navigationContent:Array;
+
+ [ArrayElementType("mx.core.IVisualElement")]
+ /**
+ * This property overrides the <code>navigationContent</code>
+ * property in the ActionBar, ViewNavigator, and
+ * ViewNavigatorApplication components.
+ *
+ * @copy ActionBar#navigationContent
+ *
+ * @default null
+ *
+ * @see ActionBar#navigationContent
+ * @see spark.skins.mobile.ActionBarSkin
+ *
+ * @langversion 3.0
+ * @playerversion AIR 2.5
+ * @productversion Flex 4.5
+ */
+ public function get navigationContent():Array
+ {
+ return _navigationContent;
+ }
+ /**
+ * @private
+ */
+ public function set navigationContent(value:Array):void
+ {
+ var oldValue:Array = _navigationContent;
+ _navigationContent = value;
+
+ if (hasEventListener(PropertyChangeEvent.PROPERTY_CHANGE))
+ {
+ var changeEvent:PropertyChangeEvent =
+ PropertyChangeEvent.createUpdateEvent(this, "navigationContent", oldValue, _navigationContent);
+
+ dispatchEvent(changeEvent);
+ }
+ }
+
+ //----------------------------------
+ // navigationLayout
+ //----------------------------------
+
+ private var _navigationLayout:LayoutBase;
+
+ /**
+ * @copy ActionBar#navigationLayout
+ *
+ * @default null
+ *
+ * @langversion 3.0
+ * @playerversion AIR 2.5
+ * @productversion Flex 4.5
+ */
+ public function get navigationLayout():LayoutBase
+ {
+ return _navigationLayout;
+ }
+ /**
+ * @private
+ */
+ public function set navigationLayout(value:LayoutBase):void
+ {
+ var oldValue:LayoutBase = _navigationLayout;
+ _navigationLayout = value;
+
+ if (hasEventListener(PropertyChangeEvent.PROPERTY_CHANGE))
+ {
+ var changeEvent:PropertyChangeEvent =
+ PropertyChangeEvent.createUpdateEvent(this, "navigationLayout", _navigationLayout, value);
+
+ dispatchEvent(changeEvent);
+ }
+ }
+
+ //----------------------------------
+ // title
+ //----------------------------------
+
+ private var _title:String;
+
+ [Bindable]
+ /**
+ * This property overrides the <code>title</code>
+ * property in the ActionBar, ViewNavigator, and
+ * ViewNavigatorApplication components.
+ *
+ * @copy ActionBar#title
+ *
+ * @default ""
+ *
+ * @langversion 3.0
+ * @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)
+ {
+ var oldValue:String = _title;
+ _title = value;
+
+ if (hasEventListener(PropertyChangeEvent.PROPERTY_CHANGE))
+ {
+ var changeEvent:PropertyChangeEvent =
+ PropertyChangeEvent.createUpdateEvent(this, "title", oldValue, _title);
+
+ dispatchEvent(changeEvent);
+ }
+ }
+ }
+
+ //----------------------------------
+ // titleContent
+ //----------------------------------
+
+ private var _titleContent:Array;
+
+ [ArrayElementType("mx.core.IVisualElement")]
+ /**
+ * This property overrides the <code>titleContent</code>
+ * property in the ActionBar, ViewNavigator, and
+ * ViewNavigatorApplication components.
+ *
+ * @copy ActionBar#titleContent
+ *
+ * @default null
+ *
+ * @see ActionBar#titleContent
+ * @see spark.skins.mobile.ActionBarSkin
+ *
+ * @langversion 3.0
+ * @playerversion AIR 2.5
+ * @productversion Flex 4.5
+ */
+ public function get titleContent():Array
+ {
+ return _titleContent;
+ }
+ /**
+ * @private
+ */
+ public function set titleContent(value:Array):void
+ {
+ var oldValue:Array = _titleContent;
+ _titleContent = value;
+
+ if (hasEventListener(PropertyChangeEvent.PROPERTY_CHANGE))
+ {
+ var changeEvent:PropertyChangeEvent =
+ PropertyChangeEvent.createUpdateEvent(this, "titleContent", oldValue, _titleContent);
+
+ dispatchEvent(changeEvent);
+ }
+ }
+
+ //----------------------------------
+ // titleLayout
+ //----------------------------------
+
+ private var _titleLayout:LayoutBase;
+
+ /**
+ * @copy ActionBar#titleLayout
+ *
+ * @default null
+ *
+ * @langversion 3.0
+ * @playerversion AIR 2.5
+ * @productversion Flex 4.5
+ */
+ public function get titleLayout():LayoutBase
+ {
+ return _titleLayout;
+ }
+ /**
+ * @private
+ */
+ public function set titleLayout(value:LayoutBase):void
+ {
+ var oldValue:LayoutBase = _titleLayout;
+ _titleLayout = value;
+
+ if (hasEventListener(PropertyChangeEvent.PROPERTY_CHANGE))
+ {
+ var changeEvent:PropertyChangeEvent =
+ PropertyChangeEvent.createUpdateEvent(this, "titleLayout", oldValue, _titleLayout);
+
+ dispatchEvent(changeEvent);
+ }
+ }
+
+ public function backKeyHandledByView():Boolean
+ {
+ if (hasEventListener(FlexEvent.BACK_KEY_PRESSED))
+ {
+ var event:FlexEvent = new FlexEvent(FlexEvent.BACK_KEY_PRESSED, false, true);
+ var eventCanceled:Boolean = !dispatchEvent(event);
+
+ // If the event was canceled, that means the application
+ // is doing its own custom logic for the back key
+ return eventCanceled;
+ }
+
+ return false;
+ }
+
+ public function canRemove():Boolean
+ {
+ if (hasEventListener(ViewNavigatorEvent.REMOVING))
+ {
+ var event:ViewNavigatorEvent =
+ new ViewNavigatorEvent(ViewNavigatorEvent.REMOVING,
+ false, true, navigator.lastAction);
+
+ return dispatchEvent(event);
+ }
+
+ return true;
+ }
+
+// //----------------------------------
+// // actionBarVisible
+// //----------------------------------
+// private var _actionBarVisible:Boolean = true;
+//
+// [Inspectable(category="General", defaultValue="true")]
+// /**
+// * Specifies whether a view should show the action bar or not.
+// * This property does not necessarily correlate to the
+// * <code>visible</code> property of the view navigator's ActionBar control.
+// *
+// * @default true
+// *
+// * @langversion 3.0
+// * @playerversion AIR 2.5
+// * @productversion Flex 4.5
+// */
+// public function get actionBarVisible():Boolean
+// {
+// return _actionBarVisible;
+// }
+//
+// /**
+// * @private
+// */
+// public function set actionBarVisible(value:Boolean):void
+// {
+// _actionBarVisible = value;
+//
+// // Immediately request actionBar's visibility be toggled
+// if (isActive && navigator)
+// {
+// if (_actionBarVisible)
+// navigator.showActionBar();
+// else
+// navigator.hideActionBar();
+// }
+// }
+
+ public function setActionBarVisible(value:Boolean):void
+ {
+ _actionBarVisible = value;
+ }
+
+ private var _active:Boolean = false;
+
+ public function get isActive():Boolean
+ {
+ return _active;
+ }
+
+ public function setActive(value:Boolean):void
+ {
+ if (_active != value)
+ {
+ _active = value;
+
+ // Switch orientation states if needed
+ if (_active)
+ updateOrientationState();
+
+ var eventName:String = _active ?
+ ViewNavigatorEvent.VIEW_ACTIVATE :
+ ViewNavigatorEvent.VIEW_DEACTIVATE;
+
+ if (hasEventListener(eventName))
+ dispatchEvent(new ViewNavigatorEvent(eventName, false, false, navigator.lastAction));
+ }
+ }
+
+ /**
+ * @private
+ */
+ mx_internal function updateOrientationState():void
+ {
+ setCurrentState(getCurrentViewState(), false);
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public function deserializeData(value:Object):Object
+ {
+ return value;
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public function setNavigator(value:ViewNavigator):void
+ {
+ _navigator = value;
+
+ if (hasEventListener("navigatorChanged"))
+ dispatchEvent(new Event("navigatorChanged"));
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public function createReturnObject():Object
+ {
+ return null;
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public function serializeData():Object
+ {
+ return data;
+ }
+
+
+ /**
+ * @inheritDoc
+ */
+ public function getCurrentViewState():String
+ {
+ var aspectRatio:String = FlexGlobals.topLevelApplication.aspectRatio;
+
+ if (hasState(aspectRatio))
+ return aspectRatio;
+
+ // If the appropriate state for the orientation of the device
+ // isn't defined, return the current state
+ return currentState;
+ }
+
+ //----------------------------------
+ // data
+ //----------------------------------
+
+ private var _data:Object;
+
+ [Bindable("dataChange")]
+
+ /**
+ * @inheritDoc
+ */
+ public function get data():Object
+ {
+ return _data;
+ }
+
+ /**
+ * @private
+ */
+ public function set data(value:Object):void
+ {
+ _data = value;
+
+ if (hasEventListener(FlexEvent.DATA_CHANGE))
+ dispatchEvent(new FlexEvent(FlexEvent.DATA_CHANGE));
+ }
+ }
+}
\ No newline at end of file
Added: incubator/flex/whiteboard/tink/iview/src/org/apache/spark/components/ViewSkinnableContainer.as
URL: http://svn.apache.org/viewvc/incubator/flex/whiteboard/tink/iview/src/org/apache/spark/components/ViewSkinnableContainer.as?rev=1230830&view=auto
==============================================================================
--- incubator/flex/whiteboard/tink/iview/src/org/apache/spark/components/ViewSkinnableContainer.as (added)
+++ incubator/flex/whiteboard/tink/iview/src/org/apache/spark/components/ViewSkinnableContainer.as Thu Jan 12 23:15:17 2012
@@ -0,0 +1,1065 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// ADOBE SYSTEMS INCORPORATED
+// Copyright 2009 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 org.apache.spark.components
+{
+ import flash.events.Event;
+ import flash.events.StageOrientationEvent;
+
+ import mx.core.FlexGlobals;
+ import mx.core.IDataRenderer;
+ import mx.core.IVisualElement;
+ import mx.core.mx_internal;
+ import mx.events.FlexEvent;
+ import mx.events.PropertyChangeEvent;
+ import mx.events.ResizeEvent;
+
+ import spark.components.SkinnableContainer;
+ import spark.components.ViewMenuItem;
+ import spark.core.ContainerDestructionPolicy;
+ import spark.events.ViewNavigatorEvent;
+ import spark.layouts.supportClasses.LayoutBase;
+
+ use namespace mx_internal;
+
+ [Exclude(name="height", kind="property")]
+ [Exclude(name="minHeight", kind="property")]
+ [Exclude(name="maxHeight", kind="property")]
+ [Exclude(name="width", kind="property")]
+ [Exclude(name="minWidth", kind="property")]
+ [Exclude(name="maxWidth", kind="property")]
+ [Exclude(name="scaleX", kind="property")]
+ [Exclude(name="scaleY", kind="property")]
+ [Exclude(name="scaleZ", kind="property")]
+ [Exclude(name="z", kind="property")]
+
+ //--------------------------------------
+ // Events
+ //--------------------------------------
+
+ /**
+ * Dispatched when the back key is pressed when a view exists inside
+ * a mobile application.
+ *
+ * @langversion 3.0
+ * @playerversion AIR 2.5
+ * @productversion Flex 4.5
+ *
+ * @eventType mx.events.FlexEvent.BACK_KEY_PRESSED
+ *
+ */
+ [Event(name="backKeyPressed", type="mx.events.FlexEvent")]
+
+ /**
+ * Dispatched when the <code>data</code> property changes.
+ *
+ * @langversion 3.0
+ * @playerversion AIR 2.5
+ * @productversion Flex 4.5
+ *
+ * @eventType mx.events.FlexEvent.DATA_CHANGE
+ *
+ */
+ [Event(name="dataChange", type="mx.events.FlexEvent")]
+
+ /**
+ * Dispatched when the menu key is pressed when a view exists inside
+ * a mobile application.
+ *
+ * @langversion 3.0
+ * @playerversion AIR 2.5
+ * @productversion Flex 4.5
+ *
+ * @eventType mx.events.FlexEvent.MENU_KEY_PRESSED
+ *
+ */
+ [Event(name="menuKeyPressed", type="mx.events.FlexEvent")]
+
+ /**
+ * Dispatched when the current view has been activated.
+ *
+ * @eventType spark.events.ViewNavigatorEvent.VIEW_ACTIVATE
+ *
+ * @langversion 3.0
+ * @playerversion AIR 2.5
+ * @productversion Flex 4.5
+ */
+ [Event(name="viewActivate", type="spark.events.ViewNavigatorEvent")]
+
+ /**
+ * Dispatched when the current view has been deactivated.
+ *
+ * @eventType spark.events.ViewNavigatorEvent.VIEW_DEACTIVATE
+ *
+ * @langversion 3.0
+ * @playerversion AIR 2.5
+ * @productversion Flex 4.5
+ */
+ [Event(name="viewDeactivate", type="spark.events.ViewNavigatorEvent")]
+
+ /**
+ * Dispatched when the screen is about to be removed in response
+ * to a screen change.
+ * Calling <code>preventDefault()</code>
+ * while handling this event cancels the screen change.
+ *
+ * @eventType spark.events.ViewNavigatorEvent.REMOVING
+ *
+ * @langversion 3.0
+ * @playerversion AIR 2.5
+ * @productversion Flex 4.5
+ */
+ [Event(name="removing", type="spark.events.ViewNavigatorEvent")]
+
+ /**
+ * The View class is the base container class for all views used by view
+ * navigators.
+ * The View container extends the Group container and adds
+ * additional properties used to communicate with it's parent
+ * navigator.
+ *
+ * <p>In a mobile application, the content area of the application
+ * displays the individual screens, or views, that make up the application.
+ * Users navigate the views of the application by using the touch screen,
+ * components built into the application, and the input controls of the mobile device.</p>
+ *
+ * <p>The following image shows a View container with a List control:</p>
+ *
+ * <p>
+ * <img src="../../images/vn_single_section_home_vn.png" alt="View container" />
+ * </p>
+ *
+ * <p>Each view in an application corresponds to a View container defined
+ * in an ActionScript or MXML file.
+ * Each View contains a <code>data</code> property that specifies the data
+ * associated with that view.
+ * Views can use the <code>data</code> property to pass information to each
+ * other as the user navigates the application.</p>
+ *
+ * @mxml
+ *
+ * <p>The <code><s:View></code> tag inherits all of the tag
+ * attributes of its superclass and adds the following tag attributes:</p>
+ *
+ * <pre>
+ * <s:View
+ * <strong>Properties</strong>
+ * actionBarVisible="true"
+ * actionContent="null"
+ * actionLayout="null"
+ * data="null"
+ * destructionPolicy="auto"
+ * navigationContent="null"
+ * navigationLayout="null"
+ * overlayControls="false"
+ * tabBarVisible="true"
+ * title=""
+ * titleContent="null"
+ * titleLayout="null"
+ * viewMenuItems="null"
+ *
+ * <strong>Events</strong>
+ * backKeyPressed="<i>No default</i>"
+ * dataChange="<i>No default</i>"
+ * menuKeyPressed="<i>No default</i>"
+ * removing="<i>No default</i>"
+ * viewActivate="<i>No default</i>"
+ * viewDeactivate="<i>No default</i>"
+ *
+ * >
+ * </pre>
+ *
+ * @see ViewNavigator
+ *
+ * @includeExample examples/ViewExample.mxml -noswf
+ * @includeExample examples/ViewExampleHomeView.mxml -noswf
+ *
+ * @langversion 3.0
+ * @playerversion AIR 2.5
+ * @productversion Flex 4.5
+ */
+ public class ViewSkinnableContainer extends SkinnableContainer implements IDataRenderer, IView
+ {
+ //--------------------------------------------------------------------------
+ //
+ // Constructor
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * Constructor.
+ *
+ * @langversion 3.0
+ * @playerversion AIR 2.5
+ * @productversion Flex 4.5
+ */
+ public function ViewSkinnableContainer()
+ {
+ super();
+ }
+
+ //--------------------------------------------------------------------------
+ //
+ // Properties
+ //
+ //--------------------------------------------------------------------------
+
+ //----------------------------------
+ // active
+ //----------------------------------
+
+ private var _active:Boolean = false;
+
+ /**
+ * Indicates whether the current view is active.
+ * The view's navigator automatically sets this flag to <code>true</code>
+ * or <code>false</code> as its state changes.
+ * Setting this property can dispatch the <code>viewActivate</code> or
+ * <code>viewDeactivate</code> events.
+ *
+ * @default false
+ *
+ * @langversion 3.0
+ * @playerversion AIR 2.5
+ * @productversion Flex 4.5
+ */
+ public function get isActive():Boolean
+ {
+ return _active;
+ }
+
+ /**
+ * @private
+ */
+ public function setActive(value:Boolean):void
+ {
+ if (_active != value)
+ {
+ _active = value;
+
+ // Switch orientation states if needed
+ if (_active)
+ updateOrientationState();
+
+ var eventName:String = _active ?
+ ViewNavigatorEvent.VIEW_ACTIVATE :
+ ViewNavigatorEvent.VIEW_DEACTIVATE;
+
+ if (hasEventListener(eventName))
+ dispatchEvent(new ViewNavigatorEvent(eventName, false, false, navigator.lastAction));
+ }
+ }
+
+ //----------------------------------
+ // canRemove
+ //----------------------------------
+
+ /**
+ * @private
+ * Determines if the current view can be removed by a navigator. The default
+ * implementation dispatches a <code>FlexEvent.REMOVING</code> event. If
+ * preventDefault() is called on the event, this property will return false.
+ *
+ * @return Returns true if the view can be removed
+ *
+ * @langversion 3.0
+ * @playerversion AIR 2.5
+ * @productversion Flex 4.5
+ */
+ public function canRemove():Boolean
+ {
+ if (hasEventListener(ViewNavigatorEvent.REMOVING))
+ {
+ var event:ViewNavigatorEvent =
+ new ViewNavigatorEvent(ViewNavigatorEvent.REMOVING,
+ false, true, navigator.lastAction);
+
+ return dispatchEvent(event);
+ }
+
+ return true;
+ }
+
+ /**
+ * @private
+ */
+ public function backKeyHandledByView():Boolean
+ {
+ if (hasEventListener(FlexEvent.BACK_KEY_PRESSED))
+ {
+ var event:FlexEvent = new FlexEvent(FlexEvent.BACK_KEY_PRESSED, false, true);
+ var eventCanceled:Boolean = !dispatchEvent(event);
+
+ // If the event was canceled, that means the application
+ // is doing its own custom logic for the back key
+ return eventCanceled;
+ }
+
+ return false;
+ }
+
+ /**
+ * @private
+ */
+ mx_internal function menuKeyHandledByView():Boolean
+ {
+ if (hasEventListener(FlexEvent.MENU_KEY_PRESSED))
+ {
+ var event:FlexEvent = new FlexEvent(FlexEvent.MENU_KEY_PRESSED, false, true);
+ var eventCanceled:Boolean = !dispatchEvent(event);
+
+ // If the event was canceled, that means the application
+ // is doing its own custom logic for the back key
+ return eventCanceled;
+ }
+
+ return false;
+ }
+
+ //----------------------------------
+ // overlayControls
+ //----------------------------------
+
+ private var _overlayControls:Boolean = false;
+
+ [Inspectable(category="General", defaultValue="false")]
+ /**
+ * By default, the TabBar and ActionBar controls of a
+ * mobile application define an area that cannot be used
+ * by the views of an application.
+ * That means your content cannot use the full screen size
+ * of the mobile device.
+ * If you set this property to <code>true</code>, the content area
+ * of the application spans the entire width and height of the screen.
+ * The ActionBar and TabBar controls hover over the content area with
+ * an <code>alpha</code> value of 0.5 so that they are partially transparent.
+ *
+ * @default false
+ *
+ * @langversion 3.0
+ * @playerversion AIR 2.5
+ * @productversion Flex 4.5
+ */
+ public function get overlayControls():Boolean
+ {
+ return _overlayControls;
+ }
+
+ /**
+ * @private
+ */
+ public function set overlayControls(value:Boolean):void
+ {
+ if (_overlayControls != value)
+ {
+ var oldValue:Boolean = _overlayControls;
+ _overlayControls = value;
+
+ if (hasEventListener(PropertyChangeEvent.PROPERTY_CHANGE))
+ {
+ var changeEvent:PropertyChangeEvent =
+ PropertyChangeEvent.createUpdateEvent(this, "overlayControls", oldValue, _overlayControls);
+
+ dispatchEvent(changeEvent);
+ }
+ }
+ }
+
+ //----------------------------------
+ // destructionPolicy
+ //----------------------------------
+
+ private var _destructionPolicy:String = ContainerDestructionPolicy.AUTO;
+
+ [Inspectable(category="General", enumeration="auto,never", defaultValue="auto")]
+ /**
+ * Defines the destruction policy the view's navigator should use
+ * when this view is removed. If set to "auto", the navigator will
+ * destroy the view when it isn't active. If set to "never", the
+ * view will be cached in memory.
+ *
+ * @default auto
+ *
+ * @langversion 3.0
+ * @playerversion AIR 2.5
+ * @productversion Flex 4.5
+ */
+ public function get destructionPolicy():String
+ {
+ return _destructionPolicy;
+ }
+
+ /**
+ * @private
+ */
+ public function set destructionPolicy(value:String):void
+ {
+ _destructionPolicy = value;
+ }
+
+ //----------------------------------
+ // navigator
+ //----------------------------------
+
+ private var _navigator:ViewNavigator = null;
+
+ /**
+ * The view navigator that this view resides in.
+ *
+ * @langversion 3.0
+ * @playerversion AIR 2.5
+ * @productversion Flex 4.5
+ */
+
+ [Bindable("navigatorChanged")]
+ public function get navigator():ViewNavigator
+ {
+ return _navigator;
+ }
+
+ /**
+ * @private
+ */
+ public function setNavigator(value:ViewNavigator):void
+ {
+ _navigator = value;
+
+ if (hasEventListener("navigatorChanged"))
+ dispatchEvent(new Event("navigatorChanged"));
+ }
+
+ //--------------------------------------------------------------------------
+ //
+ // UI Template Properties
+ //
+ //--------------------------------------------------------------------------
+
+ //----------------------------------
+ // actionBarVisible
+ //----------------------------------
+ private var _actionBarVisible:Boolean = true;
+
+ [Inspectable(category="General", defaultValue="true")]
+ /**
+ * Specifies whether a view should show the action bar or not.
+ * This property does not necessarily correlate to the
+ * <code>visible</code> property of the view navigator's ActionBar control.
+ *
+ * @default true
+ *
+ * @langversion 3.0
+ * @playerversion AIR 2.5
+ * @productversion Flex 4.5
+ */
+ public function get actionBarVisible():Boolean
+ {
+ return _actionBarVisible;
+ }
+
+ /**
+ * @private
+ */
+ public function set actionBarVisible(value:Boolean):void
+ {
+ _actionBarVisible = value;
+
+ // Immediately request actionBar's visibility be toggled
+ if (isActive && navigator)
+ {
+ if (_actionBarVisible)
+ navigator.showActionBar();
+ else
+ navigator.hideActionBar();
+ }
+ }
+
+ /**
+ * @private
+ * Method called by parent navigator to update the actionBarVisible
+ * flag as a result of the showActionBar() or hideActionBar() methods.
+ */
+ public function setActionBarVisible(value:Boolean):void
+ {
+ _actionBarVisible = value;
+ }
+
+ //----------------------------------
+ // actionContent
+ //----------------------------------
+
+ private var _actionContent:Array;
+
+ [ArrayElementType("mx.core.IVisualElement")]
+ /**
+ * This property overrides the <code>actionContent</code>
+ * property in the ActionBar, ViewNavigator, and
+ * ViewNavigatorApplication components.
+ *
+ * @copy ActionBar#actionContent
+ *
+ * @default null
+ *
+ * @see ActionBar#actionContent
+ * @see spark.skins.mobile.ActionBarSkin
+ *
+ * @langversion 3.0
+ * @playerversion AIR 2.5
+ * @productversion Flex 4.5
+ */
+ public function get actionContent():Array
+ {
+ return _actionContent;
+ }
+ /**
+ * @private
+ */
+ public function set actionContent(value:Array):void
+ {
+ var oldValue:Array = _actionContent;
+ _actionContent = value;
+
+ if (hasEventListener(PropertyChangeEvent.PROPERTY_CHANGE))
+ {
+ var changeEvent:PropertyChangeEvent =
+ PropertyChangeEvent.createUpdateEvent(this, "actionContent", oldValue, _actionContent);
+
+ dispatchEvent(changeEvent);
+ }
+ }
+
+ //----------------------------------
+ // actionLayout
+ //----------------------------------
+
+ private var _actionLayout:LayoutBase;
+
+ /**
+ * @copy ActionBar#actionLayout
+ *
+ * @default null
+ *
+ * @langversion 3.0
+ * @playerversion AIR 2.5
+ * @productversion Flex 4.5
+ */
+ public function get actionLayout():LayoutBase
+ {
+ return _actionLayout;
+ }
+ /**
+ * @private
+ */
+ public function set actionLayout(value:LayoutBase):void
+ {
+ var oldValue:LayoutBase = value;
+ _actionLayout = value;
+
+ if (hasEventListener(PropertyChangeEvent.PROPERTY_CHANGE))
+ {
+ var changeEvent:PropertyChangeEvent =
+ PropertyChangeEvent.createUpdateEvent(this, "actionLayout", oldValue, _actionLayout);
+
+ dispatchEvent(changeEvent);
+ }
+ }
+
+ //----------------------------------
+ // viewMenuItems
+ //----------------------------------
+
+ private var _viewMenuItems:Vector.<ViewMenuItem>;
+
+ /**
+ * The Vector of ViewMenuItem objects passed to the ViewMenu when
+ * this View is the active view.
+ *
+ * @see ViewMenu
+ * @see ViewMenuItem
+ *
+ * @langversion 3.0
+ * @playerversion AIR 2.5
+ * @productversion Flex 4.5
+ */
+ public function get viewMenuItems():Vector.<ViewMenuItem>
+ {
+ return _viewMenuItems;
+ }
+
+ public function set viewMenuItems(value:Vector.<ViewMenuItem>):void
+ {
+ _viewMenuItems = value;
+ }
+
+ //----------------------------------
+ // navigationContent
+ //----------------------------------
+
+ private var _navigationContent:Array;
+
+ [ArrayElementType("mx.core.IVisualElement")]
+ /**
+ * This property overrides the <code>navigationContent</code>
+ * property in the ActionBar, ViewNavigator, and
+ * ViewNavigatorApplication components.
+ *
+ * @copy ActionBar#navigationContent
+ *
+ * @default null
+ *
+ * @see ActionBar#navigationContent
+ * @see spark.skins.mobile.ActionBarSkin
+ *
+ * @langversion 3.0
+ * @playerversion AIR 2.5
+ * @productversion Flex 4.5
+ */
+ public function get navigationContent():Array
+ {
+ return _navigationContent;
+ }
+ /**
+ * @private
+ */
+ public function set navigationContent(value:Array):void
+ {
+ var oldValue:Array = _navigationContent;
+ _navigationContent = value;
+
+ if (hasEventListener(PropertyChangeEvent.PROPERTY_CHANGE))
+ {
+ var changeEvent:PropertyChangeEvent =
+ PropertyChangeEvent.createUpdateEvent(this, "navigationContent", oldValue, _navigationContent);
+
+ dispatchEvent(changeEvent);
+ }
+ }
+
+ //----------------------------------
+ // navigationLayout
+ //----------------------------------
+
+ private var _navigationLayout:LayoutBase;
+
+ /**
+ * @copy ActionBar#navigationLayout
+ *
+ * @default null
+ *
+ * @langversion 3.0
+ * @playerversion AIR 2.5
+ * @productversion Flex 4.5
+ */
+ public function get navigationLayout():LayoutBase
+ {
+ return _navigationLayout;
+ }
+ /**
+ * @private
+ */
+ public function set navigationLayout(value:LayoutBase):void
+ {
+ var oldValue:LayoutBase = _navigationLayout;
+ _navigationLayout = value;
+
+ if (hasEventListener(PropertyChangeEvent.PROPERTY_CHANGE))
+ {
+ var changeEvent:PropertyChangeEvent =
+ PropertyChangeEvent.createUpdateEvent(this, "navigationLayout", _navigationLayout, value);
+
+ dispatchEvent(changeEvent);
+ }
+ }
+
+
+
+ //----------------------------------
+ // tabBarVisible
+ //----------------------------------
+ private var _tabBarVisible:Boolean = true;
+
+ [Inspectable(category="General", defaultValue="true")]
+ /**
+ * Specifies whether a view should show the tab bar or not.
+ * This property does not necessarily correlate to the
+ * <code>visible</code> property of the navigator's TabBar control.
+ *
+ * @default true
+ *
+ * @langversion 3.0
+ * @playerversion AIR 2.5
+ * @productversion Flex 4.5
+ */
+ public function get tabBarVisible():Boolean
+ {
+ return _tabBarVisible;
+ }
+
+ /**
+ * @private
+ */
+ public function set tabBarVisible(value:Boolean):void
+ {
+ var oldValue:Boolean = _tabBarVisible;
+ _tabBarVisible = value;
+
+ // Immediately request actionBar's visibility be toggled
+ if (isActive && navigator)
+ {
+ if (hasEventListener(PropertyChangeEvent.PROPERTY_CHANGE))
+ {
+ var changeEvent:PropertyChangeEvent =
+ PropertyChangeEvent.createUpdateEvent(this, "tabBarVisible", oldValue, value);
+
+ dispatchEvent(changeEvent);
+ }
+ }
+ }
+
+ /**
+ * @private
+ * Method called by parent navigator to update the actionBarVisible
+ * flag as a result of the showTabBar() or hideTabBar() methods.
+ */
+ mx_internal function setTabBarVisible(value:Boolean):void
+ {
+ _tabBarVisible = value;
+ }
+
+ //----------------------------------
+ // title
+ //----------------------------------
+
+ private var _title:String;
+
+ [Bindable]
+ /**
+ * This property overrides the <code>title</code>
+ * property in the ActionBar, ViewNavigator, and
+ * ViewNavigatorApplication components.
+ *
+ * @copy ActionBar#title
+ *
+ * @default ""
+ *
+ * @langversion 3.0
+ * @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)
+ {
+ var oldValue:String = _title;
+ _title = value;
+
+ if (hasEventListener(PropertyChangeEvent.PROPERTY_CHANGE))
+ {
+ var changeEvent:PropertyChangeEvent =
+ PropertyChangeEvent.createUpdateEvent(this, "title", oldValue, _title);
+
+ dispatchEvent(changeEvent);
+ }
+ }
+ }
+
+ //----------------------------------
+ // titleContent
+ //----------------------------------
+
+ private var _titleContent:Array;
+
+ [ArrayElementType("mx.core.IVisualElement")]
+ /**
+ * This property overrides the <code>titleContent</code>
+ * property in the ActionBar, ViewNavigator, and
+ * ViewNavigatorApplication components.
+ *
+ * @copy ActionBar#titleContent
+ *
+ * @default null
+ *
+ * @see ActionBar#titleContent
+ * @see spark.skins.mobile.ActionBarSkin
+ *
+ * @langversion 3.0
+ * @playerversion AIR 2.5
+ * @productversion Flex 4.5
+ */
+ public function get titleContent():Array
+ {
+ return _titleContent;
+ }
+ /**
+ * @private
+ */
+ public function set titleContent(value:Array):void
+ {
+ var oldValue:Array = _titleContent;
+ _titleContent = value;
+
+ if (hasEventListener(PropertyChangeEvent.PROPERTY_CHANGE))
+ {
+ var changeEvent:PropertyChangeEvent =
+ PropertyChangeEvent.createUpdateEvent(this, "titleContent", oldValue, _titleContent);
+
+ dispatchEvent(changeEvent);
+ }
+ }
+
+ //----------------------------------
+ // titleLayout
+ //----------------------------------
+
+ private var _titleLayout:LayoutBase;
+
+ /**
+ * @copy ActionBar#titleLayout
+ *
+ * @default null
+ *
+ * @langversion 3.0
+ * @playerversion AIR 2.5
+ * @productversion Flex 4.5
+ */
+ public function get titleLayout():LayoutBase
+ {
+ return _titleLayout;
+ }
+ /**
+ * @private
+ */
+ public function set titleLayout(value:LayoutBase):void
+ {
+ var oldValue:LayoutBase = _titleLayout;
+ _titleLayout = value;
+
+ if (hasEventListener(PropertyChangeEvent.PROPERTY_CHANGE))
+ {
+ var changeEvent:PropertyChangeEvent =
+ PropertyChangeEvent.createUpdateEvent(this, "titleLayout", oldValue, _titleLayout);
+
+ dispatchEvent(changeEvent);
+ }
+ }
+
+ //--------------------------------------------------------------------------
+ //
+ // IDataRenderer Properties
+ //
+ //--------------------------------------------------------------------------
+
+ //----------------------------------
+ // data
+ //----------------------------------
+
+ private var _data:Object;
+
+ [Bindable("dataChange")]
+
+ /**
+ * The data associated with the current view.
+ * You use this property to pass infomration to the View when
+ * it is pushed onto the navigator's stack.
+ * You can set this property by passing a <code>data</code>
+ * argument to the <code>pushView()</code> method.
+ *
+ * @langversion 3.0
+ * @playerversion AIR 2.5
+ * @productversion Flex 4.5
+ */
+ public function get data():Object
+ {
+ return _data;
+ }
+
+ /**
+ * @private
+ */
+ public function set data(value:Object):void
+ {
+ _data = value;
+
+ if (hasEventListener(FlexEvent.DATA_CHANGE))
+ dispatchEvent(new FlexEvent(FlexEvent.DATA_CHANGE));
+ }
+
+ //--------------------------------------------------------------------------
+ //
+ // Methods
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * Creates an object returned to the view navigator
+ * when this view is popped off the navigator's stack.
+ *
+ * <p>Override this method in a View to return data back the new
+ * view when this view is popped off the stack.
+ * The <code>createReturnObject()</code> method returns a single Object.
+ * The Object returned by this method is written to the
+ * <code>ViewNavigator.poppedViewReturnedObject</code> property. </p>
+ *
+ * <p>The <code>ViewNavigator.poppedViewReturnedObject</code> property
+ * is of type ViewReturnObject.
+ * The <code>ViewReturnObject.object</code> property contains the
+ * value returned by this method. </p>
+ *
+ * <p>If the <code>poppedViewReturnedObject</code> property is null,
+ * no data was returned.
+ * The <code>poppedViewReturnedObject</code> property is guaranteed to be set
+ * in the new view before the new view receives the <code>add</code> event.</p>
+ *
+ * @return The value written to the <code>object</code> field of the
+ * <code>ViewNavigator.poppedViewReturnedObject</code> property.
+ *
+ * @see ViewNavigator#poppedViewReturnedObject
+ * @see spark.components.supportClasses.ViewReturnObject
+ *
+ * @langversion 3.0
+ * @playerversion AIR 2.5
+ * @productversion Flex 4.5
+ */
+ public function createReturnObject():Object
+ {
+ return null;
+ }
+
+ /**
+ * Checks the aspect ratio of the stage and returns the proper state
+ * that the View should change to.
+ *
+ * @return A String specifying the name of the state to apply to the view.
+ * The possible return values are <code>"portrait"</code>
+ * or <code>"landscape"</code>.
+ * The state is only changed if the desired state exists
+ * on the View.
+ * If it does not, this method returns the component's current state.
+ *
+ * @langversion 3.0
+ * @playerversion AIR 2.5
+ * @productversion Flex 4.5
+ */
+ public function getCurrentViewState():String
+ {
+ var aspectRatio:String = FlexGlobals.topLevelApplication.aspectRatio;
+
+ if (hasState(aspectRatio))
+ return aspectRatio;
+
+ // If the appropriate state for the orientation of the device
+ // isn't defined, return the current state
+ return currentState;
+ }
+
+ //--------------------------------------------------------------------------
+ //
+ // Private Methods
+ //
+ //--------------------------------------------------------------------------
+ /**
+ * @private
+ */
+ private function application_resizeHandler(event:Event):void
+ {
+ if (isActive)
+ updateOrientationState();
+ }
+
+ /**
+ * @private
+ */
+ mx_internal function updateOrientationState():void
+ {
+ setCurrentState(getCurrentViewState(), false);
+ }
+
+ //--------------------------------------------------------------------------
+ //
+ // Overridden methods: UIComponent
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * @private
+ */
+ override public function initialize():void
+ {
+ super.initialize();
+
+ addEventListener(FlexEvent.CREATION_COMPLETE, creationCompleteHandler);
+ }
+
+ /**
+ * @private
+ */
+ private function creationCompleteHandler(event:FlexEvent):void
+ {
+ removeEventListener(FlexEvent.CREATION_COMPLETE, creationCompleteHandler);
+
+ // Create a weak listener so stage doesn't hold a reference to the view
+ FlexGlobals.topLevelApplication.addEventListener(ResizeEvent.RESIZE,
+ application_resizeHandler, false, 0, true);
+
+ updateOrientationState();
+ }
+
+ //--------------------------------------------------------------------------
+ //
+ // Persistence Methods
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * Responsible for serializes the view's <code>data</code> property
+ * when the view is being persisted to disk.
+ * The returned object should be something that can
+ * be successfully written to a shared object.
+ * By default, this method returns the <code>data</code> property
+ * of the view.
+ *
+ * @return The serialized data object.
+ *
+ * @langversion 3.0
+ * @playerversion AIR 2.5
+ * @productversion Flex 4.5
+ */
+ public function serializeData():Object
+ {
+ return data;
+ }
+
+ /**
+ * Deserializes a data object that was saved to disk by the view,
+ * typically by a call to the <code>serializeData()</code> method.
+ *
+ * @param value The data object to deserialize.
+ *
+ * @return The value assigned to the
+ * view's <code>data</code> property.
+ *
+ *
+ * @langversion 3.0
+ * @playerversion AIR 2.5
+ * @productversion Flex 4.5
+ */
+ public function deserializeData(value:Object):Object
+ {
+ return value;
+ }
+ }
+}
\ No newline at end of file
Added: incubator/flex/whiteboard/tink/iview/src/org/apache/spark/components/supportClasses/NavigationStack.as
URL: http://svn.apache.org/viewvc/incubator/flex/whiteboard/tink/iview/src/org/apache/spark/components/supportClasses/NavigationStack.as?rev=1230830&view=auto
==============================================================================
--- incubator/flex/whiteboard/tink/iview/src/org/apache/spark/components/supportClasses/NavigationStack.as (added)
+++ incubator/flex/whiteboard/tink/iview/src/org/apache/spark/components/supportClasses/NavigationStack.as Thu Jan 12 23:15:17 2012
@@ -0,0 +1,256 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// 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 org.apache.spark.components.supportClasses
+{
+ import flash.utils.IDataInput;
+ import flash.utils.IDataOutput;
+ import flash.utils.IExternalizable;
+
+ import mx.core.mx_internal;
+
+ use namespace mx_internal;
+
+ [ExcludeClass]
+
+ /**
+ * The NavigationStack class is a data structure that is internally used by
+ * ViewNavigator to track the current set of views that are being managed
+ * by the navigator.
+ *
+ * @see spark.components.ViewNavigator
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10
+ * @playerversion AIR 2.5
+ * @productversion Flex 4.5
+ */
+ public class NavigationStack implements IExternalizable
+ {
+
+ //--------------------------------------------------------------------------
+ //
+ // Constructor
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * Constructor.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10
+ * @playerversion AIR 2.5
+ * @productversion Flex 4.5
+ */
+ public function NavigationStack()
+ {
+ super();
+
+ _source = new Vector.<ViewDescriptor>();
+ }
+
+ //--------------------------------------------------------------------------
+ //
+ // Variables
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * @private
+ */
+ private var _source:Vector.<ViewDescriptor>;
+
+ /**
+ * @private
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10
+ * @playerversion AIR 2.5
+ * @productversion Flex 4.5
+ */
+ mx_internal function get source():Vector.<ViewDescriptor>
+ {
+ return _source;
+ }
+
+ //--------------------------------------------------------------------------
+ //
+ // Properties
+ //
+ //--------------------------------------------------------------------------
+
+ //----------------------------------
+ // length
+ //----------------------------------
+
+ /**
+ * The length of the stack.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10
+ * @playerversion AIR 2.5
+ * @productversion Flex 4.5
+ */
+ public function get length():int
+ {
+ return _source.length;
+ }
+
+ //----------------------------------
+ // top
+ //----------------------------------
+
+ /**
+ * Returns the object at the top of the stack.
+ * If the stack is empty, this property is null.
+ *
+ * @default null
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10
+ * @playerversion AIR 2.5
+ * @productversion Flex 4.5
+ */
+ mx_internal function get topView():ViewDescriptor
+ {
+ return _source.length == 0 ? null : _source[_source.length - 1];
+ }
+
+ //--------------------------------------------------------------------------
+ //
+ // Methods
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * Clears the entire stack.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10
+ * @playerversion AIR 2.5
+ * @productversion Flex 4.5
+ */
+ public function clear():void
+ {
+ _source.length = 0;
+ }
+
+ /**
+ * Adds a view to the top of the navigation stack.
+ * Pushing a view changes the display of the application to
+ * the new view on the stack.
+ *
+ * @param viewClass The class of the View to create.
+ *
+ * @param data The data object to pass to the view when it is created.
+ * The new view accesses this Object by using
+ * the <code>View.data</code> property.
+ *
+ * @param context The context identifier to pass to the view when
+ * it is created.
+ *
+ * @return The data structure that represents the current view.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10
+ * @playerversion AIR 2.5
+ * @productversion Flex 4.5
+ */
+ public function pushView(viewClass:Class, data:Object, context:Object = null):ViewDescriptor
+ {
+ var viewData:ViewDescriptor = new ViewDescriptor(viewClass, data, context);
+ _source.push(viewData);
+
+ return viewData;
+ }
+
+ /**
+ * Removes the top view off the stack.
+ * Returns control from the current view back to
+ * the previous view on the stack.
+ *
+ * @return The data structure that represented the View that was removed.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10
+ * @playerversion AIR 2.5
+ * @productversion Flex 4.5
+ */
+ public function popView():ViewDescriptor
+ {
+ return _source.pop();
+ }
+
+ /**
+ * Removes all but the root object from the navigation stack.
+ * The root object becomes the current view.
+ *
+ * @return The data structure that represented the View that was at
+ * the top of the stack when this method was called, or null if
+ * nothing was removed.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10
+ * @playerversion AIR 2.5
+ * @productversion Flex 4.5
+ */
+ public function popToFirstView():ViewDescriptor
+ {
+ if (_source.length > 1)
+ {
+ var viewData:ViewDescriptor = topView;
+ _source.length = 1;
+
+ return viewData;
+ }
+
+ return null;
+ }
+
+ //--------------------------------------------------------------------------
+ //
+ // Methods: IExternalizable
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * Serializes the navigation stack in an IDataOutput object so that it
+ * can be written to a shared object.
+ *
+ * @param output The data output object used to write the data.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10
+ * @playerversion AIR 2.5
+ * @productversion Flex 4.5
+ */
+ public function writeExternal(output:IDataOutput):void
+ {
+ output.writeObject(_source);
+ }
+
+ /**
+ * Deserializes the navigation stack when it is being loaded
+ * from a shared object.
+ *
+ * @param input The external object to read from.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10
+ * @playerversion AIR 2.5
+ * @productversion Flex 4.5
+ */
+ public function readExternal(input:IDataInput):void
+ {
+ _source = input.readObject() as Vector.<ViewDescriptor>;
+ }
+ }
+}
\ No newline at end of file
Added: incubator/flex/whiteboard/tink/iview/src/org/apache/spark/components/supportClasses/ViewDescriptor.as
URL: http://svn.apache.org/viewvc/incubator/flex/whiteboard/tink/iview/src/org/apache/spark/components/supportClasses/ViewDescriptor.as?rev=1230830&view=auto
==============================================================================
--- incubator/flex/whiteboard/tink/iview/src/org/apache/spark/components/supportClasses/ViewDescriptor.as (added)
+++ incubator/flex/whiteboard/tink/iview/src/org/apache/spark/components/supportClasses/ViewDescriptor.as Thu Jan 12 23:15:17 2012
@@ -0,0 +1,203 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// 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 org.apache.spark.components.supportClasses
+{
+ import flash.utils.IDataInput;
+ import flash.utils.IDataOutput;
+ import flash.utils.IExternalizable;
+ import flash.utils.getDefinitionByName;
+ import flash.utils.getQualifiedClassName;
+ import org.apache.spark.components.IView;
+
+ [ExcludeClass]
+
+ /**
+ * The ViewDescriptor object is a data structure used to store information
+ * about a view that is being managed by a ViewNavigator.
+ *
+ * @see spark.components.ViewNavigator
+ *
+ * @langversion 3.0
+ * @playerversion AIR 2.5
+ * @productversion Flex 4.5
+ */
+ public class ViewDescriptor implements IExternalizable
+ {
+ //--------------------------------------------------------------------------
+ //
+ // Constructor
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * Constructor.
+ *
+ * @param viewClass The class used to create the View object.
+ *
+ * @param data The data object to pass to the view when it is created.
+ *
+ * @param context The context of the view.
+ *
+ * @param instance A reference to the instance of the View object.
+ *
+ * @langversion 3.0
+ * @playerversion AIR 2.5
+ * @productversion Flex 4.5
+ */
+ public function ViewDescriptor(viewClass:Class = null,
+ data:Object = null,
+ context:Object = null,
+ instance:IView = null)
+ {
+ this.viewClass = viewClass;
+ this.data = data;
+ this.context = context;
+ this.instance = instance;
+ }
+
+ //--------------------------------------------------------------------------
+ //
+ // Properties
+ //
+ //--------------------------------------------------------------------------
+
+ //----------------------------------
+ // context
+ //----------------------------------
+
+ /**
+ * The string that describes the context in which this view was created.
+ * This property is assigned to the <code>context</code>
+ * parameter that is passed to the
+ * <code>ViewNavigator.pushView()</code> method.
+ *
+ * @see spark.components.ViewNavigator#pushView()
+ *
+ * @langversion 3.0
+ * @playerversion AIR 2.5
+ * @productversion Flex 4.5
+ */
+ public var context:Object;
+
+ //----------------------------------
+ // data
+ //----------------------------------
+
+ /**
+ * The current data object that is being used by the view.
+ * When a view is removed from a navigation stack, this value
+ * is updated to match the view's instance's current
+ * <code>data</code> object.
+ *
+ * @see spark.components.View#data
+ *
+ * @langversion 3.0
+ * @playerversion AIR 2.5
+ * @productversion Flex 4.5
+ */
+ public var data:Object;
+
+ //----------------------------------
+ // instance
+ //----------------------------------
+
+ /**
+ * A reference to the View instance that is represented by this object.
+ * The ViewNavigator creates and assigns the instance as needed.
+ * This property is set to null when a view is destroyed.
+ *
+ * @langversion 3.0
+ * @playerversion AIR 2.5
+ * @productversion Flex 4.5
+ */
+ public var instance:IView;
+
+ //----------------------------------
+ // persistenceData
+ //----------------------------------
+
+ /**
+ * The serialized data that the view has requested be saved to disk when
+ * the application is writing data to a shared object or external file.
+ * This object is the result of calling
+ * the <code>serializeData()</code> method on the View object.
+ *
+ * @langversion 3.0
+ * @playerversion AIR 2.5
+ * @productversion Flex 4.5
+ */
+ public var persistenceData:Object;
+
+ //----------------------------------
+ // viewClass
+ //----------------------------------
+
+ /**
+ * The class used to create the view.
+ * The ViewNavigator expects this class to be a subclass of View.
+ *
+ * @see spark.components.View
+ *
+ * @langversion 3.0
+ * @playerversion AIR 2.5
+ * @productversion Flex 4.5
+ */
+ public var viewClass:Class;
+
+ //--------------------------------------------------------------------------
+ //
+ // Methods: IExternalizable
+ //
+ //--------------------------------------------------------------------------
+
+ // TODO (chiedozi): This method isn't module safe because it doesn't properly
+ // check application domains when using getDefinitionByName. Should use
+ // systemManager to do this. (SDK-27424)
+ /**
+ * Serializes this object stack in an IDataOutput object so that it
+ * can be written to a shared object.
+ *
+ * @param output The data output object used to write the data.
+ *
+ * @langversion 3.0
+ * @playerversion AIR 2.5
+ * @productversion Flex 4.5
+ */
+ public function writeExternal(output:IDataOutput):void
+ {
+ output.writeObject(context);
+ output.writeObject(persistenceData);
+
+ // Have to store the class name of the viewClass because classes can't be
+ // written to a shared object
+ output.writeObject(getQualifiedClassName(viewClass));
+ }
+
+ /**
+ * Deserializes the object when being loaded from a shared object.
+ *
+ * @param input The external object to read from.
+ *
+ * @langversion 3.0
+ * @playerversion AIR 2.5
+ * @productversion Flex 4.5
+ */
+ public function readExternal(input:IDataInput):void
+ {
+ context = input.readObject();
+ persistenceData = input.readObject();
+
+ var className:String = input.readObject();
+ viewClass = (className == "null") ? null : getDefinitionByName(className) as Class;
+ }
+ }
+}
\ No newline at end of file
Added: incubator/flex/whiteboard/tink/iview/src/org/apache/spark/components/supportClasses/ViewNavigatorBase.as
URL: http://svn.apache.org/viewvc/incubator/flex/whiteboard/tink/iview/src/org/apache/spark/components/supportClasses/ViewNavigatorBase.as?rev=1230830&view=auto
==============================================================================
--- incubator/flex/whiteboard/tink/iview/src/org/apache/spark/components/supportClasses/ViewNavigatorBase.as (added)
+++ incubator/flex/whiteboard/tink/iview/src/org/apache/spark/components/supportClasses/ViewNavigatorBase.as Thu Jan 12 23:15:17 2012
@@ -0,0 +1,661 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// 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 org.apache.spark.components.supportClasses
+{
+ import flash.display.InteractiveObject;
+ import flash.display.Stage;
+ import flash.events.StageOrientationEvent;
+ import flash.utils.getDefinitionByName;
+ import flash.utils.getQualifiedClassName;
+
+ import mx.core.FlexGlobals;
+ import mx.core.UIComponent;
+ import mx.core.mx_internal;
+ import mx.events.FlexEvent;
+ import mx.events.PropertyChangeEvent;
+ import mx.events.ResizeEvent;
+ import mx.utils.DensityUtil;
+
+ import spark.components.SkinnableContainer;
+ import spark.utils.MultiDPIBitmapSource;
+ import spark.components.supportClasses.ViewNavigatorAction;
+ import org.apache.spark.components.IView;
+
+ use namespace mx_internal;
+
+ /**
+ * The ViewNavigatorBase class defines the base class logic and
+ * interface used by view navigators.
+ * This class contains methods and properties related to view management,
+ * as well as integration points with ViewNavigatorApplicationBase application
+ * classes.
+ *
+ * @mxml <p>The <code><s:ViewNavigatorBase></code> tag inherits
+ * all of the tag attributes of its superclass and adds the following tag attributes:</p>
+ *
+ * <pre>
+ * <s:ViewNavigatorBase
+ * <strong>Properties</strong>
+ * icon="null"
+ * label="null"
+ * transitionsEnabled="true"
+ * />
+ * </pre>
+ *
+ * @see spark.components.ViewNavigator
+ * @see spark.components.ViewNavigatorApplication
+ *
+ * @langversion 3.0
+ * @playerversion AIR 2.5
+ * @productversion Flex 4.5
+ */
+ public class ViewNavigatorBase extends SkinnableContainer
+ {
+ //--------------------------------------------------------------------------
+ //
+ // Constructor
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * Constructor.
+ *
+ * @langversion 3.0
+ * @playerversion AIR 2.5
+ * @productversion Flex 4.5
+ */
+ public function ViewNavigatorBase()
+ {
+ super();
+
+ _navigationStack = new NavigationStack();
+ }
+
+ //--------------------------------------------------------------------------
+ //
+ // Variables
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * @private
+ * This private variable is used to indicate that the navigator shouldn't play
+ * the pending visibility animation for the chrome components that it controls
+ * (e.g, ActionBar and TabBar). This flag is set to true when the stage changes
+ * orientation. This allows the framework to prevent the hide/show animation
+ * from playing when the controls are hidden in either landscape or portrait.
+ *
+ * See SDK-28541 for more information.
+ */
+ mx_internal var disableNextControlAnimation:Boolean = false;
+
+ //--------------------------------------------------------------------------
+ //
+ // Properties
+ //
+ //--------------------------------------------------------------------------
+
+ //----------------------------------
+ // active
+ //----------------------------------
+
+ private var _active:Boolean = true;
+
+ /**
+ * Set to <code>true</code> when this navigator is active.
+ * The parent navigator automatically sets this flag its state changes.
+ *
+ * @default true
+ *
+ * @langversion 3.0
+ * @playerversion AIR 2.5
+ * @productversion Flex 4.5
+ */
+ public function get isActive():Boolean
+ {
+ return _active;
+ }
+
+ /**
+ * @private
+ * Setting the active state is hidden and should be managed my
+ * the components that manage navigators.
+ */
+ mx_internal function setActive(value:Boolean, clearNavigationStack:Boolean = false):void
+ {
+ if (_active != value)
+ _active = value;
+ }
+
+ //----------------------------------
+ // activeView
+ //----------------------------------
+
+ /**
+ * The currently active view of the navigator.
+ * Only one view can be active at a time.
+ *
+ * @default null
+ *
+ * @langversion 3.0
+ * @playerversion AIR 2.5
+ * @productversion Flex 4.5
+ */
+ public function get activeView():IView
+ {
+ return null;
+ }
+
+ //----------------------------------
+ // exitApplicationOnBackKey
+ //----------------------------------
+ /**
+ * @private
+ * This method determines if a device's default back key handler can
+ * be canceled. For example, by default, when the back key is pressed
+ * on android devices, the application exits. By returning true, that
+ * action will be canceled and the navigator's default back key behavior
+ * will run.
+ *
+ * <p>This method is only called if the navigator is the main navigator
+ * of a ViewNavigatorApplication class</p>.
+ *
+ * @default true
+ *
+ * @langversion 3.0
+ * @playerversion AIR 2.5
+ * @productversion Flex 4.5
+ */
+ mx_internal function get exitApplicationOnBackKey():Boolean
+ {
+ return true;
+ }
+
+ //----------------------------------
+ // icon
+ //----------------------------------
+
+ private var _icon:Object;
+
+ /**
+ * The icon used when this navigator is represented
+ * by a visual component.
+ *
+ * @default null
+ *
+ * @langversion 3.0
+ * @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)
+ {
+ var oldValue:Object = _icon;
+ _icon = value;
+
+ if (hasEventListener(PropertyChangeEvent.PROPERTY_CHANGE))
+ {
+ var changeEvent:PropertyChangeEvent =
+ PropertyChangeEvent.createUpdateEvent(this, "icon", oldValue, _icon);
+
+ dispatchEvent(changeEvent);
+ }
+ }
+ }
+
+ //----------------------------------
+ // label
+ //----------------------------------
+
+ private var _label:String = "";
+
+ [Bindable]
+ /**
+ * The label used when this navigator is represented by a visual component.
+ *
+ * @default null
+ *
+ * @langversion 3.0
+ * @playerversion AIR 2.5
+ * @productversion Flex 4.5
+ */
+ public function get label():String
+ {
+ return _label;
+ }
+
+ /**
+ * @private
+ */
+ public function set label(value:String):void
+ {
+ if (_label != value)
+ {
+ var oldValue:String = _label;
+ _label = value;
+
+ if (hasEventListener(PropertyChangeEvent.PROPERTY_CHANGE))
+ {
+ var changeEvent:PropertyChangeEvent =
+ PropertyChangeEvent.createUpdateEvent(this, "label", oldValue, _label);
+
+ dispatchEvent(changeEvent);
+ }
+ }
+ }
+
+ //----------------------------------
+ // lastAction
+ //----------------------------------
+
+ private var _lastAction:String = ViewNavigatorAction.NONE;
+
+ /**
+ * @private
+ * The last action performed by the navigator.
+ *
+ * @see spark.components.supportClasses.ViewNavigatorAction
+ */
+ mx_internal function get lastAction():String
+ {
+ return _lastAction;
+ }
+
+ /**
+ * @private
+ */
+ mx_internal function set lastAction(value:String):void
+ {
+ _lastAction = value;
+ }
+
+ //----------------------------------
+ // navigationStack
+ //----------------------------------
+
+ /**
+ * @private
+ */
+ protected var _navigationStack:NavigationStack;
+
+ /**
+ * @private
+ * The navigation stack that is being managed by the navigator.
+ * An empty navigation stack is automatically created when
+ * a navigator is created.
+ *
+ * @default null
+ */
+ mx_internal function get navigationStack():NavigationStack
+ {
+ return _navigationStack;
+ }
+
+ /**
+ * @private
+ */
+ mx_internal function set navigationStack(value:NavigationStack):void
+ {
+ if (value == null)
+ _navigationStack = new NavigationStack();
+ else
+ _navigationStack = value;
+ }
+
+ //----------------------------------
+ // overlayControls
+ //----------------------------------
+ private var _overlayControls:Boolean = false;
+
+ /**
+ * @private
+ * This property controls the overlay state of the navigator. The
+ * navigator will properly update this property in the
+ * updateControlsForView() method with the View.overlayControls
+ * property.
+ *
+ * @langversion 3.0
+ * @playerversion AIR 2.5
+ * @productversion Flex 4.5
+ */
+ mx_internal function get overlayControls():Boolean
+ {
+ return _overlayControls;
+ }
+
+ mx_internal function set overlayControls(value:Boolean):void
+ {
+ if (value != _overlayControls)
+ {
+ _overlayControls = value;
+ invalidateSkinState();
+
+ if (skin)
+ {
+ skin.invalidateSize();
+ skin.invalidateDisplayList();
+ }
+ }
+ }
+
+ //----------------------------------
+ // parentNavigator
+ //----------------------------------
+ private var _parentNavigator:ViewNavigatorBase;
+
+ /**
+ * The parent navigator for this navigator.
+ *
+ * @default null
+ *
+ * @langversion 3.0
+ * @playerversion AIR 2.5
+ * @productversion Flex 4.5
+ */
+ public function get parentNavigator():ViewNavigatorBase
+ {
+ return _parentNavigator;
+ }
+
+ /**
+ * @private
+ */
+ mx_internal function setParentNavigator(value:ViewNavigatorBase):void
+ {
+ _parentNavigator = value;
+ }
+
+ //----------------------------------
+ // transitionsEnabled
+ //----------------------------------
+
+ private var _transitionsEnabled:Boolean = true;
+
+ /**
+ * Set to <code>true</code> to enable view transitions
+ * when a view changes, or when the ActionBar control or
+ * TabBar control visibility changes.
+ *
+ * @default true
+ *
+ * @langversion 3.0
+ * @playerversion AIR 2.5
+ * @productversion Flex 4.5
+ */
+ public function get transitionsEnabled():Boolean
+ {
+ return _transitionsEnabled;
+ }
+
+ /**
+ * @private
+ */
+ public function set transitionsEnabled(value:Boolean):void
+ {
+ _transitionsEnabled = value;
+ }
+
+ //--------------------------------------------------------------------------
+ //
+ // Public Methods
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * This method executes the default back key behavior for a ViewNavigator.
+ *
+ * @langversion 3.0
+ * @playerversion AIR 3.1
+ * @productversion Flex 4.6
+ */
+ public function backKeyUpHandler():void
+ {
+ }
+
+ /**
+ * Serializes all data related to
+ * the navigator's children into an object that can be saved
+ * by the persistence manager.
+ * This returned object is passed to the <code>restoreViewData()</code>
+ * method when the navigator is reinstantiated.
+ *
+ * @return The object that represents the navigators state
+ *
+ * @langversion 3.0
+ * @playerversion AIR 2.5
+ * @productversion Flex 4.5
+ */
+ public function saveViewData():Object
+ {
+ var iconData:Object = icon;
+
+ if (iconData is MultiDPIBitmapSource)
+ {
+ var app:Object = FlexGlobals.topLevelApplication;
+ var dpi:Number;
+ if ("runtimeDPI" in app)
+ dpi = app["runtimeDPI"];
+ else
+ dpi = DensityUtil.getRuntimeDPI();
+
+ iconData = MultiDPIBitmapSource(iconData).getSource(dpi);
+ }
+
+ if (iconData is Class)
+ return {label:label, iconClassName:getQualifiedClassName(iconData)};
+ if (iconData is String)
+ return {label:label, iconStringName: iconData};
+
+ return {label:label};
+ }
+
+ /**
+ * Restores the state of a navigator's view
+ * from the <code>value</code> argument.
+ * The object passed as the <code>value</code> argument is
+ * created by a call to the <code>saveViewData()</code> method.
+ *
+ * @param value The object used to restore the navigators state.
+ *
+ * @langversion 3.0
+ * @playerversion AIR 2.5
+ * @productversion Flex 4.5
+ */
+ public function loadViewData(value:Object):void
+ {
+ label = value.label;
+
+ var iconClassName:String = value.iconClassName;
+
+ if (iconClassName == null)
+ icon = value.iconStringName;
+ else if (iconClassName != null)
+ icon = getDefinitionByName(iconClassName);
+
+ // TODO (chiedozi): This is not module safe because of its use of
+ // getDefinitionByName. Should use systemManager to do this. (SDK-27424)
+ }
+
+ /**
+ * Updates various properties of the navigator when a
+ * new view is added and activated.
+ *
+ * @param view The view that was added.
+ *
+ * @langversion 3.0
+ * @playerversion AIR 2.5
+ * @productversion Flex 4.5
+ */
+ public function updateControlsForView(view:IView):void
+ {
+ if (parentNavigator)
+ parentNavigator.updateControlsForView(view);
+ }
+
+ //--------------------------------------------------------------------------
+ //
+ // Private methods
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * @private
+ *
+ * @langversion 3.0
+ * @playerversion AIR 2.5
+ * @productversion Flex 4.5
+ */
+ override protected function getCurrentSkinState():String
+ {
+ var finalState:String = FlexGlobals.topLevelApplication.aspectRatio;
+
+ if (_overlayControls)
+ finalState += "AndOverlay";
+
+ return finalState;
+ }
+
+ /**
+ * @private
+ * This method checks if the current view can be removed
+ * from the display list. This is mx_internal because the
+ * TabbedViewNavigator needs to call it on its children.
+ *
+ * @return Returns true if the screen can be removed
+ *
+ * @langversion 3.0
+ * @playerversion AIR 2.5
+ * @productversion Flex 4.5
+ */
+ mx_internal function canRemoveCurrentView():Boolean
+ {
+ // This is a method instead of a property because the default
+ // implementation in ViewNavigator has a side effect
+ return true;
+ }
+
+
+ /**
+ * @private
+ * Captures the important animation values of component to use
+ * when animating the actionBar's visiblity.
+ *
+ * @param component The component to capture the values from
+ *
+ * @return Returns an object that contains the properties
+ *
+ * @langversion 3.0
+ * @playerversion AIR 2.5
+ * @productversion Flex 4.5
+ */
+ mx_internal function captureAnimationValues(component:UIComponent):Object
+ {
+ var values:Object = { x:component.x,
+ y:component.y,
+ width:component.width,
+ height:component.height,
+ explicitWidth:component.explicitWidth,
+ explicitHeight:component.explicitHeight,
+ percentWidth:component.percentWidth,
+ percentHeight:component.percentHeight,
+ visible: component.visible,
+ includeInLayout: component.includeInLayout,
+ cacheAsBitmap: component.cacheAsBitmap };
+
+ return values;
+ }
+
+ /**
+ * @private
+ * Creates the top view of the navigator and adds it to the
+ * display list. This method is used when the navigator exists
+ * inside a TabbedViewNavigator.
+ */
+ mx_internal function createTopView():void
+ {
+ // Override in sub class
+ }
+
+ /**
+ * @private
+ */
+ private function creationCompleteHandler(event:FlexEvent):void
+ {
+ removeEventListener(FlexEvent.CREATION_COMPLETE, creationCompleteHandler);
+
+ // Create a weak listener so stage doesn't hold a reference to the view
+ FlexGlobals.topLevelApplication.addEventListener(ResizeEvent.RESIZE,
+ stage_resizeHandler, false, 0, true);
+ }
+
+ /**
+ * @private
+ */
+ mx_internal function updateFocus():void
+ {
+ var stage:Stage = systemManager.stage;
+ if (!stage.focus || !stage.focus.stage || stage.focus == this)
+ {
+ if (activeView)
+ stage.focus = activeView as InteractiveObject;
+ else
+ stage.focus = this;
+ }
+ }
+
+ /**
+ * @private
+ */
+ mx_internal function stage_resizeHandler(event:ResizeEvent):void
+ {
+ disableNextControlAnimation = true;
+ invalidateSkinState();
+ }
+
+ //--------------------------------------------------------------------------
+ //
+ // Overridden methods: UIComponent
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * @private
+ */
+ override protected function attachSkin():void
+ {
+ super.attachSkin();
+
+ // Since a new skin was added, update the state of the controls
+ // added as part of the new skin
+ updateControlsForView(activeView);
+ }
+
+ /**
+ * @private
+ */
+ override public function initialize():void
+ {
+ super.initialize();
+
+ addEventListener(FlexEvent.CREATION_COMPLETE, creationCompleteHandler);
+ }
+ }
+}
\ No newline at end of file
Added: incubator/flex/whiteboard/tink/iview/src/org/apache/spark/skins/mobile/ViewNavigatorSkin.as
URL: http://svn.apache.org/viewvc/incubator/flex/whiteboard/tink/iview/src/org/apache/spark/skins/mobile/ViewNavigatorSkin.as?rev=1230830&view=auto
==============================================================================
--- incubator/flex/whiteboard/tink/iview/src/org/apache/spark/skins/mobile/ViewNavigatorSkin.as (added)
+++ incubator/flex/whiteboard/tink/iview/src/org/apache/spark/skins/mobile/ViewNavigatorSkin.as Thu Jan 12 23:15:17 2012
@@ -0,0 +1,174 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// 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 org.apache.spark.skins.mobile
+{
+
+ import spark.components.ActionBar;
+ import spark.components.Group;
+ import spark.components.ViewNavigator;
+ import spark.skins.mobile.supportClasses.MobileSkin;
+
+ /**
+ * The ActionScript-based skin for view navigators in mobile
+ * applications. This skin lays out the action bar and content
+ * group in a vertical fashion, where the action bar is on top.
+ * This skin also supports navigator overlay modes.
+ *
+ * @langversion 3.0
+ * @playerversion AIR 2.5
+ * @productversion Flex 4.5
+ */
+ public class ViewNavigatorSkin extends MobileSkin
+ {
+ //--------------------------------------------------------------------------
+ //
+ // Constructor
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * Constructor.
+ *
+ * @langversion 3.0
+ * @playerversion AIR 2.5
+ * @productversion Flex 4.5
+ */
+ public function ViewNavigatorSkin()
+ {
+ super();
+ }
+
+ //--------------------------------------------------------------------------
+ //
+ // Properties
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * @copy spark.components.SkinnableContainer#contentGroup
+ */
+ public var contentGroup:Group;
+
+ /**
+ * @copy spark.components.ViewNavigator#actionBar
+ */
+ public var actionBar:ActionBar;
+
+ //--------------------------------------------------------------------------
+ //
+ // Overridden properties
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * @copy spark.skins.spark.ApplicationSkin#hostComponent
+ */
+ public var hostComponent:ViewNavigator;
+
+ //--------------------------------------------------------------------------
+ //
+ // Methods
+ //
+ //--------------------------------------------------------------------------
+
+ private var _isOverlay:Boolean;
+
+ /**
+ * @private
+ */
+ override protected function createChildren():void
+ {
+ contentGroup = new Group();
+ contentGroup.id = "contentGroup";
+
+ actionBar = new ActionBar();
+ actionBar.id = "actionBar";
+
+ addChild(contentGroup);
+ addChild(actionBar);
+ }
+
+ /**
+ * @private
+ */
+ override protected function measure():void
+ {
+ super.measure();
+
+ measuredWidth = Math.max(actionBar.getPreferredBoundsWidth(),
+ contentGroup.getPreferredBoundsWidth());
+
+ if (currentState == "portraitAndOverlay" || currentState == "landscapeAndOverlay")
+ {
+ measuredHeight = Math.max(actionBar.getPreferredBoundsHeight(),
+ contentGroup.getPreferredBoundsHeight());
+ }
+ else
+ {
+ measuredHeight = actionBar.getPreferredBoundsHeight() +
+ contentGroup.getPreferredBoundsHeight();
+ }
+ }
+
+ /**
+ * @private
+ */
+ override protected function commitCurrentState():void
+ {
+ super.commitCurrentState();
+
+ _isOverlay = (currentState.indexOf("Overlay") >= 1);
+
+ // Force a layout pass on the components
+ invalidateProperties();
+ invalidateSize();
+ invalidateDisplayList();
+ }
+
+ /**
+ * @private
+ */
+ override protected function layoutContents(unscaledWidth:Number, unscaledHeight:Number):void
+ {
+ super.layoutContents(unscaledWidth, unscaledHeight);
+
+ var actionBarHeight:Number = 0;
+
+ // The action bar is always placed at 0,0 and stretches the entire
+ // width of the navigator
+ if (actionBar.includeInLayout)
+ {
+ actionBarHeight = Math.min(actionBar.getPreferredBoundsHeight(), unscaledHeight);
+ actionBar.setLayoutBoundsSize(unscaledWidth, actionBarHeight);
+ actionBar.setLayoutBoundsPosition(0, 0);
+ actionBarHeight = actionBar.getLayoutBoundsHeight();
+
+ // update ActionBar backgroundAlpha when in overlay mode
+ var backgroundAlpha:Number = (_isOverlay) ? 0.75 : 1;
+ actionBar.setStyle("backgroundAlpha", backgroundAlpha);
+ }
+
+ if (contentGroup.includeInLayout)
+ {
+ // If the hostComponent is in overlay mode, the contentGroup extends
+ // the entire bounds of the navigator and the alpha for the action
+ // bar changes
+ // If this changes, also update validateEstimatedSizesOfChild
+ var contentGroupHeight:Number = (_isOverlay) ? unscaledHeight : Math.max(unscaledHeight - actionBarHeight, 0);
+ var contentGroupPosition:Number = (_isOverlay) ? 0 : actionBarHeight;
+
+ contentGroup.setLayoutBoundsSize(unscaledWidth, contentGroupHeight);
+ contentGroup.setLayoutBoundsPosition(0, contentGroupPosition);
+ }
+ }
+ }
+}
\ No newline at end of file