]> git.saurik.com Git - wxWidgets.git/blobdiff - src/mac/carbon/app.cpp
docs and example for wxDC::DrawPolyPolygon() (patch 882189)
[wxWidgets.git] / src / mac / carbon / app.cpp
index 42e2c0aba8a650105bbe87cbc893b1e841c57695..613c323b92f3c4d9bf2533d9915348f8f2f6a61a 100644 (file)
@@ -231,12 +231,14 @@ short wxApp::MacHandleAEOApp(const WXEVENTREF WXUNUSED(event) , WXEVENTREF WXUNU
 
 short wxApp::MacHandleAEQuit(const WXEVENTREF WXUNUSED(event) , WXEVENTREF WXUNUSED(reply))
 {
-       wxWindow* win = GetTopWindow() ;
+    wxWindow* win = GetTopWindow() ;
     if ( win )
     {
-        win->Close(TRUE ) ;
+        wxCommandEvent exitEvent(wxEVT_COMMAND_MENU_SELECTED, s_macExitMenuItemId);
+        if (!win->ProcessEvent(exitEvent))
+            win->Close(TRUE ) ;
     }
-       else
+    else
     {
         ExitMainLoop() ;
     }
@@ -333,49 +335,53 @@ static pascal OSStatus
 MenuEventHandler( EventHandlerCallRef handler , EventRef event , void *data )
 {
     wxMenuBar* mbar = wxMenuBar::MacGetInstalledMenuBar();
-    wxFrame* win = mbar->GetFrame();
     
-    if ( win )
+    if ( mbar )
     {
-        // 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
-
-        wxEventType type=0;        
-        MenuCommand cmd=0;
-        switch (GetEventKind(event))
+        wxFrame* win = mbar->GetFrame();
+        if ( win )
         {
-            case kEventMenuOpening:
-                type = wxEVT_MENU_OPEN;
-                break;
-            case kEventMenuClosed:
-                type = wxEVT_MENU_CLOSE;
-                break;
-            case kEventMenuTargetItem:
-                type = wxEVT_MENU_HIGHLIGHT;
-                GetEventParameter(event, kEventParamMenuCommand,
-                                  typeMenuCommand, NULL,
-                                  sizeof(cmd), NULL, &cmd);
-                if (cmd == 0) return eventNotHandledErr;
-                break;
-            default:
-                wxFAIL_MSG(wxT("Unexpected menu event kind"));
-                break;
-        }
+            
+            // 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
+
+            wxEventType type=0;        
+            MenuCommand cmd=0;
+            switch (GetEventKind(event))
+            {
+                case kEventMenuOpening:
+                    type = wxEVT_MENU_OPEN;
+                    break;
+                case kEventMenuClosed:
+                    type = wxEVT_MENU_CLOSE;
+                    break;
+                case kEventMenuTargetItem:
+                    type = wxEVT_MENU_HIGHLIGHT;
+                    GetEventParameter(event, kEventParamMenuCommand,
+                                      typeMenuCommand, NULL,
+                                      sizeof(cmd), NULL, &cmd);
+                    if (cmd == 0) return eventNotHandledErr;
+                    break;
+                default:
+                    wxFAIL_MSG(wxT("Unexpected menu event kind"));
+                    break;
+            }
 
-        wxMenuEvent wxevent(type, cmd);
-        wxevent.SetEventObject(win);
+            wxMenuEvent wxevent(type, cmd);
+            wxevent.SetEventObject(win);
 
-        (void)win->GetEventHandler()->ProcessEvent(wxevent);
+            (void)win->GetEventHandler()->ProcessEvent(wxevent);
+        }
     }
 
     return eventNotHandledErr;
@@ -1100,7 +1106,10 @@ void wxApp::ExitMainLoop()
 bool wxApp::Pending()
 {
 #if TARGET_CARBON
-    return GetNumEventsInQueue( GetMainEventQueue() ) > 0 ;
+    // without the receive event (with pull param = false ) nothing is ever reported
+    EventRef theEvent;
+    ReceiveNextEvent (0, NULL, kEventDurationNoWait, false, &theEvent);
+    return GetNumEventsInQueue( GetMainEventQueue() ) > 0 ; 
 #else
     EventRecord event ;