You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by ah...@apache.org on 2014/11/11 23:08:33 UTC

[17/28] git commit: [flex-asjs] [refs/heads/develop] - add ImageAndTextButton and MultiLineLabel

add ImageAndTextButton and MultiLineLabel


Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/3f1111c5
Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/3f1111c5
Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/3f1111c5

Branch: refs/heads/develop
Commit: 3f1111c597f1ef3ac9487866ac9a595bcbfab35c
Parents: 73452ea
Author: Alex Harui <ah...@apache.org>
Authored: Mon Nov 10 09:12:13 2014 -0800
Committer: Alex Harui <ah...@apache.org>
Committed: Tue Nov 11 14:07:59 2014 -0800

----------------------------------------------------------------------
 .../as/projects/FlexJSUI/basic-manifest.xml     |   2 +
 frameworks/as/projects/FlexJSUI/defaults.css    |  14 ++-
 .../as/projects/FlexJSUI/src/FlexJSUIClasses.as |   3 +
 .../org/apache/flex/html/ImageAndTextButton.as  |  70 +++++++++++++
 .../src/org/apache/flex/html/MultilineLabel.as  |  60 +++++++++++
 .../apache/flex/html/beads/CSSTextButtonView.as |  11 +-
 .../flex/html/beads/CSSTextToggleButtonView.as  | 103 +++++++++++++++++++
 .../flex/html/beads/ImageAndTextButtonView.as   |  20 +---
 .../flex/html/beads/models/ImageAndTextModel.as |  77 ++++++++++++++
 9 files changed, 341 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/3f1111c5/frameworks/as/projects/FlexJSUI/basic-manifest.xml
----------------------------------------------------------------------
diff --git a/frameworks/as/projects/FlexJSUI/basic-manifest.xml b/frameworks/as/projects/FlexJSUI/basic-manifest.xml
index b5d4405..069eaef 100644
--- a/frameworks/as/projects/FlexJSUI/basic-manifest.xml
+++ b/frameworks/as/projects/FlexJSUI/basic-manifest.xml
@@ -34,6 +34,8 @@
     <component id="DropDownListList" class="org.apache.flex.html.supportClasses.DropDownListList"/>
     <component id="Image" class="org.apache.flex.html.Image"/>
     <component id="Label" class="org.apache.flex.html.Label"/>
+    <component id="MultilineLabel" class="org.apache.flex.html.MultilineLabel"/>
+    <component id="ImageAndTextButton" class="org.apache.flex.html.ImageAndTextButton"/>
     <component id="TextButton" class="org.apache.flex.html.TextButton"/>
     <component id="ToggleTextButton" class="org.apache.flex.html.ToggleTextButton"/>
     <component id="TextInput" class="org.apache.flex.html.TextInput"/>

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/3f1111c5/frameworks/as/projects/FlexJSUI/defaults.css
----------------------------------------------------------------------
diff --git a/frameworks/as/projects/FlexJSUI/defaults.css b/frameworks/as/projects/FlexJSUI/defaults.css
index b616d0d..5dc967f 100644
--- a/frameworks/as/projects/FlexJSUI/defaults.css
+++ b/frameworks/as/projects/FlexJSUI/defaults.css
@@ -268,6 +268,12 @@ ImageButton
     IBeadView: ClassReference("org.apache.flex.html.beads.ImageButtonView");
 }
 
+ImageAndTextButton
+{
+    IBeadModel: ClassReference("org.apache.flex.html.beads.models.ImageAndTextModel");
+    IBeadView: ClassReference("org.apache.flex.html.beads.ImageAndTextButtonView");
+}
+
 Label
 {
     IBeadModel: ClassReference("org.apache.flex.html.beads.models.TextModel");
@@ -281,6 +287,12 @@ List
     iBorderModel: ClassReference('org.apache.flex.html.beads.models.SingleLineBorderModel');
 }
 
