gecko-dev/toolkit/content/widgets/scrollbox.xml

146 lines
5.3 KiB
XML

<?xml version="1.0"?>
<!DOCTYPE bindings [
<!ENTITY % globalDTD SYSTEM "chrome://global/locale/global.dtd">
%globalDTD;
]>
<bindings id="arrowscrollboxBindings"
xmlns="http://www.mozilla.org/xbl"
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:xbl="http://www.mozilla.org/xbl">
<binding id="scrollbox-base">
<resources>
<stylesheet src="chrome://global/skin/scrollbox.css"/>
</resources>
</binding>
<binding id="scrollbox" extends="chrome://global/content/bindings/scrollbox.xml#scrollbox-base">
<content>
<xul:box class="box-inherit scrollbox-innerbox" xbl:inherits="orient,align,pack,dir" flex="1">
<children/>
</xul:box>
</content>
</binding>
<binding id="arrowscrollbox" extends="chrome://global/content/bindings/scrollbox.xml#scrollbox-base">
<content>
<xul:autorepeatbutton class="autorepeatbutton-up" collapsed="true" xbl:inherits="orient"
oncommand="scrollByPixels(this.parentNode.scrollIncrement * -1); event.stopPropagation();"/>
<xul:scrollbox xbl:inherits="orient,align,pack,dir" flex="1">
<children/>
</xul:scrollbox>
<xul:autorepeatbutton class="autorepeatbutton-down" collapsed="true" xbl:inherits="orient"
oncommand="scrollByPixels(this.parentNode.scrollIncrement); event.stopPropagation();"/>
</content>
<implementation>
<field name="_scrollIncrement">0</field>
<property name="scrollIncrement" readonly="true">
<getter><![CDATA[
if (!this._scrollIncrement) {
var pb2 =
Components.classes['@mozilla.org/preferences-service;1'].
getService(Components.interfaces.nsIPrefBranch2);
try {
this._scrollIncrement = pb2.getIntPref("toolkit.scrollbox.scrollIncrement");
}
catch (ex) {
this._scrollIncrement = 20;
}
}
return this._scrollIncrement;
]]></getter>
</property>
<field name="_scrollBoxObject">null</field>
<property name="scrollBoxObject" readonly="true">
<getter><![CDATA[
if (!this._scrollBoxObject) {
var kids = document.getAnonymousNodes(this);
this._scrollBoxObject = kids[1].boxObject.QueryInterface(Components.interfaces.nsIScrollBoxObject);
}
return this._scrollBoxObject;
]]></getter>
</property>
<method name="ensureElementIsVisible">
<parameter name="aElement"/>
<body><![CDATA[
this.scrollBoxObject.ensureElementIsVisible(aElement);
]]></body>
</method>
<method name="scrollByIndex">
<parameter name="lines"/>
<body><![CDATA[
this.scrollBoxObject.scrollByIndex(lines);
]]></body>
</method>
<method name="scrollByPixels">
<parameter name="px"/>
<body><![CDATA[
if (this.getAttribute("orient") == "horizontal") {
// if not ltr, we want to scroll the other direction
var actualPx = window.getComputedStyle(this.parentNode, "")
.direction == "ltr" ? px : (-1 * px);
this.scrollBoxObject.scrollBy(actualPx, 0);
}
else
this.scrollBoxObject.scrollBy(0, px);
]]></body>
</method>
</implementation>
<handlers>
<handler event="DOMMouseScroll" action="this.scrollByIndex(event.detail); event.stopPropagation();"/>
<handler event="underflow"><![CDATA[
var kids = document.getAnonymousNodes(this);
kids[0].collapsed = true;
kids[2].collapsed = true;
var childNodes = document.getAnonymousNodes(kids[1]);
if (childNodes && childNodes.length) {
this.ensureElementIsVisible(childNodes[0]);
if (childNodes.length > 1)
this.ensureElementIsVisible(childNodes[childNodes.length-1]);
}
event.stopPropagation();
]]></handler>
<handler event="overflow"><![CDATA[
var kids = document.getAnonymousNodes(this);
kids[0].collapsed = false;
kids[2].collapsed = false;
event.stopPropagation();
]]></handler>
</handlers>
</binding>
<binding id="autorepeatbutton" extends="chrome://global/content/bindings/scrollbox.xml#scrollbox-base">
<content chromedir="&locale.dir;">
<xul:image class="autorepeatbutton-icon"/>
</content>
</binding>
<binding id="arrowscrollbox-clicktoscroll" extends="chrome://global/content/bindings/scrollbox.xml#arrowscrollbox">
<content>
<xul:toolbarbutton class="scrollbutton-up" collapsed="true"
xbl:inherits="orient"
oncommand="scrollByIndex(-1);"
anonid="scrollbutton-up"
chromedir="&locale.dir;"/>
<xul:scrollbox xbl:inherits="orient,align,pack,dir" flex="1">
<children/>
</xul:scrollbox>
<xul:toolbarbutton class="scrollbutton-down" collapsed="true"
xbl:inherits="orient"
anonid="scrollbutton-down"
oncommand="scrollByIndex(1);"
chromedir="&locale.dir;"/>
</content>
</binding>
</bindings>