minor refactoring of menu UpdateUI handling

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@36296 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
David Surovell
2005-11-30 07:59:38 +00:00
parent 0b04c4e0bd
commit 4d53859584
3 changed files with 28 additions and 8 deletions

View File

@@ -476,6 +476,9 @@ public:
// don't want menu bars to accept the focus by tabbing to them // don't want menu bars to accept the focus by tabbing to them
virtual bool AcceptsFocusFromKeyboard() const { return false; } virtual bool AcceptsFocusFromKeyboard() const { return false; }
// update all menu item states in all menus
virtual void UpdateMenus();
protected: protected:
// the list of all our menus // the list of all our menus
wxMenuList m_menus; wxMenuList m_menus;

View File

@@ -523,16 +523,16 @@ void wxFrameBase::SetToolBar(wxToolBar *toolbar)
// update all menus // update all menus
void wxFrameBase::DoMenuUpdates(wxMenu* menu) void wxFrameBase::DoMenuUpdates(wxMenu* menu)
{ {
wxEvtHandler* source = GetEventHandler();
wxMenuBar* bar = GetMenuBar();
if (menu) if (menu)
menu->UpdateUI(source);
else if ( bar != NULL )
{ {
int nCount = bar->GetMenuCount(); wxEvtHandler* source = GetEventHandler();
for (int n = 0; n < nCount; n++) menu->UpdateUI(source);
bar->GetMenu(n)->UpdateUI(source); }
else
{
wxMenuBar* bar = GetMenuBar();
if (bar != NULL)
bar->UpdateMenus();
} }
} }

View File

@@ -1058,4 +1058,21 @@ wxString wxMenuBarBase::GetHelpString(int id) const
return item->GetHelp(); return item->GetHelp();
} }
void wxMenuBarBase::UpdateMenus( void )
{
wxEvtHandler* source;
wxMenu* menu;
int nCount = GetMenuCount();
for (int n = 0; n < nCount; n++)
{
menu = GetMenu( n );
if (menu != NULL)
{
source = menu->GetEventHandler();
if (source != NULL)
menu->UpdateUI( source );
}
}
}
#endif // wxUSE_MENUS #endif // wxUSE_MENUS