[Laszlo-checkins] r12753 - in openlaszlo/trunk: WEB-INF/lps/lfc/debugger WEB-INF/lps/lfc/kernel/dhtml WEB-INF/lps/lfc/kernel/swf WEB-INF/lps/lfc/kernel/swf9 WEB-INF/lps/lfc/views lps/components/base lps/components/debugger lps/components/incubator lps/components/incubator/test

ptw@openlaszlo.org ptw at openlaszlo.org
Thu Feb 5 05:21:48 PST 2009


Author: ptw
Date: 2009-02-05 05:20:26 -0800 (Thu, 05 Feb 2009)
New Revision: 12753

Modified:
   openlaszlo/trunk/WEB-INF/lps/lfc/debugger/LzDebug.lzs
   openlaszlo/trunk/WEB-INF/lps/lfc/kernel/dhtml/LzInputTextSprite.js
   openlaszlo/trunk/WEB-INF/lps/lfc/kernel/dhtml/LzTextSprite.js
   openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf/LzTextSprite.as
   openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf9/LzTextSprite.as
   openlaszlo/trunk/WEB-INF/lps/lfc/views/LzText.lzs
   openlaszlo/trunk/lps/components/base/swatchview.lzx
   openlaszlo/trunk/lps/components/debugger/newcontent.lzx
   openlaszlo/trunk/lps/components/incubator/scrolledittext.lzx
   openlaszlo/trunk/lps/components/incubator/test/scrolledittext-test.lzx
Log:
Change 20090204-ptw-R by ptw at dueling-banjos.home on 2009-02-04 07:40:38 EST
    in /Users/ptw/OpenLaszlo/trunk-4
    for http://svn.openlaszlo.org/openlaszlo/trunk

Summary: Tweak new scroll API's to not trigger Max's assertion

Bugs Fixed: LPP-6580  scrolledittext doesn't work in 4.1 (partial)

Technical Reviewer: hminsky (pending)
QA Reviewer: max (Message-ID: <498A6C83.20709 at laszlosystems.com>)

Details:

    LzTextSprite.as*: Keep scroll values up to date when set.  Correct
    pixelToLineNo math.

    LzTextSprite.js, LzInputTextSprite.js: Implement new kernel
    scrolling API.

    LzDebug: Fix uninitialized variable.

    LzText: Add Max's assertion, correct initial values,
    initialization, add bounds checks and warnings for incorrect
    scroll values.  Remove redundant maxscroll update.  Correct signs
    for x/yscroll updates.

    newcontent: Fix math so we don't try to scroll to invalid places

    swatchview: Brain-oh noticed in passing.  Can't supecede
    capabilities before calling super constructor (which initializes
    capabilities).


Tests:
    debugger, smokecheck, amazon



Modified: openlaszlo/trunk/WEB-INF/lps/lfc/debugger/LzDebug.lzs
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/lfc/debugger/LzDebug.lzs	2009-02-05 12:40:31 UTC (rev 12752)
+++ openlaszlo/trunk/WEB-INF/lps/lfc/debugger/LzDebug.lzs	2009-02-05 13:20:26 UTC (rev 12753)
@@ -1108,7 +1108,7 @@
    *
    * @access private
    */
