-#if !TARGET_CARBON
-bool s_macIsInModalLoop = false ;
-
-void wxApp::MacHandleModifierEvents( WXEVENTREF evr )
-{
- EventRecord* ev = (EventRecord*) evr ;
- if ( ev->modifiers != s_lastModifiers && wxWindow::FindFocus() != NULL )
- {
- wxKeyEvent event(wxEVT_KEY_DOWN);
-
- 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;
- wxWindow* focus = wxWindow::FindFocus() ;
- event.SetEventObject(focus);
-
- if ( (ev->modifiers ^ s_lastModifiers ) & controlKey )
- {
- event.m_keyCode = WXK_CONTROL ;
- event.SetEventType( ( ev->modifiers & controlKey ) ? wxEVT_KEY_DOWN : wxEVT_KEY_UP ) ;
- focus->GetEventHandler()->ProcessEvent( event ) ;
- }
- if ( (ev->modifiers ^ s_lastModifiers ) & shiftKey )
- {
- event.m_keyCode = WXK_SHIFT ;
- event.SetEventType( ( ev->modifiers & shiftKey ) ? wxEVT_KEY_DOWN : wxEVT_KEY_UP ) ;
- focus->GetEventHandler()->ProcessEvent( event ) ;
- }
- if ( (ev->modifiers ^ s_lastModifiers ) & optionKey )
- {
- event.m_keyCode = WXK_ALT ;
- event.SetEventType( ( ev->modifiers & optionKey ) ? wxEVT_KEY_DOWN : wxEVT_KEY_UP ) ;
- focus->GetEventHandler()->ProcessEvent( event ) ;
- }
- if ( ev->modifiers ^ s_lastModifiers ) & cmdKey )
- {
- event.m_keyCode = WXK_COMMAND ;
- event.SetEventType( ( ev->modifiers & cmdKey ) ? wxEVT_KEY_DOWN : wxEVT_KEY_UP ) ;
- focus->GetEventHandler()->ProcessEvent( event ) ;
- }
- s_lastModifiers = ev->modifiers ;
- }
-}
-
-void wxApp::MacHandleHighLevelEvent( WXEVENTREF evr )
-{
- // we must avoid reentrancy problems when processing high level events eg printing
- bool former = s_inYield ;
- s_inYield = TRUE ;
- EventRecord* ev = (EventRecord*) evr ;
- ::AEProcessAppleEvent( ev ) ;
- s_inYield = former ;
-}
-
-void wxApp::MacHandleMouseDownEvent( WXEVENTREF evr )
-{
- EventRecord* ev = (EventRecord*) evr ;
- wxToolTip::RemoveToolTips() ;
-
- WindowRef window;
- WindowRef frontWindow = ::FrontNonFloatingWindow() ;
- WindowAttributes frontWindowAttributes = NULL ;
- if ( frontWindow )
- ::GetWindowAttributes( frontWindow , &frontWindowAttributes ) ;
-
- short windowPart = ::FindWindow(ev->where, &window);
- wxTopLevelWindowMac* win = wxFindWinFromMacWindow( window ) ;
- if ( wxPendingDelete.Member(win) )
- return ;
-
- BitMap screenBits;
- GetQDGlobalsScreenBits( &screenBits );
-
- switch (windowPart)
- {
- case inMenuBar :
- if ( s_macIsInModalLoop )
- {
- SysBeep ( 30 ) ;
- }
- else
- {
- UInt32 menuresult = MenuSelect(ev->where) ;
- MacHandleMenuSelect( HiWord( menuresult ) , LoWord( menuresult ) );
- s_lastMouseDown = 0;
- }
- break ;
- case inSysWindow :
- SystemClick( ev , window ) ;
- s_lastMouseDown = 0;
- break ;
- case inDrag :
- if ( window != frontWindow && s_macIsInModalLoop && !(ev->modifiers & cmdKey ) )
- {
- SysBeep ( 30 ) ;
- }
- else
- {
- DragWindow(window, ev->where, &screenBits.bounds);
- if (win)
- {
- GrafPtr port ;
- GetPort( &port ) ;
- Point pt = { 0, 0 } ;
- SetPortWindowPort(window) ;
- LocalToGlobal( &pt ) ;
- SetPort( port ) ;
- win->SetSize( pt.h , pt.v , -1 ,
- -1 , wxSIZE_USE_EXISTING);
- }
- s_lastMouseDown = 0;
- }
- break ;
- case inGoAway:
- if (TrackGoAway(window, ev->where))
- {
- if ( win )
- win->Close() ;
- }
- s_lastMouseDown = 0;
- break;
- case inGrow:
- {
- Rect newContentRect ;
- Rect constraintRect ;
- constraintRect.top = win->GetMinHeight() ;
- if ( constraintRect.top == -1 )
- constraintRect.top = 0 ;
- constraintRect.left = win->GetMinWidth() ;
- if ( constraintRect.left == -1 )
- constraintRect.left = 0 ;
- constraintRect.right = win->GetMaxWidth() ;
- if ( constraintRect.right == -1 )
- constraintRect.right = 32000 ;
- constraintRect.bottom = win->GetMaxHeight() ;
- if ( constraintRect.bottom == -1 )
- constraintRect.bottom = 32000 ;
-
- Boolean growResult = ResizeWindow( window , ev->where ,
- &constraintRect , &newContentRect ) ;
- if ( growResult )
- {
- win->SetSize( newContentRect.left , newContentRect.top ,
- newContentRect.right - newContentRect.left ,
- newContentRect.bottom - newContentRect.top, wxSIZE_USE_EXISTING);
- }
- s_lastMouseDown = 0;
- }
- break;
- case inZoomIn:
- case inZoomOut:
- if (TrackBox(window, ev->where, windowPart))
- {
- // TODO setup size event
- ZoomWindow( window , windowPart , false ) ;
- if (win)
- {
- Rect tempRect ;
- GrafPtr port ;
- GetPort( &port ) ;
- Point pt = { 0, 0 } ;
- SetPortWindowPort(window) ;
- LocalToGlobal( &pt ) ;
- SetPort( port ) ;
-
- GetWindowPortBounds(window, &tempRect ) ;
- win->SetSize( pt.h , pt.v , tempRect.right-tempRect.left ,
- tempRect.bottom-tempRect.top, wxSIZE_USE_EXISTING);
- }
- }
- s_lastMouseDown = 0;
- break;
- case inCollapseBox :
- // TODO setup size event
- s_lastMouseDown = 0;
- break ;
-
- case inContent :
- {
- GrafPtr port ;
- GetPort( &port ) ;
- SetPortWindowPort(window) ;
- SetPort( port ) ;
- }
- if ( window != frontWindow && wxTheApp->s_captureWindow == NULL )
- {
- if ( s_macIsInModalLoop )
- {
- SysBeep ( 30 ) ;
- }
- else if ( UMAIsWindowFloating( window ) )
- {
- if ( win )
- win->MacMouseDown( ev , windowPart ) ;
- }
- else
- {
- if ( win )
- win->MacMouseDown( ev , windowPart ) ;
- ::SelectWindow( window ) ;
- }
- }
- else
- {
- if ( win )
- win->MacMouseDown( ev , windowPart ) ;
- }
- break ;
- default:
- break;
- }
-}
-
-void wxApp::MacHandleMouseUpEvent( WXEVENTREF evr )
-{
- EventRecord* ev = (EventRecord*) evr ;
- WindowRef window;
-
- short windowPart = inNoWindow ;
- if ( wxTheApp->s_captureWindow )
- {
- window = (WindowRef) s_captureWindow->MacGetRootWindow() ;
- windowPart = inContent ;
- }
- else
- {
- windowPart = ::FindWindow(ev->where, &window) ;
- }
-
- switch (windowPart)
- {
- case inMenuBar :
- break ;
- case inSysWindow :
- break ;
- default:
- {
- wxTopLevelWindowMac* win = wxFindWinFromMacWindow( window ) ;
- if ( win )
- win->MacMouseUp( ev , windowPart ) ;
- }
- break;
- }
-}
-
-#endif
-