-
-#if !TARGET_CARBON
-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->when , 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 )
- {
- OSErr err ;
- Point point ;
- SetPt( &point , 100 , 100 ) ;
-
- err = DIBadMount( point , ev->message ) ;
- wxASSERT( err == noErr ) ;
- }
-}
-
-void wxApp::MacHandleOSEvent( WXEVENTREF evr )
-{
- EventRecord* ev = (EventRecord*) evr ;
- switch( ( ev->message & osEvtMessageMask ) >> 24 )
- {
- case suspendResumeMessage :
- {
- bool isResuming = ev->message & resumeFlag ;
- bool convertClipboard = ev->message & convertClipboardFlag ;
-
- 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->when , false ) ;
- }
- if ( newFrontWindow )
- {
- wxTopLevelWindowMac* win = wxFindWinFromMacWindow( newFrontWindow ) ;
- if ( win )
- win->MacActivate( ev->when , true ) ;
- }
- }
- else
- {
- MacSuspend( convertClipboard ) ;
- }
- }
- 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 ;
-
- }
-}
-#else
-
-void wxApp::MacHandleMouseMovedEvent(wxInt32 x , wxInt32 y ,wxUint32 modifiers , long timestamp)
-{
- WindowRef window;
-
- wxWindow* currentMouseWindow = NULL ;
-
- if (s_captureWindow )
- {
- currentMouseWindow = s_captureWindow ;
- }
- else
- {
- wxWindow::MacGetWindowFromPoint( wxPoint( x, y ) , ¤tMouseWindow ) ;
- }
-
- if ( currentMouseWindow != wxWindow::s_lastMouseWindow )
- {
- wxMouseEvent event ;
-
- bool isDown = !(modifiers & btnState) ; // 1 is for up
- bool controlDown = modifiers & controlKey ; // for simulating right mouse
-
- event.m_leftDown = isDown && !controlDown;
-
- event.m_middleDown = FALSE;
- event.m_rightDown = isDown && controlDown;
-
- event.m_shiftDown = modifiers & shiftKey;
- 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;
-
- 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 ) ;
-
-#if wxUSE_TOOLTIPS
- wxToolTip::RelayEvent( wxWindow::s_lastMouseWindow , eventleave);
-#endif // wxUSE_TOOLTIPS
- 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 ) ;
-#if wxUSE_TOOLTIPS
- wxToolTip::RelayEvent( currentMouseWindow , evententer);
-#endif // wxUSE_TOOLTIPS
- currentMouseWindow->GetEventHandler()->ProcessEvent(evententer);
- }
- wxWindow::s_lastMouseWindow = currentMouseWindow ;
- }
-
- short windowPart = inNoWindow ;
-
- if ( s_captureWindow )
- {
- window = (WindowRef) s_captureWindow->MacGetRootWindow() ;
- windowPart = inContent ;
- }
- else
- {
- Point pt= { y , x } ;
- windowPart = ::FindWindow(pt , &window);
- }
-
- switch (windowPart)
- {
- case inContent :
- {
- wxTopLevelWindowMac* win = wxFindWinFromMacWindow( window ) ;
- if ( win )
- win->MacFireMouseEvent( nullEvent , x , y , modifiers , timestamp ) ;
- else
- {
- if ( wxIsBusy() )
- {
- }
- else
- UMAShowArrowCursor();
- }
- }
- break;
- default :
- {
- if ( wxIsBusy() )
- {
- }
- else
- UMAShowArrowCursor();
- }
- break ;
- }
-}
-#endif
-
-void wxApp::MacHandleMenuCommand( wxUint32 id )
-{
- wxMenuBar* mbar = wxMenuBar::MacGetInstalledMenuBar() ;
- wxFrame* frame = mbar->GetFrame();
- wxCHECK_RET( mbar != NULL && frame != NULL, wxT("error in menu item callback") );
- if ( frame )
- {
- frame->ProcessCommand(id);
- }
-}
-
-#if !TARGET_CARBON
-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
- {
- MenuCommand id ;
- GetMenuItemCommandID( GetMenuHandle(macMenuId) , macMenuItemNum , &id ) ;
- MacHandleMenuCommand( id ) ;
- }
- HiliteMenu(0);
-}
-#endif