X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/882b04798358fa6d525dbd9f393b9be1ae02c764..5ea02ed5dfa37a4208486a3f6824658313f4ee08:/src/mac/app.cpp diff --git a/src/mac/app.cpp b/src/mac/app.cpp index 6c43daf5d8..baa2127bbf 100644 --- a/src/mac/app.cpp +++ b/src/mac/app.cpp @@ -104,7 +104,6 @@ long wxApp::sm_lastMessageTime = 0; long wxApp::s_lastModifiers = 0 ; -bool wxApp::s_macDefaultEncodingIsPC = true ; bool wxApp::s_macSupportPCMenuShortcuts = true ; long wxApp::s_macAboutMenuItemId = wxID_ABOUT ; long wxApp::s_macPreferencesMenuItemId = wxID_PREFERENCES ; @@ -220,13 +219,12 @@ 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 ) ; } - else - */ + else { ExitMainLoop() ; } @@ -299,6 +297,8 @@ void wxApp::MacNewFile() { kEventClassMouse , kEventMouseDown } , { kEventClassMouse , kEventMouseMoved } , + { kEventClassMouse , kEventMouseUp } , + { kEventClassMouse , kEventMouseDragged } , { 'WXMC' , 'WXMC' } } ; @@ -337,6 +337,8 @@ MenuEventHandler( EventHandlerCallRef handler , EventRef event , void *data ) // but have to use ReceiveNextEvent dealing with events manually, therefore we also have // deal with clicks in the menu bar explicitely +pascal OSStatus wxMacWindowEventHandler( EventHandlerCallRef handler , EventRef event , void *data ) ; + static pascal OSStatus MouseEventHandler( EventHandlerCallRef handler , EventRef event , void *data ) { OSStatus result = eventNotHandledErr ; @@ -374,6 +376,13 @@ static pascal OSStatus MouseEventHandler( EventHandlerCallRef handler , EventRef } } break ; + case kEventMouseDragged : + case kEventMouseUp : + { + if ( wxTheApp->s_captureWindow ) + wxMacWindowEventHandler( handler , event , (void*) wxTheApp->s_captureWindow->MacGetTopLevelWindow() ) ; + } + break ; case kEventMouseMoved : { wxTheApp->MacHandleMouseMovedEvent( point.h , point.v , modifiers , EventTimeToTicks( GetEventTime( event ) ) ) ; @@ -404,7 +413,15 @@ static pascal OSStatus CommandEventHandler( EventHandlerCallRef handler , EventR wxMenuItem* item = NULL ; if ( mbar ) + { item = mbar->FindItem( id , &menu ) ; + // it is not 100 % sure that an menu of id 0 is really ours, safety check + if ( id == 0 && menu != NULL && menu->GetHMenu() != command.menu.menuRef ) + { + item = NULL ; + menu = NULL ; + } + } if ( item == NULL || menu == NULL || mbar == NULL ) return result ; @@ -424,7 +441,7 @@ static pascal OSStatus CommandEventHandler( EventHandlerCallRef handler , EventR break ; case kEventCommandUpdateStatus: // eventually trigger an updateui round - result = noErr ; + result = noErr ; break ; default : break ; @@ -582,7 +599,6 @@ bool wxApp::Initialize(int& argc, wxChar **argv) #endif #endif - wxMacSetupConverters() ; s_macCursorRgn = ::NewRgn() ; @@ -593,10 +609,11 @@ bool wxApp::Initialize(int& argc, wxChar **argv) if ( argc > 1 ) { static const wxChar *ARG_PSN = _T("-psn_"); - if ( wxStrncmp(argv[1], ARG_PSN, sizeof(ARG_PSN) - 1) == 0 ) + if ( wxStrncmp(argv[1], ARG_PSN, wxStrlen(ARG_PSN)) == 0 ) { // remove this argument - memmove(argv, argv + 1, argc--); + --argc; + memmove(argv + 1, argv + 2, argc * sizeof(char *)); } } @@ -684,7 +701,6 @@ void wxApp::CleanUp() // __wxterminate in Mach-O shared libraries wxStAppResource::CloseSharedLibraryResource(); #endif - wxMacCleanupConverters() ; UMACleanupToolbox() ; if (s_macCursorRgn) { @@ -990,15 +1006,9 @@ wxApp::wxApp() m_auto3D = TRUE; m_macCurrentEvent = NULL ; +#if TARGET_CARBON m_macCurrentEventHandlerCallRef = NULL ; -} - -bool wxApp::Initialized() -{ - if (GetTopWindow()) - return TRUE; - else - return FALSE; +#endif } int wxApp::MainLoop() @@ -1031,9 +1041,11 @@ bool wxApp::Pending() } // Dispatch a message. -void wxApp::Dispatch() +bool wxApp::Dispatch() { MacDoOneEvent() ; + + return true; } void wxApp::OnIdle(wxIdleEvent& event) @@ -1377,7 +1389,7 @@ void wxApp::MacHandleModifierEvents( WXEVENTREF evr ) event.SetEventType( ( ev->modifiers & optionKey ) ? wxEVT_KEY_DOWN : wxEVT_KEY_UP ) ; focus->GetEventHandler()->ProcessEvent( event ) ; } - if ( ev->modifiers ^ s_lastModifiers ) & cmdKey ) + if ( ( ev->modifiers ^ s_lastModifiers ) & cmdKey ) { event.m_keyCode = WXK_COMMAND ; event.SetEventType( ( ev->modifiers & cmdKey ) ? wxEVT_KEY_DOWN : wxEVT_KEY_UP ) ; @@ -1542,7 +1554,7 @@ void wxApp::MacHandleMouseDownEvent( WXEVENTREF evr ) { // Activate window first ::SelectWindow( window ) ; - + // Send event later if ( win ) win->MacMouseDown( ev , windowPart ) ; @@ -2158,7 +2170,7 @@ void wxApp::MacHandleMouseMovedEvent(wxInt32 x , wxInt32 y ,wxUint32 modifiers , event.m_controlDown = modifiers & controlKey; event.m_altDown = modifiers & optionKey; event.m_metaDown = modifiers & cmdKey; - + event.m_x = x; event.m_y = y; event.m_timeStamp = timestamp;