]> git.saurik.com Git - wxWidgets.git/blobdiff - src/mac/app.cpp
moved 'show hidden dirs' checkbox elsewhere, the dialog was too wide for wxMGL
[wxWidgets.git] / src / mac / app.cpp
index 0257b8c6070640fad78cb421e475d6dd3ba6272f..8f08a5d67cab7181997d0a397a160fc64f8e2685 100644 (file)
@@ -13,6 +13,8 @@
 #pragma implementation "app.h"
 #endif
 
+#include "wx/defs.h"
+
 #include "wx/window.h"
 #include "wx/frame.h"
 #include "wx/button.h"
@@ -35,7 +37,7 @@
 #include "wx/textctrl.h"
 #include "wx/menu.h"
 #if wxUSE_WX_RESOURCES
-#include "wx/resource.h"
+#  include "wx/resource.h"
 #endif
 
 #include <string.h>
 #include "wx/mac/uma.h"
 #include "wx/mac/macnotfy.h"
 
-#if wxUSE_SOCKETS
-    #ifdef __DARWIN__
-        #include <CoreServices/CoreServices.h>
-    #else
-        #include <OpenTransport.h>
-        #include <OpenTptInternet.h>
-    #endif
+#ifdef __DARWIN__
+#  include <CoreServices/CoreServices.h>
+#else
+#  include <Sound.h>
+#  include <Threads.h>
+#  include <ToolUtils.h>
+#  include <DiskInit.h>
+#  include <Devices.h>
 #endif
 
 extern char *wxBuffer;
@@ -85,7 +88,7 @@ const short    kMacMinHeap = (29 * 1024) ;
 const short kwxMacMenuBarResource = 1 ;
 const short kwxMacAppleMenuId = 1 ;
 
-RgnHandle            wxApp::s_macCursorRgn = NULL;
+WXHRGN            wxApp::s_macCursorRgn = NULL;
 wxWindow*            wxApp::s_captureWindow = NULL ;
 int                    wxApp::s_lastMouseDown = 0 ;
 long                     wxApp::sm_lastMessageTime = 0;
@@ -125,7 +128,7 @@ pascal OSErr AEHandleQuit( const AppleEvent *event , AppleEvent *reply , long re
     return wxTheApp->MacHandleAEQuit( (AppleEvent*) event , reply) ;
 }
 
-OSErr wxApp::MacHandleAEODoc(const AppleEvent *event , AppleEvent *reply)
+short wxApp::MacHandleAEODoc(const WXEVENTREF event , WXEVENTREF reply)
 {
     SysBeep(40) ;
     ProcessSerialNumber PSN ;
@@ -135,17 +138,17 @@ OSErr wxApp::MacHandleAEODoc(const AppleEvent *event , AppleEvent *reply)
     return noErr ;
 }
 
-OSErr wxApp::MacHandleAEPDoc(const AppleEvent *event , AppleEvent *reply)
+short wxApp::MacHandleAEPDoc(const WXEVENTREF event , WXEVENTREF reply)
 {
     return noErr ;
 }
 
-OSErr wxApp::MacHandleAEOApp(const AppleEvent *event , AppleEvent *reply)
+short wxApp::MacHandleAEOApp(const WXEVENTREF event , WXEVENTREF reply)
 {
     return noErr ;
 }
 
-OSErr wxApp::MacHandleAEQuit(const AppleEvent *event , AppleEvent *reply)
+short wxApp::MacHandleAEQuit(const WXEVENTREF event , WXEVENTREF reply)
 {
     wxWindow* win = GetTopWindow() ;
     if ( win )
@@ -159,7 +162,7 @@ OSErr wxApp::MacHandleAEQuit(const AppleEvent *event , AppleEvent *reply)
     return noErr ;
 }
 
-char StringMac[] =     "\x0d\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f"
+char StringMac[] =  "\x0d\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f"
                     "\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f"
                     "\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xae\xaf"
                     "\xb1\xb4\xb5\xb6\xbb\xbc\xbe\xbf"
