]> git.saurik.com Git - wxWidgets.git/blobdiff - src/mac/app.cpp
GTK_TOOLBAR_BOTH_HORIZ is GTK 2 only (it would have been nice if the patch mentioned...
[wxWidgets.git] / src / mac / app.cpp
index e1e9dba92243d3b7e988bdc3f891a1c8333ba1ec..04f3eee3b5bdde44b4d312b43e340a6b35eede28 100644 (file)
@@ -288,6 +288,9 @@ void wxApp::MacNewFile()
         { kEventClassCommand, kEventProcessCommand } ,
         { kEventClassCommand, kEventCommandUpdateStatus } ,
 
+        { kEventClassMenu, kEventMenuOpening },
+        { kEventClassMenu, kEventMenuClosed },
+
         { kEventClassApplication , kEventAppActivated } ,
         { kEventClassApplication , kEventAppDeactivated } ,
         // handling the quit event is not recommended by apple
@@ -299,9 +302,35 @@ void wxApp::MacNewFile()
         { 'WXMC' , 'WXMC' }
     } ;
 
-static pascal OSStatus MenuEventHandler( EventHandlerCallRef handler , EventRef event , void *data )
+static pascal OSStatus
+MenuEventHandler( EventHandlerCallRef handler , EventRef event , void *data )
 {
-    return eventNotHandledErr ;
+    // FIXME: this doesn't work for multiple windows
+    wxWindow *win = wxTheApp->GetTopWindow();
+    if ( win )
+    {
+        // VZ: we could find the menu from its handle here by examining all
+        //     the menus in the menu bar recursively but knowing that neither
+        //     wxMSW nor wxGTK do it why bother...
+#if 0
+        MenuRef menuRef;
+
+        GetEventParameter(event,
+                          kEventParamDirectObject,
+                          typeMenuRef, NULL,
+                          sizeof(menuRef), NULL,
+                          &menuRef);
+#endif // 0
+
+        wxMenuEvent event(GetEventKind(event) == kEventMenuOpening
+                        ? wxEVT_MENU_OPEN
+                        : wxEVT_MENU_CLOSE);
+        event.SetEventObject(win);
+
+        (void)win->GetEventHandler()->ProcessEvent(event);
+    }
+
+    return eventNotHandledErr;
 }
 
 // due to the rather low-level event API of wxWindows, we cannot use RunApplicationEventLoop
@@ -971,18 +1000,6 @@ int wxApp::MainLoop()
     return 0;
 }
 
-// Returns TRUE if more time is needed.
-bool wxApp::ProcessIdle()
-{
-    wxIdleEvent event;
-    event.SetEventObject(this);
-    ProcessEvent(event);
-
-    wxUpdateUIEvent::ResetUpdateTime();
-    
-    return event.MoreRequested();
-}
-
 void wxApp::ExitMainLoop()
 {
       m_keepGoing = FALSE;
@@ -996,7 +1013,7 @@ bool wxApp::Pending()
 #else
     EventRecord event ;
 
-      return EventAvail( everyEvent , &event ) ;
+    return EventAvail( everyEvent , &event ) ;
 #endif
 }
 
@@ -1044,46 +1061,6 @@ void wxApp::WakeUpIdle()
     wxMacWakeUp() ;
 }
 
-// Send idle event to all top-level windows
-bool wxApp::SendIdleEvents()
-{
-    bool needMore = FALSE;
-    wxWindowListNode* node = wxTopLevelWindows.GetFirst();
-    while (node)
-    {
-        wxWindow* win = node->GetData();
-        if (SendIdleEvents(win))
-            needMore = TRUE;
-
-        node = node->GetNext();
-    }
-    return needMore;
-}
-
-// Send idle event to window and all subwindows
-bool wxApp::SendIdleEvents(wxWindow* win)
-{
-    bool needMore = FALSE;
-
-    wxIdleEvent event;
-    event.SetEventObject(win);
-    win->ProcessEvent(event);
-
-    if (event.MoreRequested())
-        needMore = TRUE;
-
-    wxWindowListNode* node = win->GetChildren().GetFirst();
-    while (node)
-    {
-        wxWindow* win = node->GetData();
-        if (SendIdleEvents(win))
-            needMore = TRUE;
-
-        node = node->GetNext();
-    }
-    return needMore ;
-}
-
 void wxApp::Exit()
 {
     wxApp::CleanUp();