Loading common/fp_lib_table.cpp +46 −44 Original line number Original line Diff line number Diff line Loading @@ -178,6 +178,52 @@ std::vector<wxString> 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. #if 0 // will need PLUGIN_RELEASER. MODULE* FP_LIB_TABLE::LookupFootprint( const FP_LIB_ID& aFootprintId ) MODULE* FP_LIB_TABLE::LookupFootprint( const FP_LIB_ID& aFootprintId ) throw( IO_ERROR ) throw( IO_ERROR ) Loading Loading @@ -256,47 +302,3 @@ void FP_LIB_TABLE::loadLib( ROW* aRow ) throw( IO_ERROR ) } } #endif #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; } include/fp_lib_table.h +51 −5 Original line number Original line Diff line number Diff line Loading @@ -82,6 +82,8 @@ class FP_LIB_TABLE_LEXER; */ */ class FP_LIB_TABLE : public wxGridTableBase class FP_LIB_TABLE : public wxGridTableBase { { friend class DIALOG_FP_LIB_TABLE; public: public: /** /** Loading @@ -92,6 +94,7 @@ public: class ROW class ROW { { friend class FP_LIB_TABLE; friend class FP_LIB_TABLE; friend class DIALOG_FP_LIB_TABLE; public: public: Loading Loading @@ -148,8 +151,6 @@ public: void Format( OUTPUTFORMATTER* out, int nestLevel ) const void Format( OUTPUTFORMATTER* out, int nestLevel ) const throw( IO_ERROR ); throw( IO_ERROR ); protected: ROW( FP_LIB_TABLE* aOwner ) : ROW( FP_LIB_TABLE* aOwner ) : owner( aOwner ) owner( aOwner ) // lib( 0 ) // lib( 0 ) Loading Loading @@ -316,9 +317,9 @@ public: switch( aCol ) switch( aCol ) { { case 1: r.SetType( aValue ); case 1: r.SetType( aValue ); break; case 2: r.SetFullURI( aValue ); case 2: r.SetFullURI( aValue ); break; case 3: r.SetOptions( aValue ); case 3: r.SetOptions( aValue ); break; } } } } } } Loading @@ -330,6 +331,51 @@ public: return true; 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; } } //-----</wxGridTableBase overloads>------------------------------------------ //-----</wxGridTableBase overloads>------------------------------------------ Loading pcbnew/dialogs/dialog_fp_lib_table.cpp +115 −5 Original line number Original line Diff line number Diff line Loading @@ -24,7 +24,7 @@ */ */ #include <fctsys.h> #include <dialog_fp_lib_table_base.h> #include <dialog_fp_lib_table_base.h> #include <fp_lib_table.h> #include <fp_lib_table.h> Loading @@ -35,11 +35,113 @@ */ */ class DIALOG_FP_LIB_TABLE : public DIALOG_FP_LIB_TABLE_BASE class DIALOG_FP_LIB_TABLE : public DIALOG_FP_LIB_TABLE_BASE { { //-----<event handlers>---------------------------------- 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 ); } //-----</event handlers>--------------------------------- // 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: public: DIALOG_FP_LIB_TABLE( wxFrame* aParent ) : DIALOG_FP_LIB_TABLE( wxFrame* aParent, FP_LIB_TABLE* aGlobal, FP_LIB_TABLE* aProject ) : DIALOG_FP_LIB_TABLE_BASE( aParent ) 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 ); } } }; }; Loading @@ -47,9 +149,17 @@ public: int InvokePcbLibTableEditor( wxFrame* aParent, FP_LIB_TABLE* aGlobal, FP_LIB_TABLE* aProject ) 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; return 0; } } Loading pcbnew/dialogs/dialog_fp_lib_table_base.cpp +119 −111 Original line number Original line Diff line number Diff line Loading @@ -16,173 +16,164 @@ DIALOG_FP_LIB_TABLE_BASE::DIALOG_FP_LIB_TABLE_BASE( wxWindow* parent, wxWindowID wxBoxSizer* bSizer1; wxBoxSizer* bSizer1; bSizer1 = new wxBoxSizer( wxVERTICAL ); bSizer1 = new wxBoxSizer( wxVERTICAL ); m_splitter1 = new wxSplitterWindow( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxSP_3D|wxSP_3DBORDER ); m_splitter = new wxSplitterWindow( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxSP_3DSASH ); m_splitter1->Connect( wxEVT_IDLE, wxIdleEventHandler( DIALOG_FP_LIB_TABLE_BASE::m_splitter1OnIdle ), NULL, this ); m_splitter->Connect( wxEVT_IDLE, wxIdleEventHandler( DIALOG_FP_LIB_TABLE_BASE::m_splitterOnIdle ), NULL, this ); m_splitter1->SetMinimumPaneSize( 10 ); m_splitter->SetMinimumPaneSize( 10 ); m_top = new wxPanel( m_splitter1, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); m_top = new wxPanel( m_splitter, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); wxStaticBoxSizer* sbSizer3; wxStaticBoxSizer* m_top_sizer; sbSizer3 = new wxStaticBoxSizer( new wxStaticBox( m_top, wxID_ANY, _("Global and Project Scope") ), wxVERTICAL ); 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_auinotebook = new wxAuiNotebook( m_top, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxAUI_NB_BOTTOM ); m_panel4 = new wxPanel( m_auinotebook2, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); m_global_panel = new wxPanel( m_auinotebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); m_panel4->SetToolTip( _("Module libraries which are visible for all projects") ); m_global_panel->SetToolTip( _("Module libraries which are visible for all projects") ); wxBoxSizer* bSizer4; wxBoxSizer* m_global_box_sizer; bSizer4 = new wxBoxSizer( wxVERTICAL ); 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 // Grid m_grid1->CreateGrid( 1, 4 ); m_global_grid->CreateGrid( 1, 4 ); m_grid1->EnableEditing( true ); m_global_grid->EnableEditing( true ); m_grid1->EnableGridLines( true ); m_global_grid->EnableGridLines( true ); m_grid1->EnableDragGridSize( false ); m_global_grid->EnableDragGridSize( true ); m_grid1->SetMargins( 0, 0 ); m_global_grid->SetMargins( 0, 0 ); // Columns // Columns m_grid1->AutoSizeColumns(); m_global_grid->AutoSizeColumns(); m_grid1->EnableDragColMove( false ); m_global_grid->EnableDragColMove( false ); m_grid1->EnableDragColSize( true ); m_global_grid->EnableDragColSize( true ); m_grid1->SetColLabelSize( 30 ); m_global_grid->SetColLabelSize( 30 ); m_grid1->SetColLabelValue( 0, _("Nickname") ); m_global_grid->SetColLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE ); m_grid1->SetColLabelValue( 1, _("Library Path") ); m_grid1->SetColLabelValue( 2, _("Plugin") ); m_grid1->SetColLabelValue( 3, _("Options") ); m_grid1->SetColLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE ); // Rows // Rows m_grid1->AutoSizeRows(); m_global_grid->EnableDragRowSize( true ); m_grid1->EnableDragRowSize( true ); m_global_grid->SetRowLabelSize( 40 ); m_grid1->SetRowLabelSize( 80 ); m_global_grid->SetRowLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE ); m_grid1->SetRowLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE ); // Label Appearance // Label Appearance // Cell Defaults // Cell Defaults m_grid1->SetDefaultCellAlignment( wxALIGN_LEFT, wxALIGN_TOP ); m_global_grid->SetDefaultCellAlignment( wxALIGN_LEFT, wxALIGN_TOP ); bSizer4->Add( m_grid1, 1, wxALL|wxEXPAND, 5 ); m_global_box_sizer->Add( m_global_grid, 1, wxALL|wxEXPAND, 5 ); m_panel4->SetSizer( bSizer4 ); m_global_panel->SetSizer( m_global_box_sizer ); m_panel4->Layout(); m_global_panel->Layout(); bSizer4->Fit( m_panel4 ); m_global_box_sizer->Fit( m_global_panel ); m_auinotebook2->AddPage( m_panel4, _("Global Libraries"), false, wxNullBitmap ); m_auinotebook->AddPage( m_global_panel, _("Global Libraries"), true, wxNullBitmap ); m_panel5 = new wxPanel( m_auinotebook2, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); m_project_panel = new wxPanel( m_auinotebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); wxBoxSizer* bSizer5; wxBoxSizer* m_project_sizer; bSizer5 = new wxBoxSizer( wxVERTICAL ); 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 // Grid m_grid11->CreateGrid( 1, 4 ); m_project_grid->CreateGrid( 1, 4 ); m_grid11->EnableEditing( true ); m_project_grid->EnableEditing( true ); m_grid11->EnableGridLines( true ); m_project_grid->EnableGridLines( true ); m_grid11->EnableDragGridSize( false ); m_project_grid->EnableDragGridSize( true ); m_grid11->SetMargins( 0, 0 ); m_project_grid->SetMargins( 0, 0 ); // Columns // Columns m_grid11->AutoSizeColumns(); m_project_grid->AutoSizeColumns(); m_grid11->EnableDragColMove( false ); m_project_grid->EnableDragColMove( false ); m_grid11->EnableDragColSize( true ); m_project_grid->EnableDragColSize( true ); m_grid11->SetColLabelSize( 30 ); m_project_grid->SetColLabelSize( 30 ); m_grid11->SetColLabelValue( 0, _("Nickname") ); m_project_grid->SetColLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE ); m_grid11->SetColLabelValue( 1, _("Library Path") ); m_grid11->SetColLabelValue( 2, _("Plugin") ); m_grid11->SetColLabelValue( 3, _("Options") ); m_grid11->SetColLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE ); // Rows // Rows m_grid11->AutoSizeRows(); m_project_grid->EnableDragRowSize( true ); m_grid11->EnableDragRowSize( true ); m_project_grid->SetRowLabelSize( 40 ); m_grid11->SetRowLabelSize( 80 ); m_project_grid->SetRowLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE ); m_grid11->SetRowLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE ); // Label Appearance // Label Appearance // Cell Defaults // Cell Defaults m_grid11->SetDefaultCellAlignment( wxALIGN_LEFT, wxALIGN_TOP ); m_project_grid->SetDefaultCellAlignment( wxALIGN_LEFT, wxALIGN_TOP ); bSizer5->Add( m_grid11, 0, wxALL, 5 ); m_project_sizer->Add( m_project_grid, 0, wxALL, 5 ); m_panel5->SetSizer( bSizer5 ); m_project_panel->SetSizer( m_project_sizer ); m_panel5->Layout(); m_project_panel->Layout(); bSizer5->Fit( m_panel5 ); m_project_sizer->Fit( m_project_panel ); m_auinotebook2->AddPage( m_panel5, _("Project Specific Libraries"), true, wxNullBitmap ); 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; wxBoxSizer* bSizer51; bSizer51 = new wxBoxSizer( wxHORIZONTAL ); bSizer51 = new wxBoxSizer( wxHORIZONTAL ); m_button1 = new wxButton( m_top, wxID_ANY, _("Append Row"), wxDefaultPosition, wxDefaultSize, 0 ); m_append_button = 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->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_delete_button = 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->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_move_up_button = 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->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_move_down_button = 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->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(); m_top->Layout(); sbSizer3->Fit( m_top ); m_top_sizer->Fit( m_top ); m_bottom = new wxPanel( m_splitter1, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); m_bottom = new wxPanel( m_splitter, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); wxBoxSizer* bSizer8; wxBoxSizer* m_bottom_sizer; bSizer8 = new wxBoxSizer( wxVERTICAL ); m_bottom_sizer = new wxBoxSizer( wxVERTICAL ); wxStaticBoxSizer* sbSizer1; wxStaticBoxSizer* sbSizer1; sbSizer1 = new wxStaticBoxSizer( new wxStaticBox( m_bottom, wxID_ANY, _("Path Substitutions") ), wxVERTICAL ); 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 // Grid m_grid2->CreateGrid( 2, 2 ); m_path_subs_grid->CreateGrid( 2, 2 ); m_grid2->EnableEditing( true ); m_path_subs_grid->EnableEditing( true ); m_grid2->EnableGridLines( true ); m_path_subs_grid->EnableGridLines( true ); m_grid2->EnableDragGridSize( false ); m_path_subs_grid->EnableDragGridSize( false ); m_grid2->SetMargins( 0, 0 ); m_path_subs_grid->SetMargins( 0, 0 ); // Columns // Columns m_grid2->SetColSize( 0, 150 ); m_path_subs_grid->SetColSize( 0, 150 ); m_grid2->SetColSize( 1, 500 ); m_path_subs_grid->SetColSize( 1, 500 ); m_grid2->EnableDragColMove( false ); m_path_subs_grid->AutoSizeColumns(); m_grid2->EnableDragColSize( true ); m_path_subs_grid->EnableDragColMove( false ); m_grid2->SetColLabelSize( 30 ); m_path_subs_grid->EnableDragColSize( true ); m_grid2->SetColLabelValue( 0, _("Category") ); m_path_subs_grid->SetColLabelSize( 30 ); m_grid2->SetColLabelValue( 1, _("Path Segment") ); m_path_subs_grid->SetColLabelValue( 0, _("Category") ); m_grid2->SetColLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE ); m_path_subs_grid->SetColLabelValue( 1, _("Path Segment") ); m_path_subs_grid->SetColLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE ); // Rows // Rows m_grid2->EnableDragRowSize( true ); m_path_subs_grid->EnableDragRowSize( true ); m_grid2->SetRowLabelSize( 40 ); m_path_subs_grid->SetRowLabelSize( 40 ); m_grid2->SetRowLabelValue( 0, _("%S") ); m_path_subs_grid->SetRowLabelValue( 0, _("%S") ); m_grid2->SetRowLabelValue( 1, _("%P") ); m_path_subs_grid->SetRowLabelValue( 1, _("%P") ); m_grid2->SetRowLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE ); m_path_subs_grid->SetRowLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE ); // Label Appearance // Label Appearance // Cell Defaults // Cell Defaults m_grid2->SetDefaultCellAlignment( wxALIGN_LEFT, wxALIGN_TOP ); m_path_subs_grid->SetDefaultCellAlignment( wxALIGN_LEFT, wxALIGN_TOP ); sbSizer1->Add( m_grid2, 0, wxALL, 5 ); 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_sdbSizer1 = new wxStdDialogButtonSizer(); m_sdbSizer1OK = new wxButton( m_bottom, wxID_OK ); m_sdbSizer1OK = new wxButton( m_bottom, wxID_OK ); Loading @@ -191,23 +182,40 @@ DIALOG_FP_LIB_TABLE_BASE::DIALOG_FP_LIB_TABLE_BASE( wxWindow* parent, wxWindowID m_sdbSizer1->AddButton( m_sdbSizer1Cancel ); m_sdbSizer1->AddButton( m_sdbSizer1Cancel ); m_sdbSizer1->Realize(); 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(); m_bottom->Layout(); bSizer8->Fit( m_bottom ); m_bottom_sizer->Fit( m_bottom ); m_splitter1->SplitHorizontally( m_top, m_bottom, 254 ); m_splitter->SplitHorizontally( m_top, m_bottom, 343 ); bSizer1->Add( m_splitter1, 2, wxEXPAND, 5 ); bSizer1->Add( m_splitter, 2, wxEXPAND, 5 ); this->SetSizer( bSizer1 ); this->SetSizer( bSizer1 ); this->Layout(); this->Layout(); bSizer1->Fit( this ); this->Centre( wxBOTH ); 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() 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 ); } } Loading
common/fp_lib_table.cpp +46 −44 Original line number Original line Diff line number Diff line Loading @@ -178,6 +178,52 @@ std::vector<wxString> 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. #if 0 // will need PLUGIN_RELEASER. MODULE* FP_LIB_TABLE::LookupFootprint( const FP_LIB_ID& aFootprintId ) MODULE* FP_LIB_TABLE::LookupFootprint( const FP_LIB_ID& aFootprintId ) throw( IO_ERROR ) throw( IO_ERROR ) Loading Loading @@ -256,47 +302,3 @@ void FP_LIB_TABLE::loadLib( ROW* aRow ) throw( IO_ERROR ) } } #endif #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; }
include/fp_lib_table.h +51 −5 Original line number Original line Diff line number Diff line Loading @@ -82,6 +82,8 @@ class FP_LIB_TABLE_LEXER; */ */ class FP_LIB_TABLE : public wxGridTableBase class FP_LIB_TABLE : public wxGridTableBase { { friend class DIALOG_FP_LIB_TABLE; public: public: /** /** Loading @@ -92,6 +94,7 @@ public: class ROW class ROW { { friend class FP_LIB_TABLE; friend class FP_LIB_TABLE; friend class DIALOG_FP_LIB_TABLE; public: public: Loading Loading @@ -148,8 +151,6 @@ public: void Format( OUTPUTFORMATTER* out, int nestLevel ) const void Format( OUTPUTFORMATTER* out, int nestLevel ) const throw( IO_ERROR ); throw( IO_ERROR ); protected: ROW( FP_LIB_TABLE* aOwner ) : ROW( FP_LIB_TABLE* aOwner ) : owner( aOwner ) owner( aOwner ) // lib( 0 ) // lib( 0 ) Loading Loading @@ -316,9 +317,9 @@ public: switch( aCol ) switch( aCol ) { { case 1: r.SetType( aValue ); case 1: r.SetType( aValue ); break; case 2: r.SetFullURI( aValue ); case 2: r.SetFullURI( aValue ); break; case 3: r.SetOptions( aValue ); case 3: r.SetOptions( aValue ); break; } } } } } } Loading @@ -330,6 +331,51 @@ public: return true; 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; } } //-----</wxGridTableBase overloads>------------------------------------------ //-----</wxGridTableBase overloads>------------------------------------------ Loading
pcbnew/dialogs/dialog_fp_lib_table.cpp +115 −5 Original line number Original line Diff line number Diff line Loading @@ -24,7 +24,7 @@ */ */ #include <fctsys.h> #include <dialog_fp_lib_table_base.h> #include <dialog_fp_lib_table_base.h> #include <fp_lib_table.h> #include <fp_lib_table.h> Loading @@ -35,11 +35,113 @@ */ */ class DIALOG_FP_LIB_TABLE : public DIALOG_FP_LIB_TABLE_BASE class DIALOG_FP_LIB_TABLE : public DIALOG_FP_LIB_TABLE_BASE { { //-----<event handlers>---------------------------------- 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 ); } //-----</event handlers>--------------------------------- // 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: public: DIALOG_FP_LIB_TABLE( wxFrame* aParent ) : DIALOG_FP_LIB_TABLE( wxFrame* aParent, FP_LIB_TABLE* aGlobal, FP_LIB_TABLE* aProject ) : DIALOG_FP_LIB_TABLE_BASE( aParent ) 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 ); } } }; }; Loading @@ -47,9 +149,17 @@ public: int InvokePcbLibTableEditor( wxFrame* aParent, FP_LIB_TABLE* aGlobal, FP_LIB_TABLE* aProject ) 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; return 0; } } Loading
pcbnew/dialogs/dialog_fp_lib_table_base.cpp +119 −111 Original line number Original line Diff line number Diff line Loading @@ -16,173 +16,164 @@ DIALOG_FP_LIB_TABLE_BASE::DIALOG_FP_LIB_TABLE_BASE( wxWindow* parent, wxWindowID wxBoxSizer* bSizer1; wxBoxSizer* bSizer1; bSizer1 = new wxBoxSizer( wxVERTICAL ); bSizer1 = new wxBoxSizer( wxVERTICAL ); m_splitter1 = new wxSplitterWindow( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxSP_3D|wxSP_3DBORDER ); m_splitter = new wxSplitterWindow( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxSP_3DSASH ); m_splitter1->Connect( wxEVT_IDLE, wxIdleEventHandler( DIALOG_FP_LIB_TABLE_BASE::m_splitter1OnIdle ), NULL, this ); m_splitter->Connect( wxEVT_IDLE, wxIdleEventHandler( DIALOG_FP_LIB_TABLE_BASE::m_splitterOnIdle ), NULL, this ); m_splitter1->SetMinimumPaneSize( 10 ); m_splitter->SetMinimumPaneSize( 10 ); m_top = new wxPanel( m_splitter1, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); m_top = new wxPanel( m_splitter, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); wxStaticBoxSizer* sbSizer3; wxStaticBoxSizer* m_top_sizer; sbSizer3 = new wxStaticBoxSizer( new wxStaticBox( m_top, wxID_ANY, _("Global and Project Scope") ), wxVERTICAL ); 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_auinotebook = new wxAuiNotebook( m_top, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxAUI_NB_BOTTOM ); m_panel4 = new wxPanel( m_auinotebook2, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); m_global_panel = new wxPanel( m_auinotebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); m_panel4->SetToolTip( _("Module libraries which are visible for all projects") ); m_global_panel->SetToolTip( _("Module libraries which are visible for all projects") ); wxBoxSizer* bSizer4; wxBoxSizer* m_global_box_sizer; bSizer4 = new wxBoxSizer( wxVERTICAL ); 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 // Grid m_grid1->CreateGrid( 1, 4 ); m_global_grid->CreateGrid( 1, 4 ); m_grid1->EnableEditing( true ); m_global_grid->EnableEditing( true ); m_grid1->EnableGridLines( true ); m_global_grid->EnableGridLines( true ); m_grid1->EnableDragGridSize( false ); m_global_grid->EnableDragGridSize( true ); m_grid1->SetMargins( 0, 0 ); m_global_grid->SetMargins( 0, 0 ); // Columns // Columns m_grid1->AutoSizeColumns(); m_global_grid->AutoSizeColumns(); m_grid1->EnableDragColMove( false ); m_global_grid->EnableDragColMove( false ); m_grid1->EnableDragColSize( true ); m_global_grid->EnableDragColSize( true ); m_grid1->SetColLabelSize( 30 ); m_global_grid->SetColLabelSize( 30 ); m_grid1->SetColLabelValue( 0, _("Nickname") ); m_global_grid->SetColLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE ); m_grid1->SetColLabelValue( 1, _("Library Path") ); m_grid1->SetColLabelValue( 2, _("Plugin") ); m_grid1->SetColLabelValue( 3, _("Options") ); m_grid1->SetColLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE ); // Rows // Rows m_grid1->AutoSizeRows(); m_global_grid->EnableDragRowSize( true ); m_grid1->EnableDragRowSize( true ); m_global_grid->SetRowLabelSize( 40 ); m_grid1->SetRowLabelSize( 80 ); m_global_grid->SetRowLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE ); m_grid1->SetRowLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE ); // Label Appearance // Label Appearance // Cell Defaults // Cell Defaults m_grid1->SetDefaultCellAlignment( wxALIGN_LEFT, wxALIGN_TOP ); m_global_grid->SetDefaultCellAlignment( wxALIGN_LEFT, wxALIGN_TOP ); bSizer4->Add( m_grid1, 1, wxALL|wxEXPAND, 5 ); m_global_box_sizer->Add( m_global_grid, 1, wxALL|wxEXPAND, 5 ); m_panel4->SetSizer( bSizer4 ); m_global_panel->SetSizer( m_global_box_sizer ); m_panel4->Layout(); m_global_panel->Layout(); bSizer4->Fit( m_panel4 ); m_global_box_sizer->Fit( m_global_panel ); m_auinotebook2->AddPage( m_panel4, _("Global Libraries"), false, wxNullBitmap ); m_auinotebook->AddPage( m_global_panel, _("Global Libraries"), true, wxNullBitmap ); m_panel5 = new wxPanel( m_auinotebook2, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); m_project_panel = new wxPanel( m_auinotebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); wxBoxSizer* bSizer5; wxBoxSizer* m_project_sizer; bSizer5 = new wxBoxSizer( wxVERTICAL ); 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 // Grid m_grid11->CreateGrid( 1, 4 ); m_project_grid->CreateGrid( 1, 4 ); m_grid11->EnableEditing( true ); m_project_grid->EnableEditing( true ); m_grid11->EnableGridLines( true ); m_project_grid->EnableGridLines( true ); m_grid11->EnableDragGridSize( false ); m_project_grid->EnableDragGridSize( true ); m_grid11->SetMargins( 0, 0 ); m_project_grid->SetMargins( 0, 0 ); // Columns // Columns m_grid11->AutoSizeColumns(); m_project_grid->AutoSizeColumns(); m_grid11->EnableDragColMove( false ); m_project_grid->EnableDragColMove( false ); m_grid11->EnableDragColSize( true ); m_project_grid->EnableDragColSize( true ); m_grid11->SetColLabelSize( 30 ); m_project_grid->SetColLabelSize( 30 ); m_grid11->SetColLabelValue( 0, _("Nickname") ); m_project_grid->SetColLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE ); m_grid11->SetColLabelValue( 1, _("Library Path") ); m_grid11->SetColLabelValue( 2, _("Plugin") ); m_grid11->SetColLabelValue( 3, _("Options") ); m_grid11->SetColLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE ); // Rows // Rows m_grid11->AutoSizeRows(); m_project_grid->EnableDragRowSize( true ); m_grid11->EnableDragRowSize( true ); m_project_grid->SetRowLabelSize( 40 ); m_grid11->SetRowLabelSize( 80 ); m_project_grid->SetRowLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE ); m_grid11->SetRowLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE ); // Label Appearance // Label Appearance // Cell Defaults // Cell Defaults m_grid11->SetDefaultCellAlignment( wxALIGN_LEFT, wxALIGN_TOP ); m_project_grid->SetDefaultCellAlignment( wxALIGN_LEFT, wxALIGN_TOP ); bSizer5->Add( m_grid11, 0, wxALL, 5 ); m_project_sizer->Add( m_project_grid, 0, wxALL, 5 ); m_panel5->SetSizer( bSizer5 ); m_project_panel->SetSizer( m_project_sizer ); m_panel5->Layout(); m_project_panel->Layout(); bSizer5->Fit( m_panel5 ); m_project_sizer->Fit( m_project_panel ); m_auinotebook2->AddPage( m_panel5, _("Project Specific Libraries"), true, wxNullBitmap ); 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; wxBoxSizer* bSizer51; bSizer51 = new wxBoxSizer( wxHORIZONTAL ); bSizer51 = new wxBoxSizer( wxHORIZONTAL ); m_button1 = new wxButton( m_top, wxID_ANY, _("Append Row"), wxDefaultPosition, wxDefaultSize, 0 ); m_append_button = 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->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_delete_button = 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->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_move_up_button = 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->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_move_down_button = 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->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(); m_top->Layout(); sbSizer3->Fit( m_top ); m_top_sizer->Fit( m_top ); m_bottom = new wxPanel( m_splitter1, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); m_bottom = new wxPanel( m_splitter, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); wxBoxSizer* bSizer8; wxBoxSizer* m_bottom_sizer; bSizer8 = new wxBoxSizer( wxVERTICAL ); m_bottom_sizer = new wxBoxSizer( wxVERTICAL ); wxStaticBoxSizer* sbSizer1; wxStaticBoxSizer* sbSizer1; sbSizer1 = new wxStaticBoxSizer( new wxStaticBox( m_bottom, wxID_ANY, _("Path Substitutions") ), wxVERTICAL ); 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 // Grid m_grid2->CreateGrid( 2, 2 ); m_path_subs_grid->CreateGrid( 2, 2 ); m_grid2->EnableEditing( true ); m_path_subs_grid->EnableEditing( true ); m_grid2->EnableGridLines( true ); m_path_subs_grid->EnableGridLines( true ); m_grid2->EnableDragGridSize( false ); m_path_subs_grid->EnableDragGridSize( false ); m_grid2->SetMargins( 0, 0 ); m_path_subs_grid->SetMargins( 0, 0 ); // Columns // Columns m_grid2->SetColSize( 0, 150 ); m_path_subs_grid->SetColSize( 0, 150 ); m_grid2->SetColSize( 1, 500 ); m_path_subs_grid->SetColSize( 1, 500 ); m_grid2->EnableDragColMove( false ); m_path_subs_grid->AutoSizeColumns(); m_grid2->EnableDragColSize( true ); m_path_subs_grid->EnableDragColMove( false ); m_grid2->SetColLabelSize( 30 ); m_path_subs_grid->EnableDragColSize( true ); m_grid2->SetColLabelValue( 0, _("Category") ); m_path_subs_grid->SetColLabelSize( 30 ); m_grid2->SetColLabelValue( 1, _("Path Segment") ); m_path_subs_grid->SetColLabelValue( 0, _("Category") ); m_grid2->SetColLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE ); m_path_subs_grid->SetColLabelValue( 1, _("Path Segment") ); m_path_subs_grid->SetColLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE ); // Rows // Rows m_grid2->EnableDragRowSize( true ); m_path_subs_grid->EnableDragRowSize( true ); m_grid2->SetRowLabelSize( 40 ); m_path_subs_grid->SetRowLabelSize( 40 ); m_grid2->SetRowLabelValue( 0, _("%S") ); m_path_subs_grid->SetRowLabelValue( 0, _("%S") ); m_grid2->SetRowLabelValue( 1, _("%P") ); m_path_subs_grid->SetRowLabelValue( 1, _("%P") ); m_grid2->SetRowLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE ); m_path_subs_grid->SetRowLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE ); // Label Appearance // Label Appearance // Cell Defaults // Cell Defaults m_grid2->SetDefaultCellAlignment( wxALIGN_LEFT, wxALIGN_TOP ); m_path_subs_grid->SetDefaultCellAlignment( wxALIGN_LEFT, wxALIGN_TOP ); sbSizer1->Add( m_grid2, 0, wxALL, 5 ); 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_sdbSizer1 = new wxStdDialogButtonSizer(); m_sdbSizer1OK = new wxButton( m_bottom, wxID_OK ); m_sdbSizer1OK = new wxButton( m_bottom, wxID_OK ); Loading @@ -191,23 +182,40 @@ DIALOG_FP_LIB_TABLE_BASE::DIALOG_FP_LIB_TABLE_BASE( wxWindow* parent, wxWindowID m_sdbSizer1->AddButton( m_sdbSizer1Cancel ); m_sdbSizer1->AddButton( m_sdbSizer1Cancel ); m_sdbSizer1->Realize(); 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(); m_bottom->Layout(); bSizer8->Fit( m_bottom ); m_bottom_sizer->Fit( m_bottom ); m_splitter1->SplitHorizontally( m_top, m_bottom, 254 ); m_splitter->SplitHorizontally( m_top, m_bottom, 343 ); bSizer1->Add( m_splitter1, 2, wxEXPAND, 5 ); bSizer1->Add( m_splitter, 2, wxEXPAND, 5 ); this->SetSizer( bSizer1 ); this->SetSizer( bSizer1 ); this->Layout(); this->Layout(); bSizer1->Fit( this ); this->Centre( wxBOTH ); 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() 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 ); } }