added virtual wxFrame::FindItemInMenuBar(): overriding it in wxMDIParentFrame allows to look for the items in the active child when giving help for the current menu item
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@46114 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -81,6 +81,11 @@ public:
|
||||
#if wxUSE_MENUS
|
||||
virtual void SetMenuBar(wxMenuBar *menubar);
|
||||
virtual wxMenuBar *GetMenuBar() const { return m_frameMenuBar; }
|
||||
|
||||
// find the item by id in the frame menu bar: this is an internal function
|
||||
// and exists mainly in order to be overridden in the MDI parent frame
|
||||
// which also looks at its active child menu bar
|
||||
virtual const wxMenuItem *FindItemInMenuBar(int menuId) const;
|
||||
#endif // wxUSE_MENUS
|
||||
|
||||
// process menu command: returns true if processed
|
||||
@@ -212,8 +217,8 @@ protected:
|
||||
virtual void PositionStatusBar() { }
|
||||
|
||||
// show the help string for the given menu item using DoGiveHelp() if the
|
||||
// given item does have a help string, return false if there is no help for
|
||||
// such item
|
||||
// given item does have a help string (as determined by FindInMenuBar()),
|
||||
// return false if there is no help for such item
|
||||
bool ShowMenuHelp(int helpid);
|
||||
|
||||
wxStatusBar *m_frameStatusBar;
|
||||
|
@@ -92,6 +92,9 @@ public:
|
||||
virtual WXLRESULT MSWDefWindowProc(WXUINT, WXWPARAM, WXLPARAM);
|
||||
virtual bool MSWTranslateMessage(WXMSG* msg);
|
||||
|
||||
// override wxFrameBase function to also look in the active child menu bar
|
||||
virtual const wxMenuItem *FindItemInMenuBar(int menuId) const;
|
||||
|
||||
protected:
|
||||
#if wxUSE_MENUS_NATIVE
|
||||
virtual void InternalSetMenuBar();
|
||||
|
@@ -356,15 +356,12 @@ bool wxFrameBase::ShowMenuHelp(int menuId)
|
||||
wxString helpString;
|
||||
if ( menuId != wxID_SEPARATOR && menuId != -3 /* wxID_TITLE */ )
|
||||
{
|
||||
wxMenuBar *menuBar = GetMenuBar();
|
||||
if ( menuBar )
|
||||
{
|
||||
// it's ok if we don't find the item because it might belong
|
||||
// to the popup menu
|
||||
wxMenuItem *item = menuBar->FindItem(menuId);
|
||||
const wxMenuItem * const item = FindItemInMenuBar(menuId);
|
||||
if ( item )
|
||||
helpString = item->GetHelp();
|
||||
}
|
||||
|
||||
// notice that it's ok if we don't find the item because it might
|
||||
// belong to the popup menu, so don't assert here
|
||||
}
|
||||
|
||||
DoGiveHelp(helpString, true);
|
||||
@@ -560,4 +557,11 @@ void wxFrameBase::SetMenuBar(wxMenuBar *menubar)
|
||||
this->AttachMenuBar(menubar);
|
||||
}
|
||||
|
||||
const wxMenuItem *wxFrameBase::FindItemInMenuBar(int menuId) const
|
||||
{
|
||||
const wxMenuBar * const menuBar = GetMenuBar();
|
||||
|
||||
return menuBar ? menuBar->FindItem(menuId) : NULL;
|
||||
}
|
||||
|
||||
#endif // wxUSE_MENUS
|
||||
|
@@ -315,6 +315,17 @@ void wxMDIParentFrame::DoMenuUpdates(wxMenu* menu)
|
||||
}
|
||||
}
|
||||
|
||||
const wxMenuItem *wxMDIParentFrame::FindItemInMenuBar(int menuId) const
|
||||
{
|
||||
const wxMenuItem *item = wxFrame::FindItemInMenuBar(menuId);
|
||||
if ( !item && m_currentChild )
|
||||
{
|
||||
item = m_currentChild->FindItemInMenuBar(menuId);
|
||||
}
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
void wxMDIParentFrame::UpdateClientSize()
|
||||
{
|
||||
if ( GetClientWindow() )
|
||||
@@ -475,24 +486,6 @@ WXLRESULT wxMDIParentFrame::MSWWindowProc(WXUINT message,
|
||||
rc = true;
|
||||
break;
|
||||
|
||||
case WM_MENUSELECT:
|
||||
{
|
||||
WXWORD item, flags;
|
||||
WXHMENU hmenu;
|
||||
UnpackMenuSelect(wParam, lParam, &item, &flags, &hmenu);
|
||||
|
||||
if ( m_parentFrameActive )
|
||||
{
|
||||
processed = HandleMenuSelect(item, flags, hmenu);
|
||||
}
|
||||
else if (m_currentChild)
|
||||
{
|
||||
processed = m_currentChild->
|
||||
HandleMenuSelect(item, flags, hmenu);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case WM_SIZE:
|
||||
// though we don't (usually) resize the MDI client to exactly fit the
|
||||
// client area we need to pass this one to DefFrameProc to allow the children to show
|
||||
|
Reference in New Issue
Block a user