]> git.saurik.com Git - wxWidgets.git/blobdiff - src/mac/frame.cpp
some != NULL checks
[wxWidgets.git] / src / mac / frame.cpp
index 6e980623227a8a9dff1ef80b47f26d6a7e8805c6..cded59c604887d003c26c948ada38447adf10940 100644 (file)
@@ -28,7 +28,6 @@
 extern wxList wxModelessWindows;
 extern wxList wxPendingDelete;
 
-#if !USE_SHARED_LIBRARY
 BEGIN_EVENT_TABLE(wxFrame, wxWindow)
   EVT_SIZE(wxFrame::OnSize)
   EVT_ACTIVATE(wxFrame::OnActivate)
@@ -39,7 +38,6 @@ BEGIN_EVENT_TABLE(wxFrame, wxWindow)
 END_EVENT_TABLE()
 
 IMPLEMENT_DYNAMIC_CLASS(wxFrame, wxWindow)
-#endif
 
 #if wxUSE_NATIVE_STATUSBAR
 bool wxFrame::m_useNativeStatusBar = TRUE;
@@ -341,6 +339,56 @@ void wxFrame::OnSysColourChanged(wxSysColourChangedEvent& event)
 
 // Default resizing behaviour - if only ONE subwindow,
 // resize to client rectangle size
+void wxFrame::OnIdle(wxIdleEvent& WXUNUSED(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), (wxWindow*) NULL);
+    }
+}
+
+// update a menu and all submenus recursively
+void wxFrame::DoMenuUpdates(wxMenu* menu, wxWindow* WXUNUSED(focusWin))
+{
+    wxEvtHandler* evtHandler = GetEventHandler();
+    wxMenuItemList::Node* node = menu->GetMenuItems().GetFirst();
+    while (node)
+    {
+        wxMenuItem* item = node->GetData();
+        if ( !item->IsSeparator() )
+        {
+            wxWindowID id = item->GetId();
+            wxUpdateUIEvent event(id);
+            event.SetEventObject( this );
+
+            if (evtHandler->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(), (wxWindow*) NULL);
+        }
+        node = node->GetNext();
+    }
+}
+
 void wxFrame::OnSize(wxSizeEvent& event)
 {
   // if we're using constraints - do use them