Fix best size computation for wxTextCtrl without borders in wxMSW.

wxTextCtrl with wxBORDER_NONE (and possibly wxTE_READONLY) style is often used
instead of a wxStaticText to allow copying the text, so make the size of such
control the same as size of the label. This ensures that it aligns correctly
with the label vertically while before the baselines were not aligned because
a border-less text control was rendered by MSW as a label but had a too big
size.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@69066 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2011-09-11 21:55:47 +00:00
parent 7011055c55
commit df0419d21d

View File

@@ -2107,9 +2107,17 @@ wxSize wxTextCtrl::DoGetBestSize() const
}
//else: for single line control everything is ok
// we have to add the adjustments for the control height only once, not
// once per line, so do it after multiplication above
hText += EDIT_HEIGHT_FROM_CHAR_HEIGHT(cy) - cy;
// Text controls without border are special and have the same height as
// static labels (they also have the same appearance when they're disable
// and are often used as a sort of copyable to the clipboard label so it's
// important that they have the same height as the normal labels to not
// stand out).
if ( !HasFlag(wxBORDER_NONE) )
{
// we have to add the adjustments for the control height only once, not
// once per line, so do it after multiplication above
hText += EDIT_HEIGHT_FROM_CHAR_HEIGHT(cy) - cy;
}
return wxSize(wText, hText);
}