From 82668e1e850343d4183bf9b798442813126dcdb9 Mon Sep 17 00:00:00 2001 From: Maarten Bent Date: Sun, 3 Nov 2019 17:13:25 +0100 Subject: [PATCH] Remove FromDIP in wxGetEditHeightFromCharHeight This caused wxTextCtrl to become to high at higher DPI. It was added to fix appearance of wxSearchCtrl at high DPI. Remove an unneeded FromDIP there too, so it gets the same height as a normal wxTextCtrl. And centre the textctrl inside the searchctrl. --- include/wx/msw/private.h | 7 ++++--- src/generic/srchctlg.cpp | 5 +++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/include/wx/msw/private.h b/include/wx/msw/private.h index f850b7b554..e413799050 100644 --- a/include/wx/msw/private.h +++ b/include/wx/msw/private.h @@ -91,12 +91,13 @@ WXDLLIMPEXP_BASE void wxSetInstance(HINSTANCE hInst); // Return the height of a native text control corresponding to the given // character height (as returned by GetCharHeight() or wxGetCharSize()). // -// The wxWindow parameter must be valid and used for getting the DPI. -inline int wxGetEditHeightFromCharHeight(int cy, const wxWindow* w) +// The wxWindow parameter is currently not used but should still be valid. +inline int wxGetEditHeightFromCharHeight(int cy, const wxWindow* WXUNUSED(w)) { // The value 8 here is empiric, i.e. it's not necessarily correct, but // seems to work relatively well. - return cy + w->FromDIP(8); + // Don't use FromDIP(8), this seems not needed. + return cy + 8; } // Compatibility macro used in the existing code. It assumes that it's called diff --git a/src/generic/srchctlg.cpp b/src/generic/srchctlg.cpp index 583c6fd710..edf227ab5f 100644 --- a/src/generic/srchctlg.cpp +++ b/src/generic/srchctlg.cpp @@ -132,7 +132,8 @@ protected: // 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 -= FromDIP(4); + // Don't use FromDIP(4), this seems not needed. + size.y -= 4; self->SetWindowStyleFlag(flags); @@ -533,7 +534,7 @@ void wxSearchCtrl::LayoutControls() // 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 = FromDIP(2); + int textY = FromDIP(1); #else int textY = 0; #endif