[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">
<method name="setY" args="y" >
- 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))));
</method>
</programlisting>
<para>Would need to be changed to:</para>
<programlisting class="code">
<setter name="y" args="y" >
- super.setAttribute('y', Math.max(parent.arrowbuttonheight-1 , Math.min( y , parent.height - (parent.thumbheight + parent.arrowbuttonheight))));
+ super.setAttribute('y', Math.max(parent.arrowbuttonheight-1 , Math.min( y , parent.height - (parent.thumbheight + parent.arrowbuttonheight))));
</setter>
</programlisting>
<para>Here's another example. If you had this code in OpenLaszlo 4.1 or earlier:</para>
<programlisting class="code">
<text x="${Math.round((parent.width-this.width)/2)}" font="vera_super_bold" fgcolor="0x4d4d4d" datapath="@username" resize="true">
- <method name="setText">
- if (typeof(this.datapath.data) != 'undefined') {
- super.setText(this.datapath.data + "'s information");
- }
- </method>
+ <method name="setText">
+ if (typeof(this.datapath.data) != 'undefined') {
+ super.setText(this.datapath.data + "'s information");
+ }
+ </method>
</text>
</programlisting>
<para>You would change it to:</para>
<programlisting class="code">
<text x="${Math.round((parent.width-this.width)/2)}" font="vera_super_bold" fgcolor="0x4d4d4d" datapath="@username" resize="true">
- <setter name="text">
- if (typeof(this.datapath.data) != 'undefined') {
- super.setAttribute('text', this.datapath.data + "'s information");
- }
- </setter>
+ <setter name="text">
+ if (typeof(this.datapath.data) != 'undefined') {
+ super.setAttribute('text', this.datapath.data + "'s information");
+ }
+ </setter>
</text>
</programlisting>
<para>LFC setter methods like <literal>setWidth()</literal>, <literal>setHeight()</literal>,
@@ -188,14 +188,15 @@
<attribute name="text" type="text" setter="setText(text)"/>
...
<method name="setText" args="t">
- this.text = t;
- if (this._initcomplete) {
- this.setValue(t, true);
- this.field.setAttribute('text', this.value);
- if (this['ontext']) this.ontext.sendEvent();
- } else {
- this._initialtext = t;
- }
+ this.text = t;
+ if (this._initcomplete) {
+ this.setValue(t, true);
+ this.field.setAttribute('text', this.value);
+ if (this['ontext']) this.ontext.sendEvent();
+ }
+ else {
+ this._initialtext = t;
+ }
</method>
</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><setter></literal> tag:</para>
@@ -203,19 +204,20 @@
<attribute name="text" type="text"/>
...
<method name="setText" args="t">
- Debug.warn("edittext.setText is deprecated. Use setAttribute instead");
- this.setAttribute('text', t);
+ Debug.warn("edittext.setText is deprecated. Use setAttribute instead");
+ this.setAttribute('text', t);
</method>
<setter name="text" args="t">
- this.text = t;
- if (this._initcomplete) {
- this.setValue(t, true);
- this.field.setAttribute('text', this.value);
- if (this['ontext']) this.ontext.sendEvent();
- } else {
- this._initialtext = t;
- }
+ this.text = t;
+ if (this._initcomplete) {
+ this.setValue(t, true);
+ this.field.setAttribute('text', this.value);
+ if (this['ontext']) this.ontext.sendEvent();
+ }
+ else {
+ this._initialtext = t;
+ }
</setter>
</programlisting></section>
</section>
More information about the Laszlo-checkins
mailing list