constantlayout.lzx

<library>
<include href="utils/layouts/layout.lzx"/>
<class name="constantlayout" extends="layout">

    <!--- The axis in which this layout operates either 'x' or 'y'.  -->
    <attribute name="axis" value="y" type="string"/>

    <!--- The constant value that is applied to the attribute
          ( defined in 'axis' as 'x' or 'y' ) of each subview in the layout. --> 
    <attribute name="value"/>

    <!--- This method is called automatically by the layout. However it can be called directly to force the
          layout to update -->
    <method name="update" args="v=null">
        
        var l = this.subviews.length;
            
        for(var i=0; i < l; i++) {
            this.subviews[i].setAttribute( this.axis , this.value ); 
        } 
        
    </method>
    <doc>
        <tag name="shortdesc"><text>Arranges a set of views to a constant 'x' or 'y' value.</text></tag>
        <text>
            <p>
                <literal>constantlayout</literal> extends
                <sgmltag class="element" role="LzLayout"><LzLayout></sgmltag>, and therefore it is responsible for
                arranging all of the subviews for the view that it is attached to. The
                attributes of a view that <literal>constantlayout</literal>
                effects are the <literal>x</literal> and <literal>y</literal>
                values, and as its name implies <literal>constantlayout</literal>
                sets all of the subviews to the same value.</p>
            <example title="Using constantlayout">
    <canvas height="100">
        <view bgcolor="red" >
            <view width="80" height="80" bgcolor="teal"/>       
            <view width="60" height="60" bgcolor="silver"/> 
            <view width="40" height="40" bgcolor="green"/>           
            <constantlayout axis="x" value="10"/>
        </view >
    </canvas>
            </example>
            <p>In this example the teal, silver and green views are aligned on the horizontal (x) axis; the layout element's value attribute (10) causes the subviews to be shifted ten pixels to the right.</p>
   <example title="Aligning on the horizontal axis.">
        <canvas height="100" >
            <view bgcolor="red" >
                <view width="80" height="80" bgcolor="teal"/>       
                <view width="60" height="60" bgcolor="silver"/> 
                <view width="40" height="40" bgcolor="green"/>           
                <constantlayout axis="y" value="10"/>
            </view >
        </canvas>
            </example>
        </text>
    </doc>
</class>
</library>
<!-- This file will be obsoleted, isnteal use: /utrils/layouts/library,lzx -->
<!-- * X_LZ_COPYRIGHT_BEGIN ***************************************************
* Copyright 2001-2004, 2010 Laszlo Systems, Inc.  All Rights Reserved.              *
* Use is subject to license terms.                                            *
* X_LZ_COPYRIGHT_END ****************************************************** -->
<!-- @LZX_VERSION@                                                         -->

Cross References

Includes

Classes