]> git.saurik.com Git - wxWidgets.git/commitdiff
common code of wxFrame class
authorVadim Zeitlin <vadim@wxwidgets.org>
Thu, 23 Jul 1998 15:56:50 +0000 (15:56 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Thu, 23 Jul 1998 15:56:50 +0000 (15:56 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@328 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/common/framecmn.cpp [new file with mode: 0644]

diff --git a/src/common/framecmn.cpp b/src/common/framecmn.cpp
new file mode 100644 (file)
index 0000000..59e2c3c
--- /dev/null
@@ -0,0 +1,55 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        framecmn.cpp
+// Purpose:     common (for all platforms) wxFrame functions
+// Author:      Julian Smart, Vadim Zeitlin
+// Created:     01/02/97
+// Id:
+// Copyright:   (c) 1998 Robert Roebling, Julian Smart and Markus Holzem
+// Licence:     wxWindows licence
+/////////////////////////////////////////////////////////////////////////////
+
+void wxFrame::OnIdle(wxIdleEvent& event)
+{
+  DoMenuUpdates();
+}
+
+// update all menus
+void wxFrame::DoMenuUpdates()
+{
+  wxMenuBar* bar = GetMenuBar();
+  if ( bar != NULL ) {
+    int nCount = bar->GetMenuCount();
+    for (int n = 0; n < nCount; n++)
+      DoMenuUpdates(bar->GetMenu(n));
+  }
+}
+
+// update a menu and all submenus recursively
+void wxFrame::DoMenuUpdates(wxMenu* menu)
+{
+  wxNode* node = menu->GetItems().First();
+  while (node)
+  {
+    wxMenuItem* item = (wxMenuItem*) node->Data();
+    if ( !item->IsSeparator() )
+    {
+      wxWindowID id = item->GetId();
+      wxUpdateUIEvent event(id);
+      event.SetEventObject( this );
+
+      if (GetEventHandler()->ProcessEvent(event))
+      {
+        if (event.GetSetText())
+          menu->SetLabel(id, event.GetText());
+        if (event.GetSetChecked())
+          menu->Check(id, event.GetChecked());
+        if (event.GetSetEnabled())
+          menu->Enable(id, event.GetEnabled());
+      }
+
+      if (item->GetSubMenu())
+        DoMenuUpdates(item->GetSubMenu());
+    }
+    node = node->Next();
+  }
+}