Author: max
Date: 2007-08-17 17:13:09 -0700 (Fri, 17 Aug 2007)
New Revision: 6136

Modified:
   openlaszlo/branches/wafflecone/WEB-INF/lps/lfc/views/LaszloView.lzs
   openlaszlo/branches/wafflecone/WEB-INF/lps/lfc/views/LzInputText.lzs
   openlaszlo/branches/wafflecone/WEB-INF/lps/lfc/views/LzText.lzs
Log:
Change 20070817-maxcarlson-L by [EMAIL PROTECTED] on 2007-08-17 13:21:33 PDT
    in /Users/maxcarlson/openlaszlo/wafflecone
    for http://svn.openlaszlo.org/openlaszlo/branches/wafflecone

Summary: Unify capability warnings across runtimes

New Features:

Bugs Fixed: LPP-4200 - Missing warnings in "LzBrowser.js" (DHTML)

Technical Reviewer: promanik
QA Reviewer: ben
Doc Reviewer: (pending)

Documentation:

Release Notes:

Details: LzInputText.lzs - Use this.capabilities instead of 
this.sprite.capabilities and __warnCapability() instead of homespun warnings.

LzText.lzs - Only set advanced text methods and setters in construct() if 
capabilities.advancedtext is true.  Use this.capabilities instead of 
this.sprite.capabilities and __warnCapability() instead of homespun warnings. 

LaszloView.lzs - Expose LzSprite.prototype.capabilities as view.capabilities.  
Add shared __warnCapability() method.  Use this.capabilities instead of this.
sprite.capabilities and __warnCapability() instead of homespun warnings.
    

Tests: 'ant lztest' and smoketest pass.



Modified: openlaszlo/branches/wafflecone/WEB-INF/lps/lfc/views/LaszloView.lzs
===================================================================
--- openlaszlo/branches/wafflecone/WEB-INF/lps/lfc/views/LaszloView.lzs 
2007-08-18 00:08:10 UTC (rev 6135)
+++ openlaszlo/branches/wafflecone/WEB-INF/lps/lfc/views/LaszloView.lzs 
2007-08-18 00:13:09 UTC (rev 6136)
@@ -190,6 +190,8 @@
 DeclareEvent(prototype, 'ondblclick' );
 var DOUBLE_CLICK_TIME = 500;
 
