X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/952f2aaa86db53c587a265485791b06afcc1e903..01cca03e20a1c58c977e1ea1252fda8c383ded5b:/src/msw/window.cpp diff --git a/src/msw/window.cpp b/src/msw/window.cpp index 50f56cd2a7..81bf8d2465 100644 --- a/src/msw/window.cpp +++ b/src/msw/window.cpp @@ -17,10 +17,6 @@ // headers // --------------------------------------------------------------------------- -#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) - #pragma implementation "window.h" -#endif - // For compilers that support precompilation, includes "wx.h". #include "wx/wxprec.h" @@ -165,8 +161,10 @@ wxWindow *wxFindWinFromHandle(WXHWND hWnd); // get the text metrics for the current font static TEXTMETRIC wxGetTextMetrics(const wxWindowMSW *win); +#ifdef __WXWINCE__ // find the window for the mouse event at the specified position -static wxWindowMSW *FindWindowForMouseEvent(wxWindowMSW *win, int *x, int *y); //TW:REQ:Univ +static wxWindowMSW *FindWindowForMouseEvent(wxWindowMSW *win, int *x, int *y); +#endif // __WXWINCE__ // wrapper around BringWindowToTop() API static inline void wxBringWindowToTop(HWND hwnd) @@ -798,7 +796,7 @@ bool wxWindowMSW::SetCursor(const wxCursor& cursor) return true; } -void wxWindowMSW::WarpPointer (int x, int y) +void wxWindowMSW::WarpPointer(int x, int y) { ClientToScreen(&x, &y); @@ -808,6 +806,28 @@ void wxWindowMSW::WarpPointer (int x, int y) } } +void wxWindowMSW::MSWUpdateUIState(int action) +{ + // WM_UPDATEUISTATE only appeared in Windows 2000 so it can do us no good + // to use it on older systems -- and could possibly do some harm + static int s_needToUpdate = -1; + if ( s_needToUpdate == -1 ) + { + int verMaj, verMin; + s_needToUpdate = wxGetOsVersion(&verMaj, &verMin) == wxWINDOWS_NT && + verMaj >= 5; + } + + if ( s_needToUpdate ) + { + // NB: it doesn't seem to matter what we put in wParam, whether we + // include just one UISF_XXX or both, both are affected, no idea + // why + ::SendMessage(GetHwnd(), WM_UPDATEUISTATE, + MAKEWPARAM(action, UISF_HIDEFOCUS | UISF_HIDEACCEL), 0); + } +} + // --------------------------------------------------------------------------- // scrolling stuff // --------------------------------------------------------------------------- @@ -1450,6 +1470,17 @@ void wxWindowMSW::DoSetToolTip(wxToolTip *tooltip) // moving and resizing // --------------------------------------------------------------------------- +bool wxWindowMSW::IsSizeDeferred() const +{ +#if USE_DEFERRED_SIZING + if ( m_pendingPosition != wxDefaultPosition || + m_pendingSize != wxDefaultSize ) + return true; +#endif // USE_DEFERRED_SIZING + + return false; +} + // Get total size void wxWindowMSW::DoGetSize(int *x, int *y) const { @@ -1975,7 +2006,10 @@ bool wxWindowMSW::MSWProcessMessage(WXMSG* pMsg) // it return false; } - else if ( lDlgCode & DLGC_BUTTON ) + + // currently active button should get enter press even + // if there is a default button elsewhere + if ( lDlgCode & DLGC_DEFPUSHBUTTON ) { // let IsDialogMessage() handle this for all // buttons except the owner-drawn ones which it @@ -1984,16 +2018,15 @@ bool wxWindowMSW::MSWProcessMessage(WXMSG* pMsg) if ( (style & BS_OWNERDRAW) == BS_OWNERDRAW ) { // emulate the button click - wxWindow *btn = wxFindWinFromHandle((WXHWND)msg->hwnd); + wxWindow * + btn = wxFindWinFromHandle((WXHWND)msg->hwnd); if ( btn ) btn->MSWCommand(BN_CLICKED, 0 /* unused */); } bProcess = false; } - // FIXME: this should be handled by - // wxNavigationKeyEvent handler and not here! - else + else // not a button itself { #if wxUSE_BUTTON wxButton *btn = wxDynamicCast(GetDefaultItem(), @@ -2046,6 +2079,12 @@ bool wxWindowMSW::MSWProcessMessage(WXMSG* pMsg) if ( GetEventHandler()->ProcessEvent(event) ) { + // as we don't call IsDialogMessage(), which would take of + // this by default, we need to manually send this message + // so that controls could change their appearance + // appropriately + MSWUpdateUIState(UIS_CLEAR); + return true; } } @@ -2490,8 +2529,10 @@ WXLRESULT wxWindowMSW::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM l int x = GET_X_LPARAM(lParam), y = GET_Y_LPARAM(lParam); +#ifdef __WXWINCE__ // redirect the event to a static control if necessary by - // finding one under mouse + // finding one under mouse because under CE the static controls + // don't generate mouse events (even with SS_NOTIFY) wxWindowMSW *win; if ( GetCapture() == this ) { @@ -2507,6 +2548,9 @@ WXLRESULT wxWindowMSW::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM l wxCHECK_MSG( win, 0, _T("FindWindowForMouseEvent() returned NULL") ); } +#else // !__WXWINCE__ + wxWindowMSW *win = this; +#endif // __WXWINCE__/!__WXWINCE__ processed = win->HandleMouseEvent(message, x, y, wParam); @@ -4226,7 +4270,7 @@ bool wxWindowMSW::HandleSize(int WXUNUSED(w), int WXUNUSED(h), WXUINT wParam) useDefer = true; } } -#endif +#endif // USE_DEFERRED_SIZING // update this window size bool processed = false; @@ -4455,6 +4499,7 @@ void wxWindowMSW::InitMouseEvent(wxMouseEvent& event, #endif // wxUSE_MOUSEEVENT_HACK } +#ifdef __WXWINCE__ // Windows doesn't send the mouse events to the static controls (which are // transparent in the sense that their WM_NCHITTEST handler returns // HTTRANSPARENT) at all but we want all controls to receive the mouse events @@ -4465,7 +4510,7 @@ void wxWindowMSW::InitMouseEvent(wxMouseEvent& event, // Notice that this is not done for the mouse move events because this could // (would?) be too slow, but only for clicks which means that the static texts // still don't get move, enter nor leave events. -static wxWindowMSW *FindWindowForMouseEvent(wxWindowMSW *win, int *x, int *y) //TW:REQ:Univ +static wxWindowMSW *FindWindowForMouseEvent(wxWindowMSW *win, int *x, int *y) { wxCHECK_MSG( x && y, win, _T("NULL pointer in FindWindowForMouseEvent") ); @@ -4518,6 +4563,7 @@ static wxWindowMSW *FindWindowForMouseEvent(wxWindowMSW *win, int *x, int *y) // return win; } +#endif // __WXWINCE__ bool wxWindowMSW::HandleMouseEvent(WXUINT msg, int x, int y, WXUINT flags) { @@ -4575,6 +4621,18 @@ bool wxWindowMSW::HandleMouseMove(int x, int y, WXUINT flags) (void)GetEventHandler()->ProcessEvent(event); } } +#ifdef HAVE_TRACKMOUSEEVENT + else + { + // Check if we need to send a LEAVE event + // Windows doesn't send WM_MOUSELEAVE if the mouse has been captured so + // send it here if we are using native mouse leave tracking + if ( HasCapture() && !IsMouseInWindow() ) + { + GenerateMouseLeave(); + } + } +#endif // HAVE_TRACKMOUSEEVENT #if wxUSE_MOUSEEVENT_HACK // Window gets a click down message followed by a mouse move message even