newvscrollbar.lzx

<library>
    <include href="base/basescrollbar.lzx"/>
    <include href="newvscrollbar_resources.lzx"/>

<!--- The vertical scrollbar manipulates the y position of a target view that is
      clipped by its parent, creating a scrolling effect when the user
      clicks up/down arrows, clicks on the scroll track or drags the thumb. -->
<class name="newvscrollbar" extends="basescrollbar" styleable="true" bgcolor="0x595959" visible="${this.scrollable && (this.height > 21)}" axis="y">
    <!--- @keywords private -->
    <attribute name="width" value="17"/>
    <!--- @keywords private -->
    <attribute name="_obgcolor" value="$once{this.bgcolor}"/>

    <!-- up arrow -->
    <view height="13" name="toparrow">
        <basescrollarrow x="1" y="1" resource="newvscrollbar_ybuttontop_rsc" direction="-1"/>
    </view>
    <view name="scrolltrack">
        <!-- top of the scroll track -->
        <basescrolltrack name="top" x="1" y="1" resource="newvscrollbar_ytrack_rsc" stretches="height" overResourceNumber="0" downResourceNumber="2" direction="-1">
            <attribute name="height" value="${parent.thumb.y}"/>
            <attribute name="width" value="${parent.width}"/>
        </basescrolltrack>

        <!-- thumb -->
        <basescrollthumb name="thumb" x="1">
             <view resource="newvscrollbar_ythumbtop_rsc"/>
             <view resource="newvscrollbar_ythumbmiddle_rsc" stretches="both"/>
             <view resource="newvscrollbar_ythumbbottom_rsc"/>
             <stableborderlayout axis="y"/>
             <!-- note: stableborderlayout only acts on the first three views -->
             <view resource="newvscrollbar_ythumbgripper_rsc" x="2" height="${Math.min(200, parent.height-16)}" width="11" clip="true" valign="middle"/>
        </basescrollthumb>

        <!-- bottom of the scroll track -->
        <basescrolltrack name="bottom" x="1" resource="newvscrollbar_ytrack_rsc" stretches="height" overResourceNumber="0" downResourceNumber="2">
            <attribute name="y" value="${parent.thumb.y+parent.thumb.height}"/>
            <attribute name="height" value="${parent.height - parent.thumb.y - parent.thumb.height}"/>
            <attribute name="width" value="${parent.width}"/>
        </basescrolltrack>
    </view>     <!-- scrolltrack -->

    <!-- down arrow -->
    <view height="14" name="bottomarrow">
        <basescrollarrow x="1" y="1" resource="newvscrollbar_ybuttonbottom_rsc"/>
    </view>
    <stableborderlayout axis="y"/>

    <!--- @keywords private -->
    <method name="_applystyle" args="s">
        if (s != null) {
            this.setTint(this, s.basecolor);
            this.setTint(this.toparrow, s.basecolor);
            this.setTint(this.scrolltrack, s.basecolor);
            this.setTint(this.bottomarrow, s.basecolor);
        }
    </method>

    <!--- @keywords private -->
    <method name="_showEnabled">
        super._showEnabled();

        var enabled = this._enabled;
        if ( ! enabled ) {
            this._obgcolor = this.bgcolor;
        }
        this.setAttribute('opacity', enabled ? 1 : 0.6 );
        this.setAttribute('bgcolor', enabled ? this._obgcolor : parent.bgcolor );
        this.thumb.setAttribute('clickable', enabled );
        this.thumb.setAttribute('visible', true);
    </method>
</class>
</library>
<!-- * X_LZ_COPYRIGHT_BEGIN ***************************************************
* Copyright 2006-2009 Laszlo Systems, Inc.  All Rights Reserved.                   *
* Use is subject to license terms.                                            *
* X_LZ_COPYRIGHT_END ****************************************************** -->
<!-- @LZX_VERSION@                                                         -->

Cross References

Includes

Classes