Changes to DataGrid component and beads. Adding DataGridPercentageLayout so 
column widths can be specified as percentages.


Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/9bd1e9ff
Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/9bd1e9ff
Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/9bd1e9ff

Branch: refs/heads/refactor-sprite
Commit: 9bd1e9ff9fe90335b60872fb2363194e9d1513f3
Parents: dcc5ff3
Author: Peter Ent <p...@apache.org>
Authored: Tue Oct 11 11:06:06 2016 -0400
Committer: Peter Ent <p...@apache.org>
Committed: Tue Oct 11 11:06:06 2016 -0400

----------------------------------------------------------------------
 .../projects/HTML/src/main/flex/HTMLClasses.as  |   4 +
 .../org/apache/flex/html/beads/DataGridView.as  | 107 ++++-----
 .../flex/html/beads/layouts/DataGridLayout.as   | 116 +++++++---
 .../beads/layouts/DataGridPercentageLayout.as   | 224 +++++++++++++++++++
 .../flex/html/beads/layouts/IDataGridLayout.as  |  52 +++++
 .../HTML/src/main/resources/basic-manifest.xml  |   2 +
 .../HTML/src/main/resources/defaults.css        |   1 +
 7 files changed, 407 insertions(+), 99 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/9bd1e9ff/frameworks/projects/HTML/src/main/flex/HTMLClasses.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/HTML/src/main/flex/HTMLClasses.as 
b/frameworks/projects/HTML/src/main/flex/HTMLClasses.as
index e5310a0..1271417 100644
--- a/frameworks/projects/HTML/src/main/flex/HTMLClasses.as
+++ b/frameworks/projects/HTML/src/main/flex/HTMLClasses.as
@@ -136,6 +136,9 @@ internal class HTMLClasses
     import org.apache.flex.html.beads.layouts.VerticalLayout; VerticalLayout;
        import org.apache.flex.html.beads.layouts.HorizontalLayout; 
HorizontalLayout;
     import org.apache.flex.html.beads.layouts.BasicLayout; BasicLayout;
