]> git.saurik.com Git - wxWidgets.git/blobdiff - src/gtk/menu.cpp
bug in wxSplitPath() corrected: the returned file name doesn't have the
[wxWidgets.git] / src / gtk / menu.cpp
index faa9236de76a6e8090038432db1e3339fae488fc..7f42dd5e946786113d9e085107572b8996ddee49 100644 (file)
@@ -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();
+  }
+}
+