You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by pe...@apache.org on 2013/02/22 23:05:58 UTC
svn commit: r1449236 - in /flex/asjs/branches/develop/frameworks/as: ./ src/
src/org/apache/flex/core/ src/org/apache/flex/html/staticControls/
src/org/apache/flex/html/staticControls/beads/
src/org/apache/flex/html/staticControls/beads/models/
Author: pent
Date: Fri Feb 22 22:05:57 2013
New Revision: 1449236
URL: http://svn.apache.org/r1449236
Log:
CheckBox added along with ToggleButtonModel
Added:
flex/asjs/branches/develop/frameworks/as/src/org/apache/flex/core/ICheckBoxBead.as (with props)
flex/asjs/branches/develop/frameworks/as/src/org/apache/flex/core/IToggleButtonModel.as (with props)
flex/asjs/branches/develop/frameworks/as/src/org/apache/flex/html/staticControls/CheckBox.as (with props)
flex/asjs/branches/develop/frameworks/as/src/org/apache/flex/html/staticControls/beads/CheckBoxBead.as (with props)
flex/asjs/branches/develop/frameworks/as/src/org/apache/flex/html/staticControls/beads/models/ToggleButtonModel.as (with props)
Modified:
flex/asjs/branches/develop/frameworks/as/manifest.xml
flex/asjs/branches/develop/frameworks/as/src/FlexJSUIClasses.as
Modified: flex/asjs/branches/develop/frameworks/as/manifest.xml
URL: http://svn.apache.org/viewvc/flex/asjs/branches/develop/frameworks/as/manifest.xml?rev=1449236&r1=1449235&r2=1449236&view=diff
==============================================================================
--- flex/asjs/branches/develop/frameworks/as/manifest.xml (original)
+++ flex/asjs/branches/develop/frameworks/as/manifest.xml Fri Feb 22 22:05:57 2013
@@ -32,6 +32,7 @@
<component id="TextInput" class="org.apache.flex.html.staticControls.TextInput"/>
<component id="TextArea" class="org.apache.flex.html.staticControls.TextArea"/>
<component id="List" class="org.apache.flex.html.staticControls.List"/>
+ <component id="CheckBox" class="org.apache.flex.html.staticControls.CheckBox"/>
<component id="HTTPService" class="org.apache.flex.net.HTTPService"/>
<component id="LazyCollection" class="org.apache.flex.net.dataConverters.LazyCollection"/>
<component id="JSONInputParser" class="org.apache.flex.net.JSONInputParser"/>
Modified: flex/asjs/branches/develop/frameworks/as/src/FlexJSUIClasses.as
URL: http://svn.apache.org/viewvc/flex/asjs/branches/develop/frameworks/as/src/FlexJSUIClasses.as?rev=1449236&r1=1449235&r2=1449236&view=diff
==============================================================================
--- flex/asjs/branches/develop/frameworks/as/src/FlexJSUIClasses.as (original)
+++ flex/asjs/branches/develop/frameworks/as/src/FlexJSUIClasses.as Fri Feb 22 22:05:57 2013
@@ -33,7 +33,9 @@ internal class FlexJSUIClasses
import org.apache.flex.html.staticControls.beads.TextInputBead; TextInputBead;
import org.apache.flex.html.staticControls.beads.TextInputWithBorderBead; TextInputWithBorderBead;
import org.apache.flex.html.staticControls.beads.TextAreaBead; TextAreaBead;
+ import org.apache.flex.html.staticControls.beads.CheckBoxBead; CheckBoxBead;
import org.apache.flex.html.staticControls.beads.models.TextModel; TextModel;
+ import org.apache.flex.html.staticControls.beads.models.ToggleButtonModel; ToggleButtonModel;
import org.apache.flex.html.staticControls.beads.models.ArraySelectionModel; ArraySelectionModel;
}
Added: flex/asjs/branches/develop/frameworks/as/src/org/apache/flex/core/ICheckBoxBead.as
URL: http://svn.apache.org/viewvc/flex/asjs/branches/develop/frameworks/as/src/org/apache/flex/core/ICheckBoxBead.as?rev=1449236&view=auto
==============================================================================
--- flex/asjs/branches/develop/frameworks/as/src/org/apache/flex/core/ICheckBoxBead.as (added)
+++ flex/asjs/branches/develop/frameworks/as/src/org/apache/flex/core/ICheckBoxBead.as Fri Feb 22 22:05:57 2013
@@ -0,0 +1,26 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// 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.core
+{
+ public interface ICheckBoxBead extends IBead
+ {
+ function get text():String;
+ function set text(value:String):void;
+ }
+}
\ No newline at end of file
Propchange: flex/asjs/branches/develop/frameworks/as/src/org/apache/flex/core/ICheckBoxBead.as
------------------------------------------------------------------------------
svn:eol-style = native
Added: flex/asjs/branches/develop/frameworks/as/src/org/apache/flex/core/IToggleButtonModel.as
URL: http://svn.apache.org/viewvc/flex/asjs/branches/develop/frameworks/as/src/org/apache/flex/core/IToggleButtonModel.as?rev=1449236&view=auto
==============================================================================
--- flex/asjs/branches/develop/frameworks/as/src/org/apache/flex/core/IToggleButtonModel.as (added)
+++ flex/asjs/branches/develop/frameworks/as/src/org/apache/flex/core/IToggleButtonModel.as Fri Feb 22 22:05:57 2013
@@ -0,0 +1,32 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// 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.core
+{
+ public interface IToggleButtonModel extends IBeadModel
+ {
+ function get text():String;
+ function set text(value:String):void;
+
+ function get html():String;
+ function set html(value:String):void;
+
+ function get selected():Boolean;
+ function set selected(value:Boolean):void;
+ }
+}
\ No newline at end of file
Propchange: flex/asjs/branches/develop/frameworks/as/src/org/apache/flex/core/IToggleButtonModel.as
------------------------------------------------------------------------------
svn:eol-style = native
Added: flex/asjs/branches/develop/frameworks/as/src/org/apache/flex/html/staticControls/CheckBox.as
URL: http://svn.apache.org/viewvc/flex/asjs/branches/develop/frameworks/as/src/org/apache/flex/html/staticControls/CheckBox.as?rev=1449236&view=auto
==============================================================================
--- flex/asjs/branches/develop/frameworks/as/src/org/apache/flex/html/staticControls/CheckBox.as (added)
+++ flex/asjs/branches/develop/frameworks/as/src/org/apache/flex/html/staticControls/CheckBox.as Fri Feb 22 22:05:57 2013
@@ -0,0 +1,176 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// 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.staticControls
+{
+ import flash.display.DisplayObject;
+ import flash.display.SimpleButton;
+ import flash.events.Event;
+ import flash.events.MouseEvent;
+
+ import org.apache.flex.core.IBead;
+ import org.apache.flex.core.IBeadModel;
+ import org.apache.flex.core.ICheckBoxBead;
+ import org.apache.flex.core.IToggleButtonModel;
+ import org.apache.flex.core.IInitModel;
+ import org.apache.flex.core.IInitSkin;
+ import org.apache.flex.core.IStrand;
+ import org.apache.flex.core.ValuesManager;
+
+ public class CheckBox extends SimpleButton implements IStrand, IInitSkin, IInitModel
+ {
+ public function CheckBox(upState:DisplayObject=null, overState:DisplayObject=null, downState:DisplayObject=null, hitTestState:DisplayObject=null)
+ {
+ super(upState, overState, downState, hitTestState);
+
+ addEventListener(MouseEvent.CLICK, internalMouseHandler);
+ }
+
+ public function get text():String
+ {
+ return IToggleButtonModel(model).text;
+ }
+ public function set text(value:String):void
+ {
+ IToggleButtonModel(model).text = value;
+ }
+
+ public function get selected():Boolean
+ {
+ return IToggleButtonModel(model).selected;
+ }
+
+ public function set selected(value:Boolean):void
+ {
+ IToggleButtonModel(model).selected = value;
+ }
+
+ public function initModel():void
+ {
+ if (getBeadByType(IToggleButtonModel) == null)
+ addBead(new (ValuesManager.valuesImpl.getValue("IToggleButtonModel")) as IBead);
+ }
+
+ public function initSkin():void
+ {
+ if (getBeadByType(ICheckBoxBead) == null)
+ addBead(new (ValuesManager.valuesImpl.getValue("ICheckBoxBead")) as IBead);
+
+ _width = $width;
+ _height = $height;
+ }
+
+ private var _id:String;
+ public function get id():String
+ {
+ return _id;
+ }
+ public function set id(value:String):void
+ {
+ if (_id != value)
+ {
+ _id = value;
+ dispatchEvent(new Event("idChanged"));
+ }
+ }
+
+ private var _width:Number = 0;
+ override public function get width():Number
+ {
+ return _width;
+ }
+ override public function set width(value:Number):void
+ {
+ if (_width != value)
+ {
+ _width = value;
+ dispatchEvent(new Event("widthChanged"));
+ }
+ }
+ protected function get $width():Number
+ {
+ return super.width;
+ }
+
+ private var _height:Number = 0;
+ override public function get height():Number
+ {
+ return _height;
+ }
+ override public function set height(value:Number):void
+ {
+ if (_height != value)
+ {
+ _height = value;
+ dispatchEvent(new Event("heightChanged"));
+ }
+ }
+ protected function get $height():Number
+ {
+ return super.height;
+ }
+
+ private var _model:IBeadModel;
+ protected function get model():IBeadModel
+ {
+ return _model;
+ }
+
+ private var strand:Vector.<IBead>;
+ public function addBead(bead:IBead):void
+ {
+ if (!strand)
+ strand = new Vector.<IBead>;
+ strand.push(bead);
+ if (bead is IBeadModel)
+ _model = bead as IBeadModel;
+ bead.strand = this;
+ }
+
+ public function getBeadByType(classOrInterface:Class):IBead
+ {
+ for each (var bead:IBead in strand)
+ {
+ if (bead is classOrInterface)
+ return bead;
+ }
+ return null;
+ }
+
+ public function removeBead(value:IBead):IBead
+ {
+ var n:int = strand.length;
+ for (var i:int = 0; i < n; i++)
+ {
+ var bead:IBead = strand[i];
+ if (bead == value)
+ {
+ strand.splice(i, 1);
+ return bead;
+ }
+ }
+ return null;
+ }
+
+ private function internalMouseHandler(event:MouseEvent) : void
+ {
+ selected = !selected;
+ dispatchEvent( new Event(Event.CHANGE) );
+ }
+ }
+}
\ No newline at end of file
Propchange: flex/asjs/branches/develop/frameworks/as/src/org/apache/flex/html/staticControls/CheckBox.as
------------------------------------------------------------------------------
svn:eol-style = native
Added: flex/asjs/branches/develop/frameworks/as/src/org/apache/flex/html/staticControls/beads/CheckBoxBead.as
URL: http://svn.apache.org/viewvc/flex/asjs/branches/develop/frameworks/as/src/org/apache/flex/html/staticControls/beads/CheckBoxBead.as?rev=1449236&view=auto
==============================================================================
--- flex/asjs/branches/develop/frameworks/as/src/org/apache/flex/html/staticControls/beads/CheckBoxBead.as (added)
+++ flex/asjs/branches/develop/frameworks/as/src/org/apache/flex/html/staticControls/beads/CheckBoxBead.as Fri Feb 22 22:05:57 2013
@@ -0,0 +1,214 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// 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.staticControls.beads
+{
+ import flash.display.Shape;
+ import flash.display.SimpleButton;
+ import flash.display.Sprite;
+ import flash.events.Event;
+ import flash.text.TextField;
+ import flash.text.TextFieldAutoSize;
+ import flash.text.TextFieldType;
+
+ import org.apache.flex.core.IBead;
+ import org.apache.flex.core.ICheckBoxBead;
+ import org.apache.flex.core.IStrand;
+ import org.apache.flex.core.IToggleButtonModel;
+
+ public class CheckBoxBead implements IBead, ICheckBoxBead
+ {
+ public function CheckBoxBead()
+ {
+ sprites = [ upSprite = new Sprite(),
+ downSprite = new Sprite(),
+ overSprite = new Sprite(),
+ upAndSelectedSprite = new Sprite(),
+ downAndSelectedSprite = new Sprite(),
+ overAndSelectedSprite = new Sprite() ];
+
+ for each( var s:Sprite in sprites )
+ {
+ var tf:TextField = new TextField();
+ tf.type = TextFieldType.DYNAMIC;
+ tf.autoSize = TextFieldAutoSize.LEFT;
+ tf.name = "textField";
+ var icon:Shape = new Shape();
+ icon.name = "icon";
+ s.addChild(icon);
+ s.addChild(tf);
+ }
+ }
+
+ private var upSprite:Sprite;
+ private var downSprite:Sprite;
+ private var overSprite:Sprite;
+ private var upAndSelectedSprite:Sprite;
+ private var downAndSelectedSprite:Sprite;
+ private var overAndSelectedSprite:Sprite;
+
+ private var sprites:Array;
+
+ private var _toggleButtonModel:IToggleButtonModel;
+
+ public function get toggleButtonModel() : IToggleButtonModel
+ {
+ return _toggleButtonModel;
+ }
+
+ private var _strand:IStrand;
+
+ public function set strand(value:IStrand):void
+ {
+ _strand = value;
+ _toggleButtonModel = value.getBeadByType(IToggleButtonModel) as IToggleButtonModel;
+ _toggleButtonModel.addEventListener("textChange", textChangeHandler);
+ _toggleButtonModel.addEventListener("htmlChange", htmlChangeHandler);
+ _toggleButtonModel.addEventListener("selectedChange", selectedChangeHandler);
+ if (_toggleButtonModel.text !== null)
+ text = _toggleButtonModel.text;
+
+ layoutControl();
+
+ var hitArea:Shape = new Shape();
+ hitArea.graphics.beginFill(0x000000);
+ hitArea.graphics.drawRect(12,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;
+ }
+
+ public function get text():String
+ {
+ var tf:TextField = upSprite.getChildByName('textField') as TextField;
+ return tf.text;
+ }
+
+ public function set text(value:String):void
+ {
+ for each( var s:Sprite in sprites )
+ {
+ var tf:TextField = s.getChildByName('textField') as TextField;
+ tf.text = value;
+ }
+
+ layoutControl();
+ }
+
+ public function get html():String
+ {
+ var tf:TextField = upSprite.getChildByName('textField') as TextField;
+ return tf.htmlText;
+ }
+
+ public function set html(value:String):void
+ {
+ for each(var s:Sprite in sprites)
+ {
+ var tf:TextField = s.getChildByName('textField') as TextField;
+ 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;
+
+ public function get selected():Boolean
+ {
+ return _selected;
+ }
+
+ 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;
+ }
+
+ protected function layoutControl() : void
+ {
+ for each(var s:Sprite in sprites)
+ {
+ var icon:Shape = s.getChildByName("icon") as Shape;
+ var tf:TextField = s.getChildByName("textField") as TextField;
+
+ drawCheckBox(icon);
+
+ var mh:Number = Math.max(icon.height,tf.height);
+
+ icon.x = 0;
+ icon.y = (mh - icon.height)/2;
+
+ tf.x = icon.x + icon.width + 1;
+ tf.y = (mh - tf.height)/2;
+ }
+
+ }
+
+ protected function drawCheckBox(icon:Shape) : void
+ {
+ icon.graphics.clear();
+ icon.graphics.beginFill(0xCCCCCC);
+ icon.graphics.lineStyle(1,0x333333);
+ icon.graphics.drawRect(0,0,10,10);
+ icon.graphics.endFill();
+
+ if( _toggleButtonModel.selected ) {
+ icon.graphics.moveTo(0,0);
+ icon.graphics.lineTo(10,10);
+ icon.graphics.moveTo(10,0);
+ icon.graphics.lineTo(0,10);
+ }
+ }
+ }
+}
\ No newline at end of file
Propchange: flex/asjs/branches/develop/frameworks/as/src/org/apache/flex/html/staticControls/beads/CheckBoxBead.as
------------------------------------------------------------------------------
svn:eol-style = native
Added: flex/asjs/branches/develop/frameworks/as/src/org/apache/flex/html/staticControls/beads/models/ToggleButtonModel.as
URL: http://svn.apache.org/viewvc/flex/asjs/branches/develop/frameworks/as/src/org/apache/flex/html/staticControls/beads/models/ToggleButtonModel.as?rev=1449236&view=auto
==============================================================================
--- flex/asjs/branches/develop/frameworks/as/src/org/apache/flex/html/staticControls/beads/models/ToggleButtonModel.as (added)
+++ flex/asjs/branches/develop/frameworks/as/src/org/apache/flex/html/staticControls/beads/models/ToggleButtonModel.as Fri Feb 22 22:05:57 2013
@@ -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.staticControls.beads.models
+{
+ import flash.events.Event;
+ import flash.events.EventDispatcher;
+
+ import org.apache.flex.core.IBead;
+ import org.apache.flex.core.IToggleButtonModel;
+ import org.apache.flex.core.IStrand;
+
+ public class ToggleButtonModel extends EventDispatcher implements IBead, IToggleButtonModel
+ {
+ public function ToggleButtonModel()
+ {
+ super();
+ }
+
+ private var _strand:IStrand;
+
+ public function set strand(value:IStrand):void
+ {
+ _strand = value;
+ }
+
+ private var _text:String;
+ public function get text():String
+ {
+ return _text;
+ }
+
+ public function set text(value:String):void
+ {
+ if (value != _text)
+ {
+ _text = value;
+ dispatchEvent(new Event("textChange"));
+ }
+ }
+
+ private var _html:String;
+ public function get html():String
+ {
+ return _html;
+ }
+
+ public function set html(value:String):void
+ {
+ if( value != html )
+ {
+ _html = value;
+ dispatchEvent(new Event("htmlChange"));
+ }
+ }
+
+ private var _selected:Boolean;
+
+ public function get selected():Boolean
+ {
+ return _selected;
+ }
+
+ public function set selected(value:Boolean):void
+ {
+ if( value != _selected )
+ {
+ _selected = value;
+ dispatchEvent(new Event("selectedChange"));
+ }
+ }
+ }
+}
\ No newline at end of file
Propchange: flex/asjs/branches/develop/frameworks/as/src/org/apache/flex/html/staticControls/beads/models/ToggleButtonModel.as
------------------------------------------------------------------------------
svn:eol-style = native