flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aha...@apache.org
Subject [02/10] git commit: [flex-asjs] [refs/heads/dual] - JS App needed width/height properties
Date Wed, 01 Mar 2017 21:09:50 GMT
JS App needed width/height properties


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

Branch: refs/heads/dual
Commit: b7ce5424ca871c18b3606095bf8b25e9543587e4
Parents: 6be6864
Author: Alex Harui <aharui@apache.org>
Authored: Wed Feb 22 23:47:43 2017 -0800
Committer: Alex Harui <aharui@apache.org>
Committed: Wed Feb 22 23:47:43 2017 -0800

----------------------------------------------------------------------
 .../org/apache/flex/core/ApplicationBase.as     | 242 +++++++++++++++++++
 1 file changed, 242 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/b7ce5424/frameworks/projects/Basic/src/main/flex/org/apache/flex/core/ApplicationBase.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/Basic/src/main/flex/org/apache/flex/core/ApplicationBase.as
b/frameworks/projects/Basic/src/main/flex/org/apache/flex/core/ApplicationBase.as
index 60111ef..8a54c91 100644
--- a/frameworks/projects/Basic/src/main/flex/org/apache/flex/core/ApplicationBase.as
+++ b/frameworks/projects/Basic/src/main/flex/org/apache/flex/core/ApplicationBase.as
@@ -105,6 +105,248 @@ package org.apache.flex.core
             return _info;
         }
         
