From e279a9e799c3808b221dc459a3a81bd2c19b36ea Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 26 Dec 2010 16:29:22 +0000 Subject: [PATCH] Increase wxStaticText height in wxMSW to align its text with wxTextCtrl. The base lines of the text in wxTextCtrl and wxStaticText which were themselves vertically aligned didn't align, the text in the latter was one pixel too low. This seems to be happening because we don't give enough vertical space to the native static control by default and so, while the text wasn't truncated, it was positioned differently than usual. Work around this problem by allocating two extra pixels to wxStaticText height. While the exact explanation of the problem remains mysterious, this hack does result in correct appearance which seems to be sufficiently important to apply it. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@66452 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/msw/stattext.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/msw/stattext.cpp b/src/msw/stattext.cpp index a6e5b78744..572a8f8089 100644 --- a/src/msw/stattext.cpp +++ b/src/msw/stattext.cpp @@ -164,6 +164,25 @@ wxSize wxStaticText::DoGetBestClientSize() const widthTextMax += 2; #endif // __WXWINCE__ + // It looks like the static control needs "slightly" more vertical space + // than the character height and while the text isn't actually truncated if + // we use just the minimal height, it is positioned differently than when + // the control has enough space and this result in the text in edit and + // static controls not being aligned when the controls themselves are. As + // this is something you really should be able to count on, increase the + // space allocated for the control so that the base lines do align + // correctly. Notice that while the above is true at least for the single + // line controls, there doesn't seem to do any harm to allocate two extra + // pixels in multi-line case neither so do it always for consistency. + // + // I still have no idea why exactly is this needed nor why should we use 2 + // and not something else. This seems to work in all the configurations + // though (small/large fonts, different OS versions, ...) so just hard code + // it for now. If we need something better later it might be worth looking + // at the height of the text control returned by ::GetComboBoxInfo() as it + // seems to be the "minimal acceptable" height. + heightTextTotal += 2; + return wxSize(widthTextMax, heightTextTotal); } -- 2.45.2