-void wxApp::MacHandleActivateEvent( WXEVENTREF evr )
-{
- EventRecord* ev = (EventRecord*) evr ;
- WindowRef window = (WindowRef) ev->message ;
- if ( window )
- {
- bool activate = (ev->modifiers & activeFlag ) ;
- WindowClass wclass ;
- ::GetWindowClass ( window , &wclass ) ;
- if ( wclass == kFloatingWindowClass )
- {
- // if it is a floater we activate/deactivate the front non-floating window instead
- window = ::FrontNonFloatingWindow() ;
- }
- wxTopLevelWindowMac* win = wxFindWinFromMacWindow( window ) ;
- if ( win )
- win->MacActivate( ev , activate ) ;
- }
-}
-
-void wxApp::MacHandleUpdateEvent( WXEVENTREF evr )
-{
- EventRecord* ev = (EventRecord*) evr ;
- WindowRef window = (WindowRef) ev->message ;
- wxTopLevelWindowMac * win = wxFindWinFromMacWindow( window ) ;
- if ( win )
- {
- if ( !wxPendingDelete.Member(win) )
- win->MacUpdate( ev->when ) ;
- }
- 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 ) ;
- }
-}
-
-void wxApp::MacHandleDiskEvent( WXEVENTREF evr )
-{
- EventRecord* ev = (EventRecord*) evr ;
- if ( HiWord( ev->message ) != noErr )
- {
- #if !TARGET_CARBON
- OSErr err ;
- Point point ;
- SetPt( &point , 100 , 100 ) ;
-
- err = DIBadMount( point , ev->message ) ;
- wxASSERT( err == noErr ) ;
-#endif
- }
-}
-
-void wxApp::MacHandleOSEvent( WXEVENTREF evr )
-{
- EventRecord* ev = (EventRecord*) evr ;
- switch( ( ev->message & osEvtMessageMask ) >> 24 )
- {
- case suspendResumeMessage :
- {
- bool isResuming = ev->message & resumeFlag ;
-#if !TARGET_CARBON
- bool convertClipboard = ev->message & convertClipboardFlag ;
-#else
- bool convertClipboard = false;
-#endif
- bool doesActivate = UMAGetProcessModeDoesActivateOnFGSwitch() ;
- if ( isResuming )
- {
- WindowRef oldFrontWindow = NULL ;
- WindowRef newFrontWindow = NULL ;
-
- // in case we don't take care of activating ourselves, we have to synchronize
- // our idea of the active window with the process manager's - which it already activated
-
- if ( !doesActivate )
- oldFrontWindow = ::FrontNonFloatingWindow() ;
-
- MacResume( convertClipboard ) ;
-
- newFrontWindow = ::FrontNonFloatingWindow() ;
-
- if ( oldFrontWindow )
- {
- wxTopLevelWindowMac* win = wxFindWinFromMacWindow( oldFrontWindow ) ;
- if ( win )
- win->MacActivate( ev , false ) ;
- }
- if ( newFrontWindow )
- {
- wxTopLevelWindowMac* win = wxFindWinFromMacWindow( newFrontWindow ) ;
- if ( win )
- win->MacActivate( ev , true ) ;
- }
- }
- else
- {
- MacSuspend( convertClipboard ) ;
-
- // in case this suspending did close an active window, another one might
- // have surfaced -> lets deactivate that one
-
-/* TODO : find out what to do on systems < 10 , perhaps FrontNonFloatingWindow
- WindowRef newActiveWindow = ::ActiveNonFloatingWindow() ;
- if ( newActiveWindow )
- {
- wxWindow* win = wxFindWinFromMacWindow( newActiveWindow ) ;
- if ( win )
- win->MacActivate( ev , false ) ;
- }
-*/
- }
- }
- break ;
- case mouseMovedMessage :
- {
- WindowRef window;
-
- wxWindow* currentMouseWindow = NULL ;
-
- if (s_captureWindow )
- {
- currentMouseWindow = s_captureWindow ;
- }
- else
- {
- wxWindow::MacGetWindowFromPoint( wxPoint( ev->where.h , ev->where.v ) ,
- ¤tMouseWindow ) ;
- }
-
- if ( currentMouseWindow != wxWindow::s_lastMouseWindow )
- {
- wxMouseEvent event ;
-
- bool isDown = !(ev->modifiers & btnState) ; // 1 is for up
- bool controlDown = ev->modifiers & controlKey ; // for simulating right mouse
-
- event.m_leftDown = isDown && !controlDown;
- event.m_middleDown = FALSE;
- event.m_rightDown = isDown && controlDown;
- 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_x = ev->where.h;
- 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 );
- wxWindow::s_lastMouseWindow->ScreenToClient( &eventleave.m_x, &eventleave.m_y );
- eventleave.SetEventObject( wxWindow::s_lastMouseWindow ) ;
-
- wxWindow::s_lastMouseWindow->GetEventHandler()->ProcessEvent(eventleave);
- }
- if ( currentMouseWindow )
- {
- wxMouseEvent evententer(event);
- evententer.SetEventType( wxEVT_ENTER_WINDOW );
- currentMouseWindow->ScreenToClient( &evententer.m_x, &evententer.m_y );
- evententer.SetEventObject( currentMouseWindow ) ;
- currentMouseWindow->GetEventHandler()->ProcessEvent(evententer);
- }
- wxWindow::s_lastMouseWindow = currentMouseWindow ;
- }
-
- short windowPart = inNoWindow ;
-
- if ( s_captureWindow )
- {
- window = (WindowRef) s_captureWindow->MacGetRootWindow() ;
- windowPart = inContent ;
- }
- else
- {
- windowPart = ::FindWindow(ev->where, &window);
- }
-
- switch (windowPart)
- {
- case inContent :
- {
- wxTopLevelWindowMac* win = wxFindWinFromMacWindow( window ) ;
- if ( win )
- win->MacMouseMoved( ev , windowPart ) ;
- else
- {
- if ( wxIsBusy() )
- {
- }
- else
- UMAShowArrowCursor();
- }
- }
- break;
- default :
- {
- if ( wxIsBusy() )
- {
- }
- else
- UMAShowArrowCursor();
- }
- break ;
- }
- }
- break ;
-
- }
-}
-
-void wxApp::MacHandleMenuSelect( int macMenuId , int macMenuItemNum )
-{
- if (macMenuId == 0)
- return; // no menu item selected
-
- if (macMenuId == kwxMacAppleMenuId && macMenuItemNum > 1)
- {
- #if ! TARGET_CARBON
- Str255 deskAccessoryName ;
- GrafPtr savedPort ;
-
- GetMenuItemText(GetMenuHandle(kwxMacAppleMenuId), macMenuItemNum, deskAccessoryName);
- GetPort(&savedPort);
- OpenDeskAcc(deskAccessoryName);
- SetPort(savedPort);
- #endif
- }
- else
- {
- wxWindow* frontwindow = wxFindWinFromMacWindow( ::FrontWindow() ) ;
- if ( frontwindow && wxMenuBar::MacGetInstalledMenuBar() )
- wxMenuBar::MacGetInstalledMenuBar()->MacMenuSelect( frontwindow->GetEventHandler() , 0 , macMenuId , macMenuItemNum ) ;
- }
- HiliteMenu(0);
-}
-
-/*
-long wxApp::MacTranslateKey(char key, int mods)
-{
-}
-
-void wxApp::MacAdjustCursor()
-{
-}
-
-*/
-/*
-void
-wxApp::macAdjustCursor()
-{
- if (ev->what != kHighLevelEvent)
- {
- wxWindow* theMacWxFrame = wxFrame::MacFindFrameOrDialog(::FrontWindow());
- if (theMacWxFrame)
- {
- if (!theMacWxFrame->MacAdjustCursor(ev->where))
- ::SetCursor(&(qd.arrow));
- }
- }
-}
-*/