use max of avg digit or 'average char' width to measure Edit space
instead of the x-width
this is similar to what gtk does
Change-Id: I2806939a09b275a3060ddf693e2763238a4e075f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121118
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
diff --git a/vcl/source/control/edit.cxx b/vcl/source/control/edit.cxx
index c2329c4..958b26e 100644
--- a/vcl/source/control/edit.cxx
+++ b/vcl/source/control/edit.cxx
@@ -2668,8 +2668,8 @@
{
// width for N characters, independent from content.
// works only correct for fixed fonts, average otherwise
Size aSz( GetTextWidth( "x" ), GetTextHeight() );
aSz.setWidth( aSz.Width() * nChars );
float fUnitWidth = std::max(approximate_char_width(), approximate_digit_width());
Size aSz(fUnitWidth * nChars, GetTextHeight());
aSz.AdjustWidth(ImplGetExtraXOffset() * 2 );
aSz = CalcWindowSize( aSz );
return aSz;
@@ -2679,8 +2679,8 @@
{
const vcl::Window* pW = mpSubEdit ? mpSubEdit : this;
sal_Int32 nOutWidth = pW->GetOutputSizePixel().Width();
sal_Int32 nCharWidth = GetTextWidth( "x" );
return nCharWidth ? nOutWidth/nCharWidth : 0;
float fUnitWidth = std::max(approximate_char_width(), approximate_digit_width());
return nOutWidth / fUnitWidth;
}
namespace vcl