Return non-zero height from GetMultiLineTextExtent("") in wxMSW

This restores the previous behaviour inadvertently changed by bfeae1922d
(Minor optimizations in GetMultiLineTextExtent(), 2020-06-10) and makes
it official by documenting it and adding tests checking for it.

It wasn't completely obviously if this was intentional or accidental
before, but at least wxStaticText itself relied on the old behaviour,
and chances are that so did some code outside the library, so make this
part of the API now.

See #18825.
This commit is contained in:
Vadim Zeitlin
2020-07-15 01:23:29 +02:00
parent 46d6866c9f
commit d57c688d89
3 changed files with 19 additions and 1 deletions

View File

@@ -129,7 +129,13 @@ void wxTextMeasureBase::GetMultiLineTextExtent(const wxString& text,
// actually multiline specially here, to skip iteration above in this case.
if ( text.find('\n') == wxString::npos )
{
CallGetTextExtent(text, width, height);
// This case needs to be handled specially as we're supposed to return
// a non-zero height even for empty string.
if ( text.empty() )
*height = GetEmptyLineHeight();
else
CallGetTextExtent(text, width, height);
if ( heightOneLine )
*heightOneLine = *height;
return;