From 550b039d6cbcfaba2a01929e6a2cfd55ef6a581d Mon Sep 17 00:00:00 2001 From: Julian Smart Date: Wed, 24 Sep 2014 12:52:54 +0000 Subject: [PATCH] Improved search text control height and position on Windows. Was previously much too tall (regression from 3.0). git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@77880 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/generic/srchctlg.cpp | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/src/generic/srchctlg.cpp b/src/generic/srchctlg.cpp index f8fda72f51..6d4785fc53 100644 --- a/src/generic/srchctlg.cpp +++ b/src/generic/srchctlg.cpp @@ -126,7 +126,15 @@ protected: wxSearchTextCtrl* const self = const_cast(this); self->SetWindowStyleFlag((flags & ~wxBORDER_MASK) | wxBORDER_DEFAULT); - const wxSize size = wxTextCtrl::DoGetBestSize(); + wxSize size = wxTextCtrl::DoGetBestSize(); + + // The calculation for no external borders in wxTextCtrl::DoGetSizeFromTextSize also + // removes any padding around the value, which is wrong for this situation. So we + // can't use wxBORDER_NONE to calculate a good height, in which case we just have to + // assume a border in the code above and then subtract the space that would be taken up + // by a themed border (the thin blue border and the white internal border). + size.y -= 4; + self->SetWindowStyleFlag(flags); return size; @@ -515,7 +523,17 @@ void wxSearchCtrl::LayoutControls() x += sizeSearch.x; x += searchMargin; - m_text->SetSize(x, 0, textWidth, height); +#ifdef __WXMSW__ + // The text control is too high up on Windows; normally a text control looks OK because + // of the white border that's part of the theme border. We can also remove a pixel from + // the height to fit the text control in, because the padding in EDIT_HEIGHT_FROM_CHAR_HEIGHT + // is already generous. + int textY = 1; +#else + int textY = 0; +#endif + + m_text->SetSize(x, textY, textWidth, height-textY); x += textWidth; x += cancelMargin;