pcbnew: Force grid sizing based on text extents
GTK does not handle enlarged text layouts automatically, so we need to get the screen size before choosing the correct grid width for the dialog Fixes: lp:1788495 * https://bugs.launchpad.net/kicad/+bug/1788495
This commit is contained in:
parent
d06f0de1eb
commit
76600e3436
|
@ -374,6 +374,23 @@ bool DIALOG_FOOTPRINT_BOARD_EDITOR::TransferDataToWindow()
|
|||
// Show the footprint's ID.
|
||||
m_staticLibraryID->SetLabel( m_footprint->GetFPID().Format() );
|
||||
|
||||
// Work around an issue where wxWidgets doesn't calculate the row width on its own
|
||||
// TODO: Refactor this into a GRID_TRICKS routine or similar
|
||||
for( int col = 0; col < m_itemsGrid->GetNumberCols(); col++ )
|
||||
{
|
||||
// 'M' is generally the widest character, so we buffer the column width by default to ensure
|
||||
// we don't write a continuous line of text at the column header
|
||||
auto size = m_itemsGrid->GetTextExtent( m_itemsGrid->GetColLabelValue( col ) + "M").x;
|
||||
m_itemsGrid->SetColSize( col, std::max( m_itemsGrid->GetColumnWidth( col ), size ) );
|
||||
}
|
||||
|
||||
int size = m_itemsGrid->GetRowLabelSize();
|
||||
|
||||
for( int row = 0; row < m_itemsGrid->GetNumberRows(); row++ )
|
||||
size = std::max( size, m_itemsGrid->GetTextExtent( m_itemsGrid->GetRowLabelValue( row ) + "M" ).x );
|
||||
|
||||
m_itemsGrid->SetRowLabelSize( size );
|
||||
|
||||
Layout();
|
||||
adjustGridColumns( m_itemsGrid->GetRect().GetWidth());
|
||||
|
||||
|
|
|
@ -66,7 +66,14 @@ PANEL_SETUP_NETCLASSES::PANEL_SETUP_NETCLASSES( PAGED_DIALOG* aParent, PCB_EDIT_
|
|||
m_originalColWidths = new int[ m_netclassGrid->GetNumberCols() ];
|
||||
|
||||
for( int i = 0; i < m_netclassGrid->GetNumberCols(); ++i )
|
||||
m_originalColWidths[ i ] = m_netclassGrid->GetColSize( i );
|
||||
{
|
||||
// 'M' is generally the widest character, so we buffer the column width by default to ensure
|
||||
// we don't write a continuous line of text at the column header
|
||||
auto size = m_netclassGrid->GetTextExtent( m_netclassGrid->GetColLabelValue( i ) + "M");
|
||||
|
||||
m_originalColWidths[ i ] = std::max( m_netclassGrid->GetColSize( i ), size.x );
|
||||
m_netclassGrid->SetColSize( i, m_originalColWidths[ i ] );
|
||||
}
|
||||
|
||||
// Membership combobox editors require a bit more room, so increase the row size of
|
||||
// all our grids for consistency
|
||||
|
|
|
@ -65,6 +65,26 @@ PANEL_SETUP_TEXT_AND_GRAPHICS::PANEL_SETUP_TEXT_AND_GRAPHICS( PAGED_DIALOG* aPar
|
|||
|
||||
m_grid->SetDefaultRowSize( m_grid->GetDefaultRowSize() + 4 );
|
||||
|
||||
// Work around an issue where wxWidgets doesn't calculate the row width on its own
|
||||
for( int col = 0; col < m_grid->GetNumberCols(); col++ )
|
||||
{
|
||||
// 'M' is generally the widest character, so we buffer the column width by default to ensure
|
||||
// we don't write a continuous line of text at the column header
|
||||
auto size = m_grid->GetTextExtent( m_grid->GetColLabelValue( col ) + "M").x;
|
||||
|
||||
for( int row = 0; row < m_grid->GetNumberRows(); row++ )
|
||||
size = std::max( size, m_grid->GetTextExtent( m_grid->GetCellValue( row, col ) ).x );
|
||||
|
||||
m_grid->SetColSize( col, size);
|
||||
}
|
||||
|
||||
int size = m_grid->GetRowLabelSize();
|
||||
|
||||
for( int row = 0; row < m_grid->GetNumberRows(); row++ )
|
||||
size = std::max( size, m_grid->GetTextExtent( m_grid->GetRowLabelValue( row ) + "M" ).x );
|
||||
|
||||
m_grid->SetRowLabelSize( size );
|
||||
|
||||
// Work around a bug in wxWidgets where it fails to recalculate the grid height
|
||||
// after changing the default row size
|
||||
m_grid->AppendRows( 1 );
|
||||
|
|
Loading…
Reference in New Issue