+MultilineLabel
+{
+    IBeadModel: ClassReference("org.apache.flex.html.beads.models.TextModel");
+    IBeadView: ClassReference("org.apache.flex.html.beads.MultilineTextFieldView");
+}
+
 NumericStepper
 {
     IBeadModel: ClassReference("org.apache.flex.html.beads.models.RangeModel");
@@ -403,7 +415,7 @@ ToggleTextButton
 
 h5|TextButton
 {
-    IBeadView: ClassReference("org.apache.flex.html.beads.CSSTextButtonView");
+    IBeadView: ClassReference("org.apache.flex.html.beads.CSSTextToggleButtonView");
 }
 
 h5|TextInput

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/3f1111c5/frameworks/as/projects/FlexJSUI/src/FlexJSUIClasses.as
----------------------------------------------------------------------
diff --git a/frameworks/as/projects/FlexJSUI/src/FlexJSUIClasses.as b/frameworks/as/projects/FlexJSUI/src/FlexJSUIClasses.as
index f6f998e..85139d8 100644
--- a/frameworks/as/projects/FlexJSUI/src/FlexJSUIClasses.as
+++ b/frameworks/as/projects/FlexJSUI/src/FlexJSUIClasses.as
@@ -57,9 +57,11 @@ internal class FlexJSUIClasses
     import org.apache.flex.html.beads.ControlBarMeasurementBead; ControlBarMeasurementBead;
     import org.apache.flex.html.beads.CSSButtonView; CSSButtonView;
 	import org.apache.flex.html.beads.CSSTextButtonView; CSSTextButtonView;
+    import org.apache.flex.html.beads.CSSTextToggleButtonView; CSSTextToggleButtonView;
 	import org.apache.flex.html.beads.DropDownListView; DropDownListView;
 	import org.apache.flex.html.beads.CloseButtonView; CloseButtonView;
     import org.apache.flex.html.beads.ImageButtonView; ImageButtonView;
+    import org.apache.flex.html.beads.ImageAndTextButtonView; ImageAndTextButtonView;
 	import org.apache.flex.html.beads.ImageView; ImageView;
     import org.apache.flex.html.beads.ListView; ListView;
     import org.apache.flex.html.beads.NumericStepperView; NumericStepperView;
@@ -85,6 +87,7 @@ internal class FlexJSUIClasses
     import org.apache.flex.html.beads.models.ArraySelectionModel; ArraySelectionModel;
     import org.apache.flex.html.beads.models.ComboBoxModel; ComboBoxModel;
 	import org.apache.flex.html.beads.models.ImageModel; ImageModel;
+    import org.apache.flex.html.beads.models.ImageAndTextModel; ImageAndTextModel;
 	import org.apache.flex.html.beads.models.PanelModel; PanelModel;
     import org.apache.flex.html.beads.models.SingleLineBorderModel; SingleLineBorderModel;
 	import org.apache.flex.html.beads.models.TextModel; TextModel;

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/3f1111c5/frameworks/as/projects/FlexJSUI/src/org/apache/flex/html/ImageAndTextButton.as
----------------------------------------------------------------------
diff --git a/frameworks/as/projects/FlexJSUI/src/org/apache/flex/html/ImageAndTextButton.as b/frameworks/as/projects/FlexJSUI/src/org/apache/flex/html/ImageAndTextButton.as
new file mode 100644
index 0000000..c2d5999
--- /dev/null
+++ b/frameworks/as/projects/FlexJSUI/src/org/apache/flex/html/ImageAndTextButton.as
@@ -0,0 +1,70 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  Licensed to the Apache Software Foundation (ASF) under one or more
+//  contributor license agreements.  See the NOTICE file distributed with
+//  this work for additional information regarding copyright ownership.
+//  The ASF licenses this file to You under the Apache License, Version 2.0
+//  (the "License"); you may not use this file except in compliance with
+//  the License.  You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.html
+{
+	import org.apache.flex.events.Event;
+    import org.apache.flex.html.beads.models.ImageAndTextModel;
+	
+    /**
+     *  The ImageTextButton class implements a basic button that
+     *  displays and image and text.
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 10.2
+     *  @playerversion AIR 2.6
+     *  @productversion FlexJS 0.0
+     */    
+	public class ImageAndTextButton extends TextButton
+	{
+        /**
+         *  Constructor.
+         *  
+         *  @langversion 3.0
+         *  @playerversion Flash 10.2
+         *  @playerversion AIR 2.6
+         *  @productversion FlexJS 0.0
+         */
+		public function ImageAndTextButton()
+		{
+			super();
+		}
+		
+        /**
+         *  The URL of an icon to use in the button
+         *  
+         *  @langversion 3.0
+         *  @playerversion Flash 10.2
+         *  @playerversion AIR 2.6
+         *  @productversion FlexJS 0.0
+         */
+        public function get image():String
+        {
+            return ImageAndTextModel(model).image;
+        }
+        
+        /**
+         *  @private
+         */
+        public function set image(value:String):void
+        {
+            ImageAndTextModel(model).image = value;
+        }
+
+	}
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/3f1111c5/frameworks/as/projects/FlexJSUI/src/org/apache/flex/html/MultilineLabel.as
----------------------------------------------------------------------
diff --git a/frameworks/as/projects/FlexJSUI/src/org/apache/flex/html/MultilineLabel.as b/frameworks/as/projects/FlexJSUI/src/org/apache/flex/html/MultilineLabel.as
new file mode 100644
index 0000000..909bf5e
--- /dev/null
+++ b/frameworks/as/projects/FlexJSUI/src/org/apache/flex/html/MultilineLabel.as
@@ -0,0 +1,60 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  Licensed to the Apache Software Foundation (ASF) under one or more
+//  contributor license agreements.  See the NOTICE file distributed with
+//  this work for additional information regarding copyright ownership.
+//  The ASF licenses this file to You under the Apache License, Version 2.0
+//  (the "License"); you may not use this file except in compliance with
+//  the License.  You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.html
+{
+	import org.apache.flex.core.ITextModel;
+	import org.apache.flex.core.UIBase;
+	import org.apache.flex.core.ValuesManager;
+	import org.apache.flex.events.Event;
+	import org.apache.flex.events.IEventDispatcher;
+	
+	/*
+	 *  Label probably should extend TextField directly,
+	 *  but the player's APIs for TextLine do not allow
+	 *  direct instantiation, and we might want to allow
+	 *  Labels to be declared and have their actual
+	 *  view be swapped out.
+	 */
+
+    /**
+     *  The Label class implements the basic control for labeling
+     *  other controls.  
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 10.2
+     *  @playerversion AIR 2.6
+     *  @productversion FlexJS 0.0
+     */    
+    public class MultilineLabel extends Label
+	{
+        /**
+         *  Constructor.
+         *  
+         *  @langversion 3.0
+         *  @playerversion Flash 10.2
+         *  @playerversion AIR 2.6
+         *  @productversion FlexJS 0.0
+         */
+		public function MultilineLabel()
+		{
+			super();
+		}
+						
+	}
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/3f1111c5/frameworks/as/projects/FlexJSUI/src/org/apache/flex/html/beads/CSSTextButtonView.as
----------------------------------------------------------------------
diff --git a/frameworks/as/projects/FlexJSUI/src/org/apache/flex/html/beads/CSSTextButtonView.as b/frameworks/as/projects/FlexJSUI/src/org/apache/flex/html/beads/CSSTextButtonView.as
index 4772e7b..ff97004 100644
--- a/frameworks/as/projects/FlexJSUI/src/org/apache/flex/html/beads/CSSTextButtonView.as
+++ b/frameworks/as/projects/FlexJSUI/src/org/apache/flex/html/beads/CSSTextButtonView.as
@@ -115,14 +115,19 @@ package org.apache.flex.html.beads
 			if (textModel.html !== null)
 				html = textModel.html;
 
-            setupSkin(overSprite, overTextField, "hover");
-			setupSkin(downSprite, downTextField, "active");
-			setupSkin(upSprite, upTextField);
+            setupSkins();
 			
 			IEventDispatcher(_strand).addEventListener("widthChanged",sizeChangeHandler);
 			IEventDispatcher(_strand).addEventListener("heightChanged",sizeChangeHandler);
 		}
 	
+        protected function setupSkins():void
+        {
+            setupSkin(overSprite, overTextField, "hover");
+            setupSkin(downSprite, downTextField, "active");
+            setupSkin(upSprite, upTextField);            
+        }
+        
 		private function setupSkin(sprite:Sprite, textField:TextField, state:String = null):void
 		{
 			var sw:uint = DisplayObject(_strand).width;

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/3f1111c5/frameworks/as/projects/FlexJSUI/src/org/apache/flex/html/beads/CSSTextToggleButtonView.as
----------------------------------------------------------------------
diff --git a/frameworks/as/projects/FlexJSUI/src/org/apache/flex/html/beads/CSSTextToggleButtonView.as b/frameworks/as/projects/FlexJSUI/src/org/apache/flex/html/beads/CSSTextToggleButtonView.as
new file mode 100644
index 0000000..a6b3fac
--- /dev/null
+++ b/frameworks/as/projects/FlexJSUI/src/org/apache/flex/html/beads/CSSTextToggleButtonView.as
@@ -0,0 +1,103 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  Licensed to the Apache Software Foundation (ASF) under one or more
+//  contributor license agreements.  See the NOTICE file distributed with
+//  this work for additional information regarding copyright ownership.
+//  The ASF licenses this file to You under the Apache License, Version 2.0
+//  (the "License"); you may not use this file except in compliance with
+//  the License.  You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.html.beads
+{
+	
+    import org.apache.flex.core.BeadViewBase;
+	import org.apache.flex.core.IBeadView;
+	import org.apache.flex.core.IStrand;
+    import org.apache.flex.core.IStyleableObject;
+	import org.apache.flex.core.IToggleButtonModel;
+	import org.apache.flex.events.Event;
+	import org.apache.flex.events.IEventDispatcher;
+
+    /**
+     *  The CSSTextToggleButtonView class is the default view for
+     *  the org.apache.flex.html.TextToggleButton class.
+     *  It allows the look of the button to be expressed
+     *  in CSS via the background-image style and displays
+     *  a text label.  This view does not support right-to-left
+     *  text.
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 10.2
+     *  @playerversion AIR 2.6
+     *  @productversion FlexJS 0.0
+     */
+	public class CSSTextToggleButtonView extends CSSTextButtonView
+	{
+        /**
+         *  The suffix appended to the className when selected.
+         *  
+         *  @langversion 3.0
+         *  @playerversion Flash 10.2
+         *  @playerversion AIR 2.6
+         *  @productversion FlexJS 0.0
+         */
+        public static const SELECTED:String = "_Selected";
+        
+        /**
+         *  Constructor.
+         *  
+         *  @langversion 3.0
+         *  @playerversion Flash 10.2
+         *  @playerversion AIR 2.6
+         *  @productversion FlexJS 0.0
+         */
+		public function CSSTextToggleButtonView()
+		{
+		}
+		
+		private var toggleButtonModel:IToggleButtonModel;
+		
+        /**
+         *  @copy org.apache.flex.core.IBead#strand
+         *  
+         *  @langversion 3.0
+         *  @playerversion Flash 10.2
+         *  @playerversion AIR 2.6
+         *  @productversion FlexJS 0.0
+         */
+		override public function set strand(value:IStrand):void
+		{
+            super.strand = value;
+            
+			toggleButtonModel = value.getBeadByType(IToggleButtonModel) as IToggleButtonModel;
+            toggleButtonModel.addEventListener("selectedChanged", selectedChangeHandler);
+		}
+	
+		private function selectedChangeHandler(event:org.apache.flex.events.Event):void
+		{
+            var className:String = IStyleableObject(_strand).className;
+            if (toggleButtonModel.selected)
+            {
+                if (className.indexOf(SELECTED) == className.length - SELECTED.length)
+                    IStyleableObject(_strand).className = className.substring(0, className.length - SELECTED.length);
+                setupSkins();
+            }
+            else
+            {
+                if (className.indexOf(SELECTED) == -1)
+                    IStyleableObject(_strand).className += SELECTED;
+                setupSkins();                
+            }
+		}
+		
+	}
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/3f1111c5/frameworks/as/projects/FlexJSUI/src/org/apache/flex/html/beads/ImageAndTextButtonView.as
----------------------------------------------------------------------
diff --git a/frameworks/as/projects/FlexJSUI/src/org/apache/flex/html/beads/ImageAndTextButtonView.as b/frameworks/as/projects/FlexJSUI/src/org/apache/flex/html/beads/ImageAndTextButtonView.as
index 988b293..64dd7a5 100644
--- a/frameworks/as/projects/FlexJSUI/src/org/apache/flex/html/beads/ImageAndTextButtonView.as
+++ b/frameworks/as/projects/FlexJSUI/src/org/apache/flex/html/beads/ImageAndTextButtonView.as
@@ -33,8 +33,8 @@ package org.apache.flex.html.beads
 	import org.apache.flex.core.IBeadView;
 	import org.apache.flex.core.IStrand;
     import org.apache.flex.core.IStrandWithModel;
-    import org.apache.flex.core.ITextModel;
 	import org.apache.flex.core.ValuesManager;
+    import org.apache.flex.html.beads.models.ImageAndTextModel;
 	
 	/**
 	 *  The ImageButtonView class provides an image-only view
@@ -87,7 +87,7 @@ package org.apache.flex.html.beads
 		override public function set strand(value:IStrand):void
 		{
 			super.strand = value;
-            textModel = IStrandWithModel(value).model as ITextModel;
+            textModel = IStrandWithModel(value).model as ImageAndTextModel;
             textModel.addEventListener("textChange", textChangeHandler);
             textModel.addEventListener("htmlChange", htmlChangeHandler);
 			
@@ -114,10 +114,8 @@ package org.apache.flex.html.beads
 		private var overSprite:Sprite;
 		private var shape:Shape;
         
-        private var textModel:ITextModel;
+        private var textModel:ImageAndTextModel;
 		
-        private var _image:String;
-        
         /**
          *  The URL of an icon to use in the button
          *  
@@ -128,17 +126,9 @@ package org.apache.flex.html.beads
          */
         public function get image():String
         {
-            return _image;
-        }
-        
-        /**
-         *  @private
-         */
-        public function set image(value:String):void
-        {
-            _image = value;
+            return textModel.image;
         }
-        
+                
 		/**
 		 * @private
 		 */

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/3f1111c5/frameworks/as/projects/FlexJSUI/src/org/apache/flex/html/beads/models/ImageAndTextModel.as
----------------------------------------------------------------------
diff --git a/frameworks/as/projects/FlexJSUI/src/org/apache/flex/html/beads/models/ImageAndTextModel.as b/frameworks/as/projects/FlexJSUI/src/org/apache/flex/html/beads/models/ImageAndTextModel.as
new file mode 100644
index 0000000..01dd3e9
--- /dev/null
+++ b/frameworks/as/projects/FlexJSUI/src/org/apache/flex/html/beads/models/ImageAndTextModel.as
@@ -0,0 +1,77 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  Licensed to the Apache Software Foundation (ASF) under one or more
+//  contributor license agreements.  See the NOTICE file distributed with
+//  this work for additional information regarding copyright ownership.
+//  The ASF licenses this file to You under the Apache License, Version 2.0
+//  (the "License"); you may not use this file except in compliance with
+//  the License.  You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.html.beads.models
+{	
+	import org.apache.flex.core.IBead;
+	import org.apache.flex.core.IStrand;
+	import org.apache.flex.core.ITextModel;
+	import org.apache.flex.events.Event;
+	import org.apache.flex.events.EventDispatcher;
+	import org.apache.flex.events.IEventDispatcher;
+		
+    /**
+     *  The ImageAndTextModel class is associates and image
+     *  with some text. 
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 10.2
+     *  @playerversion AIR 2.6
+     *  @productversion FlexJS 0.0
+     */
+	public class ImageAndTextModel extends TextModel
+	{
+        /**
+         *  Constructor.
+         *  
+         *  @langversion 3.0
+         *  @playerversion Flash 10.2
+         *  @playerversion AIR 2.6
+         *  @productversion FlexJS 0.0
+         */
+		public function ImageAndTextModel()
+		{
+		}
+		
+
+        private var _image:String;
+        
+        /**
+         *  The URL of an icon to use in the button
+         *  
+         *  @langversion 3.0
+         *  @playerversion Flash 10.2
+         *  @playerversion AIR 2.6
+         *  @productversion FlexJS 0.0
+         */
+        public function get image():String
+        {
+            return _image;
+        }
+        
+        /**
+         *  @private
+         */
+        public function set image(value:String):void
+        {
+            _image = value;
+            dispatchEvent(new Event("imageChange"));
+        }
+        
+	}
+}