-  var inspectContext;
+  var inspectContext = null;
 
   /**
    * Body of inspect: Create an LZMessage of the object and its

Modified: openlaszlo/trunk/WEB-INF/lps/lfc/kernel/dhtml/LzInputTextSprite.js
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/lfc/kernel/dhtml/LzInputTextSprite.js	2009-02-05 12:40:31 UTC (rev 12752)
+++ openlaszlo/trunk/WEB-INF/lps/lfc/kernel/dhtml/LzInputTextSprite.js	2009-02-05 13:20:26 UTC (rev 12753)
@@ -97,6 +97,7 @@
         this.____hpadding = 0;
     }
 
+    this.scrolldiv = this.__LzInputDiv;
     //Debug.write(this.__LzInputDiv.style);
     this.__setTextEvents(true);
 }
@@ -290,6 +291,7 @@
     this.__createInputText(t);
     this.__LzInputDiv.value = t;
     this.fieldHeight = null;
+    this.__updatefieldsize();
 }
 
 LzInputTextSprite.prototype.__setTextEvents = function(c) {
@@ -899,14 +901,6 @@
     }    
 }
 
-LzInputTextSprite.prototype.setYScroll = function (n){
-  this.__LzInputDiv.scrollTop = (- n);
-}
-
-LzInputTextSprite.prototype.setXScroll = function (n){
-  this.__LzInputDiv.scrollLeft = (- n);
-}
-
 LzInputTextSprite.prototype.setWidth = function (w) {
     if (w == null || w < 0 || isNaN(w) || this.width == w) return;
     // call LzSprite.setWidth();
@@ -915,6 +909,7 @@
         this.__LZclickdiv.style.width = nw;
         this.__LZinputclickdiv.style.width = nw;
     }   
+    this.__updatefieldsize();
 }
 
 LzInputTextSprite.prototype.setHeight = function (h) {
@@ -932,6 +927,7 @@
             }
         }
     }   
+    this.__updatefieldsize();
 }   
 
 // Must match LzSprite implementation

Modified: openlaszlo/trunk/WEB-INF/lps/lfc/kernel/dhtml/LzTextSprite.js
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/lfc/kernel/dhtml/LzTextSprite.js	2009-02-05 12:40:31 UTC (rev 12752)
+++ openlaszlo/trunk/WEB-INF/lps/lfc/kernel/dhtml/LzTextSprite.js	2009-02-05 13:20:26 UTC (rev 12753)
@@ -16,7 +16,7 @@
 
     this.__LZdiv = document.createElement('div');
     this.__LZdiv.className = 'lzdiv';
-    this.__LZtextdiv = document.createElement('div');
+    this.scrolldiv = this.__LZtextdiv = document.createElement('div');
     this.__LZtextdiv.className = 'lzdiv';
     this.__LZdiv.appendChild(this.__LZtextdiv);  
     if (this.quirks.emulate_flash_font_metrics) {
@@ -81,6 +81,7 @@
         this._fontSize = fsize;
         this.__LZdiv.style.fontSize = fsize;
         this._styledirty = true;
+        this.__updatelineheight();
     }    
 }
 
@@ -105,12 +106,14 @@
         this._fontWeight = fweight;
         this.__LZdiv.style.fontWeight = fweight;
         this._styledirty = true;
+        this.__updatelineheight();
     }
 
     if (fstyle != this._fontStyle) {
         this._fontStyle = fstyle;
         this.__LZdiv.style.fontStyle = fstyle;
         this._styledirty = true;
+        this.__updatelineheight();
     }
 }
 
@@ -119,11 +122,60 @@
         this._fontFamily = fname;
         this.__LZdiv.style.fontFamily = fname;
         this._styledirty = true;
+        this.__updatelineheight();
     }
 }
 
 LzTextSprite.prototype.setTextColor = LzSprite.prototype.setColor;
 
+LzTextSprite.prototype.scrollTop;
+LzTextSprite.prototype.scrollHeight;
+LzTextSprite.prototype.scrollLeft;
+LzTextSprite.prototype.scrollWidth;
+LzTextSprite.prototype.lineHeight;
+
+LzTextSprite.prototype.__updatefieldsize = function ( ){
+  var lzv = this.owner;
+  var scrolldiv = this.scrolldiv;
+
+  if (this._styledirty) {
+    this.__updatelineheight();
+  }
+  var scrollHeight = scrolldiv.scrollHeight;
+  if (this.scrollHeight !== scrollHeight) {
+    this.scrollHeight = scrollHeight;
+    lzv.scrollevent('scrollHeight', scrollHeight);
+  }
+  var scrollTop = scrolldiv.scrollTop;
+  if (this.scrollTop !== scrollTop) {
+    this.scrollTop = scrollTop;
+    lzv.scrollevent('scrollTop', scrollTop);
+  }
+  var scrollWidth = scrolldiv.scrollWidth;
+  if (this.scrollWidth !== scrollWidth) {
+    this.scrollWidth = scrollWidth;
+    lzv.scrollevent('scrollWidth', scrollWidth);
+  }
+  var scrollLeft = scrolldiv.scrollLeft;
+  if (this.scrollLeft !== scrollLeft) {
+    this.scrollLeft = scrollLeft;
+    lzv.scrollevent('scrollLeft', scrollLeft);
+  }
+}
+
+LzTextSprite.prototype.lineHeight;
+
+LzTextSprite.prototype.__updatelineheight = function ( ){
+  var lzv = this.owner;
+  var scrolldiv = this.scrolldiv;
+  var lineHeight = this.getTextHeight();
+  if (this.lineHeight !== lineHeight) {
+    this.lineHeight = lineHeight;
+    lzv.scrollevent('lineHeight', lineHeight);
+  }
+}
+
+
 LzTextSprite.prototype.setText = function(t, force) {
     if (force != true && this.text == t) return;
     //Debug.write('LzTextSprite.setText', t);
@@ -147,6 +199,7 @@
     }
     this.__LZtextdiv.innerHTML = t;
     this.fieldHeight = null;
+    this.__updatefieldsize();
 }
 
 LzTextSprite.prototype.setMultiline = function(m) {
@@ -439,11 +492,11 @@
 }
 
 LzTextSprite.prototype.setYScroll = function (n){
-  this.__LZtextdiv.scrollTop = (- n);
+  this.scrolldiv.scrollTop = this.scrollTop = (- n);
 }
 
 LzTextSprite.prototype.setXScroll = function (n){
-  this.__LZtextdiv.scrollLeft = (- n);
+  this.scrolldiv.scrollLeft = this.scrollLeft = (- n);
 }
 
 LzTextSprite.prototype.__setWidth = LzSprite.prototype.setWidth;
@@ -458,6 +511,7 @@
     var hp = this.CSSDimension(this.height >= this.__hpadding ? this.height - this.__hpadding : 0);
     this.__LZtextdiv.style.clip = 'rect(0px ' + wp + ' ' + hp + ' 0px)';
     this.__setWidth(w);
+    this.__updatefieldsize();
     this._styledirty = true;
 }
 
@@ -469,6 +523,7 @@
     this.__LZtextdiv.style.height = hp;
     this.__LZtextdiv.style.clip = 'rect(0px ' + wp + ' ' + hp + ' 0px)';
     this.__setHeight(h);
+    this.__updatefieldsize();
     if (this.multiline) this._styledirty = true;
 }
 

Modified: openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf/LzTextSprite.as
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf/LzTextSprite.as	2009-02-05 12:40:31 UTC (rev 12752)
+++ openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf/LzTextSprite.as	2009-02-05 13:20:26 UTC (rev 12753)
@@ -375,7 +375,7 @@
   * @access private
   */
 LzTextSprite.prototype.setScroll = function ( h ){
-    this.__LZtextclip.scroll = h;
+    this.__LZtextclip.scroll = this.scroll = h;
 }
 
 /**
@@ -418,7 +418,7 @@
 }
 
 LzTextSprite.prototype.pixelToLineNo = function (n:Number):Number {
-  return Math.ceil(n / this.lineheight) + 1;
+  return Math.floor((n / this.lineheight) + 1);
 }
 
 /**
@@ -444,7 +444,7 @@
 
     // Entire flash text field covers the visible textview height
     if ((rh + this.yscroll) >= this.height) {
-        this.__LZtextclip.scroll = 0;
+        this.__LZtextclip.scroll = this.scroll = 1;
         this.__LZtextclip._y = Math.min(0, this.yscroll);
     } else {
         // The flash text field would have to be scrolled up beyond it's bottom, so
@@ -460,7 +460,7 @@
         var frac = Math.round(excess - (nlines * lh));
         //Debug.write("fraction="+fraction);
         // lines are 1-based
-        this.__LZtextclip.scroll = nlines + 1;
+        this.__LZtextclip.scroll = this.scroll = nlines + 1;
         // need to figure out where to put the fraction (add or subtract??)
         this.__LZtextclip._y = - Math.floor((dy + frac));
     }
@@ -594,9 +594,8 @@
       if (h != this.height) this.setHeight(mc._height);
     }
 
-    if (this.multiline && this.scroll == 0 ) {
-        var scrolldel = new LzDelegate(this, "__LZforceScrollAttrs");
-        lz.Idle.callOnIdle(scrolldel);
+    if (this.multiline) {
+      this.__LZforceScrollAttrs();
     }
 
     // Fix for lpp-5449 (reset the selection if the new text is not
@@ -862,8 +861,19 @@
 /**
   * @access private
   */