+var capabilities = LzSprite.prototype.capabilities;
+
 /**
   * Base level constructor for views. See <method
   * classname="LzNode">construct</method> for more on this.
@@ -1258,8 +1260,10 @@
   * @param Number v: The new value for the opacity
   */
 function setOpacity ( v ){
-    if (this.sprite.capabilities.opacity) {
+    if (this.capabilities.opacity) {
         this.sprite.setOpacity(v);
+    } else if ($debug) {
+        this.__warnCapability('view.setOpacity()'); 
     }
     this.opacity = v;
     if (this.onopacity.ready) this.onopacity.sendEvent( v );
@@ -1282,7 +1286,7 @@
         this._x = v;
         this.x = v;
         if ( this.__LZhasoffset ){
-            if (this.sprite.capabilities.rotation) {
+            if (this.capabilities.rotation) {
                 v -= ( this.xoffset * this.__LZrcos  -
                     this.yoffset * this.__LZrsin );
             } else {
@@ -1309,7 +1313,7 @@
         this._y = v;
         this.y = v;
         if ( this.__LZhasoffset ){
-            if (this.sprite.capabilities.rotation) {
+            if (this.capabilities.rotation) {
                 v -= ( this.xoffset * this.__LZrsin  +
                     this.yoffset * this.__LZrcos );
             } else {
@@ -1331,8 +1335,10 @@
   * @param Number v: The new value for <attribute>rotation</attribute>.
   */
 function setRotation ( v ){
-    if (this.sprite.capabilities.rotation) {
+    if (this.capabilities.rotation) {
         this.sprite.setRotation(v)
+    } else if ($debug) {
+        this.__warnCapability('view.setRotation()'); 
     }
     this.rotation = v;
     var rrad = Math.PI /180 * this.rotation;
@@ -1550,8 +1556,10 @@
   * @runtimes as2
   */
 function setColorTransform ( o ){
-    if (this.sprite.capabilities.colortransform) {
+    if (this.capabilities.colortransform) {
         this.sprite.setColorTransform(o);
+    } else if ($debug) {
+        this.__warnCapability('view.setColorTransform()'); 
     }
 }
 
@@ -1572,8 +1580,10 @@
   * @runtimes as2
   */
 function getColorTransform (){
-    if (this.sprite.capabilities.colortransform) {
+    if (this.capabilities.colortransform) {
         return this.sprite.getColorTransform();
+    } else if ($debug) {
+        this.__warnCapability('view.getColorTransform()'); 
     }
 }
 
@@ -2259,8 +2269,10 @@
   * @param Integer v: A number from 0 to 100 representing a volume level
   */
 function setVolume (v) {
-    if (this.sprite.capabilities.audio) {
+    if (this.capabilities.audio) {
         this.sprite.setVolume(v);
+    } else if ($debug) {
+        this.__warnCapability('view.setVolume()'); 
     }
 }
 
@@ -2269,8 +2281,10 @@
   * @return Integer: A number from 0 to 100 representing a volume level
   */
 function getVolume () {
-    if (this.sprite.capabilities.audio) {
+    if (this.capabilities.audio) {
         return this.sprite.getVolume();
+    } else if ($debug) {
+        this.__warnCapability('view.getVolume()'); 
     }
 }
 
@@ -2279,8 +2293,10 @@
   * @param Integer p: A number from -100 to 100 representing a pan level
   */
 function setPan (p) {
-    if (this.sprite.capabilities.audio) {
+    if (this.capabilities.audio) {
         this.sprite.setPan(p);
+    } else if ($debug) {
+        this.__warnCapability('view.setPan()'); 
     }
 }
 
@@ -2289,8 +2305,10 @@
   * @return Integer: A number from -100 to 100 representing a pan level
   */
 function getPan () {
-    if (this.sprite.capabilities.audio) {
+    if (this.capabilities.audio) {
         return this.sprite.getPan();
+    } else if ($debug) {
+        this.__warnCapability('view.getPan()'); 
     }
 }
 
@@ -2400,8 +2418,10 @@
   * @param Boolean accessible
   */
 function setAccessible (accessible) {
-    if (this.sprite.capabilities.accessibility) {
+    if (this.capabilities.accessibility) {
         this.sprite.setAccessible(accessible);
+    } else if ($debug) {
+        this.__warnCapability('view.setAccessible()'); 
     }
 }
 
@@ -2410,8 +2430,10 @@
   * @param Boolean s: If true, activate the current view and all of its 
children
   */
 function setAAActive ( s, mc ){
-    if (this.sprite.capabilities.accessibility) {
+    if (this.capabilities.accessibility) {
         this.sprite.setAAActive(s, mc);
+    } else if ($debug) {
+        this.__warnCapability('view.setAAActive()'); 
     }
 }
 
@@ -2421,8 +2443,10 @@
   * @param string s: Sets the accessibility name for this view
   */
 function setAAName ( s, mc ){
-    if (this.sprite.capabilities.accessibility) {
+    if (this.capabilities.accessibility) {
         this.sprite.setAAName(s, mc);
+    } else if ($debug) {
+        this.__warnCapability('view.setAAName()'); 
     }
 }
 
@@ -2431,8 +2455,10 @@
   * @param string s: Sets the accessibility name for this view
   */
 function setAADescription ( s, mc ){
-    if (this.sprite.capabilities.accessibility) {
+    if (this.capabilities.accessibility) {
         this.sprite.setAADescription(s, mc);
+    } else if ($debug) {
+        this.__warnCapability('view.setAADescription()'); 
     }
 }
 
@@ -2441,8 +2467,10 @@
   * @param number s: The tab order index for this view.  Must be a unique 
number.
   */
 function setAATabIndex ( s, mc ){
-    if (this.sprite.capabilities.accessibility) {
+    if (this.capabilities.accessibility) {
         this.sprite.setAATabIndex(s, mc);
+    } else if ($debug) {
+        this.__warnCapability('view.setAATabIndex()'); 
     }
 }
 
@@ -2452,8 +2480,10 @@
   * If false, it is active to the screen reader.
   */
 function setAASilent ( s, mc ){
-    if (this.sprite.capabilities.accessibility) {
+    if (this.capabilities.accessibility) {
         this.sprite.setAASilent(s, mc);
+    } else if ($debug) {
+        this.__warnCapability('view.setAASilent()'); 
     }
 }
 
@@ -2542,5 +2572,9 @@
     return this.sprite.getContextMenu();
 }
 
+function __warnCapability(msg) {
+    Debug.warn('The %s runtime does not support %s', lzr, msg); 
+}
+
 } // End of LzView
 

Modified: openlaszlo/branches/wafflecone/WEB-INF/lps/lfc/views/LzInputText.lzs
===================================================================
--- openlaszlo/branches/wafflecone/WEB-INF/lps/lfc/views/LzInputText.lzs        
2007-08-18 00:08:10 UTC (rev 6135)
+++ openlaszlo/branches/wafflecone/WEB-INF/lps/lfc/views/LzInputText.lzs        
2007-08-18 00:13:09 UTC (rev 6136)
@@ -233,10 +233,10 @@
   * Set the html flag on this text view
   */
 function setHTML (htmlp) {
-    if (this.sprite.capabilities['htmlinputtext']) {
+    if (this.capabilities['htmlinputtext']) {
         this.sprite.setHTML(htmlp);
     } else if ($debug) {
-        Debug.warn('This runtime does not support inputtext.setHTML()');
+        this.__warnCapability('inputtext.setHTML()'); 
     }
 }
 

Modified: openlaszlo/branches/wafflecone/WEB-INF/lps/lfc/views/LzText.lzs
===================================================================
--- openlaszlo/branches/wafflecone/WEB-INF/lps/lfc/views/LzText.lzs     
2007-08-18 00:08:10 UTC (rev 6135)
+++ openlaszlo/branches/wafflecone/WEB-INF/lps/lfc/views/LzText.lzs     
2007-08-18 00:13:09 UTC (rev 6136)
@@ -250,30 +250,49 @@
     }
 
 
-    if ('antiAliasType' in args && args.antiAliasType != null) {
-        this.setAntiAliasType(args.antiAliasType);
-    } else {
-        this.setAntiAliasType("normal"); 
-    }
+    if (this.capabilities.advancedfonts) {
+        if ('antiAliasType' in args && args.antiAliasType != null) {
+            this.setAntiAliasType(args.antiAliasType);
+        } else {
+            this.setAntiAliasType("normal"); 
+        }
 
-    if ('gridFit' in args && args.gridFit != null) {
-        this.setGridFit(args.gridFit);
-    } else {
-        this.setGridFit("subpixel");
-    }
+        if ('gridFit' in args && args.gridFit != null) {
+            this.setGridFit(args.gridFit);
+        } else {
+            this.setGridFit("subpixel");
+        }
 
-    if ('sharpness' in args && args.sharpness != null) {
-        this.setSharpness(args.sharpness);
-    } else {
-        this.setSharpness(0);
-    }
+        if ('sharpness' in args && args.sharpness != null) {
+            this.setSharpness(args.sharpness);
+        } else {
+            this.setSharpness(0);
+        }
 
-    if ('thickness' in args && args.thickness != null) {
-        this.setThickness(args.thickness);
-    } else {
-        this.setThickness(0);
+        if ('thickness' in args && args.thickness != null) {
+            this.setThickness(args.thickness);
+        } else {
+            this.setThickness(0);
+        }
+        if (! LzText.prototype.setters.antiAliasType) {
+            /**
+            * @lzxtype string
+            * @modifiers virtual
+            */
+            // no var decl since this is a virtual field
+            LzText.prototype.setters.antiAliasType = "setAntiAliasType";
+            LzText.prototype.defaultattrs.antiAliasType = "normal";
+
+            LzText.prototype.setters.gridFit = "setGridFit";
+            LzText.prototype.defaultattrs.gridfit = "subpixel";
+
+            LzText.prototype.setters.sharpness = "setSharpness";
+            LzText.prototype.defaultattrs.sharpness = 0;
+
+            LzText.prototype.setters.thickness = "setThickness";
+            LzText.prototype.defaultattrs.thickness = 0;
+        }
     }
-
 }
 
 /**
@@ -343,24 +362,9 @@
 defaultattrs.clip = true;
 
 
-/**
-  * @lzxtype string
-  * @modifiers virtual
-  */
-// no var decl since this is a virtual field
-setters.antiAliasType = "setAntiAliasType";
-defaultattrs.antiAliasType = "normal";
 
-setters.gridFit = "setGridFit";
-defaultattrs.gridfit = "subpixel";
 
-setters.sharpness = "setSharpness";
-defaultattrs.sharpness = 0;
 
-setters.thickness = "setThickness";
-defaultattrs.thickness = 0;
-
-
 /**
   * setResize set behavior of text field width when new text is added.
   * LzText only (cannot be used with LzInputText).
@@ -854,13 +858,15 @@
  * @param aliasType "normal" or "advanced"
  */
 function setAntiAliasType( aliasType ){
-    if (this.sprite.capabilities.advancedfonts) {    
+    if (this.capabilities.advancedfonts) {    
         if ((aliasType == "normal") || (aliasType == "advanced")) {
             this.antiAliasType = aliasType; 
             this.sprite.setAntiAliasType(aliasType);
         } else if ($debug) {
             Debug.warn("antiAliasType invalid, must be 'normal' or 'advanced', 
but you said '" + aliasType + "'");
         }        
+    } else if ($debug) {
+        this.__warnCapability('text.setAntiAliasType()'); 
     }
 }
 
@@ -868,8 +874,10 @@
  * Gets the kind of antialiasing set on this text object
  */ 
 function getAntiAliasType() {
-    if (this.sprite.capabilities.advancedfonts) {    
+    if (this.capabilities.advancedfonts) {    
         return this.antiAliasType;
+    } else if ($debug) {
+        this.__warnCapability('text.getAntiAliasType()'); 
     }
 }
 
@@ -879,13 +887,15 @@
  * @param gridFit "none", "pixel", or "subpixel"
  */
 function setGridFit( gridFit ){
-    if (this.sprite.capabilities.advancedfonts) {    
+    if (this.capabilities.advancedfonts) {    
         if ((gridFit == "none") || (gridFit == "pixel") || (gridFit == 
"subpixel")) {
             this.gridFit = gridFit; 
             this.sprite.setGridFit(gridFit);
         } else if ($debug) {
             Debug.warn("gridFit invalid, must be 'none', 'pixel', or 
'subpixel' but you said '" + gridFit + "'");
         }
+    } else if ($debug) {
+        this.__warnCapability('text.setGridFit()'); 
     }
 }
 
@@ -893,8 +903,10 @@
  * Gets the kind of grid fitting set on this text object
  */ 
 function getGridFit() {
-    if (this.sprite.capabilities.advancedfonts) {
+    if (this.capabilities.advancedfonts) {
         return this.gridFit; 
+    } else if ($debug) {
+        this.__warnCapability('text.getGridFit()'); 
     }
 }
 
@@ -905,13 +917,15 @@
  * @param sharpness -400 to 400
  */
 function setSharpness( sharpness ){
-    if (this.sprite.capabilities.advancedfonts) {
+    if (this.capabilities.advancedfonts) {
         if  ((sharpness >= -400) && (sharpness <= 400)) {
             this.sharpness = sharpness; 
             this.sprite.setSharpness(sharpness);
         } else if ($debug) {
             Debug.warn("sharpness out of range, must be -400 to 400");
         }        
+    } else if ($debug) {
+        this.__warnCapability('text.setSharpness()'); 
     }
 }
 
@@ -919,8 +933,10 @@
  * Gets the sharpness rendering property of this text object
  */ 
 function getSharpness() {
-    if (this.sprite.capabilities.advancedfonts) {    
+    if (this.capabilities.advancedfonts) {    
         return this.sharpness; 
+    } else if ($debug) {
+        this.__warnCapability('text.getSharpness()'); 
     }
 }
 
@@ -931,13 +947,15 @@
  * @param thickness -200 to 200
  */
 function setThickness( thickness ){
-    if (this.sprite.capabilities.advancedfonts) {
+    if (this.capabilities.advancedfonts) {
         if  ((thickness >= -200) && (thickness <= 200)) {
             this.thickness = thickness;
             this.sprite.setThickness(thickness); 
         } else if ($debug) {
             Debug.warn("thickness out of range, must be -200 to 200");
         }
+    } else if ($debug) {
+        this.__warnCapability('text.setThickness()'); 
     }
 }
 
@@ -945,8 +963,10 @@
  * Gets the thickness rendering property of this text object
  */ 
 function getThickness() {
-    if (this.sprite.capabilities.advancedfonts) {    
+    if (this.capabilities.advancedfonts) {    
         return this.thickness;
+    } else if ($debug) {
+        this.__warnCapability('text.getThickness()'); 
     }
 }
 


_______________________________________________
Laszlo-checkins mailing list
[email protected]
http://www.openlaszlo.org/mailman/listinfo/laszlo-checkins

Reply via email to