layout/xul/nsMenuBarFrame.h

Wed, 31 Dec 2014 06:55:50 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:55:50 +0100
changeset 2
7e26c7da4463
permissions
-rw-r--r--

Added tag UPSTREAM_283F7C6 for changeset ca08bd8f51b2

michael@0 1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
michael@0 2 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 3 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 5
michael@0 6 //
michael@0 7 // nsMenuBarFrame
michael@0 8 //
michael@0 9
michael@0 10 #ifndef nsMenuBarFrame_h__
michael@0 11 #define nsMenuBarFrame_h__
michael@0 12
michael@0 13 #include "mozilla/Attributes.h"
michael@0 14 #include "nsIAtom.h"
michael@0 15 #include "nsCOMPtr.h"
michael@0 16 #include "nsBoxFrame.h"
michael@0 17 #include "nsMenuFrame.h"
michael@0 18 #include "nsMenuBarListener.h"
michael@0 19 #include "nsMenuParent.h"
michael@0 20
michael@0 21 class nsIContent;
michael@0 22
michael@0 23 nsIFrame* NS_NewMenuBarFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
michael@0 24
michael@0 25 class nsMenuBarFrame : public nsBoxFrame, public nsMenuParent
michael@0 26 {
michael@0 27 public:
michael@0 28 NS_DECL_QUERYFRAME_TARGET(nsMenuBarFrame)
michael@0 29 NS_DECL_QUERYFRAME
michael@0 30 NS_DECL_FRAMEARENA_HELPERS
michael@0 31
michael@0 32 nsMenuBarFrame(nsIPresShell* aShell, nsStyleContext* aContext);
michael@0 33
michael@0 34 // nsMenuParent interface
michael@0 35 virtual nsMenuFrame* GetCurrentMenuItem() MOZ_OVERRIDE;
michael@0 36 NS_IMETHOD SetCurrentMenuItem(nsMenuFrame* aMenuItem) MOZ_OVERRIDE;
michael@0 37 virtual void CurrentMenuIsBeingDestroyed() MOZ_OVERRIDE;
michael@0 38 NS_IMETHOD ChangeMenuItem(nsMenuFrame* aMenuItem, bool aSelectFirstItem) MOZ_OVERRIDE;
michael@0 39
michael@0 40 NS_IMETHOD SetActive(bool aActiveFlag) MOZ_OVERRIDE;
michael@0 41
michael@0 42 virtual bool IsMenuBar() MOZ_OVERRIDE { return true; }
michael@0 43 virtual bool IsContextMenu() MOZ_OVERRIDE { return false; }
michael@0 44 virtual bool IsActive() MOZ_OVERRIDE { return mIsActive; }
michael@0 45 virtual bool IsMenu() MOZ_OVERRIDE { return false; }
michael@0 46 virtual bool IsOpen() MOZ_OVERRIDE { return true; } // menubars are considered always open
michael@0 47
michael@0 48 bool IsMenuOpen() { return mCurrentMenu && mCurrentMenu->IsOpen(); }
michael@0 49
michael@0 50 void InstallKeyboardNavigator();
michael@0 51 void RemoveKeyboardNavigator();
michael@0 52
michael@0 53 virtual void Init(nsIContent* aContent,
michael@0 54 nsIFrame* aParent,
michael@0 55 nsIFrame* aPrevInFlow) MOZ_OVERRIDE;
michael@0 56
michael@0 57 virtual void DestroyFrom(nsIFrame* aDestructRoot) MOZ_OVERRIDE;
michael@0 58
michael@0 59 virtual void LockMenuUntilClosed(bool aLock) MOZ_OVERRIDE {}
michael@0 60 virtual bool IsMenuLocked() MOZ_OVERRIDE { return false; }
michael@0 61
michael@0 62 // Non-interface helpers
michael@0 63
michael@0 64 // The 'stay active' flag is set when navigating from one top-level menu
michael@0 65 // to another, to prevent the menubar from deactivating and submenus from
michael@0 66 // firing extra DOMMenuItemActive events.
michael@0 67 bool GetStayActive() { return mStayActive; }
michael@0 68 void SetStayActive(bool aStayActive) { mStayActive = aStayActive; }
michael@0 69
michael@0 70 // Called when a menu on the menu bar is clicked on. Returns a menu if one
michael@0 71 // needs to be closed.
michael@0 72 nsMenuFrame* ToggleMenuActiveState();
michael@0 73
michael@0 74 bool IsActiveByKeyboard() { return mActiveByKeyboard; }
michael@0 75 void SetActiveByKeyboard() { mActiveByKeyboard = true; }
michael@0 76
michael@0 77 // indicate that a menu on the menubar was closed. Returns true if the caller
michael@0 78 // may deselect the menuitem.
michael@0 79 virtual bool MenuClosed() MOZ_OVERRIDE;
michael@0 80
michael@0 81 // Called when Enter is pressed while the menubar is focused. If the current
michael@0 82 // menu is open, let the child handle the key.
michael@0 83 nsMenuFrame* Enter(mozilla::WidgetGUIEvent* aEvent);
michael@0 84
michael@0 85 // Used to handle ALT+key combos
michael@0 86 nsMenuFrame* FindMenuWithShortcut(nsIDOMKeyEvent* aKeyEvent);
michael@0 87
michael@0 88 virtual bool IsFrameOfType(uint32_t aFlags) const MOZ_OVERRIDE
michael@0 89 {
michael@0 90 // Override bogus IsFrameOfType in nsBoxFrame.
michael@0 91 if (aFlags & (nsIFrame::eReplacedContainsBlock | nsIFrame::eReplaced))
michael@0 92 return false;
michael@0 93 return nsBoxFrame::IsFrameOfType(aFlags);
michael@0 94 }
michael@0 95
michael@0 96 #ifdef DEBUG_FRAME_DUMP
michael@0 97 virtual nsresult GetFrameName(nsAString& aResult) const MOZ_OVERRIDE
michael@0 98 {
michael@0 99 return MakeFrameName(NS_LITERAL_STRING("MenuBar"), aResult);
michael@0 100 }
michael@0 101 #endif
michael@0 102
michael@0 103 protected:
michael@0 104 nsMenuBarListener* mMenuBarListener; // The listener that tells us about key and mouse events.
michael@0 105
michael@0 106 // flag that is temporarily set when switching from one menu on the menubar to another
michael@0 107 // to indicate that the menubar should not be deactivated.
michael@0 108 bool mStayActive;
michael@0 109
michael@0 110 bool mIsActive; // Whether or not the menu bar is active (a menu item is highlighted or shown).
michael@0 111
michael@0 112 // whether the menubar was made active via the keyboard.
michael@0 113 bool mActiveByKeyboard;
michael@0 114
michael@0 115 // The current menu that is active (highlighted), which may not be open. This will
michael@0 116 // be null if no menu is active.
michael@0 117 nsMenuFrame* mCurrentMenu;
michael@0 118
michael@0 119 mozilla::dom::EventTarget* mTarget;
michael@0 120
michael@0 121 }; // class nsMenuBarFrame
michael@0 122
michael@0 123 #endif

mercurial