nsMenuParent.h 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
  2. /* This Source Code Form is subject to the terms of the Mozilla Public
  3. * License, v. 2.0. If a copy of the MPL was not distributed with this
  4. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  5. #ifndef nsMenuParent_h___
  6. #define nsMenuParent_h___
  7. class nsMenuFrame;
  8. /*
  9. * nsMenuParent is an interface implemented by nsMenuBarFrame and nsMenuPopupFrame
  10. * as both serve as parent frames to nsMenuFrame.
  11. *
  12. * Don't implement this interface on other classes unless you also fix up references,
  13. * as this interface is directly cast to and from nsMenuBarFrame and nsMenuPopupFrame.
  14. */
  15. class nsMenuParent {
  16. public:
  17. // returns the menu frame of the currently active item within the menu
  18. virtual nsMenuFrame *GetCurrentMenuItem() = 0;
  19. // sets the currently active menu frame.
  20. NS_IMETHOD SetCurrentMenuItem(nsMenuFrame* aMenuItem) = 0;
  21. // indicate that the current menu frame is being destroyed, so clear the
  22. // current menu item
  23. virtual void CurrentMenuIsBeingDestroyed() = 0;
  24. // deselects the current item and closes its popup if any, then selects the
  25. // new item aMenuItem. For a menubar, if another menu is already open, the
  26. // new menu aMenuItem is opened. In this case, if aSelectFirstItem is true,
  27. // select the first item in it. For menupopups, the menu is not opened and
  28. // the aSelectFirstItem argument is not used. The aFromKey argument indicates
  29. // that the keyboard was used to navigate to the new menu item.
  30. NS_IMETHOD ChangeMenuItem(nsMenuFrame* aMenuItem,
  31. bool aSelectFirstItem,
  32. bool aFromKey) = 0;
  33. // returns true if the menupopup is open. For menubars, returns false.
  34. virtual bool IsOpen() = 0;
  35. // returns true if the menubar is currently active. For menupopups, returns false.
  36. virtual bool IsActive() = 0;
  37. // returns true if this is a menubar. If false, it is a popup
  38. virtual bool IsMenuBar() = 0;
  39. // returns true if this is a menu, which has a tag of menupopup or popup.
  40. // Otherwise, this returns false
  41. virtual bool IsMenu() = 0;
  42. // returns true if this is a context menu
  43. virtual bool IsContextMenu() = 0;
  44. // indicate that the menubar should become active or inactive
  45. NS_IMETHOD SetActive(bool aActiveFlag) = 0;
  46. // notify that the menu has been closed and any active state should be
  47. // cleared. This should return true if the menu should be deselected
  48. // by the caller.
  49. virtual bool MenuClosed() = 0;
  50. // Lock this menu and its parents until they're closed or unlocked.
  51. // A menu being "locked" means that all events inside it that would change the
  52. // selected menu item should be ignored.
  53. // This is used when closing the popup is delayed because of a blink or fade
  54. // animation.
  55. virtual void LockMenuUntilClosed(bool aLock) = 0;
  56. virtual bool IsMenuLocked() = 0;
  57. };
  58. #endif