hscrollbar.lzx
<library>
<include href="base/basebuttonrepeater.lzx"/>
<include href="base/basescrollbar.lzx"/>
<include href="utils/layouts/stableborderlayout.lzx"/>
<include href="scrollbar_xresources.lzx"/>
<class name="hscrollbar" extends="basescrollbar" bgcolor="0x595959" axis="x">
<attribute name="disabledbgcolor" value="null
"/>
<handler name="oninit" reference="canvas">
this._showEnabled();
</handler>
<method name="_showEnabled">
if (!_enabled) {
var newbgcolor = this.disabledbgcolor;
if (newbgcolor == null) {
var p = immediateparent;
while (p.bgcolor == null && p != canvas) {
p = p.immediateparent;
}
newbgcolor = p.bgcolor;
if (newbgcolor == null) newbgcolor = 0xffffff;
}
this.setAttribute('bgcolor', newbgcolor);
} else {
this.setAttribute('bgcolor', 0x595959);
}
super._showEnabled();
</method>
<attribute name="height" value="14
"/>
<view name="leftarrow">
<basescrollarrow x="1" y="1" resource="lzscrollbar_xbuttonleft_rsc" direction="-1"/>
</view>
<view name="scrolltrack" height="12" y="1">
<basescrolltrack name="top" resource="lzscrollbar_xtrack_rsc" stretches="width" overResourceNumber="0" downResourceNumber="2" disabledResourceNumber="3" direction="-1">
<attribute name="width" value="${parent.thumb.x}"/>
<attribute name="height" value="${parent.height}"/>
</basescrolltrack>
<basescrollthumb name="thumb" y="0">
<view resource="lzscrollbar_xthumbleft_rsc"/>
<view resource="lzscrollbar_xthumbmiddle_rsc" stretches="both"/>
<view resource="lzscrollbar_xthumbright_rsc"/>
<stableborderlayout axis="x"/>
<view resource="lzscrollbar_xthumbgripper_rsc" y="1" width="${Math.min(200, parent.width-16)}" clip="true" align="center"/>
</basescrollthumb>
<basescrolltrack name="bottom" resource="lzscrollbar_xtrack_rsc" stretches="width" overResourceNumber="0" downResourceNumber="2" disabledResourceNumber="3">
<attribute name="x" value="${parent.thumb.x+parent.thumb.width}"/>
<attribute name="width" value="${parent.width - parent.thumb.x - parent.thumb.width}"/>
<attribute name="height" value="${parent.height}"/>
</basescrolltrack>
</view>
<view width="14">
<basescrollarrow name="rightarrow" y="1" resource="lzscrollbar_xbuttonright_rsc"/>
</view>
<stableborderlayout axis="x"/>
<state applied="${parent.othersb}">
<view name="patch" x="${parent.width}" bgcolor="${(parent._enabled || parent.othersb._enabled) ? 0xbdbdbd : parent.disabledbgcolor}" width="${parent.height}" height="${parent.height}"/>
</state>
<doc>
<tag name="shortdesc"><text>
Provides a horizontal scrollbar.
</text></tag>
<text>
<p>A scrollbar manipulates the x or 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.
</p>
<p>This tag creates a horizontal scrollbar. If you do not specify a
<attribute>scrolltarget</attribute> the scrollbar will automatically
be aligned to the bottom and size its width to its parent's width. It
is expected that the parent view be smaller than the scrolltarget and
set <code>clip=true</code>. The scrolling effect is produced by moving
the scrolltarget while its visible region is clipped by the parent
view.</p>
<p>If you would like the target view to start scrolled, simply set its
x position to a negative number. For example, <code>x=-10</code> will
cause the view to be scrolled 10 pixels.</p>
<note>If you have no vertical scrollbars in your application, using
the <tagname>hscrollbar</tagname> tag will make the applications
slightly smaller than if you were to use <scrollbar
axis="x">.</note>
<example title="Simple scrollbar">
<canvas height="100">
<view name="main" width="100" height="90" clip="true">
<view name="contents">
<text width="200" height="70" multiline="true" >
Remember not only to say the right thing in the right place,
but far more difficult still, to leave unsaid the wrong thing
at the tempting moment.
-- Benjamin Franklin
</text>
</view>
<hscrollbar/>
</view>
</canvas>
</example>
<p>In the example above, the scrolltarget is the 'contents' view. A
scrollbar moves its <attribute>scrolltarget</attribute> along its
axis. The attribute that is controlled by the scrollbar may be
specified as the <attribute>scrollattr</attribute>, overriding the
default value of <code>x</code> or <code>y</code>.</p>
</text>
</doc>
</class>
</library>
Cross References
Includes
Classes