From 4d53859584e0fb987fef609c620937e46b0f751a Mon Sep 17 00:00:00 2001 From: David Surovell Date: Wed, 30 Nov 2005 07:59:38 +0000 Subject: [PATCH] minor refactoring of menu UpdateUI handling git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@36296 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/menu.h | 3 +++ src/common/framecmn.cpp | 14 +++++++------- src/common/menucmn.cpp | 17 +++++++++++++++++ 3 files changed, 27 insertions(+), 7 deletions(-) diff --git a/include/wx/menu.h b/include/wx/menu.h index 624e2669ef..5e31cede13 100644 --- a/include/wx/menu.h +++ b/include/wx/menu.h @@ -476,6 +476,9 @@ public: // don't want menu bars to accept the focus by tabbing to them virtual bool AcceptsFocusFromKeyboard() const { return false; } + // update all menu item states in all menus + virtual void UpdateMenus(); + protected: // the list of all our menus wxMenuList m_menus; diff --git a/src/common/framecmn.cpp b/src/common/framecmn.cpp index 3137700a88..923fb49e2d 100644 --- a/src/common/framecmn.cpp +++ b/src/common/framecmn.cpp @@ -523,16 +523,16 @@ void wxFrameBase::SetToolBar(wxToolBar *toolbar) // update all menus void wxFrameBase::DoMenuUpdates(wxMenu* menu) { - wxEvtHandler* source = GetEventHandler(); - wxMenuBar* bar = GetMenuBar(); - if (menu) + { + wxEvtHandler* source = GetEventHandler(); menu->UpdateUI(source); - else if ( bar != NULL ) + } + else { - int nCount = bar->GetMenuCount(); - for (int n = 0; n < nCount; n++) - bar->GetMenu(n)->UpdateUI(source); + wxMenuBar* bar = GetMenuBar(); + if (bar != NULL) + bar->UpdateMenus(); } } diff --git a/src/common/menucmn.cpp b/src/common/menucmn.cpp index 2437f07e4b..edf51cab54 100644 --- a/src/common/menucmn.cpp +++ b/src/common/menucmn.cpp @@ -1058,4 +1058,21 @@ wxString wxMenuBarBase::GetHelpString(int id) const 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 -- 2.45.2