Line data Source code
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 :
6 : #ifndef nsMenuParent_h___
7 : #define nsMenuParent_h___
8 :
9 : class nsMenuFrame;
10 :
11 : /*
12 : * nsMenuParent is an interface implemented by nsMenuBarFrame and nsMenuPopupFrame
13 : * as both serve as parent frames to nsMenuFrame.
14 : *
15 : * Don't implement this interface on other classes unless you also fix up references,
16 : * as this interface is directly cast to and from nsMenuBarFrame and nsMenuPopupFrame.
17 : */
18 :
19 45 : class nsMenuParent {
20 :
21 : public:
22 : // returns the menu frame of the currently active item within the menu
23 : virtual nsMenuFrame *GetCurrentMenuItem() = 0;
24 : // sets the currently active menu frame.
25 : NS_IMETHOD SetCurrentMenuItem(nsMenuFrame* aMenuItem) = 0;
26 : // indicate that the current menu frame is being destroyed, so clear the
27 : // current menu item
28 : virtual void CurrentMenuIsBeingDestroyed() = 0;
29 : // deselects the current item and closes its popup if any, then selects the
30 : // new item aMenuItem. For a menubar, if another menu is already open, the
31 : // new menu aMenuItem is opened. In this case, if aSelectFirstItem is true,
32 : // select the first item in it. For menupopups, the menu is not opened and
33 : // the aSelectFirstItem argument is not used. The aFromKey argument indicates
34 : // that the keyboard was used to navigate to the new menu item.
35 : NS_IMETHOD ChangeMenuItem(nsMenuFrame* aMenuItem,
36 : bool aSelectFirstItem,
37 : bool aFromKey) = 0;
38 :
39 : // returns true if the menupopup is open. For menubars, returns false.
40 : virtual bool IsOpen() = 0;
41 : // returns true if the menubar is currently active. For menupopups, returns false.
42 : virtual bool IsActive() = 0;
43 : // returns true if this is a menubar. If false, it is a popup
44 : virtual bool IsMenuBar() = 0;
45 : // returns true if this is a menu, which has a tag of menupopup or popup.
46 : // Otherwise, this returns false
47 : virtual bool IsMenu() = 0;
48 : // returns true if this is a context menu
49 : virtual bool IsContextMenu() = 0;
50 :
51 : // indicate that the menubar should become active or inactive
52 : NS_IMETHOD SetActive(bool aActiveFlag) = 0;
53 :
54 : // notify that the menu has been closed and any active state should be
55 : // cleared. This should return true if the menu should be deselected
56 : // by the caller.
57 : virtual bool MenuClosed() = 0;
58 :
59 : // Lock this menu and its parents until they're closed or unlocked.
60 : // A menu being "locked" means that all events inside it that would change the
61 : // selected menu item should be ignored.
62 : // This is used when closing the popup is delayed because of a blink or fade
63 : // animation.
64 : virtual void LockMenuUntilClosed(bool aLock) = 0;
65 : virtual bool IsMenuLocked() = 0;
66 : };
67 :
68 : #endif
69 :
|