http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/d8221452/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/ComboBox.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/ComboBox.as b/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/ComboBox.as new file mode 100644 index 0000000..fa91fec --- /dev/null +++ b/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/ComboBox.as @@ -0,0 +1,277 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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.IComboBoxModel; + import org.apache.flex.core.UIBase; + import org.apache.flex.events.Event; + + COMPILE::JS + { + import goog.events; + import org.apache.flex.core.WrappedHTMLElement; + } + + [Event(name="change", type="org.apache.flex.events.Event")] + + /** + * The ComboBox class is a component that displays an input field and + * pop-up List with selections. Selecting an item from the pop-up List + * places that item into the input field of the ComboBox. The ComboBox + * 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 component. + * org.apache.flex.core.IBeadController: the bead that handles input and output. + * org.apache.flex.core.IPopUp: the bead responsible for displaying the selection list. + * 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 component. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public class ComboBox extends UIBase + { + /** + * constructor. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function ComboBox() + { + super(); + } + + /** + * The data for display by the ComboBox. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get dataProvider():Object + { + return IComboBoxModel(model).dataProvider; + } + public function set dataProvider(value:Object):void + { + IComboBoxModel(model).dataProvider = value; + } + + /** + * The index of the currently selected item. Changing this item changes + * the selectedItem value. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get selectedIndex():int + { + return IComboBoxModel(model).selectedIndex; + } + public function set selectedIndex(value:int):void + { + IComboBoxModel(model).selectedIndex = value; + } + + /** + * The item that is currently selected. Changing this item changes + * the selectedIndex. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get selectedItem():Object + { + return IComboBoxModel(model).selectedItem; + } + public function set selectedItem(value:Object):void + { + IComboBoxModel(model).selectedItem = value; + } + + /** + * @flexjsignorecoercion org.apache.flex.core.WrappedHTMLElement + */ + COMPILE::JS + override protected function createElement():WrappedHTMLElement + { + var button:WrappedHTMLElement; + var input:WrappedHTMLElement; + + element = document.createElement('div') as WrappedHTMLElement; + + input = document.createElement('input') as WrappedHTMLElement; + input.style.position = 'absolute'; + input.style.width = '80px'; + element.appendChild(input); + + button = document.createElement('div') as WrappedHTMLElement; + button.style.position = 'absolute'; + button.style.top = '0px'; + button.style.right = '0px'; + button.style.background = '#bbb'; + button.style.width = '16px'; + button.style.height = '20px'; + button.style.margin = '0'; + button.style.border = 'solid #609 1px'; + goog.events.listen(button, 'click', buttonClicked); + element.appendChild(button); + + positioner = element; + positioner.style.position = 'relative'; + + // add a click handler so that a click outside of the combo box can + // dismiss the pop-up should it be visible. + goog.events.listen(document, 'click', + dismissPopup); + + input.flexjs_wrapper = this; + + return element; + } + + COMPILE::JS + private var popup:HTMLElement; + + /** + * @param event The event. + * @flexjsignorecoercion HTMLSelectElement + */ + COMPILE::JS + private function selectChanged(event:Event):void + { + var select:HTMLSelectElement; + + select = event.currentTarget as HTMLSelectElement; + + selectedItem = select.options[select.selectedIndex].value; + + popup.parentNode.removeChild(popup); + popup = null; + + dispatchEvent(event); + } + + + /** + * @param event The event. + */ + COMPILE::JS + private function dismissPopup(event:Event):void + { + // remove the popup if it already exists + if (popup) { + popup.parentNode.removeChild(popup); + popup = null; + } + } + + + /** + * @export + * @param {Object} event The event. + * @flexjsignorecoercion HTMLInputElement + * @flexjsignorecoercion HTMLElement + * @flexjsignorecoercion HTMLSelectElement + * @flexjsignorecoercion HTMLOptionElement + * @flexjsignorecoercion Array + */ + COMPILE::JS + private function buttonClicked(event:Event):void + { + var dp:Array; + var i:int; + var input:HTMLInputElement; + var left:Number; + var n:int; + var opt:HTMLOptionElement; + var pn:HTMLElement; + var popup:HTMLElement; + var select:HTMLSelectElement; + var si:int; + var top:Number; + var width:Number; + + event.stopPropagation(); + + if (popup) { + dismissPopup(null); + + return; + } + + input = element.childNodes.item(0) as HTMLInputElement; + + pn = element; + top = pn.offsetTop + input.offsetHeight; + left = pn.offsetLeft; + width = pn.offsetWidth; + + popup = document.createElement('div') as HTMLElement; + popup.className = 'popup'; + popup.id = 'test'; + popup.style.position = 'absolute'; + popup.style.top = top.toString() + 'px'; + popup.style.left = left.toString() + 'px'; + popup.style.width = width.toString() + 'px'; + popup.style.margin = '0px auto'; + popup.style.padding = '0px'; + popup.style.zIndex = '10000'; + + select = document.createElement('select') as HTMLSelectElement; + select.style.width = width.toString() + 'px'; + goog.events.listen(select, 'change', selectChanged); + + dp = dataProvider as Array; + n = dp.length; + for (i = 0; i < n; i++) { + opt = document.createElement('option') as HTMLOptionElement; + opt.text = dp[i]; + select.add(opt, null); + } + + select.size = n; + + si = selectedIndex; + if (si < 0) { + select.value = null; + } else { + select.value = dp[si]; + } + + this.popup = popup; + + popup.appendChild(select); + document.body.appendChild(popup); + } + + } +}
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/d8221452/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/Container.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/Container.as b/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/Container.as new file mode 100644 index 0000000..ee30b7f --- /dev/null +++ b/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/Container.as @@ -0,0 +1,108 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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.ContainerBase; + import org.apache.flex.core.IChrome; + import org.apache.flex.core.IContainer; + import org.apache.flex.core.IUIBase; + COMPILE::JS + { + import org.apache.flex.core.WrappedHTMLElement; + } + import org.apache.flex.events.Event; + + [DefaultProperty("mxmlContent")] + + /** + * The Container class implements a basic container for + * other controls and containers. The position and size + * of the children are determined by a layout while the size of + * a Container can either be determined by its children or by + * specifying an exact size in pixels or as a percentage of the + * parent element. + * + * This Container does not have a built-in scroll bar or clipping of + * its content should the content exceed the Container's boundaries. To + * have scroll bars and clipping, add the ScrollingView bead. + * + * While the container is relatively lightweight, it should + * generally not be used as the base class for other controls, + * even if those controls are composed of children. That's + * because the fundamental API of Container is to support + * an arbitrary set of children, and most controls only + * support a specific set of children. + * + * And that's one of the advantages of beads: that functionality + * used in a Container can also be used in a Control as long + * as that bead doesn't assume that its strand is a Container. + * + * For example, even though you can use a Panel to create the + * equivalent of an Alert control, the Alert is a + * control and not a Container because the Alert does not + * support an arbitrary set of children. + * + * @see org.apache.flex.html.beads.layout + * @see org.apache.flex.html.supportClasses.ScrollingViewport + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public class Container extends ContainerBase + { + /** + * Constructor. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function Container() + { + super(); + } + + /** + * @flexjsignorecoercion org.apache.flex.core.WrappedHTMLElement + */ + COMPILE::JS + override protected function createElement():WrappedHTMLElement + { + element = document.createElement('div') as WrappedHTMLElement; + + positioner = element; + + // absolute positioned children need a non-null + // position value in the parent. It might + // get set to 'absolute' if the container is + // also absolutely positioned + positioner.style.position = 'relative'; + element.flexjs_wrapper = this; + + /*addEventListener('childrenAdded', + runLayoutHandler); + addEventListener('elementRemoved', + runLayoutHandler);*/ + + return element; + } + } +} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/d8221452/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/ControlBar.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/ControlBar.as b/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/ControlBar.as new file mode 100644 index 0000000..da65539 --- /dev/null +++ b/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/ControlBar.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.IBeadLayout; + import org.apache.flex.core.IChrome; + import org.apache.flex.core.IContainer; + import org.apache.flex.core.ValuesManager; + COMPILE::JS + { + import org.apache.flex.core.WrappedHTMLElement; + } + + /** + * The ControlBar class is used within a Panel as a place to position + * additional controls. The ControlBar appears at the bottom of the + * org.apache.flex.html.Panel + * and is not part of the Panel's scrollable content area. The ControlBar + * is a Container and implements the org.apache.flex.core.IChrome interface, indicating that is + * outside of the Container's content area. The ControlBar uses the following + * beads: + * + * org.apache.flex.core.IBeadModel: the data model for the component. + * org.apache.flex.core.IMeasurementBead: helps determine the overlay size of the ControlBar for layout. + * org.apache.flex.core.IBorderBead: if present, displays a border around the component. + * org.apache.flex.core.IBackgroundBead: if present, displays a solid background below the ControlBar. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public class ControlBar extends Container implements IContainer, IChrome + { + /** + * constructor. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function ControlBar() + { + super(); + + className = "ControlBar"; + } + + /** + * @private + */ + override public function addedToParent():void + { + super.addedToParent(); + + if( getBeadByType(IBeadLayout) == null ) { + var layout:IBeadLayout = new (ValuesManager.valuesImpl.getValue(this, "iBeadLayout")) as IBeadLayout; + addBead(layout); + } + } + + /** + * @flexjsignorecoercion org.apache.flex.core.WrappedHTMLElement + */ + COMPILE::JS + override protected function createElement():WrappedHTMLElement + { + element = document.createElement('div') as WrappedHTMLElement; + element.className = 'ControlBar'; + element.style.display = 'inline'; + typeNames = 'ControlBar'; + + positioner = element; + positioner.style.position = 'relative'; + element.flexjs_wrapper = this; + + return element; + } + + } +} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/d8221452/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/DataGrid.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/DataGrid.as b/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/DataGrid.as new file mode 100644 index 0000000..c271134 --- /dev/null +++ b/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/DataGrid.as @@ -0,0 +1,166 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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.IBead; + import org.apache.flex.core.IDataGridModel; + import org.apache.flex.core.IDataGridPresentationModel; + import org.apache.flex.core.UIBase; + import org.apache.flex.html.beads.models.DataGridPresentationModel; + + [Event(name="change", type="org.apache.flex.events.Event")] + + /** + * The DataGrid class displays a collection of data using columns and rows. Each + * column represents a specific field in the data set; each row represents a specific + * datum. The DataGrid is a composite component built with a org.apache.flex.html.ButtonBar + * for the column headers and a org.apache.flex.html.List for each column. The DataGrid's + * view bead (usually org.apache.flex.html.beads.DataGridView) constructs these parts while + * itemRenderer factories contruct the elements to display the data in each cell. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public class DataGrid extends UIBase + { + /** + * constructor. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function DataGrid() + { + super(); + + className = "DataGrid"; + } + + /** + * The array of org.apache.flex.html.supportClasses.DataGridColumns used to + * describe each column. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get columns():Array + { + return IDataGridModel(model).columns; + } + public function set columns(value:Array):void + { + IDataGridModel(model).columns = value; + } + + /** + * The object used to provide data to the org.apache.flex.html.DataGrid. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get dataProvider():Object + { + return IDataGridModel(model).dataProvider; + } + public function set dataProvider(value:Object):void + { + IDataGridModel(model).dataProvider = value; + } + + /** + * The currently selected row. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get selectedIndex():int + { + return IDataGridModel(model).selectedIndex; + } + + /** + * The DataGrid's presentation model + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get presentationModel():IDataGridPresentationModel + { + var beadMod:IBead = getBeadByType(IDataGridPresentationModel); + var presModel:IDataGridPresentationModel; + + if (beadMod == null) { + presModel = new DataGridPresentationModel(); + addBead(presModel); + } else { + presModel = beadMod as IDataGridPresentationModel; + } + 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; + } + + /** + * @private + * The DataGrid needs to know whenever its size is being changed so the columns can be + * be aligned properly, so the noEvent value must always be false. + */ + override public function setWidth(value:Number, noEvent:Boolean=false):void + { + super.setWidth(value,false); + } + + /** + * @private + * The DataGrid needs to know whenever its size is being changed so the columns can be + * be aligned properly, so the noEvent value must always be false. + */ + override public function setHeight(value:Number, noEvent:Boolean=false):void + { + super.setHeight(value,false); + } + } +} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/d8221452/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/DataGridButtonBar.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/DataGridButtonBar.as b/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/DataGridButtonBar.as new file mode 100644 index 0000000..c7208dc --- /dev/null +++ b/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/DataGridButtonBar.as @@ -0,0 +1,51 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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 org.apache.flex.core.WrappedHTMLElement; + } + + /** + * The DataGridButtonBar class extends ButtonBar and provides a class for styling + * the header region of the DataGrid. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public class DataGridButtonBar extends ButtonBar + { + /** + * constructor. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function DataGridButtonBar() + { + super(); + className = "DataGridButtonBar"; + } + } +} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/d8221452/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/DataGridButtonBarTextButton.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/DataGridButtonBarTextButton.as b/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/DataGridButtonBarTextButton.as new file mode 100644 index 0000000..67be174 --- /dev/null +++ b/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/DataGridButtonBarTextButton.as @@ -0,0 +1,55 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +//////////////////////////////////////////////////////////////////////////////// +package org.apache.flex.html +{ + import org.apache.flex.core.ITextModel; + + COMPILE::JS { + import org.apache.flex.core.WrappedHTMLElement; + } + + /** + * The DataGridButtonBarTextButton class extends TextButton so that + * the buttons used in the DataGrid header can be styled separately + * from normal TextButtons. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public class DataGridButtonBarTextButton extends TextButton + { + /** + * Constructor. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function DataGridButtonBarTextButton() + { + super(); + typeNames = ""; + className = "DataGridButtonBarTextButton"; + } + + } +} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/d8221452/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/DateChooser.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/DateChooser.as b/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/DateChooser.as new file mode 100644 index 0000000..62b5a3e --- /dev/null +++ b/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/DateChooser.as @@ -0,0 +1,74 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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.IDateChooserModel; + import org.apache.flex.core.UIBase; + + /** + * The change event is dispatched when the selectedDate is changed. + */ + [Event(name="change", type="org.apache.flex.events.Event")] + + /** + * The DateChooser class is a component that displays a calendar. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public class DateChooser extends UIBase + { + /** + * constructor. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function DateChooser() + { + super(); + className = "DateChooser"; + + // fix the DateChooser's size + width = 280; + height = 240; + } + + /** + * The currently selected date (or null if no date has been selected). + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get selectedDate():Date + { + return IDateChooserModel(model).selectedDate; + } + public function set selectedDate(value:Date):void + { + IDateChooserModel(model).selectedDate = value; + } + } +} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/d8221452/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/DateField.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/DateField.as b/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/DateField.as new file mode 100644 index 0000000..f46e453 --- /dev/null +++ b/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/DateField.as @@ -0,0 +1,95 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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.IBead; + import org.apache.flex.core.IDateChooserModel; + import org.apache.flex.core.UIBase; + import org.apache.flex.core.ValuesManager; + + /** + * The change event is dispatched when the selectedDate is changed. + */ + [Event(name="change", type="org.apache.flex.events.Event")] + + /** + * The DateField class provides an input field where a date can be entered + * and a pop-up calendar control for picking a date as an alternative to + * the text field. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public class DateField extends UIBase + { + /** + * constructor. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function DateField() + { + super(); + + className = "DateField"; + } + + /** + * The method called when added to a parent. The DateField class uses + * this opportunity to install additional beads. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + override public function addedToParent():void + { + var klass:* = ValuesManager.valuesImpl.getValue(this,"iFormatBead"); + var bead:IBead = new klass() as IBead; + if (bead) { + addBead(bead); + } + + super.addedToParent(); + } + + /** + * The currently selected date (or null if no date has been selected). + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get selectedDate():Date + { + return IDateChooserModel(model).selectedDate; + } + public function set selectedDate(value:Date):void + { + IDateChooserModel(model).selectedDate = value; + } + } +} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/d8221452/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/DropDownList.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/DropDownList.as b/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/DropDownList.as new file mode 100644 index 0000000..dd069b2 --- /dev/null +++ b/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/DropDownList.as @@ -0,0 +1,235 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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.ISelectionModel; + + COMPILE::JS + { + import goog.events; + import org.apache.flex.core.WrappedHTMLElement; + import org.apache.flex.html.beads.models.ArraySelectionModel; + } + + //-------------------------------------- + // Events + //-------------------------------------- + + /** + * Dispatched when the user selects an item. + * + * @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 DropDownList class implements the basic equivalent of + * the <code><select></code> tag in HTML. + * The default implementation only lets the user see and + * choose from an array of strings. More complex controls + * would display icons as well as strings, or colors instead + * of strings or just about anything. + * + * The default behavior only lets the user choose one and + * only one item. More complex controls would allow + * mutiple selection by not dismissing the dropdown as soon + * as a selection is made. + * + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public class DropDownList extends Button + { + /** + * Constructor. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function DropDownList() + { + COMPILE::JS + { + model = new ArraySelectionModel(); + } + } + + /** + * The data set to be displayed. Usually a simple + * array of strings. A more complex component + * would allow more complex data and data sets. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get dataProvider():Object + { + return ISelectionModel(model).dataProvider; + } + + /** + * @private + * @flexjsignorecoercion HTMLOptionElement + * @flexjsignorecoercion HTMLSelectElement + */ + public function set dataProvider(value:Object):void + { + ISelectionModel(model).dataProvider = value; + COMPILE::JS + { + var dp:HTMLOptionsCollection; + var i:int; + var n:int; + var opt:HTMLOptionElement; + var dd:HTMLSelectElement = element as HTMLSelectElement; + + model.dataProvider = value; + dp = dd.options; + n = dp.length; + for (i = 0; i < n; i++) { + dd.remove(0); + } + + var lf:String = labelField; + n = value.length; + for (i = 0; i < n; i++) { + opt = document.createElement('option') as HTMLOptionElement; + if (lf) + opt.text = value[i][lf]; + else + opt.text = value[i]; + dd.add(opt, null); + } + + } + } + + [Bindable("change")] + /** + * @copy org.apache.flex.core.ISelectionModel#selectedIndex + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get selectedIndex():int + { + return ISelectionModel(model).selectedIndex; + } + + /** + * @private + * @flexjsignorecoercion HTMLSelectElement + */ + public function set selectedIndex(value:int):void + { + ISelectionModel(model).selectedIndex = value; + COMPILE::JS + { + (element as HTMLSelectElement).selectedIndex = ISelectionModel(model).selectedIndex; + } + } + + + [Bindable("change")] + /** + * @copy org.apache.flex.core.ISelectionModel#selectedItem + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get selectedItem():Object + { + return ISelectionModel(model).selectedItem; + } + + /** + * @private + * @flexjsignorecoercion HTMLSelectElement + */ + public function set selectedItem(value:Object):void + { + ISelectionModel(model).selectedItem = value; + COMPILE::JS + { + (element as HTMLSelectElement).selectedIndex = ISelectionModel(model).selectedIndex; + } + } + + /** + * 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; + } + + /** + * @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 = 1; + goog.events.listen(element, 'change', + changeHandler); + + positioner = element; + positioner.style.position = 'relative'; + + element.flexjs_wrapper = this; + + 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/d8221452/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/Form.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/Form.as b/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/Form.as new file mode 100644 index 0000000..d7b0459 --- /dev/null +++ b/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/Form.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.ContainerBase; + + COMPILE::JS + { + import org.apache.flex.core.WrappedHTMLElement; + } + + [DefaultProperty("mxmlContent")] + + /** + * The Form class is a simple form. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public class Form extends ContainerBase + { + /** + * Constructor. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function Form() + { + super(); + } + + /** + * @flexjsignorecoercion org.apache.flex.core.WrappedHTMLElement + */ + COMPILE::JS + override protected function createElement():WrappedHTMLElement + {HTMLFormElement + element = document.createElement('form') as WrappedHTMLElement; + + positioner = element; + + positioner.style.position = 'relative'; + element.flexjs_wrapper = this; + return element; + } + + + private var _action:String = "#"; + + [Bindable("actionChange")] + /** + * The action to be performed when the form is submitted + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get action():String + { + return _action; + } + + /** + * @private + */ + public function set action(value:String):void + { + _action = value; + + COMPILE::JS + { + this.element.setAttribute('action', action); + this.dispatchEvent('actionChange'); + } + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/d8221452/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/HContainer.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/HContainer.as b/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/HContainer.as new file mode 100644 index 0000000..9f38883 --- /dev/null +++ b/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/HContainer.as @@ -0,0 +1,61 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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.ContainerBase; + import org.apache.flex.core.IChrome; + import org.apache.flex.core.IContainer; + import org.apache.flex.core.IUIBase; + import org.apache.flex.events.Event; + + [DefaultProperty("mxmlContent")] + + /** + * A Container that has a HorizontalLayout. + * + * This is effectively the same as the pattern + * <code> + * <basic:Container xmlns:basic="library://ns.apache.org/flexjs/basic"> + * <basic:layout> + * <basic:HorizontalLayout /> + * </basic:layout> + * </basic:Container> + * </code> + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public class HContainer extends Container implements IContainer + { + /** + * Constructor. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function HContainer() + { + super(); + } + } +} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/d8221452/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/HRule.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/HRule.as b/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/HRule.as new file mode 100644 index 0000000..7c2fb2f --- /dev/null +++ b/frameworks/projects/Basic/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/d8221452/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/Image.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/Image.as b/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/Image.as new file mode 100644 index 0000000..0a42d2a --- /dev/null +++ b/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/Image.as @@ -0,0 +1,93 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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; + + return element; + } + + } +} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/d8221452/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/ImageAndTextButton.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/ImageAndTextButton.as b/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/ImageAndTextButton.as new file mode 100644 index 0000000..8bdcc6a --- /dev/null +++ b/frameworks/projects/Basic/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/d8221452/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/ImageButton.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/ImageButton.as b/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/ImageButton.as new file mode 100644 index 0000000..de563a1 --- /dev/null +++ b/frameworks/projects/Basic/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/d8221452/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/Label.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/Label.as b/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/Label.as new file mode 100644 index 0000000..21282f8 --- /dev/null +++ b/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/Label.as @@ -0,0 +1,194 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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::SWF + { + return ITextModel(model).text; + } + COMPILE::JS + { + return element.innerHTML; + } + } + + /** + * @private + */ + public function set text(value:String):void + { + COMPILE::SWF + { + 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::SWF + { + return ITextModel(model).html; + } + COMPILE::JS + { + return element.innerHTML; + } + } + + /** + * @private + */ + public function set html(value:String):void + { + COMPILE::SWF + { + ITextModel(model).html = value; + } + COMPILE::JS + { + this.element.innerHTML = value; + this.dispatchEvent('textChange'); + } + } + private var _selectable:Boolean; + + public function get selectable():Boolean + { + return _selectable; + } + public function set selectable(value:Boolean):void + { + if(value != _selectable) + { + _selectable = value; + COMPILE::JS + { + if(element) + { + element.style.cursor = _selectable ? "auto" : "default"; + element.style.pointerEvents = _selectable ? "auto" : "none"; + } + } + } + + } + + + /** + * @private + */ + COMPILE::SWF + 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; + element.style.whiteSpace = "nowrap"; + if(!selectable) + { + element.style.cursor = "default"; + element.style.pointerEvents = "none"; + } + + className = "Label"; + typeNames = "Label"; + return element; + } + + } +} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/d8221452/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/List.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/List.as b/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/List.as new file mode 100644 index 0000000..17c8b3f --- /dev/null +++ b/frameworks/projects/Basic/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::SWF { + 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; + }; + } +}
