You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by ah...@apache.org on 2017/04/21 16:36:05 UTC
[41/43] git commit: [flex-asjs] [refs/heads/dual] - Merge branch
'develop' into dual
Merge branch 'develop' into dual
Conflicts:
examples/flexjs/MobileTrader/build.xml
frameworks/projects/HTML/src/main/flex/HTMLClasses.as
frameworks/projects/HTML/src/main/flex/org/apache/flex/html/DataGrid.as
frameworks/projects/HTML/src/main/flex/org/apache/flex/html/DateField.as
frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/ContainerView.as
frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/DataGridView.as
frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/layouts/ButtonBarLayout.as
frameworks/projects/HTML/src/main/resources/basic-manifest.xml
Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/1691921e
Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/1691921e
Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/1691921e
Branch: refs/heads/dual
Commit: 1691921e7caa62fbfd7985bd1206462d1df976c5
Parents: 358a06f b1ba88e
Author: Alex Harui <ah...@apache.org>
Authored: Tue Apr 18 23:20:18 2017 -0700
Committer: Alex Harui <ah...@apache.org>
Committed: Tue Apr 18 23:20:18 2017 -0700
----------------------------------------------------------------------
examples/flexjs/MobileTrader/build.xml | 35 +-
.../src/main/flex/MobileTrader.mxml | 3 +
.../src/main/flex/MyInitialView.mxml | 135 ++-
.../flex/controller/DataModelChangeNotifier.as | 71 ++
.../src/main/flex/views/AlertsView.mxml | 23 +-
.../src/main/flex/views/AssetsView.mxml | 21 +-
.../src/main/flex/views/WatchListView.mxml | 24 +-
.../Basic/src/main/flex/BasicClasses.as | 2 +-
.../main/flex/org/apache/flex/core/GroupBase.as | 16 +
.../flex/org/apache/flex/core/LayoutBase.as | 118 ++
.../main/flex/org/apache/flex/html/DataGrid.as | 24 +-
.../main/flex/org/apache/flex/html/DateField.as | 23 +
.../html/beads/AccordionItemRendererView.as | 2 +-
.../org/apache/flex/html/beads/ContainerView.as | 46 +-
.../apache/flex/html/beads/DataContainerView.as | 25 +-
.../org/apache/flex/html/beads/DataGridView.as | 2 +-
.../org/apache/flex/html/beads/GroupView.as | 135 +--
.../flex/html/beads/layouts/ButtonBarLayout.as | 65 +-
.../html/beads/layouts/HorizontalFlexLayout.as | 1 +
.../html/beads/layouts/VerticalFlexLayout.as | 1 +
.../html/supportClasses/MXMLItemRenderer.as | 10 +
.../supportClasses/TextButtonItemRenderer.as | 244 +++++
.../Basic/src/main/resources/basic-manifest.xml | 2 +-
.../Basic/src/main/resources/defaults.css | 1035 ++++++++++--------
.../org/apache/flex/charts/beads/ChartView.as | 28 +-
.../flex/charts/beads/layouts/BarChartLayout.as | 6 +-
.../beads/layouts/BarChartLayoutForArrayList.as | 8 +-
.../charts/beads/layouts/ChartBaseLayout.as | 25 +-
.../charts/beads/layouts/ColumnChartLayout.as | 6 +-
.../layouts/ColumnChartLayoutForArrayList.as | 6 +-
.../layouts/LineChartCategoryVsLinearLayout.as | 6 +-
.../layouts/LineChartLinearVsLinearLayout.as | 6 +-
.../flex/charts/beads/layouts/PieChartLayout.as | 6 +-
.../beads/layouts/PieChartLayoutForArrayList.as | 6 +-
.../beads/layouts/StackedBarChartLayout.as | 6 +-
.../StackedBarChartLayoutForArrayList.as | 6 +-
.../beads/layouts/StackedColumnChartLayout.as | 6 +-
.../StackedColumnChartLayoutForArrayList.as | 6 +-
.../flex/org/apache/flex/core/ILayoutHost.as | 20 +
.../org/apache/flex/utils/MockLayoutHost.as | 10 +
.../org/apache/flex/utils/MockLayoutParent.as | 10 +
.../Express/src/main/resources/defaults.css | 9 +-
.../src/main/resources/express-manifest.xml | 1 +
.../Flat/src/main/resources/defaults.css | 2 +-
.../src/main/flex/FormattersClasses.as | 3 +
.../html/accessories/DateFormatDDMMYYYYBead.as | 46 +
.../html/accessories/DateFormatMMDDYYYYBead.as | 129 +--
.../html/accessories/DateFormatYYYYMMDDBead.as | 46 +
.../html/accessories/SimpleDateFormatBead.as | 222 ++++
.../HTML/src/main/resources/basic-manifest.xml | 2 -
.../HTML/src/main/resources/defaults.css | 15 +-
.../apache/flex/mobile/StackedViewManager.as | 29 +-
.../org/apache/flex/mobile/TabbedViewManager.as | 10 +
.../flex/org/apache/flex/mobile/TitleView.as | 4 -
.../org/apache/flex/mobile/ViewManagerBase.as | 56 +-
.../flex/mobile/beads/StackedViewManagerView.as | 147 ++-
.../flex/mobile/beads/TabbedViewManagerView.as | 127 ++-
.../flex/mobile/beads/ViewManagerViewBase.as | 139 +--
.../Mobile/src/main/resources/defaults.css | 30 +
.../Network/src/main/flex/NetworkClasses.as | 4 +-
.../flex/org/apache/flex/net/BinaryUploader.as | 16 +-
.../flex/org/apache/flex/net/HTTPConstants.as | 30 +-
.../main/flex/org/apache/flex/net/HTTPHeader.as | 23 +-
.../flex/org/apache/flex/net/HTTPService.as | 9 +-
.../main/flex/org/apache/flex/net/HTTPUtils.as | 19 +-
.../flex/org/apache/flex/net/URLBinaryLoader.as | 8 +-
.../main/flex/org/apache/flex/net/URLRequest.as | 32 +-
.../org/apache/flex/net/URLRequestHeader.as | 9 +-
.../main/flex/org/apache/flex/net/URLStream.as | 137 ++-
.../flex/net/beads/CORSCredentialsBead.as | 96 ++
.../src/main/resources/basic-manifest.xml | 1 +
71 files changed, 2369 insertions(+), 1262 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/1691921e/examples/flexjs/MobileTrader/build.xml
----------------------------------------------------------------------
diff --cc examples/flexjs/MobileTrader/build.xml
index e331b36,81fd570..c34f553
--- a/examples/flexjs/MobileTrader/build.xml
+++ b/examples/flexjs/MobileTrader/build.xml
@@@ -29,7 -29,41 +29,40 @@@
<include file="${basedir}/../../build_example.xml" />
- <target name="main" depends="clean,build_example.compile" description="Clean build of ${example}">
+ <condition property="extlib_arg" value="-external-library-path=${FLEXJS_HOME}/js/libs/js.swc" >
+ <and>
+ <not>
+ <isset property="extlib_arg" />
+ </not>
+ <available file="${FLEXJS_HOME}/js/libs/js.swc" type="file" />
+ </and>
+ </condition>
+ <condition property="extlib_arg" value="-external-library-path=${FALCONJX_HOME}/../js/libs/js.swc" >
+ <and>
+ <not>
+ <isset property="extlib_arg" />
+ </not>
+ <available file="${FALCONJX_HOME}/../js/libs/js.swc" type="file" />
+ </and>
+ </condition>
+ <property name="extlib_arg" value="-external-library-path=${FALCONJX_HOME}/../externs/js/out/bin/js.swc"/>
+
- <target name="main" depends="clean,build_example.compile,build_example.compilejs,copyassets" description="Clean build of ${example}">
++ <target name="main" depends="clean,build_example.compile,copyassets" description="Clean build of ${example}">
+ </target>
+
+ <target name="copyassets">
+ <mkdir dir="${basedir}/bin/js-debug/assets" />
+ <copy todir="${basedir}/bin/js-debug/assets" >
+ <fileset dir="${basedir}/src/main/resources/assets">
+ <include name="**" />
+ </fileset>
+ </copy>
+ <mkdir dir="${basedir}/bin/js-release/assets" />
+ <copy todir="${basedir}/bin/js-release/assets" >
+ <fileset dir="${basedir}/src/main/resources/assets">
+ <include name="**" />
+ </fileset>
+ </copy>
</target>
<target name="clean">
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/1691921e/frameworks/projects/Basic/src/main/flex/BasicClasses.as
----------------------------------------------------------------------
diff --cc frameworks/projects/Basic/src/main/flex/BasicClasses.as
index d709608,a81838b..07bb731
--- a/frameworks/projects/Basic/src/main/flex/BasicClasses.as
+++ b/frameworks/projects/Basic/src/main/flex/BasicClasses.as
@@@ -161,7 -152,7 +161,7 @@@ internal class BasicClasse
import org.apache.flex.html.supportClasses.DataGroup; DataGroup;
import org.apache.flex.html.supportClasses.Viewport; Viewport;
import org.apache.flex.html.supportClasses.ScrollingViewport; ScrollingViewport;
-- import org.apache.flex.html.supportClasses.DataGridButtonBarButtonItemRenderer; DataGridButtonBarButtonItemRenderer;
++ import org.apache.flex.html.supportClasses.TextButtonItemRenderer; TextButtonItemRenderer;
import org.apache.flex.html.DataGridButtonBarTextButton; DataGridButtonBarTextButton;
import org.apache.flex.html.DataGridButtonBar; DataGridButtonBar;
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/1691921e/frameworks/projects/Basic/src/main/flex/org/apache/flex/core/GroupBase.as
----------------------------------------------------------------------
diff --cc frameworks/projects/Basic/src/main/flex/org/apache/flex/core/GroupBase.as
index e4dfb1f,0000000..07859a1
mode 100644,000000..100644
--- a/frameworks/projects/Basic/src/main/flex/org/apache/flex/core/GroupBase.as
+++ b/frameworks/projects/Basic/src/main/flex/org/apache/flex/core/GroupBase.as
@@@ -1,280 -1,0 +1,296 @@@
+////////////////////////////////////////////////////////////////////////////////
+//
+// 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.core
+{
+ import org.apache.flex.core.IContentViewHost;
+ import org.apache.flex.core.ILayoutParent;
+ import org.apache.flex.core.ILayoutHost;
+ import org.apache.flex.core.ILayoutView;
+ import org.apache.flex.core.ValuesManager;
+ import org.apache.flex.events.Event;
+ import org.apache.flex.events.ValueChangeEvent;
+ import org.apache.flex.states.State;
+ import org.apache.flex.utils.MXMLDataInterpreter;
+
+ /**
+ * Indicates that the state change has completed. All properties
+ * that need to change have been changed, and all transitinos
+ * that need to run have completed. However, any deferred work
+ * may not be completed, and the screen may not be updated until
+ * code stops executing.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion FlexJS 0.8
+ */
+ [Event(name="stateChangeComplete", type="org.apache.flex.events.Event")]
+
+ /**
+ * Indicates that the initialization of the container is complete.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion FlexJS 0.8
+ */
+ [Event(name="initComplete", type="org.apache.flex.events.Event")]
+
+ /**
+ * Indicates that the children of the container is have been added.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion FlexJS 0.8
+ */
+ [Event(name="childrenAdded", type="org.apache.flex.events.Event")]
+
+ /**
+ * The GroupBase class is the base class for most simple containers
+ * in FlexJS. It is usable as the root tag of MXML
+ * documents and UI controls and containers are added to it.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion FlexJS 0.8
+ */
+ public class GroupBase extends UIBase implements IStatesObject, IContainer, ILayoutParent, ILayoutView, IContentViewHost
+ {
+ /**
+ * Constructor.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion FlexJS 0.8
+ */
+ public function GroupBase()
+ {
+ super();
+ }
+
+ /**
+ * @flexjsignorecoercion org.apache.flex.core.WrappedHTMLElement
+ */
+ COMPILE::JS
+ override protected function createElement():WrappedHTMLElement
+ {
+ element = document.createElement('div') as WrappedHTMLElement;
+ element.flexjs_wrapper = this;
+
+ positioner = element;
+
+ return element;
+ }
+
++ override public function addedToParent():void
++ {
++ super.addedToParent();
++
++ // Load the layout bead if it hasn't already been loaded.
++ var layout:IBeadLayout = getBeadByType(IBeadLayout) as IBeadLayout;
++ if (!layout)
++ {
++ var c:Class = ValuesManager.valuesImpl.getValue(this, "iBeadLayout") as Class;
++ if (c) {
++ layout = new c() as IBeadLayout;
++ addBead(layout);
++ }
++ }
++ }
++
+ /*
+ * IContainer
+ */
+
+ /**
+ * @private
+ */
+ public function childrenAdded():void
+ {
+ dispatchEvent(new Event("childrenAdded"));
+ }
+
+ /*
+ * Utility
+ */
+
+ /**
+ * Dispatches a "layoutNeeded" event
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion FlexJS 0.8
+ */
+ public function layoutNeeded():void
+ {
+ dispatchEvent( new Event("layoutNeeded") );
+ }
+
+ /*
+ * ILayoutParent
+ */
+
+ /**
+ * Returns the ILayoutHost which is its view. From ILayoutParent.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion FlexJS 0.8
+ */
+ public function getLayoutHost():ILayoutHost
+ {
+ return view as ILayoutHost;
+ }
+
+ /**
+ * @copy org.apache.flex.core.IContentViewHost#strandChildren
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion FlexJS 0.8
+ */
+ public function get strandChildren():IParent
+ {
+ return this;
+ }
+
+ private var _states:Array;
+
+ /**
+ * The array of view states. These should
+ * be instances of org.apache.flex.states.State.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion FlexJS 0.8
+ */
+ public function get states():Array
+ {
+ return _states;
+ }
+
+ /**
+ * @private
+ * @flexjsignorecoercion Class
+ * @flexjsignorecoercion org.apache.flex.core.IBead
+ */
+ public function set states(value:Array):void
+ {
+ _states = value;
+ _currentState = _states[0].name;
+
+ try{
+ if (getBeadByType(IStatesImpl) == null)
+ {
+ var c:Class = ValuesManager.valuesImpl.getValue(this, "iStatesImpl") as Class;
+ var b:Object = new c();
+ addBead(b as IBead);
+ }
+ }
+ //TODO: Need to handle this case more gracefully
+ catch(e:Error)
+ {
+ COMPILE::SWF
+ {
+ trace(e.message);
+ }
+ }
+
+ }
+
+ /**
+ * <code>true</code> if the array of states
+ * contains a state with this name.
+ *
+ * @param state The state namem.
+ * @return True if state in state array
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion FlexJS 0.8
+ */
+ public function hasState(state:String):Boolean
+ {
+ for each (var s:State in _states)
+ {
+ if (s.name == state)
+ return true;
+ }
+ return false;
+ }
+
+ private var _currentState:String;
+
+ [Bindable("currentStateChange")]
+ /**
+ * The name of the current state.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion FlexJS 0.8
+ */
+ public function get currentState():String
+ {
+ return _currentState;
+ }
+
+ /**
+ * @private
+ */
+ public function set currentState(value:String):void
+ {
+ var event:ValueChangeEvent = new ValueChangeEvent("currentStateChange", false, false, _currentState, value)
+ _currentState = value;
+ dispatchEvent(event);
+ }
+
+ private var _transitions:Array;
+
+ /**
+ * The array of transitions.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion FlexJS 0.8
+ */
+ public function get transitions():Array
+ {
+ return _transitions;
+ }
+
+ /**
+ * @private
+ */
+ public function set transitions(value:Array):void
+ {
+ _transitions = value;
+ }
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/1691921e/frameworks/projects/Basic/src/main/flex/org/apache/flex/core/LayoutBase.as
----------------------------------------------------------------------
diff --cc frameworks/projects/Basic/src/main/flex/org/apache/flex/core/LayoutBase.as
index dde6448,0000000..f23f035
mode 100644,000000..100644
--- a/frameworks/projects/Basic/src/main/flex/org/apache/flex/core/LayoutBase.as
+++ b/frameworks/projects/Basic/src/main/flex/org/apache/flex/core/LayoutBase.as
@@@ -1,166 -1,0 +1,284 @@@
+////////////////////////////////////////////////////////////////////////////////
+//
+// 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.core
+{
+
+ import org.apache.flex.core.IBeadLayout;
+ import org.apache.flex.core.ILayoutChild;
+ import org.apache.flex.core.ILayoutHost;
+ import org.apache.flex.core.ILayoutParent;
+ import org.apache.flex.core.ILayoutView;
+ import org.apache.flex.core.IParent;
+ import org.apache.flex.core.IStrand;
+ import org.apache.flex.core.ValuesManager;
++ import org.apache.flex.events.IEventDispatcher;
++ import org.apache.flex.events.Event;
+ import org.apache.flex.utils.CSSUtils;
+
+ /**
+ * This class is the base class for most, if not all, layouts.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion FlexJS 0.8
+ */
+ public class LayoutBase implements IBeadLayout
+ {
+ /**
+ * Constructor.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion FlexJS 0.8
+ */
+ public function LayoutBase()
+ {
+ }
+
+ /**
+ * The strand/host container is also an ILayoutChild because
+ * it can have its size dictated by the host's parent which is
+ * important to know for layout optimization.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion FlexJS 0.8
+ */
+ protected var host:ILayoutChild;
+
+ /**
+ * @copy org.apache.flex.core.IBead#strand
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion FlexJS 0.8
+ *
+ * @flexjsignorecoercion org.apache.flex.core.ILayoutChild
+ */
+ public function set strand(value:IStrand):void
+ {
+ host = value as ILayoutChild;
++
++ IEventDispatcher(host).addEventListener("widthChanged", handleSizeChange);
++ IEventDispatcher(host).addEventListener("heightChanged", handleSizeChange);
++ IEventDispatcher(host).addEventListener("sizeChanged", handleSizeChange);
++
++ IEventDispatcher(host).addEventListener("childrenAdded", handleChildrenAdded);
++ IEventDispatcher(host).addEventListener("initComplete", handleInitComplete);
++
++ IEventDispatcher(host).addEventListener("layoutNeeded", handleLayoutNeeded);
++ }
++
++ /**
++ * Changes in size to the host strand are handled (by default) by running the
++ * layout sequence. Subclasses can override this function and use event.type
++ * to handle specific changes in dimension.
++ *
++ * @langversion 3.0
++ * @playerversion Flash 10.2
++ * @playerversion AIR 2.6
++ * @productversion FlexJS 0.8
++ */
++ protected function handleSizeChange(event:Event):void
++ {
++ performLayout();
++ }
++
++ /**
++ * Handles the addition of children to the host's layoutView by listening for
++ * size changes in the children.
++ *
++ * @langversion 3.0
++ * @playerversion Flash 10.2
++ * @playerversion AIR 2.6
++ * @productversion FlexJS 0.8
++ */
++ protected function handleChildrenAdded(event:Event):void
++ {
++ COMPILE::SWF {
++ var n:Number = layoutView.numElements;
++ for(var i:int=0; i < n; i++) {
++ var child:IEventDispatcher = layoutView.getElementAt(i) as IEventDispatcher;
++ child.addEventListener("widthChanged", childResizeHandler);
++ child.addEventListener("heightChanged", childResizeHandler);
++ child.addEventListener("sizeChanged", childResizeHandler);
++ }
++ }
++ }
++
++ /**
++ * If changes happen to a layoutView's child, this function will perform the
++ * layout again.
++ *
++ * @langversion 3.0
++ * @playerversion Flash 10.2
++ * @playerversion AIR 2.6
++ * @productversion FlexJS 0.8
++ */
++ protected function childResizeHandler(event:Event):void
++ {
++ performLayout();
++ }
++
++ /**
++ * Called whenever "layoutNeeded" event is dispatched against the host strand.
++ *
++ * @langversion 3.0
++ * @playerversion Flash 10.2
++ * @playerversion AIR 2.6
++ * @productversion FlexJS 0.8
++ */
++ protected function handleLayoutNeeded(event:Event):void
++ {
++ performLayout();
++ }
++
++ /**
++ * Handles the final start-up condition by running the layout an initial time.
++ *
++ * @langversion 3.0
++ * @playerversion Flash 10.2
++ * @playerversion AIR 2.6
++ * @productversion FlexJS 0.8
++ */
++ protected function handleInitComplete(event:Event):void
++ {
++ performLayout();
+ }
+
+ /**
+ * Returns an object of margins for the given child.
+ *
+ * @param child Object The element whose margins are required.
+ * @param hostWidth Number The usable width dimension of the host.
+ * @param hostHeight Number The usable height dimension of the host.
+ *
+ * @return Object A structure of {top:Number, left:Number, bottom:Number, right:Number}
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion FlexJS 0.8
+ */
+ protected function childMargins(child:Object, hostWidth:Number, hostHeight:Number):Object
+ {
+ var margin:Object = ValuesManager.valuesImpl.getValue(child, "margin");
+ var marginLeft:Object = ValuesManager.valuesImpl.getValue(child, "margin-left");
+ var marginTop:Object = ValuesManager.valuesImpl.getValue(child, "margin-top");
+ var marginRight:Object = ValuesManager.valuesImpl.getValue(child, "margin-right");
+ var marginBottom:Object = ValuesManager.valuesImpl.getValue(child, "margin-bottom");
+ var ml:Number = CSSUtils.getLeftValue(marginLeft, margin, hostWidth);
+ var mr:Number = CSSUtils.getRightValue(marginRight, margin, hostWidth);
+ var mt:Number = CSSUtils.getTopValue(marginTop, margin, hostHeight);
+ var mb:Number = CSSUtils.getBottomValue(marginBottom, margin, hostHeight);
+ if (marginLeft == "auto")
+ ml = 0;
+ if (marginRight == "auto")
+ mr = 0;
+
+ return {left:ml, top:mt, right:mr, bottom:mb};
+ }
+
+ /**
+ * Returns an object containing the child's positioning values.
+ *
+ * @param child Object The element whose positions are required.
+ *
+ * @return Object A structure of {top:Number, left:Number, bottom:Number, right:Number}
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion FlexJS 0.8
+ */
+ protected function childPositions(child:Object):Object
+ {
+ var left:Number = ValuesManager.valuesImpl.getValue(child, "left");
+ var right:Number = ValuesManager.valuesImpl.getValue(child, "right");
+ var top:Number = ValuesManager.valuesImpl.getValue(child, "top");
+ var bottom:Number = ValuesManager.valuesImpl.getValue(child, "bottom");
+
+ return {top:top, left:left, bottom:bottom, right:right};
+ }
+
+ /**
+ * Returns the ILayoutView for the host.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion FlexJS 0.8
+ *
+ * @flexjsignorecoercion org.apache.flex.core.ILayoutParent
+ */
+ protected function get layoutView():ILayoutView
+ {
+ var viewBead:ILayoutHost = (host as ILayoutParent).getLayoutHost();
+ return viewBead.contentView;
+ }
++
++ private var isLayoutRunning:Boolean = false;
++
++ /**
++ * Performs the layout in three parts: before, layout, after.
++ *
++ * @langversion 3.0
++ * @playerversion Flash 10.2
++ * @playerversion AIR 2.6
++ * @productversion FlexJS 0.8
++ */
++ public function performLayout():void
++ {
++ // avoid running this layout instance recursively.
++ if (isLayoutRunning) return;
++
++ isLayoutRunning = true;
++
++ var viewBead:ILayoutHost = (host as ILayoutParent).getLayoutHost();
++
++ viewBead.beforeLayout();
++
++ if (layout()) {
++ viewBead.afterLayout();
++ }
++
++ isLayoutRunning = false;
++
++ IEventDispatcher(host).dispatchEvent(new Event("layoutComplete"));
++ }
+
+ /**
+ * @copy org.apache.flex.core.IBeadLayout#layout
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion FlexJS 0.8
+ */
+ public function layout():Boolean
+ {
+ // override in subclass
+ return false;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/1691921e/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/DataGrid.as
----------------------------------------------------------------------
diff --cc frameworks/projects/Basic/src/main/flex/org/apache/flex/html/DataGrid.as
index fda1b46,c271134..5a17c4a
--- a/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/DataGrid.as
+++ b/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/DataGrid.as
@@@ -22,8 -22,7 +22,10 @@@ package org.apache.flex.htm
import org.apache.flex.core.IDataGridModel;
import org.apache.flex.core.IDataGridPresentationModel;
import org.apache.flex.core.UIBase;
++ import org.apache.flex.core.GroupBase;
+ import org.apache.flex.core.ValuesManager;
import org.apache.flex.html.beads.models.DataGridPresentationModel;
++ import org.apache.flex.events.Event;
[Event(name="change", type="org.apache.flex.events.Event")]
@@@ -41,7 -39,7 +43,7 @@@
* @playerversion AIR 2.6
* @productversion FlexJS 0.0
*/
- public class DataGrid extends Group
- public class DataGrid extends UIBase
++ public class DataGrid extends GroupBase
{
/**
* constructor.
@@@ -160,24 -143,24 +162,10 @@@
presentationModel.rowHeight = value;
}
-- /**
-- * @private
-- * The DataGrid needs to know whenever its size is being changed so the columns can be
-- * be aligned properly, so the noEvent value must always be false.
-- */
-- override public function setWidth(value:Number, noEvent:Boolean=false):void
-- {
-- super.setWidth(value,false);
-- }
--
-- /**
-- * @private
-- * The DataGrid needs to know whenever its size is being changed so the columns can be
-- * be aligned properly, so the noEvent value must always be false.
-- */
-- override public function setHeight(value:Number, noEvent:Boolean=false):void
++ override public function addedToParent():void
{
-- super.setHeight(value,false);
++ super.addedToParent();
++ dispatchEvent(new Event("initComplete"));
}
}
}
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/1691921e/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/DateField.as
----------------------------------------------------------------------
diff --cc frameworks/projects/Basic/src/main/flex/org/apache/flex/html/DateField.as
index f46e453,ca142ba..5b73db0
--- a/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/DateField.as
+++ b/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/DateField.as
@@@ -33,6 -34,6 +34,7 @@@ package org.apache.flex.htm
* and a pop-up calendar control for picking a date as an alternative to
* the text field.
*
++ * @toplevel
* @langversion 3.0
* @playerversion Flash 10.2
* @playerversion AIR 2.6
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/1691921e/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/AccordionItemRendererView.as
----------------------------------------------------------------------
diff --cc frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/AccordionItemRendererView.as
index bc9f89d,0000000..85e2b79
mode 100644,000000..100644
--- a/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/AccordionItemRendererView.as
+++ b/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/AccordionItemRendererView.as
@@@ -1,66 -1,0 +1,66 @@@
+////////////////////////////////////////////////////////////////////////////////
+//
+// 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.html.beads
+{
+ import org.apache.flex.events.Event;
+ import org.apache.flex.html.supportClasses.ICollapsible;
+
+ /**
+ * This class creates and manages the contents of an AccordionItemItemRenderer
+ *
+ * @viewbead
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion FlexJS 0.0
+ */
+ public class AccordionItemRendererView extends PanelView
+ {
+ /**
+ * The AccordionItemRendererView class is the default view for
+ * the org.apache.flex.html.supportClasses.AccordionItemRenderer classes.
+ * It provides some layout optimizations that can be attained by assuming
+ * the strand to be an org.apache.flex.html.supportClasses.ICollapsible.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion FlexJS 0.0
+ */
+ public function AccordionItemRendererView()
+ {
+ super();
+ }
+
+ override protected function performLayout(event:Event):void
+ {
+ var collapsibleStrand:ICollapsible = _strand as ICollapsible;
+ if (!collapsibleStrand.collapsed)
+ {
+ super.performLayout(event);
+ } else // skip layout for viewport children
+ {
+ COMPILE::SWF {
+ // no longer needed layoutViewBeforeContentLayout();
- layoutViewAfterContentLayout();
++ afterLayout();
+ }
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/1691921e/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/ContainerView.as
----------------------------------------------------------------------
diff --cc frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/ContainerView.as
index 4de5634,d62e799..ac723a9
--- a/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/ContainerView.as
+++ b/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/ContainerView.as
@@@ -160,15 -274,49 +160,15 @@@ package org.apache.flex.html.bead
* @playerversion AIR 2.6
* @productversion FlexJS 0.0
*/
- protected function completeSetup():void
+ override protected function completeSetup():void
{
+ super.completeSetup();
+
// when the first layout is complete, set up listeners for changes
// to the childrens' sizes.
-- host.addEventListener("layoutComplete", childrenChangedHandler);
-
- host.addEventListener("childrenAdded", performLayout);
- host.addEventListener("layoutNeeded", performLayout);
- host.addEventListener("widthChanged", resizeHandler);
- host.addEventListener("heightChanged", resizeHandler);
- host.addEventListener("sizeChanged", resizeHandler);
- host.addEventListener("viewCreated", viewCreatedHandler);
- }
-
- /**
- * Handles the viewCreated event by performing the first layout if
- * there are children already present (ie, from MXML).
- *
- * @langversion 3.0
- * @playerversion Flash 10.2
- * @playerversion AIR 2.6
- * @productversion FlexJS 0.0
- */
- protected function viewCreatedHandler(event:Event):void
- {
- if ((host as UIBase).numElements > 0) {
- performLayout(null);
- }
++// host.addEventListener("layoutComplete", childrenChangedHandler);
}
-
- /**
- * Calculate the space taken up by non-content children like a TItleBar in a Panel.
- *
- * @langversion 3.0
- * @playerversion Flash 10.2
- * @playerversion AIR 2.6
- * @productversion FlexJS 0.0
- */
- protected function getChromeMetrics():Rectangle
- {
- return new Rectangle(0, 0, 0, 0);
- }
-
+
/**
* Creates the Viewport (or ScrollableViewport) through which the content
* area is presented.
@@@ -229,22 -391,32 +229,22 @@@
* @playerversion AIR 2.6
* @productversion FlexJS 0.0
*/
- override protected function layoutViewBeforeContentLayout():void
- protected function performLayout(event:Event):void
++ override public function beforeLayout():void
{
- layoutRunning = true;
-
- layoutViewBeforeContentLayout();
-
- var host:UIBase = _strand as UIBase;
-
- var layout:IBeadLayout = _strand.getBeadByType(IBeadLayout) as IBeadLayout;
- if (layout == null) {
- var c:Class = ValuesManager.valuesImpl.getValue(host, "iBeadLayout");
- if (c) {
- layout = new c() as IBeadLayout;
- _strand.addBead(layout);
- }
- }
-
- if (layout) {
- layout.layout();
- }
-
- layoutViewAfterContentLayout();
-
- layoutRunning = false;
+ var host:ILayoutChild = this.host as ILayoutChild;
+ var vm:IViewportModel = viewportModel;
+ var hostWidth:Number = host.width;
+ var hostHeight:Number = host.height;
+
+ vm.borderMetrics = CSSContainerUtils.getBorderMetrics(host);
+
+ viewport.setPosition(vm.borderMetrics.left, vm.borderMetrics.top);
+
+ viewport.layoutViewportBeforeContentLayout(
+ host.isWidthSizedToContent() ? NaN : hostWidth - vm.borderMetrics.left - vm.borderMetrics.right,
+ host.isHeightSizedToContent() ? NaN : hostHeight - vm.borderMetrics.top - vm.borderMetrics.bottom);
}
-
+
/**
* @private
*/
@@@ -259,20 -431,35 +259,20 @@@
* @playerversion AIR 2.6
* @productversion FlexJS 0.0
*/
- override protected function layoutViewAfterContentLayout():void
- protected function layoutViewAfterContentLayout():void
++ override public function afterLayout():void
{
- var host:UIBase = _strand as UIBase;
- var vm:IViewportModel = viewportModel;
-
+ if (adjusting) return;
+
adjusting = true;
-
- var viewportSize:Size = viewport.layoutViewportAfterContentLayout();
-
- if (host.isWidthSizedToContent() && host.isHeightSizedToContent()) {
- host.setWidthAndHeight(viewportSize.width + vm.borderMetrics.left + vm.borderMetrics.right +
- vm.chromeMetrics.left + vm.chromeMetrics.right,
- viewportSize.height + vm.borderMetrics.top + vm.borderMetrics.bottom +
- vm.chromeMetrics.top + vm.chromeMetrics.bottom,
- false);
- }
- else if (!host.isWidthSizedToContent() && host.isHeightSizedToContent())
- {
- host.setHeight(viewportSize.height + vm.borderMetrics.top + vm.borderMetrics.bottom +
- vm.chromeMetrics.top + vm.chromeMetrics.bottom, false);
- }
- else if (host.isWidthSizedToContent() && !host.isHeightSizedToContent())
- {
- host.setWidth(viewportSize.width + vm.borderMetrics.left + vm.borderMetrics.right +
- vm.chromeMetrics.left + vm.chromeMetrics.right, false);
- }
+
- super.layoutViewAfterContentLayout();
++ super.afterLayout();
+
+ var contentSize:Size = calculateContentSize();
+ viewport.layoutViewportAfterContentLayout(contentSize);
+
adjusting = false;
}
-
+
/**
* Handles dynamic changes to the host's size by running the layout once
* the viewport has been adjusted.
@@@ -282,54 -469,11 +282,54 @@@
* @playerversion AIR 2.6
* @productversion FlexJS 0.0
*/
- override protected function resizeHandler(event:Event):void
- {
- if (!adjusting) {
- performLayout(event);
- }
- }
- protected function resizeHandler(event:Event):void
++// override protected function resizeHandler(event:Event):void
++// {
++// if (!adjusting) {
++// performLayout(event);
++// }
++// }
+
+ /**
+ * Whenever children are added, listeners are added to detect changes
+ * in their size.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion FlexJS 0.0
+ */
- protected function childrenChangedHandler(event:Event):void
- {
- var host:UIBase = _strand as UIBase;
- host.removeEventListener(event.type, childrenChangedHandler);
-
- var n:Number = contentView.numElements;
- for (var i:int=0; i < n; i++) {
- var child:IUIBase = contentView.getElementAt(i) as IUIBase;
- child.addEventListener("widthChanged", childResizeHandler);
- child.addEventListener("heightChanged", childResizeHandler);
- child.addEventListener("sizeChanged", childResizeHandler);
- }
- }
++// protected function childrenChangedHandler(event:Event):void
++// {
++// var host:UIBase = _strand as UIBase;
++// host.removeEventListener(event.type, childrenChangedHandler);
++//
++// var n:Number = contentView.numElements;
++// for (var i:int=0; i < n; i++) {
++// var child:IUIBase = contentView.getElementAt(i) as IUIBase;
++// child.addEventListener("widthChanged", childResizeHandler);
++// child.addEventListener("heightChanged", childResizeHandler);
++// child.addEventListener("sizeChanged", childResizeHandler);
++// }
++// }
+ }
+
+ COMPILE::JS
+ public class ContainerView extends GroupView //??implements IParent
+ {
+ private var _viewport:IViewport;
+
+ /**
+ * The viewport used to present the content and may display
+ * scroll bars (depending on the actual type of viewport).
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion FlexJS 0.0
+ */
+ protected function get viewport():IViewport
{
- if (!adjusting) {
- performLayout(event);
- }
+ return _viewport;
}
/**
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/1691921e/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/DataContainerView.as
----------------------------------------------------------------------
diff --cc frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/DataContainerView.as
index 36ed489,0000000..fc5f3a2
mode 100644,000000..100644
--- a/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/DataContainerView.as
+++ b/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/DataContainerView.as
@@@ -1,230 -1,0 +1,233 @@@
+////////////////////////////////////////////////////////////////////////////////
+//
+// 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.html.beads
+{
+ import org.apache.flex.core.BeadViewBase;
+ import org.apache.flex.core.ContainerBase;
+ import org.apache.flex.core.IBead;
+ import org.apache.flex.core.IBeadLayout;
+ import org.apache.flex.core.IBeadModel;
+ import org.apache.flex.core.IBeadView;
- import org.apache.flex.core.IList;
- import org.apache.flex.core.ISelectableItemRenderer;
++ import org.apache.flex.core.IDataProviderModel;
+ import org.apache.flex.core.IItemRenderer;
+ import org.apache.flex.core.IItemRendererParent;
++ import org.apache.flex.core.IList;
+ import org.apache.flex.core.IParent;
- import org.apache.flex.core.IParentIUIBase;
- import org.apache.flex.core.IDataProviderModel;
++ import org.apache.flex.core.IParentIUIBase;
++ import org.apache.flex.core.ISelectableItemRenderer;
+ import org.apache.flex.core.ISelectionModel;
+ import org.apache.flex.core.IStrand;
- import org.apache.flex.core.IUIBase;
++ import org.apache.flex.core.IUIBase;
++ import org.apache.flex.core.LayoutBase;
+ import org.apache.flex.core.Strand;
+ import org.apache.flex.core.UIBase;
+ import org.apache.flex.core.ValuesManager;
+ import org.apache.flex.events.Event;
+ import org.apache.flex.events.IEventDispatcher;
+ import org.apache.flex.html.beads.models.ScrollBarModel;
+ import org.apache.flex.html.beads.models.SingleLineBorderModel;
+ import org.apache.flex.html.supportClasses.Border;
+ import org.apache.flex.html.supportClasses.DataGroup;
+ import org.apache.flex.html.supportClasses.ScrollBar;
+
+ /**
+ * The DataContainerView provides the visual elements for the DataContainer.
+ *
+ * @viewbead
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion FlexJS 0.8
+ */
+ COMPILE::JS
+ public class DataContainerView extends ContainerView implements IListView
+ {
+ public function DataContainerView()
+ {
+ super();
+ }
+
+ /**
+ * @copy org.apache.flex.core.IBead#strand
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion FlexJS 0.8
+ */
+ override public function set strand(value:IStrand):void
+ {
+ _strand = value;
+ super.strand = value;
+
+ host.addEventListener("beadsAdded", beadsAddedHandler);
+ }
+
+ protected var dataModel:IDataProviderModel;
+
+ /**
+ * @flexjsignorecoercion org.apache.flex.core.IItemRendererParent
+ */
+ public function get dataGroup():IItemRendererParent
+ {
+ return super.contentView as IItemRendererParent;
+ }
+
+ protected function beadsAddedHandler(event:Event):void
+ {
+ dataModel = _strand.getBeadByType(IDataProviderModel) as IDataProviderModel;
+ host.addEventListener("itemsCreated", itemsCreatedHandler);
+ dataModel.addEventListener("dataProviderChanged", dataProviderChangeHandler);
+ }
+
+ /**
+ * @private
+ */
+ override protected function handleInitComplete(event:Event):void
+ {
+ super.handleInitComplete(event);
+ }
+
+ /**
+ * @private
+ */
+ protected function itemsCreatedHandler(event:Event):void
+ {
- performLayout(event);
++ trace("DataContainerView: itemsCreatedHandler");
++ host.dispatchEvent(new Event("layoutNeeded"));
+ }
+
+ /**
+ * @private
+ */
+ protected function dataProviderChangeHandler(event:Event):void
+ {
++ trace("DataContainerView: dataProviderChangeHandler");
+ performLayout(event);
+ }
+ }
+
+ COMPILE::SWF
+ public class DataContainerView extends ContainerView implements IListView
+ {
+ public function DataContainerView()
+ {
+ super();
+ }
+
+ protected var dataModel:IDataProviderModel;
+
+ /**
+ * @private
+ */
+ override public function get host():IUIBase
+ {
+ return _strand as IUIBase;
+ }
+
+ /**
+ * @copy org.apache.flex.core.IBead#strand
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion FlexJS 0.8
+ */
+ override public function set strand(value:IStrand):void
+ {
+ _strand = value;
+ super.strand = value;
+
+ host.addEventListener("beadsAdded", beadsAddedHandler);
++ host.addEventListener("itemsCreated", itemsCreatedHandler);
+ }
+
+ override protected function completeSetup():void
+ {
+ super.completeSetup();
+
+ // list is not interested in UI children, it wants to know when new items
+ // have been added or the dataProvider has changed.
- host.removeEventListener("childrenAdded", childrenChangedHandler);
- host.removeEventListener("childrenAdded", performLayout);
- host.addEventListener("itemsCreated", itemsCreatedHandler);
++// host.removeEventListener("childrenAdded", childrenChangedHandler);
++// host.removeEventListener("childrenAdded", performLayout);
+ }
+
+ protected function beadsAddedHandler(event:Event):void
+ {
+ dataModel = _strand.getBeadByType(IDataProviderModel) as IDataProviderModel;
+ dataModel.addEventListener("dataProviderChanged", dataProviderChangeHandler);
+ }
+
+ override protected function handleInitComplete(event:Event):void
+ {
+ super.handleInitComplete(event);
+ }
+
+ /**
+ * The area holding the itemRenderers.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion FlexJS 0.8
+ */
+ public function get dataGroup():IItemRendererParent
+ {
+ return super.contentView as IItemRendererParent;
+ }
+
+ /**
+ * @private
+ */
+ override public function get resizableView():IUIBase
+ {
+ return _strand as IUIBase;
+ }
+
+ /**
+ * @private
+ */
+ protected function itemsCreatedHandler(event:Event):void
+ {
- performLayout(event);
++ host.dispatchEvent(new Event("layoutNeeded"));
+ }
+
+ /**
+ * @private
+ */
+ protected function dataProviderChangeHandler(event:Event):void
+ {
- performLayout(event);
++ host.dispatchEvent(new Event("layoutNeeded"));
+ }
+
+ /**
+ * respond to a change in size or request to re-layout everything
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion FlexJS 0.0
+ */
+ override protected function resizeHandler(event:Event):void
+ {
+ // might need to do something here, not sure yet.
+ super.resizeHandler(event);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/1691921e/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/DataGridView.as
----------------------------------------------------------------------
diff --cc frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/DataGridView.as
index 68e5d95,8393057..3b387d9
--- a/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/DataGridView.as
+++ b/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/DataGridView.as
@@@ -52,249 -115,152 +52,249 @@@ package org.apache.flex.html.bead
* @playerversion AIR 2.6
* @productversion FlexJS 0.0
*/
- public function set strand(value:IStrand):void
+ public class DataGridView extends GroupView implements IBeadView
{
- _strand = value;
-
- var host:UIBase = value as UIBase;
-
- _header = new DataGridButtonBar();
- _header.id = "dataGridHeader";
-
- var scrollPort:ScrollingViewport = new ScrollingViewport();
-
- _listArea = new Container();
- _listArea.id = "dataGridListArea";
- _listArea.className = "DataGridListArea";
- _listArea.addBead(scrollPort);
+ /**
+ * constructor.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion FlexJS 0.0
+ */
+ public function DataGridView()
+ {
+ super();
+ }
- if (_strand.getBeadByType(IBeadLayout) == null) {
- var c:Class = ValuesManager.valuesImpl.getValue(host, "iBeadLayout");
- if (c)
- {
- var layout:IBeadLayout = new c() as IBeadLayout;
- _strand.addBead(layout);
+ private var _strand:IStrand;
+ private var _header:DataGridButtonBar;
+ private var _listArea:Container;
+
+ private var _lists:Array;
+
+ /**
+ * An array of List objects the comprise the columns of the DataGrid.
+ */
+ public function get columnLists():Array
+ {
+ return _lists;
+ }
+
+ /**
+ * The area used to hold the columns
+ *
+ */
+ public function get listArea():Container
+ {
+ return _listArea;
+ }
+
+ /**
+ * Returns the component used as the header for the DataGrid.
+ */
+ public function get header():IUIBase
+ {
+ return _header;
+ }
+
+ /**
+ * @copy org.apache.flex.core.IBead#strand
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion FlexJS 0.0
+ */
+ override public function set strand(value:IStrand):void
+ {
+ super.strand = value;
+ _strand = value;
+
+ var host:DataGrid = value as DataGrid;
+
+ _header = new DataGridButtonBar();
+ _header.height = 30;
+ _header.percentWidth = 100;
+
+ _listArea = new Container();
+ _listArea.percentWidth = 100;
+ _listArea.className = "DataGridListArea";
+
+ COMPILE::SWF {
+ _header.style = new SimpleCSSStyles();
+ _header.style.flexGrow = 0;
+
+ _listArea.style = new SimpleCSSStyles();
+ _listArea.style.flexGrow = 1;
}
+ COMPILE::JS {
+ _header.element.style["flex-grow"] = "0";
+ _header.element.style["min-height"] = "30px";
+ _listArea.element.style["flex-grow"] = "1";
+ }
+
- IEventDispatcher(_strand).addEventListener("initComplete", finishSetup);
++ IEventDispatcher(_strand).addEventListener("beadsAdded", finishSetup);
}
-
- finishSetup(null);
- }
-
- /**
- * @private
- */
- private function finishSetup(event:Event):void
- {
- var host:UIBase = _strand as UIBase;
-
- // see if there is a presentation model already in place. if not, add one.
- var presentationModel:DataGridPresentationModel = _strand.getBeadByType(DataGridPresentationModel) as DataGridPresentationModel;
- if (presentationModel == null) {
- presentationModel = new DataGridPresentationModel();
- _strand.addBead(presentationModel);
+
+ /**
+ * @private
+ */
+ private function finishSetup(event:Event):void
+ {
+ var host:DataGrid = _strand as DataGrid;
+
+ if (_lists == null || _lists.length == 0) {
+ createLists();
+ }
+
+ // see if there is a presentation model already in place. if not, add one.
+ var presentationModel:IDataGridPresentationModel = host.presentationModel;
+ var sharedModel:IDataGridModel = host.model as IDataGridModel;
+ IEventDispatcher(sharedModel).addEventListener("dataProviderChanged",handleDataProviderChanged);
+ IEventDispatcher(sharedModel).addEventListener("selectedIndexChanged", handleSelectedIndexChanged);
+
+ var columnLabels:Array = new Array();
+ var buttonWidths:Array = new Array();
+
+ var marginBorderOffset:int = 0;
+ COMPILE::SWF {
+ marginBorderOffset = 1;
+ }
+
+ for(var i:int=0; i < sharedModel.columns.length; i++) {
+ var dgc:DataGridColumn = sharedModel.columns[i] as DataGridColumn;
+ columnLabels.push(dgc.label);
+ var colWidth:Number = dgc.columnWidth - marginBorderOffset;
+ buttonWidths.push(colWidth);
+
+ var list:DataGridColumnList = _lists[i] as DataGridColumnList;
+ if (!isNaN(colWidth)) {
+ list.width = Number(colWidth - marginBorderOffset);
+ } else {
+ COMPILE::SWF {
+ list.style = new SimpleCSSStyles();
+ list.style.flexGrow = 1;
+ }
+ COMPILE::JS {
+ list.element.style["flex-grow"] = "1";
+ }
+ }
+ }
+
+ var bblayout:ButtonBarLayout = new ButtonBarLayout();
+ _header.buttonWidths = buttonWidths
+ _header.widthType = ButtonBarModel.PIXEL_WIDTHS;
+ _header.dataProvider = columnLabels;
+ _header.addBead(bblayout);
+ _header.addBead(new Viewport());
+ host.addElement(_header);
+
+ host.addElement(_listArea);
+
+ handleDataProviderChanged(event);
+
+ host.addEventListener("widthChanged", handleSizeChanges);
+ host.addEventListener("heightChanged", handleSizeChanges);
}
-
- var sharedModel:IDataGridModel = _strand.getBeadByType(IBeadModel) as IDataGridModel;
- IEventDispatcher(sharedModel).addEventListener("dataProviderChanged",handleDataProviderChanged);
-
- var columnLabels:Array = new Array();
-
- for(var i:int=0; i < sharedModel.columns.length; i++) {
- var dgc:DataGridColumn = sharedModel.columns[i] as DataGridColumn;
- columnLabels.push(dgc.label);
+
+ /**
+ * @private
+ */
+ private function handleSizeChanges(event:Event):void
+ {
+ _header.dispatchEvent(new Event("layoutChanged"));
+ _listArea.dispatchEvent(new Event("layoutChanged"));
}
-
- var bblayout:ButtonBarLayout = new ButtonBarLayout();
- var buttonBarModel:ArraySelectionModel = new ArraySelectionModel();
- buttonBarModel.dataProvider = columnLabels;
-
- _header.addBead(buttonBarModel);
- _header.addBead(bblayout);
- _header.addBead(new Viewport());
- host.addElement(_header);
-
- host.addElement(_listArea);
-
- handleDataProviderChanged(event);
- }
-
- /**
- * @private
- */
- private function handleSizeChanges(event:Event):void
- {
- var layoutBead:IDataGridLayout = _strand.getBeadByType(IBeadLayout) as IDataGridLayout;
- layoutBead.header = _header;
- layoutBead.columns = _lists;
- layoutBead.listArea = _listArea;
- layoutBead.layout();
- }
-
- /**
- * @private
- */
- private function handleDataProviderChanged(event:Event):void
- {
- var sharedModel:IDataGridModel = _strand.getBeadByType(IBeadModel) as IDataGridModel;
-
- if (_lists == null || _lists.length == 0) {
- createLists();
+
+ /**
+ * @private
+ */
+ private function handleDataProviderChanged(event:Event):void
+ {
+ var sharedModel:IDataGridModel = _strand.getBeadByType(IBeadModel) as IDataGridModel;
+
+ for (var i:int=0; i < _lists.length; i++)
+ {
+ var list:DataGridColumnList = _lists[i] as DataGridColumnList;
+ var listModel:ISelectionModel = list.getBeadByType(IBeadModel) as ISelectionModel;
+ listModel.dataProvider = sharedModel.dataProvider;
+ }
+
+ host.dispatchEvent(new Event("layoutNeeded"));
}
-
- for (var i:int=0; i < _lists.length; i++)
+
+ /**
+ * @private
+ */
+ private function handleSelectedIndexChanged(event:Event):void
{
- var list:DataGridColumnList = _lists[i] as DataGridColumnList;
- var listModel:ISelectionModel = list.getBeadByType(IBeadModel) as ISelectionModel;
- listModel.dataProvider = sharedModel.dataProvider;
+ var sharedModel:IDataGridModel = _strand.getBeadByType(IBeadModel) as IDataGridModel;
+ var newIndex:int = sharedModel.selectedIndex;
+
+ for (var i:int=0; i < _lists.length; i++)
+ {
+ var list:DataGridColumnList = _lists[i] as DataGridColumnList;
+ list.selectedIndex = newIndex;
+ }
}
-
- host.dispatchEvent(new Event("layoutNeeded"));
- }
-
- /**
- * @private
- */
- private function handleColumnListChange(event:Event):void
- {
- var sharedModel:IDataGridModel = _strand.getBeadByType(IBeadModel) as IDataGridModel;
- var list:DataGridColumnList = event.target as DataGridColumnList;
- sharedModel.selectedIndex = list.selectedIndex;
-
- for(var i:int=0; i < _lists.length; i++) {
- if (list != _lists[i]) {
- var otherList:DataGridColumnList = _lists[i] as DataGridColumnList;
- otherList.selectedIndex = list.selectedIndex;
+
+ /**
+ * @private
+ */
+ private function handleColumnListChange(event:Event):void
+ {
+ var sharedModel:IDataGridModel = _strand.getBeadByType(IBeadModel) as IDataGridModel;
+ var list:DataGridColumnList = event.target as DataGridColumnList;
+ sharedModel.selectedIndex = list.selectedIndex;
+
+ for(var i:int=0; i < _lists.length; i++) {
+ if (list != _lists[i]) {
+ var otherList:DataGridColumnList = _lists[i] as DataGridColumnList;
+ otherList.selectedIndex = list.selectedIndex;
+ }
}
+
+ host.dispatchEvent(new Event('change'));
}
-
- host.dispatchEvent(new Event('change'));
- }
-
- /**
- * @private
- */
- private function createLists():void
- {
- var sharedModel:IDataGridModel = _strand.getBeadByType(IBeadModel) as IDataGridModel;
- var presentationModel:DataGridPresentationModel = _strand.getBeadByType(DataGridPresentationModel) as DataGridPresentationModel;
- var listWidth:Number = host.width / sharedModel.columns.length;
-
- _lists = new Array();
-
- for (var i:int=0; i < sharedModel.columns.length; i++) {
- var dataGridColumn:DataGridColumn = sharedModel.columns[i] as DataGridColumn;
-
- var list:DataGridColumnList = new DataGridColumnList();
- list.id = "dataGridColumn"+String(i);
- list.addBead(sharedModel);
- list.itemRenderer = dataGridColumn.itemRenderer;
- list.labelField = dataGridColumn.dataField;
- list.addEventListener('change',handleColumnListChange);
- list.addBead(presentationModel);
-
- _listArea.addElement(list);
- _lists.push(list);
+
+ /**
+ * @private
+ */
+ private function createLists():void
+ {
+ var host:DataGrid = _strand as DataGrid;
+
+ var sharedModel:IDataGridModel = host.model as IDataGridModel;
+ var presentationModel:IDataGridPresentationModel = host.presentationModel;
+
+ _lists = new Array();
+
+ for (var i:int=0; i < sharedModel.columns.length; i++) {
+ var dataGridColumn:DataGridColumn = sharedModel.columns[i] as DataGridColumn;
+
+ var list:DataGridColumnList = new DataGridColumnList();
+ list.id = "dataGridColumn"+String(i);
+ list.addBead(sharedModel);
+ list.itemRenderer = dataGridColumn.itemRenderer;
+ list.labelField = dataGridColumn.dataField;
+ list.addEventListener('change',handleColumnListChange);
+ list.addBead(presentationModel);
+
+ if (i == 0) {
+ list.className = "first";
+ } else if (i == sharedModel.columns.length-1) {
+ list.className = "last";
+ } else {
+ list.className = "middle";
+ }
+
+ _listArea.addElement(list);
+ _lists.push(list);
+ }
+
+ host.dispatchEvent(new Event("layoutNeeded"));
}
-
- host.dispatchEvent(new Event("layoutNeeded"));
}
- }
}
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/1691921e/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/GroupView.as
----------------------------------------------------------------------
diff --cc frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/GroupView.as
index c3351a5,0000000..2a982c2
mode 100644,000000..100644
--- a/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/GroupView.as
+++ b/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/GroupView.as
@@@ -1,429 -1,0 +1,344 @@@
+////////////////////////////////////////////////////////////////////////////////
+//
+// 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.html.beads
+{
+ import org.apache.flex.core.BeadViewBase;
+ import org.apache.flex.core.IBead;
+ import org.apache.flex.core.IBeadLayout;
+ import org.apache.flex.core.IBeadView;
+ import org.apache.flex.core.ILayoutChild;
+ import org.apache.flex.core.ILayoutHost;
+ import org.apache.flex.core.ILayoutView;
+ import org.apache.flex.core.IStrand;
+ import org.apache.flex.core.IUIBase;
+ import org.apache.flex.core.UIBase;
+ import org.apache.flex.core.ValuesManager;
+ import org.apache.flex.events.Event;
+ import org.apache.flex.events.IEventDispatcher;
+
+ COMPILE::SWF {
+ import org.apache.flex.geom.Size;
+ import org.apache.flex.geom.Rectangle;
+ import org.apache.flex.utils.CSSContainerUtils;
+ }
+
+ /**
+ * The GroupView is a bead that manages the layout bead (if any) attached to a Group. This class
+ * also provides support for background and border styles for a Group on the SWF platform.
+ *
+ * @viewbead
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion FlexJS 0.8
+ */
+ public class GroupView extends BeadViewBase implements IBeadView, ILayoutHost
+ {
+ /**
+ * The GroupView class is the default view for
+ * the org.apache.flex.html.Group class.
+ * It lets you use some CSS styles to manage the border, background
+ * and padding around the content area.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion FlexJS 0.8
+ */
+ public function GroupView()
+ {
+ super();
+
+ layoutRunning = false;
+ }
+
+ /**
+ * The sub-element used as the parent of the container's elements. This does not
+ * include the chrome elements.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion FlexJS 0.8
+ */
+ public function get contentView():ILayoutView
+ {
+ return host as ILayoutView;
+ }
+
+ /**
+ * The view that can be resized.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion FlexJS 0.8
+ */
+ public function get resizableView():IUIBase
+ {
+ return host;
+ }
+
+
+ private var layoutRunning:Boolean;
+
+ /**
+ * Strand setter.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion FlexJS 0.8
+ */
+ override public function set strand(value:IStrand):void
+ {
+ _strand = value;
+ super.strand = value;
+
+ COMPILE::SWF {
+ displayBackgroundAndBorder(host as UIBase);
+ }
+
+ // listen for initComplete to signal that the strand has been initialized
+ // with its beads and children.
+ host.addEventListener("initComplete", handleInitComplete);
-
- // listen for when children have been added so additional event listeners
- // can be placed upon them.
- host.addEventListener("childrenAdded", handleChildrenAdded);
-
- // listen for requests to run the layout.
- host.addEventListener("layoutNeeded", performLayout);
+ }
+
+ /**
+ * Handles the initComplete event by completing the setup and kicking off the
+ * presentation of the contents.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion FlexJS 0.8
+ */
+ protected function handleInitComplete(event:Event):void
+ {
+ var ilc:ILayoutChild = host as ILayoutChild;
+ // Complete the setup if the height is sized to content or has been explicitly set
+ // and the width is sized to content or has been explicitly set
+ if ((ilc.isHeightSizedToContent() || !isNaN(ilc.explicitHeight) || !isNaN(ilc.percentHeight)) &&
+ (ilc.isWidthSizedToContent() || !isNaN(ilc.explicitWidth) || !isNaN(ilc.percentWidth))) {
+ completeSetup();
+ }
+ else {
+ // otherwise, wait until the unknown sizes have been set and then finish
+ host.addEventListener("sizeChanged", deferredSizeHandler);
+ host.addEventListener("widthChanged", deferredSizeHandler);
+ host.addEventListener("heightChanged", deferredSizeHandler);
+ }
+ }
+
+ /**
+ * Handles the case where the size of the host is not immediately known, usually do
+ * to one of its dimensions being indicated as a percent size.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion FlexJS 0.8
+ */
+ protected function deferredSizeHandler(event:Event):void
+ {
+ host.removeEventListener("sizeChanged", deferredSizeHandler);
+ host.removeEventListener("widthChanged", deferredSizeHandler);
+ host.removeEventListener("heightChanged", deferredSizeHandler);
+
+ completeSetup();
-
- var num:Number = contentView.numElements;
- if (num > 0)
- {
- performLayout(event);
- }
+ }
+
+ /**
+ * Called when the host is ready to complete its setup (usually after its size has been
+ * determined).
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion FlexJS 0.8
+ */
+ protected function completeSetup():void
+ {
+ // listen for changes to strand's size and rerun the layout
+ host.addEventListener("sizeChanged", resizeHandler);
+ host.addEventListener("widthChanged", resizeHandler);
+ host.addEventListener("heightChanged", resizeHandler);
+ }
-
- /**
- * Handles the viewCreated event by performing the first layout if
- * there are children already present (ie, from MXML).
- *
- * @langversion 3.0
- * @playerversion Flash 10.2
- * @playerversion AIR 2.6
- * @productversion FlexJS 0.8
- */
- protected function viewCreatedHandler(event:Event):void
- {
- var num:Number = contentView.numElements;
- if (num > 0)
- {
- performLayout(event);
- }
- }
-
- /**
- * @private
- */
- protected function handleChildrenAdded(event:Event):void
- {
- COMPILE::SWF {
- var n:Number = contentView.numElements;
- for(var i:int=0; i < n; i++) {
- var child:IEventDispatcher = contentView.getElementAt(i) as IEventDispatcher;
- child.addEventListener("widthChanged", childResizeHandler);
- child.addEventListener("heightChanged", childResizeHandler);
- child.addEventListener("sizeChanged", childResizeHandler);
- }
- }
-
- performLayout(event);
- }
+
+ /**
+ * Invoked in response to the strand being resized.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion FlexJS 0.8
+ */
+ protected function resizeHandler(event:Event):void
+ {
- performLayout(event);
- }
-
- /**
- * Invoked in response to any child being resized.
- *
- * @langversion 3.0
- * @playerversion Flash 10.2
- * @playerversion AIR 2.6
- * @productversion FlexJS 0.8
- */
- protected function childResizeHandler(event:Event):void
- {
- performLayout(event);
++ // override in subclasses in case there is something besides running
++ // the layout (which is handled automatically by the layout itself).
+ }
+
+ /**
+ * Provides a place for pre-layout actions.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion FlexJS 0.8
+ */
- protected function layoutViewBeforeContentLayout():void
++ public function beforeLayout():void
+ {
+ // This has no use for Group but is here so a subclass can override it.
+ }
+
+ /**
+ * Executes the layout associated with this container. Once the layout has been
+ * run, it may affect the size of the host or may cause the host to present scroll
+ * bars view its viewport.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion FlexJS 0.8
+ */
+ protected function performLayout(event:Event):void
+ {
- if (layoutRunning) return;
-
- layoutRunning = true;
-
- // pre-process before layout
- layoutViewBeforeContentLayout();
-
- var host:UIBase = _strand as UIBase;
-
- var layout:IBeadLayout = _strand.getBeadByType(IBeadLayout) as IBeadLayout;
- if (layout == null) {
- var c:Class = ValuesManager.valuesImpl.getValue(host, "iBeadLayout");
- if (c) {
- layout = new c() as IBeadLayout;
- _strand.addBead(layout);
- }
- }
-
- if (layout) {
- layout.layout();
- }
-
- // cleanup or adjust after layout
- layoutViewAfterContentLayout();
-
- layoutRunning = false;
-
- host.dispatchEvent(new Event("layoutComplete"));
++ trace("CALLING performLayout !!!!");
+ }
+
+ /**
+ * Returns the size of the content area including the padding.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion FlexJS 0.0
+ */
+ COMPILE::SWF
+ protected function calculateContentSize():Size
+ {
+ var maxWidth:Number = 0;
+ var maxHeight:Number = 0;
+ var num:Number = contentView.numElements;
+
+ for (var i:int=0; i < num; i++) {
+ var child:IUIBase = contentView.getElementAt(i) as IUIBase;
+ if (child == null || !child.visible) continue;
+ var childXMax:Number = child.x + child.width;
+ var childYMax:Number = child.y + child.height;
+ maxWidth = Math.max(maxWidth, childXMax);
+ maxHeight = Math.max(maxHeight, childYMax);
+ }
+
+ var padding:org.apache.flex.geom.Rectangle = CSSContainerUtils.getPaddingMetrics(this._strand);
+ var border:org.apache.flex.geom.Rectangle = CSSContainerUtils.getBorderMetrics(this._strand);
+
+ // return the content size as the max plus right/bottom padding. the x,y position of
+ // each child is already offset by the left/top padding by the layout algorithm.
+ return new Size(maxWidth + padding.right - (border.left+border.right), maxHeight + padding.bottom - (border.top+border.bottom));
+ }
+
+ /**
- * @private
- */
- private var adjusting:Boolean = false;
-
- /**
+ * Adjusts the size of the host after the layout has been run.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion FlexJS 0.0
+ */
+ COMPILE::SWF
- protected function layoutViewAfterContentLayout():void
++ public function afterLayout():void
+ {
- if (adjusting) return;
-
+ var host:UIBase = _strand as UIBase;
-
- adjusting = true;
-
+ var contentSize:Size = calculateContentSize();
+
+ if (host.isWidthSizedToContent() && host.isHeightSizedToContent()) {
+ host.setWidthAndHeight(contentSize.width, contentSize.height, true);
+ }
+ else if (!host.isWidthSizedToContent() && host.isHeightSizedToContent())
+ {
+ host.setHeight(contentSize.height, true);
+ }
+ else if (host.isWidthSizedToContent() && !host.isHeightSizedToContent())
+ {
+ host.setWidth(contentSize.width, true);
+ }
-
- adjusting = false;
+ }
+
+ COMPILE::JS
- protected function layoutViewAfterContentLayout():void
++ public function afterLayout():void
+ {
+ // maybe useful in a subclass on the JS side.
+ }
+
+ /**
+ * @private
+ */
+ COMPILE::SWF
+ protected function displayBackgroundAndBorder(host:UIBase) : void
+ {
+ var backgroundColor:Object = ValuesManager.valuesImpl.getValue(host, "background-color");
+ var backgroundImage:Object = ValuesManager.valuesImpl.getValue(host, "background-image");
+ if (backgroundColor != null || backgroundImage != null)
+ {
+ if (host.getBeadByType(IBackgroundBead) == null)
+ var c:Class = ValuesManager.valuesImpl.getValue(host, "iBackgroundBead");
+ if (c) {
+ host.addBead( new c() as IBead );
+ }
+ }
-
++
++ if (setupForBorder(host, "border")) return;
++ if (setupForBorder(host, "border-top")) return;
++ if (setupForBorder(host, "border-bottom")) return;
++ if (setupForBorder(host, "border-left")) return;
++ if (setupForBorder(host, "border-right")) return;
++ }
++
++ COMPILE::SWF
++ protected function setupForBorder(host:UIBase, borderType:String):Boolean
++ {
++ var result:Boolean = false;
++
+ var borderStyle:String;
- var borderStyles:Object = ValuesManager.valuesImpl.getValue(host, "border");
++ var borderStyles:Object = ValuesManager.valuesImpl.getValue(host, borderType);
+ if (borderStyles is Array)
+ {
+ borderStyle = borderStyles[1];
+ }
+ if (borderStyle == null)
+ {
- borderStyle = ValuesManager.valuesImpl.getValue(host, "border-style") as String;
++ borderStyle = ValuesManager.valuesImpl.getValue(host, borderType+"-style") as String;
+ }
+ if (borderStyle != null && borderStyle != "none")
+ {
+ if (host.getBeadByType(IBorderBead) == null) {
- c = ValuesManager.valuesImpl.getValue(host, "iBorderBead");
++ var c:Class = ValuesManager.valuesImpl.getValue(host, "iBorderBead");
+ if (c) {
+ host.addBead( new c() as IBead );
++ result = true;
+ }
+ }
+ }
++
++ return result;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/1691921e/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/layouts/ButtonBarLayout.as
----------------------------------------------------------------------
diff --cc frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/layouts/ButtonBarLayout.as
index 761e1c7,5bd1159..51d0c4c
--- a/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/layouts/ButtonBarLayout.as
+++ b/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/layouts/ButtonBarLayout.as
@@@ -17,36 -17,30 +17,21 @@@
//
////////////////////////////////////////////////////////////////////////////////
package org.apache.flex.html.beads.layouts
-{
+{
import org.apache.flex.core.IBeadLayout;
- import org.apache.flex.core.IItemRendererClassFactory;
- import org.apache.flex.core.IItemRendererParent;
-- import org.apache.flex.core.ILayoutHost;
- import org.apache.flex.core.ILayoutParent;
- import org.apache.flex.core.IParentIUIBase;
- import org.apache.flex.core.ISelectableItemRenderer;
- import org.apache.flex.core.ISelectionModel;
++ import org.apache.flex.core.ILayoutChild;
+ import org.apache.flex.core.ILayoutView;
- import org.apache.flex.core.IParentIUIBase;
- import org.apache.flex.core.ISelectableItemRenderer;
- import org.apache.flex.core.ISelectionModel;
++ import org.apache.flex.core.IStyleableObject;
import org.apache.flex.core.IStrand;
-- import org.apache.flex.core.IUIBase;
-- import org.apache.flex.core.IViewportModel;
- import org.apache.flex.core.LayoutBase;
- import org.apache.flex.core.SimpleCSSStyles;
-- import org.apache.flex.core.UIBase;
-- import org.apache.flex.core.ValuesManager;
-- import org.apache.flex.events.Event;
-- import org.apache.flex.events.IEventDispatcher;
-- import org.apache.flex.html.List;
-- import org.apache.flex.html.beads.ButtonBarView;
-
+ import org.apache.flex.html.beads.models.ButtonBarModel;
- import org.apache.flex.geom.Rectangle;
- import org.apache.flex.utils.CSSUtils;
- import org.apache.flex.utils.CSSContainerUtils;
++ import org.apache.flex.html.supportClasses.UIItemRendererBase;
+
/**
- * The ButtonBarLayout class bead sizes and positions the org.apache.flex.html.Button
- * The ButtonBarLayout class bead sizes and positions the org.apache.flex.html.Button
- * elements that make up a org.apache.flex.html.ButtonBar. This bead arranges the Buttons
++ * The ButtonBarLayout class bead sizes and positions the button
+ * elements that make up a org.apache.flex.html.ButtonBar. This bead arranges the Buttons
* horizontally and makes them all the same width unless the buttonWidths property has been set in which case
* the values stored in that array are used.
- *
+ *
* @langversion 3.0
* @playerversion Flash 10.2
* @playerversion AIR 2.6
@@@ -91,81 -98,46 +76,71 @@@
/**
* @copy org.apache.flex.core.IBeadLayout#layout
*/
- public function layout():Boolean
+ override public function layout():Boolean
{
- var layoutParent:ILayoutHost = _strand.getBeadByType(ILayoutHost) as ILayoutHost;
- var contentView:IParentIUIBase = layoutParent.contentView as IParentIUIBase;
- var itemRendererParent:IItemRendererParent = contentView as IItemRendererParent;
- var viewportModel:IViewportModel = (layoutParent as ButtonBarView).viewportModel;
-
- var n:int = contentView.numElements;
- var realN:int = n;
-
- for (var j:int=0; j < n; j++)
- {
- var child:IUIBase = itemRendererParent.getElementAt(j) as IUIBase;
- if (child == null || !child.visible) realN--;
+ var contentView:ILayoutView = layoutView;
+
+ var model:ButtonBarModel = (host as IStrand).getBeadByType(ButtonBarModel) as ButtonBarModel;
+ if (model) {
+ buttonWidths = model.buttonWidths;
+ _widthType = model.widthType;
}
-
- var xpos:Number = 0;
- var useWidth:Number = contentView.width / realN;
- var useHeight:Number = contentView.height;
-
+
+ var n:int = contentView.numElements;
++ if (n <= 0) return false;
+
for (var i:int=0; i < n; i++)
-- {
- var ir:ISelectableItemRenderer = contentView.getElementAt(i) as ISelectableItemRenderer;
- var ir:ISelectableItemRenderer = itemRendererParent.getElementAt(i) as ISelectableItemRenderer;
-- if (ir == null || !UIBase(ir).visible) continue;
- UIBase(ir).y = 0;
- UIBase(ir).x = xpos;
- if (!isNaN(useHeight) && useHeight > 0) {
- UIBase(ir).height = useHeight;
- }
++ {
++ var ilc:ILayoutChild = contentView.getElementAt(i) as ILayoutChild;
++ if (ilc == null || !ilc.visible) continue;
++ if (!(ilc is IStyleableObject)) continue;
- if (buttonWidths) UIBase(ir).width = Number(buttonWidths[i]);
- else if (!isNaN(useWidth) && useWidth > 0) {
- UIBase(ir).width = useWidth;
+ COMPILE::SWF {
+ if (buttonWidths) {
+ var widthValue:* = buttonWidths[i];
+
+ if (_widthType == ButtonBarModel.PIXEL_WIDTHS) {
- if (widthValue != null) UIBase(ir).width = Number(widthValue);
- if (UIBase(ir).style == null) {
- UIBase(ir).style = new SimpleCSSStyles();
- }
- UIBase(ir).style.flexGrow = 0;
++ if (widthValue != null) ilc.width = Number(widthValue);
++ IStyleableObject(ilc).style.flexGrow = 0;
+ }
+ else if (_widthType == ButtonBarModel.PROPORTIONAL_WIDTHS) {
+ if (widthValue != null) {
- if (UIBase(ir).style == null) {
- UIBase(ir).style = new SimpleCSSStyles();
- }
- UIBase(ir).style.flexGrow = Number(widthValue);
++ IStyleableObject(ilc).style.flexGrow = Number(widthValue);
+ }
+ }
+ else if (_widthType == ButtonBarModel.PERCENT_WIDTHS) {
- if (widthValue != null) UIBase(ir).percentWidth = Number(widthValue);
- if (UIBase(ir).style == null) {
- UIBase(ir).style = new SimpleCSSStyles();
- }
- UIBase(ir).style.flexGrow = 0;
++ if (widthValue != null) ilc.percentWidth = Number(widthValue);
++ IStyleableObject(ilc).style.flexGrow = 0;
+ }
+ } else {
- if (UIBase(ir).style == null) {
- UIBase(ir).style = new SimpleCSSStyles();
- }
- UIBase(ir).style.flexGrow = 1;
++ IStyleableObject(ilc).style.flexGrow = 1;
+ }
+ }
+
+ COMPILE::JS {
+ // otherwise let the flexbox layout handle matters on its own.
+ if (buttonWidths) {
+ var widthValue:* = buttonWidths[i];
+
+ if (_widthType == ButtonBarModel.PIXEL_WIDTHS) {
- if (widthValue != null) UIBase(ir).width = Number(widthValue);
++ if (widthValue != null) ilc.width = Number(widthValue);
+ }
+ else if (_widthType == ButtonBarModel.PROPORTIONAL_WIDTHS) {
- if (widthValue != null) UIBase(ir).element.style["flex-grow"] = String(widthValue);
++ if (widthValue != null) ilc.element.style["flex-grow"] = String(widthValue);
+ }
+ else if (_widthType == ButtonBarModel.PERCENT_WIDTHS) {
- if (widthValue != null) UIBase(ir).percentWidth = Number(widthValue);
++ if (widthValue != null) ilc.percentWidth = Number(widthValue);
+ }
+ } else {
- UIBase(ir).element.style["flex-grow"] = "1";
++ ilc.element.style["flex-grow"] = "1";
+ }
+
- UIBase(ir).height = contentView.height;
++ ilc.height = contentView.height;
}
- xpos += UIBase(ir).width;
}
-
- IEventDispatcher(_strand).dispatchEvent( new Event("layoutComplete") );
-
- return true;
+
+ // now let the horizontal layout take care of things.
+ return super.layout();
}
}
}