home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / lib / xulrunner-1.9.0.14 / chrome / toolkit.jar / content / global / bindings / menu.xml < prev    next >
Encoding:
Extensible Markup Language  |  2008-02-08  |  9.8 KB  |  277 lines

  1. <?xml version="1.0"?>
  2.  
  3. <!DOCTYPE bindings [
  4.   <!ENTITY % globalDTD SYSTEM "chrome://global/locale/global.dtd">
  5.   %globalDTD;
  6. ]>
  7.  
  8. <bindings id="menuitemBindings"
  9.    xmlns="http://www.mozilla.org/xbl"
  10.    xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
  11.    xmlns:xbl="http://www.mozilla.org/xbl">
  12.  
  13.   <binding id="menuitem-base"
  14.            extends="chrome://global/content/bindings/general.xml#control-item">
  15.     <resources>
  16.       <stylesheet src="chrome://global/skin/menu.css"/>
  17.     </resources>
  18.     <implementation implements="nsIDOMXULSelectControlItemElement, nsIDOMXULContainerItemElement, nsIAccessibleProvider">
  19.       <!-- nsIAccessibleProvider -->
  20.       <property name="accessibleType" readonly="true">
  21.         <getter>
  22.           <![CDATA[
  23.             if (this.localName == "menuseparator")
  24.               return Components.interfaces.nsIAccessibleProvider.XULMenuSeparator;
  25.             return Components.interfaces.nsIAccessibleProvider.XULMenuitem;
  26.           ]]>
  27.         </getter>
  28.       </property>
  29.  
  30.       <!-- nsIDOMXULSelectControlItemElement -->
  31.       <property name="selected" readonly="true"
  32.                 onget="return this.getAttribute('selected') == 'true';"/>
  33.       <property name="control" readonly="true">
  34.         <getter>
  35.           <![CDATA[
  36.             var parent = this.parentNode;
  37.             if (parent &&
  38.                 parent.parentNode instanceof Components.interfaces.nsIDOMXULSelectControlElement)
  39.               return parent.parentNode;
  40.             return null;
  41.           ]]>
  42.         </getter>
  43.       </property>
  44.  
  45.       <!-- nsIDOMXULContainerItemElement -->
  46.       <property name="parentContainer" readonly="true">
  47.         <getter>
  48.           for (var parent = this.parentNode; parent; parent = parent.parentNode) {
  49.             if (parent instanceof Components.interfaces.nsIDOMXULContainerElement)
  50.               return parent;
  51.           }
  52.           return null;
  53.         </getter>
  54.       </property>
  55.     </implementation>
  56.   </binding>
  57.  
  58.   <binding id="menu-base"
  59.            extends="chrome://global/content/bindings/menu.xml#menuitem-base">
  60.  
  61.     <implementation implements="nsIDOMXULContainerElement">
  62.       <property name="open" onget="return this.hasAttribute('open');">
  63.         <setter><![CDATA[
  64.           this.boxObject.QueryInterface(Components.interfaces.nsIMenuBoxObject)
  65.               .openMenu(val);
  66.           return val;
  67.         ]]></setter>
  68.       </property>
  69.  
  70.       <!-- nsIDOMXULContainerElement interface -->
  71.       <method name="appendItem">
  72.         <parameter name="aLabel"/>
  73.         <parameter name="aValue"/>
  74.         <body>
  75.           return this.insertItemAt(-1, aLabel, aValue);
  76.         </body>
  77.       </method>
  78.  
  79.       <method name="insertItemAt">
  80.         <parameter name="aIndex"/>
  81.         <parameter name="aLabel"/>
  82.         <parameter name="aValue"/>
  83.         <body>
  84.           const XUL_NS =
  85.             "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
  86.  
  87.           var menupopup = this.menupopup;
  88.           if (!menupopup) {
  89.             menupopup = this.ownerDocument.createElementNS(XUL_NS, "menupopup");
  90.             this.appendChild(menupopup);
  91.           }
  92.  
  93.           var menuitem = this.ownerDocument.createElementNS(XUL_NS, "menuitem");
  94.           menuitem.setAttribute("label", aLabel);
  95.           menuitem.setAttribute("value", aValue);
  96.  
  97.           var before = this.getItemAtIndex(aIndex);
  98.           if (before)
  99.             return menupopup.insertBefore(menuitem, before);
  100.           return menupopup.appendChild(menuitem);
  101.         </body>
  102.       </method>
  103.  
  104.       <method name="removeItemAt">
  105.         <parameter name="aIndex"/>
  106.         <body>
  107.         <![CDATA[
  108.           var menupopup = this.menupopup;
  109.           if (menupopup) {
  110.             var item = this.getItemAtIndex(aIndex);
  111.             if (item)
  112.               return menupopup.removeChild(item);
  113.           }
  114.           return null;
  115.         ]]>
  116.         </body>
  117.       </method>
  118.  
  119.       <property name="itemCount" readonly="true">
  120.         <getter>
  121.           var menupopup = this.menupopup;
  122.           return menupopup ? menupopup.childNodes.length : 0;
  123.         </getter>
  124.       </property>
  125.  
  126.       <method name="getIndexOfItem">
  127.         <parameter name="aItem"/>
  128.         <body>
  129.         <![CDATA[
  130.           var menupopup = this.menupopup;
  131.           if (menupopup) {
  132.             var items = menupopup.childNodes;
  133.             var length = items.length;
  134.             for (var index = 0; index < length; ++index) {
  135.               if (items[index] == aItem)
  136.                 return index;
  137.             }
  138.           }
  139.           return -1;
  140.         ]]>
  141.         </body>
  142.       </method>
  143.  
  144.       <method name="getItemAtIndex">
  145.         <parameter name="aIndex"/>
  146.         <body>
  147.         <![CDATA[
  148.           var menupopup = this.menupopup;
  149.           if (!menupopup || aIndex < 0 || aIndex >= menupopup.childNodes.length)
  150.             return null;
  151.  
  152.           return menupopup.childNodes[aIndex];
  153.         ]]>
  154.         </body>
  155.       </method>
  156.  
  157.       <property name="menupopup" readonly="true">
  158.         <getter>
  159.         <![CDATA[
  160.           const XUL_NS =
  161.             "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
  162.  
  163.           for (var child = this.firstChild; child; child = child.nextSibling) {
  164.             if (child.namespaceURI == XUL_NS && child.localName == "menupopup")
  165.               return child;
  166.           }
  167.           return null;
  168.         ]]>
  169.         </getter>
  170.       </property>
  171.     </implementation>
  172.   </binding>
  173.  
  174.   <binding id="menu"
  175.            extends="chrome://global/content/bindings/menu.xml#menu-base">
  176.     <content>
  177.       <xul:label class="menu-text" flex="1" xbl:inherits="value=label,accesskey,crop" crop="right"/>
  178.       <xul:hbox class="menu-accel-container" anonid="accel">
  179.         <xul:label class="menu-accel" xbl:inherits="value=acceltext"/>
  180.       </xul:hbox>
  181.       <xul:hbox align="center" class="menu-right" chromedir="&locale.dir;"
  182.                 xbl:inherits="_moz-menuactive,disabled">
  183.         <xul:image/>
  184.       </xul:hbox>
  185.       <children includes="menupopup"/>
  186.     </content>
  187.   </binding>
  188.  
  189.   <binding id="menuitem" extends="chrome://global/content/bindings/menu.xml#menuitem-base">
  190.     <content>
  191.       <xul:label class="menu-text" flex="1" xbl:inherits="value=label,accesskey,crop" crop="right"/>
  192.       <xul:hbox class="menu-accel-container" anonid="accel">
  193.         <xul:label class="menu-accel" xbl:inherits="value=acceltext"/>
  194.       </xul:hbox>
  195.     </content>
  196.   </binding>
  197.  
  198.   <binding id="menu-menubar"
  199.            extends="chrome://global/content/bindings/menu.xml#menu-base">
  200.     <content>
  201.       <xul:label class="menubar-text" xbl:inherits="value=label,accesskey,crop" crop="right"/>
  202.       <children includes="menupopup"/>
  203.     </content>
  204.   </binding>
  205.  
  206.   <binding id="menu-menubar-iconic"
  207.            extends="chrome://global/content/bindings/menu.xml#menu-base">
  208.     <content>
  209.       <xul:image class="menubar-left" xbl:inherits="src=image"/>
  210.       <xul:label class="menubar-text" xbl:inherits="value=label,accesskey,crop" crop="right"/>
  211.       <children includes="menupopup"/>
  212.     </content>
  213.   </binding>
  214.  
  215.   <binding id="menuitem-iconic" extends="chrome://global/content/bindings/menu.xml#menuitem">
  216.     <content>
  217.       <xul:hbox class="menu-iconic-left" align="center" pack="center"
  218.                 xbl:inherits="selected,_moz-menuactive,disabled,checked">
  219.         <xul:image class="menu-iconic-icon" xbl:inherits="src=image,validate,src"/>
  220.       </xul:hbox>
  221.       <xul:label class="menu-iconic-text" flex="1" xbl:inherits="value=label,accesskey,crop" crop="right"/>
  222.       <xul:hbox class="menu-accel-container" anonid="accel">
  223.         <xul:label class="menu-iconic-accel" xbl:inherits="value=acceltext"/>
  224.       </xul:hbox>
  225.     </content>
  226.   </binding>
  227.  
  228.   <binding id="menuitem-iconic-noaccel" extends="chrome://global/content/bindings/menu.xml#menuitem">
  229.     <content>
  230.       <xul:hbox class="menu-iconic-left" align="center" pack="center"
  231.                 xbl:inherits="selected,disabled,checked">
  232.         <xul:image class="menu-iconic-icon" xbl:inherits="src=image,validate,src"/>
  233.       </xul:hbox>
  234.       <xul:label class="menu-iconic-text" flex="1" xbl:inherits="value=label,accesskey,crop" crop="right"/>
  235.     </content>
  236.   </binding>
  237.  
  238.   <binding id="menuitem-iconic-desc-noaccel" extends="chrome://global/content/bindings/menu.xml#menuitem">
  239.     <content>
  240.       <xul:hbox class="menu-iconic-left" align="center" pack="center"
  241.                 xbl:inherits="selected,disabled,checked">
  242.         <xul:image class="menu-iconic-icon" xbl:inherits="src=image,validate,src"/>
  243.       </xul:hbox>
  244.       <xul:label class="menu-iconic-text" xbl:inherits="value=label,accesskey,crop" crop="right" flex="1"/>
  245.       <xul:label class="menu-iconic-text menu-description" xbl:inherits="value=description" crop="right" flex="10000"/>
  246.     </content>
  247.   </binding>
  248.  
  249.   <binding id="menu-iconic"
  250.            extends="chrome://global/content/bindings/menu.xml#menu-base">
  251.     <content>
  252.       <xul:hbox class="menu-iconic-left" align="center" pack="center">
  253.         <xul:image xbl:inherits="src=image"/>
  254.       </xul:hbox>
  255.       <xul:label class="menu-iconic-text" flex="1" xbl:inherits="value=label,accesskey,crop" crop="right"/>
  256.       <xul:hbox class="menu-accel-container" anonid="accel">
  257.         <xul:label class="menu-iconic-accel" xbl:inherits="value=acceltext"/>
  258.       </xul:hbox>
  259.       <xul:hbox class="menu-right" chromedir="&locale.dir;"
  260.                 xbl:inherits="_moz-menuactive,disabled" align="center" pack="center">
  261.         <xul:image/>
  262.       </xul:hbox>
  263.       <children includes="menupopup|template"/>
  264.     </content>
  265.   </binding>
  266.   
  267.   <binding id="menubutton-item" extends="chrome://global/content/bindings/menu.xml#menuitem-base">
  268.     <content>
  269.       <xul:label class="menubutton-text" flex="1" xbl:inherits="value=label,accesskey,crop" crop="right"/>
  270.       <children includes="menupopup"/>
  271.     </content>
  272.   </binding>  
  273.   
  274.   <binding id="menuseparator" extends="chrome://global/content/bindings/menu.xml#menuitem-base"/>
  275.  
  276. </bindings>
  277.