-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 ;
-
- 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 = ::FindWindow(ev->where, &window);
-
- switch (windowPart)
- {
- // fixes for setting the cursor back from dominic mazzoni
- case inMenuBar :
- UMAShowArrowCursor();
- break ;
- case inSysWindow :
- UMAShowArrowCursor();
- break ;
- default:
- {
- // if ( s_lastMouseDown == 0 )
- // ev->modifiers |= btnState ;
-
- // Calling GetNextEvent with a zero event mask will always
- // pass back a null event. However, it fills the EventRecord
- // with the state of the modifier keys. This is needed since
- // the modifier state returned by WaitForNextEvent often is
- // wrong mouse move events. The attempt above to correct this
- // didn't always work (under OS X at least).
-
- EventRecord tmp;
- ::GetNextEvent(0, &tmp);
- ev->modifiers = tmp.modifiers;
-
- wxTopLevelWindowMac* win = wxFindWinFromMacWindow( window ) ;
- if ( win )
- win->MacMouseMoved( ev , windowPart ) ;
- 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));
- }
- }