+LzTextSprite.prototype.__LZupdateScrollAttrs = function ( ignore ) {
+  this.__LZtextclip.onScroller();
+}
+
+/**
+  * @access private
+  */
 LzTextSprite.prototype.__LZforceScrollAttrs = function ( ignore ) {
-    this.__LZtextclip.onScroller();
+  this.__LZupdateScrollAttrs();
+  // The scroll attributes don't update right away, so we have to
+  // wait...
+  var scrolldel = new LzDelegate(this, "__LZupdateScrollAttrs");
+  lz.Idle.callOnIdle(scrolldel);
 }
 
 /**

Modified: openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf9/LzTextSprite.as
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf9/LzTextSprite.as	2009-02-05 12:40:31 UTC (rev 12752)
+++ openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf9/LzTextSprite.as	2009-02-05 13:20:26 UTC (rev 12753)
@@ -487,7 +487,7 @@
 
 
 function setHScroll(s:Number) {
-    this.textfield.scrollH = s;
+    this.textfield.scrollH = this.hscroll = s;
 }
 
 function setAntiAliasType( aliasType:String ):void {
@@ -547,7 +547,7 @@
 }
 
 function setScroll ( h:Number ) {
-    this.textfield.scrollV = h;
+    this.textfield.scrollV = this.scroll = h;
 }
 function getScroll() {
     return this.textfield.scrollV;
@@ -566,15 +566,15 @@
 }
 
 function pixelToLineNo (n:Number):Number {
-  return Math.ceil(n / lineheight) + 1;
+  return Math.floor((n / lineheight) + 1);
 }
 
 function setYScroll ( n ){
-  this.textfield.scrollV = this.pixelToLineNo((- n));
+  this.textfield.scrollV = this.scroll = this.pixelToLineNo((- n));
 }
 
 function setXScroll ( n ){
-  this.textfield.scrollH = (- n);
+  this.textfield.scrollH = this.hscroll = (- n);
 }
 
 function setWordWrap ( wrap ){

Modified: openlaszlo/trunk/WEB-INF/lps/lfc/views/LzText.lzs
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/lfc/views/LzText.lzs	2009-02-05 12:40:31 UTC (rev 12752)
+++ openlaszlo/trunk/WEB-INF/lps/lfc/views/LzText.lzs	2009-02-05 13:20:26 UTC (rev 12753)
@@ -9,6 +9,9 @@
  * @subtopic Text
  */
 
