You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by ma...@apache.org on 2013/10/02 03:01:12 UTC
[1/5] https://issues.apache.org/jira/browse/FLEX-33777 Dagrid for
mobile - formatted sources code - added ASDOC (almost all) - bug: Bitmap
renderer does not support MultiDPI when appDPI is set
Updated Branches:
refs/heads/mobileexperimental aef85b3a5 -> b68e18285
Updated Tags: refs/tags/OK_commit_donation [created] a0c31e7e1
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/b78de5c0/frameworks/projects/experimental_mobile/src/spark/components/supportClasses/MobileGridColumn.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/experimental_mobile/src/spark/components/supportClasses/MobileGridColumn.as b/frameworks/projects/experimental_mobile/src/spark/components/supportClasses/MobileGridColumn.as
new file mode 100644
index 0000000..a404bb2
--- /dev/null
+++ b/frameworks/projects/experimental_mobile/src/spark/components/supportClasses/MobileGridColumn.as
@@ -0,0 +1,148 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// 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 spark.components.supportClasses
+{
+
+import flash.events.IEventDispatcher;
+
+import mx.utils.ObjectUtil;
+
+import spark.collections.SortField;
+
+/**
+ * The MobileGridColumn class defines a column to display in a MobileGrid control.
+ * <p> The MobileGridColumn class specifies the characteristics of the column to display,
+ * such as the field of the data provider item whose value is to be displayed in the column.
+ * MobileGridColumn takes most of its properties from its parent class and adds the following Grid-specific options:</p>
+ * <ul>
+ * <li>headerText and headerStyleName: optional label and style to display in the header for this column </li>
+ * <li>sortable, sortDescending and sortField: sorting options for this column </li>
+ * </ul>
+ *
+ * @see spark.components.MobileGrid
+ * @see spark.components.supportClasses.PartRendererDescriptorBase
+ *
+ * @langversion 3.0
+ * @playerversion AIR 3.8
+ * @productversion Flex 4.11
+ */
+public class MobileGridColumn extends PartRendererDescriptorBase
+{
+
+ private var _headerText:String = null;
+ private var _headerStyleName:String;
+ private var _sortDescending:Boolean;
+ private var _sortable: Boolean = true;
+
+ public function MobileGridColumn(target:IEventDispatcher = null)
+ {
+ super(target);
+ labelFunction = null;
+ width = 100; // default width;
+ itemRenderer = null; // will set default ;
+ }
+
+ /** Defines the text to be displayed in the column's header.
+ * <p>If this property is not set, the header label will use the value of dataField property instead.</p>
+ * @see #dataField
+ */
+ public function get headerText():String
+ {
+ return _headerText != null ? _headerText : dataField ;
+ }
+
+ public function set headerText(value:String):void
+ {
+ _headerText = value;
+ }
+
+ /** Defines the css style name to be used for displaying this column's header label.
+ * <p>Use this property to display the header in a different color or font, or with a different text alignment.</p>
+ */
+ public function get headerStyleName():String
+ {
+ return _headerStyleName;
+ }
+
+ public function set headerStyleName(value:String):void
+ {
+ _headerStyleName = value;
+ }
+
+ /** Flag indicating whether a column can be sorted by clicking on its header.
+ * <p>This flag is effective only if the MobileGrid </p>
+ */
+ public function get sortable():Boolean
+ {
+ return _sortable;
+ }
+
+ public function set sortable(value:Boolean):void
+ {
+ _sortable = value;
+ }
+
+ public function get sortDescending():Boolean
+ {
+ return _sortDescending;
+ }
+
+ public function set sortDescending(value:Boolean):void
+ {
+ _sortDescending = value;
+ }
+
+ //----------------------------------
+ // sortField
+ //----------------------------------
+
+ /**
+ * Returns a SortField that can be used to sort a collection by this
+ * column's <code>dataField</code>.
+ *
+ *
+ * <p>If the <code>dataField</code> properties are not defined, but the
+ * <code>labelFunction</code> property is defined, then it assigns the
+ * <code>compareFunction</code> to a closure that does a basic string compare
+ * on the <code>labelFunction</code> applied to the data objects.</p>
+
+ */
+ public function get sortField():SortField
+ {
+ const column:MobileGridColumn = this;
+
+ var sortField:SortField = new SortField(dataField);
+
+ var cF:Function = null;
+ if (dataField == null && labelFunction != null)
+ {
+ // use basic string compare on the labelFunction results
+ cF = function (a:Object, b:Object):int
+ {
+ return ObjectUtil.stringCompare(labelFunction(a), labelFunction(b));
+ };
+ sortField.compareFunction = cF;
+ }
+ sortField.descending = column.sortDescending;
+ return sortField;
+ }
+
+
+}
+}
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/b78de5c0/frameworks/projects/experimental_mobile/src/spark/components/supportClasses/MobileGridHeader.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/experimental_mobile/src/spark/components/supportClasses/MobileGridHeader.as b/frameworks/projects/experimental_mobile/src/spark/components/supportClasses/MobileGridHeader.as
new file mode 100644
index 0000000..1cdfbf6
--- /dev/null
+++ b/frameworks/projects/experimental_mobile/src/spark/components/supportClasses/MobileGridHeader.as
@@ -0,0 +1,151 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// 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 spark.components.supportClasses
+{
+
+import mx.collections.ArrayList;
+import mx.core.UIComponent;
+import mx.core.mx_internal;
+
+import spark.components.ButtonBar;
+import spark.components.MobileGrid;
+import spark.events.IndexChangeEvent;
+import spark.events.MobileGridHeaderEvent;
+import spark.events.RendererExistenceEvent;
+import spark.utils.MultiDPIBitmapSource;
+
+use namespace mx_internal;
+
+[Event(name="sortChange", type="spark.events.MobileGridHeaderEvent")]
+
+/** @private
+ * internal class used by MobileGrid to manage and display the grid's column headers.
+ * It inherits from ButtonBar so that headers can display text and be clicked and forwards header clicks to the MobileGrid for managing sorting.
+ * the default skin for this class is : spark.skins.MobileGridHeaderButtonBarSkin
+ *
+ * @see spark.skins.MobileGridHeaderButtonBarSkin
+ */
+public class MobileGridHeader extends ButtonBar
+{
+
+ [Embed(source="../../../../assets/images/mobile320/dg_header_asc.png")]
+ private const ascIcon320Cls:Class;
+
+ [Embed(source="../../../../assets/images/mobile320/dg_header_desc.png")]
+ private const descIcon320Cls:Class;
+
+ [Embed(source="../../../../assets/images/mobile160/dg_header_asc.png")]
+ private const ascIcon160Cls:Class;
+
+ [Embed(source="../../../../assets/images/mobile160/dg_header_desc.png")]
+ private const descIcon160Cls:Class;
+
+ protected var descIconCls:MultiDPIBitmapSource;
+ protected var ascIconCls:MultiDPIBitmapSource;
+
+ private var _dataGrid:MobileGrid;
+ private var _columns: Array;
+ private var _sortIndex:int = -1;
+
+ public function MobileGridHeader()
+ {
+ this.labelField = "headerText";
+ this.iconFunction = getIconForButton;
+ this.setStyle("iconPlacement", "right");
+ this.buttonMode = false;
+ this.requireSelection = false;
+ addEventListener(IndexChangeEvent.CHANGING, changingHandler);
+ addEventListener(RendererExistenceEvent.RENDERER_ADD, rendererAddHandler);
+
+ descIconCls = new MultiDPIBitmapSource();
+ descIconCls.source160dpi = descIcon160Cls;
+ descIconCls.source320dpi = descIcon320Cls;
+ ascIconCls = new MultiDPIBitmapSource();
+ ascIconCls.source160dpi = ascIcon160Cls;
+ ascIconCls.source320dpi = ascIcon320Cls;
+ }
+
+ public function set columns(value:Array):void
+ {
+ _columns = value;
+ if (_columns)
+ {
+ dataProvider = new ArrayList(_columns);
+ }
+ else
+ {
+ dataProvider = null;
+ }
+ }
+
+ public function set dataGrid(value:MobileGrid):void
+ {
+ _dataGrid = value;
+ }
+
+ private function changingHandler(event:IndexChangeEvent):void
+ {
+ event.preventDefault(); // to clear selection
+ var i:int = event.newIndex;
+ var c: MobileGridColumn = _columns[i];
+ if (_dataGrid.sortableColumns && c.sortable) {
+ var headerEvent:MobileGridHeaderEvent = new MobileGridHeaderEvent(MobileGridHeaderEvent.SORT_CHANGE, c.colNum, false, true);
+ // HEADER_RELEASE event is cancelable
+ dispatchEvent(headerEvent);
+ }
+ }
+
+ /* will be sent back by MobileGrid when sort is confirmed */
+ mx_internal function setSort(newSortIndex:int, desc:Boolean):void
+ {
+ var prevSortIndex:int = _sortIndex;
+ _sortIndex = newSortIndex;
+
+ // update old and new
+ if (prevSortIndex != -1)
+ dataProvider.itemUpdated(_columns[prevSortIndex]);
+ if (_sortIndex != -1)
+ dataProvider.itemUpdated(_columns[_sortIndex]);
+ }
+
+ private function rendererAddHandler(event:RendererExistenceEvent):void
+ {
+ var button:UIComponent = UIComponent(event.renderer);
+ var index:int = event.index;
+ var col:MobileGridColumn = MobileGridColumn(_columns[index]);
+ // don't size the last button
+ if (index != dataProvider.length - 1)
+ button.explicitWidth = col.scaledWidth;
+ else
+ button.percentWidth = 100;
+ }
+
+ private function getIconForButton(col:MobileGridColumn):Object
+ {
+ if (col.colNum === _sortIndex)
+ {
+ return col.sortDescending ? descIconCls : ascIconCls;
+ }
+ else
+ {
+ return null;
+ }
+ }
+}
+}
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/b78de5c0/frameworks/projects/experimental_mobile/src/spark/components/supportClasses/MobileGridRowRenderer.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/experimental_mobile/src/spark/components/supportClasses/MobileGridRowRenderer.as b/frameworks/projects/experimental_mobile/src/spark/components/supportClasses/MobileGridRowRenderer.as
new file mode 100644
index 0000000..0461d22
--- /dev/null
+++ b/frameworks/projects/experimental_mobile/src/spark/components/supportClasses/MobileGridRowRenderer.as
@@ -0,0 +1,34 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// 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 spark.components.supportClasses
+{
+
+/** @private
+ * This is the internal list itemRenderer used for rendering grid cells in a single row of a MobileGrid.
+ * It inherits all its behavior for its parent class and only sets the part renderers layout.
+ */
+public class MobileGridRowRenderer extends ListMultiPartItemRendererBase
+{
+ public function MobileGridRowRenderer()
+ {
+ partRenderersLayout = new ListMultiPartTabbedLayout(this);
+ }
+
+}
+}
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/b78de5c0/frameworks/projects/experimental_mobile/src/spark/components/supportClasses/PartRendererDescriptorBase.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/experimental_mobile/src/spark/components/supportClasses/PartRendererDescriptorBase.as b/frameworks/projects/experimental_mobile/src/spark/components/supportClasses/PartRendererDescriptorBase.as
new file mode 100644
index 0000000..57a3cbb
--- /dev/null
+++ b/frameworks/projects/experimental_mobile/src/spark/components/supportClasses/PartRendererDescriptorBase.as
@@ -0,0 +1,184 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// 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 spark.components.supportClasses
+{
+import flash.events.EventDispatcher;
+import flash.events.IEventDispatcher;
+
+import mx.core.ClassFactory;
+import mx.core.DPIClassification;
+import mx.core.IFactory;
+import mx.core.mx_internal;
+
+import spark.components.itemRenderers.IItemPartRendererBase;
+import spark.components.itemRenderers.IItemTextPartRenderer;
+import spark.components.itemRenderers.ItemTextPartRenderer;
+import spark.utils.DensityUtil2;
+
+/** This is the base class for GridColumn
+ *
+ */
+public class PartRendererDescriptorBase extends EventDispatcher implements IPartRendererDescriptor
+{
+
+ private var _colNum:int;
+ private var _dataField:String;
+ private var _width:Number;
+ private var _scaledWidth:Number;
+ private var _itemRenderer:IFactory;
+ private var _labelFunction:Function;
+ private var _styleName:String;
+ private var _textAlign:String;
+
+ public function PartRendererDescriptorBase(target:IEventDispatcher = null)
+ {
+ super(target);
+ _labelFunction = null;
+ width = 100; // default width;
+ itemRenderer = null; // will set default ;
+ }
+
+ /* IDataGridColumn impl*/
+
+ public function set dataField(value:String):void
+ {
+ _dataField = value;
+ }
+
+ public function get dataField():String
+ {
+ return _dataField;
+ }
+
+ public function get labelFunction():Function
+ {
+ return _labelFunction;
+ }
+
+ /**
+ * An idempotent function that converts a data provider item into a column-specific string
+ * that's used to initialize the item renderer's <code>label</code> property.
+ *
+ * <p>You can use a label function to combine the values of several data provider items
+ * into a single string.
+ * If specified, this property is used by the
+ * <code>itemToLabel()</code> method, which computes the value of each item
+ * renderer's <code>label</code> property in this column.</p>
+ *
+ * <p>The function specified to the <code>labelFunction</code> property
+ * must have the following signature:</p>
+ *
+ * <pre>labelFunction(item:Object):String</pre>
+ *
+ * <p>The <code>item</code> parameter is the data provider item for an entire row.
+ * The second parameter is this column object.</p>
+ *
+ * <p>A typical label function could concatenate the firstName and
+ * lastName properties of the data provider item ,
+ * or do some custom formatting on a Date value property.</p>
+ */
+ public function set labelFunction(value:Function):void
+ {
+ _labelFunction = value;
+ }
+
+ public function set styleName(value:String):void
+ {
+ _styleName = value;
+ }
+
+ /** set the desired width of the column at the application's current DPI (or 160 if none)
+ * default value is 100
+ * the actual pixel width maybe higher if the runtimeDPI or application DPI are different than 160
+ *
+ * @param value = desired width of the column at 160 DPI
+ */
+ public function set width(value:Number):void
+ {
+ _width = value;
+ _scaledWidth = DensityUtil2.dpiScale(value, DPIClassification.DPI_160);
+ }
+
+ /** set the desired width of the column at the application's current DPI (or 160 if none)
+ * default value is 100
+ * the actual pixel width maybe higher if the runtimeDPI or application DPI are different than 160
+ *
+ * @param value = desired width of the column at 160 DPI
+ */
+ public function set widthAt160DPI(value:Number):void
+ {
+ _width = value;
+ _scaledWidth = DensityUtil2.dpiScale(value, DPIClassification.DPI_160);
+ }
+
+ public function get scaledWidth():Number
+ {
+ return _scaledWidth;
+ }
+
+ mx_internal function get colNum():int
+ {
+ return _colNum;
+ }
+
+ mx_internal function set colNum(value:int):void
+ {
+ _colNum = value;
+ }
+
+ public function get itemRenderer():IFactory
+ {
+ return _itemRenderer;
+ }
+
+ public function set itemRenderer(value:IFactory):void
+ {
+ _itemRenderer = value ? value : new ClassFactory(ItemTextPartRenderer);
+ }
+
+ public function get styleName():String
+ {
+ return _styleName;
+ }
+
+ [Inspectable(enumeration="left,right,center,justify")]
+ public function set textAlign(value:String):void
+ {
+ _textAlign = value;
+ }
+
+ public function createPartRenderer():IItemPartRendererBase
+ {
+ var pr:IItemPartRendererBase = _itemRenderer.newInstance() as IItemPartRendererBase;
+ if (pr)
+ {
+ pr.cssStyleName = _styleName;
+ if (pr is IItemTextPartRenderer) {
+ with( IItemTextPartRenderer(pr)){
+ labelField = _dataField;
+ labelFunction = _labelFunction;
+ textAlign = _textAlign;
+ }
+ }
+ }
+ return pr;
+ }
+
+}
+}
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/b78de5c0/frameworks/projects/experimental_mobile/src/spark/events/MobileGridHeaderEvent.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/experimental_mobile/src/spark/events/MobileGridHeaderEvent.as b/frameworks/projects/experimental_mobile/src/spark/events/MobileGridHeaderEvent.as
new file mode 100644
index 0000000..06558b7
--- /dev/null
+++ b/frameworks/projects/experimental_mobile/src/spark/events/MobileGridHeaderEvent.as
@@ -0,0 +1,58 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// 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 spark.events
+{
+import flash.events.Event;
+
+/**
+ * The MobileGridHeaderEvent class represents events that are dispatched when
+ the user clicks on the header of a column in the DataGrid to sort it.
+ *
+ * @see spark.components.MobileGrid
+ *
+ * @langversion 3.0
+ * @playerversion AIR 3.8
+ * @productversion Flex 4.11
+ */
+
+// Note: we didn't use neither mx:DataGridEven because it's in not available for mobile not GridSortEvent because it handles multiple sorting
+public class MobileGridHeaderEvent extends Event
+{
+
+ public static const SORT_CHANGE:String = "sortChange";
+
+ private var _columnIndex:int;
+
+ public function MobileGridHeaderEvent(type:String, pindex:int, bubbles:Boolean = false, cancelable:Boolean = false)
+ {
+ super(type, bubbles, cancelable);
+ this._columnIndex = pindex;
+ }
+
+ public function get columnIndex():int
+ {
+ return _columnIndex;
+ }
+
+ override public function clone():Event
+ {
+ return new MobileGridHeaderEvent(type, columnIndex, bubbles, cancelable);
+ }
+}
+}
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/b78de5c0/frameworks/projects/experimental_mobile/src/spark/skins/MobileGridHeaderButtonBarSkin.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/experimental_mobile/src/spark/skins/MobileGridHeaderButtonBarSkin.as b/frameworks/projects/experimental_mobile/src/spark/skins/MobileGridHeaderButtonBarSkin.as
new file mode 100644
index 0000000..5c21a0f
--- /dev/null
+++ b/frameworks/projects/experimental_mobile/src/spark/skins/MobileGridHeaderButtonBarSkin.as
@@ -0,0 +1,89 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// 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 spark.skins
+{
+import spark.components.ButtonBarButton;
+import spark.components.DataGroup;
+import spark.layouts.HorizontalLayout;
+import spark.layouts.VerticalAlign;
+import spark.skins.mobile.ButtonBarSkin;
+import spark.skins.mobile.supportClasses.ButtonBarButtonClassFactory;
+
+public class MobileGridHeaderButtonBarSkin extends ButtonBarSkin
+{
+
+ public function MobileGridHeaderButtonBarSkin()
+ {
+ super();
+ }
+
+ override protected function createChildren():void
+ {
+ if (!firstButton)
+ {
+ firstButton = new ButtonBarButtonClassFactory(ButtonBarButton);
+ ButtonBarButtonClassFactory(firstButton).skinClass = MobileGridHeaderFirstButtonSkin;
+ }
+
+ if (!lastButton)
+ {
+ lastButton = new ButtonBarButtonClassFactory(ButtonBarButton);
+ ButtonBarButtonClassFactory(lastButton).skinClass = MobileGridHeaderButtonSkin;
+ }
+
+ if (!middleButton)
+ {
+ middleButton = new ButtonBarButtonClassFactory(ButtonBarButton);
+ ButtonBarButtonClassFactory(middleButton).skinClass = MobileGridHeaderButtonSkin;
+ }
+
+ // create the data group to house the buttons
+ if (!dataGroup)
+ {
+ dataGroup = new DataGroup();
+ var hLayout:HorizontalLayout = new HorizontalLayout();
+ hLayout.gap = 0;
+ hLayout.verticalAlign = VerticalAlign.CONTENT_JUSTIFY;
+ hLayout.useVirtualLayout = false;
+
+ dataGroup.layout = hLayout;
+ addChild(dataGroup);
+ }
+ }
+
+ /**
+ * @private
+ */
+ override protected function drawBackground(unscaledWidth:Number, unscaledHeight:Number):void
+ {
+ super.drawBackground(unscaledWidth, unscaledHeight);
+
+ // backgroundAlpha style is not supported by ButtonBar
+ // TabbedViewNavigatorSkin sets a hard-coded value to support
+ // overlayControls
+ var backgroundAlphaValue:* = getStyle("backgroundAlpha");
+ var backgroundAlpha:Number = (backgroundAlphaValue === undefined)
+ ? 1 : getStyle("backgroundAlpha");
+
+ graphics.beginFill(getStyle("chromeColor"), backgroundAlpha);
+ graphics.drawRect(0, 0, unscaledWidth, unscaledHeight);
+ graphics.endFill();
+ }
+}
+}
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/b78de5c0/frameworks/projects/experimental_mobile/src/spark/skins/MobileGridHeaderButtonSkin.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/experimental_mobile/src/spark/skins/MobileGridHeaderButtonSkin.as b/frameworks/projects/experimental_mobile/src/spark/skins/MobileGridHeaderButtonSkin.as
new file mode 100644
index 0000000..425847f
--- /dev/null
+++ b/frameworks/projects/experimental_mobile/src/spark/skins/MobileGridHeaderButtonSkin.as
@@ -0,0 +1,43 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// 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 spark.skins
+{
+
+import spark.skins.mobile.ButtonBarMiddleButtonSkin;
+import spark.skins.mobile.assets.MobileGridHeaderButton_down;
+import spark.skins.mobile.assets.MobileGridHeaderButton_up;
+
+public class MobileGridHeaderButtonSkin extends ButtonBarMiddleButtonSkin
+{
+ //--------------------------------------------------------------------------
+ //
+ // Constructor
+ //
+ //--------------------------------------------------------------------------
+ public function MobileGridHeaderButtonSkin()
+ {
+ super();
+
+ upBorderSkin = MobileGridHeaderButton_up;
+ downBorderSkin = MobileGridHeaderButton_down;
+ }
+
+
+}
+}
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/b78de5c0/frameworks/projects/experimental_mobile/src/spark/skins/MobileGridHeaderFirstButtonSkin.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/experimental_mobile/src/spark/skins/MobileGridHeaderFirstButtonSkin.as b/frameworks/projects/experimental_mobile/src/spark/skins/MobileGridHeaderFirstButtonSkin.as
new file mode 100644
index 0000000..d3240c2
--- /dev/null
+++ b/frameworks/projects/experimental_mobile/src/spark/skins/MobileGridHeaderFirstButtonSkin.as
@@ -0,0 +1,35 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// 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 spark.skins
+{
+import spark.skins.mobile.assets.MobileGridHeaderFirstButton_down;
+import spark.skins.mobile.assets.MobileGridHeaderFirstButton_up;
+
+public class MobileGridHeaderFirstButtonSkin extends MobileGridHeaderButtonSkin
+{
+
+ public function MobileGridHeaderFirstButtonSkin()
+ {
+ super();
+ upBorderSkin = MobileGridHeaderFirstButton_up;
+ downBorderSkin = MobileGridHeaderFirstButton_down;
+ }
+
+}
+}
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/b78de5c0/frameworks/projects/experimental_mobile/src/spark/skins/MobileGridSkin.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/experimental_mobile/src/spark/skins/MobileGridSkin.as b/frameworks/projects/experimental_mobile/src/spark/skins/MobileGridSkin.as
new file mode 100644
index 0000000..20c46a0
--- /dev/null
+++ b/frameworks/projects/experimental_mobile/src/spark/skins/MobileGridSkin.as
@@ -0,0 +1,178 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// 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 spark.skins
+{
+import flash.display.BlendMode;
+
+import mx.core.BitmapAsset;
+import mx.core.ClassFactory;
+import mx.core.DPIClassification;
+import mx.core.mx_internal;
+
+import spark.components.DataGroup;
+import spark.components.LabelItemRenderer;
+import spark.components.MobileGrid;
+import spark.components.Scroller;
+import spark.components.supportClasses.MobileGridHeader;
+import spark.layouts.HorizontalAlign;
+import spark.layouts.VerticalLayout;
+import spark.skins.mobile.supportClasses.MobileSkin;
+import spark.utils.MultiDPIBitmapSource;
+import spark.utils.MultiDPIBitmapSourceExt;
+
+use namespace mx_internal;
+
+public class MobileGridSkin extends MobileSkin
+{
+
+ [Embed(source="../../../assets/images/mobile320/dg_header_shadow.png")]
+ private const headerShadowCls320:Class;
+
+ [Embed(source="../../../assets/images/mobile160/dg_header_shadow.png")]
+ private const headerShadowCls160:Class;
+
+ public var hostComponent:MobileGrid;
+ // skin parts
+ public var headerGroup:MobileGridHeader;
+ public var scroller:Scroller;
+ public var dataGroup:DataGroup;
+ private var headerShadowCls:Class;
+ private var headerShadow:BitmapAsset;
+
+
+ public function MobileGridSkin()
+ {
+ super();
+ minWidth = 112;
+ blendMode = BlendMode.NORMAL;
+ switch (applicationDPI)
+ {
+ case DPIClassification.DPI_320:
+ case DPIClassification.DPI_480:
+ minWidth = 200;
+ break;
+ case DPIClassification.DPI_160:
+ case DPIClassification.DPI_240:
+ default:
+ minWidth = 100;
+ break;
+ }
+ var headerShadowSrc:MultiDPIBitmapSource = new MultiDPIBitmapSourceExt();
+ headerShadowSrc.source320dpi = headerShadowCls320;
+ headerShadowSrc.source160dpi = headerShadowCls160;
+ headerShadowCls = Class(headerShadowSrc.getSource(NaN));
+ }
+
+ override protected function commitCurrentState():void
+ {
+ super.commitCurrentState();
+ alpha = currentState.indexOf("disabled") == -1 ? 1 : 0.5;
+ }
+
+
+ /**
+ * @private
+ */
+ override protected function createChildren():void
+ {
+
+ if (!dataGroup)
+ {
+ // Create data group layout
+ var layout:VerticalLayout = new VerticalLayout();
+ layout.requestedMinRowCount = 5;
+ layout.horizontalAlign = HorizontalAlign.JUSTIFY;
+ layout.gap = 0;
+
+ // Create data group
+ dataGroup = new DataGroup();
+ dataGroup.layout = layout;
+ dataGroup.itemRenderer = new ClassFactory(LabelItemRenderer);
+ }
+ if (!scroller)
+ {
+ // Create scroller
+ scroller = new Scroller();
+ scroller.minViewportInset = 1;
+ scroller.hasFocusableChildren = false;
+ scroller.ensureElementIsVisibleForSoftKeyboard = false;
+ addChild(scroller);
+ }
+
+ // Associate scroller with data group
+ if (!scroller.viewport)
+ {
+ scroller.viewport = dataGroup;
+ }
+
+ headerShadow = new headerShadowCls();
+ addChild(headerShadow);
+
+ /* add after, for the drop shadow*/
+
+ headerGroup = new MobileGridHeader();
+ headerGroup.id = "hg";
+ addChild(headerGroup);
+ }
+
+ /**
+ * @private
+ */
+ override protected function measure():void
+ {
+ measuredWidth = scroller.getPreferredBoundsWidth();
+ measuredHeight = scroller.getPreferredBoundsHeight() + headerGroup.getPreferredBoundsHeight();
+ }
+
+ /**
+ * @private
+ */
+ override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void
+ {
+ super.updateDisplayList(unscaledWidth, unscaledHeight);
+
+ var borderWidth:int = getStyle("borderVisible") ? 1 : 0;
+ var headerHeight:Number = headerGroup.getPreferredBoundsHeight();
+
+ // Background
+ graphics.beginFill(getStyle("contentBackgroundColor"), getStyle("contentBackgroundAlpha"));
+ graphics.drawRect(borderWidth, borderWidth, unscaledWidth - 2 * borderWidth, unscaledHeight - 2 * borderWidth);
+ graphics.endFill();
+
+ // Border
+ if (getStyle("borderVisible"))
+ {
+ graphics.lineStyle(1, getStyle("borderColor"), getStyle("borderAlpha"), true);
+ graphics.drawRect(0, 0, unscaledWidth - 1, unscaledHeight - 1);
+ }
+
+ // Header
+ setElementSize(headerGroup, unscaledWidth, headerHeight);
+ setElementPosition(headerGroup, 0, 0);
+
+ //Shadow
+ setElementSize(headerShadow, unscaledWidth, headerShadow.height);
+ setElementPosition(headerShadow, 0, headerHeight);
+ // Scroller
+ scroller.minViewportInset = borderWidth;
+ setElementSize(scroller, unscaledWidth, unscaledHeight);
+ setElementPosition(scroller, 0, headerHeight);
+ }
+}
+}
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/b78de5c0/frameworks/projects/experimental_mobile/src/spark/skins/mobile/assets/MobileGridHeaderButton_down.fxg
----------------------------------------------------------------------
diff --git a/frameworks/projects/experimental_mobile/src/spark/skins/mobile/assets/MobileGridHeaderButton_down.fxg b/frameworks/projects/experimental_mobile/src/spark/skins/mobile/assets/MobileGridHeaderButton_down.fxg
new file mode 100644
index 0000000..37be5cc
--- /dev/null
+++ b/frameworks/projects/experimental_mobile/src/spark/skins/mobile/assets/MobileGridHeaderButton_down.fxg
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+////////////////////////////////////////////////////////////////////////////////
+//
+// 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.
+//
+////////////////////////////////////////////////////////////////////////////////
+-->
+<Graphic version="2.0" xmlns="http://ns.adobe.com/fxg/2008"
+ scaleGridLeft="5" scaleGridRight="49" scaleGridTop="10" scaleGridBottom="54">
+
+ <Rect width="50" height="64">
+ <fill>
+ <LinearGradient x="0" y="0" scaleX="64" rotation="90">
+ <GradientEntry color="#B0B0B0" ratio="0"/>
+ <GradientEntry color="#5b5b5b" ratio="0.05"/>
+ <GradientEntry color="#505050" ratio="0.75"/>
+ <GradientEntry color="#404040" ratio="1"/>
+ </LinearGradient>
+ </fill>
+ </Rect>
+ <Rect width="1" height="40" x="0" y="12">
+ <fill>
+ <SolidColor color="#666666" alpha="0.5"/>
+ </fill>
+ </Rect>
+ <Rect width="1" height="40" x="1" y="12">
+ <fill>
+ <SolidColor color="#cccccc" alpha="0.5"/>
+ </fill>
+ </Rect>
+
+</Graphic>
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/b78de5c0/frameworks/projects/experimental_mobile/src/spark/skins/mobile/assets/MobileGridHeaderButton_up.fxg
----------------------------------------------------------------------
diff --git a/frameworks/projects/experimental_mobile/src/spark/skins/mobile/assets/MobileGridHeaderButton_up.fxg b/frameworks/projects/experimental_mobile/src/spark/skins/mobile/assets/MobileGridHeaderButton_up.fxg
new file mode 100644
index 0000000..6130486
--- /dev/null
+++ b/frameworks/projects/experimental_mobile/src/spark/skins/mobile/assets/MobileGridHeaderButton_up.fxg
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+////////////////////////////////////////////////////////////////////////////////
+//
+// 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.
+//
+////////////////////////////////////////////////////////////////////////////////
+-->
+<Graphic version="2.0" xmlns="http://ns.adobe.com/fxg/2008"
+ scaleGridLeft="5" scaleGridRight="49" scaleGridTop="10" scaleGridBottom="54">
+ <Rect width="50" height="64">
+ <fill>
+ <LinearGradient x="0" y="0" scaleX="64" rotation="90">
+ <GradientEntry color="#999999" ratio="0"/>
+ <GradientEntry color="#404040" ratio="0.05"/>
+ <GradientEntry color="#303030" ratio="0.75"/>
+ <GradientEntry color="#202020" ratio="1"/>
+ </LinearGradient>
+ </fill>
+ </Rect>
+ <Rect width="1" height="40" x="0" y="12">
+ <fill>
+ <SolidColor color="#666666" alpha="0.5"/>
+ </fill>
+ </Rect>
+ <Rect width="1" height="40" x="1" y="12">
+ <fill>
+ <SolidColor color="#cccccc" alpha="0.5"/>
+ </fill>
+ </Rect>
+</Graphic>
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/b78de5c0/frameworks/projects/experimental_mobile/src/spark/skins/mobile/assets/MobileGridHeaderFirstButton_down.fxg
----------------------------------------------------------------------
diff --git a/frameworks/projects/experimental_mobile/src/spark/skins/mobile/assets/MobileGridHeaderFirstButton_down.fxg b/frameworks/projects/experimental_mobile/src/spark/skins/mobile/assets/MobileGridHeaderFirstButton_down.fxg
new file mode 100644
index 0000000..1540367
--- /dev/null
+++ b/frameworks/projects/experimental_mobile/src/spark/skins/mobile/assets/MobileGridHeaderFirstButton_down.fxg
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+////////////////////////////////////////////////////////////////////////////////
+//
+// 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.
+//
+////////////////////////////////////////////////////////////////////////////////
+-->
+<Graphic version="2.0" xmlns="http://ns.adobe.com/fxg/2008">
+ <Rect width="160" height="64">
+ <fill>
+ <LinearGradient x="0" y="0" scaleX="64" rotation="90">
+ <GradientEntry color="#B0B0B0" ratio="0"/>
+ <GradientEntry color="#5b5b5b" ratio="0.05"/>
+ <GradientEntry color="#505050" ratio="0.75"/>
+ <GradientEntry color="#404040" ratio="1"/>
+ </LinearGradient>
+ </fill>
+ </Rect>
+
+</Graphic>
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/b78de5c0/frameworks/projects/experimental_mobile/src/spark/skins/mobile/assets/MobileGridHeaderFirstButton_up.fxg
----------------------------------------------------------------------
diff --git a/frameworks/projects/experimental_mobile/src/spark/skins/mobile/assets/MobileGridHeaderFirstButton_up.fxg b/frameworks/projects/experimental_mobile/src/spark/skins/mobile/assets/MobileGridHeaderFirstButton_up.fxg
new file mode 100644
index 0000000..d898d78
--- /dev/null
+++ b/frameworks/projects/experimental_mobile/src/spark/skins/mobile/assets/MobileGridHeaderFirstButton_up.fxg
@@ -0,0 +1,32 @@
+<Graphic version="2.0" xmlns="http://ns.adobe.com/fxg/2008">
+ <!--
+////////////////////////////////////////////////////////////////////////////////
+//
+// 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.
+//
+////////////////////////////////////////////////////////////////////////////////
+-->
+ <Rect width="100" height="64">
+ <fill>
+ <LinearGradient x="0" y="0" scaleX="64" rotation="90">
+ <GradientEntry color="#999999" ratio="0"/>
+ <GradientEntry color="#404040" ratio="0.05"/>
+ <GradientEntry color="#303030" ratio="0.75"/>
+ <GradientEntry color="#202020" ratio="1"/>
+ </LinearGradient>
+ </fill>
+ </Rect>
+</Graphic>
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/b78de5c0/frameworks/projects/experimental_mobile/src/spark/utils/DensityUtil2.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/experimental_mobile/src/spark/utils/DensityUtil2.as b/frameworks/projects/experimental_mobile/src/spark/utils/DensityUtil2.as
new file mode 100644
index 0000000..8c76e73
--- /dev/null
+++ b/frameworks/projects/experimental_mobile/src/spark/utils/DensityUtil2.as
@@ -0,0 +1,88 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// 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 spark.utils
+{
+
+import mx.core.FlexGlobals;
+import mx.core.mx_internal;
+import mx.managers.SystemManager;
+
+import spark.components.Application;
+
+public class DensityUtil2
+{
+
+ use namespace mx_internal;
+
+ private static var _setApplicationDPI:Number = 0;
+
+ /** Calculates a scale factor to be used when element authored for <code>sourceDPI</code>
+ * two algorithms: <br/>
+ * Application.applicationDPI has been set, which means scaling factor occurs already, so additional scaling is required, return 1
+ * Application.applicationDPI has not been set, then return runTimeDPI / sourceDPI
+ * examples:
+ * runtimeDPI = 320 and sourceDPI = 160 and applicationDPI not set (ie=320) => 2
+ * runtimeDPI = 160 and sourceDPI = 160 and applicationDPI not set (ie=160) => 1
+ * runtimeDPI = 160 and sourceDPI = 160 and applicationDPI = 160 => 1
+ * runtimeDPI = 320 and sourceDPI = 160 and applicationDPI = 160 => 1 (scaling occurs)
+ * @param sourceDPI
+ * @return scale factor
+ */
+
+ public static function getPostDPIScale(sourceDPI:Number):Number
+ {
+
+ var appDPI:Number = getSetApplicationDPI();
+ if (isNaN(appDPI))
+ {
+ // was not set,
+ var runDPI:Number = FlexGlobals.topLevelApplication.runtimeDPI;
+ return runDPI / sourceDPI;
+ }
+ else
+ return 1.0; // already scaled
+ }
+
+
+ public static function dpiScale(value:Number, sourceDPI:Number):Number
+ {
+ var appDPI:Number = getSetApplicationDPI();
+ if (isNaN(appDPI))
+ {
+ var runDPI:Number = FlexGlobals.topLevelApplication.runtimeDPI;
+ return value * runDPI / sourceDPI;
+ }
+ else
+ return value; // already scaled
+
+ }
+
+ private static function getSetApplicationDPI():Number
+ {
+ if (_setApplicationDPI == 0)
+ {
+ var application:Application = FlexGlobals.topLevelApplication as Application;
+ var sm:SystemManager = application ? application.systemManager as SystemManager : null;
+ _setApplicationDPI = sm ? sm.info()["applicationDPI"] : NaN;
+ }
+ return _setApplicationDPI;
+ }
+
+}
+}
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/b78de5c0/frameworks/projects/experimental_mobile/src/spark/utils/MultiDPIBitmapSourceExt.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/experimental_mobile/src/spark/utils/MultiDPIBitmapSourceExt.as b/frameworks/projects/experimental_mobile/src/spark/utils/MultiDPIBitmapSourceExt.as
new file mode 100644
index 0000000..eb3ac03
--- /dev/null
+++ b/frameworks/projects/experimental_mobile/src/spark/utils/MultiDPIBitmapSourceExt.as
@@ -0,0 +1,44 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// 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 spark.utils
+{
+import mx.core.FlexGlobals;
+import mx.utils.DensityUtil;
+
+public class MultiDPIBitmapSourceExt extends MultiDPIBitmapSource
+{
+
+
+ override public function getSource(desiredDPI:Number):Object
+ {
+ if (isNaN(desiredDPI))
+ {
+ var app:Object = FlexGlobals.topLevelApplication;
+ var dpi:Number;
+ if ("runtimeDPI" in app)
+ dpi = app["runtimeDPI"];
+ else
+ dpi = DensityUtil.getRuntimeDPI();
+ return getSource(dpi);
+ }
+ else
+ return super.getSource(desiredDPI);
+ }
+}
+}
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/b78de5c0/frameworks/projects/experimental_mobile/src/spark/utils/UIComponentUtils.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/experimental_mobile/src/spark/utils/UIComponentUtils.as b/frameworks/projects/experimental_mobile/src/spark/utils/UIComponentUtils.as
new file mode 100644
index 0000000..0ecf82c
--- /dev/null
+++ b/frameworks/projects/experimental_mobile/src/spark/utils/UIComponentUtils.as
@@ -0,0 +1,163 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// 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 spark.utils
+{
+import mx.collections.IList;
+import mx.core.IFlexDisplayObject;
+import mx.core.ILayoutElement;
+import mx.core.UIComponent;
+
+import spark.components.IItemRendererOwner;
+
+public class UIComponentUtils
+{
+
+ /* fast function based on char length and not on pixel length*/
+ public static function computeLongestItem(listComponent:IItemRendererOwner, dataProvider:IList, max:int = 10):Object
+ {
+ if (!dataProvider)
+ {
+ return null;
+ }
+ max = Math.min(max, dataProvider.length);
+ var maxLength:int = 0;
+ var longestItem:Object;
+ var item:Object;
+ var itemStringLength:int;
+ for (var i:int = 0; i < max; i++)
+ {
+ item = dataProvider.getItemAt(i);
+ itemStringLength = listComponent.itemToLabel(item).length;
+ if (itemStringLength >= maxLength)
+ {
+ maxLength = itemStringLength;
+ longestItem = item;
+ }
+ }
+ return longestItem;
+ }
+
+ public static function itemToLabel(item:Object, labelField:String, labelFunction:Function, nullLabel:String = '-'):String
+ {
+ if (labelFunction != null)
+ {
+ return labelFunction(item);
+ }
+ else if (item == null)
+ {
+ return nullLabel;
+ }
+ else
+ {
+ return item[labelField];
+ }
+ }
+
+ public static function clearBoundsSize(comp:UIComponent):void
+ {
+ comp.explicitWidth = NaN; // was set before
+ comp.explicitHeight = NaN;
+ comp.setLayoutBoundsSize(NaN, NaN);
+ }
+
+ public static function setElementSize(element:Object, width:Number, height:Number):void
+ {
+ if (element is ILayoutElement)
+ {
+ ILayoutElement(element).setLayoutBoundsSize(width, height, false);
+ }
+ else if (element is IFlexDisplayObject)
+ {
+ IFlexDisplayObject(element).setActualSize(width, height);
+ }
+ else
+ {
+ element.width = width;
+ element.height = height;
+ }
+ }
+
+ public static function setElementPosition(element:Object, x:Number, y:Number):void
+ {
+ if (element is ILayoutElement)
+ {
+ ILayoutElement(element).setLayoutBoundsPosition(x, y, false);
+ }
+ else if (element is IFlexDisplayObject)
+ {
+ IFlexDisplayObject(element).move(x, y);
+ }
+ else
+ {
+ element.x = x;
+ element.y = y;
+ }
+ }
+
+ public static function getElementPreferredWidth(element:Object):Number
+ {
+ var result:Number;
+
+ if (element is ILayoutElement)
+ {
+ result = ILayoutElement(element).getPreferredBoundsWidth();
+ }
+ else if (element is IFlexDisplayObject)
+ {
+ result = IFlexDisplayObject(element).measuredWidth;
+ }
+ else
+ {
+ result = element.width;
+ }
+ return Math.round(result);
+ }
+
+ public static function getElementPreferredHeight(element:Object):Number
+ {
+ var result:Number;
+
+ if (element is ILayoutElement)
+ {
+ result = ILayoutElement(element).getPreferredBoundsHeight();
+ }
+ else if (element is IFlexDisplayObject)
+ {
+ result = IFlexDisplayObject(element).measuredHeight;
+ }
+ else
+ {
+ result = element.height;
+ }
+ return Math.ceil(result);
+ }
+
+ public static function offsetForCenter(inLength:Number, outLength:Number):Number
+ {
+ return ( outLength - inLength) / 2;
+ }
+
+ public static function setElementPositionTopRight(component:Object, container:Object, paddingTop:Number = 0, paddingRight:Number = 0):void
+ {
+ var right:Number = getElementPreferredWidth(container) - getElementPreferredWidth(component) - paddingRight;
+ setElementPosition(component, paddingTop, right);
+ }
+
+}
+}
[3/5] git commit: [flex-sdk] [refs/heads/mobileexperimental] -
https://issues.apache.org/jira/browse/FLEX-33777 Dagrid for mobile - fixed
Bitmap scaling using BitmapImage instead of BitmapAsset - fixed last column
width
Posted by ma...@apache.org.
https://issues.apache.org/jira/browse/FLEX-33777 Dagrid for mobile
- fixed Bitmap scaling using BitmapImage instead of BitmapAsset
- fixed last column width
Project: http://git-wip-us.apache.org/repos/asf/flex-sdk/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-sdk/commit/fe39973b
Tree: http://git-wip-us.apache.org/repos/asf/flex-sdk/tree/fe39973b
Diff: http://git-wip-us.apache.org/repos/asf/flex-sdk/diff/fe39973b
Branch: refs/heads/mobileexperimental
Commit: fe39973bd62f7ebac64a16de58f8070517bba877
Parents: b78de5c
Author: mamsellem <ma...@systar.com>
Authored: Tue Oct 1 23:05:14 2013 +0200
Committer: mamsellem <ma...@systar.com>
Committed: Tue Oct 1 23:05:14 2013 +0200
----------------------------------------------------------------------
.../projects/experimental_mobile/defaults.css | 38 +++-
.../src/ExperimentalMobileClasses.as | 6 +-
.../src/spark/components/MobileGrid.as | 34 ++--
.../itemRenderers/IItemPartRendererBase.as | 5 +-
.../itemRenderers/IItemTextPartRenderer.as | 4 -
.../itemRenderers/ItemBitmapPartRenderer.as | 54 ++----
.../itemRenderers/ItemTextPartRenderer.as | 10 ++
.../supportClasses/IPartRendererDescriptor.as | 34 ----
.../supportClasses/ListMultiPartColumnLayout.as | 97 +++++++++++
.../ListMultiPartItemRendererBase.as | 172 +++++++++++++++++--
.../supportClasses/ListMultiPartLayoutBase.as | 9 +-
.../supportClasses/ListMultiPartTabbedLayout.as | 82 ---------
.../supportClasses/MobileGridColumn.as | 6 +-
.../supportClasses/MobileGridHeader.as | 15 +-
.../supportClasses/MobileGridRowRenderer.as | 2 +-
.../PartRendererDescriptorBase.as | 69 ++++----
.../src/spark/events/MobileGridHeaderEvent.as | 2 +-
.../src/spark/skins/MobileGridSkin.as | 3 +-
.../src/spark/utils/DensityUtil2.as | 38 +---
.../src/spark/utils/MultiDPIBitmapSourceExt.as | 23 ++-
.../src/spark/utils/UIComponentUtils.as | 34 ----
21 files changed, 433 insertions(+), 304 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/fe39973b/frameworks/projects/experimental_mobile/defaults.css
----------------------------------------------------------------------
diff --git a/frameworks/projects/experimental_mobile/defaults.css b/frameworks/projects/experimental_mobile/defaults.css
index 236ea6f..aaf188b 100644
--- a/frameworks/projects/experimental_mobile/defaults.css
+++ b/frameworks/projects/experimental_mobile/defaults.css
@@ -26,7 +26,8 @@ MobileGrid
contentBackgroundColor: #202020;
alternatingItemColors: #202020, #2a2a2a;
color: white;
- selection-color: #00a2ff; /* blue */
+ selection-color: #00a2ff; /* blue */
+
}
supportClasses|MobileGridHeader
@@ -37,9 +38,10 @@ supportClasses|MobileGridHeader
/* color: #f0f0f0; */
}
-supportClasses|ItemRendererBase
+supportClasses|MobileGridRowRenderer
{
verticalAlign: "middle";
+ downColor: #000000;;
}
@media (application-dpi: 120)
@@ -60,7 +62,6 @@ supportClasses|ItemRendererBase
supportClasses|ItemRendererBase
{
- color: #bae5ff;
paddingBottom: 12;
paddingLeft: 7;
paddingRight: 7;
@@ -73,7 +74,7 @@ supportClasses|ItemRendererBase
supportClasses|MobileGridHeader
{
- fontSize: 14;
+ fontSize: 18;
}
supportClasses|MobileGridRowRenderer
@@ -86,7 +87,6 @@ supportClasses|ItemRendererBase
supportClasses|ItemRendererBase
{
- color: #acffb5;
paddingBottom: 16;
paddingLeft: 10;
paddingRight: 10;
@@ -112,7 +112,6 @@ supportClasses|ItemRendererBase
supportClasses|ItemRendererBase
{
- color: #fbffa0;
paddingBottom: 24;
paddingLeft: 14;
paddingRight: 14;
@@ -130,7 +129,6 @@ supportClasses|ItemRendererBase
supportClasses|MobileGridRowRenderer
{
- color: #ffc2aa;
paddingTop: 2;
paddingLeft: 20;
paddingRight: 20;
@@ -146,4 +144,30 @@ supportClasses|ItemRendererBase
}
}
+@media (application-dpi: 480)
+{
+
+ supportClasses|MobileGridHeader
+ {
+ fontSize: 40;
+ }
+
+ supportClasses|MobileGridRowRenderer
+ {
+ paddingTop: 4;
+ paddingLeft: 28;
+ paddingRight: 28;
+ paddingBottom: 0;
+ }
+
+ supportClasses|ItemRendererBase
+ {
+ paddingBottom: 48;
+ paddingLeft: 28;
+ paddingRight: 28;
+ paddingTop: 48;
+ }
+}
+
+
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/fe39973b/frameworks/projects/experimental_mobile/src/ExperimentalMobileClasses.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/experimental_mobile/src/ExperimentalMobileClasses.as b/frameworks/projects/experimental_mobile/src/ExperimentalMobileClasses.as
index 215735f..b695712 100644
--- a/frameworks/projects/experimental_mobile/src/ExperimentalMobileClasses.as
+++ b/frameworks/projects/experimental_mobile/src/ExperimentalMobileClasses.as
@@ -25,10 +25,10 @@ import spark.skins.MobileGridSkin;
/*
classes that won't be detected through dependencies
-* and classes that needs to be includes in ASDOC
-* */
+ * and classes that needs to be includes in ASDOC
+ * */
- internal class ExperimentalMobileClasses
+internal class ExperimentalMobileClasses
{
// mamsellem: for some reason, the import statements alone are not enough to have the classes included
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/fe39973b/frameworks/projects/experimental_mobile/src/spark/components/MobileGrid.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/experimental_mobile/src/spark/components/MobileGrid.as b/frameworks/projects/experimental_mobile/src/spark/components/MobileGrid.as
index 618a1bc..4161580 100644
--- a/frameworks/projects/experimental_mobile/src/spark/components/MobileGrid.as
+++ b/frameworks/projects/experimental_mobile/src/spark/components/MobileGrid.as
@@ -27,10 +27,10 @@ import mx.core.ScrollPolicy;
import mx.core.mx_internal;
import spark.collections.Sort;
-import spark.components.supportClasses.IPartRendererDescriptor;
import spark.components.supportClasses.MobileGridColumn;
import spark.components.supportClasses.MobileGridHeader;
import spark.components.supportClasses.MobileGridRowRenderer;
+import spark.components.supportClasses.PartRendererDescriptorBase;
import spark.events.MobileGridHeaderEvent;
import spark.layouts.VerticalLayout;
import spark.layouts.supportClasses.LayoutBase;
@@ -58,7 +58,7 @@ use namespace mx_internal;
/**
* The MobileGrid displays a collection of items in a grid of rows and columns, with column headers, optimized for mobile devices.
- * <p> The MobileGrid component provides the following features: </p>
+ * The MobileGrid component provides the following features:
* <ul>
* <li> user can swipe through the rows in the datagrid. </li>
* <li> supports single selection of a row. </li>
@@ -69,18 +69,18 @@ use namespace mx_internal;
*
* <p> It's important to understand that MobileGrid does not have all the capabilities and flexibility of it's desktop equivalent,
* in order to ensure optimal display and scrolling performance on mobile devices. </p>
- * <p>Typically, the following features are not available in MobileGrid: </p>
+ * <p>Typically, the following features are not available in MobileGrid:
* <ul>
* <li>the list of columns is static and cannot be changed at runtime</li>
* <li>multiple selection is not supported </li>
* <li>it's not possible to interactively reorder columns </li>
* <li>custom cell renderers must be designed with care, preferably in ActionScript, to ensure good display performance </li>
* </ul>
- *
- * <p>Internally, MobileGrid inherits for Mobile spark.List component rather than any Grid or DataGrid, which means that all cell renderers in a single row are managed
- * by one single MobileGridRowRenderer that delegates the individual cell renderers to light-weight sub-renderers. </p>
+ * </p>
+ * <p>Internally, MobileGrid inherits for Mobile spark.List component rather than any Grid or DataGrid, which means that all cell renderers
+ * in a single row are managed by one single MobileGridRowRenderer that delegates the individual cell renderers to light-weight sub-renderers. </p>
* <p> You usually don't access this internal row renderer yourself, and will rather define the individual cell renderers.</p>
- * <p> This technique ensures optimal display and memory performance, which is critical for mobile devices,, at the price of less flexibility for cell renderers </p>
+ * <p> This technique ensures optimal display and memory performance, which is critical for mobile devices,, at the price of less flexibility for cell renderers. </p>
*
* @see spark.components.supportClasses.MobileGridColumn
*
@@ -94,7 +94,7 @@ public class MobileGrid extends List
[SkinPart(required="true")]
public var headerGroup:MobileGridHeader;
- private var _columns: Array;
+ private var _columns:Array;
private var _columnsChanged:Boolean = false;
private var _sortableColumns:Boolean = true;
private var lastSortIndex:int = -1;
@@ -174,7 +174,8 @@ public class MobileGrid extends List
override protected function commitProperties():void
{
super.commitProperties();
- if (_columnsChanged){
+ if (_columnsChanged)
+ {
_columnsChanged = false;
for (var i:int = 0; i < _columns.length; i++)
{
@@ -195,12 +196,12 @@ public class MobileGrid extends List
return l;
}
- protected function initDefaultItemRenderer(pcolumnDescriptors: Array):void
+ protected function initDefaultItemRenderer(pcolumnDescriptors:Array):void
{
var cf:ClassFactory;
cf = new ClassFactory(MobileGridRowRenderer);
cf.properties = {
- partRendererDescriptors: Vector.<IPartRendererDescriptor>(pcolumnDescriptors)
+ partRendererDescriptors: Vector.<PartRendererDescriptorBase>(pcolumnDescriptors)
};
this.itemRenderer = cf;
}
@@ -230,10 +231,10 @@ public class MobileGrid extends List
private function headerGroup_sortChangeHandler(event:MobileGridHeaderEvent):void
{
var e:MobileGridHeaderEvent = MobileGridHeaderEvent(event.clone());
- dispatchEvent( e)
+ dispatchEvent(e)
if (!e.isDefaultPrevented())
{
- sortByColumn(e.columnIndex);
+ sortByColumn(e.columnIndex);
}
}
@@ -243,7 +244,7 @@ public class MobileGrid extends List
var collection:ICollectionView = dataProvider as ICollectionView;
var c:MobileGridColumn = _columns[index];
if (!c.sortable)
- return ;
+ return;
var desc:Boolean = c.sortDescending;
// do the sort if we're allowed to
@@ -297,6 +298,11 @@ public class MobileGrid extends List
}
+ override public function validateSize(recursive:Boolean = false):void
+ {
+ super.validateSize(recursive);
+ }
+
}
}
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/fe39973b/frameworks/projects/experimental_mobile/src/spark/components/itemRenderers/IItemPartRendererBase.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/experimental_mobile/src/spark/components/itemRenderers/IItemPartRendererBase.as b/frameworks/projects/experimental_mobile/src/spark/components/itemRenderers/IItemPartRendererBase.as
index 7194e75..ab802f3 100644
--- a/frameworks/projects/experimental_mobile/src/spark/components/itemRenderers/IItemPartRendererBase.as
+++ b/frameworks/projects/experimental_mobile/src/spark/components/itemRenderers/IItemPartRendererBase.as
@@ -34,6 +34,10 @@ public interface IItemPartRendererBase extends IDataRenderer
*/
function set styleProvider(value:IStyleClient):void ;
+ function get canSetWidth():Boolean;
+
+ function get canSetHeight():Boolean;
+
/**
* @private
*/
@@ -50,6 +54,5 @@ public interface IItemPartRendererBase extends IDataRenderer
function getPreferredBoundsHeight(postLayoutTransform:Boolean = true):Number;
-
}
}
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/fe39973b/frameworks/projects/experimental_mobile/src/spark/components/itemRenderers/IItemTextPartRenderer.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/experimental_mobile/src/spark/components/itemRenderers/IItemTextPartRenderer.as b/frameworks/projects/experimental_mobile/src/spark/components/itemRenderers/IItemTextPartRenderer.as
index 69c3008..edcc0f9 100644
--- a/frameworks/projects/experimental_mobile/src/spark/components/itemRenderers/IItemTextPartRenderer.as
+++ b/frameworks/projects/experimental_mobile/src/spark/components/itemRenderers/IItemTextPartRenderer.as
@@ -19,10 +19,6 @@
package spark.components.itemRenderers
{
-import flash.display.DisplayObjectContainer;
-
-import mx.core.IDataRenderer;
-
public interface IItemTextPartRenderer extends IItemPartRendererBase
{
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/fe39973b/frameworks/projects/experimental_mobile/src/spark/components/itemRenderers/ItemBitmapPartRenderer.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/experimental_mobile/src/spark/components/itemRenderers/ItemBitmapPartRenderer.as b/frameworks/projects/experimental_mobile/src/spark/components/itemRenderers/ItemBitmapPartRenderer.as
index b5e7abe..c95195b 100644
--- a/frameworks/projects/experimental_mobile/src/spark/components/itemRenderers/ItemBitmapPartRenderer.as
+++ b/frameworks/projects/experimental_mobile/src/spark/components/itemRenderers/ItemBitmapPartRenderer.as
@@ -19,15 +19,18 @@
package spark.components.itemRenderers
{
-import mx.core.BitmapAsset;
+import mx.core.mx_internal;
+import mx.graphics.BitmapFillMode;
import mx.styles.IStyleClient;
-import spark.utils.MultiDPIBitmapSourceExt;
+import spark.primitives.BitmapImage;
+
+use namespace mx_internal;
/** Default lightweight class for rendering embedded Bitmaps or Multi-DPI Bitmaps in a MobileGrid cell .
* <p> You define the icon to be used in each cell by setting either iconField or iconFunction properties. </p>
* */
-public class ItemBitmapPartRenderer extends BitmapAsset implements IItemPartRendererBase
+public class ItemBitmapPartRenderer extends BitmapImage implements IItemPartRendererBase
{
private var _iconFunction:Function = null;
@@ -37,6 +40,7 @@ public class ItemBitmapPartRenderer extends BitmapAsset implements IItemPartRend
public function ItemBitmapPartRenderer()
{
super();
+ _fillMode = BitmapFillMode.REPEAT; // do not stretch
}
/**
@@ -69,12 +73,12 @@ public class ItemBitmapPartRenderer extends BitmapAsset implements IItemPartRend
* <pre>iconFunction(item:Object):Object</pre>
*
* <p>The <code>item</code> parameter is the data provider item for an entire row.</p>
- * <p> The function must return either an embedded bitmap's class, or a MultiBitmapSourceExt object .</p>
+ * <p> The function must return either an embedded bitmap's class, or a MultiBitmapSource object .</p>
*
* @default null
*
* @see #iconLabel
- * @see spark.utils.MultiDPIBitmapSourceExt
+ * @see spark.utils.MultiDPIBitmapSource
*
*/
public function get iconFunction():Function
@@ -89,26 +93,9 @@ public class ItemBitmapPartRenderer extends BitmapAsset implements IItemPartRend
public function set data(value:Object):void
{
- var iconClass:Class;
_data = value;
var iconSource:Object = _iconFunction != null ? _iconFunction(_data) : _data[_iconField];
- if (iconSource is MultiDPIBitmapSourceExt)
- {
- iconClass = MultiDPIBitmapSourceExt(iconSource).getSource(NaN) as Class;
- }
- else
- {
- iconClass = iconSource as Class;
- }
- if (iconClass != null)
- {
- var icon:BitmapAsset = new iconClass();
- this.bitmapData = icon.bitmapData;
- }
- else
- {
- this.bitmapData = null;
- }
+ this.source = iconSource;
}
public function get data():Object
@@ -116,29 +103,26 @@ public class ItemBitmapPartRenderer extends BitmapAsset implements IItemPartRend
return _data;
}
- public function getPreferredBoundsWidth(postLayoutTransform:Boolean = true):Number
+ public function set styleProvider(value:IStyleClient):void
{
- return bitmapData.width;
+ // do nothing, this renderer does not manages styles for now.
}
- public function getPreferredBoundsHeight(postLayoutTransform:Boolean = true):Number
+ public function set cssStyleName(value:String):void
{
- return bitmapData.height;
- }
- override public function setActualSize(newWidth:Number, newHeight:Number):void
- {
- // do nothing, bitmap renderer don't stretch for now
}
- public function set styleProvider(value:IStyleClient):void
+ /* to avoid any scaling artifacts, we do not allow bitmap to be stretcghed */
+
+ public function get canSetWidth():Boolean
{
- // do nothing, this renderer does not manages styles for now.
+ return false;
}
- public function set cssStyleName(value:String):void
+ public function get canSetHeight():Boolean
{
+ return false;
}
-
}
}
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/fe39973b/frameworks/projects/experimental_mobile/src/spark/components/itemRenderers/ItemTextPartRenderer.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/experimental_mobile/src/spark/components/itemRenderers/ItemTextPartRenderer.as b/frameworks/projects/experimental_mobile/src/spark/components/itemRenderers/ItemTextPartRenderer.as
index afb991e..ca3f542 100644
--- a/frameworks/projects/experimental_mobile/src/spark/components/itemRenderers/ItemTextPartRenderer.as
+++ b/frameworks/projects/experimental_mobile/src/spark/components/itemRenderers/ItemTextPartRenderer.as
@@ -91,6 +91,16 @@ public class ItemTextPartRenderer extends StyleableTextField implements IItemTex
{
_labelFunction = value;
}
+
+ public function get canSetWidth():Boolean
+ {
+ return true;
+ }
+
+ public function get canSetHeight():Boolean
+ {
+ return false;
+ }
}
}
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/fe39973b/frameworks/projects/experimental_mobile/src/spark/components/supportClasses/IPartRendererDescriptor.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/experimental_mobile/src/spark/components/supportClasses/IPartRendererDescriptor.as b/frameworks/projects/experimental_mobile/src/spark/components/supportClasses/IPartRendererDescriptor.as
deleted file mode 100644
index c81f9f6..0000000
--- a/frameworks/projects/experimental_mobile/src/spark/components/supportClasses/IPartRendererDescriptor.as
+++ /dev/null
@@ -1,34 +0,0 @@
-////////////////////////////////////////////////////////////////////////////////
-//
-// 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 spark.components.supportClasses
-{
-
-import mx.core.IFactory;
-
-import spark.components.itemRenderers.IItemPartRendererBase;
-
-public interface IPartRendererDescriptor
-{
- function get scaledWidth():Number;
-
- function get itemRenderer():IFactory;
-
- function createPartRenderer():IItemPartRendererBase;
-}
-}
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/fe39973b/frameworks/projects/experimental_mobile/src/spark/components/supportClasses/ListMultiPartColumnLayout.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/experimental_mobile/src/spark/components/supportClasses/ListMultiPartColumnLayout.as b/frameworks/projects/experimental_mobile/src/spark/components/supportClasses/ListMultiPartColumnLayout.as
new file mode 100644
index 0000000..44c2c46
--- /dev/null
+++ b/frameworks/projects/experimental_mobile/src/spark/components/supportClasses/ListMultiPartColumnLayout.as
@@ -0,0 +1,97 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// 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 spark.components.supportClasses
+{
+import mx.core.mx_internal;
+
+import spark.components.itemRenderers.IItemPartRendererBase;
+import spark.utils.UIComponentUtils;
+
+use namespace mx_internal;
+
+/** @private
+ * this class is responsible for laying out grid cells in a given MobileGrid row.
+ * It will make sure that cell content is aligned according to the column widths.
+ */
+public class ListMultiPartColumnLayout extends ListMultiPartLayoutBase
+{
+
+ public function ListMultiPartColumnLayout(target:ListMultiPartItemRendererBase)
+ {
+ super(target);
+ }
+
+ override public function measure():void
+ {
+ super.measure();
+ var totalWidth:Number = 0;
+ for each (var ld:PartRendererDescriptorBase in partRendererDescriptors)
+ {
+ totalWidth += ld.dpiScaledWidth;
+ }
+ target.measuredWidth = totalWidth;
+ target.measuredMinWidth = 50;
+ }
+
+ /* vertical align middle
+ * Layout algorithm: give all columns the requested sizes, and the last column the remaining width */
+ override public function layoutContents(unscaledWidth:Number, unscaledHeight:Number):void
+ {
+
+ if (unscaledWidth == 0 && unscaledHeight == 0)
+ return; // not ready
+ var cellPaddingLeft:Number = target.getStyle("paddingLeft");
+ var cellPaddingRight:Number = target.getStyle("paddingRight");
+ var paddingTop:Number = target.getStyle("paddingTop");
+ var paddingBottom:Number = target.getStyle("paddingBottom");
+ var cellHeight:Number = unscaledHeight - paddingTop - paddingBottom;
+
+ var desc:PartRendererDescriptorBase;
+ var dpr:IItemPartRendererBase;
+ var remainingWidth:Number = unscaledWidth;
+ var curX:Number = cellPaddingLeft;
+ var curY:Number = paddingTop;
+ var colWidth:Number;
+ var partWidth:Number;
+ var partHeight:Number;
+ var count:int = partRenderers.length - 1;
+ for (var i:int = 0; i <= count; i++)
+ {
+ dpr = partRenderers[i];
+ desc = partRendererDescriptors[i];
+ colWidth = desc.dpiScaledWidth;
+ if (dpr.canSetWidth)
+ {
+ // expand last column to fill width, unless it has explicity width
+ partWidth = Math.max(0, ( i == count && !desc.hasExplicitWidth) ? remainingWidth : colWidth - cellPaddingLeft - cellPaddingRight);
+ }
+ else
+ {
+ partWidth = dpr.getPreferredBoundsHeight();
+ }
+ partHeight = dpr.canSetHeight ? cellHeight : dpr.getPreferredBoundsHeight();
+ ;
+ setElementSize(dpr, partWidth, partHeight);
+ setElementPosition(dpr, curX, curY + UIComponentUtils.offsetForCenter(partHeight, cellHeight));
+ curX += colWidth;
+ remainingWidth -= colWidth;
+ }
+ }
+}
+}
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/fe39973b/frameworks/projects/experimental_mobile/src/spark/components/supportClasses/ListMultiPartItemRendererBase.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/experimental_mobile/src/spark/components/supportClasses/ListMultiPartItemRendererBase.as b/frameworks/projects/experimental_mobile/src/spark/components/supportClasses/ListMultiPartItemRendererBase.as
index e53a968..8f07d5c 100644
--- a/frameworks/projects/experimental_mobile/src/spark/components/supportClasses/ListMultiPartItemRendererBase.as
+++ b/frameworks/projects/experimental_mobile/src/spark/components/supportClasses/ListMultiPartItemRendererBase.as
@@ -21,30 +21,44 @@ package spark.components.supportClasses
import flash.display.DisplayObject;
import spark.components.itemRenderers.IItemPartRendererBase;
+import spark.core.DisplayObjectSharingMode;
+import spark.core.IGraphicElement;
+import spark.core.IGraphicElementContainer;
+import spark.core.ISharedDisplayObject;
/** @private
* This is the base class for multi-part renderers that manages a vector of part renderers.
* This class is responsible for creating and storing the actual renderers from their descriptors
* the layout of the part renderers is delegated to a subclass of ListMultiPartLayoutBase;
*/
-public class ListMultiPartItemRendererBase extends ItemRendererBase
+public class ListMultiPartItemRendererBase extends ItemRendererBase implements IGraphicElementContainer, ISharedDisplayObject
{
- private var _partRendererDescriptors:Vector.<IPartRendererDescriptor>;
+ private var _partRendererDescriptors:Vector.<PartRendererDescriptorBase>;
private var _partRenderers:Vector.<IItemPartRendererBase>;
+ private var _graphicElementPartRenderers:Vector.<IGraphicElement>;
private var _partRenderersLayout:ListMultiPartLayoutBase;
+ /**
+ * Management of graphicElement part renderers lifeCycle
+ */
+ private var _redrawRequested:Boolean = false;
+ private var graphicElementsNeedValidateProperties:Boolean = false;
+ private var graphicElementsNeedValidateSize:Boolean = false;
+
public function ListMultiPartItemRendererBase()
{
}
- /* set by DataGridMobile Factory */
- public function set partRendererDescriptors(value:Vector.<IPartRendererDescriptor>):void
+ /** @private
+ * set in List itemRenderer Factory properties */
+ public function set partRendererDescriptors(value:Vector.<PartRendererDescriptorBase>):void
{
_partRendererDescriptors = value;
- _partRenderers = new Vector.<IItemPartRendererBase>(_partRendererDescriptors.length);
+ _partRenderers = new Vector.<IItemPartRendererBase>(_partRendererDescriptors.length, true);
+ _graphicElementPartRenderers = new Vector.<IGraphicElement>();
}
- public function get partRendererDescriptors():Vector.<IPartRendererDescriptor>
+ public function get partRendererDescriptors():Vector.<PartRendererDescriptorBase>
{
return _partRendererDescriptors;
}
@@ -64,11 +78,17 @@ public class ListMultiPartItemRendererBase extends ItemRendererBase
return _partRenderers;
}
+ public function get graphicElementPartRenderers():Vector.<IGraphicElement>
+ {
+ return _graphicElementPartRenderers;
+ }
+
override protected function createChildren():void
{
super.createChildren();
- var desc:IPartRendererDescriptor;
+ var desc:PartRendererDescriptorBase;
var pr:IItemPartRendererBase;
+ var ge:IGraphicElement;
for (var i:int = 0; i < _partRendererDescriptors.length; i++)
{
desc = _partRendererDescriptors[i];
@@ -76,13 +96,27 @@ public class ListMultiPartItemRendererBase extends ItemRendererBase
if (pr != null)
{
pr.styleProvider = this;
- addChild(DisplayObject(pr));
+
+ if (pr is IGraphicElement)
+ {
+ ge = IGraphicElement(pr);
+ ge.parentChanged(this);
+ if (ge.setSharedDisplayObject(this))
+ {
+ ge.displayObjectSharingMode = DisplayObjectSharingMode.USES_SHARED_OBJECT;
+ }
+ _graphicElementPartRenderers.push(ge);
+ }
+ else if (pr is DisplayObject)
+ {
+ addChild(DisplayObject(pr));
+ }
_partRenderers[i] = pr;
}
else
{
//TODO move to resource bundle
- throw new Error("MobileGridColumn item renderer must implement spark.components.itemRenderers.IItemPartRendererBase") ;
+ throw new Error("MobileGridColumn item renderer must implement spark.components.itemRenderers.IItemPartRendererBase");
}
}
}
@@ -93,9 +127,9 @@ public class ListMultiPartItemRendererBase extends ItemRendererBase
_partRenderersLayout.measure();
}
- /** delegate children layout to its partRendererLayout
- subclasses can override this method to layout chrome content
- */
+ /** delegate children layout to its partRendererLayout
+ subclasses can override this method to layout chrome content
+ */
override protected function layoutContents(unscaledWidth:Number, unscaledHeight:Number):void
{
_partRenderersLayout.layoutContents(unscaledWidth, unscaledHeight);
@@ -112,6 +146,120 @@ public class ListMultiPartItemRendererBase extends ItemRendererBase
invalidateSize();
}
+ /* graphic element sub renderers lifecycle management */
+
+ override protected function commitProperties():void
+ {
+ if (graphicElementsNeedValidateProperties)
+ {
+ graphicElementsNeedValidateProperties = false;
+ for (var i:int = 0; i < _graphicElementPartRenderers.length; i++)
+ {
+ _graphicElementPartRenderers[i].validateProperties();
+ }
+ }
+ super.commitProperties();
+ }
+
+
+ override public function validateSize(recursive:Boolean = false):void
+ {
+ if (graphicElementsNeedValidateSize)
+ {
+ graphicElementsNeedValidateSize = false;
+ for (var i:int = 0; i < _graphicElementPartRenderers.length; i++)
+ {
+ _graphicElementPartRenderers[i].validateSize();
+ }
+ }
+ super.validateSize(recursive);
+ }
+
+
+ /* copied from Group*/
+ override public function validateDisplayList():void
+ {
+ super.validateDisplayList();
+ if (_redrawRequested)
+ {
+ for (var i:int = 0; i < _graphicElementPartRenderers.length; i++)
+ {
+ _graphicElementPartRenderers[i].validateDisplayList();
+ }
+ }
+ }
+
+ /* interfaces implementation, copied from spark.components.IconItemRender */
+
+ /**
+ * @inheritDoc
+ *
+ * <p>We implement this as part of ISharedDisplayObject so the iconDisplay
+ * can share our display object.</p>
+ *
+ * @langversion 3.0
+ * @playerversion AIR 1.5
+ * @productversion Flex 4
+ */
+ public function get redrawRequested():Boolean
+ {
+ return _redrawRequested;
+ }
+
+ /**
+ * @private
+ */
+ public function set redrawRequested(value:Boolean):void
+ {
+ _redrawRequested = value;
+ }
+
+ //--------------------------------------------------------------------------
+ //
+ // IGraphicElementContainer
+ //
+ // -------------------------------------------------------------------------
+
+ /**
+ * @private
+ *
+ * Notify the host component that an element changed and needs to validate properties.
+ */
+ public function invalidateGraphicElementSharing(element:IGraphicElement):void
+ {
+ //do nothing because all has been done in createChildren and won't change
+ }
+
+ /**
+ * @private
+ *
+ * Notify the host component that an element changed and needs to validate properties.
+ */
+ public function invalidateGraphicElementProperties(element:IGraphicElement):void
+ {
+ graphicElementsNeedValidateProperties = true;
+ invalidateProperties();
+ }
+
+ /**
+ * @private
+ */
+ public function invalidateGraphicElementSize(element:IGraphicElement):void
+ {
+ graphicElementsNeedValidateSize = true;
+ invalidateSize();
+ }
+
+ /**
+ * @private
+ *
+ */
+ public function invalidateGraphicElementDisplayList(element:IGraphicElement):void
+ {
+ if (element.displayObject is ISharedDisplayObject)
+ ISharedDisplayObject(element.displayObject).redrawRequested = true;
+ invalidateDisplayList();
+ }
}
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/fe39973b/frameworks/projects/experimental_mobile/src/spark/components/supportClasses/ListMultiPartLayoutBase.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/experimental_mobile/src/spark/components/supportClasses/ListMultiPartLayoutBase.as b/frameworks/projects/experimental_mobile/src/spark/components/supportClasses/ListMultiPartLayoutBase.as
index 0c8c5ff..21593b1 100644
--- a/frameworks/projects/experimental_mobile/src/spark/components/supportClasses/ListMultiPartLayoutBase.as
+++ b/frameworks/projects/experimental_mobile/src/spark/components/supportClasses/ListMultiPartLayoutBase.as
@@ -22,6 +22,7 @@ import mx.core.IFlexDisplayObject;
import mx.core.ILayoutElement;
import spark.components.itemRenderers.IItemPartRendererBase;
+import spark.core.IGraphicElement;
/** @private
* Abstract base class for laying out part renderers in a multi-part renderer.
@@ -41,11 +42,17 @@ public class ListMultiPartLayoutBase extends Object
return _target;
}
- protected function get partRendererDescriptors():Vector.<IPartRendererDescriptor>
+ protected function get partRendererDescriptors():Vector.<PartRendererDescriptorBase>
{
return target.partRendererDescriptors;
}
+ protected function get graphicElementPartRenderers():Vector.<IGraphicElement>
+ {
+ return target.graphicElementPartRenderers;
+ }
+
+
protected function get partRenderers():Vector.<IItemPartRendererBase>
{
return target.partRenderers;
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/fe39973b/frameworks/projects/experimental_mobile/src/spark/components/supportClasses/ListMultiPartTabbedLayout.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/experimental_mobile/src/spark/components/supportClasses/ListMultiPartTabbedLayout.as b/frameworks/projects/experimental_mobile/src/spark/components/supportClasses/ListMultiPartTabbedLayout.as
deleted file mode 100644
index f211a8c..0000000
--- a/frameworks/projects/experimental_mobile/src/spark/components/supportClasses/ListMultiPartTabbedLayout.as
+++ /dev/null
@@ -1,82 +0,0 @@
-////////////////////////////////////////////////////////////////////////////////
-//
-// 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 spark.components.supportClasses
-{
-import spark.components.itemRenderers.IItemPartRendererBase;
-import spark.utils.UIComponentUtils;
-
-/** @private
- * this class is reponsible for laying out grid cells in a given MobileGrid row.
- * It will make sure that cell content is aligned according to the column widths.
- */
-public class ListMultiPartTabbedLayout extends ListMultiPartLayoutBase
-{
-
- public function ListMultiPartTabbedLayout(target:ListMultiPartItemRendererBase)
- {
- super(target);
- }
-
- override public function measure():void
- {
- super.measure();
- var totalWidth:Number = 0;
- for each (var ld:IPartRendererDescriptor in partRendererDescriptors)
- {
- totalWidth += ld.scaledWidth;
- }
- target.measuredWidth = totalWidth;
- target.measuredMinWidth = 50;
- }
-
- /* vertical align middle
- * Layout algorithm: give all columns the requested sizes, and the last column the remaining width */
- override public function layoutContents(unscaledWidth:Number, unscaledHeight:Number):void
- {
-
- if (unscaledWidth == 0 && unscaledHeight == 0)
- return; // not ready
- var cellPaddingLeft:Number = target.getStyle("paddingLeft");
- var cellPaddingRight:Number = target.getStyle("paddingRight");
- var paddingTop:Number = target.getStyle("paddingTop");
- var paddingBottom:Number = target.getStyle("paddingBottom");
- var cellHeight:Number = unscaledHeight - paddingTop - paddingBottom;
-
- var desc:IPartRendererDescriptor;
- var dpr:IItemPartRendererBase;
- var remainingWidth:Number = unscaledWidth;
- var curX:Number = cellPaddingLeft;
- var curY:Number = paddingTop;
- var partWidth:Number;
- var partHeight:Number;
- var count:int = partRenderers.length - 1;
- for (var i:int = 0; i <= count; i++)
- {
- dpr = partRenderers[i];
- desc = partRendererDescriptors[i];
- partHeight = dpr.getPreferredBoundsHeight();
- partWidth = Math.max(0, i == count ? remainingWidth : desc.scaledWidth - cellPaddingLeft - cellPaddingRight);
- setElementSize(dpr, partWidth, partHeight);
- setElementPosition(dpr, curX, curY + UIComponentUtils.offsetForCenter(partHeight, cellHeight));
- curX += partWidth + cellPaddingRight + cellPaddingLeft;
- remainingWidth -= desc.scaledWidth;
- }
- }
-}
-}
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/fe39973b/frameworks/projects/experimental_mobile/src/spark/components/supportClasses/MobileGridColumn.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/experimental_mobile/src/spark/components/supportClasses/MobileGridColumn.as b/frameworks/projects/experimental_mobile/src/spark/components/supportClasses/MobileGridColumn.as
index a404bb2..9c49428 100644
--- a/frameworks/projects/experimental_mobile/src/spark/components/supportClasses/MobileGridColumn.as
+++ b/frameworks/projects/experimental_mobile/src/spark/components/supportClasses/MobileGridColumn.as
@@ -48,13 +48,13 @@ public class MobileGridColumn extends PartRendererDescriptorBase
private var _headerText:String = null;
private var _headerStyleName:String;
private var _sortDescending:Boolean;
- private var _sortable: Boolean = true;
+ private var _sortable:Boolean = true;
public function MobileGridColumn(target:IEventDispatcher = null)
{
super(target);
labelFunction = null;
- width = 100; // default width;
+ setWidth(100); // default width;
itemRenderer = null; // will set default ;
}
@@ -64,7 +64,7 @@ public class MobileGridColumn extends PartRendererDescriptorBase
*/
public function get headerText():String
{
- return _headerText != null ? _headerText : dataField ;
+ return _headerText != null ? _headerText : dataField;
}
public function set headerText(value:String):void
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/fe39973b/frameworks/projects/experimental_mobile/src/spark/components/supportClasses/MobileGridHeader.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/experimental_mobile/src/spark/components/supportClasses/MobileGridHeader.as b/frameworks/projects/experimental_mobile/src/spark/components/supportClasses/MobileGridHeader.as
index 1cdfbf6..f92075b 100644
--- a/frameworks/projects/experimental_mobile/src/spark/components/supportClasses/MobileGridHeader.as
+++ b/frameworks/projects/experimental_mobile/src/spark/components/supportClasses/MobileGridHeader.as
@@ -60,10 +60,10 @@ public class MobileGridHeader extends ButtonBar
protected var ascIconCls:MultiDPIBitmapSource;
private var _dataGrid:MobileGrid;
- private var _columns: Array;
+ private var _columns:Array;
private var _sortIndex:int = -1;
- public function MobileGridHeader()
+ public function MobileGridHeader()
{
this.labelField = "headerText";
this.iconFunction = getIconForButton;
@@ -103,8 +103,9 @@ public class MobileGridHeader extends ButtonBar
{
event.preventDefault(); // to clear selection
var i:int = event.newIndex;
- var c: MobileGridColumn = _columns[i];
- if (_dataGrid.sortableColumns && c.sortable) {
+ var c:MobileGridColumn = _columns[i];
+ if (_dataGrid.sortableColumns && c.sortable)
+ {
var headerEvent:MobileGridHeaderEvent = new MobileGridHeaderEvent(MobileGridHeaderEvent.SORT_CHANGE, c.colNum, false, true);
// HEADER_RELEASE event is cancelable
dispatchEvent(headerEvent);
@@ -129,9 +130,9 @@ public class MobileGridHeader extends ButtonBar
var button:UIComponent = UIComponent(event.renderer);
var index:int = event.index;
var col:MobileGridColumn = MobileGridColumn(_columns[index]);
- // don't size the last button
- if (index != dataProvider.length - 1)
- button.explicitWidth = col.scaledWidth;
+ // expand the last button
+ if ((index != dataProvider.length - 1) || col.hasExplicitWidth)
+ button.explicitWidth = col.dpiScaledWidth;
else
button.percentWidth = 100;
}
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/fe39973b/frameworks/projects/experimental_mobile/src/spark/components/supportClasses/MobileGridRowRenderer.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/experimental_mobile/src/spark/components/supportClasses/MobileGridRowRenderer.as b/frameworks/projects/experimental_mobile/src/spark/components/supportClasses/MobileGridRowRenderer.as
index 0461d22..b2a8d3e 100644
--- a/frameworks/projects/experimental_mobile/src/spark/components/supportClasses/MobileGridRowRenderer.as
+++ b/frameworks/projects/experimental_mobile/src/spark/components/supportClasses/MobileGridRowRenderer.as
@@ -27,7 +27,7 @@ public class MobileGridRowRenderer extends ListMultiPartItemRendererBase
{
public function MobileGridRowRenderer()
{
- partRenderersLayout = new ListMultiPartTabbedLayout(this);
+ partRenderersLayout = new ListMultiPartColumnLayout(this);
}
}
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/fe39973b/frameworks/projects/experimental_mobile/src/spark/components/supportClasses/PartRendererDescriptorBase.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/experimental_mobile/src/spark/components/supportClasses/PartRendererDescriptorBase.as b/frameworks/projects/experimental_mobile/src/spark/components/supportClasses/PartRendererDescriptorBase.as
index 57a3cbb..23ce03e 100644
--- a/frameworks/projects/experimental_mobile/src/spark/components/supportClasses/PartRendererDescriptorBase.as
+++ b/frameworks/projects/experimental_mobile/src/spark/components/supportClasses/PartRendererDescriptorBase.as
@@ -34,23 +34,25 @@ import spark.utils.DensityUtil2;
/** This is the base class for GridColumn
*
*/
-public class PartRendererDescriptorBase extends EventDispatcher implements IPartRendererDescriptor
+public class PartRendererDescriptorBase extends EventDispatcher
{
private var _colNum:int;
private var _dataField:String;
private var _width:Number;
- private var _scaledWidth:Number;
+ private var _hasExplicitWidth:Boolean;
+ private var _dpiScaledWidth:Number;
private var _itemRenderer:IFactory;
private var _labelFunction:Function;
private var _styleName:String;
private var _textAlign:String;
+
public function PartRendererDescriptorBase(target:IEventDispatcher = null)
{
super(target);
_labelFunction = null;
- width = 100; // default width;
+ setWidth(100); // default width;
itemRenderer = null; // will set default ;
}
@@ -103,44 +105,25 @@ public class PartRendererDescriptorBase extends EventDispatcher implements IPart
_styleName = value;
}
- /** set the desired width of the column at the application's current DPI (or 160 if none)
- * default value is 100
- * the actual pixel width maybe higher if the runtimeDPI or application DPI are different than 160
+ /** Set the desired width for this column.
+ * <p> Width value is expressed in current applicationDPI, or at 160 DPI if applicationDPI is not set.</p>
+ * Default value is 100.
+ * Note that the last column will always expand
*
* @param value = desired width of the column at 160 DPI
*/
public function set width(value:Number):void
{
- _width = value;
- _scaledWidth = DensityUtil2.dpiScale(value, DPIClassification.DPI_160);
+ setWidth(value);
+ _hasExplicitWidth = true;
}
- /** set the desired width of the column at the application's current DPI (or 160 if none)
- * default value is 100
- * the actual pixel width maybe higher if the runtimeDPI or application DPI are different than 160
- *
- * @param value = desired width of the column at 160 DPI
- */
- public function set widthAt160DPI(value:Number):void
+ protected function setWidth(value:Number):void
{
_width = value;
- _scaledWidth = DensityUtil2.dpiScale(value, DPIClassification.DPI_160);
+ _dpiScaledWidth = DensityUtil2.dpiScale(value, DPIClassification.DPI_160);
}
- public function get scaledWidth():Number
- {
- return _scaledWidth;
- }
-
- mx_internal function get colNum():int
- {
- return _colNum;
- }
-
- mx_internal function set colNum(value:int):void
- {
- _colNum = value;
- }
public function get itemRenderer():IFactory
{
@@ -169,8 +152,10 @@ public class PartRendererDescriptorBase extends EventDispatcher implements IPart
if (pr)
{
pr.cssStyleName = _styleName;
- if (pr is IItemTextPartRenderer) {
- with( IItemTextPartRenderer(pr)){
+ if (pr is IItemTextPartRenderer)
+ {
+ with (IItemTextPartRenderer(pr))
+ {
labelField = _dataField;
labelFunction = _labelFunction;
textAlign = _textAlign;
@@ -180,5 +165,25 @@ public class PartRendererDescriptorBase extends EventDispatcher implements IPart
return pr;
}
+ mx_internal function get hasExplicitWidth():Boolean
+ {
+ return _hasExplicitWidth;
+ }
+
+ mx_internal function get dpiScaledWidth():Number
+ {
+ return _dpiScaledWidth;
+ }
+
+ mx_internal function get colNum():int
+ {
+ return _colNum;
+ }
+
+ mx_internal function set colNum(value:int):void
+ {
+ _colNum = value;
+ }
+
}
}
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/fe39973b/frameworks/projects/experimental_mobile/src/spark/events/MobileGridHeaderEvent.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/experimental_mobile/src/spark/events/MobileGridHeaderEvent.as b/frameworks/projects/experimental_mobile/src/spark/events/MobileGridHeaderEvent.as
index 06558b7..31e1462 100644
--- a/frameworks/projects/experimental_mobile/src/spark/events/MobileGridHeaderEvent.as
+++ b/frameworks/projects/experimental_mobile/src/spark/events/MobileGridHeaderEvent.as
@@ -22,7 +22,7 @@ import flash.events.Event;
/**
* The MobileGridHeaderEvent class represents events that are dispatched when
- the user clicks on the header of a column in the DataGrid to sort it.
+ the user clicks on the header of a column in the DataGrid to sort it.
*
* @see spark.components.MobileGrid
*
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/fe39973b/frameworks/projects/experimental_mobile/src/spark/skins/MobileGridSkin.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/experimental_mobile/src/spark/skins/MobileGridSkin.as b/frameworks/projects/experimental_mobile/src/spark/skins/MobileGridSkin.as
index 20c46a0..35353f8 100644
--- a/frameworks/projects/experimental_mobile/src/spark/skins/MobileGridSkin.as
+++ b/frameworks/projects/experimental_mobile/src/spark/skins/MobileGridSkin.as
@@ -33,7 +33,6 @@ import spark.components.supportClasses.MobileGridHeader;
import spark.layouts.HorizontalAlign;
import spark.layouts.VerticalLayout;
import spark.skins.mobile.supportClasses.MobileSkin;
-import spark.utils.MultiDPIBitmapSource;
import spark.utils.MultiDPIBitmapSourceExt;
use namespace mx_internal;
@@ -73,7 +72,7 @@ public class MobileGridSkin extends MobileSkin
minWidth = 100;
break;
}
- var headerShadowSrc:MultiDPIBitmapSource = new MultiDPIBitmapSourceExt();
+ var headerShadowSrc:MultiDPIBitmapSourceExt = new MultiDPIBitmapSourceExt();
headerShadowSrc.source320dpi = headerShadowCls320;
headerShadowSrc.source160dpi = headerShadowCls160;
headerShadowCls = Class(headerShadowSrc.getSource(NaN));
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/fe39973b/frameworks/projects/experimental_mobile/src/spark/utils/DensityUtil2.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/experimental_mobile/src/spark/utils/DensityUtil2.as b/frameworks/projects/experimental_mobile/src/spark/utils/DensityUtil2.as
index 8c76e73..7f447ad 100644
--- a/frameworks/projects/experimental_mobile/src/spark/utils/DensityUtil2.as
+++ b/frameworks/projects/experimental_mobile/src/spark/utils/DensityUtil2.as
@@ -20,7 +20,6 @@ package spark.utils
{
import mx.core.FlexGlobals;
-import mx.core.mx_internal;
import mx.managers.SystemManager;
import spark.components.Application;
@@ -28,38 +27,16 @@ import spark.components.Application;
public class DensityUtil2
{
- use namespace mx_internal;
-
private static var _setApplicationDPI:Number = 0;
- /** Calculates a scale factor to be used when element authored for <code>sourceDPI</code>
- * two algorithms: <br/>
- * Application.applicationDPI has been set, which means scaling factor occurs already, so additional scaling is required, return 1
- * Application.applicationDPI has not been set, then return runTimeDPI / sourceDPI
- * examples:
- * runtimeDPI = 320 and sourceDPI = 160 and applicationDPI not set (ie=320) => 2
- * runtimeDPI = 160 and sourceDPI = 160 and applicationDPI not set (ie=160) => 1
- * runtimeDPI = 160 and sourceDPI = 160 and applicationDPI = 160 => 1
- * runtimeDPI = 320 and sourceDPI = 160 and applicationDPI = 160 => 1 (scaling occurs)
+ /** returns the actual value for a value authored for <code>sourceDPI</code>, taking into account any dpi scaling.
+ * <ul>
+ * <li> If Application.applicationDPI has been set, which means dpi scaling factor is already applied, return the original value.</li>
+ * <li> If Application.applicationDPI has not been set, then return scaled value runTimeDPI / sourceDPI </li>
+ * </li>
* @param sourceDPI
- * @return scale factor
+ * @return scaled value
*/
-
- public static function getPostDPIScale(sourceDPI:Number):Number
- {
-
- var appDPI:Number = getSetApplicationDPI();
- if (isNaN(appDPI))
- {
- // was not set,
- var runDPI:Number = FlexGlobals.topLevelApplication.runtimeDPI;
- return runDPI / sourceDPI;
- }
- else
- return 1.0; // already scaled
- }
-
-
public static function dpiScale(value:Number, sourceDPI:Number):Number
{
var appDPI:Number = getSetApplicationDPI();
@@ -70,9 +47,10 @@ public class DensityUtil2
}
else
return value; // already scaled
-
}
+ /**
+ * returns the applicationDPI that was explicitly set in top level application , or NaN if none */
private static function getSetApplicationDPI():Number
{
if (_setApplicationDPI == 0)
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/fe39973b/frameworks/projects/experimental_mobile/src/spark/utils/MultiDPIBitmapSourceExt.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/experimental_mobile/src/spark/utils/MultiDPIBitmapSourceExt.as b/frameworks/projects/experimental_mobile/src/spark/utils/MultiDPIBitmapSourceExt.as
index eb3ac03..ce17ffe 100644
--- a/frameworks/projects/experimental_mobile/src/spark/utils/MultiDPIBitmapSourceExt.as
+++ b/frameworks/projects/experimental_mobile/src/spark/utils/MultiDPIBitmapSourceExt.as
@@ -24,10 +24,28 @@ import mx.utils.DensityUtil;
public class MultiDPIBitmapSourceExt extends MultiDPIBitmapSource
{
+ /**
+ * Select one of the sourceXXXdpi properties based on the given DPI. This
+ * function handles the fallback to different sourceXXXdpi properties
+ * if the given one is null.
+ * The strategy is to try to choose the next highest
+ * property if it is not null, then return a lower property if not null, then
+ * just return null.
+ * If desiredDPI is NaN or 0, return the sourceXXXdpi for the runtime DPI .
+ *
+ * @param The desired DPI.
+ *
+ * @return One of the sourceXXXdpi properties based on the desired DPI.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion Flex 4.5
+ */
override public function getSource(desiredDPI:Number):Object
{
- if (isNaN(desiredDPI))
+ if (isNaN(desiredDPI) || (desiredDPI == 0))
{
var app:Object = FlexGlobals.topLevelApplication;
var dpi:Number;
@@ -40,5 +58,8 @@ public class MultiDPIBitmapSourceExt extends MultiDPIBitmapSource
else
return super.getSource(desiredDPI);
}
+
+ //TODO mamsellem move this code to parent class, updates any callers, and remove this class
+
}
}
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/fe39973b/frameworks/projects/experimental_mobile/src/spark/utils/UIComponentUtils.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/experimental_mobile/src/spark/utils/UIComponentUtils.as b/frameworks/projects/experimental_mobile/src/spark/utils/UIComponentUtils.as
index 0ecf82c..93f6f8e 100644
--- a/frameworks/projects/experimental_mobile/src/spark/utils/UIComponentUtils.as
+++ b/frameworks/projects/experimental_mobile/src/spark/utils/UIComponentUtils.as
@@ -18,40 +18,12 @@
////////////////////////////////////////////////////////////////////////////////
package spark.utils
{
-import mx.collections.IList;
import mx.core.IFlexDisplayObject;
import mx.core.ILayoutElement;
-import mx.core.UIComponent;
-
-import spark.components.IItemRendererOwner;
public class UIComponentUtils
{
- /* fast function based on char length and not on pixel length*/
- public static function computeLongestItem(listComponent:IItemRendererOwner, dataProvider:IList, max:int = 10):Object
- {
- if (!dataProvider)
- {
- return null;
- }
- max = Math.min(max, dataProvider.length);
- var maxLength:int = 0;
- var longestItem:Object;
- var item:Object;
- var itemStringLength:int;
- for (var i:int = 0; i < max; i++)
- {
- item = dataProvider.getItemAt(i);
- itemStringLength = listComponent.itemToLabel(item).length;
- if (itemStringLength >= maxLength)
- {
- maxLength = itemStringLength;
- longestItem = item;
- }
- }
- return longestItem;
- }
public static function itemToLabel(item:Object, labelField:String, labelFunction:Function, nullLabel:String = '-'):String
{
@@ -69,12 +41,6 @@ public class UIComponentUtils
}
}
- public static function clearBoundsSize(comp:UIComponent):void
- {
- comp.explicitWidth = NaN; // was set before
- comp.explicitHeight = NaN;
- comp.setLayoutBoundsSize(NaN, NaN);
- }
public static function setElementSize(element:Object, width:Number, height:Number):void
{
[4/5] git commit: [flex-sdk] [refs/heads/mobileexperimental] -
https://issues.apache.org/jira/browse/FLEX-33777 Dagrid for mobile - Manages
column with percent widths - Simplified class structure,
removing intermediary classes - Completed all ASDOC - Opt
Posted by ma...@apache.org.
https://issues.apache.org/jira/browse/FLEX-33777 Dagrid for mobile
- Manages column with percent widths
- Simplified class structure, removing intermediary classes
- Completed all ASDOC
- Optimized layout calculations
Project: http://git-wip-us.apache.org/repos/asf/flex-sdk/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-sdk/commit/44826607
Tree: http://git-wip-us.apache.org/repos/asf/flex-sdk/tree/44826607
Diff: http://git-wip-us.apache.org/repos/asf/flex-sdk/diff/44826607
Branch: refs/heads/mobileexperimental
Commit: 448266071533e134113d21c6e5296543753c150b
Parents: fe39973
Author: mamsellem <ma...@systar.com>
Authored: Wed Oct 2 02:47:00 2013 +0200
Committer: mamsellem <ma...@systar.com>
Committed: Wed Oct 2 02:47:00 2013 +0200
----------------------------------------------------------------------
.../src/ExperimentalMobileClasses.as | 2 +-
.../src/spark/components/MobileGrid.as | 29 +-
.../itemRenderers/IItemPartRendererBase.as | 10 +-
.../itemRenderers/IItemTextPartRenderer.as | 10 +-
.../itemRenderers/ItemBitmapPartRenderer.as | 15 +-
.../itemRenderers/ItemTextPartRenderer.as | 9 +-
.../supportClasses/ItemRendererBase.as | 34 +--
.../supportClasses/ListMultiPartColumnLayout.as | 135 ++++++++--
.../ListMultiPartItemRendererBase.as | 267 -------------------
.../supportClasses/ListMultiPartLayoutBase.as | 148 ----------
.../supportClasses/MobileGridColumn.as | 249 +++++++++++++++--
.../supportClasses/MobileGridHeader.as | 39 ++-
.../supportClasses/MobileGridRowRenderer.as | 234 +++++++++++++++-
.../PartRendererDescriptorBase.as | 189 -------------
.../src/spark/events/MobileGridHeaderEvent.as | 2 +-
.../src/spark/layouts/MobileGridLayout.as | 95 +++++++
.../src/spark/utils/DensityUtil2.as | 16 +-
.../src/spark/utils/MultiDPIBitmapSourceExt.as | 12 +-
.../src/spark/utils/UIComponentUtils.as | 8 +-
19 files changed, 771 insertions(+), 732 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/44826607/frameworks/projects/experimental_mobile/src/ExperimentalMobileClasses.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/experimental_mobile/src/ExperimentalMobileClasses.as b/frameworks/projects/experimental_mobile/src/ExperimentalMobileClasses.as
index b695712..8cb1081 100644
--- a/frameworks/projects/experimental_mobile/src/ExperimentalMobileClasses.as
+++ b/frameworks/projects/experimental_mobile/src/ExperimentalMobileClasses.as
@@ -25,7 +25,7 @@ import spark.skins.MobileGridSkin;
/*
classes that won't be detected through dependencies
- * and classes that needs to be includes in ASDOC
+ * and root classes that needs to be includes in ASDOC
* */
internal class ExperimentalMobileClasses
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/44826607/frameworks/projects/experimental_mobile/src/spark/components/MobileGrid.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/experimental_mobile/src/spark/components/MobileGrid.as b/frameworks/projects/experimental_mobile/src/spark/components/MobileGrid.as
index 4161580..39977d7 100644
--- a/frameworks/projects/experimental_mobile/src/spark/components/MobileGrid.as
+++ b/frameworks/projects/experimental_mobile/src/spark/components/MobileGrid.as
@@ -30,8 +30,8 @@ import spark.collections.Sort;
import spark.components.supportClasses.MobileGridColumn;
import spark.components.supportClasses.MobileGridHeader;
import spark.components.supportClasses.MobileGridRowRenderer;
-import spark.components.supportClasses.PartRendererDescriptorBase;
import spark.events.MobileGridHeaderEvent;
+import spark.layouts.MobileGridLayout;
import spark.layouts.VerticalLayout;
import spark.layouts.supportClasses.LayoutBase;
@@ -41,18 +41,10 @@ use namespace mx_internal;
* Dispatched when the user releases the mouse button on a column header
* to request the control to sort the grid contents based on the contents of the column.
* Only dispatched if the column is sortable and the data provider supports
- * sorting. The DataGrid control has a default handler for this event that implements
- * a single-column sort.
- * <b>Note</b>: The sort arrows are defined by the default event handler for
- * the headerRelease event. If you call the <code>preventDefault()</code> method
- * in your event handler, the arrows are not drawn.
- * </p>
+ * sorting.
*
- * @eventType mx.events.DataGridEvent.HEADER_RELEASE
+ * @eventType spark.events.MobileGridHeaderEvent
*
- * @langversion 3.0
- * @playerversion AIR 3.8
- * @productversion Flex 4.11
*/
[Event(name="sortChange", type="spark.events.MobileGridHeaderEvent")]
@@ -118,10 +110,6 @@ public class MobileGrid extends List
*
* @see spark.components.supportClasses.MobileGridColumn
*
- * @langversion 3.0
- * @playerversion Flash 9
- * @playerversion AIR 1.1
- * @productversion Flex 3
*/
[Inspectable(arrayType="spark.components.supportClasses.MobileGridColumn")]
public function set columns(value:Array):void
@@ -156,10 +144,7 @@ public class MobileGrid extends List
* @default true
*
* @see spark.components.supportClasses.MobileGridColumn#sortable
- *
- * @langversion 3.0
- * @playerversion AIR 3.8
- * @productversion Flex 4.11
+
*/
public function get sortableColumns():Boolean
{
@@ -190,18 +175,18 @@ public class MobileGrid extends List
/* default layout for row item renderers */
protected function getDefaultLayout():LayoutBase
{
- var l:VerticalLayout = new VerticalLayout();
+ var l:VerticalLayout = new MobileGridLayout(this);
l.horizontalAlign = "contentJustify";
l.gap = 0;
return l;
}
- protected function initDefaultItemRenderer(pcolumnDescriptors:Array):void
+ protected function initDefaultItemRenderer(pcolumns:Array):void
{
var cf:ClassFactory;
cf = new ClassFactory(MobileGridRowRenderer);
cf.properties = {
- partRendererDescriptors: Vector.<PartRendererDescriptorBase>(pcolumnDescriptors)
+ columns: Vector.<MobileGridColumn>(pcolumns)
};
this.itemRenderer = cf;
}
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/44826607/frameworks/projects/experimental_mobile/src/spark/components/itemRenderers/IItemPartRendererBase.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/experimental_mobile/src/spark/components/itemRenderers/IItemPartRendererBase.as b/frameworks/projects/experimental_mobile/src/spark/components/itemRenderers/IItemPartRendererBase.as
index ab802f3..37ca652 100644
--- a/frameworks/projects/experimental_mobile/src/spark/components/itemRenderers/IItemPartRendererBase.as
+++ b/frameworks/projects/experimental_mobile/src/spark/components/itemRenderers/IItemPartRendererBase.as
@@ -24,6 +24,12 @@ import mx.styles.IStyleClient;
/**
* This is the base interface that all mobile cell or other mobile item part renderers must implement.
+ * Contrary to desktop DataGrid control, there is no default base renderer,
+ * because mobile renderers must be lightweight, and derive directly for the existing component, (ie. s:Button or s:CheckBox ).
+ *
+ * @langversion 3.0
+ * @playerversion AIR 3.8
+ * @productversion Flex 4.11
*/
public interface IItemPartRendererBase extends IDataRenderer
{
@@ -34,9 +40,9 @@ public interface IItemPartRendererBase extends IDataRenderer
*/
function set styleProvider(value:IStyleClient):void ;
- function get canSetWidth():Boolean;
+ function get canSetContentWidth():Boolean;
- function get canSetHeight():Boolean;
+ function get canSetContentHeight():Boolean;
/**
* @private
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/44826607/frameworks/projects/experimental_mobile/src/spark/components/itemRenderers/IItemTextPartRenderer.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/experimental_mobile/src/spark/components/itemRenderers/IItemTextPartRenderer.as b/frameworks/projects/experimental_mobile/src/spark/components/itemRenderers/IItemTextPartRenderer.as
index edcc0f9..90ca694 100644
--- a/frameworks/projects/experimental_mobile/src/spark/components/itemRenderers/IItemTextPartRenderer.as
+++ b/frameworks/projects/experimental_mobile/src/spark/components/itemRenderers/IItemTextPartRenderer.as
@@ -19,13 +19,21 @@
package spark.components.itemRenderers
{
+/** Extended interface for renderer that include text
+ * @langversion 3.0
+ * @playerversion AIR 3.8
+ * @productversion Flex 4.11
+ */
+
public interface IItemTextPartRenderer extends IItemPartRendererBase
{
-
+ /* implement this property so that the renderer can receive the dataField from the renderer's MobileGridColumn*/
function set labelField(value:String):void;
+ /* implement this property so that the renderer can receive the labelFunction from the renderers' MobileGridColumn*/
function set labelFunction(value:Function):void;
+ /* implement this property so that the renderer can receive the textAlign property from the renderers' MobileGridColumn*/
function set textAlign(textAlign:String):void;
}
}
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/44826607/frameworks/projects/experimental_mobile/src/spark/components/itemRenderers/ItemBitmapPartRenderer.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/experimental_mobile/src/spark/components/itemRenderers/ItemBitmapPartRenderer.as b/frameworks/projects/experimental_mobile/src/spark/components/itemRenderers/ItemBitmapPartRenderer.as
index c95195b..29db838 100644
--- a/frameworks/projects/experimental_mobile/src/spark/components/itemRenderers/ItemBitmapPartRenderer.as
+++ b/frameworks/projects/experimental_mobile/src/spark/components/itemRenderers/ItemBitmapPartRenderer.as
@@ -28,7 +28,12 @@ import spark.primitives.BitmapImage;
use namespace mx_internal;
/** Default lightweight class for rendering embedded Bitmaps or Multi-DPI Bitmaps in a MobileGrid cell .
- * <p> You define the icon to be used in each cell by setting either iconField or iconFunction properties. </p>
+ *You define the icon to be used in each cell by setting either iconField or iconFunction properties.
+ *
+ * @langversion 3.0
+ * @playerversion AIR 3.8
+ * @productversion Flex 4.11
+ *
* */
public class ItemBitmapPartRenderer extends BitmapImage implements IItemPartRendererBase
{
@@ -45,12 +50,12 @@ public class ItemBitmapPartRenderer extends BitmapImage implements IItemPartRend
/**
* The name of the field or property in the DataGrid's dataProvider item that defines the icon to display for this renderer's column.
- * <p> The fields value must be either an embedded bitmap's class, or or MultiBitmapSourceExt object. </p>
+ * <p> The field value must be either an embedded bitmap's class, or or MultiBitmapSource object. </p>
* <p> If not set, then iconFunction will be used. </p>
* @default null
*
* @see #iconFunction
- * @see spark.utils.MultiDPIBitmapSourceExt
+ * @see spark.utils.MultiDPIBitmapSource
*
*/
public function get iconField():String
@@ -115,12 +120,12 @@ public class ItemBitmapPartRenderer extends BitmapImage implements IItemPartRend
/* to avoid any scaling artifacts, we do not allow bitmap to be stretcghed */
- public function get canSetWidth():Boolean
+ public function get canSetContentWidth():Boolean
{
return false;
}
- public function get canSetHeight():Boolean
+ public function get canSetContentHeight():Boolean
{
return false;
}
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/44826607/frameworks/projects/experimental_mobile/src/spark/components/itemRenderers/ItemTextPartRenderer.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/experimental_mobile/src/spark/components/itemRenderers/ItemTextPartRenderer.as b/frameworks/projects/experimental_mobile/src/spark/components/itemRenderers/ItemTextPartRenderer.as
index ca3f542..2ad7118 100644
--- a/frameworks/projects/experimental_mobile/src/spark/components/itemRenderers/ItemTextPartRenderer.as
+++ b/frameworks/projects/experimental_mobile/src/spark/components/itemRenderers/ItemTextPartRenderer.as
@@ -31,6 +31,11 @@ use namespace mx_internal;
/** Default lightweight class for rendering formatted text in MobileGrid cells .
* <p> You don't have to use this render explicitly as it will be used by default for MobileGrid text cells. </p>
+ *
+ * @langversion 3.0
+ * @playerversion AIR 3.8
+ * @productversion Flex 4.11
+ *
* */
public class ItemTextPartRenderer extends StyleableTextField implements IItemTextPartRenderer
{
@@ -92,12 +97,12 @@ public class ItemTextPartRenderer extends StyleableTextField implements IItemTex
_labelFunction = value;
}
- public function get canSetWidth():Boolean
+ public function get canSetContentWidth():Boolean
{
return true;
}
- public function get canSetHeight():Boolean
+ public function get canSetContentHeight():Boolean
{
return false;
}
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/44826607/frameworks/projects/experimental_mobile/src/spark/components/supportClasses/ItemRendererBase.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/experimental_mobile/src/spark/components/supportClasses/ItemRendererBase.as b/frameworks/projects/experimental_mobile/src/spark/components/supportClasses/ItemRendererBase.as
index cf54c6e..a91d389 100644
--- a/frameworks/projects/experimental_mobile/src/spark/components/supportClasses/ItemRendererBase.as
+++ b/frameworks/projects/experimental_mobile/src/spark/components/supportClasses/ItemRendererBase.as
@@ -20,8 +20,13 @@
/** @private
* monkey-patched from LabelItemRenderer, pruned from label/labelDisplay and change some variable accessibility
* Provides default behavior for ListMultiPartItemRenderer
- * Eventually should become superclass of LabelItemRenderer
+ *
+ * @langversion 3.0
+ * @playerversion AIR 3.8
+ * @productversion Flex 4.11
+ *
* */
+//TODO refactoring : should become superclass of LabelItemRenderer
package spark.components.supportClasses
{
@@ -57,9 +62,6 @@ use namespace mx_internal;
*
* @eventType mx.events.FlexEvent.DATA_CHANGE
*
- * @langversion 3.0
- * @playerversion AIR 2.5
- * @productversion Flex 4.5
*/
[Event(name="dataChange", type="mx.events.FlexEvent")]
@@ -72,9 +74,6 @@ use namespace mx_internal;
/**
* @copy spark.components.supportClasses.GroupBase#style:alternatingItemColors
*
- * @langversion 3.0
- * @playerversion AIR 2.5
- * @productversion Flex 4.5
*/
[Style(name="alternatingItemColors", type="Array", arrayType="uint", format="Color", inherit="yes", theme="spark, mobile")]
@@ -83,27 +82,18 @@ use namespace mx_internal;
*
* @default 0xCCCCCC
*
- * @langversion 3.0
- * @playerversion AIR 1.5
- * @productversion Flex 4
*/
[Style(name="chromeColor", type="uint", format="Color", inherit="yes", theme="spark, mobile")]
/**
* @copy spark.components.supportClasses.GroupBase#style:downColor
*
- * @langversion 3.0
- * @playerversion AIR 2.5
- * @productversion Flex 4.5
*/
[Style(name="downColor", type="uint", format="Color", inherit="yes", theme="spark, mobile")]
/**
* @copy spark.components.supportClasses.GroupBase#style:focusColor
*
- * @langversion 3.0
- * @playerversion AIR 2.5
- * @productversion Flex 4.5
*/
[Style(name="focusColor", type="uint", format="Color", inherit="yes", theme="spark, mobile")]
@@ -113,9 +103,6 @@ use namespace mx_internal;
*
* @default 5
*
- * @langversion 3.0
- * @playerversion AIR 2.5
- * @productversion Flex 4.5
*/
[Style(name="paddingBottom", type="Number", format="Length", inherit="no")]
@@ -125,27 +112,18 @@ use namespace mx_internal;
*
* @default 5
*
- * @langversion 3.0
- * @playerversion AIR 2.5
- * @productversion Flex 4.5
*/
[Style(name="paddingTop", type="Number", format="Length", inherit="no")]
/**
* @copy spark.components.supportClasses.GroupBase#style:rollOverColor
*
- * @langversion 3.0
- * @playerversion AIR 2.5
- * @productversion Flex 4.5
*/
[Style(name="rollOverColor", type="uint", format="Color", inherit="yes")]
/**
* @copy spark.components.List#style:selectionColor
*
- * @langversion 3.0
- * @playerversion AIR 2.5
- * @productversion Flex 4.5
*/
[Style(name="selectionColor", type="uint", format="Color", inherit="yes")]
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/44826607/frameworks/projects/experimental_mobile/src/spark/components/supportClasses/ListMultiPartColumnLayout.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/experimental_mobile/src/spark/components/supportClasses/ListMultiPartColumnLayout.as b/frameworks/projects/experimental_mobile/src/spark/components/supportClasses/ListMultiPartColumnLayout.as
index 44c2c46..8cd7e27 100644
--- a/frameworks/projects/experimental_mobile/src/spark/components/supportClasses/ListMultiPartColumnLayout.as
+++ b/frameworks/projects/experimental_mobile/src/spark/components/supportClasses/ListMultiPartColumnLayout.as
@@ -18,9 +18,12 @@
////////////////////////////////////////////////////////////////////////////////
package spark.components.supportClasses
{
+import mx.core.IFlexDisplayObject;
+import mx.core.ILayoutElement;
import mx.core.mx_internal;
import spark.components.itemRenderers.IItemPartRendererBase;
+import spark.core.IGraphicElement;
import spark.utils.UIComponentUtils;
use namespace mx_internal;
@@ -29,29 +32,45 @@ use namespace mx_internal;
* this class is responsible for laying out grid cells in a given MobileGrid row.
* It will make sure that cell content is aligned according to the column widths.
*/
-public class ListMultiPartColumnLayout extends ListMultiPartLayoutBase
+public class ListMultiPartColumnLayout extends Object
{
+ public function ListMultiPartColumnLayout(target:MobileGridRowRenderer)
+ {
+ _target = target;
+ }
- public function ListMultiPartColumnLayout(target:ListMultiPartItemRendererBase)
+ private var _target:MobileGridRowRenderer;
+
+ public function get target():MobileGridRowRenderer
{
- super(target);
+ return _target;
}
- override public function measure():void
+ protected function get partRendererDescriptors():Vector.<MobileGridColumn>
{
- super.measure();
- var totalWidth:Number = 0;
- for each (var ld:PartRendererDescriptorBase in partRendererDescriptors)
- {
- totalWidth += ld.dpiScaledWidth;
- }
- target.measuredWidth = totalWidth;
- target.measuredMinWidth = 50;
+ return target.columns;
+ }
+
+ protected function get graphicElementPartRenderers():Vector.<IGraphicElement>
+ {
+ return target.graphicElementPartRenderers;
+ }
+
+ protected function get partRenderers():Vector.<IItemPartRendererBase>
+ {
+ return target.partRenderers;
+ }
+
+ public function measure():void
+ {
+
}
+
/* vertical align middle
* Layout algorithm: give all columns the requested sizes, and the last column the remaining width */
- override public function layoutContents(unscaledWidth:Number, unscaledHeight:Number):void
+
+ public function layoutContents(unscaledWidth:Number, unscaledHeight:Number):void
{
if (unscaledWidth == 0 && unscaledHeight == 0)
@@ -62,9 +81,8 @@ public class ListMultiPartColumnLayout extends ListMultiPartLayoutBase
var paddingBottom:Number = target.getStyle("paddingBottom");
var cellHeight:Number = unscaledHeight - paddingTop - paddingBottom;
- var desc:PartRendererDescriptorBase;
+ var desc:MobileGridColumn;
var dpr:IItemPartRendererBase;
- var remainingWidth:Number = unscaledWidth;
var curX:Number = cellPaddingLeft;
var curY:Number = paddingTop;
var colWidth:Number;
@@ -75,23 +93,98 @@ public class ListMultiPartColumnLayout extends ListMultiPartLayoutBase
{
dpr = partRenderers[i];
desc = partRendererDescriptors[i];
- colWidth = desc.dpiScaledWidth;
- if (dpr.canSetWidth)
+ colWidth = desc.actualWidth;
+ if (dpr.canSetContentWidth)
{
// expand last column to fill width, unless it has explicity width
- partWidth = Math.max(0, ( i == count && !desc.hasExplicitWidth) ? remainingWidth : colWidth - cellPaddingLeft - cellPaddingRight);
+ partWidth = Math.max(0, colWidth - cellPaddingLeft - cellPaddingRight);
}
else
{
partWidth = dpr.getPreferredBoundsHeight();
}
- partHeight = dpr.canSetHeight ? cellHeight : dpr.getPreferredBoundsHeight();
- ;
+ partHeight = dpr.canSetContentHeight ? cellHeight : dpr.getPreferredBoundsHeight();
setElementSize(dpr, partWidth, partHeight);
setElementPosition(dpr, curX, curY + UIComponentUtils.offsetForCenter(partHeight, cellHeight));
curX += colWidth;
- remainingWidth -= colWidth;
}
}
+
+
+ /* layout helper methods */
+
+ protected function setElementPosition(element:Object, x:Number, y:Number):void
+ {
+ if (element is ILayoutElement)
+ {
+ ILayoutElement(element).setLayoutBoundsPosition(x, y, false);
+ }
+ else if (element is IFlexDisplayObject)
+ {
+ IFlexDisplayObject(element).move(x, y);
+ }
+ else
+ {
+ element.x = x;
+ element.y = y;
+ }
+ }
+
+ protected function setElementSize(element:Object, width:Number, height:Number):void
+ {
+ if (element is ILayoutElement)
+ {
+ ILayoutElement(element).setLayoutBoundsSize(width, height, false);
+ }
+ else if (element is IFlexDisplayObject)
+ {
+ IFlexDisplayObject(element).setActualSize(width, height);
+ }
+ else
+ {
+ element.width = width;
+ element.height = height;
+ }
+ }
+
+ protected function getElementPreferredWidth(element:Object):Number
+ {
+ var result:Number;
+
+ if (element is ILayoutElement)
+ {
+ result = ILayoutElement(element).getPreferredBoundsWidth();
+ }
+ else if (element is IFlexDisplayObject)
+ {
+ result = IFlexDisplayObject(element).measuredWidth;
+ }
+ else
+ {
+ result = element.width;
+ }
+
+ return Math.round(result);
+ }
+
+ protected function getElementPreferredHeight(element:Object):Number
+ {
+ var result:Number;
+
+ if (element is ILayoutElement)
+ {
+ result = ILayoutElement(element).getPreferredBoundsHeight();
+ }
+ else if (element is IFlexDisplayObject)
+ {
+ result = IFlexDisplayObject(element).measuredHeight;
+ }
+ else
+ {
+ result = element.height;
+ }
+
+ return Math.ceil(result);
+ }
}
}
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/44826607/frameworks/projects/experimental_mobile/src/spark/components/supportClasses/ListMultiPartItemRendererBase.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/experimental_mobile/src/spark/components/supportClasses/ListMultiPartItemRendererBase.as b/frameworks/projects/experimental_mobile/src/spark/components/supportClasses/ListMultiPartItemRendererBase.as
deleted file mode 100644
index 8f07d5c..0000000
--- a/frameworks/projects/experimental_mobile/src/spark/components/supportClasses/ListMultiPartItemRendererBase.as
+++ /dev/null
@@ -1,267 +0,0 @@
-////////////////////////////////////////////////////////////////////////////////
-//
-// 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 spark.components.supportClasses
-{
-import flash.display.DisplayObject;
-
-import spark.components.itemRenderers.IItemPartRendererBase;
-import spark.core.DisplayObjectSharingMode;
-import spark.core.IGraphicElement;
-import spark.core.IGraphicElementContainer;
-import spark.core.ISharedDisplayObject;
-
-/** @private
- * This is the base class for multi-part renderers that manages a vector of part renderers.
- * This class is responsible for creating and storing the actual renderers from their descriptors
- * the layout of the part renderers is delegated to a subclass of ListMultiPartLayoutBase;
- */
-public class ListMultiPartItemRendererBase extends ItemRendererBase implements IGraphicElementContainer, ISharedDisplayObject
-{
- private var _partRendererDescriptors:Vector.<PartRendererDescriptorBase>;
- private var _partRenderers:Vector.<IItemPartRendererBase>;
- private var _graphicElementPartRenderers:Vector.<IGraphicElement>;
- private var _partRenderersLayout:ListMultiPartLayoutBase;
-
- /**
- * Management of graphicElement part renderers lifeCycle
- */
- private var _redrawRequested:Boolean = false;
- private var graphicElementsNeedValidateProperties:Boolean = false;
- private var graphicElementsNeedValidateSize:Boolean = false;
-
- public function ListMultiPartItemRendererBase()
- {
- }
-
- /** @private
- * set in List itemRenderer Factory properties */
- public function set partRendererDescriptors(value:Vector.<PartRendererDescriptorBase>):void
- {
- _partRendererDescriptors = value;
- _partRenderers = new Vector.<IItemPartRendererBase>(_partRendererDescriptors.length, true);
- _graphicElementPartRenderers = new Vector.<IGraphicElement>();
- }
-
- public function get partRendererDescriptors():Vector.<PartRendererDescriptorBase>
- {
- return _partRendererDescriptors;
- }
-
- public function get partRenderersLayout():ListMultiPartLayoutBase
- {
- return _partRenderersLayout;
- }
-
- public function set partRenderersLayout(value:ListMultiPartLayoutBase):void
- {
- _partRenderersLayout = value;
- }
-
- public function get partRenderers():Vector.<IItemPartRendererBase>
- {
- return _partRenderers;
- }
-
- public function get graphicElementPartRenderers():Vector.<IGraphicElement>
- {
- return _graphicElementPartRenderers;
- }
-
- override protected function createChildren():void
- {
- super.createChildren();
- var desc:PartRendererDescriptorBase;
- var pr:IItemPartRendererBase;
- var ge:IGraphicElement;
- for (var i:int = 0; i < _partRendererDescriptors.length; i++)
- {
- desc = _partRendererDescriptors[i];
- pr = desc.createPartRenderer();
- if (pr != null)
- {
- pr.styleProvider = this;
-
- if (pr is IGraphicElement)
- {
- ge = IGraphicElement(pr);
- ge.parentChanged(this);
- if (ge.setSharedDisplayObject(this))
- {
- ge.displayObjectSharingMode = DisplayObjectSharingMode.USES_SHARED_OBJECT;
- }
- _graphicElementPartRenderers.push(ge);
- }
- else if (pr is DisplayObject)
- {
- addChild(DisplayObject(pr));
- }
- _partRenderers[i] = pr;
- }
- else
- {
- //TODO move to resource bundle
- throw new Error("MobileGridColumn item renderer must implement spark.components.itemRenderers.IItemPartRendererBase");
- }
- }
- }
-
- override protected function measure():void
- {
- super.measure();
- _partRenderersLayout.measure();
- }
-
- /** delegate children layout to its partRendererLayout
- subclasses can override this method to layout chrome content
- */
- override protected function layoutContents(unscaledWidth:Number, unscaledHeight:Number):void
- {
- _partRenderersLayout.layoutContents(unscaledWidth, unscaledHeight);
- }
-
- override protected function onDataChanged():void
- {
- var dpr:IItemPartRendererBase;
- for (var i:int = 0; i < _partRenderers.length; i++)
- {
- dpr = _partRenderers[i];
- dpr.data = data;
- }
- invalidateSize();
- }
-
- /* graphic element sub renderers lifecycle management */
-
- override protected function commitProperties():void
- {
- if (graphicElementsNeedValidateProperties)
- {
- graphicElementsNeedValidateProperties = false;
- for (var i:int = 0; i < _graphicElementPartRenderers.length; i++)
- {
- _graphicElementPartRenderers[i].validateProperties();
- }
- }
- super.commitProperties();
- }
-
-
- override public function validateSize(recursive:Boolean = false):void
- {
- if (graphicElementsNeedValidateSize)
- {
- graphicElementsNeedValidateSize = false;
- for (var i:int = 0; i < _graphicElementPartRenderers.length; i++)
- {
- _graphicElementPartRenderers[i].validateSize();
- }
- }
- super.validateSize(recursive);
- }
-
-
- /* copied from Group*/
- override public function validateDisplayList():void
- {
- super.validateDisplayList();
- if (_redrawRequested)
- {
- for (var i:int = 0; i < _graphicElementPartRenderers.length; i++)
- {
- _graphicElementPartRenderers[i].validateDisplayList();
- }
- }
- }
-
- /* interfaces implementation, copied from spark.components.IconItemRender */
-
- /**
- * @inheritDoc
- *
- * <p>We implement this as part of ISharedDisplayObject so the iconDisplay
- * can share our display object.</p>
- *
- * @langversion 3.0
- * @playerversion AIR 1.5
- * @productversion Flex 4
- */
- public function get redrawRequested():Boolean
- {
- return _redrawRequested;
- }
-
- /**
- * @private
- */
- public function set redrawRequested(value:Boolean):void
- {
- _redrawRequested = value;
- }
-
- //--------------------------------------------------------------------------
- //
- // IGraphicElementContainer
- //
- // -------------------------------------------------------------------------
-
- /**
- * @private
- *
- * Notify the host component that an element changed and needs to validate properties.
- */
- public function invalidateGraphicElementSharing(element:IGraphicElement):void
- {
- //do nothing because all has been done in createChildren and won't change
- }
-
- /**
- * @private
- *
- * Notify the host component that an element changed and needs to validate properties.
- */
- public function invalidateGraphicElementProperties(element:IGraphicElement):void
- {
- graphicElementsNeedValidateProperties = true;
- invalidateProperties();
- }
-
- /**
- * @private
- */
- public function invalidateGraphicElementSize(element:IGraphicElement):void
- {
- graphicElementsNeedValidateSize = true;
- invalidateSize();
- }
-
- /**
- * @private
- *
- */
- public function invalidateGraphicElementDisplayList(element:IGraphicElement):void
- {
- if (element.displayObject is ISharedDisplayObject)
- ISharedDisplayObject(element.displayObject).redrawRequested = true;
- invalidateDisplayList();
- }
-
-
-}
-
-}
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/44826607/frameworks/projects/experimental_mobile/src/spark/components/supportClasses/ListMultiPartLayoutBase.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/experimental_mobile/src/spark/components/supportClasses/ListMultiPartLayoutBase.as b/frameworks/projects/experimental_mobile/src/spark/components/supportClasses/ListMultiPartLayoutBase.as
deleted file mode 100644
index 21593b1..0000000
--- a/frameworks/projects/experimental_mobile/src/spark/components/supportClasses/ListMultiPartLayoutBase.as
+++ /dev/null
@@ -1,148 +0,0 @@
-////////////////////////////////////////////////////////////////////////////////
-//
-// 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 spark.components.supportClasses
-{
-import mx.core.IFlexDisplayObject;
-import mx.core.ILayoutElement;
-
-import spark.components.itemRenderers.IItemPartRendererBase;
-import spark.core.IGraphicElement;
-
-/** @private
- * Abstract base class for laying out part renderers in a multi-part renderer.
- * Subclasses must override measure() and layoutContents() methods
- */
-public class ListMultiPartLayoutBase extends Object
-{
- private var _target:ListMultiPartItemRendererBase;
-
- public function ListMultiPartLayoutBase(target:ListMultiPartItemRendererBase)
- {
- _target = target;
- }
-
- public function get target():ListMultiPartItemRendererBase
- {
- return _target;
- }
-
- protected function get partRendererDescriptors():Vector.<PartRendererDescriptorBase>
- {
- return target.partRendererDescriptors;
- }
-
- protected function get graphicElementPartRenderers():Vector.<IGraphicElement>
- {
- return target.graphicElementPartRenderers;
- }
-
-
- protected function get partRenderers():Vector.<IItemPartRendererBase>
- {
- return target.partRenderers;
- }
-
- public function measure():void
- {
-
- }
-
- /* vertical align middle
- * give all columns the requested sizes, and the last column the remaining width */
- public function layoutContents(unscaledWidth:Number, unscaledHeight:Number):void
- {
-
- }
-
- protected function setElementPosition(element:Object, x:Number, y:Number):void
- {
- if (element is ILayoutElement)
- {
- ILayoutElement(element).setLayoutBoundsPosition(x, y, false);
- }
- else if (element is IFlexDisplayObject)
- {
- IFlexDisplayObject(element).move(x, y);
- }
- else
- {
- element.x = x;
- element.y = y;
- }
- }
-
- protected function setElementSize(element:Object, width:Number, height:Number):void
- {
- if (element is ILayoutElement)
- {
- ILayoutElement(element).setLayoutBoundsSize(width, height, false);
- }
- else if (element is IFlexDisplayObject)
- {
- IFlexDisplayObject(element).setActualSize(width, height);
- }
- else
- {
- element.width = width;
- element.height = height;
- }
- }
-
- protected function getElementPreferredWidth(element:Object):Number
- {
- var result:Number;
-
- if (element is ILayoutElement)
- {
- result = ILayoutElement(element).getPreferredBoundsWidth();
- }
- else if (element is IFlexDisplayObject)
- {
- result = IFlexDisplayObject(element).measuredWidth;
- }
- else
- {
- result = element.width;
- }
-
- return Math.round(result);
- }
-
- protected function getElementPreferredHeight(element:Object):Number
- {
- var result:Number;
-
- if (element is ILayoutElement)
- {
- result = ILayoutElement(element).getPreferredBoundsHeight();
- }
- else if (element is IFlexDisplayObject)
- {
- result = IFlexDisplayObject(element).measuredHeight;
- }
- else
- {
- result = element.height;
- }
-
- return Math.ceil(result);
- }
-
-}
-}
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/44826607/frameworks/projects/experimental_mobile/src/spark/components/supportClasses/MobileGridColumn.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/experimental_mobile/src/spark/components/supportClasses/MobileGridColumn.as b/frameworks/projects/experimental_mobile/src/spark/components/supportClasses/MobileGridColumn.as
index 9c49428..b7508f1 100644
--- a/frameworks/projects/experimental_mobile/src/spark/components/supportClasses/MobileGridColumn.as
+++ b/frameworks/projects/experimental_mobile/src/spark/components/supportClasses/MobileGridColumn.as
@@ -19,11 +19,18 @@
package spark.components.supportClasses
{
+import flash.events.EventDispatcher;
import flash.events.IEventDispatcher;
+import mx.core.ClassFactory;
+import mx.core.IFactory;
+import mx.core.mx_internal;
import mx.utils.ObjectUtil;
import spark.collections.SortField;
+import spark.components.itemRenderers.IItemPartRendererBase;
+import spark.components.itemRenderers.IItemTextPartRenderer;
+import spark.components.itemRenderers.ItemTextPartRenderer;
/**
* The MobileGridColumn class defines a column to display in a MobileGrid control.
@@ -36,28 +43,201 @@ import spark.collections.SortField;
* </ul>
*
* @see spark.components.MobileGrid
- * @see spark.components.supportClasses.PartRendererDescriptorBase
*
* @langversion 3.0
* @playerversion AIR 3.8
* @productversion Flex 4.11
*/
-public class MobileGridColumn extends PartRendererDescriptorBase
-{
-
- private var _headerText:String = null;
- private var _headerStyleName:String;
- private var _sortDescending:Boolean;
- private var _sortable:Boolean = true;
+public class MobileGridColumn extends EventDispatcher
+{
public function MobileGridColumn(target:IEventDispatcher = null)
{
super(target);
+ _labelFunction = null;
+ itemRenderer = null; // will set default ;
labelFunction = null;
- setWidth(100); // default width;
itemRenderer = null; // will set default ;
}
+ private var _dataField:String;
+
+ /**
+ * The name of the field or property in the data provider item associated
+ * with the column.
+ * Each GridColumn requires this property or
+ * the <code>labelFunction</code> property to be set
+ * to calculate the displayable text for the item renderer.
+ * If the <code>dataField</code>
+ * and <code>labelFunction</code> properties are set,
+ * the data is displayed using the <code>labelFunction</code> and sorted
+ * using the <code>dataField</code>.
+
+ * <p>If the column or its grid specifies a <code>labelFunction</code>,
+ * then the dataField is not used.</p>
+ *
+ * @default null
+ *
+ * @see #labelFunction
+ *
+ */
+ public function get dataField():String
+ {
+ return _dataField;
+ }
+
+ public function set dataField(value:String):void
+ {
+ _dataField = value;
+ }
+
+ /* internal vars */
+
+ private var _width:Number = NaN;
+
+
+ /** Set the desired width for this column.
+ * <p> Width value is expressed in current applicationDPI, or at 160 DPI if applicationDPI is not set.
+ * The default value is 100.
+ *
+ * <p>Note: You can specify a percentage value in the MXML
+ * <code>width</code> attribute, such as <code>width="50%"</code>,
+ * but you cannot use a percentage value in the <code>width</code>
+ * property in ActionScript.
+ * Use the <code>percentWidth</code> property instead.</p>
+ *
+ * @see #percentWidth
+ *
+ * @default 100
+ */
+ public function get width():Number
+ {
+ return _width;
+ }
+
+ [PercentProxy("percentWidth")]
+ public function set width(value:Number):void
+ {
+ _width = value;
+ }
+
+ private var _percentWidth:Number = NaN;
+
+ /**
+ * Specifies the width of this column as a percentage of the grid's width. Allowed values are 0-100. The default value is NaN.
+ * If set, this property has precedence over the fixed width property.
+ *
+ * <p> MobileGrid will compute the column widths as follows:
+ * <ul>
+ * <li> First, honor all columns with fixed widths. Columns with no width or percentWidth receive a width of 100.</li>
+ * <li> Then distribute the remainder of width between all the columns with percentage widths.
+ * If the total of percentages is greater that 100%, it's will be normalized first..</li>
+ * <ul>
+ * </p>
+ *
+ * @default NaN
+ */
+ public function get percentWidth():Number
+ {
+ return _percentWidth;
+ }
+
+ public function set percentWidth(value:Number):void
+ {
+ _percentWidth = value;
+ }
+
+ private var _itemRenderer:IFactory;
+
+ /**
+ * The class factory for the IItemPartRendererBase class used to
+ * render individual grid cells.
+ *
+ * <p>The default item renderer is the ItemTextPartRenderer class,
+ * which displays the data item as text, optimized for mobile. </p>
+ * <p>You can use also ItemBitmapPartRenderer to display embedded bitmaps, in which case you need to define the iconField or iconFunction </p>
+ * <p>You can also create custom item renderers by deriving any subclass of UIComponent (eg. s:Button) and implementing IItemPartRendererBase.
+ * for performance reasons it's preferable that your renderer be written in ActionScript
+ *
+ * @see #dataField
+ * @see spark.components.itemRenderers.ItemTextPartRenderer
+ * @see spark.components.itemRenderers.ItemBitmapPartRenderer
+ * @see spark.components.itemRenderers.IItemPartRendererBase
+ *
+ */
+ public function get itemRenderer():IFactory
+ {
+ return _itemRenderer;
+ }
+
+ public function set itemRenderer(value:IFactory):void
+ {
+ _itemRenderer = value ? value : new ClassFactory(ItemTextPartRenderer);
+ }
+
+ private var _labelFunction:Function;
+
+
+ /**
+ * An idempotent function that converts a data provider item into a column-specific string
+ * that's used to initialize the item renderer's <code>label</code> property.
+ *
+ * <p>You can use a label function to combine the values of several data provider items
+ * into a single string.
+ * If specified, this property is used by the
+ * <code>itemToLabel()</code> method, which computes the value of each item
+ * renderer's <code>label</code> property in this column.</p>
+ *
+ * <p>The function specified to the <code>labelFunction</code> property
+ * must have the following signature:</p>
+ *
+ * <pre>labelFunction(item:Object):String</pre>
+ *
+ * <p>The <code>item</code> parameter is the data provider item for an entire row.
+ * The second parameter is this column object.</p>
+ *
+ * <p>A typical label function could concatenate the firstName and
+ * lastName properties of the data provider item ,
+ * or do some custom formatting on a Date value property.</p>
+ */
+ public function set labelFunction(value:Function):void
+ {
+ _labelFunction = value;
+ }
+
+ public function get labelFunction():Function
+ {
+ return _labelFunction;
+ }
+
+ private var _styleName:String;
+
+ /** The css style name to apply to the renderer
+ * the style items in the css will depend on the renderer. For example, text renderers will accept fontSize, color, fontWeight, etc.
+ */
+ public function get styleName():String
+ {
+ return _styleName;
+ }
+
+ public function set styleName(value:String):void
+ {
+ _styleName = value;
+ }
+
+ /** Sets the alignment of text renderers.
+ * This property is ignored for non-text renderers.
+ */
+ [Inspectable(enumeration="left,right,center,justify")]
+ public function set textAlign(value:String):void
+ {
+ _textAlign = value;
+ }
+
+ private var _textAlign:String;
+
+ private var _headerText:String = null;
+
/** Defines the text to be displayed in the column's header.
* <p>If this property is not set, the header label will use the value of dataField property instead.</p>
* @see #dataField
@@ -72,6 +252,8 @@ public class MobileGridColumn extends PartRendererDescriptorBase
_headerText = value;
}
+ private var _headerStyleName:String;
+
/** Defines the css style name to be used for displaying this column's header label.
* <p>Use this property to display the header in a different color or font, or with a different text alignment.</p>
*/
@@ -85,6 +267,20 @@ public class MobileGridColumn extends PartRendererDescriptorBase
_headerStyleName = value;
}
+ private var _sortDescending:Boolean;
+
+ public function get sortDescending():Boolean
+ {
+ return _sortDescending;
+ }
+
+ public function set sortDescending(value:Boolean):void
+ {
+ _sortDescending = value;
+ }
+
+ private var _sortable:Boolean = true;
+
/** Flag indicating whether a column can be sorted by clicking on its header.
* <p>This flag is effective only if the MobileGrid </p>
*/
@@ -98,20 +294,6 @@ public class MobileGridColumn extends PartRendererDescriptorBase
_sortable = value;
}
- public function get sortDescending():Boolean
- {
- return _sortDescending;
- }
-
- public function set sortDescending(value:Boolean):void
- {
- _sortDescending = value;
- }
-
- //----------------------------------
- // sortField
- //----------------------------------
-
/**
* Returns a SortField that can be used to sort a collection by this
* column's <code>dataField</code>.
@@ -143,6 +325,27 @@ public class MobileGridColumn extends PartRendererDescriptorBase
return sortField;
}
+ public function createPartRenderer():IItemPartRendererBase
+ {
+ var pr:IItemPartRendererBase = _itemRenderer.newInstance() as IItemPartRendererBase;
+ if (pr)
+ {
+ pr.cssStyleName = _styleName;
+ if (pr is IItemTextPartRenderer)
+ {
+ with (IItemTextPartRenderer(pr))
+ {
+ labelField = _dataField;
+ labelFunction = _labelFunction;
+ textAlign = _textAlign;
+ }
+ }
+ }
+ return pr;
+ }
+
+ mx_internal var colNum:int;
+ mx_internal var actualWidth:Number;
}
}
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/44826607/frameworks/projects/experimental_mobile/src/spark/components/supportClasses/MobileGridHeader.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/experimental_mobile/src/spark/components/supportClasses/MobileGridHeader.as b/frameworks/projects/experimental_mobile/src/spark/components/supportClasses/MobileGridHeader.as
index f92075b..7ef2232 100644
--- a/frameworks/projects/experimental_mobile/src/spark/components/supportClasses/MobileGridHeader.as
+++ b/frameworks/projects/experimental_mobile/src/spark/components/supportClasses/MobileGridHeader.as
@@ -20,6 +20,7 @@ package spark.components.supportClasses
{
import mx.collections.ArrayList;
+import mx.core.IVisualElement;
import mx.core.UIComponent;
import mx.core.mx_internal;
@@ -27,7 +28,6 @@ import spark.components.ButtonBar;
import spark.components.MobileGrid;
import spark.events.IndexChangeEvent;
import spark.events.MobileGridHeaderEvent;
-import spark.events.RendererExistenceEvent;
import spark.utils.MultiDPIBitmapSource;
use namespace mx_internal;
@@ -71,8 +71,6 @@ public class MobileGridHeader extends ButtonBar
this.buttonMode = false;
this.requireSelection = false;
addEventListener(IndexChangeEvent.CHANGING, changingHandler);
- addEventListener(RendererExistenceEvent.RENDERER_ADD, rendererAddHandler);
-
descIconCls = new MultiDPIBitmapSource();
descIconCls.source160dpi = descIcon160Cls;
descIconCls.source320dpi = descIcon320Cls;
@@ -125,17 +123,6 @@ public class MobileGridHeader extends ButtonBar
dataProvider.itemUpdated(_columns[_sortIndex]);
}
- private function rendererAddHandler(event:RendererExistenceEvent):void
- {
- var button:UIComponent = UIComponent(event.renderer);
- var index:int = event.index;
- var col:MobileGridColumn = MobileGridColumn(_columns[index]);
- // expand the last button
- if ((index != dataProvider.length - 1) || col.hasExplicitWidth)
- button.explicitWidth = col.dpiScaledWidth;
- else
- button.percentWidth = 100;
- }
private function getIconForButton(col:MobileGridColumn):Object
{
@@ -148,5 +135,29 @@ public class MobileGridHeader extends ButtonBar
return null;
}
}
+
+ /**
+ * @private
+ * Return the item renderer at the specified index, or null.
+ */
+ private function getItemRenderer(index:int):IVisualElement
+ {
+ if (!dataGroup || (index < 0) || (index >= dataGroup.numElements))
+ return null;
+
+ return dataGroup.getElementAt(index);
+ }
+
+ public function updateHeaderWidths():void
+ {
+ if (dataProvider.length != _columns.length)
+ return; // not ready
+ var header:UIComponent;
+ for (var i:int = 0; i < _columns.length; i++)
+ {
+ header = UIComponent(this.getItemRenderer(i));
+ header.explicitWidth = _columns[i].actualWidth;
+ }
+ }
}
}
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/44826607/frameworks/projects/experimental_mobile/src/spark/components/supportClasses/MobileGridRowRenderer.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/experimental_mobile/src/spark/components/supportClasses/MobileGridRowRenderer.as b/frameworks/projects/experimental_mobile/src/spark/components/supportClasses/MobileGridRowRenderer.as
index b2a8d3e..c3a1446 100644
--- a/frameworks/projects/experimental_mobile/src/spark/components/supportClasses/MobileGridRowRenderer.as
+++ b/frameworks/projects/experimental_mobile/src/spark/components/supportClasses/MobileGridRowRenderer.as
@@ -18,16 +18,246 @@
////////////////////////////////////////////////////////////////////////////////
package spark.components.supportClasses
{
+import flash.display.DisplayObject;
+
+import spark.components.itemRenderers.IItemPartRendererBase;
+import spark.core.DisplayObjectSharingMode;
+import spark.core.IGraphicElement;
+import spark.core.IGraphicElementContainer;
+import spark.core.ISharedDisplayObject;
/** @private
+ * This is the base class for multi-part renderers that manages a vector of part renderers.
+ * This class is responsible for creating and storing the actual renderers from their descriptors
+ * the layout of the part renderers is delegated to a subclass of ListMultiPartLayoutBase;
+
* This is the internal list itemRenderer used for rendering grid cells in a single row of a MobileGrid.
* It inherits all its behavior for its parent class and only sets the part renderers layout.
+ *
+ * @langversion 3.0
+ * @playerversion AIR 3.8
+ * @productversion Flex 4.11
+ *
*/
-public class MobileGridRowRenderer extends ListMultiPartItemRendererBase
+public class MobileGridRowRenderer extends ItemRendererBase implements IGraphicElementContainer, ISharedDisplayObject
{
+ private var _columns:Vector.<MobileGridColumn>;
+ private var _partRenderers:Vector.<IItemPartRendererBase>;
+ private var _graphicElementPartRenderers:Vector.<IGraphicElement>;
+ private var _partRenderersLayout:ListMultiPartColumnLayout;
+
+ /**
+ * Management of graphicElement part renderers lifeCycle
+ */
+ private var _redrawRequested:Boolean = false;
+ private var graphicElementsNeedValidateProperties:Boolean = false;
+ private var graphicElementsNeedValidateSize:Boolean = false;
+
public function MobileGridRowRenderer()
{
- partRenderersLayout = new ListMultiPartColumnLayout(this);
+ _partRenderersLayout = new ListMultiPartColumnLayout(this);
+ }
+
+ /** @private
+ * set in List itemRenderer Factory properties */
+ public function set columns(value:Vector.<MobileGridColumn>):void
+ {
+ _columns = value;
+ _partRenderers = new Vector.<IItemPartRendererBase>(_columns.length, true);
+ _graphicElementPartRenderers = new Vector.<IGraphicElement>();
+ }
+
+ public function get columns():Vector.<MobileGridColumn>
+ {
+ return _columns;
+ }
+
+ public function get partRenderers():Vector.<IItemPartRendererBase>
+ {
+ return _partRenderers;
+ }
+
+ public function get graphicElementPartRenderers():Vector.<IGraphicElement>
+ {
+ return _graphicElementPartRenderers;
+ }
+
+ override protected function createChildren():void
+ {
+ super.createChildren();
+ var desc:MobileGridColumn;
+ var pr:IItemPartRendererBase;
+ var ge:IGraphicElement;
+ for (var i:int = 0; i < _columns.length; i++)
+ {
+ desc = _columns[i];
+ pr = desc.createPartRenderer();
+ if (pr != null)
+ {
+ pr.styleProvider = this;
+
+ if (pr is IGraphicElement)
+ {
+ ge = IGraphicElement(pr);
+ ge.parentChanged(this);
+ if (ge.setSharedDisplayObject(this))
+ {
+ ge.displayObjectSharingMode = DisplayObjectSharingMode.USES_SHARED_OBJECT;
+ }
+ _graphicElementPartRenderers.push(ge);
+ }
+ else if (pr is DisplayObject)
+ {
+ addChild(DisplayObject(pr));
+ }
+ _partRenderers[i] = pr;
+ }
+ else
+ {
+ //TODO move to resource bundle
+ throw new Error("MobileGridColumn item renderer must implement spark.components.itemRenderers.IItemPartRendererBase");
+ }
+ }
+ }
+
+ override protected function measure():void
+ {
+ super.measure();
+ _partRenderersLayout.measure();
+ }
+
+ /** delegate children layout to its partRendererLayout
+ subclasses can override this method to layout chrome content
+ */
+ override protected function layoutContents(unscaledWidth:Number, unscaledHeight:Number):void
+ {
+ _partRenderersLayout.layoutContents(unscaledWidth, unscaledHeight);
+ }
+
+ override protected function onDataChanged():void
+ {
+ var dpr:IItemPartRendererBase;
+ for (var i:int = 0; i < _partRenderers.length; i++)
+ {
+ dpr = _partRenderers[i];
+ dpr.data = data;
+ }
+ invalidateSize();
+ }
+
+ /* graphic element sub renderers lifecycle management */
+
+ override protected function commitProperties():void
+ {
+ if (graphicElementsNeedValidateProperties)
+ {
+ graphicElementsNeedValidateProperties = false;
+ for (var i:int = 0; i < _graphicElementPartRenderers.length; i++)
+ {
+ _graphicElementPartRenderers[i].validateProperties();
+ }
+ }
+ super.commitProperties();
+ }
+
+
+ override public function validateSize(recursive:Boolean = false):void
+ {
+ if (graphicElementsNeedValidateSize)
+ {
+ graphicElementsNeedValidateSize = false;
+ for (var i:int = 0; i < _graphicElementPartRenderers.length; i++)
+ {
+ _graphicElementPartRenderers[i].validateSize();
+ }
+ }
+ super.validateSize(recursive);
+ }
+
+
+ /* copied from Group*/
+ override public function validateDisplayList():void
+ {
+ super.validateDisplayList();
+ if (_redrawRequested)
+ {
+ for (var i:int = 0; i < _graphicElementPartRenderers.length; i++)
+ {
+ _graphicElementPartRenderers[i].validateDisplayList();
+ }
+ }
+ }
+
+ /* interfaces implementation, copied from spark.components.IconItemRender */
+
+ /**
+ * @inheritDoc
+ *
+ * <p>We implement this as part of ISharedDisplayObject so the iconDisplay
+ * can share our display object.</p>
+ *
+ * @langversion 3.0
+ * @playerversion AIR 1.5
+ * @productversion Flex 4
+ */
+ public function get redrawRequested():Boolean
+ {
+ return _redrawRequested;
+ }
+
+ /**
+ * @private
+ */
+ public function set redrawRequested(value:Boolean):void
+ {
+ _redrawRequested = value;
+ }
+
+ //--------------------------------------------------------------------------
+ //
+ // IGraphicElementContainer
+ //
+ // -------------------------------------------------------------------------
+
+ /**
+ * @private
+ *
+ * Notify the host component that an element changed and needs to validate properties.
+ */
+ public function invalidateGraphicElementSharing(element:IGraphicElement):void
+ {
+ //do nothing because all has been done in createChildren and won't change
+ }
+
+ /**
+ * @private
+ *
+ * Notify the host component that an element changed and needs to validate properties.
+ */
+ public function invalidateGraphicElementProperties(element:IGraphicElement):void
+ {
+ graphicElementsNeedValidateProperties = true;
+ invalidateProperties();
+ }
+
+ /**
+ * @private
+ */
+ public function invalidateGraphicElementSize(element:IGraphicElement):void
+ {
+ graphicElementsNeedValidateSize = true;
+ invalidateSize();
+ }
+
+ /**
+ * @private
+ *
+ */
+ public function invalidateGraphicElementDisplayList(element:IGraphicElement):void
+ {
+ if (element.displayObject is ISharedDisplayObject)
+ ISharedDisplayObject(element.displayObject).redrawRequested = true;
+ invalidateDisplayList();
}
}
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/44826607/frameworks/projects/experimental_mobile/src/spark/components/supportClasses/PartRendererDescriptorBase.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/experimental_mobile/src/spark/components/supportClasses/PartRendererDescriptorBase.as b/frameworks/projects/experimental_mobile/src/spark/components/supportClasses/PartRendererDescriptorBase.as
deleted file mode 100644
index 23ce03e..0000000
--- a/frameworks/projects/experimental_mobile/src/spark/components/supportClasses/PartRendererDescriptorBase.as
+++ /dev/null
@@ -1,189 +0,0 @@
-////////////////////////////////////////////////////////////////////////////////
-//
-// 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 spark.components.supportClasses
-{
-import flash.events.EventDispatcher;
-import flash.events.IEventDispatcher;
-
-import mx.core.ClassFactory;
-import mx.core.DPIClassification;
-import mx.core.IFactory;
-import mx.core.mx_internal;
-
-import spark.components.itemRenderers.IItemPartRendererBase;
-import spark.components.itemRenderers.IItemTextPartRenderer;
-import spark.components.itemRenderers.ItemTextPartRenderer;
-import spark.utils.DensityUtil2;
-
-/** This is the base class for GridColumn
- *
- */
-public class PartRendererDescriptorBase extends EventDispatcher
-{
-
- private var _colNum:int;
- private var _dataField:String;
- private var _width:Number;
- private var _hasExplicitWidth:Boolean;
- private var _dpiScaledWidth:Number;
- private var _itemRenderer:IFactory;
- private var _labelFunction:Function;
- private var _styleName:String;
- private var _textAlign:String;
-
-
- public function PartRendererDescriptorBase(target:IEventDispatcher = null)
- {
- super(target);
- _labelFunction = null;
- setWidth(100); // default width;
- itemRenderer = null; // will set default ;
- }
-
- /* IDataGridColumn impl*/
-
- public function set dataField(value:String):void
- {
- _dataField = value;
- }
-
- public function get dataField():String
- {
- return _dataField;
- }
-
- public function get labelFunction():Function
- {
- return _labelFunction;
- }
-
- /**
- * An idempotent function that converts a data provider item into a column-specific string
- * that's used to initialize the item renderer's <code>label</code> property.
- *
- * <p>You can use a label function to combine the values of several data provider items
- * into a single string.
- * If specified, this property is used by the
- * <code>itemToLabel()</code> method, which computes the value of each item
- * renderer's <code>label</code> property in this column.</p>
- *
- * <p>The function specified to the <code>labelFunction</code> property
- * must have the following signature:</p>
- *
- * <pre>labelFunction(item:Object):String</pre>
- *
- * <p>The <code>item</code> parameter is the data provider item for an entire row.
- * The second parameter is this column object.</p>
- *
- * <p>A typical label function could concatenate the firstName and
- * lastName properties of the data provider item ,
- * or do some custom formatting on a Date value property.</p>
- */
- public function set labelFunction(value:Function):void
- {
- _labelFunction = value;
- }
-
- public function set styleName(value:String):void
- {
- _styleName = value;
- }
-
- /** Set the desired width for this column.
- * <p> Width value is expressed in current applicationDPI, or at 160 DPI if applicationDPI is not set.</p>
- * Default value is 100.
- * Note that the last column will always expand
- *
- * @param value = desired width of the column at 160 DPI
- */
- public function set width(value:Number):void
- {
- setWidth(value);
- _hasExplicitWidth = true;
- }
-
- protected function setWidth(value:Number):void
- {
- _width = value;
- _dpiScaledWidth = DensityUtil2.dpiScale(value, DPIClassification.DPI_160);
- }
-
-
- public function get itemRenderer():IFactory
- {
- return _itemRenderer;
- }
-
- public function set itemRenderer(value:IFactory):void
- {
- _itemRenderer = value ? value : new ClassFactory(ItemTextPartRenderer);
- }
-
- public function get styleName():String
- {
- return _styleName;
- }
-
- [Inspectable(enumeration="left,right,center,justify")]
- public function set textAlign(value:String):void
- {
- _textAlign = value;
- }
-
- public function createPartRenderer():IItemPartRendererBase
- {
- var pr:IItemPartRendererBase = _itemRenderer.newInstance() as IItemPartRendererBase;
- if (pr)
- {
- pr.cssStyleName = _styleName;
- if (pr is IItemTextPartRenderer)
- {
- with (IItemTextPartRenderer(pr))
- {
- labelField = _dataField;
- labelFunction = _labelFunction;
- textAlign = _textAlign;
- }
- }
- }
- return pr;
- }
-
- mx_internal function get hasExplicitWidth():Boolean
- {
- return _hasExplicitWidth;
- }
-
- mx_internal function get dpiScaledWidth():Number
- {
- return _dpiScaledWidth;
- }
-
- mx_internal function get colNum():int
- {
- return _colNum;
- }
-
- mx_internal function set colNum(value:int):void
- {
- _colNum = value;
- }
-
-}
-}
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/44826607/frameworks/projects/experimental_mobile/src/spark/events/MobileGridHeaderEvent.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/experimental_mobile/src/spark/events/MobileGridHeaderEvent.as b/frameworks/projects/experimental_mobile/src/spark/events/MobileGridHeaderEvent.as
index 31e1462..c660941 100644
--- a/frameworks/projects/experimental_mobile/src/spark/events/MobileGridHeaderEvent.as
+++ b/frameworks/projects/experimental_mobile/src/spark/events/MobileGridHeaderEvent.as
@@ -31,7 +31,7 @@ import flash.events.Event;
* @productversion Flex 4.11
*/
-// Note: we didn't use neither mx:DataGridEven because it's in not available for mobile not GridSortEvent because it handles multiple sorting
+// Note: we didn't use neither mx:DataGridEvent because it's in not available for mobile not GridSortEvent because it handles multiple sorting
public class MobileGridHeaderEvent extends Event
{
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/44826607/frameworks/projects/experimental_mobile/src/spark/layouts/MobileGridLayout.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/experimental_mobile/src/spark/layouts/MobileGridLayout.as b/frameworks/projects/experimental_mobile/src/spark/layouts/MobileGridLayout.as
new file mode 100644
index 0000000..8149dfe
--- /dev/null
+++ b/frameworks/projects/experimental_mobile/src/spark/layouts/MobileGridLayout.as
@@ -0,0 +1,95 @@
+package spark.layouts
+{
+import mx.core.mx_internal;
+
+import spark.components.MobileGrid;
+import spark.components.supportClasses.MobileGridColumn;
+import spark.utils.DensityUtil2;
+
+use namespace mx_internal;
+
+/**
+ * Internal class used for laying out rows, columns and headers of a MobileGrid component.
+ *
+ * @langversion 3.0
+ * @playerversion AIR 3.8
+ * @productversion Flex 4.11
+ */
+public class MobileGridLayout extends VerticalLayout
+{
+ public function MobileGridLayout(grid:MobileGrid)
+ {
+ super();
+ _grid = grid;
+ }
+
+ private var prevUnscaledWidth:Number;
+ private var _grid:MobileGrid;
+
+ override public function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void
+ {
+ super.updateDisplayList(unscaledWidth, unscaledHeight);
+ if (prevUnscaledWidth != unscaledWidth)
+ {
+ prevUnscaledWidth = unscaledWidth;
+ updateColumnWidths(unscaledWidth);
+ }
+ }
+
+ /** compute colum actual widths from colum width and percentWidth
+ * simple algorithm is following:
+ * first set all columns that have fixed width
+ * set distribute the remainder between the percentages, normalized to 100%
+ *
+ * @param unscaledWidth
+ */
+ protected function updateColumnWidths(unscaledWidth:Number):void
+ {
+ if (unscaledWidth == 0)
+ return; // not ready
+
+ var colWidth:Number;
+ var colActualWidth:Number;
+
+ var totalFixedWidths:Number = 0;
+ var totalPercentages:Number = 0;
+ var cols:Array = _grid.columns;
+ var col:MobileGridColumn;
+
+ for (var i:int = 0; i < cols.length; i++)
+ {
+ col = cols[i];
+ if (!isNaN(col.percentWidth))
+ {
+ totalPercentages += col.percentWidth;
+ }
+ else
+ {
+ colWidth = isNaN(col.width) ? 100 : col.width;
+ colActualWidth = DensityUtil2.dpiScale(colWidth);
+ col.actualWidth = colActualWidth; // can immediately set actual width
+ totalFixedWidths += colActualWidth;
+ }
+ }
+
+ // distribute remainder to percent widths
+ var remainingWidth:Number = Math.max(0, unscaledWidth - totalFixedWidths);
+ var normalPercentWidth:Number;
+ for (var j:int = 0; j < cols.length; j++)
+ {
+ col = cols[j];
+ if (!isNaN(col.percentWidth))
+ {
+ normalPercentWidth = col.percentWidth / totalPercentages;
+ /* 0 .. 1*/
+ col.actualWidth = remainingWidth * normalPercentWidth;
+ }
+ }
+
+ // update also datagrid header ;
+ _grid.headerGroup.updateHeaderWidths();
+
+ }
+
+}
+}
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/44826607/frameworks/projects/experimental_mobile/src/spark/utils/DensityUtil2.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/experimental_mobile/src/spark/utils/DensityUtil2.as b/frameworks/projects/experimental_mobile/src/spark/utils/DensityUtil2.as
index 7f447ad..247c234 100644
--- a/frameworks/projects/experimental_mobile/src/spark/utils/DensityUtil2.as
+++ b/frameworks/projects/experimental_mobile/src/spark/utils/DensityUtil2.as
@@ -19,11 +19,25 @@
package spark.utils
{
+import mx.core.DPIClassification;
import mx.core.FlexGlobals;
import mx.managers.SystemManager;
import spark.components.Application;
+//TODO merge with spark.utils.DensityUtil
+
+/**
+ * @private
+ * Utility class for density computations
+ *
+ * @langversion 3.0
+ * @playerversion AIR 3.8
+ * @productversion Flex 4.11
+
+ */
+
+
public class DensityUtil2
{
@@ -37,7 +51,7 @@ public class DensityUtil2
* @param sourceDPI
* @return scaled value
*/
- public static function dpiScale(value:Number, sourceDPI:Number):Number
+ public static function dpiScale(value:Number, sourceDPI:Number = DPIClassification.DPI_160):Number
{
var appDPI:Number = getSetApplicationDPI();
if (isNaN(appDPI))
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/44826607/frameworks/projects/experimental_mobile/src/spark/utils/MultiDPIBitmapSourceExt.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/experimental_mobile/src/spark/utils/MultiDPIBitmapSourceExt.as b/frameworks/projects/experimental_mobile/src/spark/utils/MultiDPIBitmapSourceExt.as
index ce17ffe..0a01f34 100644
--- a/frameworks/projects/experimental_mobile/src/spark/utils/MultiDPIBitmapSourceExt.as
+++ b/frameworks/projects/experimental_mobile/src/spark/utils/MultiDPIBitmapSourceExt.as
@@ -21,6 +21,12 @@ package spark.utils
import mx.core.FlexGlobals;
import mx.utils.DensityUtil;
+//TODO mamsellem move this code to parent class, updates any callers, and remove this class
+
+/** @private
+ * Adds default behavior to its parent class MultiDPIBitmapSource.
+ *
+ */
public class MultiDPIBitmapSourceExt extends MultiDPIBitmapSource
{
@@ -38,9 +44,8 @@ public class MultiDPIBitmapSourceExt extends MultiDPIBitmapSource
* @return One of the sourceXXXdpi properties based on the desired DPI.
*
* @langversion 3.0
- * @playerversion Flash 10.2
- * @playerversion AIR 2.6
- * @productversion Flex 4.5
+ * @playerversion AIR 3.8
+ * @productversion Flex 4.11
*/
override public function getSource(desiredDPI:Number):Object
@@ -59,7 +64,6 @@ public class MultiDPIBitmapSourceExt extends MultiDPIBitmapSource
return super.getSource(desiredDPI);
}
- //TODO mamsellem move this code to parent class, updates any callers, and remove this class
}
}
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/44826607/frameworks/projects/experimental_mobile/src/spark/utils/UIComponentUtils.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/experimental_mobile/src/spark/utils/UIComponentUtils.as b/frameworks/projects/experimental_mobile/src/spark/utils/UIComponentUtils.as
index 93f6f8e..737fa40 100644
--- a/frameworks/projects/experimental_mobile/src/spark/utils/UIComponentUtils.as
+++ b/frameworks/projects/experimental_mobile/src/spark/utils/UIComponentUtils.as
@@ -16,15 +16,21 @@
// limitations under the License.
//
////////////////////////////////////////////////////////////////////////////////
+
package spark.utils
{
import mx.core.IFlexDisplayObject;
import mx.core.ILayoutElement;
+/** @private
+ * Utility class for MobileGrid
+ * @langversion 3.0
+ * @playerversion AIR 3.8
+ * @productversion Flex 4.11
+ */
public class UIComponentUtils
{
-
public static function itemToLabel(item:Object, labelField:String, labelFunction:Function, nullLabel:String = '-'):String
{
if (labelFunction != null)
[2/5] git commit: [flex-sdk] [refs/heads/mobileexperimental] -
https://issues.apache.org/jira/browse/FLEX-33777 Dagrid for mobile -
formatted sources code - added ASDOC (almost all) - bug: Bitmap renderer does
not support MultiDPI when appDPI is set
Posted by ma...@apache.org.
https://issues.apache.org/jira/browse/FLEX-33777 Dagrid for mobile
- formatted sources code
- added ASDOC (almost all)
- bug: Bitmap renderer does not support MultiDPI when appDPI is set
Project: http://git-wip-us.apache.org/repos/asf/flex-sdk/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-sdk/commit/b78de5c0
Tree: http://git-wip-us.apache.org/repos/asf/flex-sdk/tree/b78de5c0
Diff: http://git-wip-us.apache.org/repos/asf/flex-sdk/diff/b78de5c0
Branch: refs/heads/mobileexperimental
Commit: b78de5c0c4b019c2d928d21f6fb2a8eb485161e6
Parents: aef85b3
Author: mamsellem <ma...@systar.com>
Authored: Tue Oct 1 12:02:14 2013 +0200
Committer: mamsellem <ma...@systar.com>
Committed: Tue Oct 1 12:02:14 2013 +0200
----------------------------------------------------------------------
asdoc/build.xml | 2 +
.../assets/images/mobile160/dg_header_asc.png | Bin 0 -> 447 bytes
.../assets/images/mobile160/dg_header_desc.png | Bin 0 -> 418 bytes
.../assets/images/mobile160/dg_header_sep.png | Bin 0 -> 201 bytes
.../images/mobile160/dg_header_shadow.png | Bin 0 -> 277 bytes
.../assets/images/mobile320/dg_header_asc.png | Bin 0 -> 527 bytes
.../assets/images/mobile320/dg_header_desc.png | Bin 0 -> 496 bytes
.../assets/images/mobile320/dg_header_sep.png | Bin 0 -> 215 bytes
.../images/mobile320/dg_header_shadow.png | Bin 0 -> 329 bytes
.../projects/experimental_mobile/build.xml | 11 +-
.../experimental_mobile/bundle-config.xml | 20 +-
.../experimental_mobile/compile-config.xml | 5 +-
.../projects/experimental_mobile/defaults.css | 129 +++
.../projects/experimental_mobile/manifest.xml | 57 +-
.../src/ExperimentalMobileClasses.as | 25 +-
.../src/spark/components/MobileGrid.as | 302 +++++++
.../itemRenderers/IItemPartRendererBase.as | 55 ++
.../itemRenderers/IItemTextPartRenderer.as | 35 +
.../itemRenderers/ItemBitmapPartRenderer.as | 144 +++
.../itemRenderers/ItemTextPartRenderer.as | 97 ++
.../supportClasses/IPartRendererDescriptor.as | 34 +
.../supportClasses/ItemRendererBase.as | 894 +++++++++++++++++++
.../ListMultiPartItemRendererBase.as | 119 +++
.../supportClasses/ListMultiPartLayoutBase.as | 141 +++
.../supportClasses/ListMultiPartTabbedLayout.as | 82 ++
.../supportClasses/MobileGridColumn.as | 148 +++
.../supportClasses/MobileGridHeader.as | 151 ++++
.../supportClasses/MobileGridRowRenderer.as | 34 +
.../PartRendererDescriptorBase.as | 184 ++++
.../src/spark/events/MobileGridHeaderEvent.as | 58 ++
.../skins/MobileGridHeaderButtonBarSkin.as | 89 ++
.../spark/skins/MobileGridHeaderButtonSkin.as | 43 +
.../skins/MobileGridHeaderFirstButtonSkin.as | 35 +
.../src/spark/skins/MobileGridSkin.as | 178 ++++
.../assets/MobileGridHeaderButton_down.fxg | 46 +
.../mobile/assets/MobileGridHeaderButton_up.fxg | 44 +
.../assets/MobileGridHeaderFirstButton_down.fxg | 34 +
.../assets/MobileGridHeaderFirstButton_up.fxg | 32 +
.../src/spark/utils/DensityUtil2.as | 88 ++
.../src/spark/utils/MultiDPIBitmapSourceExt.as | 44 +
.../src/spark/utils/UIComponentUtils.as | 163 ++++
41 files changed, 3471 insertions(+), 52 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/b78de5c0/asdoc/build.xml
----------------------------------------------------------------------
diff --git a/asdoc/build.xml b/asdoc/build.xml
index 8803daf..ed9ea86 100644
--- a/asdoc/build.xml
+++ b/asdoc/build.xml
@@ -105,6 +105,7 @@
<!-- added for Apache -->
<compiler.source-path path-element="${flexlib}/projects/apache/src"/>
<compiler.source-path path-element="${flexlib}/projects/experimental/src"/>
+ <compiler.source-path path-element="${flexlib}/projects/experimental_mobile/src"/>
<!-- namespaces to include in asdoc -->
<doc-namespaces uri="http://www.adobe.com/2006/airmxml"/>
@@ -141,6 +142,7 @@
<!-- added for Apache -->
<namespace uri="http://flex.apache.org/ns" manifest="${flexlib}/projects/apache/manifest.xml"/>
<namespace uri="http://flex.apache.org/experimental/ns" manifest="${flexlib}/projects/experimental/manifest.xml"/>
+ <namespace uri="http://flex.apache.org/experimental/ns" manifest="${flexlib}/projects/experimental_mobile/manifest.xml"/>
<library-path/>
<external-library-path dir="${env.AIR_HOME}/frameworks/libs/air">
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/b78de5c0/frameworks/projects/experimental_mobile/assets/images/mobile160/dg_header_asc.png
----------------------------------------------------------------------
diff --git a/frameworks/projects/experimental_mobile/assets/images/mobile160/dg_header_asc.png b/frameworks/projects/experimental_mobile/assets/images/mobile160/dg_header_asc.png
new file mode 100644
index 0000000..6da01b4
Binary files /dev/null and b/frameworks/projects/experimental_mobile/assets/images/mobile160/dg_header_asc.png differ
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/b78de5c0/frameworks/projects/experimental_mobile/assets/images/mobile160/dg_header_desc.png
----------------------------------------------------------------------
diff --git a/frameworks/projects/experimental_mobile/assets/images/mobile160/dg_header_desc.png b/frameworks/projects/experimental_mobile/assets/images/mobile160/dg_header_desc.png
new file mode 100644
index 0000000..3b0d1d0
Binary files /dev/null and b/frameworks/projects/experimental_mobile/assets/images/mobile160/dg_header_desc.png differ
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/b78de5c0/frameworks/projects/experimental_mobile/assets/images/mobile160/dg_header_sep.png
----------------------------------------------------------------------
diff --git a/frameworks/projects/experimental_mobile/assets/images/mobile160/dg_header_sep.png b/frameworks/projects/experimental_mobile/assets/images/mobile160/dg_header_sep.png
new file mode 100644
index 0000000..67aa576
Binary files /dev/null and b/frameworks/projects/experimental_mobile/assets/images/mobile160/dg_header_sep.png differ
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/b78de5c0/frameworks/projects/experimental_mobile/assets/images/mobile160/dg_header_shadow.png
----------------------------------------------------------------------
diff --git a/frameworks/projects/experimental_mobile/assets/images/mobile160/dg_header_shadow.png b/frameworks/projects/experimental_mobile/assets/images/mobile160/dg_header_shadow.png
new file mode 100644
index 0000000..d97bbcd
Binary files /dev/null and b/frameworks/projects/experimental_mobile/assets/images/mobile160/dg_header_shadow.png differ
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/b78de5c0/frameworks/projects/experimental_mobile/assets/images/mobile320/dg_header_asc.png
----------------------------------------------------------------------
diff --git a/frameworks/projects/experimental_mobile/assets/images/mobile320/dg_header_asc.png b/frameworks/projects/experimental_mobile/assets/images/mobile320/dg_header_asc.png
new file mode 100644
index 0000000..cec2d5a
Binary files /dev/null and b/frameworks/projects/experimental_mobile/assets/images/mobile320/dg_header_asc.png differ
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/b78de5c0/frameworks/projects/experimental_mobile/assets/images/mobile320/dg_header_desc.png
----------------------------------------------------------------------
diff --git a/frameworks/projects/experimental_mobile/assets/images/mobile320/dg_header_desc.png b/frameworks/projects/experimental_mobile/assets/images/mobile320/dg_header_desc.png
new file mode 100644
index 0000000..e4bf91c
Binary files /dev/null and b/frameworks/projects/experimental_mobile/assets/images/mobile320/dg_header_desc.png differ
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/b78de5c0/frameworks/projects/experimental_mobile/assets/images/mobile320/dg_header_sep.png
----------------------------------------------------------------------
diff --git a/frameworks/projects/experimental_mobile/assets/images/mobile320/dg_header_sep.png b/frameworks/projects/experimental_mobile/assets/images/mobile320/dg_header_sep.png
new file mode 100644
index 0000000..fd9800a
Binary files /dev/null and b/frameworks/projects/experimental_mobile/assets/images/mobile320/dg_header_sep.png differ
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/b78de5c0/frameworks/projects/experimental_mobile/assets/images/mobile320/dg_header_shadow.png
----------------------------------------------------------------------
diff --git a/frameworks/projects/experimental_mobile/assets/images/mobile320/dg_header_shadow.png b/frameworks/projects/experimental_mobile/assets/images/mobile320/dg_header_shadow.png
new file mode 100644
index 0000000..b92d426
Binary files /dev/null and b/frameworks/projects/experimental_mobile/assets/images/mobile320/dg_header_shadow.png differ
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/b78de5c0/frameworks/projects/experimental_mobile/build.xml
----------------------------------------------------------------------
diff --git a/frameworks/projects/experimental_mobile/build.xml b/frameworks/projects/experimental_mobile/build.xml
index 4796850..735e5e2 100644
--- a/frameworks/projects/experimental_mobile/build.xml
+++ b/frameworks/projects/experimental_mobile/build.xml
@@ -161,8 +161,9 @@
<target name="compile" description="Compiles experimental_mobile.swc">
<echo message="Compiling frameworks/libs/experimental_mobile.swc"/>
+ <echo message="Using ${env.AIR_HOME}/frameworks/libs/air/airglobal.swc" level="info"/>
- <!-- Load the <compc> task. We can't do this at the <project> level -->
+ <!-- Load the <compc> task. We can't do this at the <project> level -->
<!-- because targets that run before flexTasks.jar gets built would fail. -->
<taskdef resource="flexTasks.tasks" classpath="${FLEX_HOME}/lib/flexTasks.jar"/>
<!--
@@ -183,7 +184,7 @@
<jvmarg line="${compc.jvm.args}"/>
<load-config filename="compile-config.xml" />
<arg value="+playerglobal.version=${playerglobal.version}" />
- <arg value="+env.PLAYERGLOBAL_HOME=${env.PLAYERGLOBAL_HOME}" />
+ <arg value="+env.AIR_HOME=${env.AIR_HOME}"/>
</compc>
</target>
@@ -209,6 +210,12 @@
<asdoc output="${FLEX_HOME}/tempDoc" lenient="true" failonerror="true" keep-xml="true" skip-xsl="true" fork="true">
<compiler.source-path path-element="${basedir}/src"/>
<doc-classes class="ExperimentalMobileClasses"/>
+ <external-library-path dir="${FLEX_HOME}/frameworks/themes/Mobile">
+ <include name="mobile.swc"/>
+ </external-library-path>
+ <external-library-path dir="${FLEX_HOME}/frameworks/libs/mobile">
+ <include name="mobilecomponents.swc"/>
+ </external-library-path>
<namespace uri="http://flex.apache.org/experimental/ns" manifest="${basedir}/manifest.xml"/>
<namespace uri="library://ns.adobe.com/flex/spark" manifest="${basedir}/spark-manifest.xml"/>
<jvmarg line="${asdoc.jvm.args}"/>
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/b78de5c0/frameworks/projects/experimental_mobile/bundle-config.xml
----------------------------------------------------------------------
diff --git a/frameworks/projects/experimental_mobile/bundle-config.xml b/frameworks/projects/experimental_mobile/bundle-config.xml
index 0fce3e0..3a1117c 100644
--- a/frameworks/projects/experimental_mobile/bundle-config.xml
+++ b/frameworks/projects/experimental_mobile/bundle-config.xml
@@ -18,35 +18,33 @@
-->
<flex-config>
- <compiler>
+ <compiler>
<external-library-path>
<path-element>${env.PLAYERGLOBAL_HOME}/${playerglobal.version}/playerglobal.swc</path-element>
<path-element>../../libs/framework.swc</path-element>
- <path-element>../../libs/spark.swc</path-element>
- <path-element>../../libs/mobile/mobilecomponents.swc</path-element>
</external-library-path>
-
+
<include-libraries/>
-
+
<library-path/>
-
+
<locale>
<locale-element>${locale}</locale-element>
</locale>
-
+
<source-path>
<path-element>src</path-element>
<path-element>bundles/${locale}</path-element>
</source-path>
</compiler>
-
+
<include-classes/>
-
+
<include-namespaces/>
-
+
<include-resource-bundles>
<bundle>experimental</bundle>
</include-resource-bundles>
-
+
<target-player>${playerglobal.version}</target-player>
</flex-config>
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/b78de5c0/frameworks/projects/experimental_mobile/compile-config.xml
----------------------------------------------------------------------
diff --git a/frameworks/projects/experimental_mobile/compile-config.xml b/frameworks/projects/experimental_mobile/compile-config.xml
index 4e0ee97..7a21013 100644
--- a/frameworks/projects/experimental_mobile/compile-config.xml
+++ b/frameworks/projects/experimental_mobile/compile-config.xml
@@ -22,11 +22,14 @@
<accessible>true</accessible>
<external-library-path>
- <path-element>${env.PLAYERGLOBAL_HOME}/${playerglobal.version}/playerglobal.swc</path-element>
+ <path-element>${env.AIR_HOME}/frameworks/libs/air/airglobal.swc</path-element>
+ <path-element>${env.AIR_HOME}/frameworks/libs/air/airglobal.swc</path-element>
<path-element>../../libs/framework.swc</path-element>
+ <path-element>../../libs/apache.swc</path-element>
<path-element>../../libs/spark.swc</path-element>
<path-element>../../libs/textlayout.swc</path-element>
<path-element>../../libs/mobile/mobilecomponents.swc</path-element>
+ <path-element>../../themes/Mobile/mobile.swc</path-element>
</external-library-path>
<keep-as3-metadata>
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/b78de5c0/frameworks/projects/experimental_mobile/defaults.css
----------------------------------------------------------------------
diff --git a/frameworks/projects/experimental_mobile/defaults.css b/frameworks/projects/experimental_mobile/defaults.css
index 66188a1..236ea6f 100644
--- a/frameworks/projects/experimental_mobile/defaults.css
+++ b/frameworks/projects/experimental_mobile/defaults.css
@@ -18,3 +18,132 @@
*/
@namespace "http://flex.apache.org/experimental/ns";
@namespace s "library://ns.adobe.com/flex/spark";
+@namespace supportClasses "spark.components.supportClasses.*";
+
+MobileGrid
+{
+ skinClass: ClassReference('spark.skins.MobileGridSkin');
+ contentBackgroundColor: #202020;
+ alternatingItemColors: #202020, #2a2a2a;
+ color: white;
+ selection-color: #00a2ff; /* blue */
+}
+
+supportClasses|MobileGridHeader
+{
+ chromeColor: #383838;
+ skinClass: ClassReference('spark.skins.MobileGridHeaderButtonBarSkin');
+ fontWeight: bold;
+ /* color: #f0f0f0; */
+}
+
+supportClasses|ItemRendererBase
+{
+ verticalAlign: "middle";
+}
+
+@media (application-dpi: 120)
+{
+
+ supportClasses|MobileGridHeader
+ {
+ fontSize: 10;
+ }
+
+ supportClasses|MobileGridRowRenderer
+ {
+ paddingTop: 1;
+ paddingLeft: 7;
+ paddingRight: 7;
+ paddingBottom: 0;
+ }
+
+ supportClasses|ItemRendererBase
+ {
+ color: #bae5ff;
+ paddingBottom: 12;
+ paddingLeft: 7;
+ paddingRight: 7;
+ paddingTop: 12;
+ }
+}
+
+@media (application-dpi: 160)
+{
+
+ supportClasses|MobileGridHeader
+ {
+ fontSize: 14;
+ }
+
+ supportClasses|MobileGridRowRenderer
+ {
+ paddingTop: 1;
+ paddingLeft: 10;
+ paddingRight: 10;
+ paddingBottom: 0;
+ }
+
+ supportClasses|ItemRendererBase
+ {
+ color: #acffb5;
+ paddingBottom: 16;
+ paddingLeft: 10;
+ paddingRight: 10;
+ paddingTop: 16;
+ }
+}
+
+@media (application-dpi: 240)
+{
+
+ supportClasses|MobileGridHeader
+ {
+ fontSize: 20;
+ }
+
+ supportClasses|MobileGridRowRenderer
+ {
+ paddingTop: 2;
+ paddingLeft: 14;
+ paddingRight: 14;
+ paddingBottom: 0;
+ }
+
+ supportClasses|ItemRendererBase
+ {
+ color: #fbffa0;
+ paddingBottom: 24;
+ paddingLeft: 14;
+ paddingRight: 14;
+ paddingTop: 24;
+ }
+}
+
+@media (application-dpi: 320)
+{
+
+ supportClasses|MobileGridHeader
+ {
+ fontSize: 28;
+ }
+
+ supportClasses|MobileGridRowRenderer
+ {
+ color: #ffc2aa;
+ paddingTop: 2;
+ paddingLeft: 20;
+ paddingRight: 20;
+ paddingBottom: 0;
+ }
+
+ supportClasses|ItemRendererBase
+ {
+ paddingBottom: 32;
+ paddingLeft: 20;
+ paddingRight: 20;
+ paddingTop: 32;
+ }
+}
+
+
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/b78de5c0/frameworks/projects/experimental_mobile/manifest.xml
----------------------------------------------------------------------
diff --git a/frameworks/projects/experimental_mobile/manifest.xml b/frameworks/projects/experimental_mobile/manifest.xml
index 4864d95..9cb9823 100644
--- a/frameworks/projects/experimental_mobile/manifest.xml
+++ b/frameworks/projects/experimental_mobile/manifest.xml
@@ -1,29 +1,28 @@
-<?xml version="1.0"?>
-<!--
-
- 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.
-
--->
-
-<!--
-
- Experimental Mobile Components
-
--->
-<componentPackage>
-
-
-</componentPackage>
+<?xml version="1.0"?>
+<!--
+
+ 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.
+-->
+
+<!--
+ Experimental Mobile Components
+-->
+<componentPackage>
+ <component class="spark.components.MobileGrid"/>
+ <component class="spark.components.supportClasses.MobileGridColumn"/>
+ <component class="spark.components.itemRenderers.ItemBitmapPartRenderer"/>
+ <component class="spark.components.itemRenderers.ItemTextPartRenderer"/>
+</componentPackage>
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/b78de5c0/frameworks/projects/experimental_mobile/src/ExperimentalMobileClasses.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/experimental_mobile/src/ExperimentalMobileClasses.as b/frameworks/projects/experimental_mobile/src/ExperimentalMobileClasses.as
index 76e561c..215735f 100644
--- a/frameworks/projects/experimental_mobile/src/ExperimentalMobileClasses.as
+++ b/frameworks/projects/experimental_mobile/src/ExperimentalMobileClasses.as
@@ -18,13 +18,20 @@
////////////////////////////////////////////////////////////////////////////////
package
{
- internal class ExperimentalMobileClasses
- {
- /**
- * @private
- * This class is used to link additional classes into experimental.swc
- * beyond those that are found by dependecy analysis starting
- * from the classes specified in manifest.xml.
- */
- }
+import spark.components.MobileGrid;
+import spark.components.supportClasses.MobileGridColumn;
+import spark.skins.MobileGridHeaderButtonBarSkin;
+import spark.skins.MobileGridSkin;
+
+/*
+ classes that won't be detected through dependencies
+* and classes that needs to be includes in ASDOC
+* */
+
+ internal class ExperimentalMobileClasses
+{
+
+ // mamsellem: for some reason, the import statements alone are not enough to have the classes included
+ private static const classes:Array = [MobileGrid, MobileGridColumn, MobileGridSkin, MobileGridHeaderButtonBarSkin];
+}
}
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/b78de5c0/frameworks/projects/experimental_mobile/src/spark/components/MobileGrid.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/experimental_mobile/src/spark/components/MobileGrid.as b/frameworks/projects/experimental_mobile/src/spark/components/MobileGrid.as
new file mode 100644
index 0000000..618a1bc
--- /dev/null
+++ b/frameworks/projects/experimental_mobile/src/spark/components/MobileGrid.as
@@ -0,0 +1,302 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// 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 spark.components
+{
+
+import mx.collections.ICollectionView;
+import mx.collections.ISort;
+import mx.collections.ISortField;
+import mx.core.ClassFactory;
+import mx.core.ScrollPolicy;
+import mx.core.mx_internal;
+
+import spark.collections.Sort;
+import spark.components.supportClasses.IPartRendererDescriptor;
+import spark.components.supportClasses.MobileGridColumn;
+import spark.components.supportClasses.MobileGridHeader;
+import spark.components.supportClasses.MobileGridRowRenderer;
+import spark.events.MobileGridHeaderEvent;
+import spark.layouts.VerticalLayout;
+import spark.layouts.supportClasses.LayoutBase;
+
+use namespace mx_internal;
+
+/**
+ * Dispatched when the user releases the mouse button on a column header
+ * to request the control to sort the grid contents based on the contents of the column.
+ * Only dispatched if the column is sortable and the data provider supports
+ * sorting. The DataGrid control has a default handler for this event that implements
+ * a single-column sort.
+ * <b>Note</b>: The sort arrows are defined by the default event handler for
+ * the headerRelease event. If you call the <code>preventDefault()</code> method
+ * in your event handler, the arrows are not drawn.
+ * </p>
+ *
+ * @eventType mx.events.DataGridEvent.HEADER_RELEASE
+ *
+ * @langversion 3.0
+ * @playerversion AIR 3.8
+ * @productversion Flex 4.11
+ */
+[Event(name="sortChange", type="spark.events.MobileGridHeaderEvent")]
+
+/**
+ * The MobileGrid displays a collection of items in a grid of rows and columns, with column headers, optimized for mobile devices.
+ * <p> The MobileGrid component provides the following features: </p>
+ * <ul>
+ * <li> user can swipe through the rows in the datagrid. </li>
+ * <li> supports single selection of a row. </li>
+ * <li> rows can be sorted according to a given column by clicking on the column's header. </li>
+ * <li> cells can be displayed as text in different fonts and formats, as images, or using a custom renderer. </li>
+ * <li> default skin uses dark shades of gray, and is available in different screen densities.</li>
+ * </ul>
+ *
+ * <p> It's important to understand that MobileGrid does not have all the capabilities and flexibility of it's desktop equivalent,
+ * in order to ensure optimal display and scrolling performance on mobile devices. </p>
+ * <p>Typically, the following features are not available in MobileGrid: </p>
+ * <ul>
+ * <li>the list of columns is static and cannot be changed at runtime</li>
+ * <li>multiple selection is not supported </li>
+ * <li>it's not possible to interactively reorder columns </li>
+ * <li>custom cell renderers must be designed with care, preferably in ActionScript, to ensure good display performance </li>
+ * </ul>
+ *
+ * <p>Internally, MobileGrid inherits for Mobile spark.List component rather than any Grid or DataGrid, which means that all cell renderers in a single row are managed
+ * by one single MobileGridRowRenderer that delegates the individual cell renderers to light-weight sub-renderers. </p>
+ * <p> You usually don't access this internal row renderer yourself, and will rather define the individual cell renderers.</p>
+ * <p> This technique ensures optimal display and memory performance, which is critical for mobile devices,, at the price of less flexibility for cell renderers </p>
+ *
+ * @see spark.components.supportClasses.MobileGridColumn
+ *
+ * @langversion 3.0
+ * @playerversion AIR 3.8
+ * @productversion Flex 4.11
+ */
+public class MobileGrid extends List
+{
+
+ [SkinPart(required="true")]
+ public var headerGroup:MobileGridHeader;
+
+ private var _columns: Array;
+ private var _columnsChanged:Boolean = false;
+ private var _sortableColumns:Boolean = true;
+ private var lastSortIndex:int = -1;
+ private var sortIndex:int = -1;
+ private var sortColumn:MobileGridColumn;
+
+ public function MobileGrid()
+ {
+ layout = getDefaultLayout();
+ scrollSnappingMode = ScrollSnappingMode.LEADING_EDGE;
+ setStyle("horizontalScrollPolicy", ScrollPolicy.OFF);
+ useVirtualLayout = true;
+ columns = [];
+ }
+
+ /**
+ * An array of MobileGridColumn objects, one for each column that can be displayed.
+ * <p>Contrary to desktop DataGrid, this property must be set explicitly , or no columns will be displayed.</p>
+ * <p>If you want to change the set of columns,you need to re-assign the new array to the columns property.
+ * Changes to the original array without assigning the property will have no effect.</p>
+ *
+ * @see spark.components.supportClasses.MobileGridColumn
+ *
+ * @langversion 3.0
+ * @playerversion Flash 9
+ * @playerversion AIR 1.1
+ * @productversion Flex 3
+ */
+ [Inspectable(arrayType="spark.components.supportClasses.MobileGridColumn")]
+ public function set columns(value:Array):void
+ {
+ _columns = value;
+ _columnsChanged = true;
+ invalidateProperties();
+ // copy to vector and set indices
+ }
+
+ public function get columns():Array
+ {
+ return _columns.concat();
+ }
+
+ /**
+ * A flag that indicates whether the user can sort the rows
+ * by clicking on a column header cell.
+ * If <code>true</code>, the user can sort the data provider items by
+ * clicking on a column header cell.
+ * If <code>true</code>, individual columns can be made to not respond
+ * to a click on a header by setting the column's <code>sortable</code>
+ * property to <code>false</code>.
+ *
+ * <p>When a user releases the mouse button over a header cell, the DataGrid
+ * control dispatches a <code>headerRelease</code> event if both
+ * this property and the column's sortable property are <code>true</code>.
+ * If no handler calls the <code>preventDefault()</code> method on the event, the
+ * DataGrid sorts using that column's <code>MobileGridColumn.dataField</code> or
+ * <code>MobileGridColumn.labelFunction</code> properties.</p>
+ *
+ * @default true
+ *
+ * @see spark.components.supportClasses.MobileGridColumn#sortable
+ *
+ * @langversion 3.0
+ * @playerversion AIR 3.8
+ * @productversion Flex 4.11
+ */
+ public function get sortableColumns():Boolean
+ {
+ return _sortableColumns && (dataProvider is ICollectionView);
+ }
+
+ public function set sortableColumns(value:Boolean):void
+ {
+ _sortableColumns = value;
+ }
+
+ override protected function commitProperties():void
+ {
+ super.commitProperties();
+ if (_columnsChanged){
+ _columnsChanged = false;
+ for (var i:int = 0; i < _columns.length; i++)
+ {
+ MobileGridColumn(_columns[i]).colNum = i;
+ }
+ initDefaultItemRenderer(_columns);
+ if (headerGroup)
+ headerGroup.columns = _columns;
+ }
+ }
+
+ /* default layout for row item renderers */
+ protected function getDefaultLayout():LayoutBase
+ {
+ var l:VerticalLayout = new VerticalLayout();
+ l.horizontalAlign = "contentJustify";
+ l.gap = 0;
+ return l;
+ }
+
+ protected function initDefaultItemRenderer(pcolumnDescriptors: Array):void
+ {
+ var cf:ClassFactory;
+ cf = new ClassFactory(MobileGridRowRenderer);
+ cf.properties = {
+ partRendererDescriptors: Vector.<IPartRendererDescriptor>(pcolumnDescriptors)
+ };
+ this.itemRenderer = cf;
+ }
+
+ override protected function partAdded(partName:String, instance:Object):void
+ {
+ if (instance === headerGroup)
+ {
+ headerGroup.dataGrid = this;
+ headerGroup.columns = _columns;
+ headerGroup.addEventListener(MobileGridHeaderEvent.SORT_CHANGE, headerGroup_sortChangeHandler);
+ }
+ super.partAdded(partName, instance);
+ }
+
+ override protected function partRemoved(partName:String, instance:Object):void
+ {
+ if (instance === headerGroup)
+ {
+ headerGroup.columns = null;
+ headerGroup.removeEventListener(MobileGridHeaderEvent.SORT_CHANGE, headerGroup_sortChangeHandler);
+ }
+ super.partRemoved(partName, instance);
+ }
+
+
+ private function headerGroup_sortChangeHandler(event:MobileGridHeaderEvent):void
+ {
+ var e:MobileGridHeaderEvent = MobileGridHeaderEvent(event.clone());
+ dispatchEvent( e)
+ if (!e.isDefaultPrevented())
+ {
+ sortByColumn(e.columnIndex);
+ }
+ }
+
+ /* roughly same behavior as mx:DataGrid */
+ private function sortByColumn(index:int):void
+ {
+ var collection:ICollectionView = dataProvider as ICollectionView;
+ var c:MobileGridColumn = _columns[index];
+ if (!c.sortable)
+ return ;
+ var desc:Boolean = c.sortDescending;
+
+ // do the sort if we're allowed to
+ if (collection == null)
+ return;
+
+ var s:ISort = collection.sort;
+ var f:ISortField;
+
+ if (s)
+ {
+ s.compareFunction = null;
+ // analyze the current sort to see what we've been given
+ var sf:Array = s.fields;
+ if (sf)
+ {
+ for (var i:int = 0; i < sf.length; i++)
+ {
+
+ if (sf[i].name == c.dataField)
+ {
+ // we're part of the current sort
+ f = sf[i];
+ // flip the logic so desc is new desired order
+ desc = !f.descending;
+ break;
+ }
+ }
+ }
+ }
+ else
+ s = new Sort();
+
+ if (!f)
+ f = c.sortField;
+
+ c.sortDescending = desc;
+
+ // set the grid's sortIndex
+ lastSortIndex = sortIndex;
+ sortIndex = index;
+ sortColumn = c;
+ f.name = c.dataField;
+ f.descending = desc;
+ s.fields = [f];
+ collection.sort = s;
+ collection.refresh();
+
+ // update header
+ headerGroup.setSort(sortIndex, desc);
+ }
+
+
+
+}
+}
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/b78de5c0/frameworks/projects/experimental_mobile/src/spark/components/itemRenderers/IItemPartRendererBase.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/experimental_mobile/src/spark/components/itemRenderers/IItemPartRendererBase.as b/frameworks/projects/experimental_mobile/src/spark/components/itemRenderers/IItemPartRendererBase.as
new file mode 100644
index 0000000..7194e75
--- /dev/null
+++ b/frameworks/projects/experimental_mobile/src/spark/components/itemRenderers/IItemPartRendererBase.as
@@ -0,0 +1,55 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// 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 spark.components.itemRenderers
+{
+
+import mx.core.IDataRenderer;
+import mx.styles.IStyleClient;
+
+/**
+ * This is the base interface that all mobile cell or other mobile item part renderers must implement.
+ */
+public interface IItemPartRendererBase extends IDataRenderer
+{
+ /** @private
+ * Object to be used for providing styles to the part renderer.
+ * Mobile part items renders being lightweight classes, they usually don't manage styles by themselves.
+ * This property is automatically set
+ */
+ function set styleProvider(value:IStyleClient):void ;
+
+ /**
+ * @private
+ */
+ function set cssStyleName(value:String):void;
+
+ /**
+ * @private
+ */
+ function getPreferredBoundsWidth(postLayoutTransform:Boolean = true):Number;
+
+ /**
+ * @private
+ */
+ function getPreferredBoundsHeight(postLayoutTransform:Boolean = true):Number;
+
+
+
+}
+}
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/b78de5c0/frameworks/projects/experimental_mobile/src/spark/components/itemRenderers/IItemTextPartRenderer.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/experimental_mobile/src/spark/components/itemRenderers/IItemTextPartRenderer.as b/frameworks/projects/experimental_mobile/src/spark/components/itemRenderers/IItemTextPartRenderer.as
new file mode 100644
index 0000000..69c3008
--- /dev/null
+++ b/frameworks/projects/experimental_mobile/src/spark/components/itemRenderers/IItemTextPartRenderer.as
@@ -0,0 +1,35 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// 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 spark.components.itemRenderers
+{
+
+import flash.display.DisplayObjectContainer;
+
+import mx.core.IDataRenderer;
+
+public interface IItemTextPartRenderer extends IItemPartRendererBase
+{
+
+ function set labelField(value:String):void;
+
+ function set labelFunction(value:Function):void;
+
+ function set textAlign(textAlign:String):void;
+}
+}
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/b78de5c0/frameworks/projects/experimental_mobile/src/spark/components/itemRenderers/ItemBitmapPartRenderer.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/experimental_mobile/src/spark/components/itemRenderers/ItemBitmapPartRenderer.as b/frameworks/projects/experimental_mobile/src/spark/components/itemRenderers/ItemBitmapPartRenderer.as
new file mode 100644
index 0000000..b5e7abe
--- /dev/null
+++ b/frameworks/projects/experimental_mobile/src/spark/components/itemRenderers/ItemBitmapPartRenderer.as
@@ -0,0 +1,144 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// 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 spark.components.itemRenderers
+{
+
+import mx.core.BitmapAsset;
+import mx.styles.IStyleClient;
+
+import spark.utils.MultiDPIBitmapSourceExt;
+
+/** Default lightweight class for rendering embedded Bitmaps or Multi-DPI Bitmaps in a MobileGrid cell .
+ * <p> You define the icon to be used in each cell by setting either iconField or iconFunction properties. </p>
+ * */
+public class ItemBitmapPartRenderer extends BitmapAsset implements IItemPartRendererBase
+{
+
+ private var _iconFunction:Function = null;
+ private var _iconField:String = null;
+ protected var _data:Object;
+
+ public function ItemBitmapPartRenderer()
+ {
+ super();
+ }
+
+ /**
+ * The name of the field or property in the DataGrid's dataProvider item that defines the icon to display for this renderer's column.
+ * <p> The fields value must be either an embedded bitmap's class, or or MultiBitmapSourceExt object. </p>
+ * <p> If not set, then iconFunction will be used. </p>
+ * @default null
+ *
+ * @see #iconFunction
+ * @see spark.utils.MultiDPIBitmapSourceExt
+ *
+ */
+ public function get iconField():String
+ {
+ return _iconField;
+ }
+
+ public function set iconField(value:String):void
+ {
+ _iconField = value;
+ }
+
+ /**
+ * An user-provided function that converts a data provider item into an icon to display in each cell for this renderer's column.
+ *
+ * <p>if set, this property is used even if iconField is also set.</p>
+ * <p>The function specified to the <code>iconFunction</code> property
+ * must have the following signature:</p>
+ *
+ * <pre>iconFunction(item:Object):Object</pre>
+ *
+ * <p>The <code>item</code> parameter is the data provider item for an entire row.</p>
+ * <p> The function must return either an embedded bitmap's class, or a MultiBitmapSourceExt object .</p>
+ *
+ * @default null
+ *
+ * @see #iconLabel
+ * @see spark.utils.MultiDPIBitmapSourceExt
+ *
+ */
+ public function get iconFunction():Function
+ {
+ return _iconFunction;
+ }
+
+ public function set iconFunction(value:Function):void
+ {
+ _iconFunction = value;
+ }
+
+ public function set data(value:Object):void
+ {
+ var iconClass:Class;
+ _data = value;
+ var iconSource:Object = _iconFunction != null ? _iconFunction(_data) : _data[_iconField];
+ if (iconSource is MultiDPIBitmapSourceExt)
+ {
+ iconClass = MultiDPIBitmapSourceExt(iconSource).getSource(NaN) as Class;
+ }
+ else
+ {
+ iconClass = iconSource as Class;
+ }
+ if (iconClass != null)
+ {
+ var icon:BitmapAsset = new iconClass();
+ this.bitmapData = icon.bitmapData;
+ }
+ else
+ {
+ this.bitmapData = null;
+ }
+ }
+
+ public function get data():Object
+ {
+ return _data;
+ }
+
+ public function getPreferredBoundsWidth(postLayoutTransform:Boolean = true):Number
+ {
+ return bitmapData.width;
+ }
+
+ public function getPreferredBoundsHeight(postLayoutTransform:Boolean = true):Number
+ {
+ return bitmapData.height;
+ }
+
+ override public function setActualSize(newWidth:Number, newHeight:Number):void
+ {
+ // do nothing, bitmap renderer don't stretch for now
+ }
+
+ public function set styleProvider(value:IStyleClient):void
+ {
+ // do nothing, this renderer does not manages styles for now.
+ }
+
+ public function set cssStyleName(value:String):void
+ {
+ }
+
+}
+}
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/b78de5c0/frameworks/projects/experimental_mobile/src/spark/components/itemRenderers/ItemTextPartRenderer.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/experimental_mobile/src/spark/components/itemRenderers/ItemTextPartRenderer.as b/frameworks/projects/experimental_mobile/src/spark/components/itemRenderers/ItemTextPartRenderer.as
new file mode 100644
index 0000000..afb991e
--- /dev/null
+++ b/frameworks/projects/experimental_mobile/src/spark/components/itemRenderers/ItemTextPartRenderer.as
@@ -0,0 +1,97 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// 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 spark.components.itemRenderers
+{
+
+import mx.core.mx_internal;
+import mx.styles.CSSStyleDeclaration;
+import mx.styles.IStyleClient;
+import mx.styles.StyleManager;
+
+import spark.components.supportClasses.StyleableTextField;
+import spark.utils.UIComponentUtils;
+
+use namespace mx_internal;
+
+/** Default lightweight class for rendering formatted text in MobileGrid cells .
+ * <p> You don't have to use this render explicitly as it will be used by default for MobileGrid text cells. </p>
+ * */
+public class ItemTextPartRenderer extends StyleableTextField implements IItemTextPartRenderer
+{
+
+ private var _labelFunction:Function;
+ private var _labelField:String;
+ private var _data:Object;
+
+ public function ItemTextPartRenderer()
+ {
+ super();
+ editable = false;
+ selectable = false;
+ multiline = true;
+ }
+
+ public function set styleProvider(value:IStyleClient):void
+ {
+ styleName = value;
+ commitStyles();
+ }
+
+ public function set textAlign(value:String):void
+ {
+ setStyle("textAlign", value);
+ }
+
+ public function set cssStyleName(pstyleName:String):void
+ {
+ var css:CSSStyleDeclaration = pstyleName ? StyleManager.getStyleManager(null).getStyleDeclaration("." + pstyleName) : null;
+ // must add to container before working on styles
+ styleDeclaration = css; // for direct style
+ if (css)
+ {
+ leftMargin = css.getStyle("paddingLeft");
+ rightMargin = css.getStyle("paddingRight");
+ // multiline = css.get
+ }
+ }
+
+ public function set data(value:Object):void
+ {
+ _data = value;
+ text = UIComponentUtils.itemToLabel(value, _labelField, _labelFunction);
+ }
+
+ public function get data():Object
+ {
+ return _data;
+ }
+
+ public function set labelField(value:String):void
+ {
+ _labelField = value;
+ }
+
+ public function set labelFunction(value:Function):void
+ {
+ _labelFunction = value;
+ }
+}
+}
+
+
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/b78de5c0/frameworks/projects/experimental_mobile/src/spark/components/supportClasses/IPartRendererDescriptor.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/experimental_mobile/src/spark/components/supportClasses/IPartRendererDescriptor.as b/frameworks/projects/experimental_mobile/src/spark/components/supportClasses/IPartRendererDescriptor.as
new file mode 100644
index 0000000..c81f9f6
--- /dev/null
+++ b/frameworks/projects/experimental_mobile/src/spark/components/supportClasses/IPartRendererDescriptor.as
@@ -0,0 +1,34 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// 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 spark.components.supportClasses
+{
+
+import mx.core.IFactory;
+
+import spark.components.itemRenderers.IItemPartRendererBase;
+
+public interface IPartRendererDescriptor
+{
+ function get scaledWidth():Number;
+
+ function get itemRenderer():IFactory;
+
+ function createPartRenderer():IItemPartRendererBase;
+}
+}
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/b78de5c0/frameworks/projects/experimental_mobile/src/spark/components/supportClasses/ItemRendererBase.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/experimental_mobile/src/spark/components/supportClasses/ItemRendererBase.as b/frameworks/projects/experimental_mobile/src/spark/components/supportClasses/ItemRendererBase.as
new file mode 100644
index 0000000..cf54c6e
--- /dev/null
+++ b/frameworks/projects/experimental_mobile/src/spark/components/supportClasses/ItemRendererBase.as
@@ -0,0 +1,894 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// 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.
+//
+////////////////////////////////////////////////////////////////////////////////
+
+/** @private
+ * monkey-patched from LabelItemRenderer, pruned from label/labelDisplay and change some variable accessibility
+ * Provides default behavior for ListMultiPartItemRenderer
+ * Eventually should become superclass of LabelItemRenderer
+ * */
+
+package spark.components.supportClasses
+{
+import flash.display.GradientType;
+import flash.events.Event;
+import flash.geom.Matrix;
+
+import mx.core.DPIClassification;
+import mx.core.FlexGlobals;
+import mx.core.IDataRenderer;
+import mx.core.IFlexDisplayObject;
+import mx.core.ILayoutElement;
+import mx.core.UIComponent;
+import mx.core.mx_internal;
+import mx.events.FlexEvent;
+
+import spark.components.DataGroup;
+import spark.components.IItemRenderer;
+
+use namespace mx_internal;
+
+//--------------------------------------
+// Events
+//--------------------------------------
+
+/**
+ * Dispatched when the <code>data</code> property changes.
+ *
+ * <p>When you use a component as an item renderer,
+ * the <code>data</code> property contains the data to display.
+ * You can listen for this event and update the component
+ * when the <code>data</code> property changes.</p>
+ *
+ * @eventType mx.events.FlexEvent.DATA_CHANGE
+ *
+ * @langversion 3.0
+ * @playerversion AIR 2.5
+ * @productversion Flex 4.5
+ */
+[Event(name="dataChange", type="mx.events.FlexEvent")]
+
+//--------------------------------------
+// Styles
+//--------------------------------------
+
+[Style(name="paddingLeft", type="Number", format="Length", inherit="no")]
+
+/**
+ * @copy spark.components.supportClasses.GroupBase#style:alternatingItemColors
+ *
+ * @langversion 3.0
+ * @playerversion AIR 2.5
+ * @productversion Flex 4.5
+ */
+[Style(name="alternatingItemColors", type="Array", arrayType="uint", format="Color", inherit="yes", theme="spark, mobile")]
+
+/**
+ * @copy spark.components.supportClasses.GroupBase#style:chromeColor
+ *
+ * @default 0xCCCCCC
+ *
+ * @langversion 3.0
+ * @playerversion AIR 1.5
+ * @productversion Flex 4
+ */
+[Style(name="chromeColor", type="uint", format="Color", inherit="yes", theme="spark, mobile")]
+
+/**
+ * @copy spark.components.supportClasses.GroupBase#style:downColor
+ *
+ * @langversion 3.0
+ * @playerversion AIR 2.5
+ * @productversion Flex 4.5
+ */
+[Style(name="downColor", type="uint", format="Color", inherit="yes", theme="spark, mobile")]
+
+/**
+ * @copy spark.components.supportClasses.GroupBase#style:focusColor
+ *
+ * @langversion 3.0
+ * @playerversion AIR 2.5
+ * @productversion Flex 4.5
+ */
+[Style(name="focusColor", type="uint", format="Color", inherit="yes", theme="spark, mobile")]
+
+/**
+ * Number of pixels between the bottom border and the text component
+ * of the item renderer.
+ *
+ * @default 5
+ *
+ * @langversion 3.0
+ * @playerversion AIR 2.5
+ * @productversion Flex 4.5
+ */
+[Style(name="paddingBottom", type="Number", format="Length", inherit="no")]
+
+/**
+ * Number of pixels between the top border and the text component
+ * of the item renderer.
+ *
+ * @default 5
+ *
+ * @langversion 3.0
+ * @playerversion AIR 2.5
+ * @productversion Flex 4.5
+ */
+[Style(name="paddingTop", type="Number", format="Length", inherit="no")]
+
+/**
+ * @copy spark.components.supportClasses.GroupBase#style:rollOverColor
+ *
+ * @langversion 3.0
+ * @playerversion AIR 2.5
+ * @productversion Flex 4.5
+ */
+[Style(name="rollOverColor", type="uint", format="Color", inherit="yes")]
+
+/**
+ * @copy spark.components.List#style:selectionColor
+ *
+ * @langversion 3.0
+ * @playerversion AIR 2.5
+ * @productversion Flex 4.5
+ */
+[Style(name="selectionColor", type="uint", format="Color", inherit="yes")]
+
+/**
+ * @copy spark.components.supportClasses.GroupBase#style:symbolColor
+ *
+ * @langversion 3.0
+ * @playerversion AIR 2.5
+ * @productversion Flex 4.5
+ */
+[Style(name="symbolColor", type="uint", format="Color", inherit="yes", theme="spark,mobile")]
+
+/**
+ * The vertical alignment of the content when it does not have
+ * a one-to-one aspect ratio.
+ * Possible values are <code>"top"</code>, <code>"center"</code>,
+ * and <code>"bottom"</code>.
+ *
+ * @default "center"
+ *
+ * @langversion 3.0
+ * @playerversion AIR 2.5
+ * @productversion Flex 4.5
+ */
+[Style(name="verticalAlign", type="String", enumeration="bottom,middle,top", inherit="no")]
+
+//--------------------------------------
+// Excluded APIs
+//--------------------------------------
+
+[Exclude(name="focusBlendMode", kind="style")]
+[Exclude(name="focusThickness", kind="style")]
+
+public class ItemRendererBase extends UIComponent implements IDataRenderer, IItemRenderer
+{
+
+ //--------------------------------------------------------------------------
+ //
+ // Constructor
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * Constructor.
+ *
+ * @langversion 3.0
+ * @playerversion AIR 2.5
+ * @productversion Flex 4.5
+ */
+ public function ItemRendererBase()
+ {
+ super();
+
+ switch (applicationDPI)
+ {
+ case DPIClassification.DPI_480:
+ {
+ minHeight = 132;
+ break;
+ }
+ case DPIClassification.DPI_320:
+ {
+ minHeight = 88;
+ break;
+ }
+ case DPIClassification.DPI_240:
+ {
+ minHeight = 66;
+ break;
+ }
+ default:
+ {
+ // default PPI160
+ minHeight = 44;
+ break;
+ }
+ }
+
+ interactionStateDetector = new InteractionStateDetector(this);
+ interactionStateDetector.addEventListener(Event.CHANGE, interactionStateDetector_changeHandler);
+
+ cacheAsBitmap = true;
+ }
+
+ //--------------------------------------------------------------------------
+ //
+ // Private Properties
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * @private
+ * Helper class to help determine when we are in the hovered or down states
+ */
+ protected var interactionStateDetector:InteractionStateDetector;
+
+ /**
+ * @private
+ * Whether or not we're the last element in the list
+ */
+ mx_internal var isLastItem:Boolean = false;
+
+ //--------------------------------------------------------------------------
+ //
+ // Public Properties
+ //
+ //--------------------------------------------------------------------------
+
+ //----------------------------------
+ // data
+ //----------------------------------
+
+ /**
+ * @private
+ */
+ private var _data:Object;
+
+ [Bindable("dataChange")]
+
+ /**
+ * The implementation of the <code>data</code> property
+ * as defined by the IDataRenderer interface.
+ * When set, it stores the value and invalidates the component
+ * to trigger a relayout of the component.
+ *
+ * @see mx.core.IDataRenderer
+ *
+ * @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));
+
+ if (_data) onDataChanged();
+ }
+
+ protected function onDataChanged():void
+ {
+ // set data related properties
+ }
+
+ //----------------------------------
+ // down
+ //----------------------------------
+ /**
+ * @private
+ * storage for the down property
+ */
+ private var _down:Boolean = false;
+
+ /**
+ * Set to <code>true</code> when the user is pressing down on an item renderer.
+ *
+ * @default false
+ *
+ * @langversion 3.0
+ * @playerversion AIR 2.5
+ * @productversion Flex 4.5
+ */
+ protected function get down():Boolean
+ {
+ return _down;
+ }
+
+ /**
+ * @private
+ */
+ protected function set down(value:Boolean):void
+ {
+ if (value == _down)
+ return;
+
+ _down = value;
+ invalidateDisplayList();
+ }
+
+ //----------------------------------
+ // hovered
+ //----------------------------------
+ /**
+ * @private
+ * storage for the hovered property
+ */
+ private var _hovered:Boolean = false;
+
+ /**
+ * Set to <code>true</code> when the user is hovered over the item renderer.
+ *
+ * @default false
+ *
+ * @langversion 3.0
+ * @playerversion AIR 2.5
+ * @productversion Flex 4.5
+ */
+ protected function get hovered():Boolean
+ {
+ return _hovered;
+ }
+
+ /**
+ * @private
+ */
+ protected function set hovered(value:Boolean):void
+ {
+ if (value == _hovered)
+ return;
+
+ _hovered = value;
+ invalidateDisplayList();
+ }
+
+ //----------------------------------
+ // itemIndex
+ //----------------------------------
+
+ /**
+ * @private
+ * storage for the itemIndex property
+ */
+ private var _itemIndex:int;
+
+ /**
+ * @inheritDoc
+ *
+ * @default 0
+ *
+ * @langversion 3.0
+ * @playerversion AIR 2.5
+ * @productversion Flex 4.5
+ */
+ public function get itemIndex():int
+ {
+ return _itemIndex;
+ }
+
+ /**
+ * @private
+ */
+ public function set itemIndex(value:int):void
+ {
+ var wasLastItem:Boolean = isLastItem;
+ var dataGroup:DataGroup = parent as DataGroup;
+ isLastItem = (dataGroup && (value == dataGroup.numElements - 1));
+
+ // if whether or not we are the last item in the last has changed then
+ // invalidate our display. note: even if our new index has not changed,
+ // whether or not we're the last item may have so we perform this check
+ // before the value == _itemIndex check below
+ if (wasLastItem != isLastItem)
+ invalidateDisplayList();
+
+ if (value == _itemIndex)
+ return;
+
+ _itemIndex = value;
+
+ // only invalidateDisplayList() if this causes use to redraw which
+ // is only if alternatingItemColors are defined (and technically also
+ // only if we are not selected or down, etc..., but we'll ignore those
+ // as this will shortcut 95% of the time anyways)
+ if (getStyle("alternatingItemColors") !== undefined)
+ invalidateDisplayList();
+ }
+
+ public function get label():String
+ {
+ return "";
+ }
+
+ public function set label(value:String):void
+ {
+ }
+
+ private var _showsCaret:Boolean = false;
+
+ /**
+ * @inheritDoc
+ *
+ * @default false
+ *
+ * @langversion 3.0
+ * @playerversion AIR 2.5
+ * @productversion Flex 4.5
+ */
+ public function get showsCaret():Boolean
+ {
+ return _showsCaret;
+ }
+
+ /**
+ * @private
+ */
+ public function set showsCaret(value:Boolean):void
+ {
+ if (value == _showsCaret)
+ return;
+
+ _showsCaret = value;
+ invalidateDisplayList();
+ }
+
+ //----------------------------------
+ // selected
+ //----------------------------------
+
+ /**
+ * @private
+ * storage for the selected property
+ */
+ private var _selected:Boolean = false;
+
+ /**
+ * @inheritDoc
+ *
+ * @default false
+ *
+ * @langversion 3.0
+ * @playerversion AIR 2.5
+ * @productversion Flex 4.5
+ */
+ public function get selected():Boolean
+ {
+ return _selected;
+ }
+
+ /**
+ * @private
+ */
+ public function set selected(value:Boolean):void
+ {
+ if (value == _selected)
+ return;
+
+ _selected = value;
+ invalidateDisplayList();
+ }
+
+ //----------------------------------
+ // dragging
+ //----------------------------------
+
+ /**
+ * @private
+ * Storage for the dragging property.
+ */
+ private var _dragging:Boolean = false;
+
+ /**
+ * @inheritDoc
+ *
+ * @langversion 3.0
+ * @playerversion AIR 2.5
+ * @productversion Flex 4.5
+ */
+ public function get dragging():Boolean
+ {
+ return _dragging;
+ }
+
+ /**
+ * @private
+ */
+ public function set dragging(value:Boolean):void
+ {
+ _dragging = value;
+ }
+
+
+ //----------------------------------
+ // authorDensity
+ //----------------------------------
+ /**
+ * Returns the DPI of the application.
+ *
+ * @langversion 3.0
+ * @playerversion AIR 2.5
+ * @productversion Flex 4.5
+ */
+ public function get applicationDPI():Number
+ {
+ return FlexGlobals.topLevelApplication.applicationDPI;
+ }
+
+
+ override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void
+ {
+ // clear the graphics before calling super.updateDisplayList()
+ graphics.clear();
+
+ super.updateDisplayList(unscaledWidth, unscaledHeight);
+
+ drawBackground(unscaledWidth, unscaledHeight);
+
+ layoutContents(unscaledWidth, unscaledHeight);
+ }
+
+ //--------------------------------------------------------------------------
+ //
+ // Methods
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * Renders a background for the item renderer.
+ *
+ * <p>This method, along with <code>layoutContents()</code>, is called
+ * by the <code>updateDisplayList()</code> method.</p>
+ *
+ * <p>This method draws the background and the outline for this item renderer.
+ * It knows how to appropriately handle the selected, down, or caretted states.
+ * However, when <code>alternatingItemColors</code> is set to <code>undefined</code>,
+ * the default background is transparent.
+ * Override this method to change the appearance of the background of
+ * the item renderer.</p>
+ *
+ * @param unscaledWidth Specifies the width of the component, in pixels,
+ * in the component's coordinates, regardless of the value of the
+ * <code>scaleX</code> property of the component.
+ *
+ * @param unscaledHeight Specifies the height of the component, in pixels,
+ * in the component's coordinates, regardless of the value of the
+ * <code>scaleY</code> property of the component.
+ *
+ * @langversion 3.0
+ * @playerversion AIR 2.5
+ * @productversion Flex 4.5
+ */
+ protected function drawBackground(unscaledWidth:Number, unscaledHeight:Number):void
+ {
+ // figure out backgroundColor
+ var backgroundColor:*;
+ var downColor:* = getStyle("downColor");
+ var drawBackground:Boolean = true;
+ var opaqueBackgroundColor:* = undefined;
+
+ if (down && downColor !== undefined)
+ {
+ backgroundColor = downColor;
+ }
+ else if (selected)
+ {
+ backgroundColor = getStyle("selectionColor");
+ }
+ else if (hovered)
+ {
+ backgroundColor = getStyle("rollOverColor");
+ }
+ else if (showsCaret)
+ {
+ backgroundColor = getStyle("selectionColor");
+ }
+ else
+ {
+ var alternatingColors:Array;
+ var alternatingColorsStyle:Object = getStyle("alternatingItemColors");
+
+ if (alternatingColorsStyle)
+ alternatingColors = (alternatingColorsStyle is Array) ? (alternatingColorsStyle as Array) : [alternatingColorsStyle];
+
+ if (alternatingColors && alternatingColors.length > 0)
+ {
+ // translate these colors into uints
+ styleManager.getColorNames(alternatingColors);
+
+ backgroundColor = alternatingColors[itemIndex % alternatingColors.length];
+ }
+ else
+ {
+ // don't draw background if it is the contentBackgroundColor. The
+ // list skin handles the background drawing for us.
+ drawBackground = false;
+ }
+
+ }
+
+ // draw backgroundColor
+ // the reason why we draw it in the case of drawBackground == 0 is for
+ // mouse hit testing purposes
+ graphics.beginFill(backgroundColor, drawBackground ? 1 : 0);
+ graphics.lineStyle();
+ graphics.drawRect(0, 0, unscaledWidth, unscaledHeight);
+ graphics.endFill();
+
+ // Selected and down states have a gradient overlay as well
+ // as different separators colors/alphas
+ if (selected || down)
+ {
+ var colors:Array = [0x000000, 0x000000 ];
+ var alphas:Array = [.2, .1];
+ var ratios:Array = [0, 255];
+ var matrix:Matrix = new Matrix();
+
+ // gradient overlay
+ matrix.createGradientBox(unscaledWidth, unscaledHeight, Math.PI / 2, 0, 0);
+ graphics.beginGradientFill(GradientType.LINEAR, colors, alphas, ratios, matrix);
+ graphics.drawRect(0, 0, unscaledWidth, unscaledHeight);
+ graphics.endFill();
+ }
+ else if (drawBackground)
+ {
+ // If our background is a solid color, use it as the opaqueBackground property
+ // for this renderer. This makes scrolling considerably faster.
+ opaqueBackgroundColor = backgroundColor;
+ }
+
+ // Draw the separator for the item renderer
+ drawBorder(unscaledWidth, unscaledHeight, alternatingColorsStyle != null);
+
+ opaqueBackground = opaqueBackgroundColor;
+ }
+
+ /**
+ * Renders the border for the item renderer.
+ *
+ * <p>This method is called by <code>drawBackground</code> after the
+ * background has been rendered.</p>
+ *
+ * <p>Override this method to change the appearance of the separator or
+ * border of the item renderer.</p>
+ *
+ * @param unscaledWidth Specifies the width of the component, in pixels,
+ * in the component's coordinates, regardless of the value of the
+ * <code>scaleX</code> property of the component.
+ *
+ * @param unscaledHeight Specifies the height of the component, in pixels,
+ * in the component's coordinates, regardless of the value of the
+ * <code>scaleY</code> property of the component.
+ *
+ * @langversion 3.0
+ * @playerversion AIR 3.0
+ * @productversion Flex 4.6
+ */
+ protected function drawBorder(unscaledWidth:Number, unscaledHeight:Number, hasAlternatingColors:Boolean):void
+ {
+ var topSeparatorColor:uint;
+ var topSeparatorAlpha:Number;
+ var bottomSeparatorColor:uint;
+ var bottomSeparatorAlpha:Number;
+
+ var borderWidth:Number = 1;
+ var drawBottomBorder:Boolean = !hasAlternatingColors; // if alternating colors, don't draw shadow
+
+ // separators are a highlight on the top and shadow on the bottom
+ topSeparatorColor = 0xFFFFFF;
+ topSeparatorAlpha = .3;
+ bottomSeparatorColor = 0x000000;
+ bottomSeparatorAlpha = .3;
+
+
+ // draw separators
+ // don't draw top separator for down and selected states
+ if (!(selected || down))
+ {
+ graphics.beginFill(topSeparatorColor, topSeparatorAlpha);
+ graphics.drawRect(0, 0, unscaledWidth, borderWidth);
+ graphics.endFill();
+ }
+
+ if (drawBottomBorder)
+ graphics.beginFill(bottomSeparatorColor, bottomSeparatorAlpha);
+ graphics.drawRect(0, unscaledHeight - (isLastItem ? 0 : borderWidth), unscaledWidth, borderWidth);
+ graphics.endFill();
+
+
+ // add extra separators to the first and last items so that
+ // the list looks correct during the scrolling bounce/pull effect
+ // top
+ if (itemIndex == 0 && drawBottomBorder)
+ {
+ graphics.beginFill(bottomSeparatorColor, bottomSeparatorAlpha);
+ graphics.drawRect(0, -borderWidth, unscaledWidth, borderWidth);
+ graphics.endFill();
+ }
+
+ // bottom
+ if (isLastItem)
+ {
+ // we want to offset the bottom by 1 so that we don't get
+ // a double line at the bottom of the list if there's a
+ // border
+ graphics.beginFill(topSeparatorColor, topSeparatorAlpha);
+ graphics.drawRect(0, unscaledHeight + borderWidth, unscaledWidth, borderWidth);
+ graphics.endFill();
+ }
+ }
+
+ /**
+ * Positions the children for this item renderer.
+ *
+ * <p>This method, along with <code>drawBackground()</code>, is called
+ * by the <code>updateDisplayList()</code> method.</p>
+ *
+ * <p>This method positions the <code>labelDisplay</code> component.
+ * Subclasses should override this to position their children.</p>
+ *
+ * @param unscaledWidth Specifies the width of the component, in pixels,
+ * in the component's coordinates, regardless of the value of the
+ * <code>scaleX</code> property of the component.
+ *
+ * @param unscaledHeight Specifies the height of the component, in pixels,
+ * in the component's coordinates, regardless of the value of the
+ * <code>scaleY</code> property of the component.
+ *
+ * @langversion 3.0
+ * @playerversion AIR 2.5
+ * @productversion Flex 4.5
+ */
+ protected function layoutContents(unscaledWidth:Number, unscaledHeight:Number):void
+ {
+
+ }
+
+ protected function setElementPosition(element:Object, x:Number, y:Number):void
+ {
+ if (element is ILayoutElement)
+ {
+ ILayoutElement(element).setLayoutBoundsPosition(x, y, false);
+ }
+ else if (element is IFlexDisplayObject)
+ {
+ IFlexDisplayObject(element).move(x, y);
+ }
+ else
+ {
+ element.x = x;
+ element.y = y;
+ }
+ }
+
+ /**
+ * @copy spark.skins.mobile.supportClasses.MobileSkin#setElementSize()
+ *
+ * @see #setElementPosition
+ *
+ * @langversion 3.0
+ * @playerversion AIR 2.5
+ * @productversion Flex 4.5
+ */
+ protected function setElementSize(element:Object, width:Number, height:Number):void
+ {
+ if (element is ILayoutElement)
+ {
+ ILayoutElement(element).setLayoutBoundsSize(width, height, false);
+ }
+ else if (element is IFlexDisplayObject)
+ {
+ IFlexDisplayObject(element).setActualSize(width, height);
+ }
+ else
+ {
+ element.width = width;
+ element.height = height;
+ }
+ }
+
+ /**
+ * @copy spark.skins.mobile.supportClasses.MobileSkin#getElementPreferredWidth()
+ *
+ * @see #setElementPosition
+ * @see #setElementSize
+ * @see #getElementPreferredHeight
+ *
+ * @langversion 3.0
+ * @playerversion AIR 2.5
+ * @productversion Flex 4.5
+ */
+ protected function getElementPreferredWidth(element:Object):Number
+ {
+ var result:Number;
+
+ if (element is ILayoutElement)
+ {
+ result = ILayoutElement(element).getPreferredBoundsWidth();
+ }
+ else if (element is IFlexDisplayObject)
+ {
+ result = IFlexDisplayObject(element).measuredWidth;
+ }
+ else
+ {
+ result = element.width;
+ }
+
+ return Math.round(result);
+ }
+
+ /**
+ * @copy spark.skins.mobile.supportClasses.MobileSkin#getElementPreferredHeight()
+ *
+ * @see #setElementPosition
+ * @see #setElementSize
+ * @see #getElementPreferredWidth
+ *
+ * @langversion 3.0
+ * @playerversion AIR 2.5
+ * @productversion Flex 4.5
+ */
+ protected function getElementPreferredHeight(element:Object):Number
+ {
+ var result:Number;
+
+ if (element is ILayoutElement)
+ {
+ result = ILayoutElement(element).getPreferredBoundsHeight();
+ }
+ else if (element is IFlexDisplayObject)
+ {
+ result = IFlexDisplayObject(element).measuredHeight;
+ }
+ else
+ {
+ result = element.height;
+ }
+
+ return Math.ceil(result);
+ }
+
+ //--------------------------------------------------------------------------
+ //
+ // Event Handlers
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * @private
+ */
+ private function interactionStateDetector_changeHandler(event:Event):void
+ {
+ down = (interactionStateDetector.state == InteractionState.DOWN);
+ hovered = (interactionStateDetector.state == InteractionState.OVER);
+ }
+}
+}
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/b78de5c0/frameworks/projects/experimental_mobile/src/spark/components/supportClasses/ListMultiPartItemRendererBase.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/experimental_mobile/src/spark/components/supportClasses/ListMultiPartItemRendererBase.as b/frameworks/projects/experimental_mobile/src/spark/components/supportClasses/ListMultiPartItemRendererBase.as
new file mode 100644
index 0000000..e53a968
--- /dev/null
+++ b/frameworks/projects/experimental_mobile/src/spark/components/supportClasses/ListMultiPartItemRendererBase.as
@@ -0,0 +1,119 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// 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 spark.components.supportClasses
+{
+import flash.display.DisplayObject;
+
+import spark.components.itemRenderers.IItemPartRendererBase;
+
+/** @private
+ * This is the base class for multi-part renderers that manages a vector of part renderers.
+ * This class is responsible for creating and storing the actual renderers from their descriptors
+ * the layout of the part renderers is delegated to a subclass of ListMultiPartLayoutBase;
+ */
+public class ListMultiPartItemRendererBase extends ItemRendererBase
+{
+ private var _partRendererDescriptors:Vector.<IPartRendererDescriptor>;
+ private var _partRenderers:Vector.<IItemPartRendererBase>;
+ private var _partRenderersLayout:ListMultiPartLayoutBase;
+
+ public function ListMultiPartItemRendererBase()
+ {
+ }
+
+ /* set by DataGridMobile Factory */
+ public function set partRendererDescriptors(value:Vector.<IPartRendererDescriptor>):void
+ {
+ _partRendererDescriptors = value;
+ _partRenderers = new Vector.<IItemPartRendererBase>(_partRendererDescriptors.length);
+ }
+
+ public function get partRendererDescriptors():Vector.<IPartRendererDescriptor>
+ {
+ return _partRendererDescriptors;
+ }
+
+ public function get partRenderersLayout():ListMultiPartLayoutBase
+ {
+ return _partRenderersLayout;
+ }
+
+ public function set partRenderersLayout(value:ListMultiPartLayoutBase):void
+ {
+ _partRenderersLayout = value;
+ }
+
+ public function get partRenderers():Vector.<IItemPartRendererBase>
+ {
+ return _partRenderers;
+ }
+
+ override protected function createChildren():void
+ {
+ super.createChildren();
+ var desc:IPartRendererDescriptor;
+ var pr:IItemPartRendererBase;
+ for (var i:int = 0; i < _partRendererDescriptors.length; i++)
+ {
+ desc = _partRendererDescriptors[i];
+ pr = desc.createPartRenderer();
+ if (pr != null)
+ {
+ pr.styleProvider = this;
+ addChild(DisplayObject(pr));
+ _partRenderers[i] = pr;
+ }
+ else
+ {
+ //TODO move to resource bundle
+ throw new Error("MobileGridColumn item renderer must implement spark.components.itemRenderers.IItemPartRendererBase") ;
+ }
+ }
+ }
+
+ override protected function measure():void
+ {
+ super.measure();
+ _partRenderersLayout.measure();
+ }
+
+ /** delegate children layout to its partRendererLayout
+ subclasses can override this method to layout chrome content
+ */
+ override protected function layoutContents(unscaledWidth:Number, unscaledHeight:Number):void
+ {
+ _partRenderersLayout.layoutContents(unscaledWidth, unscaledHeight);
+ }
+
+ override protected function onDataChanged():void
+ {
+ var dpr:IItemPartRendererBase;
+ for (var i:int = 0; i < _partRenderers.length; i++)
+ {
+ dpr = _partRenderers[i];
+ dpr.data = data;
+ }
+ invalidateSize();
+ }
+
+
+
+}
+
+}
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/b78de5c0/frameworks/projects/experimental_mobile/src/spark/components/supportClasses/ListMultiPartLayoutBase.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/experimental_mobile/src/spark/components/supportClasses/ListMultiPartLayoutBase.as b/frameworks/projects/experimental_mobile/src/spark/components/supportClasses/ListMultiPartLayoutBase.as
new file mode 100644
index 0000000..0c8c5ff
--- /dev/null
+++ b/frameworks/projects/experimental_mobile/src/spark/components/supportClasses/ListMultiPartLayoutBase.as
@@ -0,0 +1,141 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// 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 spark.components.supportClasses
+{
+import mx.core.IFlexDisplayObject;
+import mx.core.ILayoutElement;
+
+import spark.components.itemRenderers.IItemPartRendererBase;
+
+/** @private
+ * Abstract base class for laying out part renderers in a multi-part renderer.
+ * Subclasses must override measure() and layoutContents() methods
+ */
+public class ListMultiPartLayoutBase extends Object
+{
+ private var _target:ListMultiPartItemRendererBase;
+
+ public function ListMultiPartLayoutBase(target:ListMultiPartItemRendererBase)
+ {
+ _target = target;
+ }
+
+ public function get target():ListMultiPartItemRendererBase
+ {
+ return _target;
+ }
+
+ protected function get partRendererDescriptors():Vector.<IPartRendererDescriptor>
+ {
+ return target.partRendererDescriptors;
+ }
+
+ protected function get partRenderers():Vector.<IItemPartRendererBase>
+ {
+ return target.partRenderers;
+ }
+
+ public function measure():void
+ {
+
+ }
+
+ /* vertical align middle
+ * give all columns the requested sizes, and the last column the remaining width */
+ public function layoutContents(unscaledWidth:Number, unscaledHeight:Number):void
+ {
+
+ }
+
+ protected function setElementPosition(element:Object, x:Number, y:Number):void
+ {
+ if (element is ILayoutElement)
+ {
+ ILayoutElement(element).setLayoutBoundsPosition(x, y, false);
+ }
+ else if (element is IFlexDisplayObject)
+ {
+ IFlexDisplayObject(element).move(x, y);
+ }
+ else
+ {
+ element.x = x;
+ element.y = y;
+ }
+ }
+
+ protected function setElementSize(element:Object, width:Number, height:Number):void
+ {
+ if (element is ILayoutElement)
+ {
+ ILayoutElement(element).setLayoutBoundsSize(width, height, false);
+ }
+ else if (element is IFlexDisplayObject)
+ {
+ IFlexDisplayObject(element).setActualSize(width, height);
+ }
+ else
+ {
+ element.width = width;
+ element.height = height;
+ }
+ }
+
+ protected function getElementPreferredWidth(element:Object):Number
+ {
+ var result:Number;
+
+ if (element is ILayoutElement)
+ {
+ result = ILayoutElement(element).getPreferredBoundsWidth();
+ }
+ else if (element is IFlexDisplayObject)
+ {
+ result = IFlexDisplayObject(element).measuredWidth;
+ }
+ else
+ {
+ result = element.width;
+ }
+
+ return Math.round(result);
+ }
+
+ protected function getElementPreferredHeight(element:Object):Number
+ {
+ var result:Number;
+
+ if (element is ILayoutElement)
+ {
+ result = ILayoutElement(element).getPreferredBoundsHeight();
+ }
+ else if (element is IFlexDisplayObject)
+ {
+ result = IFlexDisplayObject(element).measuredHeight;
+ }
+ else
+ {
+ result = element.height;
+ }
+
+ return Math.ceil(result);
+ }
+
+}
+}
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/b78de5c0/frameworks/projects/experimental_mobile/src/spark/components/supportClasses/ListMultiPartTabbedLayout.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/experimental_mobile/src/spark/components/supportClasses/ListMultiPartTabbedLayout.as b/frameworks/projects/experimental_mobile/src/spark/components/supportClasses/ListMultiPartTabbedLayout.as
new file mode 100644
index 0000000..f211a8c
--- /dev/null
+++ b/frameworks/projects/experimental_mobile/src/spark/components/supportClasses/ListMultiPartTabbedLayout.as
@@ -0,0 +1,82 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// 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 spark.components.supportClasses
+{
+import spark.components.itemRenderers.IItemPartRendererBase;
+import spark.utils.UIComponentUtils;
+
+/** @private
+ * this class is reponsible for laying out grid cells in a given MobileGrid row.
+ * It will make sure that cell content is aligned according to the column widths.
+ */
+public class ListMultiPartTabbedLayout extends ListMultiPartLayoutBase
+{
+
+ public function ListMultiPartTabbedLayout(target:ListMultiPartItemRendererBase)
+ {
+ super(target);
+ }
+
+ override public function measure():void
+ {
+ super.measure();
+ var totalWidth:Number = 0;
+ for each (var ld:IPartRendererDescriptor in partRendererDescriptors)
+ {
+ totalWidth += ld.scaledWidth;
+ }
+ target.measuredWidth = totalWidth;
+ target.measuredMinWidth = 50;
+ }
+
+ /* vertical align middle
+ * Layout algorithm: give all columns the requested sizes, and the last column the remaining width */
+ override public function layoutContents(unscaledWidth:Number, unscaledHeight:Number):void
+ {
+
+ if (unscaledWidth == 0 && unscaledHeight == 0)
+ return; // not ready
+ var cellPaddingLeft:Number = target.getStyle("paddingLeft");
+ var cellPaddingRight:Number = target.getStyle("paddingRight");
+ var paddingTop:Number = target.getStyle("paddingTop");
+ var paddingBottom:Number = target.getStyle("paddingBottom");
+ var cellHeight:Number = unscaledHeight - paddingTop - paddingBottom;
+
+ var desc:IPartRendererDescriptor;
+ var dpr:IItemPartRendererBase;
+ var remainingWidth:Number = unscaledWidth;
+ var curX:Number = cellPaddingLeft;
+ var curY:Number = paddingTop;
+ var partWidth:Number;
+ var partHeight:Number;
+ var count:int = partRenderers.length - 1;
+ for (var i:int = 0; i <= count; i++)
+ {
+ dpr = partRenderers[i];
+ desc = partRendererDescriptors[i];
+ partHeight = dpr.getPreferredBoundsHeight();
+ partWidth = Math.max(0, i == count ? remainingWidth : desc.scaledWidth - cellPaddingLeft - cellPaddingRight);
+ setElementSize(dpr, partWidth, partHeight);
+ setElementPosition(dpr, curX, curY + UIComponentUtils.offsetForCenter(partHeight, cellHeight));
+ curX += partWidth + cellPaddingRight + cellPaddingLeft;
+ remainingWidth -= desc.scaledWidth;
+ }
+ }
+}
+}
[5/5] git commit: [flex-sdk] [refs/heads/mobileexperimental] -
https://issues.apache.org/jira/browse/FLEX-33777 Dagrid for mobile -
refactoring: more user friendly class names
Posted by ma...@apache.org.
https://issues.apache.org/jira/browse/FLEX-33777 Dagrid for mobile
- refactoring: more user friendly class names
Project: http://git-wip-us.apache.org/repos/asf/flex-sdk/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-sdk/commit/b68e1828
Tree: http://git-wip-us.apache.org/repos/asf/flex-sdk/tree/b68e1828
Diff: http://git-wip-us.apache.org/repos/asf/flex-sdk/diff/b68e1828
Branch: refs/heads/mobileexperimental
Commit: b68e18285862309dd5f2419d13a2e23e415a2c69
Parents: 4482660
Author: mamsellem <ma...@systar.com>
Authored: Wed Oct 2 02:56:01 2013 +0200
Committer: mamsellem <ma...@systar.com>
Committed: Wed Oct 2 02:56:01 2013 +0200
----------------------------------------------------------------------
.../projects/experimental_mobile/manifest.xml | 4 +-
.../itemRenderers/IItemPartRendererBase.as | 64 ---------
.../itemRenderers/IItemTextPartRenderer.as | 39 ------
.../itemRenderers/IMobileGridCellRenderer.as | 64 +++++++++
.../IMobileGridTextCellRenderer.as | 39 ++++++
.../itemRenderers/ItemBitmapPartRenderer.as | 133 -------------------
.../itemRenderers/ItemTextPartRenderer.as | 112 ----------------
.../MobileGridBitmapCellRenderer.as | 133 +++++++++++++++++++
.../itemRenderers/MobileGridTextCellRenderer.as | 112 ++++++++++++++++
.../supportClasses/ListMultiPartColumnLayout.as | 6 +-
.../supportClasses/MobileGridColumn.as | 26 ++--
.../supportClasses/MobileGridRowRenderer.as | 14 +-
12 files changed, 373 insertions(+), 373 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/b68e1828/frameworks/projects/experimental_mobile/manifest.xml
----------------------------------------------------------------------
diff --git a/frameworks/projects/experimental_mobile/manifest.xml b/frameworks/projects/experimental_mobile/manifest.xml
index 9cb9823..e4762f6 100644
--- a/frameworks/projects/experimental_mobile/manifest.xml
+++ b/frameworks/projects/experimental_mobile/manifest.xml
@@ -23,6 +23,6 @@
<componentPackage>
<component class="spark.components.MobileGrid"/>
<component class="spark.components.supportClasses.MobileGridColumn"/>
- <component class="spark.components.itemRenderers.ItemBitmapPartRenderer"/>
- <component class="spark.components.itemRenderers.ItemTextPartRenderer"/>
+ <component class="spark.components.itemRenderers.MobileGridBitmapCellRenderer"/>
+ <component class="spark.components.itemRenderers.MobileGridTextCellRenderer"/>
</componentPackage>
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/b68e1828/frameworks/projects/experimental_mobile/src/spark/components/itemRenderers/IItemPartRendererBase.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/experimental_mobile/src/spark/components/itemRenderers/IItemPartRendererBase.as b/frameworks/projects/experimental_mobile/src/spark/components/itemRenderers/IItemPartRendererBase.as
deleted file mode 100644
index 37ca652..0000000
--- a/frameworks/projects/experimental_mobile/src/spark/components/itemRenderers/IItemPartRendererBase.as
+++ /dev/null
@@ -1,64 +0,0 @@
-////////////////////////////////////////////////////////////////////////////////
-//
-// 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 spark.components.itemRenderers
-{
-
-import mx.core.IDataRenderer;
-import mx.styles.IStyleClient;
-
-/**
- * This is the base interface that all mobile cell or other mobile item part renderers must implement.
- * Contrary to desktop DataGrid control, there is no default base renderer,
- * because mobile renderers must be lightweight, and derive directly for the existing component, (ie. s:Button or s:CheckBox ).
- *
- * @langversion 3.0
- * @playerversion AIR 3.8
- * @productversion Flex 4.11
- */
-public interface IItemPartRendererBase extends IDataRenderer
-{
- /** @private
- * Object to be used for providing styles to the part renderer.
- * Mobile part items renders being lightweight classes, they usually don't manage styles by themselves.
- * This property is automatically set
- */
- function set styleProvider(value:IStyleClient):void ;
-
- function get canSetContentWidth():Boolean;
-
- function get canSetContentHeight():Boolean;
-
- /**
- * @private
- */
- function set cssStyleName(value:String):void;
-
- /**
- * @private
- */
- function getPreferredBoundsWidth(postLayoutTransform:Boolean = true):Number;
-
- /**
- * @private
- */
- function getPreferredBoundsHeight(postLayoutTransform:Boolean = true):Number;
-
-
-}
-}
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/b68e1828/frameworks/projects/experimental_mobile/src/spark/components/itemRenderers/IItemTextPartRenderer.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/experimental_mobile/src/spark/components/itemRenderers/IItemTextPartRenderer.as b/frameworks/projects/experimental_mobile/src/spark/components/itemRenderers/IItemTextPartRenderer.as
deleted file mode 100644
index 90ca694..0000000
--- a/frameworks/projects/experimental_mobile/src/spark/components/itemRenderers/IItemTextPartRenderer.as
+++ /dev/null
@@ -1,39 +0,0 @@
-////////////////////////////////////////////////////////////////////////////////
-//
-// 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 spark.components.itemRenderers
-{
-
-/** Extended interface for renderer that include text
- * @langversion 3.0
- * @playerversion AIR 3.8
- * @productversion Flex 4.11
- */
-
-public interface IItemTextPartRenderer extends IItemPartRendererBase
-{
- /* implement this property so that the renderer can receive the dataField from the renderer's MobileGridColumn*/
- function set labelField(value:String):void;
-
- /* implement this property so that the renderer can receive the labelFunction from the renderers' MobileGridColumn*/
- function set labelFunction(value:Function):void;
-
- /* implement this property so that the renderer can receive the textAlign property from the renderers' MobileGridColumn*/
- function set textAlign(textAlign:String):void;
-}
-}
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/b68e1828/frameworks/projects/experimental_mobile/src/spark/components/itemRenderers/IMobileGridCellRenderer.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/experimental_mobile/src/spark/components/itemRenderers/IMobileGridCellRenderer.as b/frameworks/projects/experimental_mobile/src/spark/components/itemRenderers/IMobileGridCellRenderer.as
new file mode 100644
index 0000000..eb5ddc7
--- /dev/null
+++ b/frameworks/projects/experimental_mobile/src/spark/components/itemRenderers/IMobileGridCellRenderer.as
@@ -0,0 +1,64 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// 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 spark.components.itemRenderers
+{
+
+import mx.core.IDataRenderer;
+import mx.styles.IStyleClient;
+
+/**
+ * This is the base interface that all mobile cell or other mobile item part renderers must implement.
+ * Contrary to desktop DataGrid control, there is no default base renderer,
+ * because mobile renderers must be lightweight, and derive directly for the existing component, (ie. s:Button or s:CheckBox ).
+ *
+ * @langversion 3.0
+ * @playerversion AIR 3.8
+ * @productversion Flex 4.11
+ */
+public interface IMobileGridCellRenderer extends IDataRenderer
+{
+ /** @private
+ * Object to be used for providing styles to the part renderer.
+ * Mobile part items renders being lightweight classes, they usually don't manage styles by themselves.
+ * This property is automatically set
+ */
+ function set styleProvider(value:IStyleClient):void ;
+
+ function get canSetContentWidth():Boolean;
+
+ function get canSetContentHeight():Boolean;
+
+ /**
+ * @private
+ */
+ function set cssStyleName(value:String):void;
+
+ /**
+ * @private
+ */
+ function getPreferredBoundsWidth(postLayoutTransform:Boolean = true):Number;
+
+ /**
+ * @private
+ */
+ function getPreferredBoundsHeight(postLayoutTransform:Boolean = true):Number;
+
+
+}
+}
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/b68e1828/frameworks/projects/experimental_mobile/src/spark/components/itemRenderers/IMobileGridTextCellRenderer.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/experimental_mobile/src/spark/components/itemRenderers/IMobileGridTextCellRenderer.as b/frameworks/projects/experimental_mobile/src/spark/components/itemRenderers/IMobileGridTextCellRenderer.as
new file mode 100644
index 0000000..d26c312
--- /dev/null
+++ b/frameworks/projects/experimental_mobile/src/spark/components/itemRenderers/IMobileGridTextCellRenderer.as
@@ -0,0 +1,39 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// 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 spark.components.itemRenderers
+{
+
+/** Extended interface for renderer that include text
+ * @langversion 3.0
+ * @playerversion AIR 3.8
+ * @productversion Flex 4.11
+ */
+
+public interface IMobileGridTextCellRenderer extends IMobileGridCellRenderer
+{
+ /* implement this property so that the renderer can receive the dataField from the renderer's MobileGridColumn*/
+ function set labelField(value:String):void;
+
+ /* implement this property so that the renderer can receive the labelFunction from the renderers' MobileGridColumn*/
+ function set labelFunction(value:Function):void;
+
+ /* implement this property so that the renderer can receive the textAlign property from the renderers' MobileGridColumn*/
+ function set textAlign(textAlign:String):void;
+}
+}
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/b68e1828/frameworks/projects/experimental_mobile/src/spark/components/itemRenderers/ItemBitmapPartRenderer.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/experimental_mobile/src/spark/components/itemRenderers/ItemBitmapPartRenderer.as b/frameworks/projects/experimental_mobile/src/spark/components/itemRenderers/ItemBitmapPartRenderer.as
deleted file mode 100644
index 29db838..0000000
--- a/frameworks/projects/experimental_mobile/src/spark/components/itemRenderers/ItemBitmapPartRenderer.as
+++ /dev/null
@@ -1,133 +0,0 @@
-////////////////////////////////////////////////////////////////////////////////
-//
-// 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 spark.components.itemRenderers
-{
-
-import mx.core.mx_internal;
-import mx.graphics.BitmapFillMode;
-import mx.styles.IStyleClient;
-
-import spark.primitives.BitmapImage;
-
-use namespace mx_internal;
-
-/** Default lightweight class for rendering embedded Bitmaps or Multi-DPI Bitmaps in a MobileGrid cell .
- *You define the icon to be used in each cell by setting either iconField or iconFunction properties.
- *
- * @langversion 3.0
- * @playerversion AIR 3.8
- * @productversion Flex 4.11
- *
- * */
-public class ItemBitmapPartRenderer extends BitmapImage implements IItemPartRendererBase
-{
-
- private var _iconFunction:Function = null;
- private var _iconField:String = null;
- protected var _data:Object;
-
- public function ItemBitmapPartRenderer()
- {
- super();
- _fillMode = BitmapFillMode.REPEAT; // do not stretch
- }
-
- /**
- * The name of the field or property in the DataGrid's dataProvider item that defines the icon to display for this renderer's column.
- * <p> The field value must be either an embedded bitmap's class, or or MultiBitmapSource object. </p>
- * <p> If not set, then iconFunction will be used. </p>
- * @default null
- *
- * @see #iconFunction
- * @see spark.utils.MultiDPIBitmapSource
- *
- */
- public function get iconField():String
- {
- return _iconField;
- }
-
- public function set iconField(value:String):void
- {
- _iconField = value;
- }
-
- /**
- * An user-provided function that converts a data provider item into an icon to display in each cell for this renderer's column.
- *
- * <p>if set, this property is used even if iconField is also set.</p>
- * <p>The function specified to the <code>iconFunction</code> property
- * must have the following signature:</p>
- *
- * <pre>iconFunction(item:Object):Object</pre>
- *
- * <p>The <code>item</code> parameter is the data provider item for an entire row.</p>
- * <p> The function must return either an embedded bitmap's class, or a MultiBitmapSource object .</p>
- *
- * @default null
- *
- * @see #iconLabel
- * @see spark.utils.MultiDPIBitmapSource
- *
- */
- public function get iconFunction():Function
- {
- return _iconFunction;
- }
-
- public function set iconFunction(value:Function):void
- {
- _iconFunction = value;
- }
-
- public function set data(value:Object):void
- {
- _data = value;
- var iconSource:Object = _iconFunction != null ? _iconFunction(_data) : _data[_iconField];
- this.source = iconSource;
- }
-
- public function get data():Object
- {
- return _data;
- }
-
- public function set styleProvider(value:IStyleClient):void
- {
- // do nothing, this renderer does not manages styles for now.
- }
-
- public function set cssStyleName(value:String):void
- {
-
- }
-
- /* to avoid any scaling artifacts, we do not allow bitmap to be stretcghed */
-
- public function get canSetContentWidth():Boolean
- {
- return false;
- }
-
- public function get canSetContentHeight():Boolean
- {
- return false;
- }
-}
-}
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/b68e1828/frameworks/projects/experimental_mobile/src/spark/components/itemRenderers/ItemTextPartRenderer.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/experimental_mobile/src/spark/components/itemRenderers/ItemTextPartRenderer.as b/frameworks/projects/experimental_mobile/src/spark/components/itemRenderers/ItemTextPartRenderer.as
deleted file mode 100644
index 2ad7118..0000000
--- a/frameworks/projects/experimental_mobile/src/spark/components/itemRenderers/ItemTextPartRenderer.as
+++ /dev/null
@@ -1,112 +0,0 @@
-////////////////////////////////////////////////////////////////////////////////
-//
-// 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 spark.components.itemRenderers
-{
-
-import mx.core.mx_internal;
-import mx.styles.CSSStyleDeclaration;
-import mx.styles.IStyleClient;
-import mx.styles.StyleManager;
-
-import spark.components.supportClasses.StyleableTextField;
-import spark.utils.UIComponentUtils;
-
-use namespace mx_internal;
-
-/** Default lightweight class for rendering formatted text in MobileGrid cells .
- * <p> You don't have to use this render explicitly as it will be used by default for MobileGrid text cells. </p>
- *
- * @langversion 3.0
- * @playerversion AIR 3.8
- * @productversion Flex 4.11
- *
- * */
-public class ItemTextPartRenderer extends StyleableTextField implements IItemTextPartRenderer
-{
-
- private var _labelFunction:Function;
- private var _labelField:String;
- private var _data:Object;
-
- public function ItemTextPartRenderer()
- {
- super();
- editable = false;
- selectable = false;
- multiline = true;
- }
-
- public function set styleProvider(value:IStyleClient):void
- {
- styleName = value;
- commitStyles();
- }
-
- public function set textAlign(value:String):void
- {
- setStyle("textAlign", value);
- }
-
- public function set cssStyleName(pstyleName:String):void
- {
- var css:CSSStyleDeclaration = pstyleName ? StyleManager.getStyleManager(null).getStyleDeclaration("." + pstyleName) : null;
- // must add to container before working on styles
- styleDeclaration = css; // for direct style
- if (css)
- {
- leftMargin = css.getStyle("paddingLeft");
- rightMargin = css.getStyle("paddingRight");
- // multiline = css.get
- }
- }
-
- public function set data(value:Object):void
- {
- _data = value;
- text = UIComponentUtils.itemToLabel(value, _labelField, _labelFunction);
- }
-
- public function get data():Object
- {
- return _data;
- }
-
- public function set labelField(value:String):void
- {
- _labelField = value;
- }
-
- public function set labelFunction(value:Function):void
- {
- _labelFunction = value;
- }
-
- public function get canSetContentWidth():Boolean
- {
- return true;
- }
-
- public function get canSetContentHeight():Boolean
- {
- return false;
- }
-}
-}
-
-
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/b68e1828/frameworks/projects/experimental_mobile/src/spark/components/itemRenderers/MobileGridBitmapCellRenderer.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/experimental_mobile/src/spark/components/itemRenderers/MobileGridBitmapCellRenderer.as b/frameworks/projects/experimental_mobile/src/spark/components/itemRenderers/MobileGridBitmapCellRenderer.as
new file mode 100644
index 0000000..1eed532
--- /dev/null
+++ b/frameworks/projects/experimental_mobile/src/spark/components/itemRenderers/MobileGridBitmapCellRenderer.as
@@ -0,0 +1,133 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// 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 spark.components.itemRenderers
+{
+
+import mx.core.mx_internal;
+import mx.graphics.BitmapFillMode;
+import mx.styles.IStyleClient;
+
+import spark.primitives.BitmapImage;
+
+use namespace mx_internal;
+
+/** Default lightweight class for rendering embedded Bitmaps or Multi-DPI Bitmaps in a MobileGrid cell .
+ *You define the icon to be used in each cell by setting either iconField or iconFunction properties.
+ *
+ * @langversion 3.0
+ * @playerversion AIR 3.8
+ * @productversion Flex 4.11
+ *
+ * */
+public class MobileGridBitmapCellRenderer extends BitmapImage implements IMobileGridCellRenderer
+{
+
+ private var _iconFunction:Function = null;
+ private var _iconField:String = null;
+ protected var _data:Object;
+
+ public function MobileGridBitmapCellRenderer()
+ {
+ super();
+ _fillMode = BitmapFillMode.REPEAT; // do not stretch
+ }
+
+ /**
+ * The name of the field or property in the DataGrid's dataProvider item that defines the icon to display for this renderer's column.
+ * <p> The field value must be either an embedded bitmap's class, or or MultiBitmapSource object. </p>
+ * <p> If not set, then iconFunction will be used. </p>
+ * @default null
+ *
+ * @see #iconFunction
+ * @see spark.utils.MultiDPIBitmapSource
+ *
+ */
+ public function get iconField():String
+ {
+ return _iconField;
+ }
+
+ public function set iconField(value:String):void
+ {
+ _iconField = value;
+ }
+
+ /**
+ * An user-provided function that converts a data provider item into an icon to display in each cell for this renderer's column.
+ *
+ * <p>if set, this property is used even if iconField is also set.</p>
+ * <p>The function specified to the <code>iconFunction</code> property
+ * must have the following signature:</p>
+ *
+ * <pre>iconFunction(item:Object):Object</pre>
+ *
+ * <p>The <code>item</code> parameter is the data provider item for an entire row.</p>
+ * <p> The function must return either an embedded bitmap's class, or a MultiBitmapSource object .</p>
+ *
+ * @default null
+ *
+ * @see #iconLabel
+ * @see spark.utils.MultiDPIBitmapSource
+ *
+ */
+ public function get iconFunction():Function
+ {
+ return _iconFunction;
+ }
+
+ public function set iconFunction(value:Function):void
+ {
+ _iconFunction = value;
+ }
+
+ public function set data(value:Object):void
+ {
+ _data = value;
+ var iconSource:Object = _iconFunction != null ? _iconFunction(_data) : _data[_iconField];
+ this.source = iconSource;
+ }
+
+ public function get data():Object
+ {
+ return _data;
+ }
+
+ public function set styleProvider(value:IStyleClient):void
+ {
+ // do nothing, this renderer does not manages styles for now.
+ }
+
+ public function set cssStyleName(value:String):void
+ {
+
+ }
+
+ /* to avoid any scaling artifacts, we do not allow bitmap to be stretcghed */
+
+ public function get canSetContentWidth():Boolean
+ {
+ return false;
+ }
+
+ public function get canSetContentHeight():Boolean
+ {
+ return false;
+ }
+}
+}
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/b68e1828/frameworks/projects/experimental_mobile/src/spark/components/itemRenderers/MobileGridTextCellRenderer.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/experimental_mobile/src/spark/components/itemRenderers/MobileGridTextCellRenderer.as b/frameworks/projects/experimental_mobile/src/spark/components/itemRenderers/MobileGridTextCellRenderer.as
new file mode 100644
index 0000000..139d9a3
--- /dev/null
+++ b/frameworks/projects/experimental_mobile/src/spark/components/itemRenderers/MobileGridTextCellRenderer.as
@@ -0,0 +1,112 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// 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 spark.components.itemRenderers
+{
+
+import mx.core.mx_internal;
+import mx.styles.CSSStyleDeclaration;
+import mx.styles.IStyleClient;
+import mx.styles.StyleManager;
+
+import spark.components.supportClasses.StyleableTextField;
+import spark.utils.UIComponentUtils;
+
+use namespace mx_internal;
+
+/** Default lightweight class for rendering formatted text in MobileGrid cells .
+ * <p> You don't have to use this render explicitly as it will be used by default for MobileGrid text cells. </p>
+ *
+ * @langversion 3.0
+ * @playerversion AIR 3.8
+ * @productversion Flex 4.11
+ *
+ * */
+public class MobileGridTextCellRenderer extends StyleableTextField implements IMobileGridTextCellRenderer
+{
+
+ private var _labelFunction:Function;
+ private var _labelField:String;
+ private var _data:Object;
+
+ public function MobileGridTextCellRenderer()
+ {
+ super();
+ editable = false;
+ selectable = false;
+ multiline = true;
+ }
+
+ public function set styleProvider(value:IStyleClient):void
+ {
+ styleName = value;
+ commitStyles();
+ }
+
+ public function set textAlign(value:String):void
+ {
+ setStyle("textAlign", value);
+ }
+
+ public function set cssStyleName(pstyleName:String):void
+ {
+ var css:CSSStyleDeclaration = pstyleName ? StyleManager.getStyleManager(null).getStyleDeclaration("." + pstyleName) : null;
+ // must add to container before working on styles
+ styleDeclaration = css; // for direct style
+ if (css)
+ {
+ leftMargin = css.getStyle("paddingLeft");
+ rightMargin = css.getStyle("paddingRight");
+ // multiline = css.get
+ }
+ }
+
+ public function set data(value:Object):void
+ {
+ _data = value;
+ text = UIComponentUtils.itemToLabel(value, _labelField, _labelFunction);
+ }
+
+ public function get data():Object
+ {
+ return _data;
+ }
+
+ public function set labelField(value:String):void
+ {
+ _labelField = value;
+ }
+
+ public function set labelFunction(value:Function):void
+ {
+ _labelFunction = value;
+ }
+
+ public function get canSetContentWidth():Boolean
+ {
+ return true;
+ }
+
+ public function get canSetContentHeight():Boolean
+ {
+ return false;
+ }
+}
+}
+
+
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/b68e1828/frameworks/projects/experimental_mobile/src/spark/components/supportClasses/ListMultiPartColumnLayout.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/experimental_mobile/src/spark/components/supportClasses/ListMultiPartColumnLayout.as b/frameworks/projects/experimental_mobile/src/spark/components/supportClasses/ListMultiPartColumnLayout.as
index 8cd7e27..1da5268 100644
--- a/frameworks/projects/experimental_mobile/src/spark/components/supportClasses/ListMultiPartColumnLayout.as
+++ b/frameworks/projects/experimental_mobile/src/spark/components/supportClasses/ListMultiPartColumnLayout.as
@@ -22,7 +22,7 @@ import mx.core.IFlexDisplayObject;
import mx.core.ILayoutElement;
import mx.core.mx_internal;
-import spark.components.itemRenderers.IItemPartRendererBase;
+import spark.components.itemRenderers.IMobileGridCellRenderer;
import spark.core.IGraphicElement;
import spark.utils.UIComponentUtils;
@@ -56,7 +56,7 @@ public class ListMultiPartColumnLayout extends Object
return target.graphicElementPartRenderers;
}
- protected function get partRenderers():Vector.<IItemPartRendererBase>
+ protected function get partRenderers():Vector.<IMobileGridCellRenderer>
{
return target.partRenderers;
}
@@ -82,7 +82,7 @@ public class ListMultiPartColumnLayout extends Object
var cellHeight:Number = unscaledHeight - paddingTop - paddingBottom;
var desc:MobileGridColumn;
- var dpr:IItemPartRendererBase;
+ var dpr:IMobileGridCellRenderer;
var curX:Number = cellPaddingLeft;
var curY:Number = paddingTop;
var colWidth:Number;
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/b68e1828/frameworks/projects/experimental_mobile/src/spark/components/supportClasses/MobileGridColumn.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/experimental_mobile/src/spark/components/supportClasses/MobileGridColumn.as b/frameworks/projects/experimental_mobile/src/spark/components/supportClasses/MobileGridColumn.as
index b7508f1..95d2d85 100644
--- a/frameworks/projects/experimental_mobile/src/spark/components/supportClasses/MobileGridColumn.as
+++ b/frameworks/projects/experimental_mobile/src/spark/components/supportClasses/MobileGridColumn.as
@@ -28,9 +28,9 @@ import mx.core.mx_internal;
import mx.utils.ObjectUtil;
import spark.collections.SortField;
-import spark.components.itemRenderers.IItemPartRendererBase;
-import spark.components.itemRenderers.IItemTextPartRenderer;
-import spark.components.itemRenderers.ItemTextPartRenderer;
+import spark.components.itemRenderers.IMobileGridCellRenderer;
+import spark.components.itemRenderers.IMobileGridTextCellRenderer;
+import spark.components.itemRenderers.MobileGridTextCellRenderer;
/**
* The MobileGridColumn class defines a column to display in a MobileGrid control.
@@ -150,19 +150,19 @@ public class MobileGridColumn extends EventDispatcher
private var _itemRenderer:IFactory;
/**
- * The class factory for the IItemPartRendererBase class used to
+ * The class factory for the IMobileGridCellRenderer class used to
* render individual grid cells.
*
* <p>The default item renderer is the ItemTextPartRenderer class,
* which displays the data item as text, optimized for mobile. </p>
* <p>You can use also ItemBitmapPartRenderer to display embedded bitmaps, in which case you need to define the iconField or iconFunction </p>
- * <p>You can also create custom item renderers by deriving any subclass of UIComponent (eg. s:Button) and implementing IItemPartRendererBase.
+ * <p>You can also create custom item renderers by deriving any subclass of UIComponent (eg. s:Button) and implementing IMobileGridCellRenderer.
* for performance reasons it's preferable that your renderer be written in ActionScript
*
* @see #dataField
- * @see spark.components.itemRenderers.ItemTextPartRenderer
- * @see spark.components.itemRenderers.ItemBitmapPartRenderer
- * @see spark.components.itemRenderers.IItemPartRendererBase
+ * @see spark.components.itemRenderers.MobileGridTextCellRenderer
+ * @see spark.components.itemRenderers.MobileGridBitmapCellRenderer
+ * @see spark.components.itemRenderers.IMobileGridCellRenderer
*
*/
public function get itemRenderer():IFactory
@@ -172,7 +172,7 @@ public class MobileGridColumn extends EventDispatcher
public function set itemRenderer(value:IFactory):void
{
- _itemRenderer = value ? value : new ClassFactory(ItemTextPartRenderer);
+ _itemRenderer = value ? value : new ClassFactory(MobileGridTextCellRenderer);
}
private var _labelFunction:Function;
@@ -325,15 +325,15 @@ public class MobileGridColumn extends EventDispatcher
return sortField;
}
- public function createPartRenderer():IItemPartRendererBase
+ public function createPartRenderer():IMobileGridCellRenderer
{
- var pr:IItemPartRendererBase = _itemRenderer.newInstance() as IItemPartRendererBase;
+ var pr:IMobileGridCellRenderer = _itemRenderer.newInstance() as IMobileGridCellRenderer;
if (pr)
{
pr.cssStyleName = _styleName;
- if (pr is IItemTextPartRenderer)
+ if (pr is IMobileGridTextCellRenderer)
{
- with (IItemTextPartRenderer(pr))
+ with (IMobileGridTextCellRenderer(pr))
{
labelField = _dataField;
labelFunction = _labelFunction;
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/b68e1828/frameworks/projects/experimental_mobile/src/spark/components/supportClasses/MobileGridRowRenderer.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/experimental_mobile/src/spark/components/supportClasses/MobileGridRowRenderer.as b/frameworks/projects/experimental_mobile/src/spark/components/supportClasses/MobileGridRowRenderer.as
index c3a1446..832997d 100644
--- a/frameworks/projects/experimental_mobile/src/spark/components/supportClasses/MobileGridRowRenderer.as
+++ b/frameworks/projects/experimental_mobile/src/spark/components/supportClasses/MobileGridRowRenderer.as
@@ -20,7 +20,7 @@ package spark.components.supportClasses
{
import flash.display.DisplayObject;
-import spark.components.itemRenderers.IItemPartRendererBase;
+import spark.components.itemRenderers.IMobileGridCellRenderer;
import spark.core.DisplayObjectSharingMode;
import spark.core.IGraphicElement;
import spark.core.IGraphicElementContainer;
@@ -42,7 +42,7 @@ import spark.core.ISharedDisplayObject;
public class MobileGridRowRenderer extends ItemRendererBase implements IGraphicElementContainer, ISharedDisplayObject
{
private var _columns:Vector.<MobileGridColumn>;
- private var _partRenderers:Vector.<IItemPartRendererBase>;
+ private var _partRenderers:Vector.<IMobileGridCellRenderer>;
private var _graphicElementPartRenderers:Vector.<IGraphicElement>;
private var _partRenderersLayout:ListMultiPartColumnLayout;
@@ -63,7 +63,7 @@ public class MobileGridRowRenderer extends ItemRendererBase implements IGraphicE
public function set columns(value:Vector.<MobileGridColumn>):void
{
_columns = value;
- _partRenderers = new Vector.<IItemPartRendererBase>(_columns.length, true);
+ _partRenderers = new Vector.<IMobileGridCellRenderer>(_columns.length, true);
_graphicElementPartRenderers = new Vector.<IGraphicElement>();
}
@@ -72,7 +72,7 @@ public class MobileGridRowRenderer extends ItemRendererBase implements IGraphicE
return _columns;
}
- public function get partRenderers():Vector.<IItemPartRendererBase>
+ public function get partRenderers():Vector.<IMobileGridCellRenderer>
{
return _partRenderers;
}
@@ -86,7 +86,7 @@ public class MobileGridRowRenderer extends ItemRendererBase implements IGraphicE
{
super.createChildren();
var desc:MobileGridColumn;
- var pr:IItemPartRendererBase;
+ var pr:IMobileGridCellRenderer;
var ge:IGraphicElement;
for (var i:int = 0; i < _columns.length; i++)
{
@@ -115,7 +115,7 @@ public class MobileGridRowRenderer extends ItemRendererBase implements IGraphicE
else
{
//TODO move to resource bundle
- throw new Error("MobileGridColumn item renderer must implement spark.components.itemRenderers.IItemPartRendererBase");
+ throw new Error("MobileGridColumn item renderer must implement spark.components.itemRenderers.IMobileGridCellRenderer");
}
}
}
@@ -136,7 +136,7 @@ public class MobileGridRowRenderer extends ItemRendererBase implements IGraphicE
override protected function onDataChanged():void
{
- var dpr:IItemPartRendererBase;
+ var dpr:IMobileGridCellRenderer;
for (var i:int = 0; i < _partRenderers.length; i++)
{
dpr = _partRenderers[i];