- case 0x01 :
- key = WXK_HOME;
- break;
- case 0x03 :
- key = WXK_RETURN;
- break;
- case 0x04 :
- key = WXK_END;
- break;
- case 0x05 :
- key = WXK_HELP;
- break;
- case 0x08 :
- key = WXK_BACK;
- break;
- case 0x09 :
- key = WXK_TAB;
- break;
- case 0x0b :
- key = WXK_PAGEUP;
- break;
- case 0x0c :
- key = WXK_PAGEDOWN;
- break;
- case 0x0d :
- key = WXK_RETURN;
- break;
- case 0x10 :
- {
- switch( code )
- {
- case 0x7a :
- key = WXK_F1 ;
- break;
- case 0x78 :
- key = WXK_F2 ;
- break;
- case 0x63 :
- key = WXK_F3 ;
- break;
- case 0x76 :
- key = WXK_F4 ;
- break;
- case 0x60 :
- key = WXK_F5 ;
- break;
- case 0x61 :
- key = WXK_F6 ;
- break;
- case 0x62:
- key = WXK_F7 ;
- break;
- case 0x64 :
- key = WXK_F8 ;
- break;
- case 0x65 :
- key = WXK_F9 ;
- break;
- case 0x6D :
- key = WXK_F10 ;
- break;
- case 0x67 :
- key = WXK_F11 ;
- break;
- case 0x6F :
- key = WXK_F12 ;
- break;
- case 0x69 :
- key = WXK_F13 ;
- break;
- case 0x6B :
- key = WXK_F14 ;
- break;
- case 0x71 :
- key = WXK_F15 ;
- break;
- }
- }
- break ;
- case 0x1b :
- key = WXK_DELETE ;
- break ;
- case 0x1c :
- key = WXK_LEFT ;
- break ;
- case 0x1d :
- key = WXK_RIGHT ;
- break ;
- case 0x1e :
- key = WXK_UP ;
- break ;
- case 0x1f :
- key = WXK_DOWN ;
- break ;
- default:
- break ;
- } // end switch
-
- return key;
-}
-
-void wxApp::MacHandleKeyDownEvent( EventRecord *ev )
-{
- UInt32 menuresult = UMAMenuEvent(ev) ;
- if ( HiWord( menuresult ) )
- MacHandleMenuSelect( HiWord( menuresult ) , LoWord( menuresult ) ) ;
- else
- {
- short keycode ;
- short keychar ;
- keychar = short(ev->message & charCodeMask);
- keycode = short(ev->message & keyCodeMask) >> 8 ;
-
- wxWindow* focus = wxWindow::FindFocus() ;
- if ( focus )
- {
- wxKeyEvent event(wxEVT_CHAR);
- 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_keyCode = wxMacTranslateKey(keychar, keycode);
- event.m_x = ev->where.h;
- event.m_y = ev->where.v;
- event.m_timeStamp = ev->when;
- event.SetEventObject(focus);
- focus->GetEventHandler()->ProcessEvent( event ) ;
- }
- }
-}
-
-void wxApp::MacHandleKeyUpEvent( EventRecord *ev )
-{
- // nothing to do
-}
-
-void wxApp::MacHandleActivateEvent( EventRecord *ev )
-{
- WindowRef window = (WindowRef) ev->message ;
- if ( window )
- {
- bool activate = (ev->modifiers & activeFlag ) ;
- WindowClass wclass ;
- UMAGetWindowClass ( window , &wclass ) ;
- if ( wclass == kFloatingWindowClass )
- {
- // if it is a floater we activate/deactivate the front non-floating window instead
- window = UMAFrontNonFloatingWindow() ;
- }
- wxWindow* win = wxFindWinFromMacWindow( window ) ;
- if ( win )
- win->MacActivate( ev , activate ) ;
- }
-}
-
-void wxApp::MacHandleUpdateEvent( EventRecord *ev )
-{
- WindowRef window = (WindowRef) ev->message ;
- wxWindow * win = wxFindWinFromMacWindow( window ) ;
- if ( win )
- {
- win->MacUpdate( ev ) ;
- }
-}
-
-void wxApp::MacHandleDiskEvent( EventRecord *ev )
-{
- if ( HiWord( ev->message ) != noErr )
- {
- OSErr err ;
- Point point ;
- SetPt( &point , 100 , 100 ) ;
-
- err = DIBadMount( point , ev->message ) ;
- wxASSERT( err == noErr ) ;
- }
-}
-
-void wxApp::MacHandleOSEvent( EventRecord *ev )
-{
- 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 = UMAFrontNonFloatingWindow() ;
-
- MacResume( convertClipboard ) ;
-
- newFrontWindow = UMAFrontNonFloatingWindow() ;
-
- if ( oldFrontWindow )
- {
- wxWindow* win = wxFindWinFromMacWindow( oldFrontWindow ) ;
- if ( win )
- win->MacActivate( ev , false ) ;
- }
- if ( newFrontWindow )
- {
- wxWindow* 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
-
- WindowRef newActiveWindow = UMAGetActiveNonFloatingWindow() ;
- if ( newActiveWindow )
- {
- wxWindow* win = wxFindWinFromMacWindow( newActiveWindow ) ;
- if ( win )
- win->MacActivate( ev , false ) ;
- }
- }
- }
- break ;
- case mouseMovedMessage :
- {
- WindowRef window;
-
- wxWindow* currentMouseWindow = NULL ;
-
- 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->GetEventHandler()->ProcessEvent(eventleave);
- }
- if ( currentMouseWindow )
- {
- wxMouseEvent evententer(event ) ;
- evententer.SetEventType( wxEVT_ENTER_WINDOW ) ;
- currentMouseWindow->GetEventHandler()->ProcessEvent(evententer);
- }
- wxWindow::s_lastMouseWindow = currentMouseWindow ;
- }
-
- short windowPart = ::FindWindow(ev->where, &window);
-
- switch (windowPart)
- {
- case inMenuBar :
- break ;
- case inSysWindow :
- break ;
- default:
- {
- if ( s_lastMouseDown == 0 )
- ev->modifiers |= btnState ;
-
- wxWindow* win = wxFindWinFromMacWindow( window ) ;
- if ( win )
- win->MacMouseMoved( ev , windowPart ) ;
- }
- break;
- }
- }
- break ;
-
- }