http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/d8221452/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/MXMLBeadView.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/MXMLBeadView.as b/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/MXMLBeadView.as new file mode 100644 index 0000000..1807381 --- /dev/null +++ b/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/MXMLBeadView.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 MXMLBeadView class extends ContainerView + * 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 MXMLBeadView extends ContainerView implements IStrand, ILayoutHost + { + /** + * Constructor. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function MXMLBeadView() + { + super(); + } + + [Bindable("strandChanged")] + /** + * An MXMLBeadView 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::SWF + { + 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; + } + + } +}
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/d8221452/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/MultilineLabel.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/MultilineLabel.as b/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/MultilineLabel.as new file mode 100644 index 0000000..5149237 --- /dev/null +++ b/frameworks/projects/Basic/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/d8221452/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/NumericStepper.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/NumericStepper.as b/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/NumericStepper.as new file mode 100644 index 0000000..e919295 --- /dev/null +++ b/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/NumericStepper.as @@ -0,0 +1,202 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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(); + input.className = "NumericStepperInput"; + input.typeNames = "NumericStepperInput"; + addElement(input); + input.positioner.style.display = 'inline-block'; + input.positioner.style.width = '100px'; + + spinner = new Spinner(); + addElement(spinner); + + /* TODO: ajh move to view and css */ + 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/d8221452/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/Panel.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/Panel.as b/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/Panel.as new file mode 100644 index 0000000..e9c5986 --- /dev/null +++ b/frameworks/projects/Basic/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/d8221452/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/PanelWithControlBar.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/PanelWithControlBar.as b/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/PanelWithControlBar.as new file mode 100644 index 0000000..7659d9d --- /dev/null +++ b/frameworks/projects/Basic/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/d8221452/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/RadioButton.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/RadioButton.as b/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/RadioButton.as new file mode 100644 index 0000000..9aa2254 --- /dev/null +++ b/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/RadioButton.as @@ -0,0 +1,350 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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::SWF + { + 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::SWF + { + import org.apache.flex.core.UIButtonBase; + } + COMPILE::JS + { + import org.apache.flex.core.UIBase; + import org.apache.flex.core.WrappedHTMLElement; + import org.apache.flex.html.supportClasses.RadioButtonIcon; + } + import org.apache.flex.events.Event; + import org.apache.flex.events.MouseEvent; + 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::SWF + 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(org.apache.flex.events.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:org.apache.flex.events.MouseEvent) : 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 labelFor:HTMLLabelElement; + private var textNode:Text; + private var icon:RadioButtonIcon; + + /** + * @flexjsignorecoercion org.apache.flex.core.WrappedHTMLElement + * @flexjsignorecoercion HTMLInputElement + * @flexjsignorecoercion HTMLLabelElement + * @flexjsignorecoercion Text + */ + override protected function createElement():WrappedHTMLElement + { + icon = new RadioButtonIcon() + icon.id = '_radio_' + RadioButton.radioCounter++; + + textNode = document.createTextNode('radio button') as Text; + + labelFor = document.createElement('label') as HTMLLabelElement; + labelFor.appendChild(icon.element); + labelFor.appendChild(textNode); + + element = labelFor as WrappedHTMLElement; + + positioner = element; + positioner.style.position = 'relative'; + + (element as WrappedHTMLElement).flexjs_wrapper = this; + (textNode as WrappedHTMLElement).flexjs_wrapper = this; + (icon.element as WrappedHTMLElement).flexjs_wrapper = this; + + className = 'RadioButton'; + typeNames = 'RadioButton, RadioButtonIcon'; + + return element; + } + + override public function set id(value:String):void + { + super.id = value; + labelFor.id = value; + icon.element.id = value; + } + + public function get groupName():String + { + return (icon.element as HTMLInputElement).name as String; + } + public function set groupName(value:String):void + { + (icon.element as HTMLInputElement).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 (icon.element as HTMLInputElement).checked; + } + public function set selected(value:Boolean):void + { + (icon.element as HTMLInputElement).checked = value; + } + + public function get value():Object + { + return (icon.element as HTMLInputElement).value; + } + public function set value(v:Object):void + { + (icon.element as HTMLInputElement).value = v as String; + } + + public function get selectedValue():Object + { + var buttons:NodeList; + var groupName:String; + var i:int; + var n:int; + + groupName = (icon.element as HTMLInputElement).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 = (icon.element as HTMLInputElement).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/d8221452/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/RangeStepper.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/RangeStepper.as b/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/RangeStepper.as new file mode 100644 index 0000000..bcba27b --- /dev/null +++ b/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/RangeStepper.as @@ -0,0 +1,69 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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; + + /** + * The RangeStepper control allows for the selection of a single value + * from multiple choices. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public class RangeStepper extends UIBase + { + /** + * constructor. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function RangeStepper() + { + super(); + + className = "RangeStepper"; + + setWidthAndHeight(40, 60, true); + } + + /** + * The value selected or set. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function set value(newValue:Number):void + { + IRangeModel(model).value = newValue; + } + public function get value():Number + { + return IRangeModel(model).value; + } + } +} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/d8221452/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/SimpleAlert.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/SimpleAlert.as b/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/SimpleAlert.as new file mode 100644 index 0000000..0719036 --- /dev/null +++ b/frameworks/projects/Basic/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 showAlert(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::SWF + { + var alert:SimpleAlert = new SimpleAlert(); + alert.message = message; + alert.showAlert(parent); + + return alert; + } + COMPILE::JS + { + alert(message); + return null; + } + } + + } +} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/d8221452/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/SimpleList.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/SimpleList.as b/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/SimpleList.as new file mode 100644 index 0000000..9dcb348 --- /dev/null +++ b/frameworks/projects/Basic/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/d8221452/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/Slider.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/Slider.as b/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/Slider.as new file mode 100644 index 0000000..d10891c --- /dev/null +++ b/frameworks/projects/Basic/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 = "" + xloc + 'px'; + } + + } +} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/d8221452/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/Spacer.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/Spacer.as b/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/Spacer.as new file mode 100644 index 0000000..d7ab050 --- /dev/null +++ b/frameworks/projects/Basic/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; + } + + } +} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/d8221452/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/Spinner.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/Spinner.as b/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/Spinner.as new file mode 100644 index 0000000..65b5290 --- /dev/null +++ b/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/Spinner.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.IRangeModel; + import org.apache.flex.core.UIBase; + + COMPILE::JS + { + import org.apache.flex.core.WrappedHTMLElement; + } + + [Event(name="valueChange", type="org.apache.flex.events.Event")] + + /** + * The Spinner class is a component that displays a control for incrementing a value + * and a control for decrementing a value. The org.apache.flex.html.NumericStepper + * uses a Spinner as part of the component. Spinner uses the following beads: + * + * org.apache.flex.core.IBeadModel: an IRangeModel to hold the properties. + * org.apache.flex.core.IBeadView: the bead that constructs the visual parts of the Spinner. + * org.apache.flex.core.IBeadController: a bead that handles the input events. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public class Spinner extends UIBase + { + /** + * constructor. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function Spinner() + { + super(); + + className = "Spinner"; + } + + /** + * The current value of the Spinner. + * + * @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 Spinner. + * + * @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 Spinner. + * + * @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 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; + } + + /** + * 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; + } + + /** + * @flexjsignorecoercion org.apache.flex.core.WrappedHTMLElement + */ + COMPILE::JS + override protected function createElement():WrappedHTMLElement + { + element = document.createElement('div') as WrappedHTMLElement; + positioner = element; + positioner.style.position = 'relative'; + + element.style.verticalAlign = 'middle'; + 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/TextArea.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/TextArea.as b/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/TextArea.as new file mode 100644 index 0000000..10b7555 --- /dev/null +++ b/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/TextArea.as @@ -0,0 +1,126 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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; + COMPILE::JS + { + import org.apache.flex.core.WrappedHTMLElement; + } + + /** + * The TextArea class implements the basic control for + * multi-line text input. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public class TextArea extends UIBase + { + /** + * Constructor. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function TextArea() + { + super(); + } + + /** + * @copy org.apache.flex.html.Label#text + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + * @flexjsignorecoercion HTMLInputElement + */ + public function get text():String + { + COMPILE::SWF + { + return ITextModel(model).text; + } + COMPILE::JS + { + return (element as HTMLInputElement).value; + } + } + + /** + * @private + * @flexjsignorecoercion HTMLInputElement + */ + public function set text(value:String):void + { + COMPILE::SWF + { + ITextModel(model).text = value; + } + COMPILE::JS + { + (element as HTMLInputElement).value = value; + } + } + + /** + * @copy org.apache.flex.html.Label#html + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get html():String + { + return ITextModel(model).html; + } + + /** + * @private + */ + public function set html(value:String):void + { + ITextModel(model).html = value; + } + + /** + * @flexjsignorecoercion org.apache.flex.core.WrappedHTMLElement + */ + COMPILE::JS + override protected function createElement():WrappedHTMLElement + { + element = document.createElement('textarea') as WrappedHTMLElement; + positioner = element; + positioner.style.position = 'relative'; + element.flexjs_wrapper = this; + element.className = 'TextArea'; + typeNames = 'TextArea'; + + return element; + } + } +} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/d8221452/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/TextButton.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/TextButton.as b/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/TextButton.as new file mode 100644 index 0000000..a08c9b3 --- /dev/null +++ b/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/TextButton.as @@ -0,0 +1,139 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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; + } + + [DefaultProperty("text")] + + /** + * The TextButton class implements a basic button that + * displays text. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public class TextButton extends ButtonBase + { + /** + * Constructor. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function TextButton() + { + super(); + } + + /** + * @copy org.apache.flex.html.Label#text + * + * @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'); + } + } + + /** + * @copy org.apache.flex.html.Label#html + * + * @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 + * @flexjsignorecoercion org.apache.flex.core.WrappedHTMLElement + */ + COMPILE::JS + override protected function createElement():WrappedHTMLElement + { + var element:WrappedHTMLElement = super.createElement(); + className = "TextButton"; + typeNames = "TextButton"; + return element; + } + + } +} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/d8221452/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/TextInput.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/TextInput.as b/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/TextInput.as new file mode 100644 index 0000000..c8df45d --- /dev/null +++ b/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/TextInput.as @@ -0,0 +1,187 @@ +// +// 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.events.Event; + COMPILE::JS + { + import goog.events; + import org.apache.flex.core.WrappedHTMLElement; + } + + /** + * Dispatched when the user changes the text. + * + * @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 TextInput class implements the basic control for + * single-line text input. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public class TextInput extends UIBase + { + /** + * Constructor. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function TextInput() + { + super(); + + COMPILE::SWF + { + model.addEventListener("textChange", textChangeHandler); + } + } + + /** + * @copy org.apache.flex.html.Label#text + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + * @flexjsignorecoercion HTMLInputElement + */ + [Bindable(event="change")] + public function get text():String + { + COMPILE::SWF + { + return ITextModel(model).text; + } + COMPILE::JS + { + return (element as HTMLInputElement).value; + } + } + + /** + * @private + * @flexjsignorecoercion HTMLInputElement + */ + public function set text(value:String):void + { + COMPILE::SWF + { + inSetter = true; + ITextModel(model).text = value; + inSetter = false; + } + COMPILE::JS + { + (element as HTMLInputElement).value = value; + dispatchEvent(new Event('textChange')); + } + } + + /** + * @copy org.apache.flex.html.Label#html + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + * @flexjsignorecoercion HTMLInputElement + */ + [Bindable(event="change")] + public function get html():String + { + COMPILE::SWF + { + return ITextModel(model).html; + } + COMPILE::JS + { + return (element as HTMLInputElement).value; + } + } + + /** + * @private + * @flexjsignorecoercion HTMLInputElement + */ + public function set html(value:String):void + { + COMPILE::SWF + { + ITextModel(model).html = value; + } + COMPILE::JS + { + (element as HTMLInputElement).value = value; + dispatchEvent(new Event('textChange')); + } + } + + private var inSetter:Boolean; + + /** + * dispatch change event in response to a textChange event + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function textChangeHandler(event:Event):void + { + if (!inSetter) + dispatchEvent(new Event(Event.CHANGE)); + } + + /** + * @flexjsignorecoercion org.apache.flex.core.WrappedHTMLElement + */ + COMPILE::JS + override protected function createElement():WrappedHTMLElement + { + element = document.createElement('input') as WrappedHTMLElement; + element.setAttribute('type', 'input'); + element.className = 'TextInput'; + typeNames = 'TextInput'; + + //attach input handler to dispatch flexjs change event when user write in textinput + //goog.events.listen(element, 'change', killChangeHandler); + goog.events.listen(element, 'input', textChangeHandler); + + 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/TitleBar.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/TitleBar.as b/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/TitleBar.as new file mode 100644 index 0000000..3902330 --- /dev/null +++ b/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/TitleBar.as @@ -0,0 +1,146 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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.IBeadLayout; + import org.apache.flex.core.IChrome; + import org.apache.flex.core.ITitleBarModel; + import org.apache.flex.core.ValuesManager; + COMPILE::JS + { + import org.apache.flex.core.WrappedHTMLElement; + } + import org.apache.flex.events.Event; + import org.apache.flex.html.Label; + + /** + * The TitleBar class is a Container component that displays a title and an + * optional close button. The TitleBar uses the following bead types: + * + * org.apache.flex.core.IBeadModel: the data model, which includes the title and showCloseButton values. + * org.apache.flex.core.IBeadView: the bead that constructs the visual parts of the component. + * org.apache.flex.core.IBeadLayout: the bead that handles size and position of the component parts + * (org.apache.flex.html.Label and org.apache.flex.html.Button). + * org.apache.flex.core.IMeasurementBead: a bead that helps determine the size of the + * org.apache.flex.html.TitleBar for layout. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public class TitleBar extends Container implements IChrome + { + /** + * constructor. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function TitleBar() + { + super(); + + className = "TitleBar"; + } + + /** + * The title string to display. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get title():String + { + return ITitleBarModel(model).title; + } + public function set title(value:String):void + { + ITitleBarModel(model).title = value; + } + + /** + * The HTML title to display. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get htmlTitle():String + { + return ITitleBarModel(model).htmlTitle; + } + public function set htmlTitle(value:String):void + { + ITitleBarModel(model).htmlTitle = value; + } + + /** + * Whether or not to show a org.apache.flex.html.Button that indicates the component + * may be closed. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get showCloseButton():Boolean + { + return ITitleBarModel(model).showCloseButton; + } + public function set showCloseButton(value:Boolean):void + { + ITitleBarModel(model).showCloseButton = value; + } + + /** + * @private + */ + override public function addedToParent():void + { + super.addedToParent(); + + if( getBeadByType(IBeadLayout) == null ) + addBead(new (ValuesManager.valuesImpl.getValue(this, "iBeadLayout")) as IBead); + } + + /** + * @flexjsignorecoercion org.apache.flex.core.WrappedHTMLElement + */ + COMPILE::JS + override protected function createElement():WrappedHTMLElement + { + element = document.createElement('div') as WrappedHTMLElement; + + positioner = element; + positioner.style.position = 'relative'; + element.flexjs_wrapper = this; + + className = 'TitleBar'; + + return element; + } + } +}