+       import 
org.apache.flex.html.beads.layouts.OneFlexibleChildHorizontalLayout; 
OneFlexibleChildHorizontalLayout;
+       import 
org.apache.flex.html.beads.layouts.OneFlexibleChildVerticalLayout; 
OneFlexibleChildVerticalLayout;
+       
        COMPILE::SWF
        {
                import org.apache.flex.html.beads.layouts.HScrollBarLayout; 
HScrollBarLayout;
@@ -155,6 +158,7 @@ internal class HTMLClasses
        import org.apache.flex.html.DataGridButtonBar; DataGridButtonBar;
        import org.apache.flex.html.beads.DataGridColumnView; 
DataGridColumnView;
        import org.apache.flex.html.beads.DataGridView; DataGridView;
+       import org.apache.flex.html.beads.layouts.DataGridLayout; 
DataGridLayout;
        import org.apache.flex.html.beads.DateChooserView; DateChooserView;
        import org.apache.flex.html.beads.DateFieldView; DateFieldView;
        import org.apache.flex.html.beads.DecrementButtonView; 
DecrementButtonView;

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/9bd1e9ff/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/DataGridView.as
----------------------------------------------------------------------
diff --git 
a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/DataGridView.as
 
b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/DataGridView.as
index be81545..8393057 100644
--- 
a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/DataGridView.as
+++ 
b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/DataGridView.as
@@ -20,6 +20,7 @@ package org.apache.flex.html.beads
 {
        import org.apache.flex.core.IBead;
        import org.apache.flex.core.IBeadModel;
+       import org.apache.flex.core.IBeadLayout;
        import org.apache.flex.core.IBeadView;
        import org.apache.flex.core.IDataGridModel;
        import org.apache.flex.core.ISelectableItemRenderer;
@@ -34,6 +35,8 @@ package org.apache.flex.html.beads
        import org.apache.flex.html.Container;
        import org.apache.flex.html.beads.layouts.ButtonBarLayout;
        import org.apache.flex.html.beads.layouts.VerticalLayout;
+       import org.apache.flex.html.beads.layouts.HorizontalLayout;
+       import org.apache.flex.html.beads.layouts.IDataGridLayout;
        import org.apache.flex.html.beads.models.ArraySelectionModel;
        import org.apache.flex.html.beads.models.DataGridPresentationModel;
        import org.apache.flex.html.supportClasses.DataGridColumn;
@@ -74,10 +77,19 @@ package org.apache.flex.html.beads
                /**
                 * An array of List objects the comprise the columns of the 
DataGrid.
                 */
-               public function get getColumnLists():Array
+               public function get columnLists():Array
                {
                        return _lists;
                }
+               
+               /**
+                * The area used to hold the columns
+                *
+                */
+               public function get listArea():Container
+               {
+                       return _listArea;
+               }
 
                /**
                 * @private
@@ -86,6 +98,14 @@ package org.apache.flex.html.beads
                {
                        return _strand as IUIBase;
                }
+               
+               /**
+                * Returns the component used as the header for the DataGrid.
+                */
+               public function get header():IUIBase
+               {
+                       return _header;
+               }
 
                /**
                 *  @copy org.apache.flex.core.IBead#strand
@@ -100,19 +120,25 @@ package org.apache.flex.html.beads
                        _strand = value;
 
                        var host:UIBase = value as UIBase;
-                       host.addEventListener("widthChanged", 
handleSizeChanges);
-                       host.addEventListener("heightChanged", 
handleSizeChanges);
 
                        _header = new DataGridButtonBar();
                        _header.id = "dataGridHeader";
 
                        var scrollPort:ScrollingViewport = new 
ScrollingViewport();
-//                     scrollPort.showsHorizontalScrollBar = false;
 
                        _listArea = new Container();
                        _listArea.id = "dataGridListArea";
                        _listArea.className = "DataGridListArea";
                        _listArea.addBead(scrollPort);
+                       
+                       if (_strand.getBeadByType(IBeadLayout) == null) {
+                               var c:Class = 
ValuesManager.valuesImpl.getValue(host, "iBeadLayout");
+                               if (c)
+                               {
+                                       var layout:IBeadLayout = new c() as 
IBeadLayout;
+                                       _strand.addBead(layout);
+                               }
+                       }
 
                        finishSetup(null);
                }
@@ -135,19 +161,13 @@ package org.apache.flex.html.beads
                        
IEventDispatcher(sharedModel).addEventListener("dataProviderChanged",handleDataProviderChanged);
 
                        var columnLabels:Array = new Array();
-                       var buttonWidths:Array = new Array();
 
                        for(var i:int=0; i < sharedModel.columns.length; i++) {
                                var dgc:DataGridColumn = sharedModel.columns[i] 
as DataGridColumn;
                                columnLabels.push(dgc.label);
-                               if (!isNaN(dgc.columnWidth)) 
buttonWidths.push(dgc.columnWidth);
                        }
 
                        var bblayout:ButtonBarLayout = new ButtonBarLayout();
-                       if (buttonWidths.length == sharedModel.columns.length) {
-                               bblayout.buttonWidths = buttonWidths;
-                       }
-
                        var buttonBarModel:ArraySelectionModel = new 
ArraySelectionModel();
                        buttonBarModel.dataProvider = columnLabels;
 
@@ -158,62 +178,19 @@ package org.apache.flex.html.beads
 
                        host.addElement(_listArea);
 
-                       // do we know what the size is? If not, wait to be sized
-
-                       if (host.isHeightSizedToContent() || 
host.isWidthSizedToContent()) {
-                               host.addEventListener("sizeChanged", 
handleSizeChanges);
-                       }
-
-                               // else size now
-                       else {
-                               handleDataProviderChanged(event);
-                       }
+                       handleDataProviderChanged(event);
                }
 
                /**
                 * @private
                 */
                private function handleSizeChanges(event:Event):void
-               {
-                       var useWidth:Number = _listArea.width;
-                       var useHeight:Number = _listArea.height;
-
-                       if (host.width > 0) {
-                               useWidth = host.width;
-                       }
-
-                       _header.x = 0;
-                       _header.y = 0;
-                       _header.width = useWidth;
-                       _header.height = 25;
-
-                       if (host.height > 0) {
-                               useHeight = host.height - _header.height;
-                       }
-
-                       _listArea.x = 0;
-                       _listArea.y = 26;
-                       _listArea.width = useWidth;
-                       _listArea.height = useHeight;
-
-                       var sharedModel:IDataGridModel = 
_strand.getBeadByType(IBeadModel) as IDataGridModel;
-
-                       if (_lists != null && _lists.length > 0) {
-                               var xpos:Number = 0;
-                               var listWidth:Number = host.width / 
_lists.length;
-                               for (var i:int=0; i < _lists.length; i++) {
-                                       var list:DataGridColumnList = _lists[i] 
as DataGridColumnList;
-                                       list.x = xpos;
-                                       list.y = 0;
-
-                                       var dataGridColumn:DataGridColumn = 
sharedModel.columns[i] as DataGridColumn;
-                                       var colWidth:Number = 
dataGridColumn.columnWidth;
-                                       if (!isNaN(colWidth)) list.width = 
colWidth;
-                                       else list.width = listWidth;
-
-                                       xpos += list.width;
-                               }
-                       }
+               {       
+                       var layoutBead:IDataGridLayout = 
_strand.getBeadByType(IBeadLayout) as IDataGridLayout;
+                       layoutBead.header = _header;
+                       layoutBead.columns = _lists;
+                       layoutBead.listArea = _listArea;
+                       layoutBead.layout();
                }
 
                /**
@@ -234,7 +211,7 @@ package org.apache.flex.html.beads
                                listModel.dataProvider = 
sharedModel.dataProvider;
                        }
 
-                       handleSizeChanges(event);
+                       host.dispatchEvent(new Event("layoutNeeded"));
                }
 
                /**
@@ -253,7 +230,7 @@ package org.apache.flex.html.beads
                                }
                        }
 
-                       IEventDispatcher(_strand).dispatchEvent(new 
Event('change'));
+                       host.dispatchEvent(new Event('change'));
                }
 
                /**
@@ -278,15 +255,11 @@ package org.apache.flex.html.beads
                                
list.addEventListener('change',handleColumnListChange);
                                list.addBead(presentationModel);
 
-                               var colWidth:Number = 
dataGridColumn.columnWidth;
-                               if (!isNaN(colWidth)) list.width = colWidth;
-                               else list.width = listWidth;
-
                                _listArea.addElement(list);
                                _lists.push(list);
                        }
 
-                       _listArea.dispatchEvent(new Event("layoutNeeded"));
+                       host.dispatchEvent(new Event("layoutNeeded"));
                }
        }
 }

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/9bd1e9ff/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/layouts/DataGridLayout.as
----------------------------------------------------------------------
diff --git 
a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/layouts/DataGridLayout.as
 
b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/layouts/DataGridLayout.as
index 1cfba0b..1d22956 100644
--- 
a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/layouts/DataGridLayout.as
+++ 
b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/layouts/DataGridLayout.as
@@ -19,6 +19,8 @@
 package org.apache.flex.html.beads.layouts
 {      
        import org.apache.flex.core.IBeadLayout;
+       import org.apache.flex.core.IBeadModel;
+       import org.apache.flex.core.IBeadView;
        import org.apache.flex.core.IDataGridModel;
        import org.apache.flex.core.IStrand;
        import org.apache.flex.core.IUIBase;
@@ -26,6 +28,9 @@ package org.apache.flex.html.beads.layouts
        import org.apache.flex.events.Event;
        import org.apache.flex.events.IEventDispatcher;
        import org.apache.flex.html.ButtonBar;
+       import org.apache.flex.html.beads.DataGridView;
+       import org.apache.flex.html.beads.layouts.BasicLayout;
+       import org.apache.flex.html.supportClasses.DataGridColumnList;
        import org.apache.flex.html.supportClasses.DataGridColumn;
        
        /**
@@ -38,7 +43,7 @@ package org.apache.flex.html.beads.layouts
         *  @playerversion AIR 2.6
         *  @productversion FlexJS 0.0
         */
-       public class DataGridLayout implements IBeadLayout
+       public class DataGridLayout implements IDataGridLayout
        {
                /**
                 *  constructor
@@ -65,6 +70,17 @@ package org.apache.flex.html.beads.layouts
                public function set strand(value:IStrand):void
                {
                        _strand = value;
+                       
+                       var host:UIBase = _strand as UIBase;
+                       host.addEventListener("widthChanged", 
handleSizeChanges);
+                       host.addEventListener("heightChanged", 
handleSizeChanges);
+                       host.addEventListener("sizeChanged", handleSizeChanges);
+                       host.addEventListener("layoutNeeded", 
handleSizeChanges);
+                       
+                       var view:DataGridView = host.view as DataGridView;
+                       header = view.header;
+                       listArea = view.listArea;
+                       listArea.addBead(new BasicLayout());
                }
                
                private var _header:UIBase;
@@ -105,52 +121,88 @@ package org.apache.flex.html.beads.layouts
                        _columns = value;
                }
                
+               private var _listArea:IUIBase;
+               
+               public function get listArea():IUIBase
+               {
+                       return _listArea;
+               }
+               public function set listArea(value:IUIBase):void
+               {
+                       _listArea = value;
+               }
+               
         /**
          * @copy org.apache.flex.core.IBeadLayout#layout
          */
                public function layout():Boolean
                {                                               
-                       var sw:Number = UIBase(_strand).width;
-                       var sh:Number = UIBase(_strand).height;
-                       
-                       var columnHeight:Number = Math.floor(sh - 
header.height);
-                       var columnWidth:Number  = Math.floor(sw / 
columns.length);
-                       
-                       var xpos:Number = 0;
-                       var ypos:Number = Math.floor(header.height);
-                       
-                       // TODO: change the layout so that the model's 
DataGridColumn.columnWidth
-                       // isn't used blindly, but is considered in the overall 
width. In other words,
-                       // right now the width could exceed the strand's width.
-                       var model:IDataGridModel = 
_strand.getBeadByType(IDataGridModel) as IDataGridModel;
+                       if (columns == null || columns.length == 0) {
+                               return false;
+                       }
+                       var host:UIBase = _strand as UIBase;
                        
-                       var buttonWidths:Array = new Array();
+                       var useWidth:Number = host.width;
+                       var useHeight:Number = host.height;
+
+                       if (host.height > 0) {
+                               useHeight = host.height - _header.height;
+                       }
                        
-                       for(var i:int=0; i < columns.length; i++) {
-                               var column:UIBase = columns[i] as UIBase;
-                               column.x = xpos;
-                               column.y = ypos;
-                               column.height = columnHeight;
-                               
-                               var dgc:DataGridColumn = model.columns[i];
-                               if (!isNaN(dgc.columnWidth)) column.width = 
dgc.columnWidth;
-                               else column.width  = columnWidth;
-                               
-                               xpos += column.width;
-                               
-                               buttonWidths.push(column.width);
+                       var thisisnothing:Number = -1234;
+
+                       _listArea.x = 0;
+                       _listArea.y = 26;
+                       _listArea.width = useWidth;
+                       _listArea.height = useHeight;
+
+                       var sharedModel:IDataGridModel = host.model as 
IDataGridModel;
+                       var buttonWidths:Array = [];
+
+                       if (_columns != null && _columns.length > 0) {
+                               var xpos:Number = 0;
+                               var listWidth:Number = host.width / 
_columns.length;
+                               for (var i:int=0; i < _columns.length; i++) {
+                                       var list:DataGridColumnList = 
_columns[i] as DataGridColumnList;
+                                       list.x = xpos;
+                                       list.y = 0;
+
+                                       var dataGridColumn:DataGridColumn = 
sharedModel.columns[i] as DataGridColumn;
+                                       var colWidth:Number = 
dataGridColumn.columnWidth;
+                                       if (!isNaN(colWidth)) list.width = 
colWidth;
+                                       else list.width = listWidth;
+
+                                       xpos += list.width;
+                                       
+                                       buttonWidths.push(list.width);
+                               }
                        }
                        
                        var bar:ButtonBar = header as ButtonBar;
                        var barLayout:ButtonBarLayout = 
bar.getBeadByType(ButtonBarLayout) as ButtonBarLayout;
                        barLayout.buttonWidths = buttonWidths;
+                       bar.dispatchEvent(new Event("layoutNeeded"));
                        
-                       header.x = 0;
-                       header.y = 0;
-                       header.width = sw;
-                       header.dispatchEvent(new Event("layoutNeeded"));
+                       _header.x = 0;
+                       _header.y = 0;
+                       _header.width = useWidth;
+                       _header.height = 25;
+                       _header.dispatchEvent(new Event("layoutNeeded"));
                        
                        return true;
                }
+               
+               /**
+                * @private
+                */
+               private function handleSizeChanges(event:Event):void
+               {
+                       var view:DataGridView = UIBase(_strand).view as 
DataGridView;
+                       if (view == null) return;
+                       
+                       columns = view.columnLists;
+                       
+                       layout();
+               }
        }
 }

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/9bd1e9ff/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/layouts/DataGridPercentageLayout.as
----------------------------------------------------------------------
diff --git 
a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/layouts/DataGridPercentageLayout.as
 
b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/layouts/DataGridPercentageLayout.as
new file mode 100644
index 0000000..7459a24
--- /dev/null
+++ 
b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/layouts/DataGridPercentageLayout.as
@@ -0,0 +1,224 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  Licensed to the Apache Software Foundation (ASF) under one or more
+//  contributor license agreements.  See the NOTICE file distributed with
+//  this work for additional information regarding copyright ownership.
+//  The ASF licenses this file to You under the Apache License, Version 2.0
+//  (the "License"); you may not use this file except in compliance with
+//  the License.  You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.html.beads.layouts
+{      
+       import org.apache.flex.core.IBead;
+       import org.apache.flex.core.IBeadLayout;
+       import org.apache.flex.core.IBeadView;
+       import org.apache.flex.core.IDataGridModel;
+       import org.apache.flex.core.IStrand;
+       import org.apache.flex.core.IUIBase;
+       import org.apache.flex.core.UIBase;
+       import org.apache.flex.events.Event;
+       import org.apache.flex.events.IEventDispatcher;
+       import org.apache.flex.html.ButtonBar;
+       import org.apache.flex.html.beads.DataGridView;
+       import org.apache.flex.html.beads.layouts.HorizontalLayout;
+       import org.apache.flex.html.supportClasses.DataGridColumn;
+       
+       /**
+        * DataGridPercentageLayout is a class that handles the size and 
positioning of the
+        * elements of a DataGrid. This includes the ButtonBar used for the 
column
+        * headers and the Lists that are the columns. The columns are sized on 
their
+        * percentage of the width of the DataGrid space.
+        *  
+        *  @langversion 3.0
+        *  @playerversion Flash 10.2
+        *  @playerversion AIR 2.6
+        *  @productversion FlexJS 0.0
+        */
+       public class DataGridPercentageLayout implements IDataGridLayout
+       {
+               /**
+                *  constructor
+                *  
+                *  @langversion 3.0
+                *  @playerversion Flash 10.2
+                *  @playerversion AIR 2.6
+                *  @productversion FlexJS 0.0
+                */
+               public function DataGridPercentageLayout()
+               {
+               }
+               
+               private var _strand:IStrand;
+               
+               /**
+                *  @copy org.apache.flex.core.IBead#strand
+                *  
+                *  @langversion 3.0
+                *  @playerversion Flash 10.2
+                *  @playerversion AIR 2.6
+                *  @productversion FlexJS 0.0
+                */
+               public function set strand(value:IStrand):void
+               {
+                       _strand = value;
+                       
+                       var host:UIBase = value as UIBase;
+                       
+                       var view:DataGridView = host.view as DataGridView;
+                       
+                       header = view.header;
+                       listArea = view.listArea;
+                       
+                       var anylayout:IBead = 
listArea.getBeadByType(IBeadLayout);
+                       if (anylayout != null) {
+                               listArea.removeBead(anylayout);
+                       }
+                       listArea.addBead(new HorizontalLayout());
+                       
+                       host.addEventListener("widthChanged", 
handleSizeChanges);
+                       host.addEventListener("heightChanged", 
handleSizeChanges);
+                       host.addEventListener("sizeChanged", handleSizeChanges);
+                       host.addEventListener("layoutNeeded", 
handleSizeChanges);
+               }
+               
+               private var _header:UIBase;
+               
+               /**
+                * The element that is the header for the DataGrid
+                *  
+                *  @langversion 3.0
+                *  @playerversion Flash 10.2
+                *  @playerversion AIR 2.6
+                *  @productversion FlexJS 0.0
+                */
+               public function get header():IUIBase
+               {
+                       return _header;
+               }
+               public function set header(value:IUIBase):void
+               {
+                       _header = UIBase(value);
+               }
+               
+               private var _columns:Array;
+               
+               /**
+                * The array of column elements.
+                *  
+                *  @langversion 3.0
+                *  @playerversion Flash 10.2
+                *  @playerversion AIR 2.6
+                *  @productversion FlexJS 0.0
+                */
+               public function get columns():Array
+               {
+                       return _columns;
+               }
+               public function set columns(value:Array):void
+               {
+                       _columns = value;
+               }
+               
+               private var _listArea:IUIBase;
+               
+               public function get listArea():IUIBase
+               {
+                       return _listArea;
+               }
+               public function set listArea(value:IUIBase):void
+               {
+                       _listArea = value;
+               }
+               
+        /**
+         * @copy org.apache.flex.core.IBeadLayout#layout
+         */
+               public function layout():Boolean
+               {                       
+                       if (columns == null || columns.length == 0) {
+                               return false;
+                       }
+                       
+                       var host:UIBase = _strand as UIBase;
+                       
+                       var sw:Number = host.width;
+                       var sh:Number = host.height;
+                       
+                       var columnHeight:Number = Math.floor(sh - 
header.height);
+                       var columnWidth:Number  = Math.floor(sw / 
columns.length);
+                       
+                       var xpos:Number = 0;
+                       var ypos:Number = 26;
+                       
+                       _header.x = 0;
+                       _header.y = 0;
+                       _header.width = sw;
+                       _header.height = 25;
+                       
+                       if (sh > 0) {
+                               sh = sh - _header.height;
+                       }
+                       
+                       // TODO: change the layout so that the model's 
DataGridColumn.columnWidth
+                       // isn't used blindly, but is considered in the overall 
width. In other words,
+                       // right now the width could exceed the strand's width.
+                       var model:IDataGridModel = host.model as IDataGridModel;
+                       
+                       var buttonWidths:Array = new Array();
+                                               
+                       for(var i:int=0; i < columns.length; i++) {
+                               var column:UIBase = columns[i] as UIBase;
+                               column.percentHeight = 100;
+
+                               var dgc:DataGridColumn = model.columns[i];
+                               if (!isNaN(dgc.columnWidth)) {
+                                       column.percentWidth = dgc.columnWidth;
+                                       columnWidth = sw * 
(dgc.columnWidth/100.0);
+                               }
+                               else column.explicitWidth = columnWidth;
+                               
+                               buttonWidths.push(columnWidth);
+                       }
+                       
+                       _listArea.x = 0;
+                       _listArea.y = 26;
+                       _listArea.width = sw;
+                       _listArea.height = sh;
+                       _listArea.dispatchEvent(new Event("layoutNeeded"));
+                       
+                       var bar:ButtonBar = header as ButtonBar;
+                       var barLayout:ButtonBarLayout = 
bar.getBeadByType(ButtonBarLayout) as ButtonBarLayout;
+                       barLayout.buttonWidths = buttonWidths;
+                       
+                       _header.x = 0;
+                       _header.y = 0;
+                       _header.width = sw;
+                       _header.height = 25;
+                       _header.dispatchEvent(new Event("layoutNeeded"));
+                       
+                       return true;
+               }
+               
+               /**
+                * @private
+                */
+               private function handleSizeChanges(event:Event):void
+               {
+                       var view:DataGridView = UIBase(_strand).view as 
DataGridView;
+                       if (view == null) return;
+                       
+                       columns = view.columnLists;
+                       
+                       layout();
+               }
+       }
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/9bd1e9ff/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/layouts/IDataGridLayout.as
----------------------------------------------------------------------
diff --git 
a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/layouts/IDataGridLayout.as
 
b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/layouts/IDataGridLayout.as
new file mode 100644
index 0000000..2f22ec4
--- /dev/null
+++ 
b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/layouts/IDataGridLayout.as
@@ -0,0 +1,52 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  Licensed to the Apache Software Foundation (ASF) under one or more
+//  contributor license agreements.  See the NOTICE file distributed with
+//  this work for additional information regarding copyright ownership.
+//  The ASF licenses this file to You under the Apache License, Version 2.0
+//  (the "License"); you may not use this file except in compliance with
+//  the License.  You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.html.beads.layouts
+{      
+       import org.apache.flex.core.IBeadLayout;
+       import org.apache.flex.core.IDataGridModel;
+       import org.apache.flex.core.IStrand;
+       import org.apache.flex.core.IUIBase;
+       import org.apache.flex.core.UIBase;
+       import org.apache.flex.events.Event;
+       import org.apache.flex.events.IEventDispatcher;
+       import org.apache.flex.html.ButtonBar;
+       import org.apache.flex.html.supportClasses.DataGridColumn;
+       
+       /**
+        * DataGridLayout is a class that handles the size and positioning of 
the
+        * elements of a DataGrid. This includes the ButtonBar used for the 
column
+        * headers and the Lists that are the columns.
+        *  
+        *  @langversion 3.0
+        *  @playerversion Flash 10.2
+        *  @playerversion AIR 2.6
+        *  @productversion FlexJS 0.0
+        */
+       public interface IDataGridLayout extends IBeadLayout
+       {
+               function get header():IUIBase;
+               function set header(value:IUIBase):void;
+               
+               function get columns():Array;
+               function set columns(value:Array):void;
+               
+               function get listArea():IUIBase;
+               function set listArea(value:IUIBase):void;
+       }
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/9bd1e9ff/frameworks/projects/HTML/src/main/resources/basic-manifest.xml
----------------------------------------------------------------------
diff --git a/frameworks/projects/HTML/src/main/resources/basic-manifest.xml 
b/frameworks/projects/HTML/src/main/resources/basic-manifest.xml
index f916c4a..f56d4d8 100644
--- a/frameworks/projects/HTML/src/main/resources/basic-manifest.xml
+++ b/frameworks/projects/HTML/src/main/resources/basic-manifest.xml
@@ -97,6 +97,8 @@
     <component id="DataGridColumn" 
class="org.apache.flex.html.supportClasses.DataGridColumn"/>
     <component id="DataGridLinesBead" 
class="org.apache.flex.html.beads.DataGridLinesBead"/>
     <component id="DataGridColumnList" 
class="org.apache.flex.html.supportClasses.DataGridColumnList"/>
+    <component id="DataGridLayout" 
class="org.apache.flex.html.beads.layouts.DataGridLayout" />
+    <component id="DataGridPercentageLayout" 
class="org.apache.flex.html.beads.layouts.DataGridPercentageLayout" />
     
     <component id="DataItemRendererFactoryForArrayData" 
class="org.apache.flex.html.beads.DataItemRendererFactoryForArrayData" />
     <component id="DataItemRendererFactoryForArrayList" 
class="org.apache.flex.html.beads.DataItemRendererFactoryForArrayList" />

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/9bd1e9ff/frameworks/projects/HTML/src/main/resources/defaults.css
----------------------------------------------------------------------
diff --git a/frameworks/projects/HTML/src/main/resources/defaults.css 
b/frameworks/projects/HTML/src/main/resources/defaults.css
index dd9bf27..28f2077 100644
--- a/frameworks/projects/HTML/src/main/resources/defaults.css
+++ b/frameworks/projects/HTML/src/main/resources/defaults.css
@@ -110,6 +110,7 @@ DataGrid
     IDataGridPresentationModel: 
ClassReference("org.apache.flex.html.beads.models.DataGridPresentationModel");
     IBeadView: ClassReference("org.apache.flex.html.beads.DataGridView");
     IBeadModel: 
ClassReference("org.apache.flex.html.beads.models.DataGridModel");
+       IBeadLayout: 
ClassReference("org.apache.flex.html.beads.layouts.DataGridLayout");
 
     background-color: #FFFFFF;
        border-style: solid;

Reply via email to