@@ -526,6 +529,7 @@ bool wxApp::Initialize()
 
 void wxApp::CleanUp()
 {
+    wxToolTip::RemoveToolTips() ;
 #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
@@ -563,6 +567,9 @@ void wxApp::CleanUp()
   if (wxWinMacWindowList)
     delete wxWinMacWindowList ;
 
+  if (wxWinMacControlList)
+    delete wxWinMacControlList ;
+
     delete wxPendingEvents;
 #if wxUSE_THREADS
     delete wxPendingEventsLocker;
@@ -603,7 +610,7 @@ void wxApp::CleanUp()
 
     UMACleanupToolbox() ;
     if (s_macCursorRgn)
-        ::DisposeRgn(s_macCursorRgn);
+        ::DisposeRgn((RgnHandle)s_macCursorRgn);
 
     #if 0
         TerminateAE() ;
@@ -958,11 +965,11 @@ bool wxApp::Yield(bool onlyIfNeeded)
 
     long sleepTime = 1 ; //::GetCaretTime();
 
-    while ( !wxTheApp->IsExiting() && WaitNextEvent(everyEvent, &event,sleepTime, wxApp::s_macCursorRgn))
+    while ( !wxTheApp->IsExiting() && WaitNextEvent(everyEvent, &event,sleepTime, (RgnHandle) 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 ) ;
+            SetRectRgn( (RgnHandle) wxApp::s_macCursorRgn , event.where.h , event.where.v ,  event.where.h + 1 , event.where.v + 1 ) ;
     }
 
     wxMacProcessNotifierAndPendingEvents() ;
@@ -1021,7 +1028,7 @@ void wxApp::MacDoOneEvent()
 
     long sleepTime = 1; // GetCaretTime() / 4 ;
 
-    if (WaitNextEvent(everyEvent, &event, sleepTime, s_macCursorRgn))
+    if (WaitNextEvent(everyEvent, &event, sleepTime, (RgnHandle) s_macCursorRgn))
     {
         MacHandleOneEvent( &event );
     }
@@ -1035,7 +1042,7 @@ void wxApp::MacDoOneEvent()
         wxTheApp->ProcessIdle() ;
     }
     if ( event.what != kHighLevelEvent )
-        SetRectRgn( s_macCursorRgn , event.where.h , event.where.v ,  event.where.h + 1 , event.where.v + 1 ) ;
+        SetRectRgn( (RgnHandle) s_macCursorRgn , event.where.h , event.where.v ,  event.where.h + 1 , event.where.v + 1 ) ;
 
     // repeaters
 
@@ -1043,8 +1050,9 @@ void wxApp::MacDoOneEvent()
     wxMacProcessNotifierAndPendingEvents() ;
 }
 
-void wxApp::MacHandleOneEvent( EventRecord *ev )
+void wxApp::MacHandleOneEvent( WXEVENTREF evr )
 {
+    EventRecord* ev = (EventRecord*) evr ;
     m_macCurrentEvent = ev ;
 
     wxApp::sm_lastMessageTime = ev->when ;
@@ -1098,15 +1106,17 @@ void wxApp::MacHandleOneEvent( EventRecord *ev )
     wxMacProcessNotifierAndPendingEvents() ;
 }
 
-void wxApp::MacHandleHighLevelEvent( EventRecord *ev )
+void wxApp::MacHandleHighLevelEvent( WXEVENTREF evr )
 {
+    EventRecord* ev = (EventRecord*) evr ;
     ::AEProcessAppleEvent( ev ) ;
 }
 
 bool s_macIsInModalLoop = false ;
 
-void wxApp::MacHandleMouseDownEvent( EventRecord *ev )
+void wxApp::MacHandleMouseDownEvent( WXEVENTREF evr )
 {
+    EventRecord* ev = (EventRecord*) evr ;
     wxToolTip::RemoveToolTips() ;
 
     WindowRef window;
@@ -1156,12 +1166,7 @@ void wxApp::MacHandleMouseDownEvent( EventRecord *ev )
                     GrafPtr port ;
                     GetPort( &port ) ;
                     Point pt = { 0, 0 } ;
-                    #if TARGET_CARBON
-                    SetPort( GetWindowPort(window) ) ;
-                    #else
-                    SetPort( (window) ) ;
-                    #endif
-                    SetOrigin( 0 , 0 ) ;
+                    SetPortWindowPort(window) ;
                     LocalToGlobal( &pt ) ;
                     SetPort( port ) ;
                         win->SetSize( pt.h , pt.v , -1 ,
@@ -1227,12 +1232,7 @@ void wxApp::MacHandleMouseDownEvent( EventRecord *ev )
                 {
                     GrafPtr port ;
                     GetPort( &port ) ;
-                    #if TARGET_CARBON
-                    SetPort( GetWindowPort(window) ) ;
-                    #else
-                    SetPort( (window) ) ;
-                    #endif
-                    SetOrigin( 0 , 0 ) ;
+                    SetPortWindowPort(window) ;
                     SetPort( port ) ;
                 }
                 if ( window != frontWindow && wxTheApp->s_captureWindow == NULL )
@@ -1265,11 +1265,21 @@ void wxApp::MacHandleMouseDownEvent( EventRecord *ev )
     }
 }
 
