michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef nsMenuParent_h___ michael@0: #define nsMenuParent_h___ michael@0: michael@0: class nsMenuFrame; michael@0: michael@0: /* michael@0: * nsMenuParent is an interface implemented by nsMenuBarFrame and nsMenuPopupFrame michael@0: * as both serve as parent frames to nsMenuFrame. michael@0: * michael@0: * Don't implement this interface on other classes unless you also fix up references, michael@0: * as this interface is directly cast to and from nsMenuBarFrame and nsMenuPopupFrame. michael@0: */ michael@0: michael@0: class nsMenuParent { michael@0: michael@0: public: michael@0: // returns the menu frame of the currently active item within the menu michael@0: virtual nsMenuFrame *GetCurrentMenuItem() = 0; michael@0: // sets the currently active menu frame. michael@0: NS_IMETHOD SetCurrentMenuItem(nsMenuFrame* aMenuItem) = 0; michael@0: // indicate that the current menu frame is being destroyed, so clear the michael@0: // current menu item michael@0: virtual void CurrentMenuIsBeingDestroyed() = 0; michael@0: // deselects the current item and closes its popup if any, then selects the michael@0: // new item aMenuItem. For a menubar, if another menu is already open, the michael@0: // new menu aMenuItem is opened. In this case, if aSelectFirstItem is true, michael@0: // select the first item in it. For menupopups, the menu is not opened and michael@0: // the aSelectFirstItem argument is not used. michael@0: NS_IMETHOD ChangeMenuItem(nsMenuFrame* aMenuItem, bool aSelectFirstItem) = 0; michael@0: michael@0: // returns true if the menupopup is open. For menubars, returns false. michael@0: virtual bool IsOpen() = 0; michael@0: // returns true if the menubar is currently active. For menupopups, returns false. michael@0: virtual bool IsActive() = 0; michael@0: // returns true if this is a menubar. If false, it is a popup michael@0: virtual bool IsMenuBar() = 0; michael@0: // returns true if this is a menu, which has a tag of menupopup or popup. michael@0: // Otherwise, this returns false michael@0: virtual bool IsMenu() = 0; michael@0: // returns true if this is a context menu michael@0: virtual bool IsContextMenu() = 0; michael@0: michael@0: // indicate that the menubar should become active or inactive michael@0: NS_IMETHOD SetActive(bool aActiveFlag) = 0; michael@0: michael@0: // notify that the menu has been closed and any active state should be michael@0: // cleared. This should return true if the menu should be deselected michael@0: // by the caller. michael@0: virtual bool MenuClosed() = 0; michael@0: michael@0: // Lock this menu and its parents until they're closed or unlocked. michael@0: // A menu being "locked" means that all events inside it that would change the michael@0: // selected menu item should be ignored. michael@0: // This is used when closing the popup is delayed because of a blink or fade michael@0: // animation. michael@0: virtual void LockMenuUntilClosed(bool aLock) = 0; michael@0: virtual bool IsMenuLocked() = 0; michael@0: }; michael@0: michael@0: #endif michael@0: