X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/0a81f130246a2c22a47e2eed31d1e640bf94e0fe..917b00857982f2ca7247a9785c11a6a1d7e01943:/src/msw/window.cpp diff --git a/src/msw/window.cpp b/src/msw/window.cpp index d982f3ed22..609a1a4b31 100644 --- a/src/msw/window.cpp +++ b/src/msw/window.cpp @@ -182,6 +182,13 @@ extern wxMenu *wxCurrentPopupMenu; #endif +#if wxUSE_UXTHEME +// This is a hack used by the owner-drawn wxButton implementation to ensure +// that the brush used for erasing its background is correctly aligned with the +// control. +wxWindowMSW *wxWindowBeingErased = NULL; +#endif // wxUSE_UXTHEME + namespace { @@ -831,7 +838,7 @@ bool wxWindowMSW::SetCursor(const wxCursor& cursor) } // don't "overwrite" busy cursor - if ( m_cursor.Ok() && !wxIsBusy() ) + if ( m_cursor.IsOk() && !wxIsBusy() ) { // normally we should change the cursor only if it's over this window // but we should do it always if we capture the mouse currently @@ -1780,6 +1787,15 @@ void wxWindowMSW::DoGetClientSize(int *x, int *y) const if ( y ) *y = rect.bottom; } + + // The size of the client window can't be negative but ::GetClientRect() + // can return negative size for an extremely small (1x1) window with + // borders so ensure that we correct it here as having negative sizes is + // completely unexpected. + if ( x && *x < 0 ) + *x = 0; + if ( y && *y < 0 ) + *y = 0; } void wxWindowMSW::DoGetPosition(int *x, int *y) const @@ -2133,7 +2149,7 @@ void wxWindowMSW::DoGetTextExtent(const wxString& string, int *externalLeading, const wxFont *fontToUse) const { - wxASSERT_MSG( !fontToUse || fontToUse->Ok(), + wxASSERT_MSG( !fontToUse || fontToUse->IsOk(), wxT("invalid font in GetTextExtent()") ); HFONT hfontToUse; @@ -2197,18 +2213,16 @@ bool wxWindowMSW::DoPopupMenu(wxMenu *menu, int x, int y) { menu->UpdateUI(); + wxPoint pt; if ( x == wxDefaultCoord && y == wxDefaultCoord ) { - wxPoint mouse = ScreenToClient(wxGetMousePosition()); - x = mouse.x; y = mouse.y; + pt = wxGetMousePosition(); + } + else + { + pt = ClientToScreen(wxPoint(x, y)); } - HWND hWnd = GetHwnd(); - HMENU hMenu = GetHmenuOf(menu); - POINT point; - point.x = x; - point.y = y; - ::ClientToScreen(hWnd, &point); #if defined(__WXWINCE__) static const UINT flags = 0; #else // !__WXWINCE__ @@ -2226,7 +2240,7 @@ bool wxWindowMSW::DoPopupMenu(wxMenu *menu, int x, int y) } #endif // __WXWINCE__/!__WXWINCE__ - ::TrackPopupMenu(hMenu, flags, point.x, point.y, 0, hWnd, NULL); + ::TrackPopupMenu(GetHmenuOf(menu), flags, pt.x, pt.y, 0, GetHwnd(), NULL); // we need to do it right now as otherwise the events are never going to be // sent to wxCurrentPopupMenu from HandleCommand() @@ -2248,10 +2262,23 @@ bool wxWindowMSW::DoPopupMenu(wxMenu *menu, int x, int y) WXLRESULT wxWindowMSW::MSWDefWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam) { + WXLRESULT rc; if ( m_oldWndProc ) - return ::CallWindowProc(CASTWNDPROC m_oldWndProc, GetHwnd(), (UINT) nMsg, (WPARAM) wParam, (LPARAM) lParam); + rc = ::CallWindowProc(CASTWNDPROC m_oldWndProc, GetHwnd(), (UINT) nMsg, (WPARAM) wParam, (LPARAM) lParam); else - return ::DefWindowProc(GetHwnd(), nMsg, wParam, lParam); + rc = ::DefWindowProc(GetHwnd(), nMsg, wParam, lParam); + + // Special hack used by wxTextEntry auto-completion only: this event is + // sent after the normal keyboard processing so that its handler could use + // the updated contents of the text control, after taking the key that was + // pressed into account. + if ( nMsg == WM_CHAR ) + { + wxKeyEvent event(CreateCharEvent(wxEVT_AFTER_CHAR, wParam, lParam)); + HandleWindowEvent(event); + } + + return rc; } bool wxWindowMSW::MSWProcessMessage(WXMSG* pMsg) @@ -4161,7 +4188,7 @@ bool wxWindowMSW::HandleSetCursor(WXHWND WXUNUSED(hWnd), // m_cursor if the user code caught EVT_SET_CURSOR() and returned // nothing from it - this is a way to say that our cursor shouldn't // be used for this point - if ( !processedEvtSetCursor && m_cursor.Ok() ) + if ( !processedEvtSetCursor && m_cursor.IsOk() ) { hcursor = GetHcursorOf(m_cursor); } @@ -4169,7 +4196,7 @@ bool wxWindowMSW::HandleSetCursor(WXHWND WXUNUSED(hWnd), if ( !hcursor && !GetParent() ) { const wxCursor *cursor = wxGetGlobalCursor(); - if ( cursor && cursor->Ok() ) + if ( cursor && cursor->IsOk() ) { hcursor = GetHcursorOf(*cursor); } @@ -4606,7 +4633,7 @@ extern wxCOLORMAP *wxGetStdColourMap() // to. wxLogNull logNo; // suppress error if we couldn't load the bitmap wxBitmap stdColourBitmap(wxT("wxBITMAP_STD_COLOURS")); - if ( stdColourBitmap.Ok() ) + if ( stdColourBitmap.IsOk() ) { // the pixels in the bitmap must correspond to wxSTD_COL_XXX! wxASSERT_MSG( stdColourBitmap.GetWidth() == wxSTD_COL_MAX, @@ -4921,9 +4948,17 @@ wxWindowMSW::MSWGetBgBrushForChild(WXHDC hDC, wxWindowMSW *child) WXHBRUSH wxWindowMSW::MSWGetBgBrush(WXHDC hDC) { + // Use the special wxWindowBeingErased variable if it is set as the child + // being erased. + wxWindowMSW * const child = +#if wxUSE_UXTHEME + wxWindowBeingErased ? wxWindowBeingErased : +#endif + this; + for ( wxWindowMSW *win = this; win; win = win->GetParent() ) { - WXHBRUSH hBrush = win->MSWGetBgBrushForChild(hDC, this); + WXHBRUSH hBrush = win->MSWGetBgBrushForChild(hDC, child); if ( hBrush ) return hBrush; @@ -5660,11 +5695,12 @@ wxWindowMSW::CreateKeyEvent(wxEventType evType, return event; } -// isASCII is true only when we're called from WM_CHAR handler and not from -// WM_KEYDOWN one -bool wxWindowMSW::HandleChar(WXWPARAM wParam, WXLPARAM lParam) +wxKeyEvent +wxWindowMSW::CreateCharEvent(wxEventType evType, + WXWPARAM wParam, + WXLPARAM lParam) const { - wxKeyEvent event(wxEVT_CHAR); + wxKeyEvent event(evType); InitAnyKeyEvent(event, wParam, lParam); #if wxUSE_UNICODE @@ -5708,6 +5744,14 @@ bool wxWindowMSW::HandleChar(WXWPARAM wParam, WXLPARAM lParam) event.m_altDown = false; } + return event; +} + +// isASCII is true only when we're called from WM_CHAR handler and not from +// WM_KEYDOWN one +bool wxWindowMSW::HandleChar(WXWPARAM wParam, WXLPARAM lParam) +{ + wxKeyEvent event(CreateCharEvent(wxEVT_CHAR, wParam, lParam)); return HandleWindowEvent(event); }