Author: max
Date: 2007-08-27 14:08:00 -0700 (Mon, 27 Aug 2007)
New Revision: 6257

Modified:
   openlaszlo/branches/wafflecone/WEB-INF/lps/lfc/kernel/dhtml/LzTextSprite.js
   openlaszlo/branches/wafflecone/WEB-INF/lps/lfc/kernel/swf/LzTextSprite.as
   openlaszlo/branches/wafflecone/WEB-INF/lps/lfc/views/LzText.lzs
Log:
Change 20070827-maxcarlson-r by [EMAIL PROTECTED] on 2007-08-27 13:11:25 PDT
    in /Users/maxcarlson/openlaszlo/wafflecone
    for http://svn.openlaszlo.org/openlaszlo/branches/wafflecone

Summary: Fix text size measurement for font styles with constraints

New Features:

Bugs Fixed: LPP-4571 - Text component not sized correctly when fontsize 
configured via a constraint

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

Documentation:

Release Notes:

Details: LzTextSprite.as - calculate the correct line height for single-line 
text in getTexfieldHeight()

LzTextSprite.js - Recalculate line heights when styles are changed in 
getTexfieldHeight()

LzText.lzs - Add argument to setText() to force it to recompute the height even 
if this.text is the same.  setFontName() and setFontSize() call setText() with 
force == true to ensure resizing happens.

Tests: Testcase in LPP-4571 passes in swf and dhtml, 
http://localhost:8080/wafflecone/test/lztest/lztest-textheight.lzx?debug=true 
runs as before in swf and dhtml.



Modified: 
openlaszlo/branches/wafflecone/WEB-INF/lps/lfc/kernel/dhtml/LzTextSprite.js
===================================================================
--- openlaszlo/branches/wafflecone/WEB-INF/lps/lfc/kernel/dhtml/LzTextSprite.js 
2007-08-27 20:38:05 UTC (rev 6256)
+++ openlaszlo/branches/wafflecone/WEB-INF/lps/lfc/kernel/dhtml/LzTextSprite.js 
2007-08-27 21:08:00 UTC (rev 6257)
@@ -186,7 +186,7 @@
 }
 
 LzTextSprite.prototype.getTextfieldHeight = function () {
-    if (this.fieldHeight != null) return this.fieldHeight
+    if (this._styledirty != true && this.fieldHeight != null) return 
this.fieldHeight
     if (this.text == null || this.text == '') {
         this.fieldHeight = this.getTextSize('Yq_gy').height;
 //       Debug.debug('getTextfieldHeight: 0');

Modified: 
openlaszlo/branches/wafflecone/WEB-INF/lps/lfc/kernel/swf/LzTextSprite.as
===================================================================
--- openlaszlo/branches/wafflecone/WEB-INF/lps/lfc/kernel/swf/LzTextSprite.as   
2007-08-27 20:38:05 UTC (rev 6256)
+++ openlaszlo/branches/wafflecone/WEB-INF/lps/lfc/kernel/swf/LzTextSprite.as   
2007-08-27 21:08:00 UTC (rev 6257)
@@ -283,7 +283,19 @@
 }
 
 LzTextSprite.prototype.getTextfieldHeight = function ( ){
-    return this.__LZtextclip._height
+    if (this.multiline) {
+        return this.__LZtextclip._height
+    } else {
+        var textclip = this.__LZtextclip;
+        textclip.autoSize = true;
+        textclip.htmlText = this.format + "__ypgSAMPLE__" + this.closeformat;
+
+        var h = textclip._height;
+
+        textclip.htmlText = this.format + this.text + this.closeformat;
+        textclip.autoSize = false;
+    }
+    return h;
 }
 
 

Modified: openlaszlo/branches/wafflecone/WEB-INF/lps/lfc/views/LzText.lzs
===================================================================
--- openlaszlo/branches/wafflecone/WEB-INF/lps/lfc/views/LzText.lzs     
2007-08-27 20:38:05 UTC (rev 6256)
+++ openlaszlo/branches/wafflecone/WEB-INF/lps/lfc/views/LzText.lzs     
2007-08-27 21:08:00 UTC (rev 6257)
@@ -214,7 +214,7 @@
         if (this.multiline) {
             args.width = this.parent.width;
         } else {
-            // if there's text content, measure it's width
+            // if there's text content, measure its width
             if (this.text != null && this.text != '' && this.text.length > 0) {
                 args.width = this.getTextWidth();
             } else {
@@ -656,10 +656,10 @@
   * setText sets the text of the field to display
   * @param String t: the string to which to set the text
   */
-function setText ( t ){
+function setText ( t, force ){
     // force to a string
     t += '';
-    if (t == this.text) return;
+    if (force != true && t == this.text) return;
     if (this.visible) this.sprite.setVisible(this.visible);
     this.sprite.setText(t);
     this.text =  t;
@@ -794,7 +794,7 @@
     this.sprite.setFontName(fname);
     this.fontname = fname;
     // force recompute of height if needed
-    this.setText( this.getText());
+    this.setText( this.getText(), true);
 }
 
 /**
@@ -804,7 +804,7 @@
     this.sprite.setFontSize(fsize);
     this.fontsize = fsize;
     // force recompute of height if needed
-    this.setText( this.getText() );
+    this.setText( this.getText(), true);
 }
 
 /**


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

Reply via email to