From 470a46dd48dd33d7f2ed6a34868d71135f2cc445 Mon Sep 17 00:00:00 2001 From: Artur Wieczorek Date: Tue, 23 Feb 2016 00:24:17 +0100 Subject: [PATCH] Fix wxSearchCtrl vertical size in wxMSW Don't add the borders twice, this made the control too tall. Closes #16817. --- docs/changes.txt | 1 + src/generic/srchctlg.cpp | 19 +++++++++++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/docs/changes.txt b/docs/changes.txt index 4de5cd0cc1..357baea490 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -634,6 +634,7 @@ wxMSW: - Fix RegisterHotKey() with negative IDs (troelsk). - Fix event object type for wxEVT_SPINCTRL events. - Fix bug if wxToolBar tool was deleted from its own handler (Artur Wieczorek). +- Improve wxSearchCtrl appearance, don't make it too tall (Artur Wieczorek). - Fix creating or modifying file associations under recent Windows versions. wxOSX: diff --git a/src/generic/srchctlg.cpp b/src/generic/srchctlg.cpp index 758a195cc9..34cde02264 100644 --- a/src/generic/srchctlg.cpp +++ b/src/generic/srchctlg.cpp @@ -456,7 +456,12 @@ wxSize wxSearchCtrl::DoGetBestSize() const // buttons are square and equal to the height of the text control int height = sizeText.y; return wxSize(sizeSearch.x + searchMargin + sizeText.x + cancelMargin + sizeCancel.x + 2*horizontalBorder, - height) + DoGetBorderSize(); +#ifdef __WXMSW__ + // Border is already added in wxSearchTextCtrl::DoGetBestSize() + height); +#else + height) + DoGetBorderSize(); +#endif } void wxSearchCtrl::DoMoveWindow(int x, int y, int width, int height) @@ -521,7 +526,17 @@ void wxSearchCtrl::DoLayoutControls() 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;