+        private var _width:Number;
+        
+        [Bindable("widthChanged")]
+        [PercentProxy("percentWidth")]
+        /**
+         * @flexjsignorecoercion String
+         */
+        public function get width():Number
+        {
+            var pixels:Number;
+            var strpixels:String = element.style.width as String;
+            if (strpixels !== null && strpixels.indexOf('%') != -1)
+                pixels = NaN;
+            else
+                pixels = parseFloat(strpixels);
+            if (isNaN(pixels)) {
+                pixels = element.offsetWidth;
+                if (pixels === 0 && element.scrollWidth !== 0) {
+                    // invisible child elements cause offsetWidth to be 0.
+                    pixels = element.scrollWidth;
+                }
+            }
+            return pixels;
+        }
+        
+        /**
+         *  @private
+         */
+        public function set width(value:Number):void
+        {
+            if (explicitWidth != value)
+            {
+                explicitWidth = value;
+            }
+            
+            setWidth(value);
+        }
+        
+        private var _height:Number;
+        
+        [Bindable("heightChanged")]
+        [PercentProxy("percentHeight")]
+        /**
+         * @flexjsignorecoercion String
+         */
+        public function get height():Number
+        {
+            var pixels:Number;
+            var strpixels:String = element.style.height as String;
+            if (strpixels !== null && strpixels.indexOf('%') != -1)
+                pixels = NaN;
+            else
+                pixels = parseFloat(strpixels);
+            if (isNaN(pixels)) {
+                pixels = element.offsetHeight;
+                if (pixels === 0 && element.scrollHeight !== 0) {
+                    // invisible child elements cause offsetHeight to be 0.
+                    pixels = element.scrollHeight;
+                }
+            }
+            return pixels;
+        }
+        
+        /**
+         *  @private
+         */
+        public function set height(value:Number):void
+        {
+            if (explicitHeight != value)
+            {
+                explicitHeight = value;
+            }
+            
+            setHeight(value);
+        }
+        
+        /**
+         *  @copy org.apache.flex.core.ILayoutChild#setHeight
+         *  
+         *  @langversion 3.0
+         *  @playerversion Flash 10.2
+         *  @playerversion AIR 2.6
+         *  @productversion FlexJS 0.0
+         */
+        public function setHeight(value:Number, noEvent:Boolean = false):void
+        {
+            if (_height != value)
+            {
+                _height = value;
+                this.element.style.height = value.toString() + 'px';        
+                if (!noEvent)
+                    dispatchEvent(new Event("heightChanged"));
+            }            
+        }
+        
+        /**
+         *  @copy org.apache.flex.core.ILayoutChild#setWidth
+         *  
+         *  @langversion 3.0
+         *  @playerversion Flash 10.2
+         *  @playerversion AIR 2.6
+         *  @productversion FlexJS 0.0
+         */
+        public function setWidth(value:Number, noEvent:Boolean = false):void
+        {
+            if (_width != value)
+            {
+                _width = value;
+                this.element.style.width = value.toString() + 'px';        
+                if (!noEvent)
+                    dispatchEvent(new Event("widthChanged"));
+            }
+        }
+        
+        private var _explicitWidth:Number;
+        
+        /**
+         *  The explicitly set width (as opposed to measured width
+         *  or percentage width).
+         *  
+         *  @langversion 3.0
+         *  @playerversion Flash 10.2
+         *  @playerversion AIR 2.6
+         *  @productversion FlexJS 0.0
+         */
+        public function get explicitWidth():Number
+        {
+            return _explicitWidth;
+        }
+        
+        /**
+         *  @private
+         */
+        public function set explicitWidth(value:Number):void
+        {
+            if (_explicitWidth == value)
+                return;
+            
+            // width can be pixel or percent not both
+            if (!isNaN(value))
+                _percentWidth = NaN;
+            
+            _explicitWidth = value;
+            
+            dispatchEvent(new Event("explicitWidthChanged"));
+        }
+        
+        private var _explicitHeight:Number;
+        
+        /**
+         *  The explicitly set width (as opposed to measured width
+         *  or percentage width).
+         *  
+         *  @langversion 3.0
+         *  @playerversion Flash 10.2
+         *  @playerversion AIR 2.6
+         *  @productversion FlexJS 0.0
+         */
+        public function get explicitHeight():Number
+        {
+            return _explicitHeight;
+        }
+        
+        /**
+         *  @private
+         */
+        public function set explicitHeight(value:Number):void
+        {
+            if (_explicitHeight == value)
+                return;
+            
+            // height can be pixel or percent not both
+            if (!isNaN(value))
+                _percentHeight = NaN;
+            
+            _explicitHeight = value;
+            
+            dispatchEvent(new Event("explicitHeightChanged"));
+        }
+        
+        private var _percentWidth:Number;
+        
+        /**
+         *  The requested percentage width this component
+         *  should have in the parent container.  Note that
+         *  the actual percentage may be different if the 
+         *  total is more than 100% or if there are other
+         *  components with explicitly set widths.
+         *  
+         *  @langversion 3.0
+         *  @playerversion Flash 10.2
+         *  @playerversion AIR 2.6
+         *  @productversion FlexJS 0.0
+         */
+        public function get percentWidth():Number
+        {
+            return _percentWidth;
+        }
+        
+        /**
+         *  @private
+         */
+        public function set percentWidth(value:Number):void
+        {
+            this._percentWidth = value;
+            this.element.style.width = value.toString() + '%';
+            if (!isNaN(value))
+                this._explicitWidth = NaN;
+            dispatchEvent(new Event("percentWidthChanged"));
+        }
+        
+        private var _percentHeight:Number;
+        
+        /**
+         *  The requested percentage height this component
+         *  should have in the parent container.  Note that
+         *  the actual percentage may be different if the 
+         *  total is more than 100% or if there are other
+         *  components with explicitly set heights.
+         *  
+         *  @langversion 3.0
+         *  @playerversion Flash 10.2
+         *  @playerversion AIR 2.6
+         *  @productversion FlexJS 0.0
+         */
+        public function get percentHeight():Number
+        {
+            return _percentHeight;
+        }
+        
+        /**
+         *  @private
+         */
+        public function set percentHeight(value:Number):void
+        {
+            this._percentHeight = value;
+            this.element.style.height = value.toString() + '%';
+            if (!isNaN(value))
+                this._explicitHeight = NaN;
+            dispatchEvent(new Event("percentHeightChanged"));
+        }
+
 
     }
 }


Mime
View raw message