Author: hqm
Date: 2007-06-22 12:59:03 -0700 (Fri, 22 Jun 2007)
New Revision: 5504

Modified:
   openlaszlo/branches/legals/WEB-INF/lps/lfc/kernel/swf/LzTextSprite.as
   openlaszlo/branches/legals/WEB-INF/lps/lfc/views/LzInputText.lzs
   openlaszlo/branches/legals/WEB-INF/lps/lfc/views/LzText.lzs
   openlaszlo/branches/legals/test/lztest/lztest-textheight.lzx
Log:
Change 20070622-hqm-2 by [EMAIL PROTECTED] on 2007-06-22 15:05:33 EDT
    in /cygdrive/c/users/hqm/openlaszlo/legals3
    for http://svn.openlaszlo.org/openlaszlo/branches/legals

Summary: fix/changes to lztext width calculation

New Features:

multiline text defaults to parent's width

empty text defaults to zero width

Bugs Fixed: LPP-2958

Technical Reviewer: max (pending)
QA Reviewer: (pending)
Doc Reviewer: (pending)

Documentation:

Release Notes:

Details:




Tests:

test/lztest/lztest-textheight.lzx
test/lztest/lztest-lpp-2958.lzx
amazon
lzpix
examples/components/style_example.lzx




Modified: openlaszlo/branches/legals/WEB-INF/lps/lfc/kernel/swf/LzTextSprite.as
===================================================================
--- openlaszlo/branches/legals/WEB-INF/lps/lfc/kernel/swf/LzTextSprite.as       
2007-06-22 18:57:48 UTC (rev 5503)
+++ openlaszlo/branches/legals/WEB-INF/lps/lfc/kernel/swf/LzTextSprite.as       
2007-06-22 19:59:03 UTC (rev 5504)
@@ -161,8 +161,6 @@
 LzTextSprite.prototype.maxhscroll = 0;
 
 
-//DEFAULT_WIDTH: Width to use for text field if none is specified
-LzTextSprite.prototype.DEFAULT_WIDTH = 100;
 // [todo: 2004-3-29 hqm] lines seem to get the ends clipped off if you use the 
TextField.textWidth
 // from Flash, so I am adding a constant. Am I missing something here? 
 LzTextSprite.prototype.PAD_TEXTWIDTH = 4;
@@ -255,7 +253,7 @@
     var mw = mc.wordWrap;
     mc.multiline = false;
     mc.wordWrap = false;
-    var twidth = mc.textWidth + this.PAD_TEXTWIDTH;
+    var twidth = (mc.textWidth == 0) ? 0 : mc.textWidth + this.PAD_TEXTWIDTH;
     mc.multiline = ml;
     mc.wordWrap = mw;
     return twidth;

Modified: openlaszlo/branches/legals/WEB-INF/lps/lfc/views/LzInputText.lzs
===================================================================
--- openlaszlo/branches/legals/WEB-INF/lps/lfc/views/LzInputText.lzs    
2007-06-22 18:57:48 UTC (rev 5503)
+++ openlaszlo/branches/legals/WEB-INF/lps/lfc/views/LzInputText.lzs    
2007-06-22 19:59:03 UTC (rev 5504)
@@ -128,10 +128,14 @@
   */
 static var tagname = 'inputtext';
 
-// +++ Hey, are we still saying that input text is non- HTML ? 
-// If so then we need to override a number of methods in LzText which
+/** 
+  * Width to use for text field if none is specified
+  * @access private
+  */
+function getDefaultWidth () {
+    return 100;
+}
 
-
 defaultattrs.selectable = true;
 defaultattrs.enabled = true;
 

Modified: openlaszlo/branches/legals/WEB-INF/lps/lfc/views/LzText.lzs
===================================================================
--- openlaszlo/branches/legals/WEB-INF/lps/lfc/views/LzText.lzs 2007-06-22 
18:57:48 UTC (rev 5503)
+++ openlaszlo/branches/legals/WEB-INF/lps/lfc/views/LzText.lzs 2007-06-22 
19:59:03 UTC (rev 5504)
@@ -102,20 +102,11 @@
 /** 
   * Width to use for text field if none is specified
   * @access private
-  * @keywords final
   */
-static var DEFAULT_WIDTH = 100;
+function getDefaultWidth () {
+    return 0;
+}
 
