Added wxMenu::UpdateUI to wxMSW, wxGTK, wxMotif, wxStubs; rearranged/debugged
docs git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@1617 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -642,4 +642,44 @@ wxWindow *wxMenu::GetInvokingWindow()
|
||||
return m_invokingWindow;
|
||||
}
|
||||
|
||||
// Update a menu and all submenus recursively.
|
||||
// source is the object that has the update event handlers
|
||||
// defined for it. If NULL, the menu or associated window
|
||||
// will be used.
|
||||
void wxMenu::UpdateUI(wxEvtHandler* source)
|
||||
{
|
||||
if (!source && GetInvokingWindow())
|
||||
source = GetInvokingWindow()->GetEventHandler();
|
||||
if (!source)
|
||||
source = GetEventHandler();
|
||||
if (!source)
|
||||
source = this;
|
||||
|
||||
wxNode* node = GetItems().First();
|
||||
while (node)
|
||||
{
|
||||
wxMenuItem* item = (wxMenuItem*) node->Data();
|
||||
if ( !item->IsSeparator() )
|
||||
{
|
||||
wxWindowID id = item->GetId();
|
||||
wxUpdateUIEvent event(id);
|
||||
event.SetEventObject( source );
|
||||
|
||||
if (source->ProcessEvent(event))
|
||||
{
|
||||
if (event.GetSetText())
|
||||
SetLabel(id, event.GetText());
|
||||
if (event.GetSetChecked())
|
||||
Check(id, event.GetChecked());
|
||||
if (event.GetSetEnabled())
|
||||
Enable(id, event.GetEnabled());
|
||||
}
|
||||
|
||||
if (item->GetSubMenu())
|
||||
item->GetSubMenu()->UpdateUI(source);
|
||||
}
|
||||
node = node->Next();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user