X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/3dd4e4e05cc46ffc653730715e527af7b18b9caf..9b73db3c34aefd98080b425459322fa821ae271f:/src/stubs/menu.cpp diff --git a/src/stubs/menu.cpp b/src/stubs/menu.cpp index 1fc7c4a229..5880beab53 100644 --- a/src/stubs/menu.cpp +++ b/src/stubs/menu.cpp @@ -303,8 +303,51 @@ void wxMenu::ProcessCommand(wxCommandEvent & event) */ } +// 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(); + } +} + bool wxWindow::PopupMenu(wxMenu *menu, int x, int y) { + menu->SetInvokingWindow(this); + menu->UpdateUI(); + // TODO return FALSE; }