Add defensive coding for column widths in Fields Editor.

This commit is contained in:
Jeff Young 2018-04-19 21:39:25 +01:00
parent 9201417c06
commit b9239d8728
2 changed files with 16 additions and 9 deletions

View File

@ -368,6 +368,10 @@ public:
}; };
#define SHOW_COL_SIZE 50
#define GROUPBY_COL_SIZE 70
DIALOG_FIELDS_EDITOR_GLOBAL::DIALOG_FIELDS_EDITOR_GLOBAL( SCH_EDIT_FRAME* parent ) : DIALOG_FIELDS_EDITOR_GLOBAL::DIALOG_FIELDS_EDITOR_GLOBAL( SCH_EDIT_FRAME* parent ) :
DIALOG_FIELDS_EDITOR_GLOBAL_BASE( parent ), DIALOG_FIELDS_EDITOR_GLOBAL_BASE( parent ),
m_parent( parent ) m_parent( parent )
@ -379,8 +383,10 @@ DIALOG_FIELDS_EDITOR_GLOBAL::DIALOG_FIELDS_EDITOR_GLOBAL( SCH_EDIT_FRAME* parent
m_bRefresh->SetBitmap( KiBitmap( refresh_xpm ) ); m_bRefresh->SetBitmap( KiBitmap( refresh_xpm ) );
m_fieldsCtrl->AppendTextColumn( _( "Field" ), wxDATAVIEW_CELL_INERT ); m_fieldsCtrl->AppendTextColumn( _( "Field" ), wxDATAVIEW_CELL_INERT );
m_fieldsCtrl->AppendToggleColumn( _( "Show" ), wxDATAVIEW_CELL_ACTIVATABLE, 50, wxALIGN_CENTER, 0 ); m_fieldsCtrl->AppendToggleColumn( _( "Show" ), wxDATAVIEW_CELL_ACTIVATABLE,
m_fieldsCtrl->AppendToggleColumn( _( "Group By" ), wxDATAVIEW_CELL_ACTIVATABLE, 70, wxALIGN_CENTER, 0 ); SHOW_COL_SIZE, wxALIGN_CENTER, 0 );
m_fieldsCtrl->AppendToggleColumn( _( "Group By" ), wxDATAVIEW_CELL_ACTIVATABLE,
GROUPBY_COL_SIZE, wxALIGN_CENTER, 0 );
// The fact that we're a list should keep the control from reserving space for the // The fact that we're a list should keep the control from reserving space for the
// expander buttons... but it doesn't. Fix by forcing the indent to 0. // expander buttons... but it doesn't. Fix by forcing the indent to 0.
@ -581,12 +587,13 @@ void DIALOG_FIELDS_EDITOR_GLOBAL::OnTableItemContextMenu( wxGridEvent& event )
void DIALOG_FIELDS_EDITOR_GLOBAL::OnSizeFieldList( wxSizeEvent& event ) void DIALOG_FIELDS_EDITOR_GLOBAL::OnSizeFieldList( wxSizeEvent& event )
{ {
int newWidth = event.GetSize().GetX(); int nameColSize = event.GetSize().GetX() - SHOW_COL_SIZE - GROUPBY_COL_SIZE - 8;
newWidth -= m_fieldsCtrl->GetColumn( 1 )->GetWidth(); // Linux loses its head and messes these up when resizing the splitter bar:
newWidth -= m_fieldsCtrl->GetColumn( 2 )->GetWidth(); m_fieldsCtrl->GetColumn( 1 )->SetWidth( SHOW_COL_SIZE );
m_fieldsCtrl->GetColumn( 2 )->SetWidth( GROUPBY_COL_SIZE );
m_fieldsCtrl->GetColumn( 0 )->SetWidth( newWidth - 8 ); m_fieldsCtrl->GetColumn( 0 )->SetWidth( nameColSize );
event.Skip(); event.Skip();
} }

View File

@ -262,7 +262,7 @@
<property name="orient">wxVERTICAL</property> <property name="orient">wxVERTICAL</property>
<property name="permission">none</property> <property name="permission">none</property>
<object class="sizeritem" expanded="1"> <object class="sizeritem" expanded="1">
<property name="border">3</property> <property name="border">2</property>
<property name="flag">wxALL|wxBOTTOM|wxEXPAND|wxTOP</property> <property name="flag">wxALL|wxBOTTOM|wxEXPAND|wxTOP</property>
<property name="proportion">0</property> <property name="proportion">0</property>
<object class="wxBoxSizer" expanded="1"> <object class="wxBoxSizer" expanded="1">
@ -411,7 +411,7 @@
<property name="maximum_size"></property> <property name="maximum_size"></property>
<property name="min_size"></property> <property name="min_size"></property>
<property name="minimize_button">0</property> <property name="minimize_button">0</property>
<property name="minimum_size">30,28</property> <property name="minimum_size">30,30</property>
<property name="moveable">1</property> <property name="moveable">1</property>
<property name="name">m_bRefresh</property> <property name="name">m_bRefresh</property>
<property name="pane_border">1</property> <property name="pane_border">1</property>