<?xml version="1.0" encoding="UTF-8"?>
<!--
/***************************************************************************

 File Name:   menuGadgets.box

****************************************************************************
C O P Y R I G H T   A N D   C O N F I D E N T I A L I T Y   N O T I C E
****************************************************************************

  Copyright (c) 2006 AOL, LLC.  All rights reserved.
  This software contains valuable confidential and proprietary
  information of AOL, LLC. and is subject to applicable licensing
  agreements.  Unauthorized reproduction, transmission or
  distribution of this file and its contents is a violation of
  applicable laws.

                      A O L    C O N F I D E N T I A L

***************************************************************************/
-->


<?boxely version="1.0"?>

<!DOCTYPE window SYSTEM "box://boxelyToolkit/resources/localization.dtd">



<?import href="box://boxelyToolkit/content/core/coreGadgets.box"?>

<library xmlns="http://www.aol.com/boxely/resource.xsd"
         xmlns:box="http://www.aol.com/boxely/box.xsd"
         xmlns:s="http://www.aol.com/boxely/style.xsd"
         xmlns:on="http://www.aol.com/boxely/reaction.xsd"
         persists="true">



    <gadget id="aolMenuBar" type="menuBar">
        <attributes focusMode="ignore" blockEvents="true" accRole="menuBar"/>
        <behavior inherits="box://boxelyToolkit/content/behaviors.box#menuBar"/>
    </gadget>


    <gadget id="aolMenu" type="menu">
        <attributes label="" icon="" popup="_child" focusMode="ignore" topLevelMenu="true" selectablePopupChild="true" blockEvents="true"
        accRole="menuItem" accNameAt="topMenuLabel"/>
        <parts>
            <box:box id="leftGutter">
                <box:binding elementSource="_gadget" targetProperty="collapsed" path="topLevelMenu" method="twoWay"/>
                <box:image id="icon" inherits="src=icon"/>
            </box:box>
            <box:text id="topMenuLabel" s:flex="1" inherits="accelChar=accessKey,value=label,icon"/>
            <box:box id="dropmark" ornament="true">
                <box:binding elementSource="_gadget" targetProperty="collapsed" path="topLevelMenu" method="twoWay"/>
            </box:box>
        </parts>
        <behavior inherits="box://boxelyToolkit/content/behaviors.box#menu"/>
    </gadget>


    <gadget id="aolMenuBarItem" type="menu">
        <attributes popup="_child" focusMode="normal" topLevelMenu="true" selectablePopupChild="true" blockEvents="true" accRole="menuItem" accNameAt="topMenuLabel"/>
        <parts>
            <box:text id="topMenuLabel" s:flex="1" inherits="accelChar=accessKey,value=label,icon"/>
        </parts>
        <behavior inherits="box://boxelyToolkit/content/behaviors.box#menu"/>
    </gadget>


    <gadget id="aolMenuItemBlockCommand" type="control" inherits="#aolMenuItem" language="jscript" code="box://boxelyToolkit/content/menuPack/aolMenuItemBlockCommand.js">
        <behavior inherits="box://boxelyToolkit/content/behaviors.box#menuitem">
            <reaction event="command" action="gadget:onFilterCommand();"/>
        </behavior>
    </gadget>


    <gadget id="aolCheckMenuItem" type="control">
        <attributes selectableMode="item" selectablePopupChild="true" focusMode="ignore"  blockEvents="true"
                    accRole="menuItem" accNameAt="menuLabel" accAcceleratorAt="acceleratorText"/>
        <parts>
            <box:box id="leftGutter">
                <box:box id="checkmark" ornament="true"/>
            </box:box>
            <box:text id="menuLabel" s:flex="1" inherits="plaintext,value=label,$fontFamily=fontFamily,accelChar=accessKey"/>
            <box:text id="acceleratorText" inherits="value=acceltext,$fontFamily=fontFamily"/>
        </parts>
        <behavior inherits="box://boxelyToolkit/content/behaviors.box#menuitem" />
    </gadget>


    <gadget id="aolMenuSeparator" type="spacer"/>


    <gadget id="comboBox" type="select" inherits="#menuBox">
        <attributes accRole="comboBox"/>
        <parts>
            <box:aolInput id="input" s:flex="1" inherits="value"/>
            <box:dropmark id="dropmark"/>
        </parts>
    </gadget>



    <gadget id="aolMenuButton" type="control">
        <attributes cursorMode="wrap" blockEvents="true" popup="_child"
        accRole="buttonMenu" accNameAt="menuBoxLabel"/>
        <parts>
            <box:text id="menuBoxLabel" inherits="value=label,icon,collapsed=noLabel,accelChar=accessKey"/>
            <box:box id="dropmark" ornament="true"/>
            <box:box id="preLightLayer" inherits="focused,defaultButton" ornament="true"/>
        </parts>
        <behavior inherits="box://boxelyToolkit/content/behaviors.box#commandable">
            <reaction event="keyPress" keyCode="SPACE" action="toolkit:Pop"/>
        </behavior>
    </gadget>



    <gadget id="aolMenuBox" type="select" language="jscript" code="box://boxelyToolkit/content/menuPack/aolMenuBox.js">
        <attributes cursorMode="wrap" blockEvents="true" popup="_child" noLabel="false"
        accRole="buttonMenu" accNameAt="menuBoxLabel"/>
        <parts>
            <box:text id="menuBoxLabel" inherits="value=label,icon,collapsed=noLabel,accelChar=accessKey"/>
            <box:dropmark id="dropmark"/>
            <box:box id="preLightLayer" inherits="focused,defaultButton" ornament="true"/>
        </parts>
        <behavior inherits="box://boxelyToolkit/content/behaviors.box#selectable">
            <reaction event="boxCreated" action="gadget:initSelection();"/>
        </behavior>
    </gadget>


    <gadget id="comboPopup" type="popup" language="jscript" code="box://boxelyToolkit/content/menuPack/combopopup.js">
        <attributes translucent="true" focusMode="ignore" accRole="menuPopup" accNameAt="menuLabel"/>
        <parts>
            <box:vbox id="container" inherits="$maxHeight=listHeight">
                <box:content/>
            </box:vbox>
        </parts>
        <behavior>
            <reaction event="keyPress" keyCode="UP" action="gadget:onUp();"/>
            <reaction event="keyPress" keyCode="DOWN" action="gadget:onDown();"/>
            <reaction event="shutting" action="gadget:onShutting();"/>
            <reaction event="attributeSet" attributeName="collapsed" action="gadget:onCollapsed();"/>
        </behavior>
    </gadget>



    <gadget id="aolEditableCombobox" type="select" language="jscript" code="box://boxelyToolkit/content/menuPack/aolEditableCombobox.js" >
        <attributes blockEvents="false" focusMode="defer" disabled="false" readOnly="false" ignoreMouseDown="true" accRole="comboBox"
                    useAutoSuggest="true" numMatchesFound="0"/>
        <parts>
            <box:aolPromptInput id="inputField" focusMode="normal" inherits="disabled,filter,maxlength,tabIndex" on:modified="gadget:inputLabelChanged();">
                <box:binding elementSource="_gadget" targetProperty="value" path="label" method="twoWay"/>
                <box:binding elementSource="_gadget" targetProperty="ornament" path="readOnly" sourceTransformer="gadget:onReadOnlyMode();" method="twoWay"/>
            </box:aolPromptInput>
            <box:box id="separator">
                <box:binding elementSource="_gadget" targetProperty="$fill" path="$stroke" method="twoWay"/>
            </box:box>
            <box:box id="menuArea" popup="_child" inherits="disabled, search">
                <box:binding elementSource="_gadget" targetProperty="ornament" path="disabled" method="twoWay"/>
                <box:box id="dropdown" ornament="true"/>
                <box:comboPopup id="thePopup" inherits="listHeight" popupAlign="none" showNoActivate="true" on:popping="gadget:onPopping();"
                    on:shutting="gadget:onPopupClosed();" on:command="gadget:onCommand();" on:popped="gadget:onPopped();">
                    <box:content/>
                    <box:reaction event="keyPress" keyCode="UP" alt="false" override="true" action="gadget:updateInputField(true);"/>
                    <box:reaction event="keyPress" keyCode="DOWN" alt="false" override="true" action="gadget:updateInputField(false);"/>
                    <box:reaction event="keyDown" keyCode="ALT" action="toolkit:StopEventPropagation"/>
                    <box:reaction event="mouseWheel" detail="1" action="gadget:onMouseWheel(1);"/>
                    <box:reaction event="mouseWheel" detail="-1" action="gadget:onMouseWheel(-1);"/>
                </box:comboPopup>
            </box:box>
            <box:box id="preLightLayer" ornament="true" inherits="search,focused">
                <box:binding elementSource="gadget:inputField" targetProperty="focused" path="focused" method="twoWay"/>
            </box:box>
        </parts>
        <behavior>
            <reaction event="attributeSet" attributeName="disabled" action="gadget:onDisabled();"/>
            <reaction event="keyPress" keyCode="DOWN" alt="true" action="gadget:togglePopup();"/>
            <reaction event="keyPress" keyCode="UP" alt="true" action="gadget:togglePopup();"/>
            <reaction event="keyPress" keyCode="DOWN" alt="false" action="gadget:selectNextComboItem(true);"/>
            <reaction event="keyPress" keyCode="UP" alt="false" action="gadget:selectNextComboItem(false);"/>
            <reaction event="keyPress" shift="true" keyCode="TAB" action="gadget:onTabPress();"/>
            <reaction event="keyPress" keyCode="TAB" action="gadget:onTabPress();"/>
            <reaction event="mouseWheel" detail="1" action="gadget:onMouseWheel(1);"/>
            <reaction event="mouseWheel" detail="-1" action="gadget:onMouseWheel(-1);"/>
        </behavior>
    </gadget>



    <gadget id="aolCombobox" type="select" language="jscript" code="box://boxelyToolkit/content/menuPack/aolCombobox.js">
        <attributes wantEnter="false" blockEvents="false" focusMode="normal" popup="_child" ignoreMouseDown="true" accRole="comboBox"/>
        <parts>
            <box:binding elementSource="_self" targetProperty="ornament" path="disabled" method="twoWay"/>
            <box:image id="icon" inherits="src=icon"/>
            <box:aolLabel id="label" ornament="true">
                <box:binding elementSource="_gadget" targetProperty="value" path="label" method="twoWay"/>
            </box:aolLabel>
            <box:box id="separator">
                <box:binding elementSource="_gadget" targetProperty="$fill" path="$stroke" method="twoWay"/>
            </box:box>
            <box:box focusMode="defer" id="menuArea">
                <box:binding elementSource="_gadget" targetProperty="ornament" path="disabled" method="twoWay"/>
                <box:box id="dropdown" ornament="true"/>
                <box:comboPopup id="thePopup" inherits="listHeight" popupAlign="none" showNoActivate="true" on:popping="gadget:onPopping();" on:shutting="gadget:onPopupClosed();"
                    on:command="gadget:onCommand();" on:popped="gadget:onPopped();">
                    <box:content/>
                    <box:reaction event="keyPress" keyCode="UP" alt="false" override="true" action="gadget:updateLabel(true);"/>
                    <box:reaction event="keyPress" keyCode="DOWN" alt="false" override="true" action="gadget:updateLabel(false);"/>
                    <box:reaction event="keyDown" keyCode="ALT" action="toolkit:StopEventPropagation"/>
                    <box:reaction event="mouseWheel" detail="1" action="gadget:onMouseWheel(1);"/>
                    <box:reaction event="mouseWheel" detail="-1" action="gadget:onMouseWheel(-1);"/>
                </box:comboPopup>
            </box:box>
            <box:box id="preLightLayer" ornament="true">
                <box:binding elementSource="_gadget" targetProperty="focused" path="focused" method="twoWay"/>
            </box:box>
        </parts>
        <behavior>
            <reaction event="keyPress" keyCode="DOWN" alt="true" action="gadget:showPopup();"/>
            <reaction event="keyPress" keyCode="UP" alt="true" action="gadget:showPopup();"/>
            <reaction event="keyPress" alt="false" action="gadget:onKeyPress();"/>
            <reaction event="keyPress" keyCode="TAB" action="gadget:onTabPress();"/>
            <reaction event="keyPress" shift="true" keyCode="TAB" action="gadget:onTabPress();"/>
            <reaction event="mouseWheel" detail="1" action="gadget:onMouseWheel(1);"/>
            <reaction event="mouseWheel" detail="-1" action="gadget:onMouseWheel(-1);"/>
        </behavior>
    </gadget>


    <gadget id="controlOverflowPane" type="box" language="jscript" code="box://boxelyToolkit/content/menuPack/controlOverflowPane.js">
        <attributes axis="x" overflowTooltip=""/>
        <parts>
            <box:binding elementSource="gadget:contentArea" targetProperty="contentChildOverflowed" path="overflowed" method="twoWay"/>

            <box:box id="mainContainer" inherits="axis">
                <box:box id="contentArea" inherits="axis">
                    <box:box id="contentBox" inherits="axis">
                        <box:content/>
                    </box:box>
                </box:box>
                <box:aolImageButton id="spilloverButton" icon="#chevron.right" hideLabel="true" popup="_child" inherits="tooltip=overflowTooltip" accRole="ignore">
                    <box:menuPopup id="spilloverPopup" on:popping="gadget:onSpilloverPopping();" on:shutting="gadget:onSpilloverShutting();">
                    </box:menuPopup>
                </box:aolImageButton>
            </box:box>
        </parts>
        <behavior>
            <reaction event="layout" action="gadget:onLayout();"/>
            <reaction event="boxCreated" action="gadget:boxCreated();"/>
            <reaction event="attributeSet" attributeName="axis" action="gadget:setAxis();"/>
        </behavior>
    </gadget>

    <gadget id="controlOverflowMenuItem" type="control" inherits="#aolCheckMenuItem" language="jscript" code="box://boxelyToolkit/content/menuPack/controlOverflowMenuItem.js">
        <attributes blockEvents="true" selectableMode="block" collapsed="true"/>
        <behavior>
            <reaction event="attributeSet" attributeName="collapsed" action="gadget:updateSelectableState();"/>
            <reaction event="command" action="gadget:onCommanded();"/>
            <reaction event="boxDestroyed" action="gadget:onDestroyed();"/>
        </behavior>
    </gadget>

    <gadget id="controlOverflowMenu" type="menu" inherits="#aolMenu" language="jscript" code="box://boxelyToolkit/content/menuPack/controlOverflowMenu.js">
        <attributes popup="_child" focusMode="ignore" selectablePopupChild="true" blockEvents="true"
        accRole="menuItem" accNameAt="topMenuLabel"/>
        <parts>
            <box:box id="leftGutter">
                <box:image id="icon" inherits="src=icon"/>
            </box:box>
            <box:text id="topMenuLabel" s:flex="1" inherits="accelChar=accessKey,value=label,icon"/>
            <box:dropmark id="dropmark"/>
            <box:menuPopup id="popup"/>
        </parts>
        <behavior inherits="box://boxelyToolkit/content/behaviors.box#menu"/>
    </gadget>
</library>