Netclass panel: fix incorrect column sizes, that happens in a few languages.

The best size was calculated from a default size.
This default size (calculated by wxWidgets) was fully broken with some texts in a few languages.
So now this best size does not use this default size.

Fixes: lp:1816315
https://bugs.launchpad.net/kicad/+bug/1816315
This commit is contained in:
jean-pierre charras 2019-02-18 10:09:22 +01:00
parent 27b4f2fbe9
commit d62163cc7c
3 changed files with 11 additions and 4 deletions

View File

@ -64,11 +64,18 @@ PANEL_SETUP_NETCLASSES::PANEL_SETUP_NETCLASSES( PAGED_DIALOG* aParent, PCB_EDIT_
m_netclassesDirty = true;
m_originalColWidths = new int[ m_netclassGrid->GetNumberCols() ];
// Calculate a min best size to handle longest usual numeric values:
// (The 'M' large char is used to give a margin)
int min_best_width = m_netclassGrid->GetTextExtent( "555,555555 milsM" ).x;
for( int i = 0; i < m_netclassGrid->GetNumberCols(); ++i )
{
m_originalColWidths[ i ] = m_netclassGrid->GetVisibleWidth( i, true, true, true );
m_netclassGrid->SetColMinimalWidth( i, m_originalColWidths[ i ] );
// We calculate the column min size only from texts sizes, not using the initial col width
// as this initial width is sometimes strange depending on the language (wxGrid bug?)
int min_width = m_netclassGrid->GetVisibleWidth( i, true, true, false );
m_netclassGrid->SetColMinimalWidth( i, min_width );
// We use a "best size" >= min_best_width
m_originalColWidths[ i ] = std::max( min_width, min_best_width );
m_netclassGrid->SetColSize( i, m_originalColWidths[ i ] );
}

View File

@ -57,7 +57,7 @@ PANEL_SETUP_NETCLASSES_BASE::PANEL_SETUP_NETCLASSES_BASE( wxWindow* parent, wxWi
m_netclassGrid->SetColLabelAlignment( wxALIGN_CENTER, wxALIGN_CENTER );
// Rows
m_netclassGrid->EnableDragRowSize( false );
m_netclassGrid->EnableDragRowSize( true );
m_netclassGrid->SetRowLabelSize( 0 );
m_netclassGrid->SetRowLabelValue( 0, _("Default") );
m_netclassGrid->SetRowLabelAlignment( wxALIGN_LEFT, wxALIGN_CENTER );

View File

@ -117,7 +117,7 @@
<property name="drag_col_move">0</property>
<property name="drag_col_size">1</property>
<property name="drag_grid_size">0</property>
<property name="drag_row_size">0</property>
<property name="drag_row_size">1</property>
<property name="editing">1</property>
<property name="enabled">1</property>
<property name="fg"></property>