From 2b59c976f2e8a691580af23002ca0eb0a5e5e53a Mon Sep 17 00:00:00 2001 From: Thomas Pointhuber Date: Mon, 27 Aug 2018 21:38:39 +0200 Subject: [PATCH] Add Insert/Delete button to Tracks and Via setup panel GRID_TRICKS cannot handle row label events at the moment, so I disabled them. Fixes: lp:1788877 * https://bugs.launchpad.net/kicad/+bug/1788877 --- .../dialogs/panel_setup_tracks_and_vias.cpp | 233 ++++++- pcbnew/dialogs/panel_setup_tracks_and_vias.h | 13 + .../panel_setup_tracks_and_vias_base.cpp | 93 ++- .../panel_setup_tracks_and_vias_base.fbp | 635 +++++++++++++++++- .../panel_setup_tracks_and_vias_base.h | 20 + 5 files changed, 945 insertions(+), 49 deletions(-) diff --git a/pcbnew/dialogs/panel_setup_tracks_and_vias.cpp b/pcbnew/dialogs/panel_setup_tracks_and_vias.cpp index 32620e2ff1..69cca386e2 100644 --- a/pcbnew/dialogs/panel_setup_tracks_and_vias.cpp +++ b/pcbnew/dialogs/panel_setup_tracks_and_vias.cpp @@ -27,11 +27,31 @@ #include #include #include +#include #include #include +enum TRACK_VAR_GRID_COLUMNS +{ + TR_WIDTH_COL = 0 +}; + +enum VIA_VAR_GRID_COLUMNS +{ + VIA_SIZE_COL = 0, + VIA_DRILL_COL +}; + +enum DIFF_VAR_GRID_COLUMNS +{ + DP_WIDTH_COL = 0, + DP_GAP_COL, + DP_VIA_GAP_COL +}; + + PANEL_SETUP_TRACKS_AND_VIAS::PANEL_SETUP_TRACKS_AND_VIAS( PAGED_DIALOG* aParent, PCB_EDIT_FRAME* aFrame, PANEL_SETUP_FEATURE_CONSTRAINTS* aConstraintsPanel ) : @@ -43,48 +63,66 @@ PANEL_SETUP_TRACKS_AND_VIAS::PANEL_SETUP_TRACKS_AND_VIAS( m_BrdSettings = &m_Pcb->GetDesignSettings(); m_ConstraintsPanel = aConstraintsPanel; + m_trackWidthsAddButton->SetBitmap( KiBitmap( small_plus_xpm ) ); + m_trackWidthsRemoveButton->SetBitmap( KiBitmap( trash_xpm ) ); + m_viaSizesAddButton->SetBitmap( KiBitmap( small_plus_xpm ) ); + m_viaSizesRemoveButton->SetBitmap( KiBitmap( trash_xpm ) ); + m_diffPairsAddButton->SetBitmap( KiBitmap( small_plus_xpm ) ); + m_diffPairsRemoveButton->SetBitmap( KiBitmap( trash_xpm ) ); + // Membership combobox editors require a bit more room, so increase the row size of // all our grids for consistency m_trackWidthsGrid->SetDefaultRowSize( m_trackWidthsGrid->GetDefaultRowSize() + 4 ); m_viaSizesGrid->SetDefaultRowSize( m_viaSizesGrid->GetDefaultRowSize() + 4 ); m_diffPairsGrid->SetDefaultRowSize( m_diffPairsGrid->GetDefaultRowSize() + 4 ); + + m_trackWidthsGrid->PushEventHandler( new GRID_TRICKS( m_trackWidthsGrid ) ); + m_viaSizesGrid->PushEventHandler( new GRID_TRICKS( m_viaSizesGrid ) ); + m_diffPairsGrid->PushEventHandler( new GRID_TRICKS( m_diffPairsGrid ) ); + + m_trackWidthsGrid->SetSelectionMode( wxGrid::wxGridSelectionModes::wxGridSelectRows ); + m_viaSizesGrid->SetSelectionMode( wxGrid::wxGridSelectionModes::wxGridSelectRows ); + m_diffPairsGrid->SetSelectionMode( wxGrid::wxGridSelectionModes::wxGridSelectRows ); } +PANEL_SETUP_TRACKS_AND_VIAS::~PANEL_SETUP_TRACKS_AND_VIAS() +{ + // Delete the GRID_TRICKS. + m_trackWidthsGrid->PopEventHandler( true ); + m_viaSizesGrid->PopEventHandler( true ); + m_diffPairsGrid->PopEventHandler( true ); +} bool PANEL_SETUP_TRACKS_AND_VIAS::TransferDataToWindow() { -#define SETCELL( grid, row, col, val ) \ - grid->SetCellValue( row, col, StringFromValue( m_Frame->GetUserUnits(), val, true, true ) ) + if( m_trackWidthsGrid->GetNumberRows() > 0 ) + m_trackWidthsGrid->DeleteRows( 0, m_trackWidthsGrid->GetNumberRows() ); - m_trackWidthsGrid->ClearGrid(); - m_viaSizesGrid->ClearGrid(); - m_diffPairsGrid->ClearGrid(); + if( m_viaSizesGrid->GetNumberRows() > 0 ) + m_viaSizesGrid->DeleteRows( 0, m_viaSizesGrid->GetNumberRows() ); + + if( m_diffPairsGrid->GetNumberRows() > 0 ) + m_diffPairsGrid->DeleteRows( 0, m_diffPairsGrid->GetNumberRows() ); // Skip the first item, which is the current netclass value for( unsigned ii = 1; ii < m_BrdSettings->m_TrackWidthList.size(); ii++ ) { - SETCELL( m_trackWidthsGrid, ii-1, 0, m_BrdSettings->m_TrackWidthList[ii] ); + AppendTrackWidth( m_BrdSettings->m_TrackWidthList[ii] ); } // Skip the first item, which is the current netclass value for( unsigned ii = 1; ii < m_BrdSettings->m_ViasDimensionsList.size(); ii++ ) { - SETCELL( m_viaSizesGrid, ii-1, 0, m_BrdSettings->m_ViasDimensionsList[ii].m_Diameter ); - - if( m_BrdSettings->m_ViasDimensionsList[ii].m_Drill > 0 ) - SETCELL( m_viaSizesGrid, ii-1, 1, m_BrdSettings->m_ViasDimensionsList[ii].m_Drill ); + AppendViaSize( m_BrdSettings->m_ViasDimensionsList[ii].m_Diameter, + m_BrdSettings->m_ViasDimensionsList[ii].m_Drill ); } // Skip the first item, which is the current netclass value for( unsigned ii = 1; ii < m_BrdSettings->m_DiffPairDimensionsList.size(); ii++ ) { - SETCELL( m_diffPairsGrid, ii-1, 0, m_BrdSettings->m_DiffPairDimensionsList[ii].m_Width ); - - if( m_BrdSettings->m_DiffPairDimensionsList[ii].m_Gap > 0 ) - SETCELL( m_diffPairsGrid, ii-1, 1, m_BrdSettings->m_DiffPairDimensionsList[ii].m_Gap ); - - if( m_BrdSettings->m_DiffPairDimensionsList[ii].m_ViaGap > 0 ) - SETCELL( m_diffPairsGrid, ii-1, 2, m_BrdSettings->m_DiffPairDimensionsList[ii].m_ViaGap ); + AppendDiffPairs( m_BrdSettings->m_DiffPairDimensionsList[ii].m_Width, + m_BrdSettings->m_DiffPairDimensionsList[ii].m_Gap, + m_BrdSettings->m_DiffPairDimensionsList[ii].m_ViaGap ); } return true; @@ -101,9 +139,16 @@ bool PANEL_SETUP_TRACKS_AND_VIAS::TransferDataFromWindow() std::vector vias; std::vector diffPairs; + if( !m_trackWidthsGrid->CommitPendingChanges() + || !m_viaSizesGrid->CommitPendingChanges() + || !m_diffPairsGrid->CommitPendingChanges() ) + { + return false; + } + for( int row = 0; row < m_trackWidthsGrid->GetNumberRows(); ++row ) { - msg = m_trackWidthsGrid->GetCellValue( row, 0 ); + msg = m_trackWidthsGrid->GetCellValue( row, TR_WIDTH_COL ); if( !msg.IsEmpty() ) trackWidths.push_back( ValueFromString( m_Frame->GetUserUnits(), msg, true ) ); @@ -111,14 +156,14 @@ bool PANEL_SETUP_TRACKS_AND_VIAS::TransferDataFromWindow() for( int row = 0; row < m_viaSizesGrid->GetNumberRows(); ++row ) { - msg = m_viaSizesGrid->GetCellValue( row, 0 ); + msg = m_viaSizesGrid->GetCellValue( row, VIA_SIZE_COL ); if( !msg.IsEmpty() ) { VIA_DIMENSION via_dim; via_dim.m_Diameter = ValueFromString( m_Frame->GetUserUnits(), msg, true ); - msg = m_viaSizesGrid->GetCellValue( row, 1 ); + msg = m_viaSizesGrid->GetCellValue( row, VIA_DRILL_COL ); if( !msg.IsEmpty() ) via_dim.m_Drill = ValueFromString( m_Frame->GetUserUnits(), msg, true ); @@ -127,19 +172,19 @@ bool PANEL_SETUP_TRACKS_AND_VIAS::TransferDataFromWindow() } } - for( int row = 0; row < m_viaSizesGrid->GetNumberRows(); ++row ) + for( int row = 0; row < m_diffPairsGrid->GetNumberRows(); ++row ) { - msg = m_diffPairsGrid->GetCellValue( row, 0 ); + msg = m_diffPairsGrid->GetCellValue( row, DP_WIDTH_COL ); if( !msg.IsEmpty() ) { DIFF_PAIR_DIMENSION diffPair_dim; diffPair_dim.m_Width = ValueFromString( m_Frame->GetUserUnits(), msg, true ); - msg = m_diffPairsGrid->GetCellValue( row, 1 ); + msg = m_diffPairsGrid->GetCellValue( row, DP_GAP_COL ); diffPair_dim.m_Gap = ValueFromString( m_Frame->GetUserUnits(), msg, true ); - msg = m_diffPairsGrid->GetCellValue( row, 2 ); + msg = m_diffPairsGrid->GetCellValue( row, DP_VIA_GAP_COL ); if( !msg.IsEmpty() ) diffPair_dim.m_ViaGap = ValueFromString( m_Frame->GetUserUnits(), msg, true ); @@ -171,7 +216,9 @@ bool PANEL_SETUP_TRACKS_AND_VIAS::validateData() if( !m_trackWidthsGrid->CommitPendingChanges() || !m_viaSizesGrid->CommitPendingChanges() || !m_diffPairsGrid->CommitPendingChanges() ) + { return false; + } wxString msg; int minViaDia = m_ConstraintsPanel->m_viaMinSize.GetValue(); @@ -181,7 +228,7 @@ bool PANEL_SETUP_TRACKS_AND_VIAS::validateData() // Test tracks for( int row = 0; row < m_trackWidthsGrid->GetNumberRows(); ++row ) { - wxString tvalue = m_trackWidthsGrid->GetCellValue( row, 0 ); + wxString tvalue = m_trackWidthsGrid->GetCellValue( row, TR_WIDTH_COL ); if( tvalue.IsEmpty() ) continue; @@ -190,7 +237,7 @@ bool PANEL_SETUP_TRACKS_AND_VIAS::validateData() { msg.Printf( _( "Track width less than minimum track width (%s)." ), StringFromValue( m_Frame->GetUserUnits(), minTrackWidth, true, true ) ); - m_Parent->SetError( msg, this, m_trackWidthsGrid, row, 0 ); + m_Parent->SetError( msg, this, m_trackWidthsGrid, row, TR_WIDTH_COL ); return false; } } @@ -198,7 +245,7 @@ bool PANEL_SETUP_TRACKS_AND_VIAS::validateData() // Test vias for( int row = 0; row < m_viaSizesGrid->GetNumberRows(); ++row ) { - wxString viaDia = m_viaSizesGrid->GetCellValue( row, 0 ); + wxString viaDia = m_viaSizesGrid->GetCellValue( row, VIA_SIZE_COL ); if( viaDia.IsEmpty() ) continue; @@ -207,16 +254,16 @@ bool PANEL_SETUP_TRACKS_AND_VIAS::validateData() { msg.Printf( _( "Via diameter less than minimum via diameter (%s)." ), StringFromValue( m_Frame->GetUserUnits(), minViaDia, true, true ) ); - m_Parent->SetError( msg, this, m_viaSizesGrid, row, 0 ); + m_Parent->SetError( msg, this, m_viaSizesGrid, row, VIA_SIZE_COL ); return false; } - wxString viaDrill = m_viaSizesGrid->GetCellValue( row, 1 ); + wxString viaDrill = m_viaSizesGrid->GetCellValue( row, VIA_DRILL_COL ); if( viaDrill.IsEmpty() ) { msg = _( "No via drill defined." ); - m_Parent->SetError( msg, this, m_viaSizesGrid, row, 1 ); + m_Parent->SetError( msg, this, m_viaSizesGrid, row, VIA_DRILL_COL ); return false; } @@ -224,7 +271,7 @@ bool PANEL_SETUP_TRACKS_AND_VIAS::validateData() { msg.Printf( _( "Via drill less than minimum via drill (%s)." ), StringFromValue( m_Frame->GetUserUnits(), minViaDrill, true, true ) ); - m_Parent->SetError( msg, this, m_viaSizesGrid, row, 1 ); + m_Parent->SetError( msg, this, m_viaSizesGrid, row, VIA_DRILL_COL ); return false; } @@ -232,7 +279,7 @@ bool PANEL_SETUP_TRACKS_AND_VIAS::validateData() >= ValueFromString( m_Frame->GetUserUnits(), viaDia ) ) { msg = _( "Via drill larger than via diameter." ); - m_Parent->SetError( msg, this, m_viaSizesGrid, row, 1 ); + m_Parent->SetError( msg, this, m_viaSizesGrid, row, VIA_DRILL_COL ); return false; } } @@ -304,4 +351,126 @@ void PANEL_SETUP_TRACKS_AND_VIAS::ImportSettingsFrom( BOARD* aBoard ) m_BrdSettings = savedSettings; } +void PANEL_SETUP_TRACKS_AND_VIAS::AppendTrackWidth( const int aWidth ) +{ + int i = m_trackWidthsGrid->GetNumberRows(); + m_trackWidthsGrid->AppendRows( 1 ); + + wxString val = StringFromValue( m_Frame->GetUserUnits(), aWidth, true, true ); + m_trackWidthsGrid->SetCellValue( i, TR_WIDTH_COL, val ); +} + +void PANEL_SETUP_TRACKS_AND_VIAS::AppendViaSize( const int aSize, const int aDrill ) +{ + int i = m_viaSizesGrid->GetNumberRows(); + + m_viaSizesGrid->AppendRows( 1 ); + + wxString val = StringFromValue( m_Frame->GetUserUnits(), aSize, true, true ); + m_viaSizesGrid->SetCellValue( i, VIA_SIZE_COL, val ); + + if( aDrill > 0 ) + { + val = StringFromValue( m_Frame->GetUserUnits(), aDrill, true, true ); + m_viaSizesGrid->SetCellValue( i, VIA_DRILL_COL, val ); + } +} + +void PANEL_SETUP_TRACKS_AND_VIAS::AppendDiffPairs( const int aWidth, const int aGap, + const int aViaGap ) +{ + int i = m_diffPairsGrid->GetNumberRows(); + + m_diffPairsGrid->AppendRows( 1 ); + + wxString val = StringFromValue( m_Frame->GetUserUnits(), aWidth, true, true ); + m_diffPairsGrid->SetCellValue( i, DP_WIDTH_COL, val ); + + if( aGap > 0 ) + { + val = StringFromValue( m_Frame->GetUserUnits(), aGap, true, true ); + m_diffPairsGrid->SetCellValue( i, DP_GAP_COL, val ); + } + + if( aViaGap > 0 ) + { + val = StringFromValue( m_Frame->GetUserUnits(), aViaGap, true, true ); + m_diffPairsGrid->SetCellValue( i, DP_VIA_GAP_COL, val ); + } +} + +void PANEL_SETUP_TRACKS_AND_VIAS::OnAddTrackWidthsClick( wxCommandEvent& aEvent ) +{ + AppendTrackWidth( 0 ); + + m_trackWidthsGrid->MakeCellVisible( m_trackWidthsGrid->GetNumberRows() - 1, TR_WIDTH_COL ); + m_trackWidthsGrid->SetGridCursor( m_trackWidthsGrid->GetNumberRows() - 1, TR_WIDTH_COL ); + + m_trackWidthsGrid->EnableCellEditControl( true ); + m_trackWidthsGrid->ShowCellEditControl(); +} + +void PANEL_SETUP_TRACKS_AND_VIAS::OnRemoveTrackWidthsClick( wxCommandEvent& event ) +{ + int curRow = m_trackWidthsGrid->GetGridCursorRow(); + + if( curRow < 0 || m_trackWidthsGrid->GetNumberRows() <= curRow ) + return; + + m_trackWidthsGrid->DeleteRows( curRow, 1 ); + + curRow = std::max( 0, curRow - 1 ); + m_trackWidthsGrid->MakeCellVisible( curRow, m_trackWidthsGrid->GetGridCursorCol() ); + m_trackWidthsGrid->SetGridCursor( curRow, m_trackWidthsGrid->GetGridCursorCol() ); +} + +void PANEL_SETUP_TRACKS_AND_VIAS::OnAddViaSizesClick( wxCommandEvent& event ) +{ + AppendViaSize( 0, 0 ); + + m_viaSizesGrid->MakeCellVisible( m_viaSizesGrid->GetNumberRows() - 1, VIA_SIZE_COL ); + m_viaSizesGrid->SetGridCursor( m_viaSizesGrid->GetNumberRows() - 1, VIA_SIZE_COL ); + + m_viaSizesGrid->EnableCellEditControl( true ); + m_viaSizesGrid->ShowCellEditControl(); +} + +void PANEL_SETUP_TRACKS_AND_VIAS::OnRemoveViaSizesClick( wxCommandEvent& event ) +{ + int curRow = m_viaSizesGrid->GetGridCursorRow(); + + if( curRow < 0 || m_viaSizesGrid->GetNumberRows() <= curRow ) + return; + + m_viaSizesGrid->DeleteRows( curRow, 1 ); + + curRow = std::max( 0, curRow - 1 ); + m_viaSizesGrid->MakeCellVisible( curRow, m_viaSizesGrid->GetGridCursorCol() ); + m_viaSizesGrid->SetGridCursor( curRow, m_viaSizesGrid->GetGridCursorCol() ); +} + +void PANEL_SETUP_TRACKS_AND_VIAS::OnAddDiffPairsClick( wxCommandEvent& event ) +{ + AppendDiffPairs( 0, 0, 0 ); + + m_diffPairsGrid->MakeCellVisible( m_diffPairsGrid->GetNumberRows() - 1, DP_WIDTH_COL ); + m_diffPairsGrid->SetGridCursor( m_diffPairsGrid->GetNumberRows() - 1, DP_WIDTH_COL ); + + m_diffPairsGrid->EnableCellEditControl( true ); + m_diffPairsGrid->ShowCellEditControl(); +} + +void PANEL_SETUP_TRACKS_AND_VIAS::OnRemoveDiffPairsClick( wxCommandEvent& event ) +{ + int curRow = m_diffPairsGrid->GetGridCursorRow(); + + if( curRow < 0 || m_diffPairsGrid->GetNumberRows() <= curRow ) + return; + + m_diffPairsGrid->DeleteRows( curRow, 1 ); + + curRow = std::max( 0, curRow - 1 ); + m_diffPairsGrid->MakeCellVisible( curRow, m_diffPairsGrid->GetGridCursorCol() ); + m_diffPairsGrid->SetGridCursor( curRow, m_diffPairsGrid->GetGridCursorCol() ); +} diff --git a/pcbnew/dialogs/panel_setup_tracks_and_vias.h b/pcbnew/dialogs/panel_setup_tracks_and_vias.h index 1a53e726b7..22e3220a47 100644 --- a/pcbnew/dialogs/panel_setup_tracks_and_vias.h +++ b/pcbnew/dialogs/panel_setup_tracks_and_vias.h @@ -50,9 +50,22 @@ private: bool validateData(); +protected: + void OnAddTrackWidthsClick( wxCommandEvent& event ) override; + void OnRemoveTrackWidthsClick( wxCommandEvent& event ) override; + void OnAddViaSizesClick( wxCommandEvent& event ) override; + void OnRemoveViaSizesClick( wxCommandEvent& event ) override; + void OnAddDiffPairsClick( wxCommandEvent& event ) override; + void OnRemoveDiffPairsClick( wxCommandEvent& event ) override; + + void AppendTrackWidth( const int aWidth ); + void AppendViaSize( const int aSize, const int aDrill ); + void AppendDiffPairs( const int aWidth, const int aGap, const int aViaGap ); + public: PANEL_SETUP_TRACKS_AND_VIAS( PAGED_DIALOG* aParent, PCB_EDIT_FRAME* aFrame, PANEL_SETUP_FEATURE_CONSTRAINTS* aConstraintsPanel ); + ~PANEL_SETUP_TRACKS_AND_VIAS() override; bool TransferDataToWindow() override; bool TransferDataFromWindow() override; diff --git a/pcbnew/dialogs/panel_setup_tracks_and_vias_base.cpp b/pcbnew/dialogs/panel_setup_tracks_and_vias_base.cpp index a09ac0ddfc..bc693609ba 100644 --- a/pcbnew/dialogs/panel_setup_tracks_and_vias_base.cpp +++ b/pcbnew/dialogs/panel_setup_tracks_and_vias_base.cpp @@ -36,7 +36,7 @@ PANEL_SETUP_TRACKS_AND_VIAS_BASE::PANEL_SETUP_TRACKS_AND_VIAS_BASE( wxWindow* pa m_trackWidthsGrid->SetMargins( 0, 0 ); // Columns - m_trackWidthsGrid->SetColSize( 0, 100 ); + m_trackWidthsGrid->SetColSize( 0, 125 ); m_trackWidthsGrid->EnableDragColMove( false ); m_trackWidthsGrid->EnableDragColSize( false ); m_trackWidthsGrid->SetColLabelSize( 22 ); @@ -45,7 +45,7 @@ PANEL_SETUP_TRACKS_AND_VIAS_BASE::PANEL_SETUP_TRACKS_AND_VIAS_BASE( wxWindow* pa // Rows m_trackWidthsGrid->EnableDragRowSize( false ); - m_trackWidthsGrid->SetRowLabelSize( 30 ); + m_trackWidthsGrid->SetRowLabelSize( 0 ); m_trackWidthsGrid->SetRowLabelValue( 0, _("1") ); m_trackWidthsGrid->SetRowLabelValue( 1, _("2") ); m_trackWidthsGrid->SetRowLabelValue( 2, _("3") ); @@ -62,6 +62,25 @@ PANEL_SETUP_TRACKS_AND_VIAS_BASE::PANEL_SETUP_TRACKS_AND_VIAS_BASE( wxWindow* pa m_trackWidthsGrid->SetDefaultCellAlignment( wxALIGN_LEFT, wxALIGN_TOP ); sbSizer4->Add( m_trackWidthsGrid, 1, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); + wxBoxSizer* bSizer3; + bSizer3 = new wxBoxSizer( wxHORIZONTAL ); + + m_trackWidthsAddButton = new wxBitmapButton( sbSizer4->GetStaticBox(), wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, 0 ); + m_trackWidthsAddButton->SetMinSize( wxSize( 30,30 ) ); + + bSizer3->Add( m_trackWidthsAddButton, 0, wxLEFT|wxRIGHT, 5 ); + + + bSizer3->Add( 0, 0, 0, wxEXPAND|wxLEFT|wxRIGHT, 5 ); + + m_trackWidthsRemoveButton = new wxBitmapButton( sbSizer4->GetStaticBox(), wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, 0 ); + m_trackWidthsRemoveButton->SetMinSize( wxSize( 30,30 ) ); + + bSizer3->Add( m_trackWidthsRemoveButton, 0, wxLEFT|wxRIGHT, 5 ); + + + sbSizer4->Add( bSizer3, 0, wxEXPAND|wxTOP, 2 ); + bSizerLower->Add( sbSizer4, 0, wxRIGHT|wxLEFT|wxEXPAND, 5 ); @@ -78,8 +97,8 @@ PANEL_SETUP_TRACKS_AND_VIAS_BASE::PANEL_SETUP_TRACKS_AND_VIAS_BASE( wxWindow* pa m_viaSizesGrid->SetMargins( 0, 0 ); // Columns - m_viaSizesGrid->SetColSize( 0, 100 ); - m_viaSizesGrid->SetColSize( 1, 100 ); + m_viaSizesGrid->SetColSize( 0, 110 ); + m_viaSizesGrid->SetColSize( 1, 110 ); m_viaSizesGrid->EnableDragColMove( false ); m_viaSizesGrid->EnableDragColSize( false ); m_viaSizesGrid->SetColLabelSize( 22 ); @@ -89,7 +108,7 @@ PANEL_SETUP_TRACKS_AND_VIAS_BASE::PANEL_SETUP_TRACKS_AND_VIAS_BASE( wxWindow* pa // Rows m_viaSizesGrid->EnableDragRowSize( false ); - m_viaSizesGrid->SetRowLabelSize( 30 ); + m_viaSizesGrid->SetRowLabelSize( 0 ); m_viaSizesGrid->SetRowLabelValue( 0, _("1") ); m_viaSizesGrid->SetRowLabelValue( 1, _("2") ); m_viaSizesGrid->SetRowLabelValue( 2, _("3") ); @@ -106,8 +125,27 @@ PANEL_SETUP_TRACKS_AND_VIAS_BASE::PANEL_SETUP_TRACKS_AND_VIAS_BASE( wxWindow* pa m_viaSizesGrid->SetDefaultCellAlignment( wxALIGN_LEFT, wxALIGN_TOP ); sbSizer5->Add( m_viaSizesGrid, 1, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); + wxBoxSizer* bSizer4; + bSizer4 = new wxBoxSizer( wxHORIZONTAL ); - bSizerLower->Add( sbSizer5, 0, wxEXPAND|wxRIGHT|wxLEFT, 5 ); + m_viaSizesAddButton = new wxBitmapButton( sbSizer5->GetStaticBox(), wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, 0 ); + m_viaSizesAddButton->SetMinSize( wxSize( 30,30 ) ); + + bSizer4->Add( m_viaSizesAddButton, 0, wxLEFT|wxRIGHT, 5 ); + + + bSizer4->Add( 0, 0, 0, wxEXPAND|wxLEFT|wxRIGHT, 5 ); + + m_viaSizesRemoveButton = new wxBitmapButton( sbSizer5->GetStaticBox(), wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, 0 ); + m_viaSizesRemoveButton->SetMinSize( wxSize( 30,30 ) ); + + bSizer4->Add( m_viaSizesRemoveButton, 0, wxLEFT|wxRIGHT, 5 ); + + + sbSizer5->Add( bSizer4, 0, wxEXPAND|wxTOP, 2 ); + + + bSizerLower->Add( sbSizer5, 0, wxEXPAND|wxRIGHT|wxLEFT, 10 ); wxStaticBoxSizer* sbSizer6; sbSizer6 = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Differential Pairs") ), wxVERTICAL ); @@ -122,9 +160,9 @@ PANEL_SETUP_TRACKS_AND_VIAS_BASE::PANEL_SETUP_TRACKS_AND_VIAS_BASE( wxWindow* pa m_diffPairsGrid->SetMargins( 0, 0 ); // Columns - m_diffPairsGrid->SetColSize( 0, 100 ); - m_diffPairsGrid->SetColSize( 1, 100 ); - m_diffPairsGrid->SetColSize( 2, 100 ); + m_diffPairsGrid->SetColSize( 0, 110 ); + m_diffPairsGrid->SetColSize( 1, 110 ); + m_diffPairsGrid->SetColSize( 2, 110 ); m_diffPairsGrid->EnableDragColMove( false ); m_diffPairsGrid->EnableDragColSize( true ); m_diffPairsGrid->SetColLabelSize( 22 ); @@ -135,7 +173,7 @@ PANEL_SETUP_TRACKS_AND_VIAS_BASE::PANEL_SETUP_TRACKS_AND_VIAS_BASE( wxWindow* pa // Rows m_diffPairsGrid->EnableDragRowSize( true ); - m_diffPairsGrid->SetRowLabelSize( 30 ); + m_diffPairsGrid->SetRowLabelSize( 0 ); m_diffPairsGrid->SetRowLabelValue( 0, _("1") ); m_diffPairsGrid->SetRowLabelValue( 1, _("2") ); m_diffPairsGrid->SetRowLabelValue( 2, _("3") ); @@ -153,6 +191,25 @@ PANEL_SETUP_TRACKS_AND_VIAS_BASE::PANEL_SETUP_TRACKS_AND_VIAS_BASE( wxWindow* pa m_diffPairsGrid->SetDefaultCellAlignment( wxALIGN_LEFT, wxALIGN_TOP ); sbSizer6->Add( m_diffPairsGrid, 1, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); + wxBoxSizer* bSizer5; + bSizer5 = new wxBoxSizer( wxHORIZONTAL ); + + m_diffPairsAddButton = new wxBitmapButton( sbSizer6->GetStaticBox(), wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, 0 ); + m_diffPairsAddButton->SetMinSize( wxSize( 30,30 ) ); + + bSizer5->Add( m_diffPairsAddButton, 0, wxLEFT|wxRIGHT, 5 ); + + + bSizer5->Add( 0, 0, 0, wxEXPAND|wxLEFT|wxRIGHT, 5 ); + + m_diffPairsRemoveButton = new wxBitmapButton( sbSizer6->GetStaticBox(), wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, 0 ); + m_diffPairsRemoveButton->SetMinSize( wxSize( 30,30 ) ); + + bSizer5->Add( m_diffPairsRemoveButton, 0, wxLEFT|wxRIGHT, 5 ); + + + sbSizer6->Add( bSizer5, 0, wxEXPAND|wxTOP, 2 ); + bSizerLower->Add( sbSizer6, 0, wxRIGHT|wxLEFT|wxEXPAND, 5 ); @@ -163,8 +220,24 @@ PANEL_SETUP_TRACKS_AND_VIAS_BASE::PANEL_SETUP_TRACKS_AND_VIAS_BASE( wxWindow* pa this->SetSizer( bMainSizer ); this->Layout(); bMainSizer->Fit( this ); + + // Connect Events + m_trackWidthsAddButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_SETUP_TRACKS_AND_VIAS_BASE::OnAddTrackWidthsClick ), NULL, this ); + m_trackWidthsRemoveButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_SETUP_TRACKS_AND_VIAS_BASE::OnRemoveTrackWidthsClick ), NULL, this ); + m_viaSizesAddButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_SETUP_TRACKS_AND_VIAS_BASE::OnAddViaSizesClick ), NULL, this ); + m_viaSizesRemoveButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_SETUP_TRACKS_AND_VIAS_BASE::OnRemoveViaSizesClick ), NULL, this ); + m_diffPairsAddButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_SETUP_TRACKS_AND_VIAS_BASE::OnAddDiffPairsClick ), NULL, this ); + m_diffPairsRemoveButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_SETUP_TRACKS_AND_VIAS_BASE::OnRemoveDiffPairsClick ), NULL, this ); } PANEL_SETUP_TRACKS_AND_VIAS_BASE::~PANEL_SETUP_TRACKS_AND_VIAS_BASE() { + // Disconnect Events + m_trackWidthsAddButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_SETUP_TRACKS_AND_VIAS_BASE::OnAddTrackWidthsClick ), NULL, this ); + m_trackWidthsRemoveButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_SETUP_TRACKS_AND_VIAS_BASE::OnRemoveTrackWidthsClick ), NULL, this ); + m_viaSizesAddButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_SETUP_TRACKS_AND_VIAS_BASE::OnAddViaSizesClick ), NULL, this ); + m_viaSizesRemoveButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_SETUP_TRACKS_AND_VIAS_BASE::OnRemoveViaSizesClick ), NULL, this ); + m_diffPairsAddButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_SETUP_TRACKS_AND_VIAS_BASE::OnAddDiffPairsClick ), NULL, this ); + m_diffPairsRemoveButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_SETUP_TRACKS_AND_VIAS_BASE::OnRemoveDiffPairsClick ), NULL, this ); + } diff --git a/pcbnew/dialogs/panel_setup_tracks_and_vias_base.fbp b/pcbnew/dialogs/panel_setup_tracks_and_vias_base.fbp index 3f9f8dc8ac..7cf155c81d 100644 --- a/pcbnew/dialogs/panel_setup_tracks_and_vias_base.fbp +++ b/pcbnew/dialogs/panel_setup_tracks_and_vias_base.fbp @@ -219,7 +219,7 @@ "Width" wxALIGN_CENTRE 1 - 100 + 125 1 0 @@ -261,7 +261,7 @@ Resizable wxALIGN_CENTRE - 30 + 0 "1" "2" "3" "4" "5" "6" "7" "8" wxALIGN_CENTRE @@ -331,10 +331,217 @@ + + 2 + wxEXPAND|wxTOP + 0 + + + bSizer3 + wxHORIZONTAL + none + + 5 + wxLEFT|wxRIGHT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + + 1 + 0 + 1 + + 1 + 0 + 0 + + Dock + 0 + Left + 1 + + 1 + + + 0 + 0 + + wxID_ANY + MyButton + + 0 + + + 0 + 30,30 + 1 + m_trackWidthsAddButton + 1 + + + protected + 1 + + Resizable + + 1 + + + ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + OnAddTrackWidthsClick + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxEXPAND|wxLEFT|wxRIGHT + 0 + + 0 + protected + 0 + + + + 5 + wxLEFT|wxRIGHT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + + 1 + 0 + 1 + + 1 + 0 + 0 + + Dock + 0 + Left + 1 + + 1 + + + 0 + 0 + + wxID_ANY + MyButton + + 0 + + + 0 + 30,30 + 1 + m_trackWidthsRemoveButton + 1 + + + protected + 1 + + Resizable + + 1 + + + ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + OnRemoveTrackWidthsClick + + + + + + + + + + + + + + + + + + + + + + + + + + + - 5 + 10 wxEXPAND|wxRIGHT|wxLEFT 0 @@ -377,7 +584,7 @@ "Size" "Drill" wxALIGN_CENTRE 2 - 100,100 + 110,110 1 0 @@ -419,7 +626,7 @@ Resizable wxALIGN_CENTRE - 30 + 0 "1" "2" "3" "4" "5" "6" "7" "8" wxALIGN_CENTRE @@ -489,6 +696,213 @@ + + 2 + wxEXPAND|wxTOP + 0 + + + bSizer4 + wxHORIZONTAL + none + + 5 + wxLEFT|wxRIGHT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + + 1 + 0 + 1 + + 1 + 0 + 0 + + Dock + 0 + Left + 1 + + 1 + + + 0 + 0 + + wxID_ANY + MyButton + + 0 + + + 0 + 30,30 + 1 + m_viaSizesAddButton + 1 + + + protected + 1 + + Resizable + + 1 + + + ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + OnAddViaSizesClick + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxEXPAND|wxLEFT|wxRIGHT + 0 + + 0 + protected + 0 + + + + 5 + wxLEFT|wxRIGHT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + + 1 + 0 + 1 + + 1 + 0 + 0 + + Dock + 0 + Left + 1 + + 1 + + + 0 + 0 + + wxID_ANY + MyButton + + 0 + + + 0 + 30,30 + 1 + m_viaSizesRemoveButton + 1 + + + protected + 1 + + Resizable + + 1 + + + ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + OnRemoveViaSizesClick + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -535,7 +949,7 @@ "Width" "Gap" "Via Gap" wxALIGN_CENTRE 3 - 100,100,100 + 110,110,110 1 0 @@ -577,7 +991,7 @@ Resizable wxALIGN_CENTRE - 30 + 0 "1" "2" "3" "4" "5" "6" "7" "8" wxALIGN_CENTRE @@ -647,6 +1061,213 @@ + + 2 + wxEXPAND|wxTOP + 0 + + + bSizer5 + wxHORIZONTAL + none + + 5 + wxLEFT|wxRIGHT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + + 1 + 0 + 1 + + 1 + 0 + 0 + + Dock + 0 + Left + 1 + + 1 + + + 0 + 0 + + wxID_ANY + MyButton + + 0 + + + 0 + 30,30 + 1 + m_diffPairsAddButton + 1 + + + protected + 1 + + Resizable + + 1 + + + ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + OnAddDiffPairsClick + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxEXPAND|wxLEFT|wxRIGHT + 0 + + 0 + protected + 0 + + + + 5 + wxLEFT|wxRIGHT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + + 1 + 0 + 1 + + 1 + 0 + 0 + + Dock + 0 + Left + 1 + + 1 + + + 0 + 0 + + wxID_ANY + MyButton + + 0 + + + 0 + 30,30 + 1 + m_diffPairsRemoveButton + 1 + + + protected + 1 + + Resizable + + 1 + + + ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + OnRemoveDiffPairsClick + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/pcbnew/dialogs/panel_setup_tracks_and_vias_base.h b/pcbnew/dialogs/panel_setup_tracks_and_vias_base.h index 0af7d2291c..b6831f9503 100644 --- a/pcbnew/dialogs/panel_setup_tracks_and_vias_base.h +++ b/pcbnew/dialogs/panel_setup_tracks_and_vias_base.h @@ -20,6 +20,11 @@ class WX_GRID; #include #include #include +#include +#include +#include +#include +#include #include #include #include @@ -36,8 +41,23 @@ class PANEL_SETUP_TRACKS_AND_VIAS_BASE : public wxPanel protected: wxStaticText* m_label; WX_GRID* m_trackWidthsGrid; + wxBitmapButton* m_trackWidthsAddButton; + wxBitmapButton* m_trackWidthsRemoveButton; WX_GRID* m_viaSizesGrid; + wxBitmapButton* m_viaSizesAddButton; + wxBitmapButton* m_viaSizesRemoveButton; WX_GRID* m_diffPairsGrid; + wxBitmapButton* m_diffPairsAddButton; + wxBitmapButton* m_diffPairsRemoveButton; + + // Virtual event handlers, overide them in your derived class + virtual void OnAddTrackWidthsClick( wxCommandEvent& event ) { event.Skip(); } + virtual void OnRemoveTrackWidthsClick( wxCommandEvent& event ) { event.Skip(); } + virtual void OnAddViaSizesClick( wxCommandEvent& event ) { event.Skip(); } + virtual void OnRemoveViaSizesClick( wxCommandEvent& event ) { event.Skip(); } + virtual void OnAddDiffPairsClick( wxCommandEvent& event ) { event.Skip(); } + virtual void OnRemoveDiffPairsClick( wxCommandEvent& event ) { event.Skip(); } + public: