http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/7853ef15/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/supportClasses/ButtonBarButtonItemRenderer.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/supportClasses/ButtonBarButtonItemRenderer.as b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/supportClasses/ButtonBarButtonItemRenderer.as new file mode 100644 index 0000000..64a9e43 --- /dev/null +++ b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/supportClasses/ButtonBarButtonItemRenderer.as @@ -0,0 +1,137 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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.supportClasses +{ + import org.apache.flex.core.IItemRenderer; + import org.apache.flex.core.IItemRendererParent; + import org.apache.flex.core.UIBase; + import org.apache.flex.events.Event; + import org.apache.flex.html.TextButton; + import org.apache.flex.html.beads.ITextItemRenderer; + + /** + * The ButtonBarButtonItemRenderer class handles the display of each item for the + * org.apache.flex.html.ButtonBar component. This class uses a + * org.apache.flex.html.Button to represent the data. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public class ButtonBarButtonItemRenderer extends UIItemRendererBase implements ITextItemRenderer + { + /** + * constructor. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function ButtonBarButtonItemRenderer() + { + super(); + } + + private var textButton:TextButton; + + /** + * @private + */ + override public function addedToParent():void + { + super.addedToParent(); + } + + /** + * @private + */ + private function handleClickEvent(event:Event):void + { + var parent:Object = itemRendererParent; + (parent as UIBase).dispatchEvent(new Event("selected", this)); + } + + /** + * The string version of the data associated with the instance of the itemRenderer. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get text():String + { + return data as String; + } + public function set text(value:String):void + { + data = value; + } + + /** + * The data to be displayed by the itemRenderer instance. For ButtonBarItemRenderer, the + * data's string version is used as the label for the Button. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + override public function set data(value:Object):void + { + super.data = value; + + var added:Boolean = false; + if (textButton == null) { + textButton = new TextButton(); + textButton.addEventListener('click',handleClickEvent); + added = true; + } + + var valueAsString:String; + + if (value is String) { + valueAsString = value as String; + } + else if (value.hasOwnProperty("label")) { + valueAsString = String(value["label"]); + } + else if (value.hasOwnProperty("title")) { + valueAsString = String(value["title"]); + } + + if (valueAsString) textButton.text = valueAsString; + + if (added) addElement(textButton); + } + + /** + * @private + */ + override public function adjustSize():void + { + textButton.width = this.width; + textButton.height = this.height; + + updateRenderer(); + } + } +}
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/7853ef15/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/supportClasses/ContainerContentArea.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/supportClasses/ContainerContentArea.as b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/supportClasses/ContainerContentArea.as new file mode 100644 index 0000000..bd0c016 --- /dev/null +++ b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/supportClasses/ContainerContentArea.as @@ -0,0 +1,80 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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.supportClasses +{ + import org.apache.flex.core.IContentView; + import org.apache.flex.core.UIBase; + import org.apache.flex.events.Event; + + /** + * The ContainerContentArea class implements the contentView for + * a Container. Container's don't always parent their children directly as + * that makes it harder to handle scrolling. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public class ContainerContentArea extends UIBase implements IContentView + { + /** + * Constructor. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function ContainerContentArea() + { + super(); + addEventListener("layoutNeeded", forwardEventHandler); + } + + private function forwardEventHandler(event:Event):void + { + if (parent) + parent.dispatchEvent(event); + } + + /** + * @copy org.apache.flex.core.IItemRendererParent#removeAllElements() + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function removeAllElements():void + { + COMPILE::AS3 + { + removeChildren(0); + } + COMPILE::JS + { + while (element.hasChildNodes()) + { + element.removeChild(element.lastChild); + } + } + } + } +} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/7853ef15/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/supportClasses/DataGridColumn.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/supportClasses/DataGridColumn.as b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/supportClasses/DataGridColumn.as new file mode 100644 index 0000000..24e16fd --- /dev/null +++ b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/supportClasses/DataGridColumn.as @@ -0,0 +1,127 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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.supportClasses +{ + import org.apache.flex.core.IFactory; + + /** + * The DataGridColumn class is the collection of properties that describe + * a column of the org.apache.flex.html.DataGrid: which renderer + * to use for each cell in the column, the width of the column, the label for the + * column, and the name of the field in the data containing the value to display + * in the column. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public class DataGridColumn + { + /** + * constructor. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function DataGridColumn() + { + } + + private var _itemRenderer:IFactory; + + /** + * The itemRenderer class or factory to use to make instances of itemRenderers for + * display of data. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get itemRenderer():IFactory + { + return _itemRenderer; + } + public function set itemRenderer(value:IFactory):void + { + _itemRenderer = value; + } + + private var _columnWidth:Number = Number.NaN; + + /** + * The width of the column (default is 100 pixels). + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get columnWidth():Number + { + return _columnWidth; + } + public function set columnWidth(value:Number):void + { + _columnWidth = value; + } + + private var _label:String; + + /** + * The label for the column (appears in the header area). + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get label():String + { + return _label; + } + public function set label(value:String):void + { + _label = value; + } + + private var _dataField:String; + + /** + * The name of the field containing the data value presented by the column. This value is used + * by the itemRenderer is select the property from the data. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get dataField():String + { + return _dataField; + } + public function set dataField(value:String):void + { + _dataField = value; + } + } +} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/7853ef15/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/supportClasses/DataGroup.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/supportClasses/DataGroup.as b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/supportClasses/DataGroup.as new file mode 100644 index 0000000..c156a6f --- /dev/null +++ b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/supportClasses/DataGroup.as @@ -0,0 +1,151 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +//////////////////////////////////////////////////////////////////////////////// +package org.apache.flex.html.supportClasses +{ + import org.apache.flex.core.IContentView; + import org.apache.flex.core.IItemRenderer; + import org.apache.flex.core.IItemRendererParent; + import org.apache.flex.core.IRollOverModel; + import org.apache.flex.core.IStrand; + import org.apache.flex.core.UIBase; + import org.apache.flex.events.IEventDispatcher; + import org.apache.flex.events.Event; + + /** + * The DataGroup class is the IItemRendererParent used internally + * by org.apache.flex.html.List class. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public class DataGroup extends ContainerContentArea implements IItemRendererParent, IContentView + { + /** + * Constructor. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function DataGroup() + { + super(); + } + + /** + * @private + */ + override public function addElement(c:Object, dispatchEvent:Boolean = true):void + { + super.addElement(c, dispatchEvent); + + var dispatcher:IEventDispatcher = c as IEventDispatcher; + dispatcher.addEventListener("itemRendererRollOver", handleRollOver); + dispatcher.addEventListener("itemRendererRollOut", handleRollOut); + } + + /** + * @private + */ + override public function removeElement(c:Object, dispatchEvent:Boolean = true):void + { + var dispatcher:IEventDispatcher = c as IEventDispatcher; + dispatcher.removeEventListener("itemRendererRollOver", handleRollOver); + dispatcher.removeEventListener("itemRendererRollOut", handleRollOut); + + super.removeElement(c, dispatchEvent); + } + + /** + * @private + */ + private function handleRollOver(event:Event):void + { + var strand:IStrand = parent as IStrand; + var rollModel:IRollOverModel = strand.getBeadByType(IRollOverModel) as IRollOverModel; + if (rollModel) { + var n:int = numElements; + for (var i:int=0; i < n; i++) { + var renderer:Object = getElementAt(i); + if (renderer == event.currentTarget) { + rollModel.rollOverIndex = i; + break; + } + } + } + } + + /** + * @private + */ + private function handleRollOut(event:Event):void + { + var strand:IStrand = parent as IStrand; + var rollModel:IRollOverModel = strand.getBeadByType(IRollOverModel) as IRollOverModel; + if (rollModel) { + var n:int = numElements; + for (var i:int=0; i < n; i++) { + var renderer:Object = getElementAt(i); + if (renderer == event.currentTarget) { + rollModel.rollOverIndex = -1; + break; + } + } + } + } + + /** + * @copy org.apache.flex.core.IItemRendererParent#getItemRendererForIndex() + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function getItemRendererForIndex(index:int):IItemRenderer + { + if (index < 0 || index >= numElements) return null; + return getElementAt(index) as IItemRenderer; + } + + /** + * Refreshes the itemRenderers. Useful after a size change by the data group. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function updateAllItemRenderers():void + { + var n:Number = numElements; + for (var i:Number = 0; i < n; i++) + { + var renderer:DataItemRenderer = getItemRendererForIndex(i) as DataItemRenderer; + if (renderer) { + renderer.setWidth(this.width,true); + renderer.adjustSize(); + } + } + } + } +} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/7853ef15/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/supportClasses/DataItemRenderer.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/supportClasses/DataItemRenderer.as b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/supportClasses/DataItemRenderer.as new file mode 100644 index 0000000..ac15dcf --- /dev/null +++ b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/supportClasses/DataItemRenderer.as @@ -0,0 +1,178 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +//////////////////////////////////////////////////////////////////////////////// +package org.apache.flex.html.supportClasses +{ + COMPILE::AS3 + { + import flash.display.Sprite; + } + COMPILE::JS + { + import org.apache.flex.core.WrappedHTMLElement; + import org.apache.flex.html.beads.controllers.ItemRendererMouseController; + } + + /** + * The DataItemRenderer class is the base class for most itemRenderers. This class + * extends org.apache.flex.html.supportClasses.UIItemRendererBase and + * includes row and column index values. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public class DataItemRenderer extends UIItemRendererBase + { + /** + * constructor. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function DataItemRenderer() + { + super(); + } + + private var _columnIndex:int; + + /** + * The index of the column the itemRenderer represents. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get columnIndex():int + { + return _columnIndex; + } + public function set columnIndex(value:int):void + { + _columnIndex = value; + } + + private var _rowIndex:int; + + /** + * The index of the row the itemRenderer represents. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get rowIndex():int + { + return _rowIndex; + } + public function set rowIndex(value:int):void + { + _rowIndex = value; + } + + private var _dataField:String; + + /** + * The name of the field within the data the itemRenderer should use. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get dataField():String + { + return _dataField; + } + public function set dataField(value:String):void + { + _dataField = value; + } + + COMPILE::AS3 + private var background:Sprite; + + COMPILE::JS + private var controller:ItemRendererMouseController; + + /** + * @private + */ + COMPILE::AS3 + override public function addedToParent():void + { + super.addedToParent(); + + background = new Sprite(); + addChild(background); + } + + /** + * @private + */ + override public function updateRenderer():void + { + COMPILE::AS3 + { + super.updateRenderer(); + + background.graphics.clear(); + background.graphics.beginFill(useColor, (down||selected||hovered)?1:0); + background.graphics.drawRect(0, 0, width, height); + background.graphics.endFill(); + } + COMPILE::JS + { + if (selected) + element.style.backgroundColor = '#9C9C9C'; + else if (hovered) + element.style.backgroundColor = '#ECECEC'; + else + element.style.backgroundColor = null; + } + } + + /** + * @flexjsignorecoercion org.apache.flex.core.WrappedHTMLElement + * + */ + COMPILE::JS + override protected function createElement():WrappedHTMLElement + { + element = document.createElement('div') as WrappedHTMLElement; + positioner = element; + positioner.style.position = 'relative'; + + element.flexjs_wrapper = this; + className = 'DataItemRenderer'; + + controller = new ItemRendererMouseController(); + controller.strand = this; + + return element; + } + + + } +} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/7853ef15/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/supportClasses/DateChooserButton.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/supportClasses/DateChooserButton.as b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/supportClasses/DateChooserButton.as new file mode 100644 index 0000000..2d80b2f --- /dev/null +++ b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/supportClasses/DateChooserButton.as @@ -0,0 +1,67 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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.supportClasses +{ + import org.apache.flex.html.TextButton; + + /** + * The DateChooserButton class is used for each button in the DateChooser. The + * button holds the day of the month the button is representing. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public class DateChooserButton extends TextButton + { + /** + * constructor. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function DateChooserButton() + { + super(); + className = "DateChooserButton"; + } + + private var _dayOfMonth:int; + + /** + * The day of the month the button represents. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get dayOfMonth():int + { + return _dayOfMonth; + } + public function set dayOfMonth(value:int):void + { + _dayOfMonth = value; + } + } +} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/7853ef15/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/supportClasses/DropDownListList.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/supportClasses/DropDownListList.as b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/supportClasses/DropDownListList.as new file mode 100644 index 0000000..6bc1d43 --- /dev/null +++ b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/supportClasses/DropDownListList.as @@ -0,0 +1,63 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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.supportClasses +{ + import org.apache.flex.core.IPopUp; + import org.apache.flex.html.SimpleList; + import org.apache.flex.html.beads.SolidBackgroundBead; + + //-------------------------------------- + // Events + //-------------------------------------- + + /** + * @copy org.apache.flex.core.ISelectionModel#change + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + [Event(name="change", type="org.apache.flex.events.Event")] + + /** + * The DropDownListList class is the List class used internally + * by DropDownList as the dropdown/popup. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public class DropDownListList extends SimpleList implements IPopUp + { + /** + * Constructor. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function DropDownListList() + { + super(); + } + } +} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/7853ef15/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/supportClasses/GraphicsItemRenderer.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/supportClasses/GraphicsItemRenderer.as b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/supportClasses/GraphicsItemRenderer.as new file mode 100644 index 0000000..4d90c03 --- /dev/null +++ b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/supportClasses/GraphicsItemRenderer.as @@ -0,0 +1,295 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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.supportClasses +{ + import org.apache.flex.core.ISelectableItemRenderer; + import org.apache.flex.core.ValuesManager; + import org.apache.flex.core.graphics.GraphicsContainer; + import org.apache.flex.events.Event; + import org.apache.flex.utils.MXMLDataInterpreter; + + /** + * The GraphicsItemRenderer provides a base class for itemRenderers that use graphics rather than + * components. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public class GraphicsItemRenderer extends GraphicsContainer implements ISelectableItemRenderer + { + /** + * Constructor. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function GraphicsItemRenderer() + { + super(); + } + + /** + * @private + */ + override public function addedToParent():void + { + super.addedToParent(); + + // very common for item renderers to be resized by their containers, + addEventListener("widthChanged", sizeChangeHandler); + addEventListener("heightChanged", sizeChangeHandler); + + // each MXML file can also have styles in fx:Style block + ValuesManager.valuesImpl.init(this); + + MXMLDataInterpreter.generateMXMLProperties(this, mxmlProperties); + MXMLDataInterpreter.generateMXMLInstances(this, this, MXMLDescriptor); + + dispatchEvent(new Event("initBindings")); + dispatchEvent(new Event("initComplete")); + + } + + private var _labelField:String = "label"; + + /** + * The name of the field within the data to use as a label. Some itemRenderers use this field to + * identify the value they should show while other itemRenderers ignore this if they are showing + * complex information. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get labelField():String + { + return _labelField; + } + public function set labelField(value:String):void + { + _labelField = value; + } + + private var _index:int; + + /** + * The position with the dataProvider being shown by the itemRenderer instance. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get index():int + { + return _index; + } + public function set index(value:int):void + { + _index = value; + } + + private var _selected:Boolean; + + /** + * Whether or not the itemRenderer is in a selected state. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get selected():Boolean + { + return _selected; + } + public function set selected(value:Boolean):void + { + _selected = value; + updateRenderer(); + } + + private var _hovered:Boolean; + + /** + * Whether or not the itemRenderer is in a hovered state. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get hovered():Boolean + { + return _hovered; + } + public function set hovered(value:Boolean):void + { + _hovered = value; + updateRenderer(); + } + + private var _down:Boolean; + + /** + * Whether or not the itemRenderer is in a down (or pre-selected) state. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get down():Boolean + { + return _down; + } + public function set down(value:Boolean):void + { + _down = value; + updateRenderer(); + } + + private var _data:Object; + + [Bindable("__NoChangeEvent__")] + /** + * The data being represented by this itemRenderer. This can be something simple like a String or + * a Number or something very complex. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get data():Object + { + return _data; + } + public function set data(value:Object):void + { + _data = value; + } + + private var _dataField:String; + + /** + * The name of the field within the data the itemRenderer should use. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get dataField():String + { + return _dataField; + } + public function set dataField(value:String):void + { + _dataField = value; + } + + private var _itemRendererParent:Object; + + /** + * The parent container for the itemRenderer instance. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get itemRendererParent():Object + { + return _itemRendererParent; + } + public function set itemRendererParent(value:Object):void + { + _itemRendererParent = value; + } + + /** + * @private + */ + public function updateRenderer():void + { +// if (down) +// backgroundColor = downColor; +// else if (hovered) +// backgroundColor = highlightColor; +// else if (selected) +// backgroundColor = selectedColor; + } + + /** + * @copy org.apache.flex.core.ItemRendererClassFactory#mxmlContent + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public var mxmlContent:Array; + + /** + * @private + */ + public function get MXMLDescriptor():Array + { + return null; + } + + private var mxmlProperties:Array ; + + /** + * @private + */ + public function generateMXMLAttributes(data:Array):void + { + mxmlProperties = data; + } + + /** + * @private + */ + private function sizeChangeHandler(event:Event):void + { + adjustSize(); + } + + /** + * This function is called whenever the itemRenderer changes size. Sub-classes should override + * this method an handle the size change. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function adjustSize():void + { + // handle in subclass + } + } +} \ 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/supportClasses/HScrollBar.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/supportClasses/HScrollBar.as b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/supportClasses/HScrollBar.as new file mode 100644 index 0000000..0b56925 --- /dev/null +++ b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/supportClasses/HScrollBar.as @@ -0,0 +1,49 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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.supportClasses +{ + import org.apache.flex.core.IChrome; + import org.apache.flex.core.IViewportScroller; + + /** + * The ScrollBar class represents either a vertical or horizontal control + * that allows the user to quickly scan through a component that does not + * wholly fit within its container. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public class HScrollBar extends ScrollBar implements IChrome, IViewportScroller + { + /** + * constructor. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function HScrollBar() + { + super(); + } + } +} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/7853ef15/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/supportClasses/ScrollBar.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/supportClasses/ScrollBar.as b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/supportClasses/ScrollBar.as new file mode 100644 index 0000000..0bef2e6 --- /dev/null +++ b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/supportClasses/ScrollBar.as @@ -0,0 +1,50 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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.supportClasses +{ + import org.apache.flex.core.UIBase; + import org.apache.flex.core.IChrome; + import org.apache.flex.core.IViewportScroller; + + /** + * The ScrollBar class represents either a vertical or horizontal control + * that allows the user to quickly scan through a component that does not + * wholly fit within its container. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public class ScrollBar extends UIBase implements IChrome, IViewportScroller + { + /** + * constructor. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function ScrollBar() + { + super(); + } + } +} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/7853ef15/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/supportClasses/ScrollingViewport.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/supportClasses/ScrollingViewport.as b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/supportClasses/ScrollingViewport.as new file mode 100644 index 0000000..395fea0 --- /dev/null +++ b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/supportClasses/ScrollingViewport.as @@ -0,0 +1,351 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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.supportClasses +{ + COMPILE::AS3 + { + import flash.geom.Rectangle; + } + import org.apache.flex.core.IBead; + import org.apache.flex.core.IBeadLayout; + import org.apache.flex.core.IContentViewHost; + import org.apache.flex.core.IParentIUIBase; + import org.apache.flex.core.IStrand; + import org.apache.flex.core.IUIBase; + import org.apache.flex.core.IViewport; + import org.apache.flex.core.IViewportModel; + COMPILE::AS3 + { + import org.apache.flex.core.IViewportScroller; + } + import org.apache.flex.core.UIBase; + import org.apache.flex.events.Event; + import org.apache.flex.geom.Size; + import org.apache.flex.html.beads.ScrollBarView; + import org.apache.flex.html.beads.models.ScrollBarModel; + + /** + * The ScrollingViewport extends the Viewport class by adding horizontal and + * vertical scroll bars, if needed, to the content area of a Container. In + * addition, the content of the Container is clipped so that items extending + * outside the Container are hidden and reachable only by scrolling. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public class ScrollingViewport extends Viewport implements IBead, IViewport + { + /** + * Constructor + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function ScrollingViewport() + { + } + + COMPILE::AS3 + private var _verticalScroller:ScrollBar; + + COMPILE::AS3 + public function get verticalScroller():IViewportScroller + { + return _verticalScroller; + } + + COMPILE::AS3 + private var _horizontalScroller:ScrollBar + + COMPILE::AS3 + public function get horizontalScroller():IViewportScroller + { + return _horizontalScroller; + } + + COMPILE::AS3 + private var _verticalScrollPosition:Number = 0; + + public function get verticalScrollPosition():Number + { + COMPILE::AS3 + { + return _verticalScrollPosition; + } + COMPILE::JS + { + return this.contentView.positioner.scrollTop; + } + } + public function set verticalScrollPosition(value:Number):void + { + COMPILE::AS3 + { + _verticalScrollPosition = value; + handleVerticalScrollChange(); + } + COMPILE::JS + { + this.contentView.positioner.scrollTop = value; + } + } + + COMPILE::AS3 + private var _horizontalScrollPosition:Number = 0; + + public function get horizontalScrollPosition():Number + { + COMPILE::AS3 + { + return _horizontalScrollPosition; + } + COMPILE::JS + { + return this.contentView.positioner.scrollLeft; + } + } + public function set horizontalScrollPosition(value:Number):void + { + COMPILE::AS3 + { + _horizontalScrollPosition = value; + handleHorizontalScrollChange(); + } + COMPILE::JS + { + this.contentView.positioner.scrollLeft = value; + } + } + + COMPILE::JS + override public function set strand(value:IStrand):void + { + super.strand = value; + contentView.element.style.overflow = 'auto'; + } + + private var viewportWidth:Number; + private var viewportHeight:Number; + + /** + * @copy org.apache.flex.core.IViewport + */ + override public function layoutViewportBeforeContentLayout(width:Number, height:Number):void + { + super.layoutViewportBeforeContentLayout(width, height); + viewportWidth = width; + viewportHeight = height; + } + + /** + * @copy org.apache.flex.core.IViewport + */ + override public function layoutViewportAfterContentLayout():Size + { + COMPILE::AS3 + { + var hadV:Boolean = _verticalScroller != null && _verticalScroller.visible; + var hadH:Boolean = _horizontalScroller != null && _horizontalScroller.visible; + var contentSize:Size; + do + { + contentSize = super.layoutViewportAfterContentLayout(); + if (isNaN(viewportHeight)) + viewportHeight = contentSize.height; + if (isNaN(viewportWidth)) + viewportWidth = contentSize.width; + + var host:UIBase = UIBase(_strand); + var visibleWidth:Number; + var visibleHeight:Number; + var needV:Boolean = contentSize.height > viewportHeight; + var needH:Boolean = contentSize.width > viewportWidth; + + if (needV) + { + if (_verticalScroller == null) { + _verticalScroller = createVerticalScrollBar(); + (host as IContentViewHost).strandChildren.addElement(_verticalScroller); + } + } + if (needH) + { + if (_horizontalScroller == null) { + _horizontalScroller = createHorizontalScrollBar(); + (host as IContentViewHost).strandChildren.addElement(_horizontalScroller); + } + } + + if (needV) + { + _verticalScroller.visible = true; + _verticalScroller.x = contentArea.x + viewportWidth - _verticalScroller.width; + _verticalScroller.y = contentArea.y; + _verticalScroller.setHeight(viewportHeight - (needH ? _horizontalScroller.height : 0), true); + visibleWidth = _verticalScroller.x; + } + else if (_verticalScroller) + _verticalScroller.visible = false; + + if (needH) + { + _horizontalScroller.visible = true; + _horizontalScroller.x = contentArea.x; + _horizontalScroller.y = contentArea.y + viewportHeight - _horizontalScroller.height; + _horizontalScroller.setWidth(viewportWidth - (needV ? _verticalScroller.width : 0), true); + visibleHeight = _horizontalScroller.y; + } + + var needsLayout:Boolean = false; + // resize content area if needed to get out from under scrollbars + if (!isNaN(visibleWidth) || !isNaN(visibleHeight)) + { + if (!isNaN(visibleWidth)) + needsLayout = visibleWidth != contentView.width; + if (!isNaN(visibleHeight)) + needsLayout = visibleHeight != contentView.height; + if (!isNaN(visibleWidth) && !isNaN(visibleHeight)) + contentArea.setWidthAndHeight(visibleWidth, visibleHeight, false); + else if (!isNaN(visibleWidth)) + contentArea.setWidth(visibleWidth, false); + else if (!isNaN(visibleHeight)) + contentArea.setHeight(visibleHeight, false); + } + if (needsLayout) + { + var layout:IBeadLayout = host.getBeadByType(IBeadLayout) as IBeadLayout; + layout.layout(); + } + } while (needsLayout && (needV != hadV || needH == hadH)); + if (_verticalScroller) + { + ScrollBarModel(_verticalScroller.model).maximum = contentSize.height; + ScrollBarModel(_verticalScroller.model).pageSize = contentArea.height; + ScrollBarModel(_verticalScroller.model).pageStepSize = contentArea.height; + if (contentSize.height > contentArea.height && + (contentSize.height - contentArea.height) < _verticalScrollPosition) + _verticalScrollPosition = contentSize.height - contentArea.height; + } + if (_horizontalScroller) + { + ScrollBarModel(_horizontalScroller.model).maximum = contentSize.width; + ScrollBarModel(_horizontalScroller.model).pageSize = contentArea.width; + ScrollBarModel(_horizontalScroller.model).pageStepSize = contentArea.width; + if (contentSize.width > contentArea.width && + (contentSize.width - contentArea.width) < _horizontalScrollPosition) + _horizontalScrollPosition = contentSize.width - contentArea.width; + } + + var rect:Rectangle = new Rectangle(_horizontalScrollPosition, _verticalScrollPosition, + (_verticalScroller != null && _verticalScroller.visible) ? + _verticalScroller.x : viewportWidth, + (_horizontalScroller != null && _horizontalScroller.visible) ? + _horizontalScroller.y : viewportHeight); + contentArea.scrollRect = rect; + return contentSize; + + } + COMPILE::JS + { + return new Size(contentView.width, contentView.height); + } + + } + + COMPILE::AS3 + private function createVerticalScrollBar():ScrollBar + { + var vsbm:ScrollBarModel = new ScrollBarModel(); + vsbm.minimum = 0; + vsbm.snapInterval = 1; + vsbm.stepSize = 1; + vsbm.value = 0; + + var vsb:VScrollBar; + vsb = new VScrollBar(); + vsb.model = vsbm; + vsb.visible = false; + + vsb.addEventListener("scroll",handleVerticalScroll); + return vsb; + } + + COMPILE::AS3 + private function createHorizontalScrollBar():ScrollBar + { + var hsbm:ScrollBarModel = new ScrollBarModel(); + hsbm.minimum = 0; + hsbm.snapInterval = 1; + hsbm.stepSize = 1; + hsbm.value = 0; + + var hsb:HScrollBar; + hsb = new HScrollBar(); + hsb.model = hsbm; + hsb.visible = false; + + hsb.addEventListener("scroll",handleHorizontalScroll); + return hsb; + } + + COMPILE::AS3 + private function handleVerticalScroll(event:Event):void + { + var host:UIBase = UIBase(_strand); + var vpos:Number = ScrollBarModel(_verticalScroller.model).value; + var rect:Rectangle = contentArea.scrollRect; + rect.y = vpos; + contentArea.scrollRect = rect; + + _verticalScrollPosition = vpos; + } + + COMPILE::AS3 + private function handleHorizontalScroll(event:Event):void + { + var host:UIBase = UIBase(_strand); + var hpos:Number = ScrollBarModel(_horizontalScroller.model).value; + var rect:Rectangle = contentArea.scrollRect; + rect.x = hpos; + contentArea.scrollRect = rect; + + _horizontalScrollPosition = hpos; + } + + COMPILE::AS3 + private function handleVerticalScrollChange():void + { + if (_verticalScroller) { + ScrollBarModel(_verticalScroller.model).value = verticalScrollPosition; + } + } + + COMPILE::AS3 + private function handleHorizontalScrollChange():void + { + if (_horizontalScroller) { + ScrollBarModel(_horizontalScroller.model).value = horizontalScrollPosition; + } + } + } +} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/7853ef15/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/supportClasses/StringItemRenderer.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/supportClasses/StringItemRenderer.as b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/supportClasses/StringItemRenderer.as new file mode 100644 index 0000000..9568932 --- /dev/null +++ b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/supportClasses/StringItemRenderer.as @@ -0,0 +1,183 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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.supportClasses +{ + COMPILE::AS3 + { + import flash.text.TextFieldAutoSize; + import flash.text.TextFieldType; + + import org.apache.flex.core.CSSTextField; + } + COMPILE::JS + { + import org.apache.flex.core.WrappedHTMLElement; + import org.apache.flex.html.beads.controllers.ItemRendererMouseController; + } + import org.apache.flex.events.Event; + import org.apache.flex.html.beads.ITextItemRenderer; + + /** + * The StringItemRenderer class displays data in string form using the data's toString() + * function. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public class StringItemRenderer extends DataItemRenderer implements ITextItemRenderer + { + /** + * constructor. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function StringItemRenderer() + { + super(); + + COMPILE::AS3 + { + textField = new CSSTextField(); + textField.type = TextFieldType.DYNAMIC; + textField.autoSize = TextFieldAutoSize.LEFT; + textField.selectable = false; + textField.parentDrawsBackground = true; + } + } + + COMPILE::AS3 + public var textField:CSSTextField; + + /** + * @private + */ + COMPILE::AS3 + override public function addedToParent():void + { + super.addedToParent(); + + addChild(textField); + + adjustSize(); + } + + /** + * @private + */ + COMPILE::AS3 + override public function adjustSize():void + { + var cy:Number = height/2; + + textField.x = 0; + textField.y = cy - textField.height/2; + textField.width = width; + + updateRenderer(); + } + + /** + * The text currently displayed by the itemRenderer instance. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get text():String + { + COMPILE::AS3 + { + return textField.text; + } + COMPILE::JS + { + return this.element.innerHTML; + } + } + + public function set text(value:String):void + { + COMPILE::AS3 + { + textField.text = value; + } + COMPILE::JS + { + this.element.innerHTML = value; + } + } + + /** + * Sets the data value and uses the String version of the data for display. + * + * @param Object data The object being displayed by the itemRenderer instance. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + override public function set data(value:Object):void + { + super.data = value; + var text:String; + if (labelField) text = String(value[labelField]); + else if (dataField) text = String(value[dataField]); + else text = String(value); + + this.text = text; + } + + COMPILE::JS + private var controller:ItemRendererMouseController; + + COMPILE::JS + private var backgroundView:WrappedHTMLElement; + + /** + * @flexjsignorecoercion org.apache.flex.core.WrappedHTMLElement + */ + COMPILE::JS + override protected function createElement():WrappedHTMLElement + { + element = document.createElement('div') as WrappedHTMLElement; + positioner = element; + positioner.style.position = 'relative'; + + element.flexjs_wrapper = this; + className = 'StringItemRenderer'; + + // itemRenderers should provide something for the background to handle + // the selection and highlight + backgroundView = element; + + controller = new ItemRendererMouseController(); + controller.strand = this; + + return element; + } + + } +} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/7853ef15/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/supportClasses/TextFieldItemRenderer.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/supportClasses/TextFieldItemRenderer.as b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/supportClasses/TextFieldItemRenderer.as new file mode 100644 index 0000000..a19fc2f --- /dev/null +++ b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/supportClasses/TextFieldItemRenderer.as @@ -0,0 +1,541 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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.supportClasses +{ + import flash.text.TextFieldType; + + import org.apache.flex.core.CSSTextField; + import org.apache.flex.core.IBead; + import org.apache.flex.core.IBeadController; + import org.apache.flex.core.IFlexJSElement; + 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.events.MouseEvent; + import org.apache.flex.events.utils.MouseEventConverter; + import org.apache.flex.geom.Rectangle; + import org.apache.flex.html.beads.ITextItemRenderer; + import org.apache.flex.utils.CSSContainerUtils; + + /** + * The TextFieldItemRenderer class provides a org.apache.flex.html.TextField as an itemRenderer. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public class TextFieldItemRenderer extends CSSTextField implements ITextItemRenderer, IStrand, IUIBase, IFlexJSElement + { + /** + * constructor. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function TextFieldItemRenderer() + { + super(); + type = TextFieldType.DYNAMIC; + selectable = false; + + MouseEventConverter.setupInstanceConverters(this); + } + + public var highlightColor:uint = 0xCEDBEF; + public var selectedColor:uint = 0xA8C6EE; + public var downColor:uint = 0x808080; + + private var _explicitWidth:Number; + + /** + * The explicitly set width (as opposed to measured width + * or percentage width). + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get explicitWidth():Number + { + if (isNaN(_explicitWidth)) + { + var value:* = ValuesManager.valuesImpl.getValue(this, "width"); + if (value !== undefined) { + _explicitWidth = Number(value); + } + } + + return _explicitWidth; + } + + /** + * @private + */ + public function set explicitWidth(value:Number):void + { + if (_explicitWidth == value) + return; + + // width can be pixel or percent not both + if (!isNaN(value)) + _percentWidth = NaN; + + _explicitWidth = value; + + dispatchEvent(new Event("explicitWidthChanged")); + } + + private var _explicitHeight:Number; + + /** + * The explicitly set width (as opposed to measured width + * or percentage width). + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get explicitHeight():Number + { + if (isNaN(_explicitHeight)) + { + var value:* = ValuesManager.valuesImpl.getValue(this, "height"); + if (value !== undefined) { + _explicitHeight = Number(value); + } + } + + return _explicitHeight; + } + + /** + * @private + */ + public function set explicitHeight(value:Number):void + { + if (_explicitHeight == value) + return; + + // height can be pixel or percent not both + if (!isNaN(value)) + _percentHeight = NaN; + + _explicitHeight = value; + + dispatchEvent(new Event("explicitHeightChanged")); + } + + private var _percentWidth:Number; + + /** + * The requested percentage width this component + * should have in the parent container. Note that + * the actual percentage may be different if the + * total is more than 100% or if there are other + * components with explicitly set widths. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get percentWidth():Number + { + return _percentWidth; + } + + /** + * @private + */ + public function set percentWidth(value:Number):void + { + if (_percentWidth == value) + return; + + if (!isNaN(value)) + _explicitWidth = NaN; + + _percentWidth = value; + + dispatchEvent(new Event("percentWidthChanged")); + } + + private var _percentHeight:Number; + + /** + * The requested percentage height this component + * should have in the parent container. Note that + * the actual percentage may be different if the + * total is more than 100% or if there are other + * components with explicitly set heights. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get percentHeight():Number + { + return _percentHeight; + } + + /** + * @private + */ + public function set percentHeight(value:Number):void + { + if (_percentHeight == value) + return; + + if (!isNaN(value)) + _explicitHeight = NaN; + + _percentHeight = value; + + dispatchEvent(new Event("percentHeightChanged")); + } + + private var _width:Number; + + /** + * @private + */ + override public function get width():Number + { + if (isNaN(explicitWidth)) + { + var w:Number = _width; + if (isNaN(w)) w = $width; + var metrics:Rectangle = CSSContainerUtils.getBorderAndPaddingMetrics(this); + return w + metrics.left + metrics.right; + } + else + return explicitWidth; + } + override public function set width(value:Number):void + { + if (explicitWidth != value) + { + explicitWidth = value; + } + + if (value != _width) { + _width = value; + dispatchEvent( new Event("widthChanged") ); + } + } + + /** + * @private + */ + protected function get $width():Number + { + return super.width; + } + + private var _height:Number; + + /** + * @private + */ + override public function get height():Number + { + if (isNaN(explicitHeight)) + { + var h:Number = _height; + if (isNaN(h)) h = $height; + var metrics:Rectangle = CSSContainerUtils.getBorderAndPaddingMetrics(this); + return h + metrics.top + metrics.bottom; + } + else + return explicitHeight; + } + + override public function set height(value:Number):void + { + if (explicitHeight != value) + { + explicitHeight = value; + } + + if (_height != value) { + _height = value; + dispatchEvent(new Event("heightChanged")); + } + } + + /** + * @private + */ + protected function get $height():Number + { + return super.height; + } + + /** + * The String(data) for the itemRenderer instance. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get data():Object + { + return text; + } + public function set data(value:Object):void + { + text = String(value); + } + + /** + * @private + */ + public function get labelField():String + { + return null; + } + public function set labelField(value:String):void + { + // nothing to do for this + } + + private var _index:int; + + /** + * An index value for the itemRenderer corresponding the data's position with its dataProvider. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get index():int + { + return _index; + } + public function set index(value:int):void + { + _index = value; + } + + private var _hovered:Boolean; + + /** + * Returns whether or not the itemRenderer is a "hovered" state. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get hovered():Boolean + { + return _hovered; + } + public function set hovered(value:Boolean):void + { + _hovered = value; + updateRenderer(); + } + + private var _selected:Boolean; + + /** + * Whether or not the itemRenderer should be represented in a selected state. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get selected():Boolean + { + return _selected; + } + public function set selected(value:Boolean):void + { + _selected = value; + updateRenderer(); + } + + private var _down:Boolean; + + /** + * Whether or not the itemRenderer should be represented in a down (or pre-selected) state. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get down():Boolean + { + return _down; + } + public function set down(value:Boolean):void + { + _down = value; + updateRenderer(); + } + + private var _itemRendererParent:Object; + + /** + * The parent component of the itemRenderer instance. This is the container that houses + * all of the itemRenderers. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get itemRendererParent():Object + { + return _itemRendererParent; + } + public function set itemRendererParent(value:Object):void + { + _itemRendererParent = value; + } + + /** + * @private + */ + public function updateRenderer():void + { + background = (down || selected || hovered); + if (down) + backgroundColor = downColor; + else if (hovered) + backgroundColor = highlightColor; + else if (selected) + backgroundColor = selectedColor; + } + + /** + * @private + */ + public function get element():IFlexJSElement + { + return this; + } + + // beads declared in MXML are added to the strand. + // from AS, just call addBead() + public var beads:Array; + + private var _beads:Vector.<IBead>; + + /** + * @private + */ + public function addBead(bead:IBead):void + { + if (!_beads) + _beads = new Vector.<IBead>; + _beads.push(bead); + bead.strand = this; + } + + /** + * @private + */ + public function getBeadByType(classOrInterface:Class):IBead + { + for each (var bead:IBead in _beads) + { + if (bead is classOrInterface) + return bead; + } + return null; + } + + /** + * @private + */ + public function removeBead(value:IBead):IBead + { + var n:int = _beads.length; + for (var i:int = 0; i < n; i++) + { + var bead:IBead = _beads[i]; + if (bead == value) + { + _beads.splice(i, 1); + return bead; + } + } + return null; + } + + /** + * @private + */ + public function addedToParent():void + { + var c:Class; + + for each (var bead:IBead in beads) + addBead(bead); + + dispatchEvent(new Event("beadsAdded")); + + // renderer has a default model (the 'data' property) + // and it is essentially a view of that model, so it + // only needs an assignable controller + + if (getBeadByType(IBeadController) == null) + { + c = ValuesManager.valuesImpl.getValue(this, "iBeadController") as Class; + if (c) + { + var controller:IBeadController = new c as IBeadController; + if (controller) + addBead(controller); + } + } + } + + /** + * @copy org.apache.flex.core.IUIBase#topMostEventDispatcher + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get topMostEventDispatcher():IEventDispatcher + { + if (!parent) + return null; + return IUIBase(parent).topMostEventDispatcher; + } + + } +} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/7853ef15/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/supportClasses/UIItemRendererBase.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/supportClasses/UIItemRendererBase.as b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/supportClasses/UIItemRendererBase.as new file mode 100644 index 0000000..90c66fa --- /dev/null +++ b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/supportClasses/UIItemRendererBase.as @@ -0,0 +1,282 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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.supportClasses +{ + import org.apache.flex.core.ISelectableItemRenderer; + import org.apache.flex.core.UIBase; + import org.apache.flex.core.ValuesManager; + import org.apache.flex.events.Event; + import org.apache.flex.utils.MXMLDataInterpreter; + + [DefaultProperty("mxmlContent")] + + /** + * The UIItemRendererBase class is the base class for all itemRenderers. An itemRenderer is used to + * display a single datum within a collection of data. Components such as a List use itemRenderers to + * show their dataProviders. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public class UIItemRendererBase extends UIBase implements ISelectableItemRenderer + { + /** + * constructor. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function UIItemRendererBase() + { + } + + /** + * @private + */ + override public function addedToParent():void + { + super.addedToParent(); + + // very common for item renderers to be resized by their containers, + addEventListener("widthChanged", sizeChangeHandler); + addEventListener("heightChanged", sizeChangeHandler); + addEventListener("sizeChanged", sizeChangeHandler); + + // each MXML file can also have styles in fx:Style block + ValuesManager.valuesImpl.init(this); + + MXMLDataInterpreter.generateMXMLProperties(this, mxmlProperties); + MXMLDataInterpreter.generateMXMLInstances(this, this, MXMLDescriptor); + + dispatchEvent(new Event("initBindings")); + dispatchEvent(new Event("initComplete")); + + } + + private var _itemRendererParent:Object; + + /** + * The parent container for the itemRenderer instance. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get itemRendererParent():Object + { + return _itemRendererParent; + } + public function set itemRendererParent(value:Object):void + { + _itemRendererParent = value; + } + + /** + * @copy org.apache.flex.core.ItemRendererClassFactory#mxmlContent + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public var mxmlContent:Array; + + /** + * @private + */ + public function get MXMLDescriptor():Array + { + return null; + } + + private var mxmlProperties:Array ; + + /** + * @private + */ + public function generateMXMLAttributes(data:Array):void + { + mxmlProperties = data; + } + + public var backgroundColor:uint = 0xFFFFFF; + public var highlightColor:uint = 0xCEDBEF; + public var selectedColor:uint = 0xA8C6EE; + public var downColor:uint = 0x808080; + protected var useColor:uint = backgroundColor; + + private var _data:Object; + + [Bindable("__NoChangeEvent__")] + /** + * The data being represented by this itemRenderer. This can be something simple like a String or + * a Number or something very complex. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get data():Object + { + return _data; + } + public function set data(value:Object):void + { + _data = value; + } + + private var _labelField:String = "label"; + + /** + * The name of the field within the data to use as a label. Some itemRenderers use this field to + * identify the value they should show while other itemRenderers ignore this if they are showing + * complex information. + */ + public function get labelField():String + { + return _labelField; + } + public function set labelField(value:String):void + { + _labelField = value; + } + + private var _index:int; + + /** + * The position with the dataProvider being shown by the itemRenderer instance. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get index():int + { + return _index; + } + public function set index(value:int):void + { + _index = value; + } + + private var _hovered:Boolean; + + /** + * Whether or not the itemRenderer is in a hovered state. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get hovered():Boolean + { + return _hovered; + } + public function set hovered(value:Boolean):void + { + _hovered = value; + updateRenderer(); + } + + private var _selected:Boolean; + + /** + * Whether or not the itemRenderer is in a selected state. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get selected():Boolean + { + return _selected; + } + public function set selected(value:Boolean):void + { + _selected = value; + updateRenderer(); + } + + private var _down:Boolean; + + /** + * Whether or not the itemRenderer is in a down (or pre-selected) state. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get down():Boolean + { + return _down; + } + public function set down(value:Boolean):void + { + _down = value; + updateRenderer(); + } + + /** + * @private + */ + public function updateRenderer():void + { + if (down) + useColor = downColor; + else if (hovered) + useColor = highlightColor; + else if (selected) + useColor = selectedColor; + else + useColor = backgroundColor; + } + + /** + * @private + */ + private function sizeChangeHandler(event:Event):void + { + adjustSize(); + } + + /** + * This function is called whenever the itemRenderer changes size. Sub-classes should override + * this method an handle the size change. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function adjustSize():void + { + // handle in subclass + } + } +} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/7853ef15/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/supportClasses/VScrollBar.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/supportClasses/VScrollBar.as b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/supportClasses/VScrollBar.as new file mode 100644 index 0000000..a72c64c --- /dev/null +++ b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/supportClasses/VScrollBar.as @@ -0,0 +1,49 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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.supportClasses +{ + import org.apache.flex.core.IChrome; + import org.apache.flex.core.IViewportScroller; + + /** + * The ScrollBar class represents either a vertical or horizontal control + * that allows the user to quickly scan through a component that does not + * wholly fit within its container. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public class VScrollBar extends ScrollBar implements IChrome, IViewportScroller + { + /** + * constructor. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function VScrollBar() + { + super(); + } + } +}