[Laszlo-checkins] r11974 - openlaszlo/trunk/docs/src/developers

lou@openlaszlo.org lou at openlaszlo.org
Thu Dec 4 03:36:29 PST 2008


Author: lou
Date: 2008-12-04 03:36:10 -0800 (Thu, 04 Dec 2008)
New Revision: 11974

Modified:
   openlaszlo/trunk/docs/src/developers/classes-powerprogramming.dbk
Log:
Change 20081204-lou-Y by lou at loumac.local on 2008-12-04 07:31:24 AST
    in /Users/lou/src/svn/openlaszlo/trunk
    for http://svn.openlaszlo.org/openlaszlo/trunk

Summary: dguide, Chapter 33. Extending Classes section 2.2. Attribute setters defined with <setter/>: format program listings

Bugs Fixed: LPP-7433

Details: Add indentation to program listings to make them easier to read (no content changes)

Tests: visual verify



Modified: openlaszlo/trunk/docs/src/developers/classes-powerprogramming.dbk
===================================================================
--- openlaszlo/trunk/docs/src/developers/classes-powerprogramming.dbk	2008-12-04 11:34:50 UTC (rev 11973)
+++ openlaszlo/trunk/docs/src/developers/classes-powerprogramming.dbk	2008-12-04 11:36:10 UTC (rev 11974)
@@ -145,36 +145,36 @@
    
    <programlisting class="code">
       &lt;method name=&quot;setY&quot; args=&quot;y&quot; &gt; 
-      super.setY( Math.max(parent.arrowbuttonheight-1 , Math.min( y , parent.height - (parent.thumbheight + parent.arrowbuttonheight)))); 
+         super.setY( Math.max(parent.arrowbuttonheight-1 , Math.min( y , parent.height - (parent.thumbheight + parent.arrowbuttonheight)))); 
       &lt;/method&gt;    
    </programlisting>
    
    <para>Would need to be changed to:</para>
    <programlisting class="code">
       &lt;setter name=&quot;y&quot; args=&quot;y&quot; &gt;
-      super.setAttribute(&apos;y&apos;, Math.max(parent.arrowbuttonheight-1 , Math.min( y , parent.height - (parent.thumbheight + parent.arrowbuttonheight))));
+         super.setAttribute(&apos;y&apos;, Math.max(parent.arrowbuttonheight-1 , Math.min( y , parent.height - (parent.thumbheight + parent.arrowbuttonheight))));
       &lt;/setter&gt;
    </programlisting>
    <para>Here's another example. If you had this code in OpenLaszlo 4.1 or earlier:</para>
    
    <programlisting class="code">
       &lt;text x=&quot;${Math.round((parent.width-this.width)/2)}&quot; font=&quot;vera_super_bold&quot; fgcolor=&quot;0x4d4d4d&quot; datapath=&quot;@username&quot; resize=&quot;true&quot;&gt;
-      &lt;method name=&quot;setText&quot;&gt;
-      if (typeof(this.datapath.data) != &apos;undefined&apos;) {
-      super.setText(this.datapath.data + &quot;&apos;s information&quot;);
-      }
-      &lt;/method&gt;
+         &lt;method name=&quot;setText&quot;&gt;
+            if (typeof(this.datapath.data) != &apos;undefined&apos;) {
+               super.setText(this.datapath.data + &quot;&apos;s information&quot;);
+            }
+         &lt;/method&gt;
       &lt;/text&gt;
    </programlisting>
    
    <para>You would change it to:</para>
    <programlisting class="code">
       &lt;text x=&quot;${Math.round((parent.width-this.width)/2)}&quot; font=&quot;vera_super_bold&quot; fgcolor=&quot;0x4d4d4d&quot; datapath=&quot;@username&quot; resize=&quot;true&quot;&gt;
-      &lt;setter name=&quot;text&quot;&gt;
-      if (typeof(this.datapath.data) != &apos;undefined&apos;) {
-      super.setAttribute(&apos;text&apos;, this.datapath.data + &quot;&apos;s information&quot;);
-      }
-      &lt;/setter&gt;
+         &lt;setter name=&quot;text&quot;&gt;
+            if (typeof(this.datapath.data) != &apos;undefined&apos;) {
+               super.setAttribute(&apos;text&apos;, this.datapath.data + &quot;&apos;s information&quot;);
+            }
+         &lt;/setter&gt;
       &lt;/text&gt;
    </programlisting>
    <para>LFC setter methods like <literal>setWidth()</literal>, <literal>setHeight()</literal>, 
@@ -188,14 +188,15 @@
       &lt;attribute name=&quot;text&quot; type=&quot;text&quot; setter=&quot;setText(text)&quot;/&gt;
       ...
       &lt;method name=&quot;setText&quot; args=&quot;t&quot;&gt;
-      this.text = t;
-      if (this._initcomplete) {
-      this.setValue(t, true);
-      this.field.setAttribute(&apos;text&apos;, this.value);
-      if (this[&apos;ontext&apos;]) this.ontext.sendEvent();
-      } else {
-      this._initialtext = t;
-      }
+         this.text = t;
+         if (this._initcomplete) {
+            this.setValue(t, true);
+            this.field.setAttribute(&apos;text&apos;, this.value);
+            if (this[&apos;ontext&apos;]) this.ontext.sendEvent();
+            } 
+         else {
+            this._initialtext = t;
+         }
       &lt;/method&gt;
    </programlisting>
    <para>As you can see, this allows setting the text object via <literal>setAttribute('text',...)</literal> and <literal>setText()</literal>. To make this code run a little faster (by removing a call to <literal>setText()</literal> from the setter), and follow how the LFC does it, this was rewritten to use the <literal>&lt;setter&gt;</literal> tag:</para>
@@ -203,19 +204,20 @@
       &lt;attribute name=&quot;text&quot; type=&quot;text&quot;/&gt;
       ...
       &lt;method name=&quot;setText&quot; args=&quot;t&quot;&gt;
-      Debug.warn(&quot;edittext.setText is deprecated. Use setAttribute instead&quot;);
-      this.setAttribute(&apos;text&apos;, t);
+         Debug.warn(&quot;edittext.setText is deprecated. Use setAttribute instead&quot;);
+         this.setAttribute(&apos;text&apos;, t);
       &lt;/method&gt;
       
       &lt;setter name=&quot;text&quot; args=&quot;t&quot;&gt;
-      this.text = t;
-      if (this._initcomplete) {
-      this.setValue(t, true);
-      this.field.setAttribute(&apos;text&apos;, this.value);
-      if (this[&apos;ontext&apos;]) this.ontext.sendEvent();
-      } else {
-      this._initialtext = t;
-      }
+         this.text = t;
+         if (this._initcomplete) {
+            this.setValue(t, true);
+            this.field.setAttribute(&apos;text&apos;, this.value);
+            if (this[&apos;ontext&apos;]) this.ontext.sendEvent();
+            } 
+         else {
+            this._initialtext = t;
+         }
       &lt;/setter&gt;
    </programlisting></section>
 </section>



More information about the Laszlo-checkins mailing list