http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/e31f54e4/frameworks/projects/Flat/as/src/org/apache/flex/flat/beads/DropDownListView.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Flat/as/src/org/apache/flex/flat/beads/DropDownListView.as b/frameworks/projects/Flat/as/src/org/apache/flex/flat/beads/DropDownListView.as deleted file mode 100644 index f7357b9..0000000 --- a/frameworks/projects/Flat/as/src/org/apache/flex/flat/beads/DropDownListView.as +++ /dev/null @@ -1,309 +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.flat.beads -{ - import flash.display.DisplayObject; - import flash.display.DisplayObjectContainer; - import flash.display.Graphics; - import flash.display.Shape; - import flash.display.SimpleButton; - import flash.display.Sprite; - import flash.text.TextFieldType; - - import org.apache.flex.core.BeadViewBase; - import org.apache.flex.core.CSSShape; - import org.apache.flex.core.CSSSprite; - import org.apache.flex.core.CSSTextField; - import org.apache.flex.core.IBeadView; - import org.apache.flex.core.ILayoutChild; - import org.apache.flex.core.IPopUpHost; - import org.apache.flex.core.ISelectionModel; - import org.apache.flex.core.IStrand; - import org.apache.flex.core.IUIBase; - import org.apache.flex.core.ValuesManager; - import org.apache.flex.events.Event; - import org.apache.flex.events.IEventDispatcher; - import org.apache.flex.html.beads.IDropDownListView; - import org.apache.flex.utils.CSSUtils; - - /** - * The DropDownListView class is the default view for - * the org.apache.flex.flat.DropDownList class. - * It displays a simple text label with what appears to be a - * down arrow button on the right, but really, the entire - * view is the button that will display or dismiss the dropdown. - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public class DropDownListView extends BeadViewBase implements IDropDownListView, IBeadView - { - /** - * Constructor. - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public function DropDownListView() - { - upSprite = new CSSSprite(); - upSprite.className = 'dropdown-toggle-open-btn'; - downSprite = new CSSSprite(); - downSprite.className = 'dropdown-toggle-open-btn'; - overSprite = new CSSSprite(); - overSprite.className = 'dropdown-toggle-open-btn'; - overSprite.state = 'hover'; - upTextField = new CSSTextField(); - downTextField = new CSSTextField(); - overTextField = new CSSTextField(); - upSprite.addChild(upTextField); - overSprite.addChild(overTextField); - downSprite.addChild(downTextField); - upTextField.selectable = false; - upTextField.parentDrawsBackground = true; - upTextField.parentHandlesPadding = true; - upTextField.type = TextFieldType.DYNAMIC; - downTextField.selectable = false; - downTextField.parentDrawsBackground = true; - downTextField.parentHandlesPadding = true; - downTextField.type = TextFieldType.DYNAMIC; - overTextField.selectable = false; - overTextField.parentDrawsBackground = true; - overTextField.parentHandlesPadding = true; - overTextField.type = TextFieldType.DYNAMIC; - // auto-size collapses if no text - //upTextField.autoSize = "left"; - //downTextField.autoSize = "left"; - //overTextField.autoSize = "left"; - - upArrows = new CSSShape(); - upArrows.className = 'dropdown-caret'; - overArrows = new CSSShape(); - overArrows.className = 'dropdown-caret'; - downArrows = new CSSShape(); - downArrows.className = 'dropdown-caret'; - upSprite.addChild(upArrows); - overSprite.addChild(overArrows); - downSprite.addChild(downArrows); - - } - - - private var selectionModel:ISelectionModel; - - 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;; - selectionModel = value.getBeadByType(ISelectionModel) as ISelectionModel; - selectionModel.addEventListener("selectedIndexChanged", selectionChangeHandler); - selectionModel.addEventListener("dataProviderChanged", selectionChangeHandler); - 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; - if (selectionModel.selectedIndex !== -1) - selectionChangeHandler(null); - else - text = "^W_"; - upTextField.height = upTextField.textHeight + 4; - downTextField.height = downTextField.textHeight + 4; - overTextField.height = overTextField.textHeight + 4; - if (selectionModel.selectedIndex == -1) - text = ""; - - IEventDispatcher(value).addEventListener("heightChanged", changeHandler); - IEventDispatcher(value).addEventListener("widthChanged", changeHandler); - changeHandler(null); - } - - private function selectionChangeHandler(event:Event):void - { - if (selectionModel.selectedItem == null) - text = ""; - else if (selectionModel.labelField != null) - text = selectionModel.selectedItem[selectionModel.labelField].toString(); - else - text = selectionModel.selectedItem.toString(); - } - - private function changeHandler(event:Event):void - { - var ww:Number = DisplayObject(_strand).width; - var hh:Number = DisplayObject(_strand).height; - var padding:Object = ValuesManager.valuesImpl.getValue(_strand, "padding"); - var paddingLeft:Object = ValuesManager.valuesImpl.getValue(_strand,"padding-left"); - var paddingRight:Object = ValuesManager.valuesImpl.getValue(_strand,"padding-right"); - var paddingTop:Object = ValuesManager.valuesImpl.getValue(_strand,"padding-top"); - var paddingBottom:Object = ValuesManager.valuesImpl.getValue(_strand,"padding-bottom"); - var pl:Number = CSSUtils.getLeftValue(paddingLeft, padding, ww); - var pr:Number = CSSUtils.getRightValue(paddingRight, padding, ww); - var pt:Number = CSSUtils.getLeftValue(paddingTop, padding, hh); - var pb:Number = CSSUtils.getRightValue(paddingBottom, padding, hh); - - upArrows.draw(0, 0); - overArrows.draw(0, 0); - downArrows.draw(0, 0); - if (ILayoutChild(_strand).isHeightSizedToContent() && text != "") - { - hh = upTextField.textHeight + pt + pb; - ILayoutChild(_strand).setHeight(hh, true); - } - upSprite.draw(ww, hh); - overSprite.draw(ww, hh); - downSprite.draw(ww, hh); - - upArrows.x = ww - upArrows.width - pr; - overArrows.x = ww - overArrows.width - pr; - downArrows.x = ww - downArrows.width - pr; - upArrows.y = (hh - upArrows.height) / 2; - overArrows.y = (hh - overArrows.height) / 2; - downArrows.y = (hh - downArrows.height) / 2; - - upTextField.width = upTextField.textWidth + 4; - downTextField.width = downTextField.textWidth + 4; - overTextField.width = overTextField.textWidth + 4; - upTextField.height = upTextField.textHeight + 5; - downTextField.height = downTextField.textHeight + 5; - overTextField.height = overTextField.textHeight + 5; - upTextField.y = (hh - upTextField.height) / 2; - downTextField.y = (hh - downTextField.height) / 2; - overTextField.y = (hh - overTextField.height) / 2; - upTextField.x = pl; - downTextField.x = pl; - overTextField.x = pl; - shape.graphics.clear(); - shape.graphics.beginFill(0xCCCCCC); - shape.graphics.drawRect(0, 0, ww, hh); - shape.graphics.endFill(); - } - - private var upTextField:CSSTextField; - private var downTextField:CSSTextField; - private var overTextField:CSSTextField; - private var upSprite:CSSSprite; - private var downSprite:CSSSprite; - private var overSprite:CSSSprite; - private var upArrows:CSSShape; - private var downArrows:CSSShape; - private var overArrows:CSSShape; - - /** - * The text that is displayed in the view. - * - * @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; - changeHandler(null); - } - - private var _popUp:IStrand; - - /** - * The dropdown/popup that displays the set of choices. - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public function get popUp():IStrand - { - if (!_popUp) - { - var popUpClass:Class = ValuesManager.valuesImpl.getValue(_strand, "iPopUp") as Class; - _popUp = new popUpClass() as IStrand; - } - return _popUp; - } - - private var _popUpVisible:Boolean; - - /** - * A flag that indicates whether the dropdown/popup is - * visible. - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public function get popUpVisible():Boolean - { - return _popUpVisible; - } - - /** - * @private - */ - public function set popUpVisible(value:Boolean):void - { - if (value != _popUpVisible) - { - _popUpVisible = value; - if (value) - { - var root:Object = DisplayObject(_strand).root; - var host:DisplayObjectContainer = DisplayObject(_strand).parent; - while (host && !(host is IPopUpHost)) - host = host.parent; - if (host) - IPopUpHost(host).addElement(popUp); - } - else - { - DisplayObject(_popUp).parent.removeChild(_popUp as DisplayObject); - } - } - } - - } -}
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/e31f54e4/frameworks/projects/Flat/as/src/org/apache/flex/flat/beads/RadioCSSContentAndTextToggleButtonView.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Flat/as/src/org/apache/flex/flat/beads/RadioCSSContentAndTextToggleButtonView.as b/frameworks/projects/Flat/as/src/org/apache/flex/flat/beads/RadioCSSContentAndTextToggleButtonView.as deleted file mode 100644 index e6e3ba5..0000000 --- a/frameworks/projects/Flat/as/src/org/apache/flex/flat/beads/RadioCSSContentAndTextToggleButtonView.as +++ /dev/null @@ -1,47 +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.flat.beads -{ - /** - * The RadioCSSContentAndTextToggleButtonView class is the default view for - * the org.apache.flex.flat.RadioButton class. - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public class RadioCSSContentAndTextToggleButtonView extends CSSContentAndTextToggleButtonView - { - /** - * Constructor. - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public function RadioCSSContentAndTextToggleButtonView() - { - super(); - - className = "radio-icon"; - } - } -} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/e31f54e4/frameworks/projects/Flat/as/src/org/apache/flex/flat/supportClasses/DropDownListList.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Flat/as/src/org/apache/flex/flat/supportClasses/DropDownListList.as b/frameworks/projects/Flat/as/src/org/apache/flex/flat/supportClasses/DropDownListList.as deleted file mode 100644 index f423d24..0000000 --- a/frameworks/projects/Flat/as/src/org/apache/flex/flat/supportClasses/DropDownListList.as +++ /dev/null @@ -1,64 +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.flat.supportClasses -{ - import org.apache.flex.core.IPopUp; - import org.apache.flex.html.SimpleList; - import org.apache.flex.html.beads.SolidBackgroundBead; - - //-------------------------------------- - // Events - //-------------------------------------- - - /** - * @copy org.apache.flex.core.ISelectionModel#change - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - [Event(name="change", type="org.apache.flex.events.Event")] - - /** - * The DropDownListList class is the List class used internally - * by DropDownList as the dropdown/popup. - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public class DropDownListList extends SimpleList implements IPopUp - { - /** - * Constructor. - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public function DropDownListList() - { - super(); - className = "dropdown-menu"; - } - } -} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/e31f54e4/frameworks/projects/Flat/as/src/org/apache/flex/flat/supportClasses/DropDownListStringItemRenderer.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Flat/as/src/org/apache/flex/flat/supportClasses/DropDownListStringItemRenderer.as b/frameworks/projects/Flat/as/src/org/apache/flex/flat/supportClasses/DropDownListStringItemRenderer.as deleted file mode 100644 index 3ab6a79..0000000 --- a/frameworks/projects/Flat/as/src/org/apache/flex/flat/supportClasses/DropDownListStringItemRenderer.as +++ /dev/null @@ -1,70 +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.flat.supportClasses -{ - import flash.text.TextFieldAutoSize; - import flash.text.TextFieldType; - - import org.apache.flex.core.CSSTextField; - import org.apache.flex.core.ValuesManager; - import org.apache.flex.events.Event; - import org.apache.flex.html.beads.ITextItemRenderer; - import org.apache.flex.html.supportClasses.StringItemRenderer; - - /** - * The DropDownListStringItemRenderer is a StringItemRenderer with a particular - * className for use in DropDownList. - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public class DropDownListStringItemRenderer extends StringItemRenderer - { - /** - * constructor. - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public function DropDownListStringItemRenderer() - { - super(); - - className = 'dropdown-menu-item-renderer'; - } - - /** - * @private - */ - override public function updateRenderer():void - { - className = selected ? 'dropdown-menu-item-renderer-selected' : 'dropdown-menu-item-renderer'; - if (selected) - selectedColor = ValuesManager.valuesImpl.getValue(this, 'background-color'); - if (hovered) - highlightColor = ValuesManager.valuesImpl.getValue(this, 'background-color', "hover"); - downColor = selectedColor; - super.updateRenderer(); - } - } -} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/e31f54e4/frameworks/projects/Flat/compile-asjs-config.xml ---------------------------------------------------------------------- diff --git a/frameworks/projects/Flat/compile-asjs-config.xml b/frameworks/projects/Flat/compile-asjs-config.xml deleted file mode 100644 index a755d5c..0000000 --- a/frameworks/projects/Flat/compile-asjs-config.xml +++ /dev/null @@ -1,80 +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. - ---> -<flex-config> - - <compiler> - <accessible>false</accessible> - - <external-library-path> - </external-library-path> - - <mxml> - <children-as-data>true</children-as-data> - </mxml> - <binding-value-change-event>org.apache.flex.events.ValueChangeEvent</binding-value-change-event> - <binding-value-change-event-kind>org.apache.flex.events.ValueChangeEvent</binding-value-change-event-kind> - <binding-value-change-event-type>valueChange</binding-value-change-event-type> - - <keep-as3-metadata> - <name>Bindable</name> - <name>Managed</name> - <name>ChangeEvent</name> - <name>NonCommittingChangeEvent</name> - <name>Transient</name> - </keep-as3-metadata> - - <locale/> - - <library-path> - <!-- asjscompc won't 'link' these classes in, but will list their requires - if these swcs are on the external-library-path then their requires - will not be listed --> - <path-element>../../externs/Core.swc</path-element> - <path-element>../../externs/HTML.swc</path-element> - </library-path> - - <namespaces> - <namespace> - <uri>library://ns.apache.org/flexjs/flat</uri> - <manifest>flat-manifest.xml</manifest> - </namespace> - </namespaces> - - <source-path> - <path-element>as/src</path-element> - </source-path> - - <warn-no-constructor>false</warn-no-constructor> - </compiler> - - <include-file> - </include-file> - - <include-classes> - <class>FlatClasses</class> - </include-classes> - - <include-namespaces> - <uri>library://ns.apache.org/flexjs/flat</uri> - </include-namespaces> - - <target-player>${playerglobal.version}</target-player> - - -</flex-config> http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/e31f54e4/frameworks/projects/Flat/compile-config.xml ---------------------------------------------------------------------- diff --git a/frameworks/projects/Flat/compile-config.xml b/frameworks/projects/Flat/compile-config.xml deleted file mode 100644 index 44c7c9f..0000000 --- a/frameworks/projects/Flat/compile-config.xml +++ /dev/null @@ -1,91 +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. - ---> -<flex-config> - - <compiler> - <accessible>false</accessible> - - <external-library-path> - <path-element>${env.AIR_HOME}/frameworks/libs/air/airglobal.swc</path-element> - <path-element>../../libs/Binding.swc</path-element> - <path-element>../../libs/Core.swc</path-element> - <path-element>../../libs/Graphics.swc</path-element> - <path-element>../../libs/HTML.swc</path-element> - </external-library-path> - - <mxml> - <children-as-data>true</children-as-data> - </mxml> - <binding-value-change-event>org.apache.flex.events.ValueChangeEvent</binding-value-change-event> - <binding-value-change-event-kind>org.apache.flex.events.ValueChangeEvent</binding-value-change-event-kind> - <binding-value-change-event-type>valueChange</binding-value-change-event-type> - - <keep-as3-metadata> - <name>Bindable</name> - <name>Managed</name> - <name>ChangeEvent</name> - <name>NonCommittingChangeEvent</name> - <name>Transient</name> - </keep-as3-metadata> - - <locale/> - - <library-path/> - - <namespaces> - <namespace> - <uri>library://ns.apache.org/flexjs/flat</uri> - <manifest>flat-manifest.xml</manifest> - </namespace> - <namespace> - <uri>library://ns.apache.org/flexjs/flat</uri> - <manifest>flat-as-manifest.xml</manifest> - </namespace> - </namespaces> - - <source-path> - <path-element>as/src</path-element> - <!--<path-element>asjs/src</path-element>--> - </source-path> - - <warn-no-constructor>false</warn-no-constructor> - </compiler> - - <include-file> - <name>defaults.css</name> - <path>as/defaults.css</path> - </include-file> - <include-file> - <name>js/out/*</name> - <path>js/out/*</path> - </include-file> - - <include-classes> - <class>FlatClasses</class> - <!--<class>FlatASJSClasses</class>--> - </include-classes> - - <include-namespaces> - <uri>library://ns.apache.org/flexjs/flat</uri> - </include-namespaces> - - <target-player>${playerglobal.version}</target-player> - - -</flex-config> http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/e31f54e4/frameworks/projects/Flat/flat-as-manifest.xml ---------------------------------------------------------------------- diff --git a/frameworks/projects/Flat/flat-as-manifest.xml b/frameworks/projects/Flat/flat-as-manifest.xml deleted file mode 100644 index 6f12083..0000000 --- a/frameworks/projects/Flat/flat-as-manifest.xml +++ /dev/null @@ -1,26 +0,0 @@ -<?xml version="1.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. - ---> - - -<componentPackage> - - <component id="DropDownListList" class="org.apache.flex.flat.supportClasses.DropDownListList" /> - -</componentPackage> http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/e31f54e4/frameworks/projects/Flat/flat-manifest.xml ---------------------------------------------------------------------- diff --git a/frameworks/projects/Flat/flat-manifest.xml b/frameworks/projects/Flat/flat-manifest.xml deleted file mode 100644 index 77f5ffc..0000000 --- a/frameworks/projects/Flat/flat-manifest.xml +++ /dev/null @@ -1,99 +0,0 @@ -<?xml version="1.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. - ---> - - -<componentPackage> - - <component id="Button" class="org.apache.flex.html.Button" lookupOnly="true" /> - <component id="ButtonBar" class="org.apache.flex.html.ButtonBar" lookupOnly="true" /> - <component id="CloseButton" class="org.apache.flex.html.CloseButton" lookupOnly="true" /> - <component id="DropDownList" class="org.apache.flex.flat.DropDownList" /> - <component id="Image" class="org.apache.flex.html.Image" lookupOnly="true" /> - <component id="Label" class="org.apache.flex.html.Label" lookupOnly="true" /> - <component id="MultilineLabel" class="org.apache.flex.html.MultilineLabel" lookupOnly="true" /> - <component id="ImageAndTextButton" class="org.apache.flex.html.ImageAndTextButton" lookupOnly="true" /> - <component id="TextButton" class="org.apache.flex.html.TextButton" lookupOnly="true" /> - <component id="ToggleTextButton" class="org.apache.flex.html.ToggleTextButton" lookupOnly="true" /> - <component id="TextInput" class="org.apache.flex.html.TextInput" lookupOnly="true" /> - <component id="TextArea" class="org.apache.flex.html.TextArea" lookupOnly="true" /> - <component id="List" class="org.apache.flex.html.List" lookupOnly="true" /> - <component id="SimpleList" class="org.apache.flex.html.SimpleList" lookupOnly="true" /> - <component id="CheckBox" class="org.apache.flex.flat.CheckBox" /> - <component id="RadioButton" class="org.apache.flex.flat.RadioButton" /> - <component id="ComboBox" class="org.apache.flex.html.ComboBox" lookupOnly="true" /> - <component id="Container" class="org.apache.flex.html.Container" lookupOnly="true" /> - <component id="HContainer" class="org.apache.flex.html.HContainer" lookupOnly="true" /> - <component id="VContainer" class="org.apache.flex.html.VContainer" lookupOnly="true" /> - <component id="Panel" class="org.apache.flex.html.Panel" lookupOnly="true" /> - <component id="PanelView" class="org.apache.flex.html.beads.PanelView" lookupOnly="true" /> - <component id="PanelWithControlBar" class="org.apache.flex.html.PanelWithControlBar" lookupOnly="true" /> - <component id="ControlBar" class="org.apache.flex.html.ControlBar" lookupOnly="true" /> - <component id="TitleBar" class="org.apache.flex.html.TitleBar" lookupOnly="true" /> - <component id="TitleBarModel" class="org.apache.flex.html.beads.models.TitleBarModel" lookupOnly="true" /> - <component id="ToolTip" class="org.apache.flex.html.ToolTip" lookupOnly="true" /> - <component id="BasicLayout" class="org.apache.flex.html.beads.layouts.BasicLayout" lookupOnly="true" /> - <component id="VerticalLayout" class="org.apache.flex.html.beads.layouts.VerticalLayout" lookupOnly="true" /> - <component id="HorizontalLayout" class="org.apache.flex.html.beads.layouts.HorizontalLayout" lookupOnly="true" /> - <component id="TileLayout" class="org.apache.flex.html.beads.layouts.TileLayout" lookupOnly="true" /> - <component id="ListView" class="org.apache.flex.html.beads.ListView" lookupOnly="true" /> - <component id="MultilineTextFieldView" class="org.apache.flex.html.beads.MultilineTextFieldView" lookupOnly="true" /> - - <component id="SimpleAlert" class="org.apache.flex.html.SimpleAlert" lookupOnly="true" /> - <component id="Alert" class="org.apache.flex.html.Alert" lookupOnly="true" /> - <component id="Spinner" class="org.apache.flex.html.Spinner" lookupOnly="true" /> - <component id="Slider" class="org.apache.flex.html.Slider" lookupOnly="true" /> - <component id="SolidBackgroundBead" class="org.apache.flex.html.beads.SolidBackgroundBead" lookupOnly="true" /> - <component id="NumericStepper" class="org.apache.flex.html.NumericStepper" lookupOnly="true" /> - <component id="TextFieldItemRenderer" class="org.apache.flex.html.supportClasses.TextFieldItemRenderer" lookupOnly="true" /> - <component id="StringItemRenderer" class="org.apache.flex.html.supportClasses.StringItemRenderer" lookupOnly="true" /> - <component id="DataItemRenderer" class="org.apache.flex.html.supportClasses.DataItemRenderer" lookupOnly="true" /> - <component id="ButtonBarButtonItemRenderer" class="org.apache.flex.html.supportClasses.ButtonBarButtonItemRenderer" lookupOnly="true" /> - <component id="VScrollBar" class="org.apache.flex.html.supportClasses.VScrollBar" lookupOnly="true" /> - <component id="NumericOnlyTextInputBead" class="org.apache.flex.html.accessories.NumericOnlyTextInputBead" lookupOnly="true" /> - <component id="PasswordInputBead" class="org.apache.flex.html.accessories.PasswordInputBead" lookupOnly="true" /> - <component id="TextPromptBead" class="org.apache.flex.html.accessories.TextPromptBead" lookupOnly="true" /> - <component id="HRule" class="org.apache.flex.html.HRule" lookupOnly="true" /> - <component id="Spacer" class="org.apache.flex.html.Spacer" lookupOnly="true" /> - <component id="ImageAndTextButtonView" class="org.apache.flex.html.beads.ImageAndTextButtonView" lookupOnly="true" /> - <component id="ScrollingViewport" class="org.apache.flex.html.supportClasses.ScrollingViewport" lookupOnly="true" /> - - <component id="DataGrid" class="org.apache.flex.html.DataGrid" lookupOnly="true" /> - <component id="DataGridColumn" class="org.apache.flex.html.supportClasses.DataGridColumn" lookupOnly="true" /> - - <component id="DateChooser" class="org.apache.flex.html.DateChooser" lookupOnly="true" /> - <component id="DateField" class="org.apache.flex.html.DateField" lookupOnly="true" /> - <component id="VerticalColumnLayout" class="org.apache.flex.html.beads.layouts.VerticalColumnLayout" lookupOnly="true" /> - - <component id="ToolTipBead" class="org.apache.flex.html.accessories.ToolTipBead" lookupOnly="true" /> - - <component id="LayoutChangeNotifier" class="org.apache.flex.html.beads.layouts.LayoutChangeNotifier" lookupOnly="true" /> - <component id="ImageButton" class="org.apache.flex.html.ImageButton" lookupOnly="true" /> - <component id="FlexibleFirstChildHorizontalLayout" class="org.apache.flex.html.beads.layouts.FlexibleFirstChildHorizontalLayout" lookupOnly="true" /> - <component id="OneFlexibleChildVerticalLayout" class="org.apache.flex.html.beads.layouts.OneFlexibleChildVerticalLayout" lookupOnly="true" /> - <component id="OneFlexibleChildHorizontalLayout" class="org.apache.flex.html.beads.layouts.OneFlexibleChildHorizontalLayout" lookupOnly="true" /> - <component id="MXMLBeadViewBase" class="org.apache.flex.html.MXMLBeadViewBase" lookupOnly="true" /> - - <component id="Border" class="org.apache.flex.html.supportClasses.Border" lookupOnly="true" /> - - <component id="ViewBase" class="org.apache.flex.core.ViewBase" lookupOnly="true" /> - <component id="ViewBaseDataBinding" class="org.apache.flex.binding.ViewBaseDataBinding" lookupOnly="true" /> - <component id="State" class="org.apache.flex.states.State" lookupOnly="true" /> - -</componentPackage> http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/e31f54e4/frameworks/projects/Flat/src/main/flex/FlatClasses.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Flat/src/main/flex/FlatClasses.as b/frameworks/projects/Flat/src/main/flex/FlatClasses.as new file mode 100644 index 0000000..29173ef --- /dev/null +++ b/frameworks/projects/Flat/src/main/flex/FlatClasses.as @@ -0,0 +1,44 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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 +{ + +/** + * @private + * This class is used to link additional classes into rpc.swc + * beyond those that are found by dependecy analysis starting + * from the classes specified in manifest.xml. + */ +internal class FlatClasses +{ + COMPILE::AS3 + { + import org.apache.flex.flat.beads.CSSScrollBarView; CSSScrollBarView; + import org.apache.flex.flat.beads.CSSScrollBarButtonView; CSSScrollBarButtonView; + import org.apache.flex.flat.supportClasses.DropDownListStringItemRenderer; DropDownListStringItemRenderer; + import org.apache.flex.flat.supportClasses.DropDownListList; DropDownListList; + import org.apache.flex.flat.beads.DropDownListView; DropDownListView; + import org.apache.flex.flat.beads.CheckboxCSSContentAndTextToggleButtonView; CheckboxCSSContentAndTextToggleButtonView; + import org.apache.flex.flat.beads.RadioCSSContentAndTextToggleButtonView; RadioCSSContentAndTextToggleButtonView; + + } +} + +} + http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/e31f54e4/frameworks/projects/Flat/src/main/flex/org/apache/flex/flat/CheckBox.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Flat/src/main/flex/org/apache/flex/flat/CheckBox.as b/frameworks/projects/Flat/src/main/flex/org/apache/flex/flat/CheckBox.as new file mode 100644 index 0000000..466e9b2 --- /dev/null +++ b/frameworks/projects/Flat/src/main/flex/org/apache/flex/flat/CheckBox.as @@ -0,0 +1,161 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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.flat +{ + COMPILE::AS3 + { + import org.apache.flex.html.CheckBox; + } + COMPILE::JS + { + import org.apache.flex.core.UIBase; + import org.apache.flex.core.WrappedHTMLElement; + import org.apache.flex.events.Event; + } + + /** + * The CheckBox class provides a FlatUI-like appearance for + * a CheckBox. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + COMPILE::AS3 + public class CheckBox extends org.apache.flex.html.CheckBox + { + /** + * Constructor. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function CheckBox() + { + super(); + } + } + + COMPILE::JS + public class CheckBox extends UIBase + { + + private var input:HTMLInputElement; + private var checkbox:HTMLSpanElement; + private var label:HTMLLabelElement; + private var textNode:Text; + + /** + * @flexjsignorecoercion org.apache.flex.core.WrappedHTMLElement + * @flexjsignorecoercion HTMLLabelElement + * @flexjsignorecoercion HTMLInputElement + * @flexjsignorecoercion HTMLSpanElement + * @flexjsignorecoercion Text + */ + override protected function createElement():WrappedHTMLElement + { + label = document.createElement('label') as HTMLLabelElement; + element = label as WrappedHTMLElement; + + input = document.createElement('input') as HTMLInputElement; + input.type = 'checkbox'; + input.className = 'checkbox-input'; + input.addEventListener('change', selectionChangeHandler, false); + label.appendChild(input); + + checkbox = document.createElement('span') as HTMLSpanElement; + checkbox.className = 'checkbox-icon'; + checkbox.addEventListener('mouseover', mouseOverHandler, false); + checkbox.addEventListener('mouseout', mouseOutHandler, false); + label.appendChild(checkbox); + + textNode = document.createTextNode('') as Text; + label.appendChild(textNode); + label.className = 'CheckBox'; + typeNames = 'CheckBox'; + + positioner = element; + positioner.style.position = 'relative'; + (input as WrappedHTMLElement).flexjs_wrapper = this; + (checkbox as WrappedHTMLElement).flexjs_wrapper = this; + element.flexjs_wrapper = this; + + return element; + }; + + + /** + */ + private function mouseOverHandler(event:Event):void + { + checkbox.className = 'checkbox-icon-hover'; + } + + /** + */ + private function mouseOutHandler(event:Event):void + { + if (input.checked) + checkbox.className = 'checkbox-icon-checked'; + else + checkbox.className = 'checkbox-icon'; + } + + + /** + */ + private function selectionChangeHandler(event:Event):void + { + if (input.checked) + checkbox.className = 'checkbox-icon-checked'; + else + checkbox.className = 'checkbox-icon'; + } + + + public function get text():String + { + return textNode.nodeValue; + } + + public function set text(value:String):void + { + textNode.nodeValue = value; + } + + public function get selected():Boolean + { + return input.checked; + } + + public function set selected(value:Boolean):void + { + input.checked = value; + if (value) + checkbox.className = 'checkbox-icon-checked'; + else + checkbox.className = 'checkbox-icon'; + } + + } + +} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/e31f54e4/frameworks/projects/Flat/src/main/flex/org/apache/flex/flat/DropDownList.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Flat/src/main/flex/org/apache/flex/flat/DropDownList.as b/frameworks/projects/Flat/src/main/flex/org/apache/flex/flat/DropDownList.as new file mode 100644 index 0000000..265f2c7 --- /dev/null +++ b/frameworks/projects/Flat/src/main/flex/org/apache/flex/flat/DropDownList.as @@ -0,0 +1,368 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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.flat +{ + import org.apache.flex.core.UIBase; + + COMPILE::AS3 + { + import org.apache.flex.html.DropDownList; + } + COMPILE::JS + { + import goog.events; + import org.apache.flex.core.ListBase; + import org.apache.flex.core.WrappedHTMLElement; + import org.apache.flex.core.ISelectionModel; + import org.apache.flex.events.Event; + import org.apache.flex.html.beads.models.ArraySelectionModel; + import org.apache.flex.utils.CSSUtils; + } + + /** + * The DropDownList class provides a FlatUI-like appearance for + * a DropDownList. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + COMPILE::AS3 + public class DropDownList extends org.apache.flex.html.DropDownList + { + /** + * Constructor. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function DropDownList() + { + super(); + } + } + + COMPILE::JS + public class DropDownList extends ListBase + { + /** + * Constructor. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function DropDownList() + { + super(); + model = new ArraySelectionModel(); + } + + private var label:HTMLSpanElement; + private var button:HTMLButtonElement; + private var caret:HTMLSpanElement; + private var menu:HTMLUListElement; + + /** + * @flexjsignorecoercion org.apache.flex.core.WrappedHTMLElement + * @flexjsignorecoercion HTMLButtonElement + * @flexjsignorecoercion HTMLDivElement + * @flexjsignorecoercion HTMLSpanElement + */ + override protected function createElement():WrappedHTMLElement + { + var button:HTMLButtonElement; + var outer:HTMLDivElement; + var caret:HTMLSpanElement; + + this.element = document.createElement('div') as WrappedHTMLElement; + outer = this.element as HTMLDivElement; + + this.button = button = document.createElement('button') as HTMLButtonElement; + button.className = 'dropdown-toggle-open-btn'; + if (this.className) + button.className += ' ' + this.className; + goog.events.listen(button, 'click', buttonClicked); + outer.appendChild(button); + + this.label = document.createElement('span') as HTMLSpanElement; + this.label.className = 'dropdown-label'; + button.appendChild(this.label); + this.caret = caret = document.createElement('span') as HTMLSpanElement; + button.appendChild(caret); + caret.className = 'dropdown-caret'; + + this.positioner = this.element; + this.positioner.style.position = 'relative'; + + // add a click handler so that a click outside of the combo box can + // dismiss the pop-up should it be visible. + goog.events.listen(document, 'click', dismissPopup); + + (button as WrappedHTMLElement).flexjs_wrapper = this; + this.element.flexjs_wrapper = this; + (this.label as WrappedHTMLElement).flexjs_wrapper = this; + (caret as WrappedHTMLElement).flexjs_wrapper = this; + + return this.element; + } + + + /** + * @param event The event. + * @flexjsignorecoercion org.apache.flex.core.UIBase + */ + private function selectChanged(event:Event):void + { + var select:UIBase; + + select = event.target as UIBase; + + this.selectedIndex = parseInt(select.id, 10); + + this.menu.parentNode.removeChild(this.menu); + this.menu = null; + + this.dispatchEvent('change'); + } + + + /** + * @param event The event. + */ + private function dismissPopup(event:Event = null):void + { + // remove the popup if it already exists + if (this.menu) + { + this.menu.parentNode.removeChild(this.menu); + this.menu = null; + } + } + + + /** + * @param event The event. + * @flexjsignorecoercion Array + * @flexjsignorecoercion HTMLButtonElement + * @flexjsignorecoercion HTMLUListElement + * @flexjsignorecoercion HTMLLIElement + * @flexjsignorecoercion HTMLAnchorElement + */ + private function buttonClicked(event:Event):void + { + var dp:Array; + var i:int; + var button:HTMLButtonElement; + var left:Number; + var n:int; + var opt:HTMLLIElement; + var opts:Array; + var pn:HTMLDivElement; + var select:HTMLUListElement; + var top:Number; + var width:Number; + + event.stopPropagation(); + + if (this.menu) + { + this.dismissPopup(); + return; + } + + button = this.element.childNodes.item(0) as HTMLButtonElement; + + pn = this.element as HTMLDivElement; + top = pn.offsetTop + button.offsetHeight; + left = pn.offsetLeft; + width = pn.offsetWidth; + + this.menu = select = document.createElement('ul') as HTMLUListElement; + var el:Element = element as Element; + var cv:Object = getComputedStyle(el); + select.style.width = cv.width; + goog.events.listen(select, 'click', selectChanged); + select.className = 'dropdown-menu'; + + var lf:String = this.labelField; + dp = dataProvider as Array; + n = dp.length; + for (i = 0; i < n; i++) { + opt = document.createElement('li') as HTMLLIElement; + opt.style.backgroundColor = 'transparent'; + var ir:HTMLAnchorElement = document.createElement('a') as HTMLAnchorElement; + if (lf) + ir.innerHTML = dp[i][lf]; + else + ir.innerHTML = dp[i]; + ir.id = i.toString(); + if (i == this.selectedIndex) + ir.className = 'dropdown-menu-item-renderer-selected'; + else + ir.className = 'dropdown-menu-item-renderer'; + opt.appendChild(ir); + select.appendChild(opt); + } + + this.element.appendChild(select); + }; + + + /** + */ + override public function addedToParent():void + { + super.addedToParent(); + var el:Element = button as Element; + var cv:Object = getComputedStyle(el); + var s:String = cv.paddingLeft; + var pl:Number = CSSUtils.toNumber(s); + s = cv.paddingRight; + var pr:Number = CSSUtils.toNumber(s); + s = cv.borderLeftWidth; + var bl:Number = CSSUtils.toNumber(s); + s = cv.borderRightWidth; + var br:Number = CSSUtils.toNumber(s); + var caretWidth:Number = this.caret.offsetWidth; + // 10 seems to factor spacing between span and extra FF padding? + var fluff:Number = pl + pr + bl + br + caretWidth + 1 + 10; + var labelWidth:Number = this.width - fluff; + var strWidth:String = labelWidth.toString(); + strWidth += 'px'; + this.label.style.width = strWidth; + } + + override public function set className(value:String):void + { + super.className = value; + if (this.button) { + this.button.className = this.typeNames ? + value + ' ' + 'dropdown-toggle-open-btn' + ' ' + this.typeNames : + value + ' ' + 'dropdown-toggle-open-btn'; + } + } + + /** + * The data set to be displayed. Usually a simple + * array of strings. A more complex component + * would allow more complex data and data sets. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get dataProvider():Object + { + return ISelectionModel(model).dataProvider; + } + + /** + * @private + * @flexjsignorecoercion HTMLOptionElement + * @flexjsignorecoercion HTMLSelectElement + */ + public function set dataProvider(value:Object):void + { + ISelectionModel(model).dataProvider = value; + } + + /** + * The name of field within the data used for display. Each item of the + * data should have a property with this name. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get labelField():String + { + return ISelectionModel(model).labelField; + } + public function set labelField(value:String):void + { + ISelectionModel(model).labelField = value; + } + + [Bindable("change")] + /** + * @copy org.apache.flex.core.ISelectionModel#selectedIndex + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get selectedIndex():int + { + return ISelectionModel(model).selectedIndex; + } + + /** + * @private + * @flexjsignorecoercion HTMLSelectElement + * @flexjsignorecoercion String + */ + public function set selectedIndex(value:int):void + { + ISelectionModel(model).selectedIndex = value; + var lf:String = this.labelField; + if (lf) + this.label.innerHTML = this.selectedItem[lf] as String; + else + this.label.innerHTML = this.selectedItem as String; + } + + + [Bindable("change")] + /** + * @copy org.apache.flex.core.ISelectionModel#selectedItem + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get selectedItem():Object + { + return ISelectionModel(model).selectedItem; + } + + /** + * @private + * @flexjsignorecoercion HTMLSelectElement + * @flexjsignorecoercion String + */ + public function set selectedItem(value:Object):void + { + ISelectionModel(model).selectedItem = value; + var lf:String = this.labelField; + if (lf) + this.label.innerHTML = this.selectedItem[lf] as String; + else + this.label.innerHTML = this.selectedItem as String; + } + } +} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/e31f54e4/frameworks/projects/Flat/src/main/flex/org/apache/flex/flat/RadioButton.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Flat/src/main/flex/org/apache/flex/flat/RadioButton.as b/frameworks/projects/Flat/src/main/flex/org/apache/flex/flat/RadioButton.as new file mode 100644 index 0000000..1294a25 --- /dev/null +++ b/frameworks/projects/Flat/src/main/flex/org/apache/flex/flat/RadioButton.as @@ -0,0 +1,245 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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.flat +{ + COMPILE::AS3 + { + import org.apache.flex.html.RadioButton; + } + COMPILE::JS + { + import org.apache.flex.core.UIBase; + import org.apache.flex.core.WrappedHTMLElement; + } + + /** + * The RadioButton class provides a FlatUI-like appearance for + * a RadioButton. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + COMPILE::AS3 + public class RadioButton extends org.apache.flex.html.RadioButton + { + /** + * Constructor. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function RadioButton() + { + super(); + } + } + + COMPILE::JS + public class RadioButton extends UIBase + { + /** + * Provides unique name + */ + public static var radioCounter:int = 0; + + private var input:HTMLInputElement; + private var radio:HTMLSpanElement; + private var textNode:Text; + private var labelFor:HTMLLabelElement; + + /** + * @flexjsignorecoercion org.apache.flex.core.WrappedHTMLElement + * @flexjsignorecoercion HTMLInputElement + * @flexjsignorecoercion HTMLSpanElement + * @flexjsignorecoercion HTMLLabelElement + */ + override protected function createElement():WrappedHTMLElement + { + // hide this eleement + input = document.createElement('input') as HTMLInputElement; + input.type = 'radio'; + input.className = 'radio-input'; + input.id = '_radio_' + radioCounter++; + input.addEventListener('change', selectionChangeHandler, false); + + radio = document.createElement('span') as HTMLSpanElement; + radio.className = 'radio-icon'; + radio.addEventListener('mouseover', mouseOverHandler, false); + radio.addEventListener('mouseout', mouseOutHandler, false); + + textNode = document.createTextNode('radio button') as Text; + + labelFor = document.createElement('label') as HTMLLabelElement; + labelFor.appendChild(input); + labelFor.appendChild(radio); + labelFor.appendChild(textNode); + labelFor.style.position = 'relative'; + + element = labelFor as WrappedHTMLElement; + element.className = 'RadioButton'; + typeNames = 'RadioButton'; + + positioner = element; + positioner.style.position = 'relative'; + (input as WrappedHTMLElement).flexjs_wrapper = this; + (radio as WrappedHTMLElement).flexjs_wrapper = this; + element.flexjs_wrapper = this; + (textNode as WrappedHTMLElement).flexjs_wrapper = this; + + return element; + } + + + /** + * @param e The event object. + */ + private function mouseOverHandler(e:Event):void + { + radio.className = 'radio-icon-hover'; + } + + + /** + * @param e The event object. + */ + private function mouseOutHandler(e:Event):void + { + if (input.checked) + radio.className = 'radio-icon-checked'; + else + radio.className = 'radio-icon'; + } + + + /** + * @param e The event object. + */ + private function selectionChangeHandler(e:Event):void + { + // this should reset the icons in the non-selected radio + selectedValue = value; + } + + + override public function set id(value:String):void + { + super.id = value; + labelFor.id = value; + input.id = value; + } + + /** + * @flexjsignorecoercion String + */ + public function get groupName():String + { + return input.name as String; + } + + public function set groupName(value:String):void + { + input.name = value; + } + + public function get text():String + { + return textNode.nodeValue; + } + + public function set text(value:String):void + { + textNode.nodeValue = value; + } + + public function get selected():Boolean + { + return input.checked; + } + + public function set selected(value:Boolean):void + { + input.checked = value; + if (input.checked) + radio.className = 'radio-icon-checked'; + else + radio.className = 'radio-icon'; + } + + public function get value():String + { + return input.value; + } + + public function set value(value:String):void + { + input.value = value; + } + + /** + * @flexjsignorecoercion Array + * @flexjsignorecoercion String + */ + public function get selectedValue():Object + { + var buttons:Array; + var groupName:String; + var i:int; + var n:int; + + groupName = input.name as String; + buttons = document.getElementsByName(groupName) as Array; + n = buttons.length; + + for (i = 0; i < n; i++) { + if (buttons[i].checked) { + return buttons[i].value; + } + } + return null; + } + + /** + * @flexjsignorecoercion Array + * @flexjsignorecoercion String + */ + public function set selectedValue(value:Object):void + { + var buttons:Array; + var groupName:String; + var i:int; + var n:int; + + groupName = input.name as String; + buttons = document.getElementsByName(groupName) as Array; + n = buttons.length; + for (i = 0; i < n; i++) { + if (buttons[i].value === value) { + buttons[i].checked = true; + buttons[i].flexjs_wrapper.selected = true; + } + else + buttons[i].flexjs_wrapper.selected = false; + } + } + } +} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/e31f54e4/frameworks/projects/Flat/src/main/flex/org/apache/flex/flat/beads/CSSContentAndTextToggleButtonView.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Flat/src/main/flex/org/apache/flex/flat/beads/CSSContentAndTextToggleButtonView.as b/frameworks/projects/Flat/src/main/flex/org/apache/flex/flat/beads/CSSContentAndTextToggleButtonView.as new file mode 100644 index 0000000..aa3e8b5 --- /dev/null +++ b/frameworks/projects/Flat/src/main/flex/org/apache/flex/flat/beads/CSSContentAndTextToggleButtonView.as @@ -0,0 +1,304 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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.flat.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.core.StyleableCSSTextField; + import org.apache.flex.core.ValuesManager; + import org.apache.flex.events.Event; + import org.apache.flex.utils.CSSUtils; + + /** + * The CSSContentAndTextToggleButtonView class is the default view for + * the org.apache.flex.flat.CheckBox and RadioButton classes. + * It supports CSS content property for the + * icon. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public class CSSContentAndTextToggleButtonView extends BeadViewBase implements IBeadView + { + /** + * map of classname suffixes. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + private static var suffixMap:Object = { + "upSprite": "", + "downSprite": "-checked", + "overSprite": "-hover", + "upAndSelectedSprite": "-checked", + "downAndSelectedSprite": "-checked", + "overAndSelectedSprite": "-checked" + } + + /** + * className to use for styling. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + protected var className:String; + + /** + * Constructor. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function CSSContentAndTextToggleButtonView() + { + } + + 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; + + for (var p:String in suffixMap) + { + var s:Sprite = new Sprite(); + sprites.push(s); + this[p] = s; + + var tf:CSSTextField = new CSSTextField(); + tf.type = TextFieldType.DYNAMIC; + tf.autoSize = TextFieldAutoSize.LEFT; + tf.name = "textField"; + tf.parentHandlesPadding = true; + var icon:StyleableCSSTextField = new StyleableCSSTextField(); + icon.name = "icon"; + icon.className = className + suffixMap[p]; + s.addChild(icon); + s.addChild(tf); + } + + _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.styleParent = _strand; + 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 + { + // TODO: Layout using descendant selectors (.checkbox .icons) + for (var p:String in suffixMap) + { + var s:Sprite = this[p]; + var icon:StyleableCSSTextField = s.getChildByName("icon") as StyleableCSSTextField; + icon.autoSize = TextFieldAutoSize.LEFT; + var tf:CSSTextField = s.getChildByName("textField") as CSSTextField; + + icon.CSSParent = _strand; + var content:String = ValuesManager.valuesImpl.getValue(icon, "content", "before"); + if (content != null) + icon.text = content; + var mh:Number = Math.max(icon.height,tf.height); + + var padding:Object = ValuesManager.valuesImpl.getValue(_strand, "padding"); + var paddingLeft:Object = ValuesManager.valuesImpl.getValue(_strand,"padding-left"); + icon.x = 0; + icon.y = (mh - icon.height)/2; + + tf.x = CSSUtils.getLeftValue(paddingLeft, padding, s.width); + tf.y = (mh - tf.height)/2; + } + + } + } +} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/e31f54e4/frameworks/projects/Flat/src/main/flex/org/apache/flex/flat/beads/CSSScrollBarButtonView.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Flat/src/main/flex/org/apache/flex/flat/beads/CSSScrollBarButtonView.as b/frameworks/projects/Flat/src/main/flex/org/apache/flex/flat/beads/CSSScrollBarButtonView.as new file mode 100644 index 0000000..09669c4 --- /dev/null +++ b/frameworks/projects/Flat/src/main/flex/org/apache/flex/flat/beads/CSSScrollBarButtonView.as @@ -0,0 +1,178 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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.flat.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.CSSShape; + 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 CSSScrollBarButtonView class is the default view for + * the buttons in a org.apache.flex.html.ScrollBar class. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public class CSSScrollBarButtonView extends BeadViewBase implements IBeadView + { + /** + * Constructor. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function CSSScrollBarButtonView() + { + upSprite = new Sprite(); + downSprite = new Sprite(); + overSprite = new Sprite(); + upArrowShape = new CSSShape(); + downArrowShape = new CSSShape(); + overArrowShape = new CSSShape(); + overArrowShape.state = "hover"; + upSprite.addChild(upArrowShape); + downSprite.addChild(downArrowShape); + overSprite.addChild(overArrowShape); + } + + 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, overArrowShape, "hover"); + setupBackground(downSprite, downArrowShape, "active"); + setupBackground(upSprite, upArrowShape); + + 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, overArrowShape, "hover"); + setupSkin(downSprite, downArrowShape, "active"); + setupSkin(upSprite, upArrowShape); + updateHitArea(); + } + + private function setupSkin(sprite:Sprite, shape:CSSShape, 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); + + var w:Object = ValuesManager.valuesImpl.getValue(shape, "width", state); + var h:Object = ValuesManager.valuesImpl.getValue(shape, "height", state); + shape.draw(Number(w), Number(h)); + + CSSBorderUtils.draw(sprite.graphics, + shape.width + pl + pr, + shape.height + pt + pb, + _strand as DisplayObject, + state, true); + } + + private function setupBackground(sprite:Sprite, shape:CSSShape, 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, shape, state); + updateHitArea(); + }); + } + else { + setupSkin(sprite, shape, state); + updateHitArea(); + } + } + + private var upSprite:Sprite; + private var downSprite:Sprite; + private var overSprite:Sprite; + public var upArrowShape:CSSShape; + public var downArrowShape:CSSShape; + public var overArrowShape:CSSShape; + + private function updateHitArea():void + { + shape.graphics.clear(); + shape.graphics.beginFill(0xCCCCCC); + shape.graphics.drawRect(0, 0, upSprite.width, upSprite.height); + shape.graphics.endFill(); + + } + } +}
