http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/7853ef15/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 new file mode 100644 index 0000000..582a1e7 --- /dev/null +++ b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/DataGridView.as @@ -0,0 +1,294 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +//////////////////////////////////////////////////////////////////////////////// +package org.apache.flex.html.beads +{ + import org.apache.flex.core.IBead; + import org.apache.flex.core.IBeadModel; + import org.apache.flex.core.IBeadView; + import org.apache.flex.core.IDataGridModel; + import org.apache.flex.core.ISelectableItemRenderer; + import org.apache.flex.core.ISelectionModel; + import org.apache.flex.core.IStrand; + import org.apache.flex.core.IUIBase; + import org.apache.flex.core.UIBase; + import org.apache.flex.core.ValuesManager; + import org.apache.flex.events.Event; + import org.apache.flex.events.IEventDispatcher; + import org.apache.flex.html.ButtonBar; + import org.apache.flex.html.Container; + import org.apache.flex.html.List; + import org.apache.flex.html.beads.layouts.ButtonBarLayout; + import org.apache.flex.html.beads.layouts.VerticalLayout; + import org.apache.flex.html.beads.models.ArraySelectionModel; + import org.apache.flex.html.beads.models.DataGridPresentationModel; + import org.apache.flex.html.supportClasses.DataGridColumn; + import org.apache.flex.html.supportClasses.ScrollingViewport; + import org.apache.flex.html.supportClasses.Viewport; + + /** + * The DataGridView class is the visual bead for the org.apache.flex.html.DataGrid. + * This class constructs the items that make the DataGrid: Lists for each column and a + * org.apache.flex.html.ButtonBar for the column headers. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public class DataGridView implements IBeadView + { + /** + * constructor. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function DataGridView() + { + } + + private var _strand:IStrand; + private var _header:ButtonBar; + private var _listArea:Container; + + private var _lists:Array; + + /** + * An array of List objects the comprise the columns of the DataGrid. + */ + public function get getColumnLists():Array + { + return _lists; + } + + /** + * @private + */ + public function get host():IUIBase + { + return _strand as IUIBase; + } + + /** + * @copy org.apache.flex.core.IBead#strand + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function set strand(value:IStrand):void + { + _strand = value; + + var host:UIBase = value as UIBase; + host.addEventListener("widthChanged", handleSizeChanges); + host.addEventListener("heightChanged", handleSizeChanges); + + _header = new ButtonBar(); + _header.id = "dataGridHeader"; + + var scrollPort:ScrollingViewport = new ScrollingViewport(); +// scrollPort.showsHorizontalScrollBar = false; + + _listArea = new Container(); + _listArea.id = "dataGridListArea"; + _listArea.className = "DataGridListArea"; + _listArea.addBead(scrollPort); + + finishSetup(null); + } + + /** + * @private + */ + private function finishSetup(event:Event):void + { + var host:UIBase = _strand as UIBase; + + // see if there is a presentation model already in place. if not, add one. + var presentationModel:DataGridPresentationModel = _strand.getBeadByType(DataGridPresentationModel) as DataGridPresentationModel; + if (presentationModel == null) { + presentationModel = new DataGridPresentationModel(); + _strand.addBead(presentationModel); + } + + var sharedModel:IDataGridModel = _strand.getBeadByType(IBeadModel) as IDataGridModel; + 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; + + _header.addBead(buttonBarModel); + _header.addBead(bblayout); + _header.addBead(new Viewport()); + host.addElement(_header); + + 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); + } + } + + /** + * @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:List = _lists[i] as List; + 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; + } + } + } + + /** + * @private + */ + private function handleDataProviderChanged(event:Event):void + { + var sharedModel:IDataGridModel = _strand.getBeadByType(IBeadModel) as IDataGridModel; + + if (_lists == null || _lists.length == 0) { + createLists(); + } + + for (var i:int=0; i < _lists.length; i++) + { + var list:List = _lists[i] as List; + var listModel:ISelectionModel = list.getBeadByType(IBeadModel) as ISelectionModel; + listModel.dataProvider = sharedModel.dataProvider; + } + + handleSizeChanges(event); + } + + /** + * @private + */ + private function handleColumnListChange(event:Event):void + { + var sharedModel:IDataGridModel = _strand.getBeadByType(IBeadModel) as IDataGridModel; + var list:List = event.target as List; + sharedModel.selectedIndex = list.selectedIndex; + + for(var i:int=0; i < _lists.length; i++) { + if (list != _lists[i]) { + var otherList:List = _lists[i] as List; + otherList.selectedIndex = list.selectedIndex; + } + } + + IEventDispatcher(_strand).dispatchEvent(new Event('change')); + } + + /** + * @private + */ + private function createLists():void + { + var sharedModel:IDataGridModel = _strand.getBeadByType(IBeadModel) as IDataGridModel; + var presentationModel:DataGridPresentationModel = _strand.getBeadByType(DataGridPresentationModel) as DataGridPresentationModel; + var listWidth:Number = host.width / sharedModel.columns.length; + + _lists = new Array(); + + for (var i:int=0; i < sharedModel.columns.length; i++) { + var dataGridColumn:DataGridColumn = sharedModel.columns[i] as DataGridColumn; + + var list:List = new List(); + list.id = "dataGridColumn"+String(i); + list.className = "DataGridColumn"; + list.addBead(sharedModel); + list.itemRenderer = dataGridColumn.itemRenderer; + list.labelField = dataGridColumn.dataField; + 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")); + } + } +} +
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/7853ef15/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/DataItemRendererFactoryForArrayData.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/DataItemRendererFactoryForArrayData.as b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/DataItemRendererFactoryForArrayData.as new file mode 100644 index 0000000..609bfbc --- /dev/null +++ b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/DataItemRendererFactoryForArrayData.as @@ -0,0 +1,161 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +//////////////////////////////////////////////////////////////////////////////// +package org.apache.flex.html.beads +{ + import org.apache.flex.core.IBead; + import org.apache.flex.core.IDataProviderItemRendererMapper; + import org.apache.flex.core.IItemRendererClassFactory; + import org.apache.flex.core.IItemRendererParent; + import org.apache.flex.core.IListPresentationModel; + import org.apache.flex.core.ISelectableItemRenderer; + import org.apache.flex.core.ISelectionModel; + import org.apache.flex.core.IStrand; + import org.apache.flex.core.IUIBase; + import org.apache.flex.core.SimpleCSSStyles; + import org.apache.flex.core.UIBase; + import org.apache.flex.core.ValuesManager; + import org.apache.flex.events.Event; + import org.apache.flex.events.IEventDispatcher; + import org.apache.flex.html.List; + + /** + * The DataItemRendererFactoryForArrayData class reads an + * array of data and creates an item renderer for every + * item in the array. Other implementations of + * IDataProviderItemRendererMapper map different data + * structures or manage a virtual set of renderers. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public class DataItemRendererFactoryForArrayData implements IBead, IDataProviderItemRendererMapper + { + /** + * Constructor. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function DataItemRendererFactoryForArrayData() + { + } + + private var selectionModel:ISelectionModel; + + private var labelField:String; + + 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; + selectionModel = value.getBeadByType(ISelectionModel) as ISelectionModel; + var listView:IListView = value.getBeadByType(IListView) as IListView; + dataGroup = listView.dataGroup; + selectionModel.addEventListener("dataProviderChanged", dataProviderChangeHandler); + + labelField = (listView.host as List).labelField; + + if (!itemRendererFactory) + { + _itemRendererFactory = new (ValuesManager.valuesImpl.getValue(_strand, "iItemRendererClassFactory")) as IItemRendererClassFactory; + _strand.addBead(_itemRendererFactory); + } + + dataProviderChangeHandler(null); + } + + private var _itemRendererFactory:IItemRendererClassFactory; + + /** + * The org.apache.flex.core.IItemRendererClassFactory used + * to generate instances of item renderers. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get itemRendererFactory():IItemRendererClassFactory + { + return _itemRendererFactory; + } + + /** + * @private + */ + public function set itemRendererFactory(value:IItemRendererClassFactory):void + { + _itemRendererFactory = value; + } + + /** + * The org.apache.flex.core.IItemRendererParent that will + * parent the item renderers. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + protected var dataGroup:IItemRendererParent; + + private function dataProviderChangeHandler(event:Event):void + { + var dp:Array = selectionModel.dataProvider as Array; + if (!dp) + return; + + dataGroup.removeAllElements(); + + var listView:IListView = _strand.getBeadByType(IListView) as IListView; + var presentationModel:IListPresentationModel = _strand.getBeadByType(IListPresentationModel) as IListPresentationModel; + + var n:int = dp.length; + for (var i:int = 0; i < n; i++) + { + var ir:ISelectableItemRenderer = itemRendererFactory.createItemRenderer(dataGroup) as ISelectableItemRenderer; + ir.index = i; + ir.labelField = labelField; + if (presentationModel) { + var style:SimpleCSSStyles = new SimpleCSSStyles(); + style.marginBottom = presentationModel.separatorThickness; + UIBase(ir).style = style; + UIBase(ir).height = presentationModel.rowHeight; + } + dataGroup.addElement(ir); + ir.data = dp[i]; + } + + IEventDispatcher(_strand).dispatchEvent(new Event("itemsCreated")); + } + } +} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/7853ef15/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/DataItemRendererFactoryForArrayList.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/DataItemRendererFactoryForArrayList.as b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/DataItemRendererFactoryForArrayList.as new file mode 100644 index 0000000..9895394 --- /dev/null +++ b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/DataItemRendererFactoryForArrayList.as @@ -0,0 +1,174 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +//////////////////////////////////////////////////////////////////////////////// +package org.apache.flex.html.beads +{ + import org.apache.flex.collections.ArrayList; + import org.apache.flex.core.IBead; + import org.apache.flex.core.IDataProviderItemRendererMapper; + import org.apache.flex.core.IItemRendererClassFactory; + import org.apache.flex.core.IItemRendererParent; + import org.apache.flex.core.IListPresentationModel; + import org.apache.flex.core.ISelectableItemRenderer; + import org.apache.flex.core.ISelectionModel; + import org.apache.flex.core.IStrand; + import org.apache.flex.core.IUIBase; + import org.apache.flex.core.SimpleCSSStyles; + import org.apache.flex.core.UIBase; + import org.apache.flex.core.ValuesManager; + import org.apache.flex.events.Event; + import org.apache.flex.events.IEventDispatcher; + import org.apache.flex.html.List; + + /** + * The DataItemRendererFactoryForArrayList class uses an ArrayList + * and creates an item renderer for every + * item in the collection. Other implementations of + * IDataProviderItemRendererMapper map different data + * structures or manage a virtual set of renderers. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public class DataItemRendererFactoryForArrayList implements IBead, IDataProviderItemRendererMapper + { + /** + * Constructor. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function DataItemRendererFactoryForArrayList() + { + } + + private var selectionModel:ISelectionModel; + + private var labelField:String; + + 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; + IEventDispatcher(_strand).addEventListener("beadsAdded", finishSetup); + IEventDispatcher(_strand).addEventListener("initComplete", finishSetup); + } + + private function finishSetup(event:Event):void + { + selectionModel = _strand.getBeadByType(ISelectionModel) as ISelectionModel; + var listView:IListView = _strand.getBeadByType(IListView) as IListView; + dataGroup = listView.dataGroup; + selectionModel.addEventListener("dataProviderChanged", dataProviderChangeHandler); + + labelField = (listView.host as List).labelField; + + if (!itemRendererFactory) + { + _itemRendererFactory = _strand.getBeadByType(IItemRendererClassFactory) as IItemRendererClassFactory; + if (_itemRendererFactory == null) { + _itemRendererFactory = new (ValuesManager.valuesImpl.getValue(_strand, "iItemRendererClassFactory")) as IItemRendererClassFactory; + _strand.addBead(_itemRendererFactory); + } + } + + dataProviderChangeHandler(null); + } + + private var _itemRendererFactory:IItemRendererClassFactory; + + /** + * The org.apache.flex.core.IItemRendererClassFactory used + * to generate instances of item renderers. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get itemRendererFactory():IItemRendererClassFactory + { + return _itemRendererFactory; + } + + /** + * @private + */ + public function set itemRendererFactory(value:IItemRendererClassFactory):void + { + _itemRendererFactory = value; + } + + /** + * The org.apache.flex.core.IItemRendererParent that will + * parent the item renderers. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + protected var dataGroup:IItemRendererParent; + + private function dataProviderChangeHandler(event:Event):void + { + var dp:ArrayList = selectionModel.dataProvider as ArrayList; + if (!dp) + return; + + dataGroup.removeAllElements(); + + var listView:IListView = _strand.getBeadByType(IListView) as IListView; + var presentationModel:IListPresentationModel = _strand.getBeadByType(IListPresentationModel) as IListPresentationModel; + + var n:int = dp.length; + for (var i:int = 0; i < n; i++) + { + var ir:ISelectableItemRenderer = itemRendererFactory.createItemRenderer(dataGroup) as ISelectableItemRenderer; + ir.index = i; + ir.labelField = labelField; + if (presentationModel) { + UIBase(ir).height = presentationModel.rowHeight; + + // ensure that the IR spans the width of its column + var style:SimpleCSSStyles = new SimpleCSSStyles(); + style.right = 0; + style.left = 0; + UIBase(ir).style = style; + } + dataGroup.addElement(ir); + ir.data = dp.getItemAt(i); + } + + IEventDispatcher(_strand).dispatchEvent(new Event("itemsCreated")); + } + } +} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/7853ef15/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/DataItemRendererFactoryForColumnData.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/DataItemRendererFactoryForColumnData.as b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/DataItemRendererFactoryForColumnData.as new file mode 100644 index 0000000..d399cfb --- /dev/null +++ b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/DataItemRendererFactoryForColumnData.as @@ -0,0 +1,142 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +//////////////////////////////////////////////////////////////////////////////// +package org.apache.flex.html.beads +{ + import org.apache.flex.core.IBead; + import org.apache.flex.core.IBeadView; + import org.apache.flex.core.IDataGridModel; + import org.apache.flex.core.IDataProviderItemRendererMapper; + import org.apache.flex.core.IItemRendererClassFactory; + import org.apache.flex.core.IItemRendererParent; + import org.apache.flex.core.IStrand; + import org.apache.flex.core.ValuesManager; + import org.apache.flex.events.Event; + import org.apache.flex.events.IEventDispatcher; + import org.apache.flex.html.supportClasses.DataItemRenderer; + + /** + * The DataItemRendererFactoryForColumnData class implents the + * org.apache.flex.core.IDataProviderItemRendererMapper interface and creates the itemRenderers + * for each cell in the org.apache.flex.html.DataGrid. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public class DataItemRendererFactoryForColumnData implements IBead, IDataProviderItemRendererMapper + { + /** + * constructor. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function DataItemRendererFactoryForColumnData() + { + } + + private var selectionModel:IDataGridModel; + + 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; + selectionModel = value.getBeadByType(IDataGridModel) as IDataGridModel; + var listView:IListView = value.getBeadByType(IListView) as IListView; + dataGroup = listView.dataGroup; + selectionModel.addEventListener("dataProviderChanged", dataProviderChangeHandler); + + if (!itemRendererFactory) + { + _itemRendererFactory = new (ValuesManager.valuesImpl.getValue(_strand, "iItemRendererClassFactory")) as IItemRendererClassFactory; + _strand.addBead(_itemRendererFactory); + } + + dataProviderChangeHandler(null); + } + + private var _itemRendererFactory:IItemRendererClassFactory; + + /** + * The factory used to create the itemRenderers. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get itemRendererFactory():IItemRendererClassFactory + { + return _itemRendererFactory + } + public function set itemRendererFactory(value:IItemRendererClassFactory):void + { + _itemRendererFactory = value; + } + + /** + * The dataGroup that is the pareent for the itemRenderers + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + protected var dataGroup:IItemRendererParent; + + /** + * @private + */ + private function dataProviderChangeHandler(event:Event):void + { + var dp:Array = selectionModel.dataProvider as Array; + if (!dp) + return; + + dataGroup.removeAllElements(); + + var view:DataGridColumnView = _strand.getBeadByType(IBeadView) as DataGridColumnView; + if (view == null) return; + + var n:int = dp.length; + for (var i:int = 0; i < n; i++) + { + var tf:DataItemRenderer = itemRendererFactory.createItemRenderer(dataGroup) as DataItemRenderer; + tf.index = i; + tf.labelField = view.column.dataField; + dataGroup.addElement(tf); + tf.data = dp[i]; + } + + IEventDispatcher(_strand).dispatchEvent(new Event("itemsCreated")); + } + } +} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/7853ef15/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/DataProviderChangeNotifier.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/DataProviderChangeNotifier.as b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/DataProviderChangeNotifier.as new file mode 100644 index 0000000..8905fb9 --- /dev/null +++ b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/DataProviderChangeNotifier.as @@ -0,0 +1,154 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +//////////////////////////////////////////////////////////////////////////////// +package org.apache.flex.html.beads +{ + import org.apache.flex.core.IBead; + import org.apache.flex.core.IDocument; + import org.apache.flex.core.ISelectionModel; + import org.apache.flex.core.IStrand; + import org.apache.flex.events.Event; + import org.apache.flex.collections.ArrayList; + + /** + * The DataProviderChangeNotifier notifies listeners when a selection model's + * ArrayList dataProvider has changed. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public class DataProviderChangeNotifier implements IBead, IDocument + { + /** + * constructor. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function DataProviderChangeNotifier() + { + } + + protected var _dataProvider:ArrayList; + + 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; + + if (_dataProvider == null) { + var object:Object = document[sourceID]; + _dataProvider = object[propertyName] as ArrayList; + } + + _dataProvider.addEventListener("itemAdded", handleItemAdded); + _dataProvider.addEventListener("itemRemoved", handleItemRemoved); + _dataProvider.addEventListener("itemUpdated", handleItemUpdated); + + } + + protected var document:Object; + + /** + * @private + */ + public function setDocument(document:Object, id:String = null):void + { + this.document = document; + } + + private var _sourceID:String; + + /** + * The ID of the object holding the ArrayList, usually a model. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get sourceID():String + { + return _sourceID; + } + public function set sourceID(value:String):void + { + _sourceID = value; + } + + private var _propertyName:String; + + /** + * The property in the sourceID that is the ArrayList. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get propertyName():String + { + return _propertyName; + } + + public function set propertyName(value:String):void + { + _propertyName = value; + } + + /** + * @private + */ + private function handleItemAdded(event:Event):void + { + var selectionModel:ISelectionModel = _strand.getBeadByType(ISelectionModel) as ISelectionModel; + selectionModel.dispatchEvent(new Event("dataProviderChanged")); + } + + /** + * @private + */ + private function handleItemRemoved(event:Event):void + { + var selectionModel:ISelectionModel = _strand.getBeadByType(ISelectionModel) as ISelectionModel; + selectionModel.dispatchEvent(new Event("dataProviderChanged")); + } + + /** + * @private + */ + private function handleItemUpdated(event:Event):void + { + var selectionModel:ISelectionModel = _strand.getBeadByType(ISelectionModel) as ISelectionModel; + selectionModel.dispatchEvent(new Event("dataProviderChanged")); + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/7853ef15/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/DateChooserView.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/DateChooserView.as b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/DateChooserView.as new file mode 100644 index 0000000..5abf4c4 --- /dev/null +++ b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/DateChooserView.as @@ -0,0 +1,256 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +//////////////////////////////////////////////////////////////////////////////// +package org.apache.flex.html.beads +{ + import org.apache.flex.html.beads.models.DateChooserModel; + import org.apache.flex.html.supportClasses.DateChooserButton; + + import org.apache.flex.core.BeadViewBase; + import org.apache.flex.core.IBeadModel; + import org.apache.flex.core.IBeadView; + import org.apache.flex.core.IStrand; + import org.apache.flex.core.UIBase; + import org.apache.flex.core.ValuesManager; + import org.apache.flex.events.Event; + import org.apache.flex.events.IEventDispatcher; + import org.apache.flex.html.beads.layouts.TileLayout; + import org.apache.flex.html.Container; + import org.apache.flex.html.TextButton; + + /** + * The DateChooserView class is a view bead for the DateChooser. This class + * creates the elements for the DateChooser: the buttons to move between + * months, the labels for the days of the week, and the buttons for each day + * of the month. + */ + public class DateChooserView extends BeadViewBase implements IBeadView + { + /** + * constructor + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function DateChooserView() + { + } + + /** + * @copy org.apache.flex.core.IBead#strand + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + override public function set strand(value:IStrand):void + { + super.strand = value; + + // make sure there is a model. + model = _strand.getBeadByType(IBeadModel) as DateChooserModel; + if (model == null) { + model = new (ValuesManager.valuesImpl.getValue(_strand,"iBeadModel")) as DateChooserModel; + } + model.addEventListener("displayedMonthChanged",handleModelChange); + model.addEventListener("displayedYearChanged",handleModelChange); + + createChildren(); + } + + private var _prevMonthButton:TextButton; + private var _nextMonthButton:TextButton; + private var _dayButtons:Array; + private var monthLabel:TextButton; + private var dayContainer:Container; + + private var model:DateChooserModel; + + /** + * The button that causes the previous month to be displayed by the DateChooser. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get prevMonthButton():TextButton + { + return _prevMonthButton; + } + + /** + * The button that causes the next month to be displayed by the DateChooser. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get nextMonthButton():TextButton + { + return _nextMonthButton; + } + + /** + * The array of DateChooserButton instances that represent each day of the month. + */ + public function get dayButtons():Array + { + return _dayButtons; + } + + /** + * @private + */ + private function createChildren():void + { + _prevMonthButton = new TextButton(); + _prevMonthButton.width = 40; + _prevMonthButton.height = 20; + _prevMonthButton.x = 0; + _prevMonthButton.y = 0; + _prevMonthButton.text = "<"; + UIBase(_strand).addElement(_prevMonthButton); + + _nextMonthButton = new TextButton(); + _nextMonthButton.width = 40; + _nextMonthButton.height = 20; + _nextMonthButton.x = UIBase(_strand).width - _nextMonthButton.width; + _nextMonthButton.y = 0; + _nextMonthButton.text = ">"; + UIBase(_strand).addElement(_nextMonthButton); + + monthLabel = new TextButton(); + monthLabel.text = "Month Here"; + monthLabel.width = 100; + monthLabel.height = 20; + monthLabel.x = (UIBase(_strand).width - monthLabel.width)/2; + monthLabel.y = 0; + UIBase(_strand).addElement(monthLabel); + + dayContainer = new Container(); + var tileLayout:TileLayout = new TileLayout(); + dayContainer.addBead(tileLayout); + UIBase(_strand).addElement(dayContainer, false); + + tileLayout.numColumns = 7; + dayContainer.x = 0; + dayContainer.y = monthLabel.y + monthLabel.height + 5; + + var sw:Number = UIBase(_strand).width; + var sh:Number = UIBase(_strand).height; + //trace("Strand's width x height is "+sw+" x "+sh); + dayContainer.width = sw; + dayContainer.height = sh - (monthLabel.height+5); + + // the calendar has 7 columns with 6 rows, the first row are the day names + for(var i:int=0; i < 7; i++) { + var dayName:DateChooserButton = new DateChooserButton(); + dayName.text = model.dayNames[i]; + dayName.dayOfMonth = 0; + dayContainer.addElement(dayName, false); + } + + _dayButtons = new Array(); + + for(i=0; i < 42; i++) { + var date:DateChooserButton = new DateChooserButton(); + date.text = String(i+1); + dayContainer.addElement(date, false); + dayButtons.push(date); + } + + IEventDispatcher(dayContainer).dispatchEvent( new Event("itemsCreated") ); + IEventDispatcher(_strand).dispatchEvent( new Event("layoutNeeded") ); + IEventDispatcher(dayContainer).dispatchEvent( new Event("layoutNeeded") ); + + updateCalendar(); + } + + /** + * @private + */ + private function updateCalendar():void + { + monthLabel.text = model.monthNames[model.displayedMonth] + " " + + String(model.displayedYear); + + var firstDay:Date = new Date(model.displayedYear,model.displayedMonth,1); + + // blank out the labels for the first firstDay.day-1 entries. + for(var i:int=0; i < firstDay.getDay(); i++) { + var dateButton:DateChooserButton = dayButtons[i] as DateChooserButton; + dateButton.dayOfMonth = -1; + dateButton.text = ""; + } + + // renumber to the last day of the month + var dayNumber:int = 1; + var numDays:Number = numberOfDaysInMonth(model.displayedMonth, model.displayedYear); + + for(; i < dayButtons.length && dayNumber <= numDays; i++) { + dateButton = dayButtons[i] as DateChooserButton; + dateButton.dayOfMonth = dayNumber; + dateButton.text = String(dayNumber++); + } + + // blank out the rest + for(; i < dayButtons.length; i++) { + dateButton = dayButtons[i] as DateChooserButton; + dateButton.dayOfMonth = -1; + dateButton.text = ""; + } + } + + /** + * @private + */ + private function numberOfDaysInMonth(month:Number, year:Number):Number + { + var n:int; + + if (month == 1) // Feb + { + if (((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0)) // leap year + n = 29; + else + n = 28; + } + + else if (month == 3 || month == 5 || month == 8 || month == 10) + n = 30; + + else + n = 31; + + return n; + } + + /** + * @private + */ + private function handleModelChange(event:Event):void + { + updateCalendar(); + } + } +} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/7853ef15/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/DateFieldView.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/DateFieldView.as b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/DateFieldView.as new file mode 100644 index 0000000..f709a1f --- /dev/null +++ b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/DateFieldView.as @@ -0,0 +1,192 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +//////////////////////////////////////////////////////////////////////////////// +package org.apache.flex.html.beads +{ + import org.apache.flex.core.BeadViewBase; + import org.apache.flex.core.IBeadView; + import org.apache.flex.core.IDateChooserModel; + import org.apache.flex.core.IFormatBead; + import org.apache.flex.core.IParent; + import org.apache.flex.core.IPopUpHost; + import org.apache.flex.core.IStrand; + import org.apache.flex.core.UIBase; + import org.apache.flex.core.ValuesManager; + import org.apache.flex.events.Event; + import org.apache.flex.events.IEventDispatcher; + import org.apache.flex.utils.UIUtils; + import org.apache.flex.utils.PointUtils; + import org.apache.flex.geom.Point; + import org.apache.flex.html.DateChooser; + import org.apache.flex.html.TextButton; + import org.apache.flex.html.TextInput; + + /** + * The DateFieldView class is a bead for DateField that creates the + * input and button controls. This class also handles the pop-up + * mechanics. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public class DateFieldView extends BeadViewBase implements IBeadView + { + /** + * constructor. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function DateFieldView() + { + } + + private var _textInput:TextInput; + private var _button:TextButton; + + /** + * The TextButton that triggers the display of the DateChooser pop-up. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get menuButton():TextButton + { + return _button; + } + + /** + * The TextInput that displays the date selected. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get textInput():TextInput + { + return _textInput; + } + + /** + * @copy org.apache.flex.core.IBead#strand + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + override public function set strand(value:IStrand):void + { + super.strand = value; + + _textInput = new TextInput(); + UIBase(_strand).addElement(_textInput); + _textInput.width = 100; + _textInput.height = 18; + + _button = new TextButton(); + _button.text = "M"; + UIBase(_strand).addElement(_button); + _button.x = _textInput.width; + _button.y = _textInput.y; + + IEventDispatcher(_strand).addEventListener("beadsAdded",handleBeadsAdded); + } + + private function handleBeadsAdded(event:Event):void + { + var formatter:IFormatBead = _strand.getBeadByType(IFormatBead) as IFormatBead; + formatter.addEventListener("formatChanged",handleFormatChanged); + } + + private function handleFormatChanged(event:Event):void + { + var formatter:IFormatBead = event.target as IFormatBead; + _textInput.text = formatter.formattedString; + } + + private var _popUp:DateChooser; + + /** + * The pop-up component that holds the selection list. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get popUp():DateChooser + { + return _popUp; + } + + private var _popUpVisible:Boolean; + + /** + * This property is true if the pop-up selection list is currently visible. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get popUpVisible():Boolean + { + return _popUpVisible; + } + public function set popUpVisible(value:Boolean):void + { + if (value != _popUpVisible) + { + _popUpVisible = value; + if (value) + { + if (!_popUp) + { + _popUp = new DateChooser(); + _popUp.width = 210; + _popUp.height = 220; + } + + var model:IDateChooserModel = _strand.getBeadByType(IDateChooserModel) as IDateChooserModel; + _popUp.selectedDate = model.selectedDate; + + var host:IPopUpHost = UIUtils.findPopUpHost(UIBase(_strand)); + var point:Point = new Point(_button.x, _button.y+_button.height); + var p2:Point = PointUtils.localToGlobal(point, _strand); + var p3:Point = PointUtils.globalToLocal(p2, host); + _popUp.x = p3.x; + _popUp.y = p3.y; + + host.addElement(_popUp); + } + else + { + UIUtils.removePopUp(_popUp); + } + } + } + } +} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/7853ef15/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/DownArrowButtonView.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/DownArrowButtonView.as b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/DownArrowButtonView.as new file mode 100644 index 0000000..c68a633 --- /dev/null +++ b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/DownArrowButtonView.as @@ -0,0 +1,111 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +//////////////////////////////////////////////////////////////////////////////// +package org.apache.flex.html.beads +{ + import flash.display.Graphics; + import flash.display.Shape; + import flash.display.SimpleButton; + + import org.apache.flex.core.BeadViewBase; + import org.apache.flex.core.IStrand; + import org.apache.flex.core.IBeadView; + import org.apache.flex.events.Event; + + /** + * The DownArrowButtonView class is the view for + * the down arrow button in a ScrollBar and other controls. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public class DownArrowButtonView extends BeadViewBase implements IBeadView + { + /** + * Constructor. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function DownArrowButtonView() + { + upView = new Shape(); + downView = new Shape(); + overView = new Shape(); + + drawView(upView.graphics, 0xf8f8f8); + drawView(downView.graphics, 0xd8d8d8); + drawView(overView.graphics, 0xe8e8e8); + } + + private function drawView(g:Graphics, bgColor:uint):void + { + g.lineStyle(1); + g.beginFill(bgColor); + g.drawRoundRect(0, 0, ScrollBarView.FullSize, ScrollBarView.FullSize, ScrollBarView.ThirdSize); + g.endFill(); + g.lineStyle(0); + g.beginFill(0); + g.moveTo(ScrollBarView.QuarterSize, ScrollBarView.QuarterSize); + g.lineTo(ScrollBarView.ThreeQuarterSize, ScrollBarView.QuarterSize); + g.lineTo(ScrollBarView.HalfSize, ScrollBarView.ThreeQuarterSize); + g.lineTo(ScrollBarView.QuarterSize, ScrollBarView.QuarterSize); + g.endFill(); + } + + private var shape:Shape; + + /** + * @copy org.apache.flex.core.IBead#strand + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + override public function set strand(value:IStrand):void + { + super.strand = value; + shape = new Shape(); + shape.graphics.beginFill(0xCCCCCC); + shape.graphics.drawRect(0, 0, ScrollBarView.FullSize, ScrollBarView.FullSize); + shape.graphics.endFill(); + SimpleButton(value).upState = upView; + SimpleButton(value).downState = downView; + SimpleButton(value).overState = overView; + SimpleButton(value).hitTestState = shape; + + SimpleButton(_strand).addEventListener("widthChanged",sizeChangeHandler); + SimpleButton(_strand).addEventListener("heightChanged",sizeChangeHandler); + } + + private var upView:Shape; + private var downView:Shape; + private var overView:Shape; + + private function sizeChangeHandler(event:Event):void + { + SimpleButton(_strand).scaleX = SimpleButton(_strand).width / ScrollBarView.FullSize; + SimpleButton(_strand).scaleY = SimpleButton(_strand).height / ScrollBarView.FullSize; + } + } +} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/7853ef15/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/DropDownListView.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/DropDownListView.as b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/DropDownListView.as new file mode 100644 index 0000000..1334227 --- /dev/null +++ b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/DropDownListView.as @@ -0,0 +1,300 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +//////////////////////////////////////////////////////////////////////////////// +package org.apache.flex.html.beads +{ + import flash.display.DisplayObject; + import flash.display.DisplayObjectContainer; + import flash.display.Graphics; + import flash.display.Shape; + import flash.display.SimpleButton; + import flash.display.Sprite; + import flash.text.TextFieldType; + + import org.apache.flex.core.BeadViewBase; + import org.apache.flex.core.CSSTextField; + import org.apache.flex.core.IBeadView; + import org.apache.flex.core.IPopUpHost; + import org.apache.flex.core.ISelectionModel; + import org.apache.flex.core.IStrand; + import org.apache.flex.core.ValuesManager; + import org.apache.flex.events.Event; + import org.apache.flex.events.IEventDispatcher; + import org.apache.flex.utils.SolidBorderUtil; + + /** + * The DropDownListView class is the default view for + * the org.apache.flex.html.DropDownList class. + * It displays a simple text label with what appears to be a + * down arrow button on the right, but really, the entire + * view is the button that will display or dismiss the dropdown. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public class DropDownListView extends BeadViewBase implements IDropDownListView, IBeadView + { + /** + * Constructor. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function DropDownListView() + { + upSprite = new Sprite(); + downSprite = new Sprite(); + overSprite = new Sprite(); + upTextField = new CSSTextField(); + downTextField = new CSSTextField(); + overTextField = new CSSTextField(); + upSprite.addChild(upTextField); + overSprite.addChild(overTextField); + downSprite.addChild(downTextField); + upTextField.parentDrawsBackground = true; + downTextField.parentDrawsBackground = true; + overTextField.parentDrawsBackground = true; + upTextField.selectable = false; + upTextField.type = TextFieldType.DYNAMIC; + downTextField.selectable = false; + downTextField.type = TextFieldType.DYNAMIC; + overTextField.selectable = false; + overTextField.type = TextFieldType.DYNAMIC; + // auto-size collapses if no text + //upTextField.autoSize = "left"; + //downTextField.autoSize = "left"; + //overTextField.autoSize = "left"; + + upArrows = new Shape(); + overArrows = new Shape(); + downArrows = new Shape(); + upSprite.addChild(upArrows); + overSprite.addChild(overArrows); + downSprite.addChild(downArrows); + drawArrows(upArrows); + drawArrows(overArrows); + drawArrows(downArrows); + + } + + + private var selectionModel:ISelectionModel; + + private var shape:Shape; + + /** + * @copy org.apache.flex.core.IBead#strand + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + override public function set strand(value:IStrand):void + { + super.strand = value;; + selectionModel = value.getBeadByType(ISelectionModel) as ISelectionModel; + selectionModel.addEventListener("selectedIndexChanged", selectionChangeHandler); + selectionModel.addEventListener("dataProviderChanged", selectionChangeHandler); + shape = new Shape(); + shape.graphics.beginFill(0xCCCCCC); + shape.graphics.drawRect(0, 0, 10, 10); + shape.graphics.endFill(); + SimpleButton(value).upState = upSprite; + SimpleButton(value).downState = downSprite; + SimpleButton(value).overState = overSprite; + SimpleButton(value).hitTestState = shape; + if (selectionModel.selectedIndex !== -1) + text = selectionModel.selectedItem.toString(); + else + text = "^W_"; + upTextField.height = upTextField.textHeight + 4; + downTextField.height = downTextField.textHeight + 4; + overTextField.height = overTextField.textHeight + 4; + if (selectionModel.selectedIndex == -1) + text = ""; + + IEventDispatcher(value).addEventListener("heightChanged", changeHandler); + IEventDispatcher(value).addEventListener("widthChanged", changeHandler); + changeHandler(null); + } + + private function selectionChangeHandler(event:Event):void + { + if (selectionModel.selectedItem == null) + text = ""; + else if (selectionModel.labelField != null) + text = selectionModel.selectedItem[selectionModel.labelField].toString(); + else + text = selectionModel.selectedItem.toString(); + } + + private function changeHandler(event:Event):void + { + var ww:Number = DisplayObject(_strand).width; + var hh:Number = DisplayObject(_strand).height; + + upArrows.x = ww - upArrows.width - 6; + overArrows.x = ww - overArrows.width - 6; + downArrows.x = ww - downArrows.width - 6; + upArrows.y = (hh - upArrows.height) / 2; + overArrows.y = (hh - overArrows.height) / 2; + downArrows.y = (hh - downArrows.height) / 2; + + upTextField.width = upArrows.x; + downTextField.width = downArrows.x; + overTextField.width = overArrows.x; + upTextField.height = hh; + downTextField.height = hh; + overTextField.height = hh; + + drawBorder(upSprite, 0xf8f8f8, ww, hh); + drawBorder(overSprite, 0xe8e8e8, ww, hh); + drawBorder(downSprite, 0xd8d8d8, ww, hh); + + shape.graphics.clear(); + shape.graphics.beginFill(0xCCCCCC); + shape.graphics.drawRect(0, 0, ww, hh); + shape.graphics.endFill(); + } + + private var upTextField:CSSTextField; + private var downTextField:CSSTextField; + private var overTextField:CSSTextField; + private var upSprite:Sprite; + private var downSprite:Sprite; + private var overSprite:Sprite; + private var upArrows:Shape; + private var downArrows:Shape; + private var overArrows:Shape; + + private function drawBorder(sprite:Sprite, color:uint, ww:Number, hh:Number):void + { + SolidBorderUtil.drawBorder(sprite.graphics, 0, 0, + ww, hh, + 0x808080, color, 1, 1, 4); + } + + private function drawArrows(shape:Shape):void + { + var g:Graphics = shape.graphics; + g.beginFill(0); + g.moveTo(8, 0); + g.lineTo(12, 4); + g.lineTo(4, 4); + g.lineTo(8, 0); + g.endFill(); + g.beginFill(0); + g.moveTo(8, 10); + g.lineTo(12, 6); + g.lineTo(4, 6); + g.lineTo(8, 10); + g.endFill(); + } + + /** + * The text that is displayed in the view. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get text():String + { + return upTextField.text; + } + + /** + * @private + */ + public function set text(value:String):void + { + var ww:Number = DisplayObject(_strand).width; + var hh:Number = DisplayObject(_strand).height; + upTextField.text = value; + downTextField.text = value; + overTextField.text = value; + } + + private var _popUp:IStrand; + + /** + * The dropdown/popup that displays the set of choices. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get popUp():IStrand + { + if (!_popUp) + { + var popUpClass:Class = ValuesManager.valuesImpl.getValue(_strand, "iPopUp") as Class; + _popUp = new popUpClass() as IStrand; + } + return _popUp; + } + + private var _popUpVisible:Boolean; + + /** + * A flag that indicates whether the dropdown/popup is + * visible. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get popUpVisible():Boolean + { + return _popUpVisible; + } + + /** + * @private + */ + public function set popUpVisible(value:Boolean):void + { + if (value != _popUpVisible) + { + _popUpVisible = value; + if (value) + { + var root:Object = DisplayObject(_strand).root; + var host:DisplayObjectContainer = DisplayObject(_strand).parent; + while (host && !(host is IPopUpHost)) + host = host.parent; + if (host) + IPopUpHost(host).addElement(popUp); + } + else + { + DisplayObject(_popUp).parent.removeChild(_popUp as DisplayObject); + } + } + } + + } +} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/7853ef15/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/HRuleView.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/HRuleView.as b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/HRuleView.as new file mode 100644 index 0000000..3c7e092 --- /dev/null +++ b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/HRuleView.as @@ -0,0 +1,87 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +//////////////////////////////////////////////////////////////////////////////// +package org.apache.flex.html.beads +{ + import flash.display.Bitmap; + import flash.display.Loader; + import flash.display.LoaderInfo; + import flash.net.URLRequest; + + import org.apache.flex.core.BeadViewBase; + import org.apache.flex.core.IBeadView; + import org.apache.flex.core.IImageModel; + import org.apache.flex.core.IStrand; + import org.apache.flex.core.UIBase; + import org.apache.flex.events.Event; + import org.apache.flex.events.IEventDispatcher; + + /** + * The ImageView class creates the visual elements of the org.apache.flex.html.Image component. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public class HRuleView extends BeadViewBase implements IBeadView + { + /** + * constructor. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function HRuleView() + { + } + + /** + * @copy org.apache.flex.core.IBead#strand + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + override public function set strand(value:IStrand):void + { + super.strand = value; + + IEventDispatcher(_strand).addEventListener("widthChanged",handleSizeChange); + IEventDispatcher(_strand).addEventListener("heightChanged",handleSizeChange); + IEventDispatcher(_strand).addEventListener("sizeChanged",handleSizeChange); + + handleSizeChange(null); + } + + /** + * @private + */ + private function handleSizeChange(event:Object):void + { + var ui:UIBase = _strand as UIBase; + ui.graphics.clear(); + ui.graphics.beginFill(0); + ui.graphics.drawRect(0, 0, ui.width, 1); + ui.graphics.endFill(); + } + } +} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/7853ef15/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/HScrollBarThumbView.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/HScrollBarThumbView.as b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/HScrollBarThumbView.as new file mode 100644 index 0000000..05a41b6 --- /dev/null +++ b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/HScrollBarThumbView.as @@ -0,0 +1,120 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +//////////////////////////////////////////////////////////////////////////////// +package org.apache.flex.html.beads +{ + import flash.display.DisplayObject; + import flash.display.Graphics; + import flash.display.Shape; + import flash.display.SimpleButton; + + import org.apache.flex.core.BeadViewBase; + import org.apache.flex.core.IBeadView; + import org.apache.flex.core.IStrand; + import org.apache.flex.events.Event; + import org.apache.flex.events.IEventDispatcher; + import org.apache.flex.html.supportClasses.ScrollBar; + + /** + * The HScrollBarThumbView class is the view for + * the thumb button in a Horizontal ScrollBar. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public class HScrollBarThumbView extends BeadViewBase implements IBeadView + { + /** + * Constructor. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function HScrollBarThumbView() + { + } + + private function drawView(g:Graphics, bgColor:uint):void + { + var ww:Number = DisplayObject(_strand).width; + g.clear(); + g.lineStyle(1); + g.beginFill(bgColor); + g.drawRoundRect(0, 0, ww, ScrollBarView.FullSize, ScrollBarView.HalfSize); + g.endFill(); + } + + private var shape:Shape; + + /** + * @copy org.apache.flex.core.IBead#strand + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + override public function set strand(value:IStrand):void + { + super.strand = value; + + upView = new Shape(); + downView = new Shape(); + overView = new Shape(); + + drawView(upView.graphics, 0xc8c8c8); + drawView(downView.graphics, 0xc8c8c8); + drawView(overView.graphics, 0xb8b8b8); + + shape = new Shape(); + shape.graphics.beginFill(0xCCCCCC); + shape.graphics.drawRect(0, 0, ScrollBarView.FullSize, ScrollBarView.FullSize); + shape.graphics.endFill(); + SimpleButton(value).upState = upView; + SimpleButton(value).downState = downView; + SimpleButton(value).overState = overView; + SimpleButton(value).hitTestState = shape; + IEventDispatcher(_strand).addEventListener("widthChanged", widthChangedHandler); + } + + private function widthChangedHandler(event:Event):void + { + DisplayObject(_strand).scaleY = 1.0; + DisplayObject(_strand).scaleX = 1.0; + + var ww:Number = DisplayObject(_strand).width; + drawView(upView.graphics, 0xc8c8c8); + drawView(downView.graphics, 0xc8c8c8); + drawView(overView.graphics, 0xb8b8b8); + + shape.graphics.clear(); + shape.graphics.beginFill(0xCCCCCC); + shape.graphics.drawRect(0, 0, ww, ScrollBarView.FullSize); + shape.graphics.endFill(); + } + + private var upView:Shape; + private var downView:Shape; + private var overView:Shape; + + } +} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/7853ef15/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/HScrollBarTrackView.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/HScrollBarTrackView.as b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/HScrollBarTrackView.as new file mode 100644 index 0000000..de6a3af --- /dev/null +++ b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/HScrollBarTrackView.as @@ -0,0 +1,118 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +//////////////////////////////////////////////////////////////////////////////// +package org.apache.flex.html.beads +{ + import flash.display.DisplayObject; + import flash.display.Graphics; + import flash.display.Shape; + import flash.display.SimpleButton; + + import org.apache.flex.core.BeadViewBase; + import org.apache.flex.core.IBeadView; + import org.apache.flex.core.IStrand; + import org.apache.flex.events.Event; + + /** + * The HScrollBarTrackView class is the view for + * the track in a Horizontal ScrollBar. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public class HScrollBarTrackView extends BeadViewBase implements IBeadView + { + /** + * Constructor. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function HScrollBarTrackView() + { + } + + private function drawView(g:Graphics, bgColor:uint):void + { + var w:Number = SimpleButton(_strand).width; + + g.clear(); + g.lineStyle(1, 0x808080); + g.beginFill(bgColor); + g.drawRect(0, 0, w, ScrollBarView.FullSize); + g.endFill(); + g.lineStyle(0); + } + + private function widthChangeHandler(event:Event):void + { + DisplayObject(_strand).scaleY = 1.0; + DisplayObject(_strand).scaleX = 1.0; + + var w:Number = SimpleButton(_strand).width; + + drawView(upView.graphics, 0xf8f8f8); + drawView(downView.graphics, 0xd8d8d8); + drawView(overView.graphics, 0xe8e8e8); + shape.graphics.clear(); + shape.graphics.beginFill(0xCCCCCC); + shape.graphics.drawRect(0, 0, ScrollBarView.FullSize, w); + shape.graphics.endFill(); + + } + + private var shape:Shape; + + /** + * @copy org.apache.flex.core.IBead#strand + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + override public function set strand(value:IStrand):void + { + super.strand = value; + + upView = new Shape(); + downView = new Shape(); + overView = new Shape(); + + drawView(upView.graphics, 0xf8f8f8); + drawView(downView.graphics, 0xd8d8d8); + drawView(overView.graphics, 0xe8e8e8); + + SimpleButton(value).addEventListener("widthChanged", widthChangeHandler); + shape = new Shape(); + SimpleButton(value).upState = upView; + SimpleButton(value).downState = downView; + SimpleButton(value).overState = overView; + SimpleButton(value).hitTestState = shape; + } + + private var upView:Shape; + private var downView:Shape; + private var overView:Shape; + + } +} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/7853ef15/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/HScrollBarView.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/HScrollBarView.as b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/HScrollBarView.as new file mode 100644 index 0000000..68fe11f --- /dev/null +++ b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/HScrollBarView.as @@ -0,0 +1,99 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +//////////////////////////////////////////////////////////////////////////////// +package org.apache.flex.html.beads +{ + import flash.display.DisplayObject; + + import org.apache.flex.core.IBead; + import org.apache.flex.core.IBeadLayout; + import org.apache.flex.core.IBeadView; + import org.apache.flex.core.IScrollBarModel; + import org.apache.flex.core.IStrand; + import org.apache.flex.core.IUIBase; + import org.apache.flex.core.Strand; + import org.apache.flex.core.UIBase; + import org.apache.flex.core.ValuesManager; + import org.apache.flex.events.IEventDispatcher; + import org.apache.flex.events.Event; + import org.apache.flex.html.Button; + import org.apache.flex.html.beads.controllers.ButtonAutoRepeatController; + + /** + * The HScrollBarView class is the default view for + * the org.apache.flex.html.supportClasses.HScrollBar class. + * It implements the classic desktop-like HScrollBar. + * A different view would implement more modern scrollbars that hide themselves + * until hovered over with the mouse. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public class HScrollBarView extends ScrollBarView implements IBeadView, IStrand, IScrollBarView + { + /** + * Constructor. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function HScrollBarView() + { + } + + /** + * @copy org.apache.flex.core.IBead#strand + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + override public function set strand(value:IStrand):void + { + super.strand = value; + + UIBase(value).setHeight(ScrollBarView.FullSize, true); + + // TODO: (aharui) put in values impl + _increment = new Button(); + Button(_increment).addBead(new RightArrowButtonView()); + Button(_increment).addBead(new ButtonAutoRepeatController()); + _decrement = new Button(); + Button(_decrement).addBead(new LeftArrowButtonView()); + Button(_decrement).addBead(new ButtonAutoRepeatController()); + _track = new Button(); + Button(_track).addBead(new HScrollBarTrackView()); + _thumb = new Button(); + Button(_thumb).addBead(new HScrollBarThumbView()); + + UIBase(value).addChild(_decrement); + UIBase(value).addChild(_increment); + UIBase(value).addChild(_track); + UIBase(value).addChild(_thumb); + + IEventDispatcher(_strand).addEventListener("widthChanged", changeHandler); + + layout.layout(); + } + } +} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/7853ef15/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/IBackgroundBead.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/IBackgroundBead.as b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/IBackgroundBead.as new file mode 100644 index 0000000..2590a9a --- /dev/null +++ b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/IBackgroundBead.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 org.apache.flex.html.beads +{ + import org.apache.flex.core.IBead; + + /** + * The IBackgroundBead interface is a marker interface for beads + * that draw backgrounds. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public interface IBackgroundBead extends IBead + { + } +} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/7853ef15/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/IBorderBead.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/IBorderBead.as b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/IBorderBead.as new file mode 100644 index 0000000..3e4fc39 --- /dev/null +++ b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/IBorderBead.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 org.apache.flex.html.beads +{ + import org.apache.flex.core.IBead; + + /** + * The IBackgroundBead interface is a marker interface for beads + * that draw backgrounds. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public interface IBorderBead extends IBead + { + } +} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/7853ef15/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/IComboBoxView.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/IComboBoxView.as b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/IComboBoxView.as new file mode 100644 index 0000000..650d300 --- /dev/null +++ b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/IComboBoxView.as @@ -0,0 +1,78 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +//////////////////////////////////////////////////////////////////////////////// +package org.apache.flex.html.beads +{ + import org.apache.flex.core.IBeadView; + import org.apache.flex.core.IStrand; + + /** + * The IComboBoxView interface provides the protocol for any bead that + * creates the visual parts for a org.apache.flex.html.ComboBox control. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public interface IComboBoxView extends IBeadView + { + /** + * The string appearing in the input area for the ComboBox. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + function get text():String; + function set text(value:String):void; + + /** + * The HTML string appearing in the input area for the ComboBox. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + function get html():String; + function set html(value:String):void; + + /** + * The component housing the selection list. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + function get popUp():IStrand; + + /** + * Determines whether or not the pop-up with the selection list is visible or not. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + function get popUpVisible():Boolean; + function set popUpVisible(value:Boolean):void; + } +} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/7853ef15/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/IDataGridView.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/IDataGridView.as b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/IDataGridView.as new file mode 100644 index 0000000..8f04d11 --- /dev/null +++ b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/IDataGridView.as @@ -0,0 +1,36 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +//////////////////////////////////////////////////////////////////////////////// +package org.apache.flex.html.beads +{ + import org.apache.flex.core.IBeadView; + + /** + * The IDataGridView interface marks as a component as being the bead that + * can create the visual pieces for a org.apache.flex.html.DataGrid. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public interface IDataGridView extends IBeadView + { + + } +}
