X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/d76048f514b0de4307c2490f8806bf41033bc81a..1c405bb51093fc7812fb66e7d47faac5707e02b5:/src/mgl/window.cpp diff --git a/src/mgl/window.cpp b/src/mgl/window.cpp index 346c33f826..86b882527f 100644 --- a/src/mgl/window.cpp +++ b/src/mgl/window.cpp @@ -118,7 +118,7 @@ static void CaptureScreenshot() // MGL_WM hooks: // --------------------------------------------------------------------------- -static void wxWindowPainter(window_t *wnd, MGLDC *dc) +static void MGLAPI wxWindowPainter(window_t *wnd, MGLDC *dc) { wxWindowMGL *w = (wxWindow*) wnd->userData; @@ -129,7 +129,7 @@ static void wxWindowPainter(window_t *wnd, MGLDC *dc) } } -static ibool wxWindowMouseHandler(window_t *wnd, event_t *e) +static ibool MGLAPI wxWindowMouseHandler(window_t *wnd, event_t *e) { wxWindowMGL *win = (wxWindowMGL*)MGL_wmGetWindowUserData(wnd); wxPoint orig(win->GetClientAreaOrigin()); @@ -248,7 +248,20 @@ static ibool wxWindowMouseHandler(window_t *wnd, event_t *e) static long wxScanToKeyCode(event_t *event) { - #define KEY(mgl,wx) case mgl: key = wx; break; + // VS: make it __WXDEBUG__-only, since we have lots of wxLogTrace calls + // here and the arguments would be stored in non-debug executable even + // though wxLogTrace would be no-op... + #ifdef __WXDEBUG__ + #define KEY(mgl_key,wx_key) \ + case mgl_key: \ + wxLogTrace(_T("keyevents"), \ + _T("key " #mgl_key ", mapped to " #wx_key)); \ + key = wx_key; \ + break; + #else + #define KEY(mgl_key,wx_key) \ + case mgl_key: key = wx_key; break; + #endif long key = 0; switch ( EVT_scanCode(event->message) ) @@ -374,7 +387,7 @@ static long wxAsciiToKeyCode(event_t *event) return (long)EVT_asciiCode(event->message); } -static ibool wxWindowKeybHandler(window_t *wnd, event_t *e) +static ibool MGLAPI wxWindowKeybHandler(window_t *wnd, event_t *e) { wxWindowMGL *win = (wxWindowMGL*)MGL_wmGetWindowUserData(wnd); @@ -437,9 +450,9 @@ static ibool wxWindowKeybHandler(window_t *wnd, event_t *e) } #endif // wxUSE_ACCEL - /* wxMSW doesn't send char events with Alt pressed */ - /* Only send wxEVT_CHAR event if not processed yet. Thus, ALT-x - will only be sent if it is not in an accelerator table. */ + // wxMSW doesn't send char events with Alt pressed + // Only send wxEVT_CHAR event if not processed yet. Thus, ALT-x + // will only be sent if it is not in an accelerator table. event2.m_keyCode = wxAsciiToKeyCode(e); if ( !ret && event2.m_keyCode != 0 ) { @@ -447,6 +460,22 @@ static ibool wxWindowKeybHandler(window_t *wnd, event_t *e) ret = win->GetEventHandler()->ProcessEvent(event2); } + // Synthetize navigation key event, but do it only if the TAB key + // wasn't handled yet. + // FIXME_MGL - isn't this wxUniv's business? + if ( !ret && event.m_keyCode == WXK_TAB && + win->GetParent() && win->GetParent()->HasFlag(wxTAB_TRAVERSAL) ) + { + wxNavigationKeyEvent navEvent; + navEvent.SetEventObject(win->GetParent()); + // Shift-TAB goes in reverse direction: + navEvent.SetDirection(!event.m_shiftDown); + // Ctrl-TAB changes the (parent) window, i.e. switch notebook page: + navEvent.SetWindowChange(event.m_controlDown); + navEvent.SetCurrentFocus(wxStaticCast(win, wxWindow)); + ret = win->GetParent()->GetEventHandler()->ProcessEvent(navEvent); + } + return ret; } } @@ -469,12 +498,17 @@ END_EVENT_TABLE() // constructors and such // ---------------------------------------------------------------------------- +extern wxDisplayModeInfo wxGetDefaultDisplayMode(); + void wxWindowMGL::Init() { // First of all, make sure window manager is up and running. If it is // not the case, initialize it in default display mode if ( !g_winMng ) - wxTheApp->SetDisplayMode(wxDisplayModeInfo(640, 480, 16)); + { + if ( !wxTheApp->SetDisplayMode(wxGetDefaultDisplayMode()) ) + wxFatalError(_("Cannot initialize display.")); + } // generic: InitBase(); @@ -704,7 +738,7 @@ void wxWindowMGL::Lower() MGL_wmLowerWindow(m_wnd); } -void wxWindowMGL::CaptureMouse() +void wxWindowMGL::DoCaptureMouse() { if ( gs_mouseCapture ) MGL_wmUncaptureEvents(gs_mouseCapture->m_wnd, wxMGL_CAPTURE_MOUSE); @@ -713,7 +747,7 @@ void wxWindowMGL::CaptureMouse() MGL_wmCaptureEvents(m_wnd, EVT_MOUSEEVT, wxMGL_CAPTURE_MOUSE); } -void wxWindowMGL::ReleaseMouse() +void wxWindowMGL::DoReleaseMouse() { wxASSERT_MSG( gs_mouseCapture == this, wxT("attempt to release mouse, but this window hasn't captured it") )