-/**
-  * @access private
-  * @keywords final
-  * @todo 2004-3-29 hqm lines seem to get the ends clipped off if you use the 
TextField.textWidth
-  * from Flash, so I am adding a constant. Am I missing something here? 
-  */
-static var PAD_TEXTWIDTH = 4;
-
-static var DEFAULT_SIZE = 8;
-
 defaultattrs.pixellock = true;
 
 /**
@@ -217,16 +208,21 @@
     //    if no width was supplied and there's no constraint, measure the text 
width:
     //        if empty text content was supplied, use DEFAULT_WIDTH
     if (args.width == null) {
-        // if there's text content, measure it's width
-        if (this.text != null && this.text != '' && this.text.length > 0) {
-            args.width = this.getTextWidth();
+        if (this.multiline) {
+            args.width = this.parent.width;
         } else {
-            // Empty string would result in a zero width view, which confuses
-            // developers, so use something reasonable instead.
-            args.width = this.DEFAULT_WIDTH;
+            // if there's text content, measure it's width
+            if (this.text != null && this.text != '' && this.text.length > 0) {
+                args.width = this.getTextWidth();
+            } else {
+                // Input text will have a nonzero default width, so it behaves
+                // like HTML input field.
+                args.width = this.getDefaultWidth();
+            }
         }
+    } else {
+        this.setResize(false);
     }
-    if (args.width == null) args.width = 100;
 
     // To compute our height:
     // + If height is supplied, use it.

Modified: openlaszlo/branches/legals/test/lztest/lztest-textheight.lzx
===================================================================
--- openlaszlo/branches/legals/test/lztest/lztest-textheight.lzx        
2007-06-22 18:57:48 UTC (rev 5503)
+++ openlaszlo/branches/legals/test/lztest/lztest-textheight.lzx        
2007-06-22 19:59:03 UTC (rev 5504)
@@ -16,7 +16,7 @@
     <text resize="true" id="t1">A</text>
     <text fontsize="28" id="t2">B</text>
     <text fontsize="36" id="t3" >C</text>
-    <text multiline="true" id="t4" oninit="setText('oneline\ntwolines');"/>
+    <text multiline="true" width="100" id="t4" 
oninit="setText('oneline\ntwolines');"/>
     <text text="Username:" id="t5"/>
     <text multiline="true" id="t6">Oneline<br/>Two lines<br/>Three</text>
     <text multiline="true" id="t7" width="350">The text that appears in the 
combobox may be different from the
@@ -119,14 +119,14 @@
     LzTestManager.assertEquals(29, t3.getAttribute("width"), "text3 width");
     LzTestManager.assertEquals(100, t4.getAttribute("width"), "multiline4 text 
width");
     LzTestManager.assertEquals(67, t5.width, "text5 width");
-    LzTestManager.assertEquals(57, t6.getAttribute("width"), "multiline6 
text.width");
-    LzTestManager.assertEquals(57, t6.width, "multiline6 text width");
+    LzTestManager.assertEquals(t6.parent.width, t6.getAttribute("width"), 
"multiline6 text.width");
+    LzTestManager.assertEquals(t6.parent.width, t6.width, "multiline6 text 
width");
     LzTestManager.assertEquals(350, t7.getAttribute("width"), "multiline7 
text.width");
     LzTestManager.assertEquals(350, t7.width, "multiline7 text width");
     LzTestManager.assertEquals(100, t8.getAttribute("width"), "text8 width");
     LzTestManager.assertEquals(100, t8.width, "text8 width");
-    LzTestManager.assertEquals(88, t9.getAttribute("width"), "text9 width");
-    LzTestManager.assertEquals(88, t9.width, "text9 width");
+    LzTestManager.assertEquals(100, t9.getAttribute("width"), "text9 width");
+    LzTestManager.assertEquals(100, t9.width, "text9 width");
     LzTestManager.assertEquals(88, t10.getAttribute("width"), "text10 width");
     LzTestManager.assertEquals(88, t10.width, "text10 width");
     LzTestManager.assertEquals(350, t11.getAttribute("width"), "multiline7 
text.width");
@@ -141,14 +141,14 @@
     LzTestManager.assertEquals(200, it3.width, "inputtext3.width");
     LzTestManager.assertEquals(26, it4.getAttribute("width"), "inputtext4 
width");
     LzTestManager.assertEquals(26, it4.width, "inputtext4.width");
-    LzTestManager.assertEquals(17, it5.getAttribute("width"), "inputtext5 
width");
-    LzTestManager.assertEquals(17, it5.width, "inputtext5.width");
+    LzTestManager.assertEquals(it5.parent.width, it5.getAttribute("width"), 
"inputtext5 width");
+    LzTestManager.assertEquals(it5.parent.width, it5.width, 
"inputtext5.width");
     LzTestManager.assertEquals(26, it6.getAttribute("width"), "inputtext6 
width");
     LzTestManager.assertEquals(26, it6.width, "inputtext6.width");
 
     LzTestManager.assertEquals(350, it7.getAttribute("width"), "multiline7 
inputtext.width");
     LzTestManager.assertEquals(350, it7.width, "multiline7 inputtext width");
-    LzTestManager.assertEquals(100, tempty.width, "tempty.width");
+    LzTestManager.assertEquals(0, tempty.width, "tempty.width");
 
 
     LzTestManager.assertEquals(110, thepost.getAttribute("width"), "thepost 
width");


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

Reply via email to