diff --git a/common/fp_lib_table.cpp b/common/fp_lib_table.cpp index cab2481320..2e5ca3bf98 100644 --- a/common/fp_lib_table.cpp +++ b/common/fp_lib_table.cpp @@ -178,6 +178,52 @@ std::vector FP_LIB_TABLE::GetLogicalLibs() } +FP_LIB_TABLE::ROW* FP_LIB_TABLE::FindRow( const wxString& aNickName ) const +{ + // this function must be *super* fast, so therefore should not instantiate + // anything which would require using the heap. + const FP_LIB_TABLE* cur = this; + + do + { + INDEX_CITER it = cur->nickIndex.find( aNickName ); + + if( it != cur->nickIndex.end() ) + { + return (FP_LIB_TABLE::ROW*) &cur->rows[it->second]; // found + } + + // not found, search fall back table(s), if any + } while( ( cur = cur->fallBack ) != 0 ); + + return 0; // not found +} + + +bool FP_LIB_TABLE::InsertRow( const ROW& aRow, bool doReplace ) +{ + // this does not need to be super fast. + + INDEX_CITER it = nickIndex.find( aRow.nickName ); + + if( it == nickIndex.end() ) + { + rows.push_back( aRow ); + nickIndex.insert( INDEX_VALUE( aRow.nickName, rows.size() - 1 ) ); + return true; + } + + if( doReplace ) + { + rows[it->second] = aRow; + return true; + } + + return false; +} + + + #if 0 // will need PLUGIN_RELEASER. MODULE* FP_LIB_TABLE::LookupFootprint( const FP_LIB_ID& aFootprintId ) throw( IO_ERROR ) @@ -256,47 +302,3 @@ void FP_LIB_TABLE::loadLib( ROW* aRow ) throw( IO_ERROR ) } #endif - -FP_LIB_TABLE::ROW* FP_LIB_TABLE::FindRow( const wxString& aNickName ) const -{ - // this function must be *super* fast, so therefore should not instantiate - // anything which would require using the heap. - const FP_LIB_TABLE* cur = this; - - do - { - INDEX_CITER it = cur->nickIndex.find( aNickName ); - - if( it != cur->nickIndex.end() ) - { - return (FP_LIB_TABLE::ROW*) &cur->rows[it->second]; // found - } - - // not found, search fall back table(s), if any - } while( ( cur = cur->fallBack ) != 0 ); - - return 0; // not found -} - - -bool FP_LIB_TABLE::InsertRow( const ROW& aRow, bool doReplace ) -{ - // this does not need to be super fast. - - INDEX_CITER it = nickIndex.find( aRow.nickName ); - - if( it == nickIndex.end() ) - { - rows.push_back( aRow ); - nickIndex.insert( INDEX_VALUE( aRow.nickName, rows.size() - 1 ) ); - return true; - } - - if( doReplace ) - { - rows[it->second] = aRow; - return true; - } - - return false; -} diff --git a/include/fp_lib_table.h b/include/fp_lib_table.h index 97a512e6af..990b69c064 100644 --- a/include/fp_lib_table.h +++ b/include/fp_lib_table.h @@ -82,6 +82,8 @@ class FP_LIB_TABLE_LEXER; */ class FP_LIB_TABLE : public wxGridTableBase { + friend class DIALOG_FP_LIB_TABLE; + public: /** @@ -92,6 +94,7 @@ public: class ROW { friend class FP_LIB_TABLE; + friend class DIALOG_FP_LIB_TABLE; public: @@ -148,8 +151,6 @@ public: void Format( OUTPUTFORMATTER* out, int nestLevel ) const throw( IO_ERROR ); - protected: - ROW( FP_LIB_TABLE* aOwner ) : owner( aOwner ) // lib( 0 ) @@ -316,9 +317,9 @@ public: switch( aCol ) { - case 1: r.SetType( aValue ); - case 2: r.SetFullURI( aValue ); - case 3: r.SetOptions( aValue ); + case 1: r.SetType( aValue ); break; + case 2: r.SetFullURI( aValue ); break; + case 3: r.SetOptions( aValue ); break; } } } @@ -330,6 +331,51 @@ public: return true; } + bool InsertRows( size_t aPos = 0, size_t aNumRows = 1 ) + { + if( aPos < rows.size() ) + { + rows.insert( rows.begin() + aPos, aNumRows, ROW( this ) ); + return true; + } + return false; + } + + bool AppendRows( size_t aNumRows = 1 ) + { + while( aNumRows-- ) + rows.push_back( ROW( this ) ); + return true; + } + + bool DeleteRows( size_t aPos, size_t aNumRows ) + { + if( aPos + aNumRows <= rows.size() ) + { + ROWS_ITER start = rows.begin() + aPos; + rows.erase( start, start + aNumRows ); + return true; + } + return false; + } + + void Clear() + { + rows.clear(); + } + + wxString GetColLabelValue( int aCol ) + { + switch( aCol ) + { + case 0: return _( "Nickname" ); + case 1: return _( "Plugin" ); + case 2: return _( "Library Path" ); + case 3: return _( "Options" ); + default: return wxEmptyString; + } + } + //----------------------------------------------- diff --git a/pcbnew/dialogs/dialog_fp_lib_table.cpp b/pcbnew/dialogs/dialog_fp_lib_table.cpp index 08978ea663..57e36a5cc1 100644 --- a/pcbnew/dialogs/dialog_fp_lib_table.cpp +++ b/pcbnew/dialogs/dialog_fp_lib_table.cpp @@ -24,7 +24,7 @@ */ - +#include #include #include @@ -35,11 +35,113 @@ */ class DIALOG_FP_LIB_TABLE : public DIALOG_FP_LIB_TABLE_BASE { + //--------------------------------------- + + void pageChangedHandler( wxAuiNotebookEvent& event ) + { + int pageNdx = m_auinotebook->GetSelection(); + + m_cur_grid = pageNdx ? m_global_grid : m_project_grid; + } + + void appendRowHandler( wxMouseEvent& event ) + { + D(printf("%s\n", __func__);) + } + + void deleteRowHandler( wxMouseEvent& event ) + { + D(printf("%s\n", __func__);) + } + + void moveUpHandler( wxMouseEvent& event ) + { + D(printf("%s\n", __func__);) + } + + void moveDownHandler( wxMouseEvent& event ) + { + D(printf("%s\n", __func__);) + } + + void onCancelButtonClick( wxCommandEvent& event ) + { + m_global->rows = m_orig_global; + m_project->rows = m_orig_project; + + // @todo reindex, or add member function for wholesale row replacement + + EndModal( wxID_CANCEL ); + } + + void onOKButtonClick( wxCommandEvent& event ) + { + EndModal( wxID_OK ); + } + + + //-------------------------------------- + + + // caller's tables are modified only on OK button. + FP_LIB_TABLE* m_global; + FP_LIB_TABLE* m_project; + + // local copies are saved and restored if Cancel button. + FP_LIB_TABLE::ROWS m_orig_global; + FP_LIB_TABLE::ROWS m_orig_project; + + wxGrid* m_cur_grid; ///< changed based on tab choice + public: - DIALOG_FP_LIB_TABLE( wxFrame* aParent ) : - DIALOG_FP_LIB_TABLE_BASE( aParent ) + DIALOG_FP_LIB_TABLE( wxFrame* aParent, FP_LIB_TABLE* aGlobal, FP_LIB_TABLE* aProject ) : + DIALOG_FP_LIB_TABLE_BASE( aParent ), + m_global( aGlobal ), + m_project( aProject ), + m_orig_global( aGlobal->rows ), + m_orig_project( aProject->rows ) { + /* + GetSizer()->SetSizeHints( this ); + Centre(); + SetAutoLayout( true ); + Layout(); + */ + +#if 1 && defined(DEBUG) + // put some dummy data into table(s) + FP_LIB_TABLE::ROW row( m_global ); + + row.SetNickName( wxT( "passives" ) ); + row.SetType( wxT( "kicad" ) ); + row.SetFullURI( wxT( "%G/passives" ) ); + row.SetOptions( wxT( "speed=fast,purpose=testing" ) ); + m_global->InsertRow( row ); + + row.SetNickName( wxT( "micros" ) ); + row.SetType( wxT( "legacy" ) ); + row.SetFullURI( wxT( "%P/micros" ) ); + row.SetOptions( wxT( "speed=fast,purpose=testing" ) ); + m_global->InsertRow( row ); + + row.owner = m_project; + row.SetFullURI( wxT( "%P/chips" ) ); + m_project->InsertRow( row ); + +#endif + + m_global_grid->SetTable( m_global ); + m_project_grid->SetTable( m_project ); + + //m_global_grid->AutoSize(); + m_global_grid->AutoSizeColumns( false ); + + //m_project_grid->AutoSize(); + m_project_grid->AutoSizeColumns( false ); + + //m_path_subs_grid->AutoSize(); + m_path_subs_grid->AutoSizeColumns( false ); } }; @@ -47,9 +149,17 @@ public: int InvokePcbLibTableEditor( wxFrame* aParent, FP_LIB_TABLE* aGlobal, FP_LIB_TABLE* aProject ) { - DIALOG_FP_LIB_TABLE dlg( aParent ); + DIALOG_FP_LIB_TABLE dlg( aParent, aGlobal, aProject ); - dlg.Show( true ); + int ret = dlg.ShowModal(); + switch( ret ) + { + case wxID_OK: + break; + + case wxID_CANCEL: + break; + } return 0; } diff --git a/pcbnew/dialogs/dialog_fp_lib_table_base.cpp b/pcbnew/dialogs/dialog_fp_lib_table_base.cpp index dd5d8226d2..91d371aab9 100644 --- a/pcbnew/dialogs/dialog_fp_lib_table_base.cpp +++ b/pcbnew/dialogs/dialog_fp_lib_table_base.cpp @@ -16,173 +16,164 @@ DIALOG_FP_LIB_TABLE_BASE::DIALOG_FP_LIB_TABLE_BASE( wxWindow* parent, wxWindowID wxBoxSizer* bSizer1; bSizer1 = new wxBoxSizer( wxVERTICAL ); - m_splitter1 = new wxSplitterWindow( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxSP_3D|wxSP_3DBORDER ); - m_splitter1->Connect( wxEVT_IDLE, wxIdleEventHandler( DIALOG_FP_LIB_TABLE_BASE::m_splitter1OnIdle ), NULL, this ); - m_splitter1->SetMinimumPaneSize( 10 ); + m_splitter = new wxSplitterWindow( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxSP_3DSASH ); + m_splitter->Connect( wxEVT_IDLE, wxIdleEventHandler( DIALOG_FP_LIB_TABLE_BASE::m_splitterOnIdle ), NULL, this ); + m_splitter->SetMinimumPaneSize( 10 ); - m_top = new wxPanel( m_splitter1, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); - wxStaticBoxSizer* sbSizer3; - sbSizer3 = new wxStaticBoxSizer( new wxStaticBox( m_top, wxID_ANY, _("Global and Project Scope") ), wxVERTICAL ); + m_top = new wxPanel( m_splitter, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); + wxStaticBoxSizer* m_top_sizer; + m_top_sizer = new wxStaticBoxSizer( new wxStaticBox( m_top, wxID_ANY, _("Library Tables by Scope") ), wxVERTICAL ); - m_auinotebook2 = new wxAuiNotebook( m_top, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxAUI_NB_DEFAULT_STYLE ); - m_panel4 = new wxPanel( m_auinotebook2, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); - m_panel4->SetToolTip( _("Module libraries which are visible for all projects") ); + m_auinotebook = new wxAuiNotebook( m_top, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxAUI_NB_BOTTOM ); + m_global_panel = new wxPanel( m_auinotebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); + m_global_panel->SetToolTip( _("Module libraries which are visible for all projects") ); - wxBoxSizer* bSizer4; - bSizer4 = new wxBoxSizer( wxVERTICAL ); + wxBoxSizer* m_global_box_sizer; + m_global_box_sizer = new wxBoxSizer( wxVERTICAL ); - m_grid1 = new wxGrid( m_panel4, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 ); + m_global_grid = new wxGrid( m_global_panel, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 ); // Grid - m_grid1->CreateGrid( 1, 4 ); - m_grid1->EnableEditing( true ); - m_grid1->EnableGridLines( true ); - m_grid1->EnableDragGridSize( false ); - m_grid1->SetMargins( 0, 0 ); + m_global_grid->CreateGrid( 1, 4 ); + m_global_grid->EnableEditing( true ); + m_global_grid->EnableGridLines( true ); + m_global_grid->EnableDragGridSize( true ); + m_global_grid->SetMargins( 0, 0 ); // Columns - m_grid1->AutoSizeColumns(); - m_grid1->EnableDragColMove( false ); - m_grid1->EnableDragColSize( true ); - m_grid1->SetColLabelSize( 30 ); - m_grid1->SetColLabelValue( 0, _("Nickname") ); - m_grid1->SetColLabelValue( 1, _("Library Path") ); - m_grid1->SetColLabelValue( 2, _("Plugin") ); - m_grid1->SetColLabelValue( 3, _("Options") ); - m_grid1->SetColLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE ); + m_global_grid->AutoSizeColumns(); + m_global_grid->EnableDragColMove( false ); + m_global_grid->EnableDragColSize( true ); + m_global_grid->SetColLabelSize( 30 ); + m_global_grid->SetColLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE ); // Rows - m_grid1->AutoSizeRows(); - m_grid1->EnableDragRowSize( true ); - m_grid1->SetRowLabelSize( 80 ); - m_grid1->SetRowLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE ); + m_global_grid->EnableDragRowSize( true ); + m_global_grid->SetRowLabelSize( 40 ); + m_global_grid->SetRowLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE ); // Label Appearance // Cell Defaults - m_grid1->SetDefaultCellAlignment( wxALIGN_LEFT, wxALIGN_TOP ); - bSizer4->Add( m_grid1, 1, wxALL|wxEXPAND, 5 ); + m_global_grid->SetDefaultCellAlignment( wxALIGN_LEFT, wxALIGN_TOP ); + m_global_box_sizer->Add( m_global_grid, 1, wxALL|wxEXPAND, 5 ); - m_panel4->SetSizer( bSizer4 ); - m_panel4->Layout(); - bSizer4->Fit( m_panel4 ); - m_auinotebook2->AddPage( m_panel4, _("Global Libraries"), false, wxNullBitmap ); - m_panel5 = new wxPanel( m_auinotebook2, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); - wxBoxSizer* bSizer5; - bSizer5 = new wxBoxSizer( wxVERTICAL ); + m_global_panel->SetSizer( m_global_box_sizer ); + m_global_panel->Layout(); + m_global_box_sizer->Fit( m_global_panel ); + m_auinotebook->AddPage( m_global_panel, _("Global Libraries"), true, wxNullBitmap ); + m_project_panel = new wxPanel( m_auinotebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); + wxBoxSizer* m_project_sizer; + m_project_sizer = new wxBoxSizer( wxVERTICAL ); - m_grid11 = new wxGrid( m_panel5, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 ); + m_project_grid = new wxGrid( m_project_panel, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 ); // Grid - m_grid11->CreateGrid( 1, 4 ); - m_grid11->EnableEditing( true ); - m_grid11->EnableGridLines( true ); - m_grid11->EnableDragGridSize( false ); - m_grid11->SetMargins( 0, 0 ); + m_project_grid->CreateGrid( 1, 4 ); + m_project_grid->EnableEditing( true ); + m_project_grid->EnableGridLines( true ); + m_project_grid->EnableDragGridSize( true ); + m_project_grid->SetMargins( 0, 0 ); // Columns - m_grid11->AutoSizeColumns(); - m_grid11->EnableDragColMove( false ); - m_grid11->EnableDragColSize( true ); - m_grid11->SetColLabelSize( 30 ); - m_grid11->SetColLabelValue( 0, _("Nickname") ); - m_grid11->SetColLabelValue( 1, _("Library Path") ); - m_grid11->SetColLabelValue( 2, _("Plugin") ); - m_grid11->SetColLabelValue( 3, _("Options") ); - m_grid11->SetColLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE ); + m_project_grid->AutoSizeColumns(); + m_project_grid->EnableDragColMove( false ); + m_project_grid->EnableDragColSize( true ); + m_project_grid->SetColLabelSize( 30 ); + m_project_grid->SetColLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE ); // Rows - m_grid11->AutoSizeRows(); - m_grid11->EnableDragRowSize( true ); - m_grid11->SetRowLabelSize( 80 ); - m_grid11->SetRowLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE ); + m_project_grid->EnableDragRowSize( true ); + m_project_grid->SetRowLabelSize( 40 ); + m_project_grid->SetRowLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE ); // Label Appearance // Cell Defaults - m_grid11->SetDefaultCellAlignment( wxALIGN_LEFT, wxALIGN_TOP ); - bSizer5->Add( m_grid11, 0, wxALL, 5 ); + m_project_grid->SetDefaultCellAlignment( wxALIGN_LEFT, wxALIGN_TOP ); + m_project_sizer->Add( m_project_grid, 0, wxALL, 5 ); - m_panel5->SetSizer( bSizer5 ); - m_panel5->Layout(); - bSizer5->Fit( m_panel5 ); - m_auinotebook2->AddPage( m_panel5, _("Project Specific Libraries"), true, wxNullBitmap ); + m_project_panel->SetSizer( m_project_sizer ); + m_project_panel->Layout(); + m_project_sizer->Fit( m_project_panel ); + m_auinotebook->AddPage( m_project_panel, _("Project Specific Libraries"), false, wxNullBitmap ); - sbSizer3->Add( m_auinotebook2, 1, wxEXPAND | wxALL, 5 ); + m_top_sizer->Add( m_auinotebook, 1, wxEXPAND | wxALL, 5 ); wxBoxSizer* bSizer51; bSizer51 = new wxBoxSizer( wxHORIZONTAL ); - m_button1 = new wxButton( m_top, wxID_ANY, _("Append Row"), wxDefaultPosition, wxDefaultSize, 0 ); - m_button1->SetToolTip( _("Add a pcb library row to this table") ); + m_append_button = new wxButton( m_top, wxID_ANY, _("Append Row"), wxDefaultPosition, wxDefaultSize, 0 ); + m_append_button->SetToolTip( _("Add a pcb library row to this table") ); - bSizer51->Add( m_button1, 0, wxALL, 5 ); + bSizer51->Add( m_append_button, 0, wxALL, 5 ); - m_button2 = new wxButton( m_top, wxID_ANY, _("Delete Row"), wxDefaultPosition, wxDefaultSize, 0 ); - m_button2->SetToolTip( _("Remove a PCB library from this library table") ); + m_delete_button = new wxButton( m_top, wxID_ANY, _("Delete Row"), wxDefaultPosition, wxDefaultSize, 0 ); + m_delete_button->SetToolTip( _("Remove a PCB library from this library table") ); - bSizer51->Add( m_button2, 0, wxALL, 5 ); + bSizer51->Add( m_delete_button, 0, wxALL, 5 ); - m_button3 = new wxButton( m_top, wxID_ANY, _("Move Up"), wxDefaultPosition, wxDefaultSize, 0 ); - m_button3->SetToolTip( _("Move the currently selected row up one position") ); + m_move_up_button = new wxButton( m_top, wxID_ANY, _("Move Up"), wxDefaultPosition, wxDefaultSize, 0 ); + m_move_up_button->SetToolTip( _("Move the currently selected row up one position") ); - bSizer51->Add( m_button3, 0, wxALL, 5 ); + bSizer51->Add( m_move_up_button, 0, wxALL, 5 ); - m_button4 = new wxButton( m_top, wxID_ANY, _("Move Down"), wxDefaultPosition, wxDefaultSize, 0 ); - m_button4->SetToolTip( _("Move the currently selected row down one position") ); + m_move_down_button = new wxButton( m_top, wxID_ANY, _("Move Down"), wxDefaultPosition, wxDefaultSize, 0 ); + m_move_down_button->SetToolTip( _("Move the currently selected row down one position") ); - bSizer51->Add( m_button4, 0, wxALL, 5 ); + bSizer51->Add( m_move_down_button, 0, wxALL, 5 ); - sbSizer3->Add( bSizer51, 0, wxALIGN_CENTER, 5 ); + m_top_sizer->Add( bSizer51, 0, wxALIGN_CENTER|wxBOTTOM, 8 ); - m_top->SetSizer( sbSizer3 ); + m_top->SetSizer( m_top_sizer ); m_top->Layout(); - sbSizer3->Fit( m_top ); - m_bottom = new wxPanel( m_splitter1, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); - wxBoxSizer* bSizer8; - bSizer8 = new wxBoxSizer( wxVERTICAL ); + m_top_sizer->Fit( m_top ); + m_bottom = new wxPanel( m_splitter, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); + wxBoxSizer* m_bottom_sizer; + m_bottom_sizer = new wxBoxSizer( wxVERTICAL ); wxStaticBoxSizer* sbSizer1; sbSizer1 = new wxStaticBoxSizer( new wxStaticBox( m_bottom, wxID_ANY, _("Path Substitutions") ), wxVERTICAL ); - m_grid2 = new wxGrid( m_bottom, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 ); + m_path_subs_grid = new wxGrid( m_bottom, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 ); // Grid - m_grid2->CreateGrid( 2, 2 ); - m_grid2->EnableEditing( true ); - m_grid2->EnableGridLines( true ); - m_grid2->EnableDragGridSize( false ); - m_grid2->SetMargins( 0, 0 ); + m_path_subs_grid->CreateGrid( 2, 2 ); + m_path_subs_grid->EnableEditing( true ); + m_path_subs_grid->EnableGridLines( true ); + m_path_subs_grid->EnableDragGridSize( false ); + m_path_subs_grid->SetMargins( 0, 0 ); // Columns - m_grid2->SetColSize( 0, 150 ); - m_grid2->SetColSize( 1, 500 ); - m_grid2->EnableDragColMove( false ); - m_grid2->EnableDragColSize( true ); - m_grid2->SetColLabelSize( 30 ); - m_grid2->SetColLabelValue( 0, _("Category") ); - m_grid2->SetColLabelValue( 1, _("Path Segment") ); - m_grid2->SetColLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE ); + m_path_subs_grid->SetColSize( 0, 150 ); + m_path_subs_grid->SetColSize( 1, 500 ); + m_path_subs_grid->AutoSizeColumns(); + m_path_subs_grid->EnableDragColMove( false ); + m_path_subs_grid->EnableDragColSize( true ); + m_path_subs_grid->SetColLabelSize( 30 ); + m_path_subs_grid->SetColLabelValue( 0, _("Category") ); + m_path_subs_grid->SetColLabelValue( 1, _("Path Segment") ); + m_path_subs_grid->SetColLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE ); // Rows - m_grid2->EnableDragRowSize( true ); - m_grid2->SetRowLabelSize( 40 ); - m_grid2->SetRowLabelValue( 0, _("%S") ); - m_grid2->SetRowLabelValue( 1, _("%P") ); - m_grid2->SetRowLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE ); + m_path_subs_grid->EnableDragRowSize( true ); + m_path_subs_grid->SetRowLabelSize( 40 ); + m_path_subs_grid->SetRowLabelValue( 0, _("%S") ); + m_path_subs_grid->SetRowLabelValue( 1, _("%P") ); + m_path_subs_grid->SetRowLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE ); // Label Appearance // Cell Defaults - m_grid2->SetDefaultCellAlignment( wxALIGN_LEFT, wxALIGN_TOP ); - sbSizer1->Add( m_grid2, 0, wxALL, 5 ); + m_path_subs_grid->SetDefaultCellAlignment( wxALIGN_LEFT, wxALIGN_TOP ); + sbSizer1->Add( m_path_subs_grid, 1, wxALL|wxEXPAND, 5 ); - bSizer8->Add( sbSizer1, 1, wxALL|wxEXPAND, 5 ); + m_bottom_sizer->Add( sbSizer1, 1, wxALL|wxEXPAND, 5 ); m_sdbSizer1 = new wxStdDialogButtonSizer(); m_sdbSizer1OK = new wxButton( m_bottom, wxID_OK ); @@ -191,23 +182,40 @@ DIALOG_FP_LIB_TABLE_BASE::DIALOG_FP_LIB_TABLE_BASE( wxWindow* parent, wxWindowID m_sdbSizer1->AddButton( m_sdbSizer1Cancel ); m_sdbSizer1->Realize(); - bSizer8->Add( m_sdbSizer1, 0, wxALL|wxEXPAND, 5 ); + m_bottom_sizer->Add( m_sdbSizer1, 0, wxALL|wxEXPAND, 5 ); - m_bottom->SetSizer( bSizer8 ); + m_bottom->SetSizer( m_bottom_sizer ); m_bottom->Layout(); - bSizer8->Fit( m_bottom ); - m_splitter1->SplitHorizontally( m_top, m_bottom, 254 ); - bSizer1->Add( m_splitter1, 2, wxEXPAND, 5 ); + m_bottom_sizer->Fit( m_bottom ); + m_splitter->SplitHorizontally( m_top, m_bottom, 343 ); + bSizer1->Add( m_splitter, 2, wxEXPAND, 5 ); this->SetSizer( bSizer1 ); this->Layout(); - bSizer1->Fit( this ); this->Centre( wxBOTH ); + + // Connect Events + m_auinotebook->Connect( wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGED, wxAuiNotebookEventHandler( DIALOG_FP_LIB_TABLE_BASE::pageChangedHandler ), NULL, this ); + m_append_button->Connect( wxEVT_LEFT_DOWN, wxMouseEventHandler( DIALOG_FP_LIB_TABLE_BASE::appendRowHandler ), NULL, this ); + m_delete_button->Connect( wxEVT_LEFT_DOWN, wxMouseEventHandler( DIALOG_FP_LIB_TABLE_BASE::deleteRowHandler ), NULL, this ); + m_move_up_button->Connect( wxEVT_LEFT_DOWN, wxMouseEventHandler( DIALOG_FP_LIB_TABLE_BASE::moveUpHandler ), NULL, this ); + m_move_down_button->Connect( wxEVT_LEFT_DOWN, wxMouseEventHandler( DIALOG_FP_LIB_TABLE_BASE::moveDownHandler ), NULL, this ); + m_sdbSizer1Cancel->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FP_LIB_TABLE_BASE::onCancelButtonClick ), NULL, this ); + m_sdbSizer1OK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FP_LIB_TABLE_BASE::onOKButtonClick ), NULL, this ); } DIALOG_FP_LIB_TABLE_BASE::~DIALOG_FP_LIB_TABLE_BASE() { + // Disconnect Events + m_auinotebook->Disconnect( wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGED, wxAuiNotebookEventHandler( DIALOG_FP_LIB_TABLE_BASE::pageChangedHandler ), NULL, this ); + m_append_button->Disconnect( wxEVT_LEFT_DOWN, wxMouseEventHandler( DIALOG_FP_LIB_TABLE_BASE::appendRowHandler ), NULL, this ); + m_delete_button->Disconnect( wxEVT_LEFT_DOWN, wxMouseEventHandler( DIALOG_FP_LIB_TABLE_BASE::deleteRowHandler ), NULL, this ); + m_move_up_button->Disconnect( wxEVT_LEFT_DOWN, wxMouseEventHandler( DIALOG_FP_LIB_TABLE_BASE::moveUpHandler ), NULL, this ); + m_move_down_button->Disconnect( wxEVT_LEFT_DOWN, wxMouseEventHandler( DIALOG_FP_LIB_TABLE_BASE::moveDownHandler ), NULL, this ); + m_sdbSizer1Cancel->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FP_LIB_TABLE_BASE::onCancelButtonClick ), NULL, this ); + m_sdbSizer1OK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FP_LIB_TABLE_BASE::onOKButtonClick ), NULL, this ); + } diff --git a/pcbnew/dialogs/dialog_fp_lib_table_base.fbp b/pcbnew/dialogs/dialog_fp_lib_table_base.fbp index 5b9038d16a..e4b71d5f77 100644 --- a/pcbnew/dialogs/dialog_fp_lib_table_base.fbp +++ b/pcbnew/dialogs/dialog_fp_lib_table_base.fbp @@ -42,7 +42,7 @@ DIALOG_FP_LIB_TABLE_BASE - -1,-1 + 864,652 wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER DIALOG_SHIM; dialog_shim.h PCB Library Tables @@ -131,7 +131,7 @@ 0 1 - m_splitter1 + m_splitter 1 @@ -140,12 +140,12 @@ Resizable 0.0 - 254 + 343 -1 1 wxSPLIT_HORIZONTAL - wxSP_3D|wxSP_3DBORDER + wxSP_3DSASH 0 @@ -254,19 +254,19 @@ - + wxID_ANY - Global and Project Scope + Library Tables by Scope - sbSizer3 + m_top_sizer wxVERTICAL none - + 5 wxEXPAND | wxALL 1 - + 1 1 1 @@ -301,7 +301,7 @@ 0 1 - m_auinotebook2 + m_auinotebook 1 @@ -311,7 +311,7 @@ Resizable 1 - wxAUI_NB_DEFAULT_STYLE + wxAUI_NB_BOTTOM -1 0 @@ -325,7 +325,7 @@ - + pageChangedHandler @@ -351,11 +351,11 @@ - + Global Libraries - 0 - + 1 + 1 1 1 @@ -390,7 +390,7 @@ 0 1 - m_panel4 + m_global_panel 1 @@ -429,9 +429,9 @@ - + - bSizer4 + m_global_box_sizer wxVERTICAL none @@ -448,7 +448,7 @@ 1 - 1 + 0 @@ -462,7 +462,7 @@ 1 wxALIGN_CENTRE 30 - "Nickname" "Library Path" "Plugin" "Options" + wxALIGN_CENTRE 4 @@ -470,16 +470,16 @@ 1 0 Dock - 0 + 1 Left 0 1 - 0 + 1 1 1 1 - 1 + 0 1 @@ -497,8 +497,8 @@ 0 - 1 - m_grid1 + 0 + m_global_grid 1 @@ -507,7 +507,7 @@ Fixed wxALIGN_CENTRE - 80 + 40 wxALIGN_CENTRE @@ -580,11 +580,11 @@ - + Project Specific Libraries - 1 - + 0 + 1 1 1 @@ -619,7 +619,7 @@ 0 1 - m_panel5 + m_project_panel 1 @@ -658,9 +658,9 @@ - + - bSizer5 + m_project_sizer wxVERTICAL none @@ -677,7 +677,7 @@ 1 - 1 + 0 @@ -691,7 +691,7 @@ 1 wxALIGN_CENTRE 30 - "Nickname" "Library Path" "Plugin" "Options" + wxALIGN_CENTRE 4 @@ -699,16 +699,16 @@ 1 0 Dock - 0 + 1 Left 0 1 - 0 + 1 1 1 1 - 1 + 0 1 @@ -726,8 +726,8 @@ 0 - 1 - m_grid11 + 0 + m_project_grid 1 @@ -736,7 +736,7 @@ Fixed wxALIGN_CENTRE - 80 + 40 wxALIGN_CENTRE @@ -812,8 +812,8 @@ - 5 - wxALIGN_CENTER + 8 + wxALIGN_CENTER|wxBOTTOM 0 @@ -861,7 +861,7 @@ 0 1 - m_button1 + m_append_button 1 @@ -891,7 +891,7 @@ - + appendRowHandler @@ -949,7 +949,7 @@ 0 1 - m_button2 + m_delete_button 1 @@ -979,7 +979,7 @@ - + deleteRowHandler @@ -1037,7 +1037,7 @@ 0 1 - m_button3 + m_move_up_button 1 @@ -1067,7 +1067,7 @@ - + moveUpHandler @@ -1125,7 +1125,7 @@ 0 1 - m_button4 + m_move_down_button 1 @@ -1155,7 +1155,7 @@ - + moveDownHandler @@ -1252,16 +1252,16 @@ - + - bSizer8 + m_bottom_sizer wxVERTICAL none - + 5 wxALL|wxEXPAND 1 - + wxID_ANY Path Substitutions @@ -1271,8 +1271,8 @@ 5 - wxALL - 0 + wxALL|wxEXPAND + 1 1 1 @@ -1282,7 +1282,7 @@ - 0 + 1 0 @@ -1333,7 +1333,7 @@ 0 1 - m_grid2 + m_path_subs_grid 1 @@ -1431,11 +1431,11 @@ m_sdbSizer1 protected - + onCancelButtonClick - + onOKButtonClick diff --git a/pcbnew/dialogs/dialog_fp_lib_table_base.h b/pcbnew/dialogs/dialog_fp_lib_table_base.h index f65b923c2a..3156b1cdf5 100644 --- a/pcbnew/dialogs/dialog_fp_lib_table_base.h +++ b/pcbnew/dialogs/dialog_fp_lib_table_base.h @@ -42,32 +42,42 @@ class DIALOG_FP_LIB_TABLE_BASE : public DIALOG_SHIM private: protected: - wxSplitterWindow* m_splitter1; + wxSplitterWindow* m_splitter; wxPanel* m_top; - wxAuiNotebook* m_auinotebook2; - wxPanel* m_panel4; - wxGrid* m_grid1; - wxPanel* m_panel5; - wxGrid* m_grid11; - wxButton* m_button1; - wxButton* m_button2; - wxButton* m_button3; - wxButton* m_button4; + wxAuiNotebook* m_auinotebook; + wxPanel* m_global_panel; + wxGrid* m_global_grid; + wxPanel* m_project_panel; + wxGrid* m_project_grid; + wxButton* m_append_button; + wxButton* m_delete_button; + wxButton* m_move_up_button; + wxButton* m_move_down_button; wxPanel* m_bottom; - wxGrid* m_grid2; + wxGrid* m_path_subs_grid; wxStdDialogButtonSizer* m_sdbSizer1; wxButton* m_sdbSizer1OK; wxButton* m_sdbSizer1Cancel; + + // Virtual event handlers, overide them in your derived class + virtual void pageChangedHandler( wxAuiNotebookEvent& event ) { event.Skip(); } + virtual void appendRowHandler( wxMouseEvent& event ) { event.Skip(); } + virtual void deleteRowHandler( wxMouseEvent& event ) { event.Skip(); } + virtual void moveUpHandler( wxMouseEvent& event ) { event.Skip(); } + virtual void moveDownHandler( wxMouseEvent& event ) { event.Skip(); } + virtual void onCancelButtonClick( wxCommandEvent& event ) { event.Skip(); } + virtual void onOKButtonClick( wxCommandEvent& event ) { event.Skip(); } + public: - DIALOG_FP_LIB_TABLE_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("PCB Library Tables"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); + DIALOG_FP_LIB_TABLE_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("PCB Library Tables"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 864,652 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); ~DIALOG_FP_LIB_TABLE_BASE(); - void m_splitter1OnIdle( wxIdleEvent& ) + void m_splitterOnIdle( wxIdleEvent& ) { - m_splitter1->SetSashPosition( 254 ); - m_splitter1->Disconnect( wxEVT_IDLE, wxIdleEventHandler( DIALOG_FP_LIB_TABLE_BASE::m_splitter1OnIdle ), NULL, this ); + m_splitter->SetSashPosition( 343 ); + m_splitter->Disconnect( wxEVT_IDLE, wxIdleEventHandler( DIALOG_FP_LIB_TABLE_BASE::m_splitterOnIdle ), NULL, this ); } };