-void wxApp::MacHandleMouseUpEvent( EventRecord *ev )
+void wxApp::MacHandleMouseUpEvent( WXEVENTREF evr )
 {
+    EventRecord* ev = (EventRecord*) evr ;
     WindowRef window;
 
-    short windowPart = ::FindWindow(ev->where, &window);
+    short windowPart = inNoWindow ;
+       if ( wxTheApp->s_captureWindow )
+       {
+               window = (WindowRef) s_captureWindow->MacGetRootWindow() ;
+               windowPart = inContent ;
+       } 
+       else
+       {
+               windowPart = ::FindWindow(ev->where, &window) ;
+       }
 
     switch (windowPart)
     {
@@ -1396,8 +1406,9 @@ long wxMacTranslateKey(unsigned char key, unsigned char code)
     return retval;
 }
 
-void wxApp::MacHandleKeyDownEvent( EventRecord *ev )
+void wxApp::MacHandleKeyDownEvent( WXEVENTREF evr )
 {
+    EventRecord* ev = (EventRecord*) evr ;
     wxToolTip::RemoveToolTips() ;
 
     UInt32 menuresult = UMAMenuEvent(ev) ;
@@ -1513,8 +1524,9 @@ void wxApp::MacHandleKeyDownEvent( EventRecord *ev )
     }
 }
 
-void wxApp::MacHandleKeyUpEvent( EventRecord *ev )
+void wxApp::MacHandleKeyUpEvent( WXEVENTREF evr )
 {
+    EventRecord* ev = (EventRecord*) evr ;
     wxToolTip::RemoveToolTips() ;
 
     UInt32 menuresult = UMAMenuEvent(ev) ;
@@ -1548,8 +1560,9 @@ void wxApp::MacHandleKeyUpEvent( EventRecord *ev )
     }
 }
 
-void wxApp::MacHandleActivateEvent( EventRecord *ev )
+void wxApp::MacHandleActivateEvent( WXEVENTREF evr )
 {
+    EventRecord* ev = (EventRecord*) evr ;
     WindowRef window = (WindowRef) ev->message ;
     if ( window )
     {
@@ -1567,8 +1580,9 @@ void wxApp::MacHandleActivateEvent( EventRecord *ev )
     }
 }
 
-void wxApp::MacHandleUpdateEvent( EventRecord *ev )
+void wxApp::MacHandleUpdateEvent( WXEVENTREF evr )
 {
+    EventRecord* ev = (EventRecord*) evr ;
     WindowRef window = (WindowRef) ev->message ;
     wxTopLevelWindowMac * win = wxFindWinFromMacWindow( window ) ;
     if ( win )
@@ -1586,8 +1600,9 @@ void wxApp::MacHandleUpdateEvent( EventRecord *ev )
     }
 }
 
-void wxApp::MacHandleDiskEvent( EventRecord *ev )
+void wxApp::MacHandleDiskEvent( WXEVENTREF evr )
 {
+    EventRecord* ev = (EventRecord*) evr ;
     if ( HiWord( ev->message ) != noErr )
   {
  #if !TARGET_CARBON
@@ -1601,8 +1616,9 @@ void wxApp::MacHandleDiskEvent( EventRecord *ev )
     }
 }
 
-void wxApp::MacHandleOSEvent( EventRecord *ev )
+void wxApp::MacHandleOSEvent( WXEVENTREF evr )
 {
+    EventRecord* ev = (EventRecord*) evr ;
     switch( ( ev->message & osEvtMessageMask ) >> 24 )
     {
         case suspendResumeMessage :
@@ -1669,7 +1685,6 @@ void wxApp::MacHandleOSEvent( EventRecord *ev )
 
                 wxWindow::MacGetWindowFromPoint( wxPoint( ev->where.h , ev->where.v ) ,
                                                  &currentMouseWindow ) ;
-
                 if ( currentMouseWindow != wxWindow::s_lastMouseWindow )
                 {
                     wxMouseEvent event ;
@@ -1688,17 +1703,21 @@ void wxApp::MacHandleOSEvent( EventRecord *ev )
                     event.m_y = ev->where.v;
                     event.m_timeStamp = ev->when;
                     event.SetEventObject(this);
-
+                    
                     if ( wxWindow::s_lastMouseWindow )
                     {
-                        wxMouseEvent eventleave(event ) ;
-                        eventleave.SetEventType( wxEVT_LEAVE_WINDOW ) ;
+                        wxMouseEvent eventleave(event);
+                        eventleave.SetEventType( wxEVT_LEAVE_WINDOW );
+                        wxWindow::s_lastMouseWindow->ScreenToClient( &eventleave.m_x, &eventleave.m_y );
+                        
                         wxWindow::s_lastMouseWindow->GetEventHandler()->ProcessEvent(eventleave);
                     }
                     if ( currentMouseWindow )
                     {
-                        wxMouseEvent evententer(event ) ;
-                        evententer.SetEventType( wxEVT_ENTER_WINDOW ) ;
+                        wxMouseEvent evententer(event);
+                        evententer.SetEventType( wxEVT_ENTER_WINDOW );
+                        currentMouseWindow->ScreenToClient( &evententer.m_x, &evententer.m_y );
+                        
                         currentMouseWindow->GetEventHandler()->ProcessEvent(evententer);
                     }
                     wxWindow::s_lastMouseWindow = currentMouseWindow ;