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;