<?xml version="1.0"?>

<!DOCTYPE bindings [
  <!ENTITY % transformationitemDTD SYSTEM "chrome://cssproperties/locale/transformationitem.dtd" >
  %transformationitemDTD;
]>

<bindings id="transformationitemBindings"
   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="rotate"
           extends="chrome://global/content/bindings/richlistbox.xml#richlistitem">

    <resources>
      <stylesheet src="chrome://cssproperties/skin/transformationitem.css"/>
    </resources>

    <content>
      <xul:label class="transformationitem-title" value="&rotation.label;"/>
      <xul:hbox align="center">
        <xul:rotator anonid="rotator" onlyonrelease="true"
                     onchange="ReapplyTransforms()"/>
      </xul:hbox>
    </content>

    <implementation>
      <method name="getChild">
        <parameter name="aChildName"/>
        <body><![CDATA[
          return document.getAnonymousElementByAttribute(this, "anonid", aChildName);
        ]]></body>
      </method>

      <property name="value">
        <getter>
        <![CDATA[
          return this.getChild("rotator").value;
        ]]>
        </getter>
        <setter>
        <![CDATA[
          this.getChild("rotator").value = val;
        ]]>
        </setter>
      </property>
    </implementation>
  </binding>

  <binding id="translate"
           extends="chrome://global/content/bindings/richlistbox.xml#richlistitem">

    <resources>
      <stylesheet src="chrome://cssproperties/skin/transformationitem.css"/>
    </resources>

    <content>
      <xul:label class="transformationitem-title" value="&translation.label;"/>
      <xul:hbox align="center">
        <xul:label value="&horizontally.label;"/>
        <xul:menulist anonid="Htextbox" editable="true"
                      oncommand="onLengthMenulistCommand(this, '% px pt cm in mm pc em ex rem ch', '', true, ReapplyTransforms)"
                      oninput="onLengthMenulistCommand(this, '% px pt cm in mm pc em ex rem ch', '', true, ReapplyTransforms)">
          <xul:menupopup anonid="horizontalTranslationMenupopup"
                         onpopupshowing="PopulateLengths(this, '% px pt cm in mm pc em ex rem ch')"/>
        </xul:menulist>
        <xul:spinbuttons onup="IncreaseLength(this, '% px pt cm in mm pc em ex rem ch', ReapplyTransforms)"
                         ondown="DecreaseLength(this, '% px pt cm in mm pc em ex rem ch', true, ReapplyTransforms)"/>
        <xul:label value="&vertically.label;"/>
        <xul:menulist anonid="Vtextbox" editable="true"
                      oncommand="onLengthMenulistCommand(this, '% px pt cm in mm pc em ex rem ch', '', true, ReapplyTransforms)"
                      oninput="onLengthMenulistCommand(this, '% px pt cm in mm pc em ex rem ch', '', true, ReapplyTransforms)">
          <xul:menupopup anonid="verticalTranslationMenupopup"
                         onpopupshowing="PopulateLengths(this, '% px pt cm in mm pc em ex rem ch', ReapplyTransforms)"/>
        </xul:menulist>
        <xul:spinbuttons onup="IncreaseLength(this, '% px pt cm in mm pc em ex rem ch', ReapplyTransforms)"
                         ondown="DecreaseLength(this, '% px pt cm in mm pc em ex rem ch', true, ReapplyTransforms)"/>
      </xul:hbox>
    </content>

    <implementation>
      <method name="getChild">
        <parameter name="aChildName"/>
        <body><![CDATA[
          return document.getAnonymousElementByAttribute(this, "anonid", aChildName);
        ]]></body>
      </method>

      <property name="horizontally">
        <getter>
        <![CDATA[
          return this.getChild("Htextbox").value;
        ]]>
        </getter>
        <setter>
        <![CDATA[
          this.getChild("Htextbox").value = val;
        ]]>
        </setter>
      </property>

      <property name="vertically">
        <getter>
        <![CDATA[
          return this.getChild("Vtextbox").value;
        ]]>
        </getter>
        <setter>
        <![CDATA[
          this.getChild("Vtextbox").value = val;
        ]]>
        </setter>
      </property>
    </implementation>
  </binding>

  <binding id="skew"
           extends="chrome://global/content/bindings/richlistbox.xml#richlistitem">

    <resources>
      <stylesheet src="chrome://cssproperties/skin/transformationitem.css"/>
    </resources>

    <content>
      <xul:label class="transformationitem-title" value="&skew.label;"/>
      <xul:hbox align="center">
        <xul:label value="&aroundXAxis.label;"/>
        <xul:rotator anonid="rotatorX" onlyonrelease="true"
                     onchange="ReapplyTransforms()"/>
        <xul:label value="&aroundYAxis.label;"/>
        <xul:rotator anonid="rotatorY" onlyonrelease="true"
                     onchange="ReapplyTransforms()"/>
      </xul:hbox>
    </content>

    <implementation>
      <method name="getChild">
        <parameter name="aChildName"/>
        <body><![CDATA[
          return document.getAnonymousElementByAttribute(this, "anonid", aChildName);
        ]]></body>
      </method>

      <property name="valueX">
        <getter>
        <![CDATA[
          return this.getChild("rotatorX").value;
        ]]>
        </getter>
        <setter>
        <![CDATA[
          this.getChild("rotatorX").value = val;
        ]]>
        </setter>
      </property>

      <property name="valueY">
        <getter>
        <![CDATA[
          return this.getChild("rotatorY").value;
        ]]>
        </getter>
        <setter>
        <![CDATA[
          this.getChild("rotatorY").value = val;
        ]]>
        </setter>
      </property>
    </implementation>
  </binding>

  <binding id="scale"
           extends="chrome://global/content/bindings/richlistbox.xml#richlistitem">

    <resources>
      <stylesheet src="chrome://cssproperties/skin/transformationitem.css"/>
    </resources>

    <content>
      <xul:label class="transformationitem-title" value="&scale.label;"/>
      <xul:hbox align="center">
        <xul:label value="&horizontally.label;"/>
        <xul:textbox anonid="Htextbox" oninput="this.parentNode.parentNode.checkNumber(this); ReapplyTransforms()"/>
        <xul:label value="&vertically.label;"/>
        <xul:textbox anonid="Vtextbox" oninput="this.parentNode.parentNode.checkNumber(this); ReapplyTransforms()"/>
      </xul:hbox>
    </content>

    <implementation>
      <method name="getChild">
        <parameter name="aChildName"/>
        <body><![CDATA[
          return document.getAnonymousElementByAttribute(this, "anonid", aChildName);
        ]]></body>
      </method>

      <property name="horizontally">
        <getter>
        <![CDATA[
          return this.getChild("Htextbox").value;
        ]]>
        </getter>
        <setter>
        <![CDATA[
          this.getChild("Htextbox").value = val;
        ]]>
        </setter>
      </property>

      <property name="vertically">
        <getter>
        <![CDATA[
          return this.getChild("Vtextbox").value;
        ]]>
        </getter>
        <setter>
        <![CDATA[
          this.getChild("Vtextbox").value = val;
        ]]>
        </setter>
      </property>

      <method name="checkNumber">
        <parameter name="aElt"/>
        <body>
          <![CDATA[
            aElt.value = aElt.value.replace( /[^0-9\.]/g , "");
          ]]>
        </body>
      </method>

    </implementation>
  </binding>

</bindings>