зеркало из https://github.com/mozilla/pjs.git
More fun with menus.
This commit is contained in:
Родитель
1c2b36a081
Коммит
efe3a93b89
|
@ -30,6 +30,8 @@
|
||||||
#include "nsIDOMEventReceiver.h"
|
#include "nsIDOMEventReceiver.h"
|
||||||
#include "nsXULAtoms.h"
|
#include "nsXULAtoms.h"
|
||||||
#include "nsMenuFrame.h"
|
#include "nsMenuFrame.h"
|
||||||
|
#include "nsIView.h"
|
||||||
|
#include "nsIViewManager.h"
|
||||||
|
|
||||||
//
|
//
|
||||||
// NS_NewMenuBarFrame
|
// NS_NewMenuBarFrame
|
||||||
|
@ -113,6 +115,13 @@ nsMenuBarFrame::Init(nsIPresContext& aPresContext,
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NS_IMETHODIMP
|
||||||
|
nsMenuBarFrame::SetActive()
|
||||||
|
{
|
||||||
|
mIsActive = PR_TRUE;
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
nsMenuBarFrame::ToggleMenuActiveState()
|
nsMenuBarFrame::ToggleMenuActiveState()
|
||||||
{
|
{
|
||||||
|
@ -129,7 +138,7 @@ nsMenuBarFrame::ToggleMenuActiveState()
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Activate the menu bar
|
// Activate the menu bar
|
||||||
mIsActive = PR_TRUE;
|
SetActive();
|
||||||
|
|
||||||
// Set the active menu to be the top left item (e.g., the File menu).
|
// Set the active menu to be the top left item (e.g., the File menu).
|
||||||
// We use an attribute called "active" to track the current active menu.
|
// We use an attribute called "active" to track the current active menu.
|
||||||
|
|
|
@ -45,7 +45,7 @@ public:
|
||||||
NS_IMETHOD SetCurrentMenuItem(nsIFrame* aMenuItem);
|
NS_IMETHOD SetCurrentMenuItem(nsIFrame* aMenuItem);
|
||||||
NS_IMETHOD GetNextMenuItem(nsIFrame* aStart, nsIFrame** aResult);
|
NS_IMETHOD GetNextMenuItem(nsIFrame* aStart, nsIFrame** aResult);
|
||||||
NS_IMETHOD GetPreviousMenuItem(nsIFrame* aStart, nsIFrame** aResult);
|
NS_IMETHOD GetPreviousMenuItem(nsIFrame* aStart, nsIFrame** aResult);
|
||||||
NS_IMETHOD SetActive() { mIsActive = PR_TRUE; return NS_OK; };
|
NS_IMETHOD SetActive();
|
||||||
|
|
||||||
NS_IMETHOD IsActive() { return mIsActive; };
|
NS_IMETHOD IsActive() { return mIsActive; };
|
||||||
|
|
||||||
|
|
|
@ -191,9 +191,6 @@ nsMenuFrame::HandleEvent(nsIPresContext& aPresContext,
|
||||||
nsIFrame* frame = mPopupFrames.FirstChild();
|
nsIFrame* frame = mPopupFrames.FirstChild();
|
||||||
if (frame) {
|
if (frame) {
|
||||||
// We have children.
|
// We have children.
|
||||||
nsMenuPopupFrame* popup = (nsMenuPopupFrame*)frame;
|
|
||||||
PRBool onMenuBar = PR_TRUE;
|
|
||||||
popup->SyncViewWithFrame(onMenuBar);
|
|
||||||
ToggleMenuState();
|
ToggleMenuState();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -244,6 +241,11 @@ nsMenuFrame::OpenMenu(PRBool aActivateFlag)
|
||||||
nsMenuPopupFrame* menuPopup = (nsMenuPopupFrame*)frame;
|
nsMenuPopupFrame* menuPopup = (nsMenuPopupFrame*)frame;
|
||||||
|
|
||||||
if (aActivateFlag) {
|
if (aActivateFlag) {
|
||||||
|
|
||||||
|
// Sync up the view.
|
||||||
|
if (menuPopup)
|
||||||
|
menuPopup->SyncViewWithFrame(PR_TRUE);
|
||||||
|
|
||||||
// Open the menu.
|
// Open the menu.
|
||||||
mContent->SetAttribute(kNameSpaceID_None, nsXULAtoms::open, "true", PR_TRUE);
|
mContent->SetAttribute(kNameSpaceID_None, nsXULAtoms::open, "true", PR_TRUE);
|
||||||
if (child) {
|
if (child) {
|
||||||
|
@ -264,6 +266,10 @@ nsMenuFrame::OpenMenu(PRBool aActivateFlag)
|
||||||
if (child)
|
if (child)
|
||||||
child->UnsetAttribute(kNameSpaceID_None, nsXULAtoms::menuactive, PR_TRUE);
|
child->UnsetAttribute(kNameSpaceID_None, nsXULAtoms::menuactive, PR_TRUE);
|
||||||
mMenuOpen = PR_FALSE;
|
mMenuOpen = PR_FALSE;
|
||||||
|
|
||||||
|
// Make sure we clear out our own items.
|
||||||
|
if (menuPopup)
|
||||||
|
menuPopup->SetCurrentMenuItem(nsnull);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -93,7 +93,6 @@ protected:
|
||||||
protected:
|
protected:
|
||||||
nsFrameList mPopupFrames;
|
nsFrameList mPopupFrames;
|
||||||
PRBool mMenuOpen;
|
PRBool mMenuOpen;
|
||||||
nsMenuBarFrame* mMenuBar;
|
|
||||||
nsIMenuParent* mMenuParent; // Our parent menu.
|
nsIMenuParent* mMenuParent; // Our parent menu.
|
||||||
}; // class nsMenuFrame
|
}; // class nsMenuFrame
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче