]> git.saurik.com Git - wxWidgets.git/blobdiff - src/mac/app.cpp
Up-ported code to make tree item visible when programmatically
[wxWidgets.git] / src / mac / app.cpp
index a11ff6db93eae87862f233e9e8d1d6f236e8cd3c..4e4699db1df73493cb160cbff05c14cf03ad546d 100644 (file)
@@ -13,6 +13,7 @@
 #pragma implementation "app.h"
 #endif
 
 #pragma implementation "app.h"
 #endif
 
+#include "wx/window.h"
 #include "wx/frame.h"
 #include "wx/app.h"
 #include "wx/utils.h"
 #include "wx/frame.h"
 #include "wx/app.h"
 #include "wx/utils.h"
@@ -20,6 +21,7 @@
 #include "wx/pen.h"
 #include "wx/brush.h"
 #include "wx/cursor.h"
 #include "wx/pen.h"
 #include "wx/brush.h"
 #include "wx/cursor.h"
+#include "wx/intl.h"
 #include "wx/icon.h"
 #include "wx/palette.h"
 #include "wx/dc.h"
 #include "wx/icon.h"
 #include "wx/palette.h"
 #include "wx/dc.h"
@@ -29,6 +31,7 @@
 #include "wx/module.h"
 #include "wx/memory.h"
 #include "wx/tooltip.h"
 #include "wx/module.h"
 #include "wx/memory.h"
 #include "wx/tooltip.h"
+#include "wx/menu.h"
 #if wxUSE_WX_RESOURCES
 #include "wx/resource.h"
 #endif
 #if wxUSE_WX_RESOURCES
 #include "wx/resource.h"
 #endif
 
 // mac
 
 
 // mac
 
-#if __option(profile)
+#ifndef __UNIX__
+  #if __option(profile)
        #include <profiler.h>
        #include <profiler.h>
+  #endif
 #endif
 
 #include "apprsrc.h"
 
 #endif
 
 #include "apprsrc.h"
 
-#include <wx/mac/uma.h>
-#include <wx/mac/macnotfy.h>
+#include "wx/mac/uma.h"
+#include "wx/mac/macnotfy.h"
 
 #if wxUSE_SOCKETS
 
 #if wxUSE_SOCKETS
-#include <OpenTransport.h>
-#include <OpenTptInternet.h>
+    #ifdef __APPLE__
+        #include <CoreServices/CoreServices.h>
+    #else
+        #include <OpenTransport.h>
+        #include <OpenTptInternet.h>
+    #endif
 #endif
 
 extern char *wxBuffer;
 #endif
 
 extern char *wxBuffer;
@@ -86,31 +95,47 @@ bool wxApp::s_macSupportPCMenuShortcuts = true ;
 long wxApp::s_macAboutMenuItemId = wxID_ABOUT ;
 wxString wxApp::s_macHelpMenuTitleName = "&Help" ;
 
 long wxApp::s_macAboutMenuItemId = wxID_ABOUT ;
 wxString wxApp::s_macHelpMenuTitleName = "&Help" ;
 
+#if defined(UNIVERSAL_INTERFACES_VERSION) && (UNIVERSAL_INTERFACES_VERSION >= 0x0340)
+pascal OSErr AEHandleODoc( const AppleEvent *event , AppleEvent *reply , long refcon )
+#else
 pascal OSErr AEHandleODoc( const AppleEvent *event , AppleEvent *reply , unsigned long refcon )
 pascal OSErr AEHandleODoc( const AppleEvent *event , AppleEvent *reply , unsigned long refcon )
+#endif
 {
        wxApp* app = (wxApp*) refcon ;
 {
        wxApp* app = (wxApp*) refcon ;
-       return wxTheApp->MacHandleAEODoc( event , reply) ;
+       return wxTheApp->MacHandleAEODoc( (AppleEvent*) event , reply) ;
 }
 
 }
 
+#if defined(UNIVERSAL_INTERFACES_VERSION) && (UNIVERSAL_INTERFACES_VERSION >= 0x0340)
+pascal OSErr AEHandleOApp( const AppleEvent *event , AppleEvent *reply , long refcon )
+#else
 pascal OSErr AEHandleOApp( const AppleEvent *event , AppleEvent *reply , unsigned long refcon )
 pascal OSErr AEHandleOApp( const AppleEvent *event , AppleEvent *reply , unsigned long refcon )
+#endif
 {
        wxApp* app = (wxApp*) refcon ;
 {
        wxApp* app = (wxApp*) refcon ;
-       return wxTheApp->MacHandleAEOApp( event , reply ) ;
+       return wxTheApp->MacHandleAEOApp( (AppleEvent*) event , reply ) ;
 }
 
 }
 
+#if defined(UNIVERSAL_INTERFACES_VERSION) && (UNIVERSAL_INTERFACES_VERSION >= 0x0340)
+pascal OSErr AEHandlePDoc( const AppleEvent *event , AppleEvent *reply , long refcon )
+#else
 pascal OSErr AEHandlePDoc( const AppleEvent *event , AppleEvent *reply , unsigned long refcon )
 pascal OSErr AEHandlePDoc( const AppleEvent *event , AppleEvent *reply , unsigned long refcon )
+#endif
 {
        wxApp* app = (wxApp*) refcon ;
 {
        wxApp* app = (wxApp*) refcon ;
-       return wxTheApp->MacHandleAEPDoc( event , reply ) ;
+       return wxTheApp->MacHandleAEPDoc( (AppleEvent*) event , reply ) ;
 }
 
 }
 
+#if defined(UNIVERSAL_INTERFACES_VERSION) && (UNIVERSAL_INTERFACES_VERSION >= 0x0340)
+pascal OSErr AEHandleQuit( const AppleEvent *event , AppleEvent *reply , long refcon )
+#else
 pascal OSErr AEHandleQuit( const AppleEvent *event , AppleEvent *reply , unsigned long refcon )
 pascal OSErr AEHandleQuit( const AppleEvent *event , AppleEvent *reply , unsigned long refcon )
+#endif
 {
        wxApp* app = (wxApp*) refcon ;
 {
        wxApp* app = (wxApp*) refcon ;
-       return wxTheApp->MacHandleAEQuit( event , reply) ;
+       return wxTheApp->MacHandleAEQuit( (AppleEvent*) event , reply) ;
 }
 
 }
 
-OSErr wxApp::MacHandleAEODoc(AppleEvent *event , AppleEvent *reply)
+OSErr wxApp::MacHandleAEODoc(const AppleEvent *event , AppleEvent *reply)
 {
        ProcessSerialNumber PSN ;
        PSN.highLongOfPSN = 0 ;
 {
        ProcessSerialNumber PSN ;
        PSN.highLongOfPSN = 0 ;
@@ -119,17 +144,17 @@ OSErr wxApp::MacHandleAEODoc(AppleEvent *event , AppleEvent *reply)
        return noErr ;
 }
 
        return noErr ;
 }
 
-OSErr wxApp::MacHandleAEPDoc(AppleEvent *event , AppleEvent *reply)
+OSErr wxApp::MacHandleAEPDoc(const AppleEvent *event , AppleEvent *reply)
 {
        return noErr ;
 }
 
 {
        return noErr ;
 }
 
-OSErr wxApp::MacHandleAEOApp(AppleEvent *event , AppleEvent *reply)
+OSErr wxApp::MacHandleAEOApp(const AppleEvent *event , AppleEvent *reply)
 {
        return noErr ;
 }
 
 {
        return noErr ;
 }
 
-OSErr wxApp::MacHandleAEQuit(AppleEvent *event , AppleEvent *reply)
+OSErr wxApp::MacHandleAEQuit(const AppleEvent *event , AppleEvent *reply)
 {
        wxWindow* win = GetTopWindow() ;
        if ( win )
 {
        wxWindow* win = GetTopWindow() ;
        if ( win )
@@ -325,18 +350,36 @@ bool wxApp::Initialize()
   // Mac-specific
 
   UMAInitToolbox( 4 ) ;
   // Mac-specific
 
   UMAInitToolbox( 4 ) ;
+  SetEventMask( everyEvent ) ;
        UMAShowWatchCursor() ;
 
        UMAShowWatchCursor() ;
 
-       AEInstallEventHandler( kCoreEventClass , kAEOpenDocuments , NewAEEventHandlerProc(AEHandleODoc) , (long) wxTheApp , FALSE ) ;
-       AEInstallEventHandler( kCoreEventClass , kAEOpenApplication , NewAEEventHandlerProc(AEHandleOApp) , (long) wxTheApp , FALSE ) ;
-       AEInstallEventHandler( kCoreEventClass , kAEPrintDocuments , NewAEEventHandlerProc(AEHandlePDoc) , (long) wxTheApp , FALSE ) ;
-       AEInstallEventHandler( kCoreEventClass , kAEQuitApplication , NewAEEventHandlerProc(AEHandleQuit) , (long) wxTheApp  , FALSE ) ;
+#if defined(UNIVERSAL_INTERFACES_VERSION) && (UNIVERSAL_INTERFACES_VERSION >= 0x0340)
+    AEInstallEventHandler( kCoreEventClass , kAEOpenDocuments ,   NewAEEventHandlerUPP(AEHandleODoc) ,
+                           (long) wxTheApp , FALSE ) ;
+    AEInstallEventHandler( kCoreEventClass , kAEOpenApplication , NewAEEventHandlerUPP(AEHandleOApp) ,
+                           (long) wxTheApp , FALSE ) ;
+    AEInstallEventHandler( kCoreEventClass , kAEPrintDocuments ,  NewAEEventHandlerUPP(AEHandlePDoc) ,
+                           (long) wxTheApp , FALSE ) ;
+    AEInstallEventHandler( kCoreEventClass , kAEQuitApplication , NewAEEventHandlerUPP(AEHandleQuit) ,
+                           (long) wxTheApp , FALSE ) ;
+#else
+       AEInstallEventHandler( kCoreEventClass , kAEOpenDocuments ,   NewAEEventHandlerProc(AEHandleODoc) ,
+                              (long) wxTheApp , FALSE ) ;
+       AEInstallEventHandler( kCoreEventClass , kAEOpenApplication , NewAEEventHandlerProc(AEHandleOApp) ,
+                              (long) wxTheApp , FALSE ) ;
+       AEInstallEventHandler( kCoreEventClass , kAEPrintDocuments ,  NewAEEventHandlerProc(AEHandlePDoc) ,
+                              (long) wxTheApp , FALSE ) ;
+       AEInstallEventHandler( kCoreEventClass , kAEQuitApplication , NewAEEventHandlerProc(AEHandleQuit) ,
+                              (long) wxTheApp , FALSE ) ;
+#endif
 
 
 
 
+#ifndef __UNIX__
   // test the minimal configuration necessary
 
   // test the minimal configuration necessary
 
+       #if !TARGET_CARBON
        long theSystem ;
        long theSystem ;
-       long theMachine;
+       long theMachine; 
 
        if (Gestalt(gestaltMachineType, &theMachine) != noErr)
        {
 
        if (Gestalt(gestaltMachineType, &theMachine) != noErr)
        {
@@ -354,7 +397,6 @@ bool wxApp::Initialize()
        {
                error = kMacSTROldSystem  ;
        }
        {
                error = kMacSTROldSystem  ;
        }
-       #if !TARGET_CARBON
        else if ((long)GetApplLimit() - (long)ApplicationZone() < kMacMinHeap)
        {
                error = kMacSTRSmallSize;
        else if ((long)GetApplLimit() - (long)ApplicationZone() < kMacMinHeap)
        {
                error = kMacSTRSmallSize;
@@ -369,6 +411,7 @@ bool wxApp::Initialize()
                }
        }
        */
                }
        }
        */
+#endif
 
        // if we encountered any problems so far, give the error code and exit immediately
 
 
        // if we encountered any problems so far, give the error code and exit immediately
 
@@ -384,13 +427,17 @@ bool wxApp::Initialize()
          return FALSE ;
   }
 
          return FALSE ;
   }
 
-#if __option(profile)
+#ifndef __UNIX__
+  #if __option(profile)
        ProfilerInit( collectDetailed, bestTimeBase , 20000 , 40 ) ;
        ProfilerInit( collectDetailed, bestTimeBase , 20000 , 40 ) ;
+  #endif
 #endif
 
   // now avoid exceptions thrown for new (bad_alloc)
 
 #endif
 
   // now avoid exceptions thrown for new (bad_alloc)
 
+#ifndef __UNIX__
   std::__throws_bad_alloc = FALSE ;
   std::__throws_bad_alloc = FALSE ;
+#endif
 
        s_macCursorRgn = ::NewRgn() ;
 
 
        s_macCursorRgn = ::NewRgn() ;
 
@@ -412,6 +459,19 @@ bool wxApp::Initialize()
   wxTheColourDatabase = new wxColourDatabase(wxKEY_STRING);
   wxTheColourDatabase->Initialize();
 
   wxTheColourDatabase = new wxColourDatabase(wxKEY_STRING);
   wxTheColourDatabase->Initialize();
 
+#ifdef __WXDEBUG__
+#if wxUSE_LOG
+    // flush the logged messages if any and install a 'safer' log target: the
+    // default one (wxLogGui) can't be used after the resources are freed just
+    // below and the user suppliedo ne might be even more unsafe (using any
+    // wxWindows GUI function is unsafe starting from now)
+    wxLog::DontCreateOnDemand();
+
+    // this will flush the old messages if any
+    delete wxLog::SetActiveTarget(new wxLogStderr);
+#endif // wxUSE_LOG
+#endif
+
   wxInitializeStockLists();
   wxInitializeStockObjects();
 
   wxInitializeStockLists();
   wxInitializeStockObjects();
 
@@ -422,8 +482,9 @@ bool wxApp::Initialize()
   wxBitmap::InitStandardHandlers();
 
   wxModule::RegisterModules();
   wxBitmap::InitStandardHandlers();
 
   wxModule::RegisterModules();
-  if (!wxModule::InitializeModules())
+  if (!wxModule::InitializeModules()) {
      return FALSE;
      return FALSE;
+  }
 
   wxWinMacWindowList = new wxList(wxKEY_INTEGER);
   wxWinMacControlList = new wxList(wxKEY_INTEGER);
 
   wxWinMacWindowList = new wxList(wxKEY_INTEGER);
   wxWinMacControlList = new wxList(wxKEY_INTEGER);
@@ -483,9 +544,11 @@ void wxApp::CleanUp()
 
   wxClassInfo::CleanUpClasses();
 
 
   wxClassInfo::CleanUpClasses();
 
-#if __option(profile)
-       ProfilerDump( "\papp.prof" ) ;
-       ProfilerTerm() ;
+#ifndef __UNIX__
+  #if __option(profile)
+  ProfilerDump( "\papp.prof" ) ;
+  ProfilerTerm() ;
+  #endif
 #endif
 
   delete wxTheApp;
 #endif
 
   delete wxTheApp;
@@ -510,6 +573,7 @@ void wxApp::CleanUp()
     delete wxLog::SetActiveTarget(NULL);
 #endif // wxUSE_LOG
 
     delete wxLog::SetActiveTarget(NULL);
 #endif // wxUSE_LOG
 
+       UMACleanupToolbox() ;
        if (s_macCursorRgn)
                ::DisposeRgn(s_macCursorRgn);
 
        if (s_macCursorRgn)
                ::DisposeRgn(s_macCursorRgn);
 
@@ -531,8 +595,9 @@ int wxEntry( int argc, char *argv[] , bool enterLoop )
     wxDebugContext::SetCheckpoint();
 #endif
 #endif
     wxDebugContext::SetCheckpoint();
 #endif
 #endif
-    if (!wxApp::Initialize())
+    if (!wxApp::Initialize()) {
         return 0;
         return 0;
+    }
    // create the application object or ensure that one already exists
     if (!wxTheApp)
     {
    // create the application object or ensure that one already exists
     if (!wxTheApp)
     {
@@ -600,7 +665,7 @@ int wxEntry( int argc, char *argv[] , bool enterLoop )
        wxApp::CleanUp();
        
        return retValue;
        wxApp::CleanUp();
        
        return retValue;
-};
+}
 
 // Static member initialization
 wxAppInitializerFunction wxAppBase::m_appInitFn = (wxAppInitializerFunction) NULL;
 
 // Static member initialization
 wxAppInitializerFunction wxAppBase::m_appInitFn = (wxAppInitializerFunction) NULL;
@@ -820,22 +885,46 @@ void wxCYield()
 }
 
 // Yield to other processes
 }
 
 // Yield to other processes
+
+static bool gs_inYield = FALSE;
+
 bool wxYield()
 {
 bool wxYield()
 {
+#ifdef __WXDEBUG__    
+    if (gs_inYield)
+        wxFAIL_MSG( wxT("wxYield called recursively" ) );
+#endif
+
+    gs_inYield = TRUE;
+    
 #if wxUSE_THREADS
 #if wxUSE_THREADS
-  YieldToAnyThread() ;
+    YieldToAnyThread() ;
 #endif
 #endif
-  EventRecord event ;
+    EventRecord event ;
 
 
-       long sleepTime = 0 ; //::GetCaretTime();
+       long sleepTime = 1 ; //::GetCaretTime();
 
        while ( !wxTheApp->IsExiting() && WaitNextEvent(everyEvent, &event,sleepTime, wxApp::s_macCursorRgn))
        {
        wxTheApp->MacHandleOneEvent( &event );
 
        while ( !wxTheApp->IsExiting() && WaitNextEvent(everyEvent, &event,sleepTime, wxApp::s_macCursorRgn))
        {
        wxTheApp->MacHandleOneEvent( &event );
+           if ( event.what != kHighLevelEvent )
+                   SetRectRgn( wxApp::s_macCursorRgn , event.where.h , event.where.v ,  event.where.h + 1 , event.where.v + 1 ) ;
        }
 
        wxMacProcessNotifierAndPendingEvents() ;
        }
 
        wxMacProcessNotifierAndPendingEvents() ;
-  return TRUE;
+
+    gs_inYield = FALSE;
+    
+    return TRUE;
+}
+
+// Yield to incoming messages; but fail silently if recursion is detected.
+bool wxYieldIfNeeded()
+{
+    if (gs_inYield)
+        return FALSE;
+        
+    return wxYield();
 }
 
 // platform specifics
 }
 
 // platform specifics
@@ -880,7 +969,7 @@ void wxApp::MacDoOneEvent()
 {
   EventRecord event ;
 
 {
   EventRecord event ;
 
-       long sleepTime = ::GetCaretTime();
+       long sleepTime = 1 ; // GetCaretTime() / 4 ;
 
        if (WaitNextEvent(everyEvent, &event,sleepTime, s_macCursorRgn))
        {
 
        if (WaitNextEvent(everyEvent, &event,sleepTime, s_macCursorRgn))
        {
@@ -896,10 +985,11 @@ void wxApp::MacDoOneEvent()
                wxTheApp->ProcessIdle() ;
        }
        if ( event.what != kHighLevelEvent )
                wxTheApp->ProcessIdle() ;
        }
        if ( event.what != kHighLevelEvent )
-               SetRectRgn( s_macCursorRgn , event.where.h - 1 , event.where.v - 1,  event.where.h + 1 , event.where.v + 1 ) ;
+               SetRectRgn( s_macCursorRgn , event.where.h , event.where.v ,  event.where.h + 1 , event.where.v + 1 ) ;
 
        // repeaters
 
 
        // repeaters
 
+  DeletePendingObjects() ;
        wxMacProcessNotifierAndPendingEvents() ;
 }
 
        wxMacProcessNotifierAndPendingEvents() ;
 }
 
@@ -977,6 +1067,8 @@ void wxApp::MacHandleMouseDownEvent( EventRecord *ev )
 
        short windowPart = ::FindWindow(ev->where, &window);
        wxWindow* win = wxFindWinFromMacWindow( window ) ;
 
        short windowPart = ::FindWindow(ev->where, &window);
        wxWindow* win = wxFindWinFromMacWindow( window ) ;
+    if ( wxPendingDelete.Member(win) )
+        return ;
 
        BitMap screenBits;
        GetQDGlobalsScreenBits( &screenBits );
 
        BitMap screenBits;
        GetQDGlobalsScreenBits( &screenBits );
@@ -1037,6 +1129,7 @@ void wxApp::MacHandleMouseDownEvent( EventRecord *ev )
                        s_lastMouseDown = 0;
                        break;
                case inGrow:
                        s_lastMouseDown = 0;
                        break;
                case inGrow:
+                 {
                                int growResult = GrowWindow(window , ev->where, &screenBits.bounds);
                                if (growResult != 0)
                                {
                                int growResult = GrowWindow(window , ev->where, &screenBits.bounds);
                                if (growResult != 0)
                                {
@@ -1044,16 +1137,19 @@ void wxApp::MacHandleMouseDownEvent( EventRecord *ev )
                                        int newHeight = HiWord(growResult);
                                        int oldWidth, oldHeight;
 
                                        int newHeight = HiWord(growResult);
                                        int oldWidth, oldHeight;
 
-                                       win->GetSize(&oldWidth, &oldHeight);
-                                       if (newWidth == 0)
-                                               newWidth = oldWidth;
-                                       if (newHeight == 0)
-                                               newHeight = oldHeight;
 
                                        if (win)
 
                                        if (win)
+                                       {
+                                               win->GetSize(&oldWidth, &oldHeight);
+                                               if (newWidth == 0)
+                                                       newWidth = oldWidth;
+                                               if (newHeight == 0)
+                                                       newHeight = oldHeight;
                                                win->SetSize( -1, -1, newWidth, newHeight, wxSIZE_USE_EXISTING);
                                                win->SetSize( -1, -1, newWidth, newHeight, wxSIZE_USE_EXISTING);
+                                       }
                                }
                                s_lastMouseDown = 0;
                                }
                                s_lastMouseDown = 0;
+                 }
                        break;
                case inZoomIn:
                case inZoomOut:
                        break;
                case inZoomIn:
                case inZoomOut:
@@ -1089,7 +1185,7 @@ void wxApp::MacHandleMouseDownEvent( EventRecord *ev )
                                        SetOrigin( 0 , 0 ) ;
                                        SetPort( port ) ;
                                }
                                        SetOrigin( 0 , 0 ) ;
                                        SetPort( port ) ;
                                }
-                               if ( window != frontWindow )
+                               if ( window != frontWindow && wxTheApp->s_captureWindow == NULL )
                                {
                                        if ( s_macIsInModalLoop )
                                        {
                                {
                                        if ( s_macIsInModalLoop )
                                        {
@@ -1102,6 +1198,8 @@ void wxApp::MacHandleMouseDownEvent( EventRecord *ev )
                                        }
                                        else
                                        {
                                        }
                                        else
                                        {
+                                               if ( win )
+                                                       win->MacMouseDown( ev , windowPart ) ;
                                                UMASelectWindow( window ) ;
                                        }
                                }
                                                UMASelectWindow( window ) ;
                                        }
                                }
@@ -1253,7 +1351,10 @@ void wxApp::MacHandleKeyDownEvent( EventRecord *ev )
        
        UInt32 menuresult = UMAMenuEvent(ev) ;
        if ( HiWord( menuresult ) )
        
        UInt32 menuresult = UMAMenuEvent(ev) ;
        if ( HiWord( menuresult ) )
+       {
+               if ( !s_macIsInModalLoop )
                MacHandleMenuSelect( HiWord( menuresult ) , LoWord( menuresult ) ) ;
                MacHandleMenuSelect( HiWord( menuresult ) , LoWord( menuresult ) ) ;
+       }
        else
        {
                short keycode ;
        else
        {
                short keycode ;
@@ -1343,7 +1444,37 @@ void wxApp::MacHandleKeyDownEvent( EventRecord *ev )
 
 void wxApp::MacHandleKeyUpEvent( EventRecord *ev )
 {
 
 void wxApp::MacHandleKeyUpEvent( EventRecord *ev )
 {
-       // nothing to do
+       wxToolTip::RemoveToolTips() ;
+       
+       UInt32 menuresult = UMAMenuEvent(ev) ;
+       if ( HiWord( menuresult ) )
+       {
+       }
+       else
+       {
+               short keycode ;
+               short keychar ;
+               keychar = short(ev->message & charCodeMask);
+               keycode = short(ev->message & keyCodeMask) >> 8 ;
+
+               wxWindow* focus = wxWindow::FindFocus() ;
+               if ( focus )
+               {
+                       long keyval = wxMacTranslateKey(keychar, keycode) ;
+                       
+                       wxKeyEvent event(wxEVT_KEY_UP);
+                       event.m_shiftDown = ev->modifiers & shiftKey;
+                       event.m_controlDown = ev->modifiers & controlKey;
+                       event.m_altDown = ev->modifiers & optionKey;
+                       event.m_metaDown = ev->modifiers & cmdKey;
+                       event.m_keyCode = keyval;
+                       event.m_x = ev->where.h;
+                       event.m_y = ev->where.v;
+                       event.m_timeStamp = ev->when;
+                       event.SetEventObject(focus);
+                       bool handled = focus->GetEventHandler()->ProcessEvent( event ) ;
+               }
+       }
 }
 
 void wxApp::MacHandleActivateEvent( EventRecord *ev )
 }
 
 void wxApp::MacHandleActivateEvent( EventRecord *ev )
@@ -1371,7 +1502,16 @@ void wxApp::MacHandleUpdateEvent( EventRecord *ev )
        wxWindow * win = wxFindWinFromMacWindow( window ) ;
        if ( win )
        {
        wxWindow * win = wxFindWinFromMacWindow( window ) ;
        if ( win )
        {
-               win->MacUpdate( ev ) ;
+        if ( !wxPendingDelete.Member(win) )
+                       win->MacUpdate( ev ) ;
+       }
+       else
+       {
+               // since there is no way of telling this foreign window to update itself
+               // we have to invalidate the update region otherwise we keep getting the same
+               // event over and over again
+               BeginUpdate( window ) ;
+               EndUpdate( window ) ;
        }
 }
 
        }
 }
 
@@ -1397,7 +1537,11 @@ void wxApp::MacHandleOSEvent( EventRecord *ev )
                case suspendResumeMessage :
                        {
                                bool isResuming = ev->message & resumeFlag ;
                case suspendResumeMessage :
                        {
                                bool isResuming = ev->message & resumeFlag ;
+#if !TARGET_CARBON
                                bool convertClipboard = ev->message & convertClipboardFlag ;
                                bool convertClipboard = ev->message & convertClipboardFlag ;
+#else
+                               bool convertClipboard = false;
+#endif
                                bool doesActivate = UMAGetProcessModeDoesActivateOnFGSwitch() ;
                                if ( isResuming )
                                {
                                bool doesActivate = UMAGetProcessModeDoesActivateOnFGSwitch() ;
                                if ( isResuming )
                                {
@@ -1450,7 +1594,8 @@ void wxApp::MacHandleOSEvent( EventRecord *ev )
 
                                wxWindow* currentMouseWindow = NULL ;
 
 
                                wxWindow* currentMouseWindow = NULL ;
 
-                               MacGetWindowFromPoint( wxPoint( ev->where.h , ev->where.v ) , &currentMouseWindow ) ;
+                               wxWindow::MacGetWindowFromPoint( wxPoint( ev->where.h , ev->where.v ) ,
+                                                                                                &currentMouseWindow ) ;
 
                                if ( currentMouseWindow != wxWindow::s_lastMouseWindow )
                                {
 
                                if ( currentMouseWindow != wxWindow::s_lastMouseWindow )
                                {
@@ -1490,9 +1635,12 @@ void wxApp::MacHandleOSEvent( EventRecord *ev )
 
                                switch (windowPart)
                                {
 
                                switch (windowPart)
                                {
+                                       // fixes for setting the cursor back from dominic mazzoni
                                        case inMenuBar :
                                        case inMenuBar :
+                                           UMAShowArrowCursor();
                                                break ;
                                        case inSysWindow :
                                                break ;
                                        case inSysWindow :
+                                           UMAShowArrowCursor();
                                                break ;
                                        default:
                                                {
                                                break ;
                                        default:
                                                {
@@ -1502,6 +1650,9 @@ void wxApp::MacHandleOSEvent( EventRecord *ev )
                                                        wxWindow* win = wxFindWinFromMacWindow( window ) ;
                                                        if ( win )
                                                                win->MacMouseMoved( ev , windowPart ) ;
                                                        wxWindow* win = wxFindWinFromMacWindow( window ) ;
                                                        if ( win )
                                                                win->MacMouseMoved( ev , windowPart ) ;
+                                                       else                                       
+                                                       UMAShowArrowCursor();
+
                                                }
                                                break;
                                }
                                                }
                                                break;
                                }