UNIT_BINDER: allows more room to show values (especially inches need room)

Fixes #15539
https://gitlab.com/kicad/code/kicad/-/issues/15539
This commit is contained in:
jean-pierre charras 2023-08-30 09:12:59 +02:00
parent f9b59b4fdf
commit 07e13c51d1
1 changed files with 4 additions and 1 deletions

View File

@ -66,8 +66,11 @@ UNIT_BINDER::UNIT_BINDER( UNITS_PROVIDER* aUnitsProvider, wxWindow* aEventSource
if( textEntry )
{
wxClientDC dc( m_valueCtrl );
// Gives enough room to display a value in inches i )n textEntry
// 4 digits + '.' + 10 digits + 2 chars (units) look enough.
wxSize minSize = m_valueCtrl->GetMinSize();
int minWidth = dc.GetTextExtent( wxT( "XXX.XXXXXXX" ) ).GetWidth();
int minWidth = dc.GetTextExtent( wxT( "XXXX.XXXXXXXXXXUU" ) ).GetWidth();
if( minSize.GetWidth() < minWidth )
m_valueCtrl->SetMinSize( wxSize( minWidth, minSize.GetHeight() ) );