Fix: Pcbnew net class editor is chopping off net class names

Fixes: lp:1616599
* https://bugs.launchpad.net/kicad/+bug/1616599
This commit is contained in:
jp-charras 2016-08-25 09:35:35 +02:00
parent 91e953868a
commit 9d5300b284
2 changed files with 33 additions and 4 deletions

View File

@ -117,15 +117,15 @@ void NETS_LIST_CTRL::SetRowItems( unsigned aRow,
*/
// @todo: maybe move this to common.cpp if it works.
void EnsureGridColumnWidths( wxGrid* aGrid )
static void EnsureGridColumnWidths( wxWindow* aShower, wxGrid* aGrid )
{
wxScreenDC sDC;
wxWindowDC sDC( aShower );
sDC.SetFont( aGrid->GetLabelFont() );
int colCount = aGrid->GetNumberCols();
for( int col = 0; col<colCount; ++col )
for( int col = 0; col < colCount; ++col )
{
// add two spaces to the text and size it.
wxString colText = aGrid->GetColLabelValue( col ) + wxT( " " );
@ -137,6 +137,28 @@ void EnsureGridColumnWidths( wxGrid* aGrid )
}
}
static void EnsureGridRowTitleWidth( wxWindow* aShower, wxGrid* aGrid, int aMinWidth )
{
wxWindowDC sDC( aShower );
sDC.SetFont( aGrid->GetLabelFont() );
int minsize = aMinWidth;
int rowCount = aGrid->GetNumberRows();
for( int row = 0; row < rowCount; ++row )
{
// add two spaces to the text and size it.
wxString rowText = aGrid->GetRowLabelValue( row ) + wxT( " " );
wxSize needed = sDC.GetTextExtent( rowText );
minsize = std::max( minsize, needed.x );
}
// set the width of the row laberls
aGrid->SetRowLabelSize( minsize );
}
DIALOG_DESIGN_RULES::DIALOG_DESIGN_RULES( PCB_EDIT_FRAME* parent ) :
DIALOG_DESIGN_RULES_BASE( parent )
@ -144,7 +166,8 @@ DIALOG_DESIGN_RULES::DIALOG_DESIGN_RULES( PCB_EDIT_FRAME* parent ) :
m_Parent = parent;
SetAutoLayout( true );
EnsureGridColumnWidths( m_grid ); // override any column widths set by wxformbuilder.
m_initialRowLabelsSize = m_grid->GetRowLabelSize();
EnsureGridColumnWidths( this, m_grid ); // override any column widths set by wxformbuilder.
wxListItem column0;
wxListItem column1;
@ -175,6 +198,8 @@ DIALOG_DESIGN_RULES::DIALOG_DESIGN_RULES( PCB_EDIT_FRAME* parent ) :
}
InitDialogRules();
EnsureGridRowTitleWidth( this, m_grid, m_initialRowLabelsSize );
m_sdbSizer1OK->SetDefault();
// Allow tabbing out of grid controls.
@ -704,6 +729,8 @@ void DIALOG_DESIGN_RULES::OnAddNetclassClick( wxCommandEvent& event )
m_grid->SetCellValue( irow, icol, value );
}
EnsureGridRowTitleWidth( this, m_grid, m_initialRowLabelsSize );
InitializeRulesSelectionBoxes();
}
@ -758,6 +785,7 @@ void DIALOG_DESIGN_RULES::OnRemoveNetclassClick( wxCommandEvent& event )
m_grid->SetRowLabelValue( ii, labels[ii] );
InitializeRulesSelectionBoxes();
EnsureGridRowTitleWidth( this, m_grid, m_initialRowLabelsSize );
}
}

View File

@ -69,6 +69,7 @@ private:
BOARD_DESIGN_SETTINGS* m_BrdSettings;
static int s_LastTabSelection; ///< which tab user had open last
int m_initialRowLabelsSize; ///< the initial width given by wxFormBuilder
/**
* A two column table which gets filled once and never loses any elements, so it is