http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/7853ef15/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/HRule.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/HRule.as b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/HRule.as new file mode 100644 index 0000000..7c2fb2f --- /dev/null +++ b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/HRule.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 +{ + import org.apache.flex.core.UIBase; + COMPILE::JS + { + import org.apache.flex.core.WrappedHTMLElement; + } + + /** + * The HRule class displays a horizontal line + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public class HRule extends UIBase + { + /** + * Constructor. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function HRule() + { + super(); + } + + /** + * @flexjsignorecoercion org.apache.flex.core.WrappedHTMLElement + */ + COMPILE::JS + override protected function createElement():WrappedHTMLElement + { + element = document.createElement('hr') as WrappedHTMLElement; + positioner = element; + positioner.style.position = 'relative'; + element.flexjs_wrapper = 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/Image.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/Image.as b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/Image.as new file mode 100644 index 0000000..ae81c18 --- /dev/null +++ b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/Image.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 +{ + import org.apache.flex.core.IImageModel; + import org.apache.flex.core.UIBase; + COMPILE::JS + { + import org.apache.flex.core.WrappedHTMLElement; + import org.apache.flex.html.beads.models.ImageModel; + import org.apache.flex.html.beads.ImageView; + } + + /** + * The Image class is a component that displays a bitmap. The Image uses + * the following beads: + * + * org.apache.flex.core.IBeadModel: the data model for the Image, including the source property. + * org.apache.flex.core.IBeadView: constructs the visual elements of the component. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public class Image extends UIBase + { + /** + * constructor. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function Image() + { + super(); + } + + /** + * The location of the bitmap, usually a URL. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + * @flexjsignorecoercion org.apache.flex.core.IImageModel + */ + public function get source():String + { + return (model as IImageModel).source; + } + public function set source(value:String):void + { + (model as IImageModel).source = value; + } + + /** + * @flexjsignorecoercion org.apache.flex.core.WrappedHTMLElement + */ + COMPILE::JS + override protected function createElement():WrappedHTMLElement + { + element = document.createElement('img') as WrappedHTMLElement; + element.className = 'Image'; + typeNames = 'Image'; + + positioner = element; + positioner.style.position = 'relative'; + element.flexjs_wrapper = this; + + model = new + ImageModel(); + + addBead(new + ImageView()); + + return element; + } + + } +} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/7853ef15/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/ImageAndTextButton.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/ImageAndTextButton.as b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/ImageAndTextButton.as new file mode 100644 index 0000000..8bdcc6a --- /dev/null +++ b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/ImageAndTextButton.as @@ -0,0 +1,128 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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 +{ + import org.apache.flex.events.Event; + import org.apache.flex.html.beads.models.ImageAndTextModel; + COMPILE::JS + { + import org.apache.flex.core.WrappedHTMLElement; + } + + /** + * The ImageTextButton class implements a basic button that + * displays and image and text. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public class ImageAndTextButton extends TextButton + { + /** + * Constructor. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function ImageAndTextButton() + { + super(); + } + + /** + * @private + */ + COMPILE::JS + override public function get text():String + { + return ImageAndTextModel(model).text; + } + + /** + * @private + */ + COMPILE::JS + override public function set text(value:String):void + { + ImageAndTextModel(model).text = value; + COMPILE::JS + { + setInnerHTML(); + } + } + + /** + * The URL of an icon to use in the button + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get image():String + { + return ImageAndTextModel(model).image; + } + + /** + * @private + */ + public function set image(value:String):void + { + ImageAndTextModel(model).image = value; + COMPILE::JS + { + setInnerHTML(); + } + } + + /** + * @flexjsignorecoercion org.apache.flex.core.WrappedHTMLElement + */ + COMPILE::JS + override protected function createElement():WrappedHTMLElement + { + element = document.createElement('button') as WrappedHTMLElement; + element.setAttribute('type', 'button'); + + positioner = element; + positioner.style.position = 'relative'; + element.flexjs_wrapper = this; + + return element; + } + + /** + */ + COMPILE::JS + protected function setInnerHTML():void + { + var inner:String = ''; + if (image != null) + inner += "<img src='" + image + "'/>"; + inner += ' '; + inner += text; + element.innerHTML = inner; + }; + } +} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/7853ef15/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/ImageButton.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/ImageButton.as b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/ImageButton.as new file mode 100644 index 0000000..de563a1 --- /dev/null +++ b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/ImageButton.as @@ -0,0 +1,89 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +//////////////////////////////////////////////////////////////////////////////// +package org.apache.flex.html +{ + import org.apache.flex.core.SimpleCSSStyles; + COMPILE::JS + { + import org.apache.flex.core.WrappedHTMLElement; + } + + /** + * The ImageButton class presents an image as a button. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public class ImageButton extends Button + { + /** + * Constructor. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function ImageButton() + { + super(); + typeNames = "ImageButton"; + } + + /** + * @flexjsignorecoercion org.apache.flex.core.WrappedHTMLElement + */ + COMPILE::JS + override protected function createElement():WrappedHTMLElement + { + element = document.createElement("input") as WrappedHTMLElement; + positioner = element; + element.flexjs_wrapper = this; + + var inputElement:HTMLInputElement = element as HTMLInputElement; + inputElement.type = "image"; + + return element; + } + + /** + * Sets the image for the button. This is a URL. + * TODO: figure out how to set the source in the style, rather than using + * backgroundImage behind the scenes. + */ + public function get source():String + { + return style.backgroundImage; + } + + public function set source(url:String):void + { + if (!style) + style = new SimpleCSSStyles(); + style.backgroundImage = url; + + COMPILE::JS { + var inputElement:HTMLInputElement = element as HTMLInputElement; + inputElement.src = url; + } + } + } +} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/7853ef15/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/Label.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/Label.as b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/Label.as new file mode 100644 index 0000000..392dcca --- /dev/null +++ b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/Label.as @@ -0,0 +1,163 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +//////////////////////////////////////////////////////////////////////////////// +package org.apache.flex.html +{ + import org.apache.flex.core.ITextModel; + import org.apache.flex.core.UIBase; + import org.apache.flex.core.ValuesManager; + import org.apache.flex.events.Event; + import org.apache.flex.events.IEventDispatcher; + COMPILE::JS + { + import org.apache.flex.core.WrappedHTMLElement; + } + + /* + * Label probably should extend TextField directly, + * but the player's APIs for TextLine do not allow + * direct instantiation, and we might want to allow + * Labels to be declared and have their actual + * view be swapped out. + */ + + /** + * The Label class implements the basic control for labeling + * other controls. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public class Label extends UIBase + { + /** + * Constructor. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function Label() + { + super(); + } + + [Bindable("textChange")] + /** + * The text to display in the label. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get text():String + { + COMPILE::AS3 + { + return ITextModel(model).text; + } + COMPILE::JS + { + return element.innerHTML; + } + } + + /** + * @private + */ + public function set text(value:String):void + { + COMPILE::AS3 + { + ITextModel(model).text = value; + } + COMPILE::JS + { + this.element.innerHTML = value; + this.dispatchEvent('textChange'); + } + + } + + [Bindable("htmlChange")] + /** + * The html-formatted text to display in the label. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get html():String + { + COMPILE::AS3 + { + return ITextModel(model).html; + } + COMPILE::JS + { + return element.innerHTML; + } + } + + /** + * @private + */ + public function set html(value:String):void + { + COMPILE::AS3 + { + ITextModel(model).html = value; + } + COMPILE::JS + { + this.element.innerHTML = value; + this.dispatchEvent('textChange'); + } + } + + + /** + * @private + */ + COMPILE::AS3 + override public function addedToParent():void + { + super.addedToParent(); + model.addEventListener("textChange", repeaterListener); + model.addEventListener("htmlChange", repeaterListener); + } + + /** + * @flexjsignorecoercion org.apache.flex.core.WrappedHTMLElement + */ + COMPILE::JS + override protected function createElement():WrappedHTMLElement + { + element = document.createElement('span') as WrappedHTMLElement; + positioner = element; + element.flexjs_wrapper = 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/List.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/List.as b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/List.as new file mode 100644 index 0000000..63bcf02 --- /dev/null +++ b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/List.as @@ -0,0 +1,311 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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 +{ + import org.apache.flex.core.ContainerBaseStrandChildren; + import org.apache.flex.core.IContentViewHost; + import org.apache.flex.core.IDataProviderItemRendererMapper; + import org.apache.flex.core.IFactory; + import org.apache.flex.core.IItemRendererClassFactory; + import org.apache.flex.core.IItemRendererProvider; + import org.apache.flex.core.IListPresentationModel; + import org.apache.flex.core.IRollOverModel; + import org.apache.flex.core.ISelectionModel; + import org.apache.flex.core.ListBase; + import org.apache.flex.core.UIBase; + import org.apache.flex.core.ValuesManager; + COMPILE::JS + { + import org.apache.flex.core.WrappedHTMLElement; + import org.apache.flex.html.beads.ListView; + import org.apache.flex.html.supportClasses.DataGroup; + } + import org.apache.flex.events.Event; + import org.apache.flex.events.IEventDispatcher; + import org.apache.flex.html.beads.models.ListPresentationModel; + + /** + * Indicates that the initialization of the list is complete. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + [Event(name="initComplete", type="org.apache.flex.events.Event")] + + /** + * The change event is dispatched whenever the list's selection changes. + * + * @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 List class is a component that displays multiple data items. The List uses + * the following bead types: + * + * org.apache.flex.core.IBeadModel: the data model, which includes the dataProvider, selectedItem, and + * so forth. + * org.apache.flex.core.IBeadView: the bead that constructs the visual parts of the list. + * org.apache.flex.core.IBeadController: the bead that handles input and output. + * org.apache.flex.core.IBeadLayout: the bead responsible for the size and position of the itemRenderers. + * org.apache.flex.core.IDataProviderItemRendererMapper: the bead responsible for creating the itemRenders. + * org.apache.flex.core.IItemRenderer: the class or factory used to display an item in the list. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public class List extends ListBase implements IItemRendererProvider + { + /** + * constructor. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function List() + { + super(); + } + + /** + * The name of field within the data used for display. Each item of the + * data should have a property with this name. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get labelField():String + { + return ISelectionModel(model).labelField; + } + public function set labelField(value:String):void + { + ISelectionModel(model).labelField = value; + } + + /** + * The data being display by the List. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get dataProvider():Object + { + return ISelectionModel(model).dataProvider; + } + public function set dataProvider(value:Object):void + { + ISelectionModel(model).dataProvider = value; + } + + /** + * The index of the currently selected item. Changing this value + * also changes the selectedItem property. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get selectedIndex():int + { + return ISelectionModel(model).selectedIndex; + } + public function set selectedIndex(value:int):void + { + ISelectionModel(model).selectedIndex = value; + } + + /** + * The index of the item currently below the pointer. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get rollOverIndex():int + { + return IRollOverModel(model).rollOverIndex; + } + public function set rollOverIndex(value:int):void + { + IRollOverModel(model).rollOverIndex = value; + } + + /** + * The presentation model for the list. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get presentationModel():IListPresentationModel + { + var presModel:IListPresentationModel = getBeadByType(IListPresentationModel) as IListPresentationModel; + if (presModel == null) { + presModel = new ListPresentationModel(); + addBead(presModel); + } + return presModel; + } + + /** + * The default height of each cell in every column + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get rowHeight():Number + { + return presentationModel.rowHeight; + } + public function set rowHeight(value:Number):void + { + presentationModel.rowHeight = value; + } + + /** + * The item currently selected. Changing this value also + * changes the selectedIndex property. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get selectedItem():Object + { + return ISelectionModel(model).selectedItem; + } + public function set selectedItem(value:Object):void + { + ISelectionModel(model).selectedItem = value; + } + + private var _itemRenderer:IFactory; + + /** + * The class or factory used to display each item. + * + * @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; + } + + /** + * Returns whether or not the itemRenderer property has been set. + * + * @see org.apache.flex.core.IItemRendererProvider + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get hasItemRenderer():Boolean + { + var result:Boolean = false; + + COMPILE::AS3 { + result = _itemRenderer != null; + } + + COMPILE::JS { + var test:* = _itemRenderer; + result = _itemRenderer !== null && test !== undefined; + } + + return result; + } + + + /** + * @private + */ + override public function addedToParent():void + { + super.addedToParent(); + + if (getBeadByType(IDataProviderItemRendererMapper) == null) + { + var mapper:IDataProviderItemRendererMapper = new (ValuesManager.valuesImpl.getValue(this, "iDataProviderItemRendererMapper")) as IDataProviderItemRendererMapper; + addBead(mapper); + } + var itemRendererFactory:IItemRendererClassFactory = getBeadByType(IItemRendererClassFactory) as IItemRendererClassFactory; + if (!itemRendererFactory) + { + itemRendererFactory = new (ValuesManager.valuesImpl.getValue(this, "iItemRendererClassFactory")) as IItemRendererClassFactory; + addBead(itemRendererFactory); + } + + dispatchEvent(new Event("initComplete")); + } + + /** + * @flexjsignorecoercion org.apache.flex.core.WrappedHTMLElement + */ + COMPILE::JS + override protected function createElement():WrappedHTMLElement + { + super.createElement(); + className = 'List'; + + return element; + } + + /** + * @flexjsignorecoercion org.apache.flex.html.beads.ListView + * @flexjsignorecoercion org.apache.flex.html.supportClasses.DataGroup + */ + COMPILE::JS + override public function internalChildren():Array + { + var listView:ListView = getBeadByType(ListView) as ListView; + var dg:DataGroup = listView.dataGroup as DataGroup; + var renderers:Array = dg.internalChildren(); + return renderers; + }; + } +} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/7853ef15/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/MXMLBeadViewBase.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/MXMLBeadViewBase.as b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/MXMLBeadViewBase.as new file mode 100644 index 0000000..301e430 --- /dev/null +++ b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/MXMLBeadViewBase.as @@ -0,0 +1,317 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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 +{ + import org.apache.flex.states.State; + + import org.apache.flex.core.IBead; + import org.apache.flex.core.ILayoutHost; + import org.apache.flex.core.IParent; + import org.apache.flex.core.IParentIUIBase; + import org.apache.flex.core.IStrand; + import org.apache.flex.core.IStatesImpl; + import org.apache.flex.core.ValuesManager; + import org.apache.flex.html.beads.ContainerView; + import org.apache.flex.events.Event; + import org.apache.flex.events.ValueChangeEvent; + import org.apache.flex.utils.MXMLDataInterpreter; + + [DefaultProperty("mxmlContent")] + + /** + * The MXMLBeadViewBase class extends BeadViewBase + * and adds support for databinding and specification + * of children in MXML. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public class MXMLBeadViewBase extends ContainerView implements IStrand, ILayoutHost + { + /** + * Constructor. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function MXMLBeadViewBase() + { + super(); + } + + [Bindable("strandChanged")] + /** + * An MXMLBeadViewBase doesn't create its children until it is added to + * the 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; + // each MXML file can also have styles in fx:Style block + ValuesManager.valuesImpl.init(this); + + dispatchEvent(new Event("strandChanged")); + + for each (var bead:IBead in beads) + addBead(bead); + + dispatchEvent(new org.apache.flex.events.Event("beadsAdded")); + + MXMLDataInterpreter.generateMXMLInstances(this, IParent(value), MXMLDescriptor); + + dispatchEvent(new Event("initBindings")) + dispatchEvent(new Event("initComplete")) + dispatchEvent(new Event("childrenAdded")); + } + + [Bindable("__NoChangeEvent__")] + /** + * The model object. + */ + public function get model():Object + { + return _strand["model"]; + } + + /** + * @copy org.apache.flex.core.Application#MXMLDescriptor + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get MXMLDescriptor():Array + { + return null; + } + + /** + * @copy org.apache.flex.core.Application#generateMXMLAttributes() + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function generateMXMLAttributes(data:Array):void + { + MXMLDataInterpreter.generateMXMLProperties(this, data); + } + + /** + * @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 var _states:Array; + + /** + * The array of view states. These should + * be instances of org.apache.flex.states.State. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get states():Array + { + return _states; + } + + /** + * @private + */ + public function set states(value:Array):void + { + _states = value; + _currentState = _states[0].name; + + try{ + if (getBeadByType(IStatesImpl) == null) + addBead(new (ValuesManager.valuesImpl.getValue(this, "iStatesImpl")) as IBead); + } + //TODO: Need to handle this case more gracefully + catch(e:Error) + { + COMPILE::AS3 + { + trace(e.message); + } + } + + } + + /** + * <code>true</code> if the array of states + * contains a state with this name. + * + * @param state The state namem. + * @return True if state in state array + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function hasState(state:String):Boolean + { + for each (var s:State in _states) + { + if (s.name == state) + return true; + } + return false; + } + + private var _currentState:String; + + [Bindable("currentStateChange")] + /** + * The name of the current state. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get currentState():String + { + return _currentState; + } + + /** + * @private + */ + public function set currentState(value:String):void + { + var event:ValueChangeEvent = new ValueChangeEvent("currentStateChange", false, false, _currentState, value) + _currentState = value; + dispatchEvent(event); + } + + private var _transitions:Array; + + /** + * The array of transitions. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get transitions():Array + { + return _transitions; + } + + /** + * @private + */ + public function set transitions(value:Array):void + { + _transitions = value; + } + + /** + * @copy org.apache.flex.core.Application#beads + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public var beads:Array; + + private var _beads:Array; + + /** + * @copy org.apache.flex.core.IStrand#addBead() + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function addBead(bead:IBead):void + { + if (!_beads) + _beads = []; + _beads.push(bead); + bead.strand = this; + } + + /** + * @copy org.apache.flex.core.IStrand#getBeadByType() + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function getBeadByType(classOrInterface:Class):IBead + { + for each (var bead:IBead in _beads) + { + if (bead is classOrInterface) + return bead; + } + return null; + } + + /** + * @copy org.apache.flex.core.IStrand#removeBead() + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + 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; + } + + } +} \ 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/MultilineLabel.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/MultilineLabel.as b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/MultilineLabel.as new file mode 100644 index 0000000..5149237 --- /dev/null +++ b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/MultilineLabel.as @@ -0,0 +1,76 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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 +{ + import org.apache.flex.core.ITextModel; + import org.apache.flex.core.UIBase; + import org.apache.flex.core.ValuesManager; + import org.apache.flex.events.Event; + import org.apache.flex.events.IEventDispatcher; + COMPILE::JS + { + import org.apache.flex.core.WrappedHTMLElement; + } + + /* + * Label probably should extend TextField directly, + * but the player's APIs for TextLine do not allow + * direct instantiation, and we might want to allow + * Labels to be declared and have their actual + * view be swapped out. + */ + + /** + * The Label class implements the basic control for labeling + * other controls. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public class MultilineLabel extends Label + { + /** + * Constructor. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function MultilineLabel() + { + super(); + } + + /** + * @flexjsignorecoercion org.apache.flex.core.WrappedHTMLElement + */ + COMPILE::JS + override protected function createElement():WrappedHTMLElement + { + element = document.createElement('div') as WrappedHTMLElement; + positioner = element; + element.flexjs_wrapper = 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/NumericStepper.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/NumericStepper.as b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/NumericStepper.as new file mode 100644 index 0000000..02120e7 --- /dev/null +++ b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/NumericStepper.as @@ -0,0 +1,214 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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 +{ + import org.apache.flex.core.IRangeModel; + import org.apache.flex.core.UIBase; + COMPILE::JS + { + import goog.events; + import org.apache.flex.core.WrappedHTMLElement; + } + + [Event(name="valueChange", type="org.apache.flex.events.Event")] + + /** + * The NumericStepper class is a component that displays a numeric + * value and up/down controls (using a org.apache.flex.html.Spinner) to + * increase and decrease the value by specific amounts. The NumericStepper uses the following beads: + * + * org.apache.flex.core.IBeadModel: the data model for the component of type org.apache.flex.core.IRangeModel. + * org.apache.flex.core.IBeadView: constructs the parts of the component. + * org.apache.flex.core.IBeadController: handles the input events. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public class NumericStepper extends UIBase + { + /** + * constructor. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function NumericStepper() + { + super(); + } + + [Bindable("valueChange")] + /** + * The current value of the control. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get value():Number + { + return IRangeModel(model).value; + } + public function set value(newValue:Number):void + { + IRangeModel(model).value = newValue; + } + + /** + * The minimum value the control will display. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get minimum():Number + { + return IRangeModel(model).minimum; + } + public function set minimum(value:Number):void + { + IRangeModel(model).minimum = value; + } + + /** + * The maximum value the control will display. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get maximum():Number + { + return IRangeModel(model).maximum; + } + public function set maximum(value:Number):void + { + IRangeModel(model).maximum = value; + } + + /** + * The amount to increase or descrease the value. The value + * will not exceed the minimum or maximum value. The final + * value is affected by the snapInterval. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get stepSize():Number + { + return IRangeModel(model).stepSize; + } + public function set stepSize(value:Number):void + { + IRangeModel(model).stepSize = value; + } + + /** + * The modulus for the value. If this property is set, + * the value displayed with a muliple of the snapInterval. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get snapInterval():Number + { + return IRangeModel(model).snapInterval; + } + public function set snapInterval(value:Number):void + { + IRangeModel(model).snapInterval = value; + } + + COMPILE::JS + private var input:TextInput; + + COMPILE::JS + private var spinner:Spinner; + + /** + * @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'; + + input = new TextInput(); + addElement(input); + input.positioner.style.display = 'inline-block'; + input.positioner.style.width = '100px'; + + spinner = new Spinner(); + spinner.positioner.style.display = 'inline-block'; + spinner.positioner.style.height = '24px'; + spinner.positioner.style.marginLeft = '-1px'; + spinner.positioner.style.marginTop = '-1px'; + addElement(spinner); + + /* TODO: ajh move to view and css */ + spinner.incrementButton.positioner.style.display = 'block'; + spinner.incrementButton.positioner.style.marginBottom = '-1px'; + spinner.incrementButton.positioner.style.paddingTop = '1.5px'; + spinner.incrementButton.positioner.style.paddingBottom = '2px'; + spinner.incrementButton.positioner.style.fontSize = '7px'; + spinner.decrementButton.positioner.style.marginTop = '0px'; + spinner.decrementButton.positioner.style.display = 'block'; + spinner.decrementButton.positioner.style.paddingTop = '2px'; + spinner.decrementButton.positioner.style.paddingBottom = '1.5px'; + spinner.decrementButton.positioner.style.fontSize = '7px'; + spinner.positioner.style.display = 'inline-block'; + goog.events.listen(spinner, 'valueChange', + spinnerChange); + + element.flexjs_wrapper = this; + className = 'NumericStepper'; + + input.text = String(spinner.value); + + return element; + } + + /** + * @param event The input event. + */ + COMPILE::JS + private function spinnerChange(event:Event):void + { + var newValue:Number = spinner.value; + value = newValue; + input.text = String(spinner.value); + dispatchEvent(new Event('valueChange')); + }; + + + } +} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/7853ef15/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/Panel.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/Panel.as b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/Panel.as new file mode 100644 index 0000000..e9c5986 --- /dev/null +++ b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/Panel.as @@ -0,0 +1,121 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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 +{ + import org.apache.flex.core.IPanelModel; + + COMPILE::JS + { + import org.apache.flex.core.WrappedHTMLElement; + } + + [Event(name="close", type="org.apache.flex.events.Event")] + + /** + * The Panel class is a Container component capable of parenting other + * components. The Panel has a TitleBar. If you want to a Panel with + * a ControlBar, use PanelWithControlBar which + * will instantiate, by default, an ControlBar. + * The Panel uses the following bead types: + * + * org.apache.flex.core.IBeadModel: the data model for the Panel that includes the title and whether + * or not to display the close button. + * org.apache.flex.core.IBeadView: creates the parts of the Panel. + * org.apache.flex.core.IBorderBead: if present, draws a border around the Panel. + * org.apache.flex.core.IBackgroundBead: if present, provides a colored background for the Panel. + * + * @see PanelWithControlBar + * @see ControlBar + * @see TitleBar + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public class Panel extends Container + { + /** + * constructor. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function Panel() + { + super(); + } + + /** + * The string to display in the org.apache.flex.html.TitleBar. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get title():String + { + return IPanelModel(model).title; + } + public function set title(value:String):void + { + IPanelModel(model).title = value; + } + + /** + * The HTML string to display in the org.apache.flex.html.TitleBar. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get htmlTitle():String + { + return IPanelModel(model).htmlTitle; + } + public function set htmlTitle(value:String):void + { + IPanelModel(model).htmlTitle = value; + } + + /** + * Whether or not to show a Close button in the org.apache.flex.html.TitleBar. + */ + public function get showCloseButton():Boolean + { + return IPanelModel(model).showCloseButton; + } + public function set showCloseButton(value:Boolean):void + { + IPanelModel(model).showCloseButton = value; + } + + COMPILE::JS + override protected function createElement():WrappedHTMLElement + { + super.createElement(); + element.className = "Panel"; + typeNames = "Panel"; + return element; + } + } +} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/7853ef15/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/PanelWithControlBar.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/PanelWithControlBar.as b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/PanelWithControlBar.as new file mode 100644 index 0000000..7659d9d --- /dev/null +++ b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/PanelWithControlBar.as @@ -0,0 +1,121 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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 +{ + import org.apache.flex.core.IPanelModel; + + [Event(name="close", type="org.apache.flex.events.Event")] + + /** + * The Panel class is a Container component capable of parenting other + * components. The Panel has a TitleBar and an optional org.apache.flex.html.ControlBar. + * The Panel uses the following bead types: + * + * org.apache.flex.core.IBeadModel: the data model for the Panel that includes the title and whether + * or not to display the close button. + * org.apache.flex.core.IBeadView: creates the parts of the Panel. + * org.apache.flex.core.IBorderBead: if present, draws a border around the Panel. + * org.apache.flex.core.IBackgroundBead: if present, provides a colored background for the Panel. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public class PanelWithControlBar extends Container + { + /** + * constructor. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function PanelWithControlBar() + { + super(); + } + + /** + * The string to display in the org.apache.flex.html.TitleBar. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get title():String + { + return IPanelModel(model).title; + } + public function set title(value:String):void + { + IPanelModel(model).title = value; + } + + /** + * The HTML string to display in the org.apache.flex.html.TitleBar. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get htmlTitle():String + { + return IPanelModel(model).htmlTitle; + } + public function set htmlTitle(value:String):void + { + IPanelModel(model).htmlTitle = value; + } + + /** + * Whether or not to show a Close button in the org.apache.flex.html.TitleBar. + */ + public function get showCloseButton():Boolean + { + return IPanelModel(model).showCloseButton; + } + public function set showCloseButton(value:Boolean):void + { + IPanelModel(model).showCloseButton = value; + } + + /** + * The items in the org.apache.flex.html.ControlBar. Setting this property automatically + * causes the ControlBar to display. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get controlBar():Array + { + return IPanelModel(model).controlBar; + } + public function set controlBar(value:Array):void + { + IPanelModel(model).controlBar = value; + } + + } +} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/7853ef15/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/RadioButton.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/RadioButton.as b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/RadioButton.as new file mode 100644 index 0000000..63f90e9 --- /dev/null +++ b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/RadioButton.as @@ -0,0 +1,347 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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 +{ + COMPILE::AS3 + { + import flash.display.DisplayObject; + import flash.events.MouseEvent; + import flash.utils.Dictionary; + } + + import org.apache.flex.core.IStrand; + import org.apache.flex.core.IValueToggleButtonModel; + COMPILE::AS3 + { + import org.apache.flex.core.UIButtonBase; + } + COMPILE::JS + { + import org.apache.flex.core.UIBase; + import org.apache.flex.core.WrappedHTMLElement; + } + import org.apache.flex.events.Event; + import org.apache.flex.core.IUIBase; + + [Event(name="change", type="org.apache.flex.events.Event")] + + /** + * The RadioButton class is a component that displays a selectable Button. RadioButtons + * are typically used in groups, identified by the groupName property. RadioButton use + * the following beads: + * + * org.apache.flex.core.IBeadModel: the data model, which includes the groupName. + * org.apache.flex.core.IBeadView: the bead that constructs the visual parts of the RadioButton.. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + COMPILE::AS3 + public class RadioButton extends UIButtonBase implements IStrand + { + /** + * constructor. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function RadioButton(upState:DisplayObject=null, overState:DisplayObject=null, downState:DisplayObject=null, hitTestState:DisplayObject=null) + { + super(upState, overState, downState, hitTestState); + + addEventListener(MouseEvent.CLICK, internalMouseHandler); + } + + protected static var dict:Dictionary = new Dictionary(true); + + private var _groupName:String; + + /** + * The name of the group. Only one RadioButton in a group is selected. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get groupName() : String + { + return IValueToggleButtonModel(model).groupName; + } + public function set groupName(value:String) : void + { + IValueToggleButtonModel(model).groupName = value; + } + + /** + * The string used as a label for the RadioButton. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get text():String + { + return IValueToggleButtonModel(model).text; + } + public function set text(value:String):void + { + IValueToggleButtonModel(model).text = value; + } + + /** + * Whether or not the RadioButton instance is selected. Setting this property + * causes the currently selected RadioButton in the same group to lose the + * selection. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get selected():Boolean + { + return IValueToggleButtonModel(model).selected; + } + public function set selected(selValue:Boolean):void + { + IValueToggleButtonModel(model).selected = selValue; + + // if this button is being selected, its value should become + // its group's selectedValue + if( selValue ) { + for each(var rb:RadioButton in dict) + { + if( rb.groupName == groupName ) + { + rb.selectedValue = value; + } + } + } + } + + /** + * The value associated with the RadioButton. For example, RadioButtons with labels, + * "Red", "Green", and "Blue" might have the values 0, 1, and 2 respectively. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get value():Object + { + return IValueToggleButtonModel(model).value; + } + public function set value(newValue:Object):void + { + IValueToggleButtonModel(model).value = newValue; + } + + /** + * The group's currently selected value. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get selectedValue():Object + { + return IValueToggleButtonModel(model).selectedValue; + } + public function set selectedValue(newValue:Object):void + { + // a radio button is really selected when its value matches that of the group's value + IValueToggleButtonModel(model).selected = (newValue == value); + IValueToggleButtonModel(model).selectedValue = newValue; + } + + /** + * @private + */ + override public function addedToParent():void + { + super.addedToParent(); + + // if this instance is selected, set the local selectedValue to + // this instance's value + if( selected ) selectedValue = value; + + else { + + // make sure this button's selectedValue is set from its group's selectedValue + // to keep it in sync with the rest of the buttons in its group. + for each(var rb:RadioButton in dict) + { + if( rb.groupName == groupName ) + { + selectedValue = rb.selectedValue; + break; + } + } + } + + dict[this] = this; + } + + /** + * @private + */ + private function internalMouseHandler(event:Event) : void + { + // prevent radiobutton from being turned off by a click + if( !selected ) { + selected = !selected; + dispatchEvent(new Event("change")); + } + } + } + + COMPILE::JS + public class RadioButton extends UIBase + { + public static var radioCounter:int = 0; + + private var input:HTMLInputElement; + private var labelFor:HTMLLabelElement; + private var textNode:Text; + /** + * @flexjsignorecoercion org.apache.flex.core.WrappedHTMLElement + * @flexjsignorecoercion HTMLInputElement + * @flexjsignorecoercion HTMLLabelElement + * @flexjsignorecoercion Text + */ + override protected function createElement():WrappedHTMLElement + { + input = document.createElement('input') as HTMLInputElement; + input.type = 'radio'; + input.id = '_radio_' + RadioButton.radioCounter++; + + textNode = document.createTextNode('radio button') as Text; + + labelFor = document.createElement('label') as HTMLLabelElement; + labelFor.appendChild(input); + labelFor.appendChild(textNode); + + element = labelFor as WrappedHTMLElement; + element.className = 'RadioButton'; + typeNames = 'RadioButton'; + + positioner = element; + positioner.style.position = 'relative'; + + (input as WrappedHTMLElement).flexjs_wrapper = this; + (element as WrappedHTMLElement).flexjs_wrapper = this; + (textNode as WrappedHTMLElement).flexjs_wrapper = this; + + return element; + } + + override public function set id(value:String):void + { + super.id = value; + labelFor.id = value; + input.id = value; + } + + public function get groupName():String + { + return input.name as String; + } + public function set groupName(value:String):void + { + input.name = value; + } + + public function get text():String + { + return textNode.nodeValue as String; + } + public function set text(value:String):void + { + textNode.nodeValue = value; + } + + /** @export */ + public function get selected():Boolean + { + return input.checked; + } + public function set selected(value:Boolean):void + { + input.checked = value; + } + + public function get value():Object + { + return input.value; + } + public function set value(v:Object):void + { + input.value = v as String; + } + + public function get selectedValue():Object + { + var buttons:NodeList; + var groupName:String; + var i:int; + var n:int; + + groupName = input.name as String; + buttons = document.getElementsByName(groupName); + n = buttons.length; + + for (i = 0; i < n; i++) { + if (buttons[i].checked) { + return buttons[i].value; + } + } + return null; + } + + /** + * @flexjsignorecoercion Array + */ + public function set selectedValue(value:Object):void + { + var buttons:NodeList; + var groupName:String; + var i:int; + var n:int; + + groupName = input.name as String; + buttons = document.getElementsByName(groupName); + n = buttons.length; + for (i = 0; i < n; i++) { + if (buttons[i].value === value) { + buttons[i].checked = true; + break; + } + } + } + } + +} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/7853ef15/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/SimpleAlert.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/SimpleAlert.as b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/SimpleAlert.as new file mode 100644 index 0000000..676d9e7 --- /dev/null +++ b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/SimpleAlert.as @@ -0,0 +1,140 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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 +{ + import org.apache.flex.core.IAlertModel; + import org.apache.flex.core.IPopUp; + import org.apache.flex.core.UIBase; + import org.apache.flex.events.Event; + + [Event(name="close", type="org.apache.flex.events.Event")] + + /** + * The SimpleAlert class is a component that displays a message and an OK button. The + * SimpleAlert converts directly to window.alert() for HTML. SimpleAlert uses + * the following beads: + * + * org.apache.flex.core.IBeadModel: the data model, which includes the message. + * org.apache.flex.core.IBeadView: the bead that constructs the visual parts of the Alert. + * org.apache.flex.core.IBeadController: the bead responsible for handling input events. + * org.apache.flex.core.IBorderBead: a bead, if present, that draws a border around the control. + * org.apache.flex.core.IBackgroundBead: a bead, if present, that creates a solid-color background. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public class SimpleAlert extends UIBase implements IPopUp + { + /** + * constructor. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function SimpleAlert() + { + super(); + + className = "SimpleAlert"; + } + + /** + * The message to display. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + private function get message():String + { + return IAlertModel(model).message; + } + private function set message(value:String):void + { + IAlertModel(model).message = value; + } + + /** + * The HTML message to display. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + private function get htmlMessage():String + { + return IAlertModel(model).htmlMessage; + } + private function set htmlMessage(value:String):void + { + IAlertModel(model).htmlMessage = value; + } + + /** + * This function causes the SimpleAlert to appear. The parent is used for ActionScript and + * identifies the IPopUpParent that manages the alert. + * + * @param Object parent The object that hosts the pop-up. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function show(parent:Object) : void + { + parent.addElement(this); + } + + /** + * A convenience function to compose and display the alert. + * + * @param String message The content to display in the SimpleAlert. + * @param Object parent The object that hosts the pop-up. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + static public function show(message:String, parent:Object):SimpleAlert + { + COMPILE::AS3 + { + var alert:SimpleAlert = new SimpleAlert(); + alert.message = message; + alert.show(parent); + + return alert; + } + COMPILE::JS + { + alert(message); + return null; + } + } + + } +} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/7853ef15/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/SimpleList.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/SimpleList.as b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/SimpleList.as new file mode 100644 index 0000000..9dcb348 --- /dev/null +++ b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/SimpleList.as @@ -0,0 +1,79 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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 +{ + COMPILE::JS + { + import goog.events; + import org.apache.flex.core.WrappedHTMLElement; + } + + /** + * The SimpleList class is a component that displays data in a vertical column. This + * component differs from org.apache.flex.html.List in that it displays + * only string values and maps to the <select> HTML element. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public class SimpleList extends List + { + /** + * constructor. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function SimpleList() + { + super(); + } + + /** + * @flexjsignorecoercion org.apache.flex.core.WrappedHTMLElement + * @flexjsignorecoercion HTMLSelectElement + */ + COMPILE::JS + override protected function createElement():WrappedHTMLElement + { + element = document.createElement('select') as WrappedHTMLElement; + (element as HTMLSelectElement).size = 5; + goog.events.listen(element, 'change', + changeHandler); + positioner = element; + positioner.style.position = 'relative'; + className = 'SimpleList'; + + return element; + } + + /** + * @flexjsignorecoercion HTMLSelectElement + */ + COMPILE::JS + protected function changeHandler(event:Event):void + { + model.selectedIndex = (element as HTMLSelectElement).selectedIndex; + } + } +} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/7853ef15/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/Slider.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/Slider.as b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/Slider.as new file mode 100644 index 0000000..6944895 --- /dev/null +++ b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/Slider.as @@ -0,0 +1,233 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +//////////////////////////////////////////////////////////////////////////////// +package org.apache.flex.html +{ + import org.apache.flex.core.IRangeModel; + import org.apache.flex.core.UIBase; + + COMPILE::JS + { + import org.apache.flex.html.beads.SliderTrackView; + import org.apache.flex.html.beads.SliderThumbView; + import org.apache.flex.html.beads.controllers.SliderMouseController; + import org.apache.flex.core.WrappedHTMLElement; + } + + [Event(name="valueChange", type="org.apache.flex.events.Event")] + + /** + * The Slider class is a component that displays a range of values using a + * track and a thumb control. The Slider uses the following bead types: + * + * org.apache.flex.core.IBeadModel: the data model, typically an IRangeModel, that holds the Slider values. + * org.apache.flex.core.IBeadView: the bead that constructs the visual parts of the Slider. + * org.apache.flex.core.IBeadController: the bead that handles input. + * org.apache.flex.core.IThumbValue: the bead responsible for the display of the thumb control. + * org.apache.flex.core.ITrackView: the bead responsible for the display of the track. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public class Slider extends UIBase + { + /** + * constructor. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function Slider() + { + super(); + + className = "Slider"; + + IRangeModel(model).value = 0; + IRangeModel(model).minimum = 0; + IRangeModel(model).maximum = 100; + IRangeModel(model).stepSize = 1; + IRangeModel(model).snapInterval = 1; + } + + /** + * The current value of the Slider. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get value():Number + { + return IRangeModel(model).value; + } + public function set value(newValue:Number):void + { + IRangeModel(model).value = newValue; + } + + /** + * The minimum value of the Slider. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get minimum():Number + { + return IRangeModel(model).minimum; + } + public function set minimum(value:Number):void + { + IRangeModel(model).minimum = value; + } + + /** + * The maximum value of the Slider. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get maximum():Number + { + return IRangeModel(model).maximum; + } + public function set maximum(value:Number):void + { + IRangeModel(model).maximum = value; + } + + /** + * The modulus of the Slider value. The thumb will be positioned + * at the nearest multiple of this value. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get snapInterval():Number + { + return IRangeModel(model).snapInterval; + } + public function set snapInterval(value:Number):void + { + IRangeModel(model).snapInterval = value; + } + + /** + * The amount to move the thumb when the track is selected. This value is + * adjusted to fit the nearest snapInterval. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get stepSize():Number + { + return IRangeModel(model).stepSize; + } + public function set stepSize(value:Number):void + { + IRangeModel(model).stepSize = value; + } + + COMPILE::JS + private var track:SliderTrackView; + + COMPILE::JS + private var thumb:SliderThumbView; + + COMPILE::JS + private var controller:SliderMouseController; + + /** + * @flexjsignorecoercion org.apache.flex.core.WrappedHTMLElement + */ + COMPILE::JS + override protected function createElement():WrappedHTMLElement + { + element = document.createElement('div') as WrappedHTMLElement; + element.style.width = '200px'; + element.style.height = '30px'; + + track = new SliderTrackView(); + addBead(track); + + thumb = new SliderThumbView(); + addBead(thumb); + + controller = new SliderMouseController(); + addBead(controller); + + positioner = element; + positioner.style.position = 'relative'; + element.flexjs_wrapper = this; + + className = 'Slider'; + + return element; + } + + /** + */ + COMPILE::JS + public function snap(value:Number):Number + { + var si:Number = snapInterval; + var n:Number = Math.round((value - minimum) / si) * + si + minimum; + if (value > 0) + { + if (value - n < n + si - value) + return n; + return n + si; + } + if (value - n > n + si - value) + return n + si; + return n; + } + + + /** + * @param {number} value The value used to calculate new position of the thumb. + * @return {void} Moves the thumb to the corresponding position. + */ + COMPILE::JS + public function setThumbFromValue(value:Number):void + { + var min:Number = model.minimum; + var max:Number = model.maximum; + var p:Number = (value - min) / (max - min); + var xloc:Number = p * (parseInt(track.element.style.width, 10) - + parseInt(thumb.element.style.width, 10)); + + thumb.element.style.left = String(xloc) + 'px'; + } + + } +} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/7853ef15/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/Spacer.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/Spacer.as b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/Spacer.as new file mode 100644 index 0000000..d7ab050 --- /dev/null +++ b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/Spacer.as @@ -0,0 +1,64 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +//////////////////////////////////////////////////////////////////////////////// +package org.apache.flex.html +{ + import org.apache.flex.core.UIBase; + COMPILE::JS + { + import org.apache.flex.core.WrappedHTMLElement; + } + + /** + * The Spacer class takes up space in the UI layout. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public class Spacer extends UIBase + { + /** + * Constructor. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function Spacer() + { + super(); + } + + /** + * @flexjsignorecoercion org.apache.flex.core.WrappedHTMLElement + */ + COMPILE::JS + override protected function createElement():WrappedHTMLElement + { + this.element = document.createElement('div') as WrappedHTMLElement; + this.positioner = this.element; + this.element.flexjs_wrapper = this; + + return element; + } + + } +}