+{
+#pragma "warnUndefinedReferences=true"
+
 /**
  * <p>This class is used for non-editable text fields (as opposed to
  * <sgmltag class="element" role="LzInputText">&lt;inputtext&gt;</sgmltag>).  A text field can be initalized
@@ -243,6 +246,7 @@
     tsprite.setWidth(val);
     super.$lzc$set_width(val);
     // maxhscroll depends on width
+    if (this.scrollwidth < this.width) { this.scrollwidth = this.width; }
     this.updateAttribute('maxhscroll', this.scrollwidth - this.width);
     // recalculate height
     if (this.sizeToHeight) {
@@ -301,9 +305,17 @@
     if (this.capabilities.linescrolling) {
       lineNo = tsprite.pixelToLineNo(value);
     } else {
-      lineNo = Math.floor(value / this.lineheight) + 1;
+      lineNo = Math.floor((value / this.lineheight) + 1);
     }
     this.updateAttribute(name, lineNo);
+    if ($dhtml) {
+      // DHTML sprites do not have line attributes
+    } else if ($debug) {
+      // Max's assertion that line attributes match the sprite
+      if (this[name] != this.sprite[name]) {
+        Debug.warn("%w.%s: %d != %d", this, name, this[name], this.sprite[name]);
+      }
+    }
   }
 
   /**
@@ -313,7 +325,7 @@
    * @type Number
    * @keywords read-only
    */
-  var lineheight:Number;
+  var lineheight:Number = 0;
   /** @access private */
   function $lzc$set_lineheight(x:Number):void {
     if ($debug) { Debug.error("lineheight is read-only"); }
@@ -335,6 +347,12 @@
   var yscroll:Number = 0;
   /** @access private */
   function $lzc$set_yscroll(n:Number):void {
+    if (n > 0) {
+      if ($debug) {
+        Debug.warn("Invalid value for %w.yscroll: %w", this, n);
+      }
+      n = 0;
+    }
     this.tsprite.setYScroll(n);
     this.updateAttribute('yscroll', n);
     this.updateLineAttribute('scroll', (- n));
@@ -358,7 +376,7 @@
    * @type number
    * @keywords read-only
    */
-  var scrollheight:Number;
+  var scrollheight:Number = 0;
   /** @access private */
   function $lzc$set_scrollheight(x:Number):void {
     if ($debug) { Debug.error("scrollheight is read-only"); }
@@ -380,6 +398,12 @@
   var xscroll:Number = 0;
   /** @access private */
   function $lzc$set_xscroll(n:Number):void {
+    if (n > 0) {
+      if ($debug) {
+        Debug.warn("Invalid value for %w.xscroll: %w", this, n);
+      }
+      n = 0;
+    }
     this.tsprite.setXScroll(n);
     this.updateAttribute('xscroll', n);
     this.updateAttribute('hscroll', (- n));
@@ -403,7 +427,7 @@
    * @type number
    * @keywords read-only
    */
-  var scrollwidth:Number;
+  var scrollwidth:Number = 0;
   /** @access private */
   function $lzc$set_scrollwidth(x:Number):void {
     if ($debug) { Debug.error("scrollwidth is read-only"); }
@@ -428,6 +452,12 @@
   var scroll:Number = 1;
   /** @access private */
   function $lzc$set_scroll(n:Number):void {
+    if (n < 1 || n > this.maxscroll) {
+      if ($debug) {
+        Debug.warn("Invalid valuefor %w.scroll: %w (limits [1, %w])", this, n, this.maxscroll);
+      }
+      n = n < 1 ? 1 : this.maxscroll;
+    }
     var tsprite = this.tsprite;
     var pixel:Number;
     if (this.capabilities.linescrolling) {
@@ -461,14 +491,6 @@
   }
   /** @lzxtype event */
   var onmaxscroll:LzDeclaredEventClass = LzDeclaredEvent;
-  /**
-   * maxscroll depends on height
-   * @access private
-   */
-  override function $lzc$set_height(v) {
-    super.$lzc$set_height(v);
-    this.updateLineAttribute('maxscroll', this.scrollheight - this.height);
-  }
 
   /**
    * The horizontal scroll position in pixels.  Default 0.
@@ -478,6 +500,12 @@
   var hscroll:Number = 0;
   /** @access private */
   function $lzc$set_hscroll(n:Number):void {
+    if (n < 0 || n > this.maxhscroll) {
+      if ($debug) {
+        Debug.warn("Invalid value for %w.hscroll: %w (limits [0, %w])", this, n, this.maxhscroll);
+      }
+      n = n < 1 ? 1 : this.maxhscroll;
+    }
     // Call the pixel interface which will update the attribute and
     // send the event
     this.$lzc$set_xscroll((- n));
@@ -520,29 +548,31 @@
   function scrollevent(name:String, value):void {
     switch (name) {
       case 'scrollTop':
-        this.updateAttribute('yscroll', value);
+        this.updateAttribute('yscroll', (- value));
         this.updateLineAttribute('scroll', value);
         break;
       case 'scrollLeft':
-        this.updateAttribute('xscroll', value);
+        this.updateAttribute('xscroll', (- value));
         this.updateAttribute('hscroll', value);
         break;
       case 'scrollHeight':
         this.updateAttribute('scrollheight', value);
         // This can't be negative
-        this.updateLineAttribute('maxscroll', Math.max(0, value - this.height));
+        this.updateLineAttribute('maxscroll', Math.max(0, value - this.tsprite.height));
         break;
       case 'scrollWidth':
         this.updateAttribute('scrollwidth', value);
         // This can't be negative
-        this.updateAttribute('maxhscroll', Math.max(0, value - this.width));
+        this.updateAttribute('maxhscroll', Math.max(0, value - this.tsprite.width));
         break;
       case 'lineHeight':
         this.updateAttribute('lineheight', value);
         // Update all the line-based values...
-        this.updateLineAttribute('scroll', this.yscroll);
-        // This can't be negative
-        this.updateLineAttribute('maxscroll', Math.max(0, this.scrollheight - this.height));
+        if (this.inited) {
+          this.updateLineAttribute('scroll', (- this.yscroll));
+          // This can't be negative
+          this.updateLineAttribute('maxscroll', Math.max(0, this.scrollheight - this.tsprite.height));
+        }
         break;
       default:
         if ($debug) {
@@ -627,7 +657,7 @@
     }
     var tsprite = this.tsprite;
     if (this.visible) tsprite.setVisible(this.visible);
-    if (this.maxlength != null && t.length > this.maxlength){
+    if (t.length > this.maxlength){
       t = t.substring(0, this.maxlength);
     }
     tsprite.setText(t);
@@ -670,10 +700,16 @@
    * @lzxtype numberExpression
    * @type Number
    */
-  var maxlength;
+  var maxlength:Number = Infinity;
   /** @access private */
   function $lzc$set_maxlength(val) {
-    if (val == null || val == '') return;
+    if (val == null) { val = Infinity; }
+    if (isNaN(val)) {
+      if ($debug) {
+        Debug.warn("Invalid value for %w.maxlength: %w", this, val);
+      }
+      return;
+    }
     this.maxlength = val;
     this.tsprite.setMaxLength(val);
     if (this.onmaxlength.ready) this.onmaxlength.sendEvent(val);
@@ -739,7 +775,7 @@
     if (! (align == "left" || align == "right" || align == "center"
            || align == "justify")) {
       if ($debug) {
-        Debug.warn("invalid value for %w.textalign = %w", this, align);
+        Debug.warn("Invalid value for %w.textalign: %w", this, align);
       }
       align = "left";
     }
@@ -790,7 +826,7 @@
       // CSS actually also allows: overline, line-through, blink
       // but Flash can't handle that..
       if ($debug) {
-        Debug.warn("invalid value for %w.textdecoration = %w", this, decoration);
+        Debug.warn("Invalid value for %w.textdecoration: %w", this, decoration);
       }
       decoration = "none";
     }
@@ -851,7 +887,7 @@
     }
 
     this.text = ((args['text'] != null) ? String(args.text) : "");
-    if(this.maxlength != null && this.text.length > this.maxlength){
+    if(this.text.length > this.maxlength){
       this.text = this.text.substring(0, this.maxlength);
     }
 
@@ -1057,12 +1093,14 @@
 
   /** @access private */
   function getScroll ( ){
-    return this.tsprite.getScroll();
+    //    if ($debug) Debug.deprecated(this, arguments.callee, 'scroll');
+    return this.scroll;
   }
 
   /** @access private */
   function getMaxScroll ( ){
-    return this.tsprite.getMaxScroll();
+    //    if ($debug) Debug.deprecated(this, arguments.callee, 'maxscroll');
+    return this.maxscroll;
   }
   /** @access private */
   function $lzc$getMaxScroll_dependencies ( who , self){
@@ -1071,7 +1109,8 @@
 
   /** @access private */
   function getBottomScroll ( ){
-    return this.tsprite.getBottomScroll();
+    //    if ($debug) Debug.deprecated(this, arguments.callee, 'scroll + height / lineheight');
+    return this.scroll + this.height / this.lineheight;
   }
 
   /**
@@ -1522,3 +1561,4 @@
 lz[LzText.tagname] = LzText;
 
 
+}

Modified: openlaszlo/trunk/lps/components/base/swatchview.lzx
===================================================================
--- openlaszlo/trunk/lps/components/base/swatchview.lzx	2009-02-05 12:40:31 UTC (rev 12752)
+++ openlaszlo/trunk/lps/components/base/swatchview.lzx	2009-02-05 13:20:26 UTC (rev 12753)
@@ -14,11 +14,11 @@
 
     <!--- @keywords private -->
     <method name="construct" args="parent, args">  <![CDATA[
+        super.construct( parent, args );
         // We _do_ support colortransform, independent of the
         // platform's support
         this.capabilities = new LzInheritedHash(this.capabilities);
         this.capabilities.colortransform = true;
-        super.construct( parent, args );
         if ( args['width'] == null ){
             args['width'] = this.immediateparent.width;
         }

Modified: openlaszlo/trunk/lps/components/debugger/newcontent.lzx
===================================================================
--- openlaszlo/trunk/lps/components/debugger/newcontent.lzx	2009-02-05 12:40:31 UTC (rev 12752)
+++ openlaszlo/trunk/lps/components/debugger/newcontent.lzx	2009-02-05 13:20:26 UTC (rev 12753)
@@ -279,8 +279,8 @@
                      var tpane = classroot.textpane;
                      var mscroll = tpane.getMaxScroll();
                      var scroll = tpane.getScroll();
-                     var percent = (this.y - bh)  / (parent.height - (bh + bh + parent.thumbheight));
-                     var line = Math.floor(mscroll * percent) +1;
+                     var percent = Math.min(1, Math.max(0, (this.y - bh)  / (parent.height - (bh + bh + parent.thumbheight))));
+                     var line = Math.floor((mscroll-1) * percent) + 1;
                      this.classroot.setLineNoScroll(line);
                  ]]>
            </method> 
@@ -312,7 +312,7 @@
 
 <method name="clear">
       this.textpane.clearText();
-      this.setLine(0);
+      this.setLine(1);
       this.updateDisplay();
      </method>
 
@@ -352,17 +352,18 @@
 
 <method name="pageUp" args="n=null">
          var tpane = this.textpane;
-         tpane.setAttribute('scroll', tpane.getScroll() - (tpane.getBottomScroll()  - tpane.getScroll()));
+         tpane.setAttribute('scroll', Math.max(1, tpane.getScroll() - (tpane.getBottomScroll()  - tpane.getScroll())));
          this.updateDisplay();
      </method>
 <method name="pageDown" args="n=null">
          var tpane = this.textpane;
-         tpane.setAttribute('scroll', tpane.getScroll() + (tpane.getBottomScroll()  - tpane.getScroll()));
+         tpane.setAttribute('scroll', Math.min(tpane.maxscroll, tpane.getScroll() + (tpane.getBottomScroll()  - tpane.getScroll())));
          this.updateDisplay();
      </method>
 
 <method name="incScroll" args="n">
-       this.textpane.setAttribute('scroll', this.textpane.getScroll() + n);
+       var tpane = this.textpane;
+       tpane.setAttribute('scroll', Math.min(tpane.maxscroll, Math.max(1, tpane.getScroll() + n)));
        this.updateDisplay();
      </method>
 

Modified: openlaszlo/trunk/lps/components/incubator/scrolledittext.lzx
===================================================================
--- openlaszlo/trunk/lps/components/incubator/scrolledittext.lzx	2009-02-05 12:40:31 UTC (rev 12752)
+++ openlaszlo/trunk/lps/components/incubator/scrolledittext.lzx	2009-02-05 13:20:26 UTC (rev 12753)
@@ -16,6 +16,13 @@
 
         <_newinternalinputtext name="inp" x="${parent.border}" 
             y="${parent.border}">
+            <!-- Supplied by lztext now
+                attribute name="lineheight"
+                       value="${this.getTextHeight()/this.getMaxScroll()}"/-->
+            <attribute name="maxtextheight"
+                       value="${this.lineheight * this.maxscroll}"/>
+            <attribute name="maxheight" 
+                       value="${this.height + this.maxtextheight}"/>
             <attribute name="pos" value="0" type="number"/>
             
             <setter name="pos" args="p">
@@ -121,7 +128,7 @@
         
         <method name="updateScrollMax" args="IGNORE_THIS_ARG = null">
             if(this['_vs']){
-                this._vs.setAttribute("scrollmax", this.inp.scrollheight);
+                this._vs.setAttribute("scrollmax", this.inp.maxheight);
             }
         </method>
         

Modified: openlaszlo/trunk/lps/components/incubator/test/scrolledittext-test.lzx
===================================================================
--- openlaszlo/trunk/lps/components/incubator/test/scrolledittext-test.lzx	2009-02-05 12:40:31 UTC (rev 12752)
+++ openlaszlo/trunk/lps/components/incubator/test/scrolledittext-test.lzx	2009-02-05 13:20:26 UTC (rev 12753)
@@ -8,18 +8,32 @@
 
     <simplelayout axis="x" spacing="6"/>
     
+    <method name="showMeasurements" args="atextfield">
+        var o = 'Measurements for ' + atextfield;
+        with (atextfield) {
+            o += '\nscroll: ' + scroll + ' sprite ' + sprite.scroll;
+            o += '\nmaxscroll: ' + maxscroll + ' sprite ' + sprite.maxscroll;
+            o += '\nhscroll: ' + hscroll + ' sprite ' + sprite.hscroll;
+            o += '\nmaxhscroll: ' + maxhscroll + ' sprite ' + sprite.maxhscroll;
+        }
+        Debug.write(o);
+    </method>
+
     <view bgcolor="papayawhip">
         <simplelayout axis="y" spacing="6"/>
-        <scrolledittext id="set1" x="20" y="20" width="300" height="100" vscrollbarclassname="newvscrollbar">this is the fun scrolledittext</scrolledittext>
+        <scrolledittext name="set1" x="20" y="20" width="300" height="100" vscrollbarclassname="newvscrollbar">this is the fun scrolledittext</scrolledittext>
         <button>Wider
-            <handler name="onclick">set1.setAttribute("width", set1.width + 20);</handler>
+            <handler name="onclick">this.parent.set1.setAttribute("width", this.parent.set1.width + 20);</handler>
         </button>
         <button>Taller
-            <handler name="onclick">set1.setAttribute("height", set1.height + 20);</handler>
+            <handler name="onclick">this.parent.set1.setAttribute("height", this.parent.set1.height + 20);</handler>
         </button>
         <button>Change style
-            <handler name="onclick">set1.inp.setAttribute("fontsize", set1.inp.fontsize != 9 ? 9 : 11);</handler>
+            <handler name="onclick">this.parent.set1.inp.setAttribute("fontsize", this.parent.set1.inp.fontsize != 9 ? 9 : 11);</handler>
         </button>
+        <button>Show measurements
+            <handler name="onclick">canvas.showMeasurements(this.parent.set1);</handler>
+        </button>
     </view>
 
         <!--scrolledittext x="20" y="20" width="300" height="200" vscrollbarclassname="newvscrollbar">this is the fun scrolledittext</scrolledittext-->



More information about the Laszlo-checkins mailing list