+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
+ {
+ // Activate window first
+ ::SelectWindow( window ) ;
+
+ // Send event later
+ if ( win )
+ win->MacMouseDown( ev , windowPart ) ;
+ }
+ }
+ 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
+
+long wxMacTranslateKey(unsigned char key, unsigned char code) ;
+long wxMacTranslateKey(unsigned char key, unsigned char code)
+{
+ long retval = key ;
+ switch (key)
+ {
+ case kHomeCharCode :
+ retval = WXK_HOME;
+ break;
+ case kEnterCharCode :
+ retval = WXK_RETURN;
+ break;
+ case kEndCharCode :
+ retval = WXK_END;
+ break;
+ case kHelpCharCode :
+ retval = WXK_HELP;
+ break;
+ case kBackspaceCharCode :
+ retval = WXK_BACK;
+ break;
+ case kTabCharCode :
+ retval = WXK_TAB;
+ break;
+ case kPageUpCharCode :
+ retval = WXK_PAGEUP;
+ break;
+ case kPageDownCharCode :
+ retval = WXK_PAGEDOWN;
+ break;
+ case kReturnCharCode :
+ retval = WXK_RETURN;
+ break;
+ case kFunctionKeyCharCode :
+ {
+ switch( code )
+ {
+ case 0x7a :
+ retval = WXK_F1 ;
+ break;
+ case 0x78 :
+ retval = WXK_F2 ;
+ break;
+ case 0x63 :
+ retval = WXK_F3 ;
+ break;
+ case 0x76 :
+ retval = WXK_F4 ;
+ break;
+ case 0x60 :
+ retval = WXK_F5 ;
+ break;
+ case 0x61 :
+ retval = WXK_F6 ;
+ break;
+ case 0x62:
+ retval = WXK_F7 ;
+ break;
+ case 0x64 :
+ retval = WXK_F8 ;
+ break;
+ case 0x65 :
+ retval = WXK_F9 ;
+ break;
+ case 0x6D :
+ retval = WXK_F10 ;
+ break;
+ case 0x67 :
+ retval = WXK_F11 ;
+ break;
+ case 0x6F :
+ retval = WXK_F12 ;
+ break;
+ case 0x69 :
+ retval = WXK_F13 ;
+ break;
+ case 0x6B :
+ retval = WXK_F14 ;
+ break;
+ case 0x71 :
+ retval = WXK_F15 ;
+ break;
+ }
+ }
+ break ;
+ case kEscapeCharCode :
+ retval = WXK_ESCAPE ;
+ break ;
+ case kLeftArrowCharCode :
+ retval = WXK_LEFT ;
+ break ;
+ case kRightArrowCharCode :
+ retval = WXK_RIGHT ;
+ break ;
+ case kUpArrowCharCode :
+ retval = WXK_UP ;
+ break ;
+ case kDownArrowCharCode :
+ retval = WXK_DOWN ;
+ break ;
+ case kDeleteCharCode :
+ retval = WXK_DELETE ;
+ default:
+ break ;
+ } // end switch
+
+ return retval;
+}
+
+int wxKeyCodeToMacModifier(wxKeyCode key)
+{
+ switch (key)
+ {
+ case WXK_START:
+ case WXK_MENU:
+ return cmdKey;
+
+ case WXK_SHIFT:
+ return shiftKey;
+
+ case WXK_CAPITAL:
+ return alphaLock;
+
+ case WXK_ALT:
+ return optionKey;
+
+ case WXK_CONTROL:
+ return controlKey;
+
+ default:
+ return 0;
+ }
+}
+
+bool wxGetKeyState(wxKeyCode key) //virtual key code if < 10.2.x, else see below
+{
+//#ifdef __DARWIN__
+// wxHIDKeyboard keyboard;
+// return keyboard.IsActive(key);
+//#else
+// TODO: Have it use HID Manager on OSX...
+//if OS X > 10.2 (i.e. 10.2.x)
+//a known apple bug prevents the system from determining led
+//states with GetKeys... can only determine caps lock led
+ return !!(GetCurrentKeyModifiers() & wxKeyCodeToMacModifier(key));
+//else
+// KeyMapByteArray keymap;
+// GetKeys((BigEndianLong*)keymap);
+// return !!(BitTst(keymap, (sizeof(KeyMapByteArray)*8) - iKey));
+//#endif
+}
+
+#if !TARGET_CARBON
+void wxApp::MacHandleKeyDownEvent( WXEVENTREF evr )
+{
+ EventRecord* ev = (EventRecord*) evr ;
+ wxToolTip::RemoveToolTips() ;
+
+ UInt32 menuresult = UMAMenuEvent(ev) ;
+ if ( HiWord( menuresult ) )
+ {
+ if ( !s_macIsInModalLoop )
+ MacHandleMenuSelect( HiWord( menuresult ) , LoWord( menuresult ) ) ;
+ }
+ else
+ {
+ wxWindow* focus = wxWindow::FindFocus() ;
+
+ if ( MacSendKeyDownEvent( focus , ev->message , ev->modifiers , ev->when , ev->where.h , ev->where.v ) == false )
+ {
+#if 0
+ // we must handle control keys the other way round, otherwise text content is updated too late
+ // has not been handled -> perform default
+ wxControl* control = wxDynamicCast( focus , wxControl ) ;
+ if ( control && control->GetMacControl() != NULL )
+ {
+ short keycode ;
+ short keychar ;
+ keychar = short(ev->message & charCodeMask);
+ keycode = short(ev->message & keyCodeMask) >> 8 ;
+ ::HandleControlKey( (ControlHandle) control->GetMacControl() , keycode , keychar , ev->modifiers ) ;
+ }
+#endif
+ }
+ }
+}
+
+void wxApp::MacHandleKeyUpEvent( WXEVENTREF evr )
+{
+ EventRecord* ev = (EventRecord*) evr ;
+ wxToolTip::RemoveToolTips() ;
+
+ UInt32 menuresult = UMAMenuEvent(ev) ;
+ if ( HiWord( menuresult ) )
+ {
+ }
+ else
+ {
+ MacSendKeyUpEvent( wxWindow::FindFocus() , ev->message , ev->modifiers , ev->when , ev->where.h , ev->where.v ) ;
+ }
+}
+
+#endif
+
+bool wxApp::MacSendKeyDownEvent( wxWindow* focus , long keymessage , long modifiers , long when , short wherex , short wherey )
+{
+ if ( !focus )
+ return false ;
+
+ short keycode ;
+ short keychar ;
+ keychar = short(keymessage & charCodeMask);
+ keycode = short(keymessage & keyCodeMask) >> 8 ;
+
+ if ( modifiers & ( controlKey|shiftKey|optionKey ) )
+ {
+ // control interferes with some built-in keys like pgdown, return etc. therefore we remove the controlKey modifier
+ // and look at the character after
+ UInt32 state = 0;
+ UInt32 keyInfo = KeyTranslate((Ptr)GetScriptManagerVariable(smKCHRCache), ( modifiers & (~(controlKey|shiftKey|optionKey))) | keycode, &state);
+ keychar = short(keyInfo & charCodeMask);
+ keycode = short(keyInfo & keyCodeMask) >> 8 ;
+ }
+ long keyval = wxMacTranslateKey(keychar, keycode) ;
+ long realkeyval = keyval ;
+ if ( keyval == keychar )
+ {
+ // we are not on a special character combo -> pass the real os event-value to EVT_CHAR, but not to EVT_KEY (make upper first)
+ realkeyval = short(keymessage & charCodeMask) ;
+ keyval = wxToupper( keyval ) ;
+ }
+
+ wxKeyEvent event(wxEVT_KEY_DOWN);
+ bool handled = false ;
+ event.m_shiftDown = modifiers & shiftKey;
+ event.m_controlDown = modifiers & controlKey;
+ event.m_altDown = modifiers & optionKey;
+ event.m_metaDown = modifiers & cmdKey;
+ event.m_keyCode = keyval ;
+
+ event.m_x = wherex;
+ event.m_y = wherey;
+ event.m_timeStamp = when;
+ event.SetEventObject(focus);
+ handled = focus->GetEventHandler()->ProcessEvent( event ) ;
+ if ( handled && event.GetSkipped() )
+ handled = false ;
+ if ( !handled )
+ {
+#if wxUSE_ACCEL
+ if (!handled)
+ {
+ wxWindow *ancestor = focus;
+ while (ancestor)
+ {
+ int command = ancestor->GetAcceleratorTable()->GetCommand( event );
+ if (command != -1)
+ {
+ wxCommandEvent command_event( wxEVT_COMMAND_MENU_SELECTED, command );
+ handled = ancestor->GetEventHandler()->ProcessEvent( command_event );
+ break;
+ }
+ if (ancestor->IsTopLevel())
+ break;
+ ancestor = ancestor->GetParent();
+ }
+ }
+#endif // wxUSE_ACCEL
+ }
+ if (!handled)
+ {
+ event.Skip( FALSE ) ;
+ event.SetEventType( wxEVT_CHAR ) ;
+ // raw value again
+ event.m_keyCode = realkeyval ;
+
+ handled = focus->GetEventHandler()->ProcessEvent( event ) ;
+ if ( handled && event.GetSkipped() )
+ handled = false ;
+ }
+ if ( !handled &&
+ (keyval == WXK_TAB) &&
+// CS: copied the change below from wxGTK
+// VZ: testing for wxTE_PROCESS_TAB shouldn't be done here the control may
+// have this style, yet choose not to process this particular TAB in which
+// case TAB must still work as a navigational character
+#if 0
+ (!focus->HasFlag(wxTE_PROCESS_TAB)) &&
+#endif
+ (focus->GetParent()) &&
+ (focus->GetParent()->HasFlag( wxTAB_TRAVERSAL)) )
+ {
+ wxNavigationKeyEvent new_event;
+ new_event.SetEventObject( focus );
+ new_event.SetDirection( !event.ShiftDown() );
+ /* CTRL-TAB changes the (parent) window, i.e. switch notebook page */
+ new_event.SetWindowChange( event.ControlDown() );
+ new_event.SetCurrentFocus( focus );
+ handled = focus->GetEventHandler()->ProcessEvent( new_event );
+ if ( handled && new_event.GetSkipped() )
+ handled = false ;
+ }
+ // backdoor handler for default return and command escape
+ if ( !handled && (!focus->IsKindOf(CLASSINFO(wxControl) ) || !focus->MacCanFocus() ) )
+ {
+ // if window is not having a focus still testing for default enter or cancel
+ // TODO add the UMA version for ActiveNonFloatingWindow
+ wxWindow* focus = wxFindWinFromMacWindow( FrontWindow() ) ;
+ if ( focus )
+ {
+ if ( keyval == WXK_RETURN )
+ {
+ wxButton *def = wxDynamicCast(focus->GetDefaultItem(),
+ wxButton);
+ if ( def && def->IsEnabled() )
+ {
+ wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, def->GetId() );
+ event.SetEventObject(def);
+ def->Command(event);
+ return true ;
+ }
+ }
+ /* generate wxID_CANCEL if command-. or <esc> has been pressed (typically in dialogs) */
+ else if (keyval == WXK_ESCAPE || (keyval == '.' && modifiers & cmdKey ) )
+ {
+ wxCommandEvent new_event(wxEVT_COMMAND_BUTTON_CLICKED,wxID_CANCEL);
+ new_event.SetEventObject( focus );
+ handled = focus->GetEventHandler()->ProcessEvent( new_event );
+ }
+ }
+ }
+ return handled ;
+}
+
+bool wxApp::MacSendKeyUpEvent( wxWindow* focus , long keymessage , long modifiers , long when , short wherex , short wherey )
+{
+ if ( !focus )
+ return false ;
+
+ short keycode ;
+ short keychar ;
+ keychar = short(keymessage & charCodeMask);
+ keycode = short(keymessage & keyCodeMask) >> 8 ;
+ if ( modifiers & ( controlKey|shiftKey|optionKey ) )
+ {
+ // control interferes with some built-in keys like pgdown, return etc. therefore we remove the controlKey modifier
+ // and look at the character after
+ UInt32 state = 0;
+ UInt32 keyInfo = KeyTranslate((Ptr)GetScriptManagerVariable(smKCHRCache), ( modifiers & (~(controlKey|shiftKey|optionKey))) | keycode, &state);
+ keychar = short(keyInfo & charCodeMask);
+ keycode = short(keyInfo & keyCodeMask) >> 8 ;
+ }
+ long keyval = wxMacTranslateKey(keychar, keycode) ;
+
+ if ( keyval == keychar )
+ {
+ keyval = wxToupper( keyval ) ;
+ }
+ bool handled = false ;
+
+ wxKeyEvent event(wxEVT_KEY_UP);
+ event.m_shiftDown = modifiers & shiftKey;
+ event.m_controlDown = modifiers & controlKey;
+ event.m_altDown = modifiers & optionKey;
+ event.m_metaDown = modifiers & cmdKey;
+ event.m_keyCode = keyval ;
+
+ event.m_x = wherex;
+ event.m_y = wherey;
+ event.m_timeStamp = when;
+ event.SetEventObject(focus);
+ handled = focus->GetEventHandler()->ProcessEvent( event ) ;
+
+ return handled ;
+}
+
+#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