X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/3ae670cd59711e19ed3c65dc7fd7fff102d52b69..1fd850ab550a30bc600d5a10c5aed5386bf3624b:/src/msw/window.cpp diff --git a/src/msw/window.cpp b/src/msw/window.cpp index 34e2e2bb4f..041edce030 100644 --- a/src/msw/window.cpp +++ b/src/msw/window.cpp @@ -81,6 +81,7 @@ #include "wx/msw/private.h" #include "wx/msw/private/keyboard.h" #include "wx/msw/dcclient.h" +#include "wx/private/textmeasure.h" #if wxUSE_TOOLTIPS #include "wx/tooltip.h" @@ -1429,7 +1430,7 @@ WXDWORD wxWindowMSW::MSWGetStyle(long flags, WXDWORD *exstyle) const // it doesn't seem useful to use WS_CLIPSIBLINGS here as we officially // don't support overlapping windows and it only makes sense for them and, // presumably, gives the system some extra work (to manage more clipping - // regions), so avoid it alltogether + // regions), so avoid it altogether if ( flags & wxVSCROLL ) @@ -2164,31 +2165,18 @@ void wxWindowMSW::DoGetTextExtent(const wxString& string, int *externalLeading, const wxFont *fontToUse) const { - wxASSERT_MSG( !fontToUse || fontToUse->IsOk(), - wxT("invalid font in GetTextExtent()") ); - - HFONT hfontToUse; - if ( fontToUse ) - hfontToUse = GetHfontOf(*fontToUse); + // ensure we work with a valid font + wxFont font; + if ( !fontToUse || !fontToUse->IsOk() ) + font = GetFont(); else - hfontToUse = GetHfontOf(GetFont()); + font = *fontToUse; - WindowHDC hdc(GetHwnd()); - SelectInHDC selectFont(hdc, hfontToUse); + wxCHECK_RET( font.IsOk(), wxT("invalid font in GetTextExtent()") ); - SIZE sizeRect; - TEXTMETRIC tm; - ::GetTextExtentPoint32(hdc, string.t_str(), string.length(), &sizeRect); - GetTextMetrics(hdc, &tm); - - if ( x ) - *x = sizeRect.cx; - if ( y ) - *y = sizeRect.cy; - if ( descent ) - *descent = tm.tmDescent; - if ( externalLeading ) - *externalLeading = tm.tmExternalLeading; + const wxWindow* win = static_cast(this); + wxTextMeasure txm(win, &font); + txm.GetTextExtent(string, x, y, descent, externalLeading); } // --------------------------------------------------------------------------- @@ -4828,6 +4816,8 @@ bool wxWindowMSW::HandlePaint() // be called from inside the event handlers called above) m_updateRegion.Clear(); + wxPaintDCImpl::EndPaint((wxWindow *)this); + return processed; } @@ -4969,7 +4959,11 @@ wxWindowMSW::MSWGetBgBrushForChild(WXHDC hDC, wxWindowMSW *child) ::MapWindowPoints(NULL, GetHwnd(), (POINT *)&rc, 1); - if ( !::SetBrushOrgEx((HDC)hDC, -rc.left, -rc.top, NULL) ) + int x = rc.left, + y = rc.top; + MSWAdjustBrushOrg(&x, &y); + + if ( !::SetBrushOrgEx((HDC)hDC, -x, -y, NULL) ) { wxLogLastError(wxT("SetBrushOrgEx(bg brush)")); } @@ -5461,7 +5455,7 @@ bool wxWindowMSW::HandleMouseEvent(WXUINT msg, int x, int y, WXUINT flags) }; #ifdef wxHAS_XBUTTON - // the same messages are used for both auxillary mouse buttons so we need + // the same messages are used for both auxiliary mouse buttons so we need // to adjust the index manually switch ( msg ) { @@ -5682,21 +5676,6 @@ MSWInitAnyKeyEvent(wxKeyEvent& event, #ifndef __WXWINCE__ event.SetTimestamp(::GetMessageTime()); #endif - - // Event coordinates must be in window client coordinates system which - // doesn't make sense if there is no window. - // - // We could use screen coordinates for such events but this would make the - // logic of the event handlers more complicated: you'd need to test for the - // event object and interpret the coordinates differently according to - // whether it's NULL or not so unless somebody really asks for this let's - // just avoid the issue. - if ( win ) - { - const wxPoint mousePos = win->ScreenToClient(wxGetMousePosition()); - event.m_x = mousePos.x; - event.m_y = mousePos.y; - } } } // anonymous namespace @@ -7230,9 +7209,21 @@ wxWindow* wxFindWindowAtPoint(const wxPoint& pt) { // WindowFromPoint() ignores the disabled children but we're supposed // to take them into account, so check if we have a child at this - // coordinate. - ::ScreenToClient(hWnd, &pt2); - hWnd = ::ChildWindowFromPointEx(hWnd, pt2, CWP_SKIPINVISIBLE); + // coordinate using ChildWindowFromPointEx(). + for ( ;; ) + { + pt2.x = pt.x; + pt2.y = pt.y; + ::ScreenToClient(hWnd, &pt2); + HWND child = ::ChildWindowFromPointEx(hWnd, pt2, CWP_SKIPINVISIBLE); + if ( child == hWnd || !child ) + break; + + // ChildWindowFromPointEx() only examines the immediate children + // but we want to get the deepest (top in Z-order) one, so continue + // iterating for as long as it finds anything. + hWnd = child; + } } return wxGetWindowFromHWND((WXHWND)hWnd);