http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/7853ef15/frameworks/projects/HTML/as/src/org/apache/flex/html/accessories/NumericOnlyTextInputBead.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/HTML/as/src/org/apache/flex/html/accessories/NumericOnlyTextInputBead.as b/frameworks/projects/HTML/as/src/org/apache/flex/html/accessories/NumericOnlyTextInputBead.as deleted file mode 100644 index 8790830..0000000 --- a/frameworks/projects/HTML/as/src/org/apache/flex/html/accessories/NumericOnlyTextInputBead.as +++ /dev/null @@ -1,199 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// -// 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.accessories -{ - COMPILE::JS - { - import goog.events.BrowserEvent; - } - COMPILE::AS3 - { - import flash.events.TextEvent; - - import org.apache.flex.core.CSSTextField; - } - import org.apache.flex.core.IBead; - import org.apache.flex.core.IStrand; - import org.apache.flex.events.Event; - import org.apache.flex.events.IEventDispatcher; - COMPILE::AS3 - { - import org.apache.flex.html.beads.ITextFieldView; - } - - /** - * The NumericOnlyTextInputBead class is a specialty bead that can be used with - * any TextInput control. The bead prevents non-numeric entry into the text input - * area. - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public class NumericOnlyTextInputBead implements IBead - { - /** - * constructor. - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public function NumericOnlyTextInputBead() - { - } - - private var _strand:IStrand; - - /** - * @copy org.apache.flex.core.IBead#strand - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public function set strand(value:IStrand):void - { - _strand = value; - - COMPILE::AS3 - { - IEventDispatcher(value).addEventListener("viewChanged",viewChangeHandler); - } - COMPILE::JS - { - IEventDispatcher(value).addEventListener("keypress",validateInput); - } - } - - private var _decimalSeparator:String = "."; - - /** - * The character used to separate the integer and fraction parts of numbers. - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public function get decimalSeparator():String - { - return _decimalSeparator; - } - public function set decimalSeparator(value:String):void - { - if (_decimalSeparator != value) { - _decimalSeparator = value; - } - } - - private var _maxChars:int = 0; - - /** - * The character used to separate the integer and fraction parts of numbers. - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public function get maxChars():int - { - return _maxChars; - } - public function set maxChars(value:int):void - { - if (_maxChars != value) { - _maxChars = value; - } - } - - /** - * @private - */ - COMPILE::AS3 - private function viewChangeHandler(event:Event):void - { - // get the ITextFieldView bead, which is required for this bead to work - var textView:ITextFieldView = _strand.getBeadByType(ITextFieldView) as ITextFieldView; - if (textView) { - var textField:CSSTextField = textView.textField; - textField.restrict = "0-9" + decimalSeparator; - textField.maxChars = maxChars; - // listen for changes to this textField and prevent non-numeric values, such - // as 34.09.94 - textField.addEventListener(TextEvent.TEXT_INPUT, handleTextInput); - } - else { - throw new Error("NumericOnlyTextInputBead requires strand to have an ITextFieldView bead"); - } - } - - /** - * @private - */ - COMPILE::AS3 - private function handleTextInput(event:TextEvent):void - { - var insert:String = event.text; - var caretIndex:int = (event.target as CSSTextField).caretIndex; - var current:String = (event.target as CSSTextField).text; - var value:String = current.substring(0,caretIndex) + insert + current.substr(caretIndex); - var n:Number = Number(value); - if (isNaN(n)) event.preventDefault(); - } - - COMPILE::JS - private function validateInput(event:BrowserEvent):void - { - var code:int = event.charCode; - - // backspace or delete - if (event.keyCode == 8 || event.keyCode == 46) return; - - // tab or return/enter - if (event.keyCode == 9 || event.keyCode == 13) return; - - // left or right cursor arrow - if (event.keyCode == 37 || event.keyCode == 39) return; - - var key:String = String.fromCharCode(code); - - var regex:RegExp = /[0-9]|\./; - if (!regex.test(key)) { - event["returnValue"] = false; - if (event.preventDefault) event.preventDefault(); - return; - } - var cursorStart:int = event.target.selectionStart; - var cursorEnd:int = event.target.selectionEnd; - var left:String = event.target.value.substring(0, cursorStart); - var right:String = event.target.value.substr(cursorEnd); - var complete:String = left + key + right; - if (isNaN(parseFloat(complete))) { - event["returnValue"] = false; - if (event.preventDefault) event.preventDefault(); - } - - } - } -}
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/7853ef15/frameworks/projects/HTML/as/src/org/apache/flex/html/accessories/PasswordInputBead.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/HTML/as/src/org/apache/flex/html/accessories/PasswordInputBead.as b/frameworks/projects/HTML/as/src/org/apache/flex/html/accessories/PasswordInputBead.as deleted file mode 100644 index 191339b..0000000 --- a/frameworks/projects/HTML/as/src/org/apache/flex/html/accessories/PasswordInputBead.as +++ /dev/null @@ -1,102 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// -// 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.accessories -{ - COMPILE::AS3 - { - import org.apache.flex.core.CSSTextField; - } - import org.apache.flex.core.IBead; - import org.apache.flex.core.IStrand; - import org.apache.flex.core.UIBase; - import org.apache.flex.events.Event; - import org.apache.flex.events.IEventDispatcher; - COMPILE::AS3 - { - import org.apache.flex.html.beads.ITextFieldView; - } - - /** - * The PasswordInput class is a specialty bead that can be used with - * any TextInput control. The bead secures the text input area by masking - * the input as it is typed. - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public class PasswordInputBead implements IBead - { - /** - * constructor. - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public function PasswordInputBead() - { - } - - private var _strand:IStrand; - - /** - * @copy org.apache.flex.core.IBead#strand - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public function set strand(value:IStrand):void - { - _strand = value; - - COMPILE::AS3 - { - IEventDispatcher(value).addEventListener("viewChanged",viewChangeHandler); - } - COMPILE::JS - { - var host:UIBase = value as UIBase; - var e:HTMLInputElement = host.element as HTMLInputElement; - e.type = 'password'; - } - } - - /** - * @private - */ - COMPILE::AS3 - private function viewChangeHandler(event:Event):void - { - // get the ITextFieldView bead, which is required for this bead to work - var textView:ITextFieldView = _strand.getBeadByType(ITextFieldView) as ITextFieldView; - if (textView) { - var textField:CSSTextField = textView.textField; - textField.displayAsPassword = true; - } - else { - throw new Error("PasswordInputBead requires strand to have a TextInputView bead"); - } - } - } -} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/7853ef15/frameworks/projects/HTML/as/src/org/apache/flex/html/accessories/TextPromptBead.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/HTML/as/src/org/apache/flex/html/accessories/TextPromptBead.as b/frameworks/projects/HTML/as/src/org/apache/flex/html/accessories/TextPromptBead.as deleted file mode 100644 index 5447da6..0000000 --- a/frameworks/projects/HTML/as/src/org/apache/flex/html/accessories/TextPromptBead.as +++ /dev/null @@ -1,148 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// -// 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.accessories -{ - COMPILE::AS3 - { - import flash.text.TextFieldType; - - import org.apache.flex.core.CSSTextField; - } - - import org.apache.flex.core.IBead; - import org.apache.flex.core.IStrand; - import org.apache.flex.core.UIBase; - import org.apache.flex.events.Event; - import org.apache.flex.events.IEventDispatcher; - - /** - * The TextPromptBead class is a specialty bead that can be used with - * any TextInput control. The bead places a string into the input field - * when there is no value associated with the text property. - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public class TextPromptBead implements IBead - { - /** - * constructor. - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public function TextPromptBead() - { - } - - private var _prompt:String; - - /** - * The string to use as the placeholder prompt. - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public function get prompt():String - { - return _prompt; - } - public function set prompt(value:String):void - { - _prompt = value; - } - - private var _strand:IStrand; - - /** - * @copy org.apache.flex.core.IBead#strand - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - * @flexjsignorecoercion HTMLInputElement - * @flexjsignorecoercion org.apache.flex.core.UIBase; - */ - public function set strand(value:IStrand):void - { - _strand = value; - - COMPILE::AS3 - { - // listen for changes in text to hide or show the prompt - var model:Object = UIBase(_strand).model; - if (!model.hasOwnProperty("text")) { - throw new Error("Model requires a text property when used with TextPromptBead"); - } - IEventDispatcher(model).addEventListener("textChange", handleTextChange); - - // create a TextField that displays the prompt - it shows - // and hides based on the model's content - promptField = new CSSTextField(); - promptField.selectable = false; - promptField.type = TextFieldType.DYNAMIC; - promptField.mouseEnabled = false; - promptField.multiline = false; - promptField.wordWrap = false; - promptField.textColor = 0xBBBBBB; - - // trigger the event handler to display if needed - handleTextChange(null); - } - COMPILE::JS - { - var host:UIBase = value as UIBase; - var e:HTMLInputElement = host.element as HTMLInputElement; - e.placeholder = prompt; - } - } - - COMPILE::AS3 - private var promptField:CSSTextField; - private var promptAdded:Boolean; - - /** - * @private - */ - COMPILE::AS3 - private function handleTextChange( event:Event ):void - { - // see what the model currently has to determine if the prompt should be - // displayed or not. - var model:Object = UIBase(_strand).model; - - if (model.text != null && model.text.length > 0 ) { - if (promptAdded) UIBase(_strand).removeChild(promptField); - promptAdded = false; - } - else { - if (!promptAdded) UIBase(_strand).addChild(promptField); - promptField.text = prompt; - promptAdded = true; - } - } - } -} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/7853ef15/frameworks/projects/HTML/as/src/org/apache/flex/html/accessories/ToolTipBead.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/HTML/as/src/org/apache/flex/html/accessories/ToolTipBead.as b/frameworks/projects/HTML/as/src/org/apache/flex/html/accessories/ToolTipBead.as deleted file mode 100644 index 64d04bf..0000000 --- a/frameworks/projects/HTML/as/src/org/apache/flex/html/accessories/ToolTipBead.as +++ /dev/null @@ -1,141 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// -// 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.accessories -{ - - import org.apache.flex.core.IBead; - import org.apache.flex.core.IPopUpHost; - import org.apache.flex.core.IStrand; - import org.apache.flex.core.IUIBase; - import org.apache.flex.core.UIBase; - import org.apache.flex.events.Event; - import org.apache.flex.events.IEventDispatcher; - import org.apache.flex.events.MouseEvent; - import org.apache.flex.events.utils.MouseUtils; - import org.apache.flex.geom.Point; - import org.apache.flex.html.ToolTip; - import org.apache.flex.utils.PointUtils; - import org.apache.flex.utils.UIUtils; - - /** - * The ToolTipBead class is a specialty bead that can be used with - * any control. The bead floats a string over a control if - * the user hovers over the control with a mouse. - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public class ToolTipBead implements IBead - { - /** - * constructor. - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public function ToolTipBead() - { - } - - private var _toolTip:String; - - /** - * The string to use as the toolTip. - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public function get toolTip():String - { - return _toolTip; - } - public function set toolTip(value:String):void - { - _toolTip = value; - } - - private var _strand:IStrand; - - /** - * @copy org.apache.flex.core.IBead#strand - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public function set strand(value:IStrand):void - { - _strand = value; - - IEventDispatcher(_strand).addEventListener(MouseEvent.MOUSE_OVER, rollOverHandler, false); - } - - private var tt:ToolTip; - private var host:IPopUpHost; - - /** - * @private - */ - protected function rollOverHandler( event:MouseEvent ):void - { - IEventDispatcher(_strand).addEventListener(MouseEvent.MOUSE_OUT, rollOutHandler, false); - - var comp:IUIBase = _strand as IUIBase - host = UIUtils.findPopUpHost(comp); - if (tt) host.removeElement(tt); - - tt = new ToolTip(); - tt.text = toolTip; - var pt:Point = determinePosition(event, event.target); - tt.x = pt.x; - tt.y = pt.y; - host.addElement(tt, false); // don't trigger a layout - } - - /** - * @private - * Determines the position of the toolTip. - */ - protected function determinePosition(event:MouseEvent, base:Object):Point - { - var comp:IUIBase = _strand as IUIBase; - var pt:Point = new Point(comp.width, comp.height); - pt = PointUtils.localToGlobal(pt, comp); - return pt; - } - - /** - * @private - */ - private function rollOutHandler( event:MouseEvent ):void - { - if (tt) { - host.removeElement(tt); - } - tt = null; - } - } -} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/7853ef15/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/AlertMeasurementBead.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/AlertMeasurementBead.as b/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/AlertMeasurementBead.as deleted file mode 100644 index dbe6c05..0000000 --- a/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/AlertMeasurementBead.as +++ /dev/null @@ -1,88 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// -// Licensed to the Apache Software Foundation (ASF) under one or more -// contributor license agreements. See the NOTICE file distributed with -// this work for additional information regarding copyright ownership. -// The ASF licenses this file to You under the Apache License, Version 2.0 -// (the "License"); you may not use this file except in compliance with -// the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -//////////////////////////////////////////////////////////////////////////////// -package org.apache.flex.html.beads -{ - import org.apache.flex.core.IMeasurementBead; - import org.apache.flex.core.IStrand; - - /** - * The AlertMeasureBead class provides boundary measurements for an - * org.apache.flex.html.Alert component. - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public class AlertMeasurementBead implements IMeasurementBead - { - /** - * constructor. - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public function AlertMeasurementBead() - { - } - - /** - * Returns the overall width of the org.apache.flex.html.Alert component. - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public function get measuredWidth():Number - { - return 0; - } - - /** - * Returns the overall height of the org.apache.flex.html.Alert component. - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public function get measuredHeight():Number - { - return 0; - } - - private var _strand:IStrand; - - /** - * @copy org.apache.flex.core.IBead#strand - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public function set strand(value:IStrand):void - { - _strand = value; - } - } -} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/7853ef15/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/AlertView.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/AlertView.as b/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/AlertView.as deleted file mode 100644 index 5788d47..0000000 --- a/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/AlertView.as +++ /dev/null @@ -1,226 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// -// Licensed to the Apache Software Foundation (ASF) under one or more -// contributor license agreements. See the NOTICE file distributed with -// this work for additional information regarding copyright ownership. -// The ASF licenses this file to You under the Apache License, Version 2.0 -// (the "License"); you may not use this file except in compliance with -// the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -//////////////////////////////////////////////////////////////////////////////// -package org.apache.flex.html.beads -{ - import org.apache.flex.core.BeadViewBase; - import org.apache.flex.core.IAlertModel; - import org.apache.flex.core.IBead; - import org.apache.flex.core.IBeadView; - import org.apache.flex.core.IMeasurementBead; - import org.apache.flex.core.IParent; - import org.apache.flex.core.IStrand; - import org.apache.flex.core.UIBase; - import org.apache.flex.core.ValuesManager; - import org.apache.flex.events.Event; - import org.apache.flex.events.IEventDispatcher; - import org.apache.flex.geom.Rectangle; - import org.apache.flex.html.Alert; - import org.apache.flex.html.ControlBar; - import org.apache.flex.html.Label; - import org.apache.flex.html.TextButton; - import org.apache.flex.html.TitleBar; - import org.apache.flex.utils.CSSContainerUtils; - - /** - * The AlertView class creates the visual elements of the org.apache.flex.html.Alert - * component. The job of the view bead is to put together the parts of the Alert, such as the - * title bar, message, and various buttons, within the space of the Alert component strand. - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public class AlertView extends BeadViewBase implements IBeadView - { - /** - * constructor. - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public function AlertView() - { - } - - private var _titleBar:TitleBar; - private var _controlBar:ControlBar; - private var _label:Label; - private var _okButton:TextButton; - private var _cancelButton:TextButton; - private var _yesButton:TextButton; - private var _noButton:TextButton; - - /** - * @copy org.apache.flex.core.IBead#strand - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - override public function set strand(value:IStrand):void - { - super.strand = value; - - var backgroundColor:Object = ValuesManager.valuesImpl.getValue(value, "background-color"); - var backgroundImage:Object = ValuesManager.valuesImpl.getValue(value, "background-image"); - if (backgroundColor != null || backgroundImage != null) - { - if (value.getBeadByType(IBackgroundBead) == null) - value.addBead(new (ValuesManager.valuesImpl.getValue(value, "iBackgroundBead")) as IBead); - } - - var borderStyle:String; - var borderStyles:Object = ValuesManager.valuesImpl.getValue(value, "border"); - if (borderStyles is Array) - { - borderStyle = borderStyles[1]; - } - if (borderStyle == null) - { - borderStyle = ValuesManager.valuesImpl.getValue(value, "border-style") as String; - } - if (borderStyle != null && borderStyle != "none") - { - if (value.getBeadByType(IBorderBead) == null) - value.addBead(new (ValuesManager.valuesImpl.getValue(value, "iBorderBead")) as IBead); - } - - var flags:uint = IAlertModel(UIBase(_strand).model).flags; - if( flags & Alert.OK ) { - _okButton = new TextButton(); - _okButton.text = IAlertModel(UIBase(_strand).model).okLabel; - _okButton.addEventListener("click",handleOK); - } - if( flags & Alert.CANCEL ) { - _cancelButton = new TextButton(); - _cancelButton.text = IAlertModel(UIBase(_strand).model).cancelLabel; - _cancelButton.addEventListener("click",handleCancel); - } - if( flags & Alert.YES ) { - _yesButton = new TextButton(); - _yesButton.text = IAlertModel(UIBase(_strand).model).yesLabel; - _yesButton.addEventListener("click",handleYes); - } - if( flags & Alert.NO ) { - _noButton = new TextButton(); - _noButton.text = IAlertModel(UIBase(_strand).model).noLabel; - _noButton.addEventListener("click",handleNo); - } - - _titleBar = new TitleBar(); - _titleBar.title = IAlertModel(UIBase(_strand).model).title; - - _label = new Label(); - _label.text = IAlertModel(UIBase(_strand).model).message; - - _controlBar = new ControlBar(); - if( _okButton ) _controlBar.addElement(_okButton); - if( _cancelButton ) _controlBar.addElement(_cancelButton); - if( _yesButton ) _controlBar.addElement(_yesButton); - if( _noButton ) _controlBar.addElement(_noButton); - - IParent(_strand).addElement(_titleBar); - IParent(_strand).addElement(_controlBar); - IParent(_strand).addElement(_label); - - sizeHandler(null); - } - - /** - * @private - */ - private function sizeHandler(event:Event):void - { - var labelMeasure:IMeasurementBead = _label.measurementBead; - var titleMeasure:IMeasurementBead = _titleBar.measurementBead; - var ctrlMeasure:IMeasurementBead = _controlBar.measurementBead; - var maxWidth:Number = Math.max(titleMeasure.measuredWidth, ctrlMeasure.measuredWidth, labelMeasure.measuredWidth); - - var metrics:Rectangle = CSSContainerUtils.getBorderAndPaddingMetrics(_strand); - - _titleBar.x = 0; - _titleBar.y = 0; - _titleBar.width = maxWidth; - _titleBar.height = 25; - _titleBar.dispatchEvent(new Event("layoutNeeded")); - - // content placement here - _label.x = metrics.left; - _label.y = _titleBar.y + _titleBar.height + metrics.top; - _label.width = maxWidth - metrics.left - metrics.right; - - _controlBar.x = 0; - _controlBar.y = _titleBar.height + _label.y + _label.height + metrics.bottom; - _controlBar.width = maxWidth; - _controlBar.height = 25; - _controlBar.dispatchEvent(new Event("layoutNeeded")); - - UIBase(_strand).width = maxWidth; - UIBase(_strand).height = _titleBar.height + _label.height + _controlBar.height + metrics.top + metrics.bottom; - } - - /** - * @private - */ - private function handleOK(event:Event):void - { - // create some custom event where the detail value - // is the OK button flag. Do same for other event handlers - dispatchCloseEvent(Alert.OK); - } - - /** - * @private - */ - private function handleCancel(event:Event):void - { - dispatchCloseEvent(Alert.CANCEL); - } - - /** - * @private - */ - private function handleYes(event:Event):void - { - dispatchCloseEvent(Alert.YES); - } - - /** - * @private - */ - private function handleNo(event:Event):void - { - dispatchCloseEvent(Alert.NO); - } - - /** - * @private - */ - public function dispatchCloseEvent(buttonFlag:uint):void - { - // TO DO: buttonFlag should be part of the event - var newEvent:Event = new Event("close",true); - IEventDispatcher(_strand).dispatchEvent(newEvent); - } - } -} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/7853ef15/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/BackgroundImageBead.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/BackgroundImageBead.as b/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/BackgroundImageBead.as deleted file mode 100644 index bee07e9..0000000 --- a/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/BackgroundImageBead.as +++ /dev/null @@ -1,112 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// -// Licensed to the Apache Software Foundation (ASF) under one or more -// contributor license agreements. See the NOTICE file distributed with -// this work for additional information regarding copyright ownership. -// The ASF licenses this file to You under the Apache License, Version 2.0 -// (the "License"); you may not use this file except in compliance with -// the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -//////////////////////////////////////////////////////////////////////////////// -package org.apache.flex.html.beads -{ - import flash.display.Bitmap; - import flash.display.Loader; - import flash.display.LoaderInfo; - import flash.display.Sprite; - import flash.events.Event; - import flash.events.IOErrorEvent; - import flash.net.URLRequest; - - import org.apache.flex.core.IBead; - import org.apache.flex.core.IStrand; - import org.apache.flex.core.UIBase; - import org.apache.flex.core.ValuesManager; - - /** - * The BackgroundImageBead is used to render an image as the background to any component - * that supports it, such as Container. - * - * Note that this bead is for ActionScript only since CSS/HTML allows this just by specifying - * a background image in the style selector. To use this bead, place a ClassReference to it - * within @media -flex-flash { } group in the CSS declarations. - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public class BackgroundImageBead implements IBead, IBackgroundBead - { - /** - * Constructor - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public function BackgroundImageBead() - { - backgroundSprite = new Sprite(); - } - - private var _strand:IStrand; - private var backgroundSprite:Sprite; - private var bitmap:Bitmap; - private var loader:Loader; - - public function set strand(value:IStrand):void - { - _strand = value; - - setupBackground(backgroundSprite); - } - - /** - * @private - */ - private function setupBackground(sprite:Sprite, state:String = null):void - { - var backgroundImage:Object = ValuesManager.valuesImpl.getValue(_strand, "background-image", state); - if (backgroundImage) - { - loader = new Loader(); - var url:String = backgroundImage as String; - loader.load(new URLRequest(url)); - loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, function (e:IOErrorEvent):void { - trace(e); - e.preventDefault(); - }); - loader.contentLoaderInfo.addEventListener(flash.events.Event.COMPLETE, function (e:flash.events.Event):void { - var host:UIBase = UIBase(_strand); - if (bitmap) { - host.removeChild(bitmap); - } - - bitmap = Bitmap(LoaderInfo(e.target).content); - - host.addChildAt(bitmap,0); - - if (isNaN(host.explicitWidth) && isNaN(host.percentWidth)) - host.setWidth(loader.content.width); - else - bitmap.width = UIBase(_strand).width; - - if (isNaN(host.explicitHeight) && isNaN(host.percentHeight)) - host.setHeight(loader.content.height); - else - bitmap.height = UIBase(_strand).height; - }); - } - } - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/7853ef15/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/ButtonBarView.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/ButtonBarView.as b/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/ButtonBarView.as deleted file mode 100644 index cbe0a3e..0000000 --- a/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/ButtonBarView.as +++ /dev/null @@ -1,69 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// -// Licensed to the Apache Software Foundation (ASF) under one or more -// contributor license agreements. See the NOTICE file distributed with -// this work for additional information regarding copyright ownership. -// The ASF licenses this file to You under the Apache License, Version 2.0 -// (the "License"); you may not use this file except in compliance with -// the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -//////////////////////////////////////////////////////////////////////////////// -package org.apache.flex.html.beads -{ - import org.apache.flex.core.IBead; - import org.apache.flex.core.IBeadModel; - import org.apache.flex.core.IParent; - import org.apache.flex.core.IStrand; - import org.apache.flex.core.ValuesManager; - import org.apache.flex.core.UIBase; - import org.apache.flex.events.Event; - import org.apache.flex.events.IEventDispatcher; - import org.apache.flex.html.supportClasses.Border; - - /** - * The ButtonBarView class creates the visual elements of the org.apache.flex.html.ButtonBar - * component. A ButtonBar is a type of List and ButtonBarView extends the ListView bead, adding a border. - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public class ButtonBarView extends ListView - { - /** - * constructor. - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public function ButtonBarView() - { - super(); - } - - /** - * @copy org.apache.flex.core.IBead#strand - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - override public function set strand(value:IStrand):void - { - _strand = value; - super.strand = value; - } - } -} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/7853ef15/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/CSSButtonView.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/CSSButtonView.as b/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/CSSButtonView.as deleted file mode 100644 index fcd14cc..0000000 --- a/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/CSSButtonView.as +++ /dev/null @@ -1,167 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// -// Licensed to the Apache Software Foundation (ASF) under one or more -// contributor license agreements. See the NOTICE file distributed with -// this work for additional information regarding copyright ownership. -// The ASF licenses this file to You under the Apache License, Version 2.0 -// (the "License"); you may not use this file except in compliance with -// the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -//////////////////////////////////////////////////////////////////////////////// -package org.apache.flex.html.beads -{ - import flash.display.DisplayObject; - import flash.display.Loader; - import flash.display.Shape; - import flash.display.SimpleButton; - import flash.display.Sprite; - import flash.events.Event; - import flash.net.URLRequest; - - import org.apache.flex.core.BeadViewBase; - import org.apache.flex.core.IBeadView; - import org.apache.flex.core.IStrand; - import org.apache.flex.core.ITextModel; - import org.apache.flex.core.ValuesManager; - import org.apache.flex.events.Event; - import org.apache.flex.events.IEventDispatcher; - import org.apache.flex.utils.CSSBorderUtils; - import org.apache.flex.utils.CSSUtils; - import org.apache.flex.utils.StringTrimmer; - - /** - * The CSSButtonView class is the default view for - * the org.apache.flex.html.Button class. - * It allows the look of the button to be expressed - * in CSS via the background-image style. This view - * does not display text. Use CSSTextButtonView and - * TextButton instead. - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public class CSSButtonView extends BeadViewBase implements IBeadView - { - /** - * Constructor. - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public function CSSButtonView() - { - upSprite = new Sprite(); - downSprite = new Sprite(); - overSprite = new Sprite(); - } - - private var textModel:ITextModel; - - private var shape:Shape; - - /** - * @copy org.apache.flex.core.IBead#strand - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - override public function set strand(value:IStrand):void - { - super.strand = value; - shape = new Shape(); - shape.graphics.beginFill(0xCCCCCC); - shape.graphics.drawRect(0, 0, 10, 10); - shape.graphics.endFill(); - SimpleButton(value).upState = upSprite; - SimpleButton(value).downState = downSprite; - SimpleButton(value).overState = overSprite; - SimpleButton(value).hitTestState = shape; - - setupBackground(overSprite, "hover"); - setupBackground(downSprite, "active"); - setupBackground(upSprite); - - IEventDispatcher(_strand).addEventListener("widthChanged",sizeChangeHandler); - IEventDispatcher(_strand).addEventListener("heightChanged",sizeChangeHandler); - } - - private function sizeChangeHandler(event:org.apache.flex.events.Event):void - { - setupSkins(); - } - - protected function setupSkins():void - { - setupSkin(overSprite, "hover"); - setupSkin(downSprite, "active"); - setupSkin(upSprite); - updateHitArea(); - } - - private function setupSkin(sprite:Sprite, state:String = null):void - { - var padding:Object = ValuesManager.valuesImpl.getValue(_strand, "padding", state); - var paddingLeft:Object = ValuesManager.valuesImpl.getValue(_strand, "padding-left", state); - var paddingRight:Object = ValuesManager.valuesImpl.getValue(_strand, "padding-right", state); - var paddingTop:Object = ValuesManager.valuesImpl.getValue(_strand, "padding-top", state); - var paddingBottom:Object = ValuesManager.valuesImpl.getValue(_strand, "padding-bottom", state); - var pl:Number = CSSUtils.getLeftValue(paddingLeft, padding, DisplayObject(_strand).width); - var pr:Number = CSSUtils.getRightValue(paddingRight, padding, DisplayObject(_strand).width); - var pt:Number = CSSUtils.getTopValue(paddingTop, padding, DisplayObject(_strand).height); - var pb:Number = CSSUtils.getBottomValue(paddingBottom, padding, DisplayObject(_strand).height); - - CSSBorderUtils.draw(sprite.graphics, - DisplayObject(_strand).width + pl + pr, - DisplayObject(_strand).height + pt + pb, - _strand as DisplayObject, - state, true); - } - - private function setupBackground(sprite:Sprite, state:String = null):void - { - var backgroundImage:Object = ValuesManager.valuesImpl.getValue(_strand, "background-image", state); - if (backgroundImage) - { - var loader:Loader = new Loader(); - sprite.addChildAt(loader, 0); - var url:String = backgroundImage as String; - loader.load(new URLRequest(url)); - loader.contentLoaderInfo.addEventListener(flash.events.Event.COMPLETE, function (e:flash.events.Event):void { - setupSkin(sprite, state); - updateHitArea(); - }); - } - else { - setupSkin(sprite, state); - updateHitArea(); - } - } - - private var upSprite:Sprite; - private var downSprite:Sprite; - private var overSprite:Sprite; - - private function updateHitArea():void - { - shape.graphics.clear(); - shape.graphics.beginFill(0xCCCCCC); - shape.graphics.drawRect(0, 0, upSprite.width, upSprite.height); - shape.graphics.endFill(); - - } - } -} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/7853ef15/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/CSSImageAndTextButtonView.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/CSSImageAndTextButtonView.as b/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/CSSImageAndTextButtonView.as deleted file mode 100644 index 12ac07d..0000000 --- a/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/CSSImageAndTextButtonView.as +++ /dev/null @@ -1,367 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// -// Licensed to the Apache Software Foundation (ASF) under one or more -// contributor license agreements. See the NOTICE file distributed with -// this work for additional information regarding copyright ownership. -// The ASF licenses this file to You under the Apache License, Version 2.0 -// (the "License"); you may not use this file except in compliance with -// the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -//////////////////////////////////////////////////////////////////////////////// -package org.apache.flex.html.beads -{ - import flash.display.DisplayObject; - import flash.display.Loader; - import flash.display.Shape; - import flash.display.SimpleButton; - import flash.display.Sprite; - import flash.events.Event; - import flash.net.URLRequest; - import flash.text.TextField; - import flash.text.TextFieldType; - - import org.apache.flex.core.BeadViewBase; - import org.apache.flex.core.CSSTextField; - import org.apache.flex.core.IBeadView; - import org.apache.flex.core.IStrand; - import org.apache.flex.core.ValuesManager; - import org.apache.flex.events.Event; - import org.apache.flex.events.IEventDispatcher; - import org.apache.flex.html.TextButton; - import org.apache.flex.html.beads.models.ImageAndTextModel; - import org.apache.flex.utils.CSSUtils; - import org.apache.flex.utils.SolidBorderUtil; - import org.apache.flex.utils.StringTrimmer; - - /** - * The CSSTextButtonView class is the default view for - * the org.apache.flex.html.TextButton class. - * It allows the look of the button to be expressed - * in CSS via the background-image style and displays - * a text label. This view does not support right-to-left - * text. - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public class CSSImageAndTextButtonView extends BeadViewBase implements IBeadView - { - /** - * Constructor. - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public function CSSImageAndTextButtonView() - { - upSprite = new Sprite(); - downSprite = new Sprite(); - overSprite = new Sprite(); - upTextField = new CSSTextField(); - downTextField = new CSSTextField(); - overTextField = new CSSTextField(); - upTextField.selectable = false; - upTextField.type = TextFieldType.DYNAMIC; - downTextField.selectable = false; - downTextField.type = TextFieldType.DYNAMIC; - overTextField.selectable = false; - overTextField.type = TextFieldType.DYNAMIC; - upTextField.autoSize = "left"; - downTextField.autoSize = "left"; - overTextField.autoSize = "left"; - upSprite.addChild(upTextField); - downSprite.addChild(downTextField); - overSprite.addChild(overTextField); - } - - private var textModel:ImageAndTextModel; - - private var shape:Shape; - - /** - * @copy org.apache.flex.core.IBead#strand - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - override public function set strand(value:IStrand):void - { - _strand = value; - textModel = value.getBeadByType(ImageAndTextModel) as ImageAndTextModel; - textModel.addEventListener("textChange", textChangeHandler); - textModel.addEventListener("htmlChange", htmlChangeHandler); - textModel.addEventListener("imageChange", imageChangeHandler); - shape = new Shape(); - shape.graphics.beginFill(0xCCCCCC); - shape.graphics.drawRect(0, 0, 10, 10); - shape.graphics.endFill(); - upTextField.styleParent = _strand; - downTextField.styleParent = _strand; - overTextField.styleParent = _strand; - upTextField.parentDrawsBackground = true; - downTextField.parentDrawsBackground = true; - overTextField.parentDrawsBackground = true; - upTextField.parentHandlesPadding = true; - downTextField.parentHandlesPadding = true; - overTextField.parentHandlesPadding = true; - SimpleButton(value).upState = upSprite; - SimpleButton(value).downState = downSprite; - SimpleButton(value).overState = overSprite; - SimpleButton(value).hitTestState = shape; - if (textModel.text !== null) - text = textModel.text; - if (textModel.html !== null) - html = textModel.html; - - setupSkins(); - - IEventDispatcher(_strand).addEventListener("widthChanged",sizeChangeHandler); - IEventDispatcher(_strand).addEventListener("heightChanged",sizeChangeHandler); - IEventDispatcher(_strand).addEventListener("sizeChanged",sizeChangeHandler); - } - - protected function setupSkins():void - { - setupSkin(overSprite, overTextField, "hover"); - setupSkin(downSprite, downTextField, "active"); - setupSkin(upSprite, upTextField); - updateHitArea(); - } - - private function setupSkin(sprite:Sprite, textField:TextField, state:String = null):void - { - var sw:uint = DisplayObject(_strand).width; - var sh:uint = DisplayObject(_strand).height; - - textField.defaultTextFormat.leftMargin = 0; - textField.defaultTextFormat.rightMargin = 0; - // set it again so it gets noticed - textField.defaultTextFormat = textField.defaultTextFormat; - - var borderColor:uint; - var borderThickness:uint; - var borderStyle:String; - var borderStyles:Object = ValuesManager.valuesImpl.getValue(_strand, "border", state); - if (borderStyles is Array) - { - borderColor = CSSUtils.toColor(borderStyles[2]); - borderStyle = borderStyles[1]; - borderThickness = borderStyles[0]; - } - else if (borderStyles is String) - borderStyle = borderStyles as String; - var value:Object = ValuesManager.valuesImpl.getValue(_strand, "border-style", state); - if (value != null) - borderStyle = value as String; - value = ValuesManager.valuesImpl.getValue(_strand, "border-color", state); - if (value != null) - borderColor = CSSUtils.toColor(value); - value = ValuesManager.valuesImpl.getValue(_strand, "border-width", state); - if (value != null) - borderThickness = value as uint; - if (borderStyle == "none") - { - borderStyle = "solid"; - borderThickness = 0; - } - - var borderRadius:String; - var borderEllipseWidth:Number = NaN; - var borderEllipseHeight:Number = NaN; - value = ValuesManager.valuesImpl.getValue(_strand, "border-radius", state); - if (value != null) - { - if (value is Number) - borderEllipseWidth = 2 * (value as Number); - else - { - borderRadius = value as String; - var arr:Array = StringTrimmer.splitAndTrim(borderRadius, "/"); - borderEllipseWidth = 2 * CSSUtils.toNumber(arr[0]); - if (arr.length > 1) - borderEllipseHeight = 2 * CSSUtils.toNumber(arr[1]); - } - } - - var padding:Object = ValuesManager.valuesImpl.getValue(_strand, "padding", state); - var paddingLeft:Object = ValuesManager.valuesImpl.getValue(_strand, "padding-left", state); - var paddingRight:Object = ValuesManager.valuesImpl.getValue(_strand, "padding-right", state); - var paddingTop:Object = ValuesManager.valuesImpl.getValue(_strand, "padding-top", state); - var paddingBottom:Object = ValuesManager.valuesImpl.getValue(_strand, "padding-bottom", state); - var pl:Number = CSSUtils.getLeftValue(paddingLeft, padding, DisplayObject(_strand).width); - var pr:Number = CSSUtils.getRightValue(paddingRight, padding, DisplayObject(_strand).width); - var pt:Number = CSSUtils.getTopValue(paddingTop, padding, DisplayObject(_strand).height); - var pb:Number = CSSUtils.getBottomValue(paddingBottom, padding, DisplayObject(_strand).height); - - var backgroundColor:Object = ValuesManager.valuesImpl.getValue(_strand, "background-color", state); - var bgColor:uint; - var bgAlpha:Number = 1; - if (backgroundColor != null) - { - bgColor = CSSUtils.toColorWithAlpha(backgroundColor); - if (bgColor & 0xFF000000) - { - bgAlpha = bgColor >>> 24 / 255; - bgColor = bgColor & 0xFFFFFF; - } - } - if (borderStyle == "solid") - { - var useWidth:Number = Math.max(sw,textField.textWidth); - var useHeight:Number = Math.max(sh,textField.textHeight); - - if ((useWidth-pl-pr-2*borderThickness) < textField.textWidth) - useWidth = textField.textWidth+pl+pr+2*borderThickness; - if ((useHeight-pt-pb-2*borderThickness) < textField.textHeight) - useHeight = textField.textHeight+pt+pb+2*borderThickness; - - sprite.graphics.clear(); - SolidBorderUtil.drawBorder(sprite.graphics, - 0, 0, useWidth, useHeight, - borderColor, backgroundColor == null ? null : bgColor, borderThickness, bgAlpha, - borderEllipseWidth, borderEllipseHeight); - textField.y = ((useHeight - textField.textHeight) / 2) - 2; - textField.x = ((useWidth - textField.textWidth) / 2) - 2; - } - var backgroundImage:Object = image; - if (backgroundImage) - { - var loader:Loader = new Loader(); - sprite.addChildAt(loader, 0); - sprite.addChild(textField); - var url:String = backgroundImage as String; - loader.load(new URLRequest(url)); - loader.contentLoaderInfo.addEventListener(flash.events.Event.COMPLETE, function (e:flash.events.Event):void { - updateHitArea(); - loader.x = pl; - textField.x = loader.width + pl; - textField.y = pt; - loader.y = (textField.height + pt + pb - loader.height) / 2; - sprite.graphics.clear(); - SolidBorderUtil.drawBorder(sprite.graphics, - 0, 0, textField.x + textField.width + pr + borderThickness, - textField.y + textField.height + pb + borderThickness, - borderColor, backgroundColor == null ? null : bgColor, borderThickness, bgAlpha, - borderEllipseWidth, borderEllipseHeight); - }); - } - var textColor:Object = ValuesManager.valuesImpl.getValue(_strand, "color", state); - if (textColor) { - textField.textColor = Number(textColor); - } - } - - private function textChangeHandler(event:org.apache.flex.events.Event):void - { - text = textModel.text; - } - - private function htmlChangeHandler(event:org.apache.flex.events.Event):void - { - html = textModel.html; - } - - private function sizeChangeHandler(event:org.apache.flex.events.Event):void - { - setupSkins(); - } - - private var upTextField:CSSTextField; - private var downTextField:CSSTextField; - private var overTextField:CSSTextField; - private var upSprite:Sprite; - private var downSprite:Sprite; - private var overSprite:Sprite; - - /** - * 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 textModel.image; - } - - private function imageChangeHandler(event:org.apache.flex.events.Event):void - { - setupSkins(); - } - - /** - * The text to be displayed in the button - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public function get text():String - { - return upTextField.text; - } - - /** - * @private - */ - public function set text(value:String):void - { - upTextField.text = value; - downTextField.text = value; - overTextField.text = value; - updateHitArea(); - } - - private function updateHitArea():void - { - var useWidth:uint = Math.max(DisplayObject(_strand).width, upTextField.textWidth); - var useHeight:uint = Math.max(DisplayObject(_strand).height, upTextField.textHeight); - - shape.graphics.clear(); - shape.graphics.beginFill(0xCCCCCC); - shape.graphics.drawRect(0, 0, useWidth, useHeight); - shape.graphics.endFill(); - - } - - /** - * The html-formatted text to be displayed in the button - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public function get html():String - { - return upTextField.htmlText; - } - - /** - * @private - */ - public function set html(value:String):void - { - upTextField.htmlText = value; - downTextField.htmlText = value; - overTextField.htmlText = value; - } - } -} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/7853ef15/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/CSSTextButtonView.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/CSSTextButtonView.as b/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/CSSTextButtonView.as deleted file mode 100644 index cc285b7..0000000 --- a/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/CSSTextButtonView.as +++ /dev/null @@ -1,347 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// -// Licensed to the Apache Software Foundation (ASF) under one or more -// contributor license agreements. See the NOTICE file distributed with -// this work for additional information regarding copyright ownership. -// The ASF licenses this file to You under the Apache License, Version 2.0 -// (the "License"); you may not use this file except in compliance with -// the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -//////////////////////////////////////////////////////////////////////////////// -package org.apache.flex.html.beads -{ - import flash.display.DisplayObject; - import flash.display.Loader; - import flash.display.Shape; - import flash.display.SimpleButton; - import flash.display.Sprite; - import flash.events.Event; - import flash.net.URLRequest; - import flash.text.TextField; - import flash.text.TextFieldType; - - import org.apache.flex.core.BeadViewBase; - import org.apache.flex.core.CSSTextField; - import org.apache.flex.core.IBeadView; - import org.apache.flex.core.IStrand; - import org.apache.flex.core.ITextModel; - import org.apache.flex.core.ValuesManager; - import org.apache.flex.events.Event; - import org.apache.flex.events.IEventDispatcher; - import org.apache.flex.html.TextButton; - import org.apache.flex.utils.CSSUtils; - import org.apache.flex.utils.SolidBorderUtil; - import org.apache.flex.utils.StringTrimmer; - - /** - * The CSSTextButtonView class is the default view for - * the org.apache.flex.html.TextButton class. - * It allows the look of the button to be expressed - * in CSS via the background-image style and displays - * a text label. This view does not support right-to-left - * text. - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public class CSSTextButtonView extends BeadViewBase implements IBeadView - { - /** - * Constructor. - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public function CSSTextButtonView() - { - upSprite = new Sprite(); - downSprite = new Sprite(); - overSprite = new Sprite(); - upTextField = new CSSTextField(); - downTextField = new CSSTextField(); - overTextField = new CSSTextField(); - upTextField.selectable = false; - upTextField.type = TextFieldType.DYNAMIC; - downTextField.selectable = false; - downTextField.type = TextFieldType.DYNAMIC; - overTextField.selectable = false; - overTextField.type = TextFieldType.DYNAMIC; - upTextField.autoSize = "left"; - downTextField.autoSize = "left"; - overTextField.autoSize = "left"; - upSprite.addChild(upTextField); - downSprite.addChild(downTextField); - overSprite.addChild(overTextField); - } - - private var textModel:ITextModel; - - private var shape:Shape; - - /** - * @copy org.apache.flex.core.IBead#strand - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - override public function set strand(value:IStrand):void - { - _strand = value; - textModel = value.getBeadByType(ITextModel) as ITextModel; - textModel.addEventListener("textChange", textChangeHandler); - textModel.addEventListener("htmlChange", htmlChangeHandler); - shape = new Shape(); - shape.graphics.beginFill(0xCCCCCC); - shape.graphics.drawRect(0, 0, 10, 10); - shape.graphics.endFill(); - upTextField.styleParent = _strand; - downTextField.styleParent = _strand; - overTextField.styleParent = _strand; - upTextField.parentDrawsBackground = true; - downTextField.parentDrawsBackground = true; - overTextField.parentDrawsBackground = true; - upTextField.parentHandlesPadding = true; - downTextField.parentHandlesPadding = true; - overTextField.parentHandlesPadding = true; - SimpleButton(value).upState = upSprite; - SimpleButton(value).downState = downSprite; - SimpleButton(value).overState = overSprite; - SimpleButton(value).hitTestState = shape; - if (textModel.text !== null) - text = textModel.text; - if (textModel.html !== null) - html = textModel.html; - - setupSkins(); - - IEventDispatcher(_strand).addEventListener("widthChanged",sizeChangeHandler); - IEventDispatcher(_strand).addEventListener("heightChanged",sizeChangeHandler); - IEventDispatcher(_strand).addEventListener("sizeChanged",sizeChangeHandler); - } - - protected function setupSkins():void - { - setupSkin(overSprite, overTextField, "hover"); - setupSkin(downSprite, downTextField, "active"); - setupSkin(upSprite, upTextField); - updateHitArea(); - } - - private function setupSkin(sprite:Sprite, textField:TextField, state:String = null):void - { - var sw:uint = DisplayObject(_strand).width; - var sh:uint = DisplayObject(_strand).height; - - textField.defaultTextFormat.leftMargin = 0; - textField.defaultTextFormat.rightMargin = 0; - // set it again so it gets noticed - textField.defaultTextFormat = textField.defaultTextFormat; - - var borderColor:uint; - var borderThickness:uint; - var borderStyle:String; - var borderStyles:Object = ValuesManager.valuesImpl.getValue(_strand, "border", state); - if (borderStyles is Array) - { - borderColor = CSSUtils.toColor(borderStyles[2]); - borderStyle = borderStyles[1]; - borderThickness = borderStyles[0]; - } - else if (borderStyles is String) - borderStyle = borderStyles as String; - var value:Object = ValuesManager.valuesImpl.getValue(_strand, "border-style", state); - if (value != null) - borderStyle = value as String; - value = ValuesManager.valuesImpl.getValue(_strand, "border-color", state); - if (value != null) - borderColor = CSSUtils.toColor(value); - value = ValuesManager.valuesImpl.getValue(_strand, "border-width", state); - if (value != null) - borderThickness = value as uint; - if (borderStyle == "none") - { - borderStyle = "solid"; - borderThickness = 0; - } - - var borderRadius:String; - var borderEllipseWidth:Number = NaN; - var borderEllipseHeight:Number = NaN; - value = ValuesManager.valuesImpl.getValue(_strand, "border-radius", state); - if (value != null) - { - if (value is Number) - borderEllipseWidth = 2 * (value as Number); - else - { - borderRadius = value as String; - var arr:Array = StringTrimmer.splitAndTrim(borderRadius, "/"); - borderEllipseWidth = 2 * CSSUtils.toNumber(arr[0]); - if (arr.length > 1) - borderEllipseHeight = 2 * CSSUtils.toNumber(arr[1]); - } - } - - var padding:Object = ValuesManager.valuesImpl.getValue(_strand, "padding", state); - var paddingLeft:Object = ValuesManager.valuesImpl.getValue(_strand, "padding-left", state); - var paddingRight:Object = ValuesManager.valuesImpl.getValue(_strand, "padding-right", state); - var paddingTop:Object = ValuesManager.valuesImpl.getValue(_strand, "padding-top", state); - var paddingBottom:Object = ValuesManager.valuesImpl.getValue(_strand, "padding-bottom", state); - var pl:Number = CSSUtils.getLeftValue(paddingLeft, padding, DisplayObject(_strand).width); - var pr:Number = CSSUtils.getRightValue(paddingRight, padding, DisplayObject(_strand).width); - var pt:Number = CSSUtils.getTopValue(paddingTop, padding, DisplayObject(_strand).height); - var pb:Number = CSSUtils.getBottomValue(paddingBottom, padding, DisplayObject(_strand).height); - - var backgroundColor:Object = ValuesManager.valuesImpl.getValue(_strand, "background-color", state); - var bgColor:uint; - var bgAlpha:Number = 1; - if (backgroundColor != null) - { - bgColor = CSSUtils.toColorWithAlpha(backgroundColor); - if (bgColor & 0xFF000000) - { - bgAlpha = bgColor >>> 24 / 255; - bgColor = bgColor & 0xFFFFFF; - } - } - if (borderStyle == "solid") - { - var useWidth:Number = Math.max(sw,textField.textWidth); - var useHeight:Number = Math.max(sh,textField.textHeight); - - if ((useWidth-pl-pr-2*borderThickness) < textField.textWidth) - useWidth = textField.textWidth+pl+pr+2*borderThickness; - if ((useHeight-pt-pb-2*borderThickness) < textField.textHeight) - useHeight = textField.textHeight+pt+pb+2*borderThickness; - - sprite.graphics.clear(); - SolidBorderUtil.drawBorder(sprite.graphics, - 0, 0, useWidth, useHeight, - borderColor, backgroundColor == null ? null : bgColor, borderThickness, bgAlpha, - borderEllipseWidth, borderEllipseHeight); - textField.y = ((useHeight - textField.textHeight) / 2) - 2; - textField.x = ((useWidth - textField.textWidth) / 2) - 2; - } - var backgroundImage:Object = ValuesManager.valuesImpl.getValue(_strand, "background-image", state); - if (backgroundImage) - { - var loader:Loader = new Loader(); - sprite.addChildAt(loader, 0); - var url:String = backgroundImage as String; - loader.load(new URLRequest(url)); - loader.contentLoaderInfo.addEventListener(flash.events.Event.COMPLETE, function (e:flash.events.Event):void { - var useWidth:Number = Math.max(sw,textField.textWidth); - var useHeight:Number = Math.max(sh,textField.textHeight); - - if ((useWidth-2*Number(padding)-2*borderThickness) < textField.textWidth) - useWidth = textField.textWidth+2*Number(padding)+2*borderThickness; - if ((useHeight-2*Number(padding)-2*borderThickness) < textField.textHeight) - useHeight = textField.textHeight+2*Number(padding)+2*borderThickness; - - textField.y = (useHeight - textField.height) / 2; - textField.x = (useWidth - textField.width) / 2; - updateHitArea(); - }); - } - var textColor:Object = ValuesManager.valuesImpl.getValue(_strand, "color", state); - if (textColor) { - textField.textColor = Number(textColor); - } - } - - private function textChangeHandler(event:org.apache.flex.events.Event):void - { - text = textModel.text; - } - - private function htmlChangeHandler(event:org.apache.flex.events.Event):void - { - html = textModel.html; - } - - private function sizeChangeHandler(event:org.apache.flex.events.Event):void - { - setupSkins(); - } - - private var upTextField:CSSTextField; - private var downTextField:CSSTextField; - private var overTextField:CSSTextField; - private var upSprite:Sprite; - private var downSprite:Sprite; - private var overSprite:Sprite; - - /** - * The text to be displayed in the button - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public function get text():String - { - return upTextField.text; - } - - /** - * @private - */ - public function set text(value:String):void - { - upTextField.text = value; - downTextField.text = value; - overTextField.text = value; - updateHitArea(); - } - - private function updateHitArea():void - { - var useWidth:uint = Math.max(DisplayObject(_strand).width, upTextField.textWidth); - var useHeight:uint = Math.max(DisplayObject(_strand).height, upTextField.textHeight); - - shape.graphics.clear(); - shape.graphics.beginFill(0xCCCCCC); - shape.graphics.drawRect(0, 0, useWidth, useHeight); - shape.graphics.endFill(); - - } - - /** - * The html-formatted text to be displayed in the button - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public function get html():String - { - return upTextField.htmlText; - } - - /** - * @private - */ - public function set html(value:String):void - { - upTextField.htmlText = value; - downTextField.htmlText = value; - overTextField.htmlText = value; - } - } -} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/7853ef15/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/CSSTextToggleButtonView.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/CSSTextToggleButtonView.as b/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/CSSTextToggleButtonView.as deleted file mode 100644 index 7de01ef..0000000 --- a/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/CSSTextToggleButtonView.as +++ /dev/null @@ -1,105 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// -// Licensed to the Apache Software Foundation (ASF) under one or more -// contributor license agreements. See the NOTICE file distributed with -// this work for additional information regarding copyright ownership. -// The ASF licenses this file to You under the Apache License, Version 2.0 -// (the "License"); you may not use this file except in compliance with -// the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -//////////////////////////////////////////////////////////////////////////////// -package org.apache.flex.html.beads -{ - - import org.apache.flex.core.BeadViewBase; - import org.apache.flex.core.IBeadView; - import org.apache.flex.core.IStrand; - import org.apache.flex.core.IStyleableObject; - import org.apache.flex.core.IToggleButtonModel; - import org.apache.flex.events.Event; - import org.apache.flex.events.IEventDispatcher; - - /** - * The CSSTextToggleButtonView class is the default view for - * the org.apache.flex.html.TextToggleButton class. - * It allows the look of the button to be expressed - * in CSS via the background-image style and displays - * a text label. This view does not support right-to-left - * text. - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public class CSSTextToggleButtonView extends CSSTextButtonView - { - /** - * The suffix appended to the className when selected. - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public static const SELECTED:String = "_Selected"; - - /** - * Constructor. - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public function CSSTextToggleButtonView() - { - } - - private var toggleButtonModel:IToggleButtonModel; - - private var _selected:Boolean; - - /** - * @copy org.apache.flex.core.IBead#strand - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - override public function set strand(value:IStrand):void - { - super.strand = value; - - toggleButtonModel = value.getBeadByType(IToggleButtonModel) as IToggleButtonModel; - toggleButtonModel.addEventListener("selectedChange", selectedChangeHandler); - } - - private function selectedChangeHandler(event:org.apache.flex.events.Event):void - { - var className:String = IStyleableObject(_strand).className; - if (toggleButtonModel.selected) - { - if (className.indexOf(SELECTED) == className.length - SELECTED.length) - IStyleableObject(_strand).className = className.substring(0, className.length - SELECTED.length); - setupSkins(); - } - else - { - if (className.indexOf(SELECTED) == -1) - IStyleableObject(_strand).className += SELECTED; - setupSkins(); - } - } - - } -} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/7853ef15/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/CheckBoxView.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/CheckBoxView.as b/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/CheckBoxView.as deleted file mode 100644 index a04f2bf..0000000 --- a/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/CheckBoxView.as +++ /dev/null @@ -1,296 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// -// Licensed to the Apache Software Foundation (ASF) under one or more -// contributor license agreements. See the NOTICE file distributed with -// this work for additional information regarding copyright ownership. -// The ASF licenses this file to You under the Apache License, Version 2.0 -// (the "License"); you may not use this file except in compliance with -// the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -//////////////////////////////////////////////////////////////////////////////// -package org.apache.flex.html.beads -{ - import flash.display.Shape; - import flash.display.SimpleButton; - import flash.display.Sprite; - import flash.text.TextFieldAutoSize; - import flash.text.TextFieldType; - - import org.apache.flex.core.BeadViewBase; - import org.apache.flex.core.CSSTextField; - import org.apache.flex.core.IBeadView; - import org.apache.flex.core.IStrand; - import org.apache.flex.core.IToggleButtonModel; - import org.apache.flex.events.Event; - - /** - * The CheckBoxView class is the default view for - * the org.apache.flex.html.CheckBox class. - * It displays a simple checkbox with an 'x' if checked, - * and a label on the right. There are no styles or - * properties to configure the look of the 'x' or the - * position of the label relative to the checkbox as - * there are no equivalents in the standard HTML checkbox. - * - * A more complex CheckBox could implement more view - * configuration. - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public class CheckBoxView extends BeadViewBase implements IBeadView - { - /** - * Constructor. - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public function CheckBoxView() - { - sprites = [ upSprite = new Sprite(), - downSprite = new Sprite(), - overSprite = new Sprite(), - upAndSelectedSprite = new Sprite(), - downAndSelectedSprite = new Sprite(), - overAndSelectedSprite = new Sprite() ]; - - for each( var s:Sprite in sprites ) - { - var tf:CSSTextField = new CSSTextField(); - tf.type = TextFieldType.DYNAMIC; - tf.autoSize = TextFieldAutoSize.LEFT; - tf.name = "textField"; - var icon:Shape = new Shape(); - icon.name = "icon"; - s.addChild(icon); - s.addChild(tf); - } - } - - private var upSprite:Sprite; - private var downSprite:Sprite; - private var overSprite:Sprite; - private var upAndSelectedSprite:Sprite; - private var downAndSelectedSprite:Sprite; - private var overAndSelectedSprite:Sprite; - - private var sprites:Array; - - private var _toggleButtonModel:IToggleButtonModel; - - // TODO: Can we remove this? - private function get toggleButtonModel() : IToggleButtonModel - { - return _toggleButtonModel; - } - - /** - * @copy org.apache.flex.core.IBead#strand - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - override public function set strand(value:IStrand):void - { - super.strand = value; - - _toggleButtonModel = value.getBeadByType(IToggleButtonModel) as IToggleButtonModel; - _toggleButtonModel.addEventListener("textChange", textChangeHandler); - _toggleButtonModel.addEventListener("htmlChange", htmlChangeHandler); - _toggleButtonModel.addEventListener("selectedChange", selectedChangeHandler); - if (_toggleButtonModel.text !== null) - text = _toggleButtonModel.text; - - layoutControl(); - - var hitArea:Shape = new Shape(); - hitArea.graphics.beginFill(0x000000); - hitArea.graphics.drawRect(0,0,upSprite.width, upSprite.height); - hitArea.graphics.endFill(); - - SimpleButton(value).upState = upSprite; - SimpleButton(value).downState = downSprite; - SimpleButton(value).overState = overSprite; - SimpleButton(value).hitTestState = hitArea; - - if (toggleButtonModel.text !== null) - text = toggleButtonModel.text; - if (toggleButtonModel.html !== null) - html = toggleButtonModel.html; - } - - /** - * @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 - { - var tf:CSSTextField = upSprite.getChildByName('textField') as CSSTextField; - return tf.text; - } - - /** - * @private - */ - public function set text(value:String):void - { - for each( var s:Sprite in sprites ) - { - var tf:CSSTextField = s.getChildByName('textField') as CSSTextField; - tf.text = value; - } - - layoutControl(); - } - - /** - * @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 - { - var tf:CSSTextField = upSprite.getChildByName('textField') as CSSTextField; - return tf.htmlText; - } - - /** - * @private - */ - public function set html(value:String):void - { - for each(var s:Sprite in sprites) - { - var tf:CSSTextField = s.getChildByName('textField') as CSSTextField; - tf.htmlText = value; - } - - layoutControl(); - } - - private function textChangeHandler(event:Event):void - { - text = toggleButtonModel.text; - } - - private function htmlChangeHandler(event:Event):void - { - html = toggleButtonModel.html; - } - - private var _selected:Boolean; - - /** - * @copy org.apache.flex.core.IToggleButtonModel#selected - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public function get selected():Boolean - { - return _selected; - } - - /** - * @private - */ - public function set selected(value:Boolean):void - { - _selected = value; - - layoutControl(); - - if( value ) { - SimpleButton(_strand).upState = upAndSelectedSprite; - SimpleButton(_strand).downState = downAndSelectedSprite; - SimpleButton(_strand).overState = overAndSelectedSprite; - - } else { - SimpleButton(_strand).upState = upSprite; - SimpleButton(_strand).downState = downSprite; - SimpleButton(_strand).overState = overSprite; - } - } - - private function selectedChangeHandler(event:Event):void - { - selected = toggleButtonModel.selected; - } - - /** - * Display the icon and text label - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - protected function layoutControl() : void - { - for each(var s:Sprite in sprites) - { - var icon:Shape = s.getChildByName("icon") as Shape; - var tf:CSSTextField = s.getChildByName("textField") as CSSTextField; - - drawCheckBox(icon); - - var mh:Number = Math.max(icon.height,tf.height); - - icon.x = 0; - icon.y = (mh - icon.height)/2; - - tf.x = icon.x + icon.width + 1; - tf.y = (mh - tf.height)/2; - } - - } - - /** - * Draw the checkbox - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - protected function drawCheckBox(icon:Shape) : void - { - icon.graphics.clear(); - icon.graphics.beginFill(0xf8f8f8); - icon.graphics.lineStyle(1,0x808080); - icon.graphics.drawRect(0,0,10,10); - icon.graphics.endFill(); - - if( _toggleButtonModel.selected ) { - icon.graphics.lineStyle(2,0); - icon.graphics.moveTo(3,4); - icon.graphics.lineTo(5,7); - icon.graphics.lineTo(9,0); - } - } - } -}
