// ----------------------
#include <string.h>
-#if !USE_SHARED_LIBRARY
IMPLEMENT_DYNAMIC_CLASS(wxMenu, wxEvtHandler)
IMPLEMENT_DYNAMIC_CLASS(wxMenuBar, wxEvtHandler)
-#endif
// ============================================================================
// implementation
m_eventHandler = this;
m_noItems = 0;
m_menuBar = NULL;
+ m_clientData = (void*) NULL;
if (m_title != "")
{
Append(-2, m_title) ;
// TODO
}
-const wxString& wxMenu::GetTitle() const
+const wxString wxMenu::GetTitle() const
{
return m_title;
}
*/
}
+// 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;
}