Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 02748200BB3 for ; Wed, 2 Nov 2016 16:14:11 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 013D8160AEA; Wed, 2 Nov 2016 15:14:11 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id A4C27160B10 for ; Wed, 2 Nov 2016 16:14:08 +0100 (CET) Received: (qmail 22162 invoked by uid 500); 2 Nov 2016 15:14:07 -0000 Mailing-List: contact commits-help@flex.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@flex.apache.org Delivered-To: mailing list commits@flex.apache.org Received: (qmail 21901 invoked by uid 99); 2 Nov 2016 15:14:07 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 02 Nov 2016 15:14:07 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 1517BEAB4A; Wed, 2 Nov 2016 15:14:07 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: aharui@apache.org To: commits@flex.apache.org Date: Wed, 02 Nov 2016 15:14:15 -0000 Message-Id: <74cbebf2fa82437aacab63e6dd703212@git.apache.org> In-Reply-To: <60e117a620cb44149b0247fe4028d184@git.apache.org> References: <60e117a620cb44149b0247fe4028d184@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [10/43] git commit: [flex-asjs] [refs/heads/refactor-sprite] - try to copy HTML to Basic without losing history archived-at: Wed, 02 Nov 2016 15:14:11 -0000 http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/d8221452/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/TextFieldView.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/TextFieldView.as b/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/TextFieldView.as new file mode 100644 index 0000000..61b6edb --- /dev/null +++ b/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/TextFieldView.as @@ -0,0 +1,54 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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.text.TextFieldType; + + /** + * The TextFieldView class is the default view for + * the org.apache.flex.html.Label class. + * It displays text using a TextField, so there is no + * right-to-left text support in this view. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public class TextFieldView extends TextFieldViewBase + { + /** + * Constructor. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function TextFieldView() + { + super(); + + textField.selectable = false; + textField.type = TextFieldType.DYNAMIC; + textField.mouseEnabled = false; + textField.autoSize = "left"; + } + } +} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/d8221452/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/TextFieldViewBase.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/TextFieldViewBase.as b/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/TextFieldViewBase.as new file mode 100644 index 0000000..3ab2874 --- /dev/null +++ b/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/TextFieldViewBase.as @@ -0,0 +1,404 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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.DisplayObjectContainer; + import flash.text.StyleSheet; + + import org.apache.flex.core.CSSTextField; + import org.apache.flex.core.IBeadView; + import org.apache.flex.core.ILayoutChild; + import org.apache.flex.core.IStrand; + import org.apache.flex.core.ITextModel; + import org.apache.flex.core.IUIBase; + import org.apache.flex.core.UIBase; + import org.apache.flex.core.ValuesManager; + import org.apache.flex.events.Event; + import org.apache.flex.events.IEventDispatcher; + + /** + * The TextFieldViewBase class is the base class for + * the components that display text. + * It displays text using a TextField, so there is no + * right-to-left text support in this view. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public class TextFieldViewBase implements IBeadView, ITextFieldView + { + /** + * Constructor. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function TextFieldViewBase() + { + _textField = new CSSTextField(); + } + + private var _textField:CSSTextField; + + /** + * @copy org.apache.flex.core.ITextModel#textField + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get textField() : CSSTextField + { + return _textField; + } + + private var _textModel:ITextModel; + + protected 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; + _textModel = value.getBeadByType(ITextModel) as ITextModel; + _textModel.addEventListener("textChange", textChangeHandler); + _textModel.addEventListener("htmlChange", htmlChangeHandler); + IEventDispatcher(_strand).addEventListener("widthChanged", widthChangeHandler); + IEventDispatcher(_strand).addEventListener("heightChanged", heightChangeHandler); + IEventDispatcher(_strand).addEventListener("sizeChanged", sizeChangeHandler); + DisplayObjectContainer(value).addChild(_textField); + if (_textModel.text !== null) + text = _textModel.text; + if (_textModel.html !== null) + html = _textModel.html; + + var ilc:ILayoutChild = host as ILayoutChild; + autoHeight = ilc.isHeightSizedToContent(); + autoWidth = ilc.isWidthSizedToContent(); + if (!autoWidth && !isNaN(ilc.explicitWidth)) + { + widthChangeHandler(null); + } + if (!autoHeight && !isNaN(ilc.explicitHeight)) + { + heightChangeHandler(null); + } + + // textfield's collapse to height==4 if no text + if (autoHeight && _textModel.text === null) + { + var fontHeight:Number = ValuesManager.valuesImpl.getValue(_strand, "fontSize") + 4; + if (textField.height != fontHeight) + { + textField.autoSize = "none"; + textField.height = fontHeight; + } + } + } + + /** + * @private + */ + public function get host() : IUIBase + { + return _strand as IUIBase; + } + + /** + * @copy org.apache.flex.core.ITextModel#text + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get text():String + { + return _textField.text; + } + + /** + * @private + */ + public function set text(value:String):void + { + if (value == null) + value = ""; + _textField.text = value; + autoSizeIfNeeded(); + } + + /** + * Handle autosizing. The built-in player algorithm + * doesn't work the way we would like, especially + * when it collapses Textfields with empty strings. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + protected function autoSizeIfNeeded():void + { + var host:UIBase = UIBase(_strand); + if (autoHeight) + { + if (textField.text != "") + { + if (textField.height != textField.textHeight + 4) + { + textField.height = textField.textHeight + 4; + inHeightChange = true; + host.dispatchEvent(new Event("heightChanged")); + inHeightChange = false; + } + } + else + { + var fontHeight:Number = ValuesManager.valuesImpl.getValue(_strand, "fontSize") + 4; + if (textField.height != fontHeight) + { + textField.height = fontHeight; + inHeightChange = true; + host.dispatchEvent(new Event("heightChanged")); + inHeightChange = false; + } + } + } + if (autoWidth) + { + if (textField.width != textField.textWidth + 4) + { + textField.width = textField.textWidth + 4; + inWidthChange = true; + host.dispatchEvent(new Event("widthChanged")); + inWidthChange = false; + } + } + } + + /** + * @copy org.apache.flex.core.ITextModel#html + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get html():String + { + return _textField.htmlText; + } + + /** + * @private + */ + public function set html(value:String):void + { + convertToTextFieldHTML(value); + autoSizeIfNeeded(); + } + + private function convertToTextFieldHTML(input:String):void + { + var classCount:int = 0; + var ss:StyleSheet; + var c:int = input.indexOf("", c); + if (c1 == -1) + { + trace("did not parse span correctly"); + return; + } + var tag:String = input.substring(c, c1 + 1); + var c2:int = tag.indexOf("style="); + if (c2 != -1) + { + var quote:String = tag.charAt(c2 + 6); + var c3:int = tag.indexOf(quote, c2 + 7); + if (c3 != -1) + { + var styles:String = tag.substring(c2 + 7, c3); + if (!ss) + ss = new StyleSheet(); + var styleObject:Object = {}; + var list:Array = styles.split(";"); + for each (var pair:String in list) + { + var parts:Array = pair.split(":"); + var name:String = parts[0]; + var c4:int = name.indexOf("-"); + if (c4 != -1) + { + var firstChar:String = name.charAt(c4 + 1); + firstChar = firstChar.toUpperCase(); + var tail:String = name.substring(c4 + 2); + name = name.substring(0, c4) + firstChar + tail; + } + styleObject[name] = parts[1]; + } + var className:String = "css" + classCount++; + ss.setStyle("." + className, styleObject); + var newTag:String = ""; + input = input.replace(tag, newTag); + c1 += newTag.length - tag.length; + } + } + c = input.indexOf(" 0 ) + { + textField.height = textField.textHeight + 5; + } + + textField.y = ((hh - textField.height) / 2); + } + + /** + * @private + */ + override protected function sizeChangeHandler(event:Event):void + { + var ww:Number = host.width; + if( !isNaN(ww) && ww > 0 ) textField.width = ww; + + var hh:Number = host.height; + if( !isNaN(hh) && hh > 0 ) + { + textField.height = textField.textHeight + 5; + textField.y = ((hh - textField.height) / 2); + } + } + } +} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/d8221452/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/TextInputWithBorderView.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/TextInputWithBorderView.as b/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/TextInputWithBorderView.as new file mode 100644 index 0000000..fbab13e --- /dev/null +++ b/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/TextInputWithBorderView.as @@ -0,0 +1,100 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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 org.apache.flex.core.IBead; + import org.apache.flex.core.IBeadModel; + import org.apache.flex.core.ILayoutChild; + import org.apache.flex.core.IParent; + 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.geom.Rectangle; + import org.apache.flex.html.supportClasses.Border; + import org.apache.flex.utils.CSSContainerUtils; + + /** + * The TextInputWithBorderView class is the default view for + * the org.apache.flex.html.TextInput. + * It displays text using a TextField, so there is no + * right-to-left text support in this view. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public class TextInputWithBorderView extends TextInputView + { + public function TextInputWithBorderView() + { + super(); + textField.parentDrawsBackground = true; + textField.parentHandlesPadding = true; + } + + /** + * @private + */ + override public function set strand(value:IStrand):void + { + super.strand = value; + + value.addBead(new (ValuesManager.valuesImpl.getValue(value, "iBackgroundBead")) as IBead); + value.addBead(new (ValuesManager.valuesImpl.getValue(value, "iBorderBead")) as IBead); + } + + /** + * Determine the width of the TextField. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + override protected function widthChangeHandler(event:Event):void + { + if (!inWidthChange) + { + textField.autoSize = "none"; + autoWidth = false; + var uiMetrics:Rectangle = CSSContainerUtils.getBorderAndPaddingMetrics(host); + textField.width = host.width - uiMetrics.left - uiMetrics.right; + textField.x = uiMetrics.left; + } + } + + /** + * Determine the size of the TextField. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + override protected function sizeChangeHandler(event:Event):void + { + super.sizeChangeHandler(event); + widthChangeHandler(event); + } + } +} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/d8221452/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/TextItemRendererFactoryForArrayData.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/TextItemRendererFactoryForArrayData.as b/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/TextItemRendererFactoryForArrayData.as new file mode 100644 index 0000000..9ffd9fe --- /dev/null +++ b/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/TextItemRendererFactoryForArrayData.as @@ -0,0 +1,159 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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.IDataProviderItemRendererMapper; + import org.apache.flex.core.IItemRendererClassFactory; + import org.apache.flex.core.IItemRendererParent; + import org.apache.flex.core.ISelectionModel; + import org.apache.flex.core.IStrand; + import org.apache.flex.core.ValuesManager; + import org.apache.flex.events.Event; + import org.apache.flex.events.EventDispatcher; + import org.apache.flex.events.ItemRendererEvent; + import org.apache.flex.events.IEventDispatcher; + + [Event(name="itemRendererCreated",type="org.apache.flex.events.ItemRendererEvent")] + + /** + * The TextItemRendererFactoryForArrayData class is the + * IDataProviderItemRendererMapper for creating + * ITextItemRenderers and assigning them data from an array. + * Other IDataProviderItemRendererMapper implementations + * assign specific array or vector types to item + * renderers expecting those types. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public class TextItemRendererFactoryForArrayData extends EventDispatcher implements IBead, IDataProviderItemRendererMapper + { + /** + * Constructor. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function TextItemRendererFactoryForArrayData(target:Object=null) + { + super(target); + } + + private var selectionModel:ISelectionModel; + + 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(value).addEventListener("beadsAdded",finishSetup); + IEventDispatcher(value).addEventListener("initComplete",finishSetup); + } + + private function finishSetup(event:Event):void + { + selectionModel = _strand.getBeadByType(ISelectionModel) as ISelectionModel; + var listView:IListView = _strand.getBeadByType(IListView) as IListView; + dataGroup = listView.dataGroup; + selectionModel.addEventListener("dataProviderChanged", dataProviderChangeHandler); + + if (!itemRendererFactory) + { + _itemRendererFactory = new (ValuesManager.valuesImpl.getValue(_strand, "iItemRendererClassFactory")) as IItemRendererClassFactory; + _strand.addBead(_itemRendererFactory); + } + + dataProviderChangeHandler(null); + } + + private var _itemRendererFactory:IItemRendererClassFactory; + + /** + * An IItemRendererClassFactory that should generate ITextItemRenderers + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get itemRendererFactory():IItemRendererClassFactory + { + return _itemRendererFactory + } + + /** + * @private + */ + public function set itemRendererFactory(value:IItemRendererClassFactory):void + { + _itemRendererFactory = value; + } + + /** + * The IItemRendererParent that should parent the ITextItemRenderers + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + protected var dataGroup:IItemRendererParent; + + private function dataProviderChangeHandler(event:Event):void + { + var dp:Array = selectionModel.dataProvider as Array; + if (!dp) + return; + + dataGroup.removeAllElements(); + + var n:int = dp.length; + for (var i:int = 0; i < n; i++) + { + var tf:ITextItemRenderer = itemRendererFactory.createItemRenderer(dataGroup) as ITextItemRenderer; + tf.index = i; + dataGroup.addElement(tf); + if (selectionModel.labelField) + tf.text = dp[i][selectionModel.labelField]; + else + tf.text = dp[i]; + + var newEvent:ItemRendererEvent = new ItemRendererEvent(ItemRendererEvent.CREATED); + newEvent.itemRenderer = tf; + dispatchEvent(newEvent); + } + + IEventDispatcher(_strand).dispatchEvent(new Event("itemsCreated")); + } + + } +} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/d8221452/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/TextItemRendererFactoryForStringVectorData.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/TextItemRendererFactoryForStringVectorData.as b/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/TextItemRendererFactoryForStringVectorData.as new file mode 100644 index 0000000..b0c11b5 --- /dev/null +++ b/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/TextItemRendererFactoryForStringVectorData.as @@ -0,0 +1,143 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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.IItemRendererClassFactory; + import org.apache.flex.core.IItemRendererParent; + import org.apache.flex.core.ISelectionModel; + import org.apache.flex.core.IStrand; + import org.apache.flex.events.Event; + import org.apache.flex.events.EventDispatcher; + import org.apache.flex.events.IEventDispatcher; + import org.apache.flex.events.ItemRendererEvent; + + [Event(name="itemRendererCreated",type="org.apache.flex.events.ItemRendererEvent")] + + /** + * The TextItemRendererFactoryForStringVectorData class is the + * IDataProviderItemRendererMapper for creating + * ITextItemRenderers and assigning them data from an vector + * of Strings. Other IDataProviderItemRendererMapper implementations + * assign specific array or vector types to item + * renderers expecting those types. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public class TextItemRendererFactoryForStringVectorData extends EventDispatcher implements IBead + { + /** + * Constructor. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function TextItemRendererFactoryForStringVectorData(target:Object=null) + { + super(target); + } + + private var selectionModel:ISelectionModel; + + 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(value).addEventListener("beadsAdded",finishSetup); + } + + private function finishSetup(event:Event):void + { + selectionModel = _strand.getBeadByType(ISelectionModel) as ISelectionModel; + var listView:IListView = _strand.getBeadByType(IListView) as IListView; + dataGroup = listView.dataGroup; + selectionModel.addEventListener("dataProviderChange", dataProviderChangeHandler); + dataProviderChangeHandler(null); + } + + private var _itemRendererFactory:IItemRendererClassFactory; + + /** + * An IItemRendererClassFactory that should generate ITextItemRenderers + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get itemRendererFactory():IItemRendererClassFactory + { + return _itemRendererFactory + } + + /** + * @private + */ + public function set itemRendererFactory(value:IItemRendererClassFactory):void + { + _itemRendererFactory = value; + } + + /** + * The IItemRendererParent that should parent the ITextItemRenderers + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + protected var dataGroup:IItemRendererParent; + + private function dataProviderChangeHandler(event:Event):void + { + var dp:Vector. = selectionModel.dataProvider as Vector.; + + dataGroup.removeAllElements(); + + var n:int = dp.length; + for (var i:int = 0; i < n; i++) + { + var tf:ITextItemRenderer = itemRendererFactory.createItemRenderer(dataGroup) as ITextItemRenderer; + tf.index = i; + dataGroup.addElement(tf); + tf.text = dp[i]; + + var newEvent:ItemRendererEvent = new ItemRendererEvent(ItemRendererEvent.CREATED); + newEvent.itemRenderer = tf; + dispatchEvent(newEvent); + } + } + + } +} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/d8221452/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/TitleBarMeasurementBead.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/TitleBarMeasurementBead.as b/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/TitleBarMeasurementBead.as new file mode 100644 index 0000000..8195f70 --- /dev/null +++ b/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/TitleBarMeasurementBead.as @@ -0,0 +1,108 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +//////////////////////////////////////////////////////////////////////////////// +package org.apache.flex.html.beads +{ + import org.apache.flex.core.IMeasurementBead; + import org.apache.flex.core.IStrand; + import org.apache.flex.core.ValuesManager; + import org.apache.flex.html.TitleBar; + + /** + * The TitleBarMeasurementBead class measures the overall size of a + * org.apache.flex.html.TitleBar. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public class TitleBarMeasurementBead implements IMeasurementBead + { + /** + * constructor. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function TitleBarMeasurementBead() + { + } + + /** + * The overall width of the org.apache.flex.html.TitleBar. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get measuredWidth():Number + { + var mwidth:Number = 0; + var titleBar:TitleBar = _strand as TitleBar; + var titleView:TitleBarView = _strand.getBeadByType(TitleBarView) as TitleBarView; + var labelMeasure:IMeasurementBead = titleView.titleLabel.measurementBead; + mwidth = labelMeasure.measuredWidth; + if( titleBar.showCloseButton ) { + var buttonMeasure:IMeasurementBead = titleView.closeButton.measurementBead; + mwidth += buttonMeasure.measuredWidth; + } + return mwidth; + } + + /** + * The overall height of the org.apache.flex.html.TitleBar. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get measuredHeight():Number + { + var mheight:Number = 0; + var titleBar:TitleBar = _strand as TitleBar; + var titleView:TitleBarView = _strand.getBeadByType(TitleBarView) as TitleBarView; + var labelMeasure:IMeasurementBead = titleView.titleLabel.measurementBead; + mheight = labelMeasure.measuredHeight; + if( titleBar.showCloseButton ) { + var buttonMeasure:IMeasurementBead = titleView.closeButton.measurementBead; + mheight = Math.max(mheight,buttonMeasure.measuredHeight); + } + return mheight; + } + + 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/d8221452/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/TitleBarView.mxml ---------------------------------------------------------------------- diff --git a/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/TitleBarView.mxml b/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/TitleBarView.mxml new file mode 100644 index 0000000..206f43e --- /dev/null +++ b/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/TitleBarView.mxml @@ -0,0 +1,58 @@ + + + + + + + + + + + + + + + + + + + + + http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/d8221452/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/UpArrowButtonView.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/UpArrowButtonView.as b/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/UpArrowButtonView.as new file mode 100644 index 0000000..8e6ff4a --- /dev/null +++ b/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/UpArrowButtonView.as @@ -0,0 +1,112 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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.Graphics; + import flash.display.Shape; + import flash.display.SimpleButton; + + import org.apache.flex.core.BeadViewBase; + import org.apache.flex.core.IBeadView; + import org.apache.flex.core.IStrand; + import org.apache.flex.events.Event; + + /** + * The UpArrowButtonView class is the view for + * the up arrow button in a ScrollBar and other controls. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public class UpArrowButtonView extends BeadViewBase implements IBeadView + { + /** + * Constructor. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function UpArrowButtonView() + { + upView = new Shape(); + downView = new Shape(); + overView = new Shape(); + + drawView(upView.graphics, 0xf8f8f8); + drawView(downView.graphics, 0xd8d8d8); + drawView(overView.graphics, 0xe8e8e8); + } + + private function drawView(g:Graphics, bgColor:uint):void + { + g.lineStyle(1); + g.beginFill(bgColor); + g.drawRoundRect(0, 0, ScrollBarView.FullSize, ScrollBarView.FullSize, ScrollBarView.ThirdSize); + g.endFill(); + g.lineStyle(0); + g.beginFill(0); + g.moveTo(ScrollBarView.QuarterSize, ScrollBarView.ThreeQuarterSize); + g.lineTo(ScrollBarView.ThreeQuarterSize, ScrollBarView.ThreeQuarterSize); + g.lineTo(ScrollBarView.HalfSize, ScrollBarView.QuarterSize); + g.lineTo(ScrollBarView.QuarterSize, ScrollBarView.ThreeQuarterSize); + g.endFill(); + } + + 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, ScrollBarView.FullSize, ScrollBarView.FullSize); + shape.graphics.endFill(); + SimpleButton(value).upState = upView; + SimpleButton(value).downState = downView; + SimpleButton(value).overState = overView; + SimpleButton(value).hitTestState = shape; + + SimpleButton(_strand).addEventListener("widthChanged",sizeChangeHandler); + SimpleButton(_strand).addEventListener("heightChanged",sizeChangeHandler); + } + + private var upView:Shape; + private var downView:Shape; + private var overView:Shape; + + private function sizeChangeHandler(event:Event):void + { + SimpleButton(_strand).scaleX = SimpleButton(_strand).width / ScrollBarView.FullSize; + SimpleButton(_strand).scaleY = SimpleButton(_strand).height / ScrollBarView.FullSize; + } + } +} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/d8221452/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/VRuleView.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/VRuleView.as b/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/VRuleView.as new file mode 100644 index 0000000..5eb6c4c --- /dev/null +++ b/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/VRuleView.as @@ -0,0 +1,87 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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.net.URLRequest; + + import org.apache.flex.core.BeadViewBase; + import org.apache.flex.core.IBeadView; + import org.apache.flex.core.IImageModel; + 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 ImageView class creates the visual elements of the org.apache.flex.html.Image component. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public class VRuleView extends BeadViewBase implements IBeadView + { + /** + * constructor. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function VRuleView() + { + } + + /** + * @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; + + IEventDispatcher(_strand).addEventListener("widthChanged",handleSizeChange); + IEventDispatcher(_strand).addEventListener("heightChanged",handleSizeChange); + IEventDispatcher(_strand).addEventListener("sizeChanged",handleSizeChange); + + handleSizeChange(null); + } + + /** + * @private + */ + private function handleSizeChange(event:Object):void + { + var ui:UIBase = _strand as UIBase; + ui.graphics.clear(); + ui.graphics.beginFill(0); + ui.graphics.drawRect(0, 0, 1, ui.height); + ui.graphics.endFill(); + } + } +} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/d8221452/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/VScrollBarThumbView.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/VScrollBarThumbView.as b/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/VScrollBarThumbView.as new file mode 100644 index 0000000..0f70b37 --- /dev/null +++ b/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/VScrollBarThumbView.as @@ -0,0 +1,119 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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.Graphics; + import flash.display.Shape; + import flash.display.SimpleButton; + import flash.display.DisplayObject; + + import org.apache.flex.core.BeadViewBase; + import org.apache.flex.core.IBeadView; + import org.apache.flex.core.IStrand; + import org.apache.flex.events.Event; + import org.apache.flex.events.IEventDispatcher; + + /** + * The VScrollBarThumbView class is the view for + * the thumb button in a Vertical ScrollBar. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public class VScrollBarThumbView extends BeadViewBase implements IBeadView + { + /** + * Constructor. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function VScrollBarThumbView() + { + } + + private function drawView(g:Graphics, bgColor:uint):void + { + var hh:Number = DisplayObject(_strand).height; + g.clear(); + g.lineStyle(1); + g.beginFill(bgColor); + g.drawRoundRect(0, 0, ScrollBarView.FullSize, hh, ScrollBarView.HalfSize); + g.endFill(); + } + + 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; + + upView = new Shape(); + downView = new Shape(); + overView = new Shape(); + + drawView(upView.graphics, 0xc8c8c8); + drawView(downView.graphics, 0xc8c8c8); + drawView(overView.graphics, 0xb8b8b8); + + shape = new Shape(); + shape.graphics.beginFill(0xCCCCCC); + shape.graphics.drawRect(0, 0, ScrollBarView.FullSize, ScrollBarView.FullSize); + shape.graphics.endFill(); + SimpleButton(value).upState = upView; + SimpleButton(value).downState = downView; + SimpleButton(value).overState = overView; + SimpleButton(value).hitTestState = shape; + IEventDispatcher(_strand).addEventListener("heightChanged", heightChangedHandler); + } + + private function heightChangedHandler(event:Event):void + { + DisplayObject(_strand).scaleY = 1.0; + DisplayObject(_strand).scaleX = 1.0; + + var hh:Number = DisplayObject(_strand).height; + drawView(upView.graphics, 0xc8c8c8); + drawView(downView.graphics, 0xc8c8c8); + drawView(overView.graphics, 0xb8b8b8); + + shape.graphics.clear(); + shape.graphics.beginFill(0xCCCCCC); + shape.graphics.drawRect(0, 0, ScrollBarView.FullSize, hh); + shape.graphics.endFill(); + } + + private var upView:Shape; + private var downView:Shape; + private var overView:Shape; + + } +} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/d8221452/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/VScrollBarTrackView.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/VScrollBarTrackView.as b/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/VScrollBarTrackView.as new file mode 100644 index 0000000..3510251 --- /dev/null +++ b/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/VScrollBarTrackView.as @@ -0,0 +1,118 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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.Graphics; + import flash.display.Shape; + import flash.display.SimpleButton; + + import org.apache.flex.core.BeadViewBase; + import org.apache.flex.core.IBeadView; + import org.apache.flex.core.IStrand; + import org.apache.flex.events.Event; + + /** + * The VScrollBarTrackView class is the view for + * the track in a Vertical ScrollBar. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public class VScrollBarTrackView extends BeadViewBase implements IBeadView + { + /** + * Constructor. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function VScrollBarTrackView() + { + } + + private function drawView(g:Graphics, bgColor:uint):void + { + var h:Number = SimpleButton(_strand).height; + + g.clear(); + g.lineStyle(1, 0x808080); + g.beginFill(bgColor); + g.drawRect(0, 0, ScrollBarView.FullSize, h); + g.endFill(); + g.lineStyle(0); + } + + private function heightChangeHandler(event:Event):void + { + DisplayObject(_strand).scaleY = 1.0; + DisplayObject(_strand).scaleX = 1.0; + + var h:Number = SimpleButton(_strand).height; + + drawView(upView.graphics, 0xf8f8f8); + drawView(downView.graphics, 0xd8d8d8); + drawView(overView.graphics, 0xe8e8e8); + shape.graphics.clear(); + shape.graphics.beginFill(0xCCCCCC); + shape.graphics.drawRect(0, 0, ScrollBarView.FullSize, h); + shape.graphics.endFill(); + + } + + 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; + + upView = new Shape(); + downView = new Shape(); + overView = new Shape(); + + drawView(upView.graphics, 0xf8f8f8); + drawView(downView.graphics, 0xd8d8d8); + drawView(overView.graphics, 0xe8e8e8); + + SimpleButton(value).addEventListener("heightChanged", heightChangeHandler); + shape = new Shape(); + SimpleButton(value).upState = upView; + SimpleButton(value).downState = downView; + SimpleButton(value).overState = overView; + SimpleButton(value).hitTestState = shape; + } + + private var upView:Shape; + private var downView:Shape; + private var overView:Shape; + + } +} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/d8221452/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/VScrollBarView.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/VScrollBarView.as b/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/VScrollBarView.as new file mode 100644 index 0000000..840f7bf --- /dev/null +++ b/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/VScrollBarView.as @@ -0,0 +1,99 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +//////////////////////////////////////////////////////////////////////////////// +package org.apache.flex.html.beads +{ + import flash.display.DisplayObject; + + import org.apache.flex.core.IBead; + import org.apache.flex.core.IBeadLayout; + import org.apache.flex.core.IBeadView; + import org.apache.flex.core.IScrollBarModel; + import org.apache.flex.core.IStrand; + import org.apache.flex.core.IUIBase; + import org.apache.flex.core.Strand; + import org.apache.flex.core.UIBase; + import org.apache.flex.core.ValuesManager; + import org.apache.flex.events.IEventDispatcher; + import org.apache.flex.events.Event; + import org.apache.flex.html.Button; + import org.apache.flex.html.beads.controllers.ButtonAutoRepeatController; + + /** + * The ScrollBarView class is the default view for + * the org.apache.flex.html.supportClasses.VScrollBar class. + * It implements the classic desktop-like VScrollBar. + * A different view would implement more modern scrollbars that hide themselves + * until hovered over with the mouse. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public class VScrollBarView extends ScrollBarView implements IBeadView, IStrand, IScrollBarView + { + /** + * Constructor. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function VScrollBarView() + { + } + + /** + * @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; + + UIBase(value).setWidth(ScrollBarView.FullSize, true); + + // TODO: (aharui) put in values impl + _increment = new Button(); + Button(_increment).addBead(new DownArrowButtonView()); + Button(_increment).addBead(new ButtonAutoRepeatController()); + _decrement = new Button(); + Button(_decrement).addBead(new UpArrowButtonView()); + Button(_decrement).addBead(new ButtonAutoRepeatController()); + _track = new Button(); + Button(_track).addBead(new VScrollBarTrackView()); + _thumb = new Button(); + Button(_thumb).addBead(new VScrollBarThumbView()); + + UIBase(value).addChild(_decrement); + UIBase(value).addChild(_increment); + UIBase(value).addChild(_track); + UIBase(value).addChild(_thumb); + + IEventDispatcher(_strand).addEventListener("heightChanged", changeHandler); + + layout.layout(); + } + } +} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/d8221452/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/WebBrowserView.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/WebBrowserView.as b/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/WebBrowserView.as new file mode 100644 index 0000000..63d04e2 --- /dev/null +++ b/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/WebBrowserView.as @@ -0,0 +1,198 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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 +{ + COMPILE::SWF { + import flash.events.Event; + import flash.html.HTMLLoader; + import flash.net.URLRequest; + } + + import org.apache.flex.core.IBeadView; + 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.html.beads.models.WebBrowserModel; + + /** + * The WebBrowserView creates an instance of HTMLLoader to load + * web pages into AIR application. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + COMPILE::SWF + public class WebBrowserView implements IBeadView + { + /** + * constructor. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function WebBrowserView() + { + loader = new HTMLLoader(); + loader.placeLoadStringContentInApplicationSandbox = false; + + loader.addEventListener(flash.events.LocationChangeEvent.LOCATION_CHANGE, handleLocationChange); + } + + private var _strand:IStrand; + + private var loader:HTMLLoader; + + /** + * @private + */ + public function get host():IUIBase + { + return _strand as IUIBase; + } + + /** + * @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; + + (host as UIBase).addEventListener("widthChanged", handleSizeChange); + (host as UIBase).addEventListener("heightChanged", handleSizeChange); + + var model:IEventDispatcher = (host as UIBase).model as IEventDispatcher; + model.addEventListener("urlChanged", loadPage); + + loader.x = 0; + loader.y = 0; + loader.width = host.width; + loader.height = host.height; + (host as UIBase).addElement(loader); + } + + /** + * @private + */ + private function loadPage(event:org.apache.flex.events.Event):void + { + var model:WebBrowserModel = (host as UIBase).model as WebBrowserModel; + loader.load(new URLRequest(model.url)); + } + + /** + * @private + */ + private function handleSizeChange(event:org.apache.flex.events.Event):void + { + loader.width = host.width; + loader.height = host.height; + } + + /** + * @private + */ + private function handleLocationChange(event:flash.events.LocationChangeEvent):void + { + var model:WebBrowserModel = (host as UIBase).model as WebBrowserModel; + model.setURL(loader.location); + host.dispatchEvent(new org.apache.flex.events.Event("locationChanged")); + } + } + + COMPILE::JS + public class WebBrowserView implements IBeadView + { + /** + * Constructor + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function WebBrowserView() + { + + } + + private var _strand:IStrand; + + /** + * @private + */ + public function get host():IUIBase + { + return _strand as IUIBase; + } + + /** + * @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; + + var model:IEventDispatcher = (host as UIBase).model as IEventDispatcher; + model.addEventListener("urlChanged", loadPage); + + var iframe:HTMLIFrameElement = (host as UIBase).element as HTMLIFrameElement; + iframe.addEventListener("load", handlePageShow, false); + } + + /** + * @private + */ + private function loadPage(event:Event):void + { + var model:WebBrowserModel = (host as UIBase).model as WebBrowserModel; + + var iframe:HTMLIFrameElement = (host as UIBase).element as HTMLIFrameElement; + iframe.src = model.url; + } + + /** + * @private + */ + private function handlePageShow(event:Event):void + { + var model:WebBrowserModel = (host as UIBase).model as WebBrowserModel; + var iframe:HTMLIFrameElement = (host as UIBase).element as HTMLIFrameElement; + + model.setURL(iframe.src); + host.dispatchEvent(new org.apache.flex.events.Event("locationChanged")); + } + } +} + http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/d8221452/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/controllers/AlertController.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/controllers/AlertController.as b/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/controllers/AlertController.as new file mode 100644 index 0000000..3982d0f --- /dev/null +++ b/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/controllers/AlertController.as @@ -0,0 +1,88 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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.controllers +{ + import flash.display.DisplayObject; + + import org.apache.flex.core.IBeadController; + import org.apache.flex.core.IStrand; + import org.apache.flex.events.Event; + import org.apache.flex.events.IEventDispatcher; + + /** + * The AlertControler class bead handles the close event on the org.apache.flex.html.Alert + * by removing the org.apache.flex.html.Alert from the display. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public class AlertController implements IBeadController + { + /** + * constructor. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function AlertController() + { + } + + 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 get strand():IStrand + { + return _strand; + } + + /** + * @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(value).addEventListener("close",handleAlertClose); + } + + /** + * @private + */ + private function handleAlertClose(event:Event):void + { + DisplayObject(_strand).parent.removeChild(DisplayObject(_strand)); + } + } +} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/d8221452/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/controllers/ButtonAutoRepeatController.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/controllers/ButtonAutoRepeatController.as b/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/controllers/ButtonAutoRepeatController.as new file mode 100644 index 0000000..4100a28 --- /dev/null +++ b/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/controllers/ButtonAutoRepeatController.as @@ -0,0 +1,147 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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.controllers +{ + import flash.utils.clearInterval; + import flash.utils.clearTimeout; + import flash.utils.setInterval; + import flash.utils.setTimeout; + + import org.apache.flex.core.IBead; + import org.apache.flex.core.IBeadController; + import org.apache.flex.core.IStrand; + import org.apache.flex.events.Event; + import org.apache.flex.events.MouseEvent; + import org.apache.flex.events.IEventDispatcher; + + /** + * The ButtonAutoRepeatController class adds autorepeat + * functionality to a button. This version is simply waits + * a specified amount of time (default is 250ms), then repeats the button + * event at a specified interval, which defaults to + * 125 milliseconds. Alternate implementations could + * have non-linear repeat timing, look for keyboard modifiers to choose + * different rates, etc. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public class ButtonAutoRepeatController implements IBead, IBeadController + { + /** + * Constructor. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function ButtonAutoRepeatController() + { + } + + 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(value).addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler); + } + + /** + * The number of milliseconds to wait before repeating the event + * for the first time. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public var delay:int = 250; + + /** + * The number of milliseconds to wait before repeating the event + * after the first time. This value is not checked for + * changes after the events start repeating. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public var interval:int = 100; + + private var timeout:uint; + private var repeater:uint; + + private function mouseDownHandler(event:MouseEvent):void + { + event.target.addEventListener(MouseEvent.MOUSE_OUT, mouseOutHandler); + event.target.addEventListener(MouseEvent.MOUSE_UP, mouseUpHandler); + timeout = setTimeout(sendFirstRepeat, delay); + } + + private function mouseOutHandler(event:MouseEvent):void + { + event.target.removeEventListener(MouseEvent.MOUSE_OUT, mouseOutHandler); + event.target.removeEventListener(MouseEvent.MOUSE_UP, mouseUpHandler); + if (repeater > 0) + clearInterval(repeater); + repeater = 0; + if (timeout > 0) + clearTimeout(timeout); + timeout = 0; + } + + private function mouseUpHandler(event:MouseEvent):void + { + event.target.removeEventListener(MouseEvent.MOUSE_OUT, mouseOutHandler); + event.target.removeEventListener(MouseEvent.MOUSE_UP, mouseUpHandler); + if (repeater > 0) + clearInterval(repeater); + repeater = 0; + if (timeout > 0) + clearTimeout(timeout); + timeout = 0; + } + + private function sendFirstRepeat():void + { + clearTimeout(timeout); + timeout = 0; + repeater = setInterval(sendRepeats, interval); + IEventDispatcher(_strand).dispatchEvent(new Event("buttonRepeat")); + } + + private function sendRepeats():void + { + IEventDispatcher(_strand).dispatchEvent(new Event("buttonRepeat")); + } + } +} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/d8221452/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/controllers/ComboBoxController.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/controllers/ComboBoxController.as b/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/controllers/ComboBoxController.as new file mode 100644 index 0000000..12fb59c --- /dev/null +++ b/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/controllers/ComboBoxController.as @@ -0,0 +1,104 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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.controllers +{ + import flash.display.DisplayObject; + + import org.apache.flex.core.IBeadController; + import org.apache.flex.core.ISelectionModel; + import org.apache.flex.core.IStrand; + import org.apache.flex.events.Event; + import org.apache.flex.events.IEventDispatcher; + import org.apache.flex.events.MouseEvent; + import org.apache.flex.html.beads.IComboBoxView; + + /** + * The ComboBoxController class bead handles mouse events on the elements of + * the org.apache.flex.html.ComboBox. This includes selecting the + * button to display the selection list pop-up as well as selecting an item from the + * pop-up list. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public class ComboBoxController implements IBeadController + { + /** + * constructor. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function ComboBoxController() + { + } + + 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(value).addEventListener(MouseEvent.CLICK, clickHandler); + } + + /** + * @private + */ + private function clickHandler(event:MouseEvent):void + { + var viewBead:IComboBoxView = _strand.getBeadByType(IComboBoxView) as IComboBoxView; + viewBead.popUpVisible = true; + var selectionModel:ISelectionModel = _strand.getBeadByType(ISelectionModel) as ISelectionModel; + var popUpModel:ISelectionModel = viewBead.popUp.getBeadByType(ISelectionModel) as ISelectionModel; + popUpModel.dataProvider = selectionModel.dataProvider; + popUpModel.selectedIndex = selectionModel.selectedIndex; + DisplayObject(viewBead.popUp).width = DisplayObject(_strand).width; + DisplayObject(viewBead.popUp).height = 200; + DisplayObject(viewBead.popUp).x = DisplayObject(_strand).x; + DisplayObject(viewBead.popUp).y = DisplayObject(_strand).y; + IEventDispatcher(viewBead.popUp).addEventListener("change", changeHandler); + } + + /** + * @private + */ + private function changeHandler(event:Event):void + { + var viewBead:IComboBoxView = _strand.getBeadByType(IComboBoxView) as IComboBoxView; + viewBead.popUpVisible = false; + var selectionModel:ISelectionModel = _strand.getBeadByType(ISelectionModel) as ISelectionModel; + var popUpModel:ISelectionModel = viewBead.popUp.getBeadByType(ISelectionModel) as ISelectionModel; + selectionModel.selectedIndex = popUpModel.selectedIndex; + IEventDispatcher(_strand).dispatchEvent(new Event("change")); + } + + } +}