X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/2d120f8391920145647ec10e84629bc21fa9f1bb..ca8b28f2efff34b9939035a7aeb1de1e3ac98a0c:/src/motif/menu.cpp?ds=sidebyside diff --git a/src/motif/menu.cpp b/src/motif/menu.cpp index 2ee35df7c2..b940cce133 100644 --- a/src/motif/menu.cpp +++ b/src/motif/menu.cpp @@ -65,6 +65,7 @@ wxMenu::wxMenu(const wxString& title, const wxFunction func) m_eventHandler = this; m_noItems = 0; m_menuBar = NULL; + m_pInvokingWindow = NULL; //// Motif-specific members m_numColumns = 1; @@ -379,12 +380,50 @@ void wxMenu::ProcessCommand(wxCommandEvent & event) { processed = GetEventHandler()->ProcessEvent(event); } - /* TODO // Try the window the menu was popped up from (and up // through the hierarchy) if ( !processed && GetInvokingWindow()) processed = GetInvokingWindow()->ProcessEvent(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) @@ -409,6 +448,10 @@ bool wxWindow::PopupMenu(wxMenu *menu, int x, int y) menu->SetId(1); /* Mark as popped-up */ menu->CreateMenu(NULL, widget, menu); + menu->SetInvokingWindow(this); + + menu->UpdateUI(); + // menu->SetParent(parent); // parent->children->Append(menu); // Store menu for later deletion @@ -465,6 +508,19 @@ wxMenuBar::wxMenuBar() m_font = wxSystemSettings::GetSystemFont(wxSYS_DEFAULT_GUI_FONT); } +wxMenuBar::wxMenuBar(long WXUNUSED(style)) +{ + m_eventHandler = this; + m_menuCount = 0; + m_menus = NULL; + m_titles = NULL; + m_menuBarFrame = NULL; + m_mainWidget = (WXWidget) NULL; + m_backgroundColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_MENU); + m_foregroundColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_MENUTEXT); + m_font = wxSystemSettings::GetSystemFont(wxSYS_DEFAULT_GUI_FONT); +} + wxMenuBar::wxMenuBar(int n, wxMenu *menus[], const wxString titles[]) { m_eventHandler = this;