Cleaning SelectNet window display
Select net has two columns, so we should limit the column width to the size of the grid. The size should adjust with the window, so we take the size of the first column as fixed and assign the rest of the grid width to the second column.
This commit is contained in:
parent
5e30e4d475
commit
85921535b3
|
@ -67,10 +67,15 @@ public:
|
|||
private:
|
||||
void onCellClick( wxGridEvent& event ) override;
|
||||
void onFilterChange( wxCommandEvent& event ) override;
|
||||
void onColumnResize( wxGridSizeEvent& event ) override;
|
||||
void onSelectCell( wxGridEvent& event ) override;
|
||||
void updateSize( wxSizeEvent& event ) override;
|
||||
|
||||
void setColumnSize();
|
||||
void buildNetsList();
|
||||
|
||||
wxString m_selection;
|
||||
int m_firstWidth;
|
||||
bool m_wasSelected;
|
||||
BOARD* m_brd;
|
||||
PCB_EDIT_FRAME* m_frame;
|
||||
|
@ -98,12 +103,14 @@ DIALOG_SELECT_NET_FROM_LIST::DIALOG_SELECT_NET_FROM_LIST( PCB_EDIT_FRAME* aParen
|
|||
|
||||
// Choose selection mode
|
||||
m_netsListGrid->SetSelectionMode( wxGrid::wxGridSelectRows );
|
||||
|
||||
buildNetsList();
|
||||
|
||||
m_sdbSizerOK->SetDefault();
|
||||
GetSizer()->SetSizeHints( this );
|
||||
Center();
|
||||
|
||||
m_firstWidth = m_netsListGrid->GetColumnWidth( 0 );
|
||||
setColumnSize();
|
||||
}
|
||||
|
||||
|
||||
|
@ -194,6 +201,13 @@ void DIALOG_SELECT_NET_FROM_LIST::HighlightNet( bool aEnabled, const wxString& a
|
|||
}
|
||||
}
|
||||
|
||||
void DIALOG_SELECT_NET_FROM_LIST::setColumnSize()
|
||||
{
|
||||
auto size = m_netsListGrid->GetGridWindow()->GetSize();
|
||||
|
||||
m_netsListGrid->SetColumnWidth( 0, m_firstWidth );
|
||||
m_netsListGrid->SetColumnWidth( 1, size.x - m_firstWidth );
|
||||
}
|
||||
|
||||
DIALOG_SELECT_NET_FROM_LIST::~DIALOG_SELECT_NET_FROM_LIST()
|
||||
{
|
||||
|
@ -206,9 +220,38 @@ void DIALOG_SELECT_NET_FROM_LIST::onFilterChange( wxCommandEvent& event )
|
|||
}
|
||||
|
||||
|
||||
void DIALOG_SELECT_NET_FROM_LIST::updateSize( wxSizeEvent& event )
|
||||
{
|
||||
setColumnSize();
|
||||
this->Refresh();
|
||||
event.Skip();
|
||||
}
|
||||
|
||||
|
||||
void DIALOG_SELECT_NET_FROM_LIST::onColumnResize( wxGridSizeEvent& event )
|
||||
{
|
||||
m_firstWidth = m_netsListGrid->GetColumnWidth( 0 );
|
||||
setColumnSize();
|
||||
}
|
||||
|
||||
|
||||
void DIALOG_SELECT_NET_FROM_LIST::onSelectCell( wxGridEvent& event )
|
||||
{
|
||||
|
||||
int selected_row = event.GetRow();
|
||||
m_selection = m_netsListGrid->GetCellValue( selected_row, COL_NETNAME );
|
||||
|
||||
// Select the full row when clicking on any cell off the row
|
||||
m_netsListGrid->SelectRow( selected_row, false );
|
||||
|
||||
HighlightNet( true, m_selection );
|
||||
}
|
||||
|
||||
|
||||
void DIALOG_SELECT_NET_FROM_LIST::onCellClick( wxGridEvent& event )
|
||||
{
|
||||
int selected_row = event.GetRow();
|
||||
|
||||
m_selection = m_netsListGrid->GetCellValue( selected_row, COL_NETNAME );
|
||||
m_wasSelected = true;
|
||||
|
||||
|
|
|
@ -46,8 +46,8 @@ DIALOG_SELECT_NET_FROM_LIST_BASE::DIALOG_SELECT_NET_FROM_LIST_BASE( wxWindow* pa
|
|||
m_netsListGrid->SetMargins( 0, 0 );
|
||||
|
||||
// Columns
|
||||
m_netsListGrid->SetColSize( 0, 325 );
|
||||
m_netsListGrid->SetColSize( 1, 100 );
|
||||
m_netsListGrid->SetColSize( 0, 300 );
|
||||
m_netsListGrid->SetColSize( 1, 130 );
|
||||
m_netsListGrid->EnableDragColMove( false );
|
||||
m_netsListGrid->EnableDragColSize( true );
|
||||
m_netsListGrid->SetColLabelSize( 20 );
|
||||
|
@ -89,16 +89,22 @@ DIALOG_SELECT_NET_FROM_LIST_BASE::DIALOG_SELECT_NET_FROM_LIST_BASE( wxWindow* pa
|
|||
this->Centre( wxBOTH );
|
||||
|
||||
// Connect Events
|
||||
this->Connect( wxEVT_SIZE, wxSizeEventHandler( DIALOG_SELECT_NET_FROM_LIST_BASE::updateSize ) );
|
||||
m_textCtrlFilter->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_SELECT_NET_FROM_LIST_BASE::onFilterChange ), NULL, this );
|
||||
m_cbShowZeroPad->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_SELECT_NET_FROM_LIST_BASE::onFilterChange ), NULL, this );
|
||||
m_netsListGrid->Connect( wxEVT_GRID_CELL_LEFT_CLICK, wxGridEventHandler( DIALOG_SELECT_NET_FROM_LIST_BASE::onCellClick ), NULL, this );
|
||||
m_netsListGrid->Connect( wxEVT_GRID_COL_SIZE, wxGridSizeEventHandler( DIALOG_SELECT_NET_FROM_LIST_BASE::onColumnResize ), NULL, this );
|
||||
m_netsListGrid->Connect( wxEVT_GRID_SELECT_CELL, wxGridEventHandler( DIALOG_SELECT_NET_FROM_LIST_BASE::onSelectCell ), NULL, this );
|
||||
}
|
||||
|
||||
DIALOG_SELECT_NET_FROM_LIST_BASE::~DIALOG_SELECT_NET_FROM_LIST_BASE()
|
||||
{
|
||||
// Disconnect Events
|
||||
this->Disconnect( wxEVT_SIZE, wxSizeEventHandler( DIALOG_SELECT_NET_FROM_LIST_BASE::updateSize ) );
|
||||
m_textCtrlFilter->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_SELECT_NET_FROM_LIST_BASE::onFilterChange ), NULL, this );
|
||||
m_cbShowZeroPad->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_SELECT_NET_FROM_LIST_BASE::onFilterChange ), NULL, this );
|
||||
m_netsListGrid->Disconnect( wxEVT_GRID_CELL_LEFT_CLICK, wxGridEventHandler( DIALOG_SELECT_NET_FROM_LIST_BASE::onCellClick ), NULL, this );
|
||||
m_netsListGrid->Disconnect( wxEVT_GRID_COL_SIZE, wxGridSizeEventHandler( DIALOG_SELECT_NET_FROM_LIST_BASE::onColumnResize ), NULL, this );
|
||||
m_netsListGrid->Disconnect( wxEVT_GRID_SELECT_CELL, wxGridEventHandler( DIALOG_SELECT_NET_FROM_LIST_BASE::onSelectCell ), NULL, this );
|
||||
|
||||
}
|
||||
|
|
|
@ -87,18 +87,18 @@
|
|||
<event name="OnRightDown"></event>
|
||||
<event name="OnRightUp"></event>
|
||||
<event name="OnSetFocus"></event>
|
||||
<event name="OnSize"></event>
|
||||
<event name="OnSize">updateSize</event>
|
||||
<event name="OnUpdateUI"></event>
|
||||
<object class="wxBoxSizer" expanded="0">
|
||||
<object class="wxBoxSizer" expanded="1">
|
||||
<property name="minimum_size"></property>
|
||||
<property name="name">bSizerMain</property>
|
||||
<property name="orient">wxVERTICAL</property>
|
||||
<property name="permission">none</property>
|
||||
<object class="sizeritem" expanded="0">
|
||||
<object class="sizeritem" expanded="1">
|
||||
<property name="border">5</property>
|
||||
<property name="flag">wxEXPAND</property>
|
||||
<property name="proportion">0</property>
|
||||
<object class="wxFlexGridSizer" expanded="0">
|
||||
<object class="wxFlexGridSizer" expanded="1">
|
||||
<property name="cols">3</property>
|
||||
<property name="flexible_direction">wxBOTH</property>
|
||||
<property name="growablecols">1</property>
|
||||
|
@ -405,7 +405,7 @@
|
|||
<property name="col_label_values">"Net name" "Number of pads"</property>
|
||||
<property name="col_label_vert_alignment">wxALIGN_CENTRE</property>
|
||||
<property name="cols">2</property>
|
||||
<property name="column_sizes">325,100</property>
|
||||
<property name="column_sizes">300,130</property>
|
||||
<property name="context_help"></property>
|
||||
<property name="context_menu">1</property>
|
||||
<property name="default_pane">0</property>
|
||||
|
@ -484,7 +484,7 @@
|
|||
<event name="OnGridCmdRangeSelect"></event>
|
||||
<event name="OnGridCmdRowSize"></event>
|
||||
<event name="OnGridCmdSelectCell"></event>
|
||||
<event name="OnGridColSize"></event>
|
||||
<event name="OnGridColSize">onColumnResize</event>
|
||||
<event name="OnGridEditorCreated"></event>
|
||||
<event name="OnGridEditorHidden"></event>
|
||||
<event name="OnGridEditorShown"></event>
|
||||
|
@ -494,7 +494,7 @@
|
|||
<event name="OnGridLabelRightDClick"></event>
|
||||
<event name="OnGridRangeSelect"></event>
|
||||
<event name="OnGridRowSize"></event>
|
||||
<event name="OnGridSelectCell"></event>
|
||||
<event name="OnGridSelectCell">onSelectCell</event>
|
||||
<event name="OnKeyDown"></event>
|
||||
<event name="OnKeyUp"></event>
|
||||
<event name="OnKillFocus"></event>
|
||||
|
|
|
@ -47,8 +47,11 @@ class DIALOG_SELECT_NET_FROM_LIST_BASE : public DIALOG_SHIM
|
|||
wxButton* m_sdbSizerCancel;
|
||||
|
||||
// Virtual event handlers, overide them in your derived class
|
||||
virtual void updateSize( wxSizeEvent& event ) { event.Skip(); }
|
||||
virtual void onFilterChange( wxCommandEvent& event ) { event.Skip(); }
|
||||
virtual void onCellClick( wxGridEvent& event ) { event.Skip(); }
|
||||
virtual void onColumnResize( wxGridSizeEvent& event ) { event.Skip(); }
|
||||
virtual void onSelectCell( wxGridEvent& event ) { event.Skip(); }
|
||||
|
||||
|
||||
public:
|
||||
|
|
Loading…
Reference in New Issue