2001-09-29 00:14:13 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
1999-07-18 11:07:55 +04:00
|
|
|
|
|
|
|
//
|
|
|
|
// nsMenuBarFrame
|
|
|
|
//
|
|
|
|
|
|
|
|
#ifndef nsMenuBarFrame_h__
|
|
|
|
#define nsMenuBarFrame_h__
|
|
|
|
|
2012-09-14 20:10:08 +04:00
|
|
|
#include "mozilla/Attributes.h"
|
1999-07-18 11:07:55 +04:00
|
|
|
#include "nsIAtom.h"
|
|
|
|
#include "nsCOMPtr.h"
|
2000-08-10 02:38:46 +04:00
|
|
|
#include "nsBoxFrame.h"
|
2007-07-04 19:49:38 +04:00
|
|
|
#include "nsMenuFrame.h"
|
1999-07-19 06:02:38 +04:00
|
|
|
#include "nsMenuBarListener.h"
|
2008-12-05 19:37:31 +03:00
|
|
|
#include "nsMenuParent.h"
|
1999-07-18 11:07:55 +04:00
|
|
|
|
1999-07-19 12:09:30 +04:00
|
|
|
class nsIContent;
|
|
|
|
|
2006-03-27 01:30:36 +04:00
|
|
|
nsIFrame* NS_NewMenuBarFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
|
1999-07-18 11:07:55 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
class nsMenuBarFrame final : public nsBoxFrame, public nsMenuParent
|
1999-07-18 11:07:55 +04:00
|
|
|
{
|
|
|
|
public:
|
2011-09-28 05:46:11 +04:00
|
|
|
NS_DECL_QUERYFRAME_TARGET(nsMenuBarFrame)
|
|
|
|
NS_DECL_QUERYFRAME
|
2009-09-12 20:49:24 +04:00
|
|
|
NS_DECL_FRAMEARENA_HELPERS
|
|
|
|
|
2015-01-06 12:27:56 +03:00
|
|
|
explicit nsMenuBarFrame(nsStyleContext* aContext);
|
2000-01-14 02:20:28 +03:00
|
|
|
|
2008-12-05 19:37:31 +03:00
|
|
|
// nsMenuParent interface
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual nsMenuFrame* GetCurrentMenuItem() override;
|
|
|
|
NS_IMETHOD SetCurrentMenuItem(nsMenuFrame* aMenuItem) override;
|
|
|
|
virtual void CurrentMenuIsBeingDestroyed() override;
|
2015-06-26 19:32:25 +03:00
|
|
|
NS_IMETHOD ChangeMenuItem(nsMenuFrame* aMenuItem,
|
|
|
|
bool aSelectFirstItem,
|
|
|
|
bool aFromKey) override;
|
1999-07-24 05:59:32 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
NS_IMETHOD SetActive(bool aActiveFlag) override;
|
1999-08-13 00:45:47 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual bool IsMenuBar() override { return true; }
|
|
|
|
virtual bool IsContextMenu() override { return false; }
|
|
|
|
virtual bool IsActive() override { return mIsActive; }
|
|
|
|
virtual bool IsMenu() override { return false; }
|
|
|
|
virtual bool IsOpen() override { return true; } // menubars are considered always open
|
2000-02-09 12:34:35 +03:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool IsMenuOpen() { return mCurrentMenu && mCurrentMenu->IsOpen(); }
|
2007-06-30 02:15:59 +04:00
|
|
|
|
2007-07-04 19:49:38 +04:00
|
|
|
void InstallKeyboardNavigator();
|
|
|
|
void RemoveKeyboardNavigator();
|
1999-09-21 05:03:00 +04:00
|
|
|
|
2014-05-25 02:20:40 +04:00
|
|
|
virtual void Init(nsIContent* aContent,
|
|
|
|
nsContainerFrame* aParent,
|
2015-03-21 19:28:04 +03:00
|
|
|
nsIFrame* aPrevInFlow) override;
|
1999-07-19 06:02:38 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual void DestroyFrom(nsIFrame* aDestructRoot) override;
|
1999-08-22 11:44:00 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual void LockMenuUntilClosed(bool aLock) override {}
|
|
|
|
virtual bool IsMenuLocked() override { return false; }
|
2010-04-19 18:12:58 +04:00
|
|
|
|
1999-07-19 06:29:11 +04:00
|
|
|
// Non-interface helpers
|
1999-07-23 11:49:43 +04:00
|
|
|
|
2013-01-12 00:21:48 +04:00
|
|
|
// The 'stay active' flag is set when navigating from one top-level menu
|
|
|
|
// to another, to prevent the menubar from deactivating and submenus from
|
|
|
|
// firing extra DOMMenuItemActive events.
|
|
|
|
bool GetStayActive() { return mStayActive; }
|
|
|
|
void SetStayActive(bool aStayActive) { mStayActive = aStayActive; }
|
2007-10-04 02:00:41 +04:00
|
|
|
|
2007-07-04 19:49:38 +04:00
|
|
|
// Called when a menu on the menu bar is clicked on. Returns a menu if one
|
|
|
|
// needs to be closed.
|
|
|
|
nsMenuFrame* ToggleMenuActiveState();
|
2007-06-29 23:04:45 +04:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool IsActiveByKeyboard() { return mActiveByKeyboard; }
|
2011-10-17 18:59:28 +04:00
|
|
|
void SetActiveByKeyboard() { mActiveByKeyboard = true; }
|
2011-01-04 20:24:51 +03:00
|
|
|
|
2007-07-04 19:49:38 +04:00
|
|
|
// indicate that a menu on the menubar was closed. Returns true if the caller
|
|
|
|
// may deselect the menuitem.
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual bool MenuClosed() override;
|
2007-06-30 02:15:59 +04:00
|
|
|
|
2007-07-04 19:49:38 +04:00
|
|
|
// Called when Enter is pressed while the menubar is focused. If the current
|
|
|
|
// menu is open, let the child handle the key.
|
2013-10-02 07:46:03 +04:00
|
|
|
nsMenuFrame* Enter(mozilla::WidgetGUIEvent* aEvent);
|
2007-07-04 19:49:38 +04:00
|
|
|
|
|
|
|
// Used to handle ALT+key combos
|
|
|
|
nsMenuFrame* FindMenuWithShortcut(nsIDOMKeyEvent* aKeyEvent);
|
1999-07-26 05:35:39 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual bool IsFrameOfType(uint32_t aFlags) const override
|
2007-02-24 21:33:33 +03:00
|
|
|
{
|
|
|
|
// Override bogus IsFrameOfType in nsBoxFrame.
|
|
|
|
if (aFlags & (nsIFrame::eReplacedContainsBlock | nsIFrame::eReplaced))
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2007-02-24 21:33:33 +03:00
|
|
|
return nsBoxFrame::IsFrameOfType(aFlags);
|
|
|
|
}
|
|
|
|
|
2014-01-06 03:31:14 +04:00
|
|
|
#ifdef DEBUG_FRAME_DUMP
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual nsresult GetFrameName(nsAString& aResult) const override
|
1) implememted box reflow coelescing.
2) implemented gfx scrollbars for list boxes
3) fixed progess meter to be an animated gif
4) fixed bugs 23521, 24721, 19114, 20546, 24385, 24457, 23156, 20226, 22543
-r hyatt, troy, rod
2000-02-10 01:02:40 +03:00
|
|
|
{
|
2001-11-14 04:33:42 +03:00
|
|
|
return MakeFrameName(NS_LITERAL_STRING("MenuBar"), aResult);
|
1) implememted box reflow coelescing.
2) implemented gfx scrollbars for list boxes
3) fixed progess meter to be an animated gif
4) fixed bugs 23521, 24721, 19114, 20546, 24385, 24457, 23156, 20226, 22543
-r hyatt, troy, rod
2000-02-10 01:02:40 +03:00
|
|
|
}
|
2001-09-15 04:45:54 +04:00
|
|
|
#endif
|
1) implememted box reflow coelescing.
2) implemented gfx scrollbars for list boxes
3) fixed progess meter to be an animated gif
4) fixed bugs 23521, 24721, 19114, 20546, 24385, 24457, 23156, 20226, 22543
-r hyatt, troy, rod
2000-02-10 01:02:40 +03:00
|
|
|
|
1999-07-18 11:07:55 +04:00
|
|
|
protected:
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<nsMenuBarListener> mMenuBarListener; // The listener that tells us about key and mouse events.
|
2000-02-09 12:34:35 +03:00
|
|
|
|
2007-10-04 02:00:41 +04:00
|
|
|
// flag that is temporarily set when switching from one menu on the menubar to another
|
|
|
|
// to indicate that the menubar should not be deactivated.
|
2011-09-29 10:19:26 +04:00
|
|
|
bool mStayActive;
|
2007-10-04 02:00:41 +04:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool mIsActive; // Whether or not the menu bar is active (a menu item is highlighted or shown).
|
2011-01-04 20:24:51 +03:00
|
|
|
|
|
|
|
// whether the menubar was made active via the keyboard.
|
2011-09-29 10:19:26 +04:00
|
|
|
bool mActiveByKeyboard;
|
2011-01-04 20:24:51 +03:00
|
|
|
|
2007-07-04 19:49:38 +04:00
|
|
|
// The current menu that is active (highlighted), which may not be open. This will
|
|
|
|
// be null if no menu is active.
|
|
|
|
nsMenuFrame* mCurrentMenu;
|
1999-07-18 11:07:55 +04:00
|
|
|
}; // class nsMenuBarFrame
|
|
|
|
|
|
|
|
#endif
|