diff --git a/common/dialog_shim.cpp b/common/dialog_shim.cpp index 1f6c82466b..0f73cb8470 100644 --- a/common/dialog_shim.cpp +++ b/common/dialog_shim.cpp @@ -76,8 +76,6 @@ DIALOG_SHIM::DIALOG_SHIM( wxWindow* aParent, wxWindowID id, const wxString& titl aParent = aParent->GetParent(); kiwayHolder = dynamic_cast( aParent ); } - - wxASSERT_MSG( kiwayHolder, "Dialog parent is not a KIWAY_HOLDER" ); } if( kiwayHolder ) diff --git a/common/dialogs/dialog_configure_paths.cpp b/common/dialogs/dialog_configure_paths.cpp index e4769fc15a..b72a47053c 100644 --- a/common/dialogs/dialog_configure_paths.cpp +++ b/common/dialogs/dialog_configure_paths.cpp @@ -49,7 +49,8 @@ enum SEARCH_PATH_GRID_COLUMNS DIALOG_CONFIGURE_PATHS::DIALOG_CONFIGURE_PATHS( wxWindow* aParent, FILENAME_RESOLVER* aResolver ) : DIALOG_CONFIGURE_PATHS_BASE( aParent ), m_errorGrid( nullptr ), - m_resolver( aResolver ) + m_resolver( aResolver ), + m_gridWidthsDirty( true ) { m_btnAddEnvVar->SetBitmap( KiBitmap( small_plus_xpm ) ); m_btnDeleteEnvVar->SetBitmap( KiBitmap( trash_xpm ) ); @@ -450,28 +451,38 @@ void DIALOG_CONFIGURE_PATHS::OnGridCellRightClick( wxGridEvent& aEvent ) } -void DIALOG_CONFIGURE_PATHS::AdjustGridColumns( int aWidth ) +void DIALOG_CONFIGURE_PATHS::OnGridCellChange( wxGridEvent& aEvent ) { - m_EnvVars->AutoSizeColumn( EV_NAME_COL ); - m_EnvVars->SetColSize( EV_NAME_COL, std::max( m_EnvVars->GetColSize( EV_NAME_COL ), 120 ) ); + m_gridWidthsDirty = true; - m_EnvVars->SetColSize( EV_PATH_COL, aWidth - m_EnvVars->GetColSize( EV_NAME_COL ) ); - - m_SearchPaths->AutoSizeColumn( SP_ALIAS_COL ); - m_SearchPaths->SetColSize( SP_ALIAS_COL, std::max( m_SearchPaths->GetColSize( SP_ALIAS_COL ), 120 ) ); - - m_SearchPaths->AutoSizeColumn( SP_PATH_COL ); - m_SearchPaths->SetColSize( SP_PATH_COL, std::max( m_SearchPaths->GetColSize( SP_PATH_COL ), 300 ) ); - - m_SearchPaths->SetColSize( SP_DESC_COL, aWidth - ( m_SearchPaths->GetColSize( SP_ALIAS_COL ) - + m_SearchPaths->GetColSize( SP_PATH_COL ) ) ); + aEvent.Skip(); } void DIALOG_CONFIGURE_PATHS::OnUpdateUI( wxUpdateUIEvent& event ) { - if( !m_EnvVars->IsCellEditControlShown() && !m_SearchPaths->IsCellEditControlShown() ) - AdjustGridColumns( m_EnvVars->GetRect().GetWidth() ); + if( m_gridWidthsDirty && ( !m_EnvVars->IsCellEditControlShown() + && !m_SearchPaths->IsCellEditControlShown() ) ) + { + int width = m_EnvVars->GetClientRect().GetWidth(); + + m_EnvVars->AutoSizeColumn( EV_NAME_COL ); + m_EnvVars->SetColSize( EV_NAME_COL, std::max( m_EnvVars->GetColSize( EV_NAME_COL ), 120 ) ); + + m_EnvVars->SetColSize( EV_PATH_COL, width - m_EnvVars->GetColSize( EV_NAME_COL ) ); + + width = m_SearchPaths->GetClientRect().GetWidth(); + + m_SearchPaths->AutoSizeColumn( SP_ALIAS_COL ); + m_SearchPaths->SetColSize( SP_ALIAS_COL, std::max( m_SearchPaths->GetColSize( SP_ALIAS_COL ), 120 ) ); + + m_SearchPaths->AutoSizeColumn( SP_PATH_COL ); + m_SearchPaths->SetColSize( SP_PATH_COL, std::max( m_SearchPaths->GetColSize( SP_PATH_COL ), 300 ) ); + + m_SearchPaths->SetColSize( SP_DESC_COL, width - ( m_SearchPaths->GetColSize( SP_ALIAS_COL ) + + m_SearchPaths->GetColSize( SP_PATH_COL ) ) ); + m_gridWidthsDirty = false; + } // Handle a grid error. This is delayed to OnUpdateUI so that we can change focus // even when the original validation was triggered from a killFocus event (and for @@ -498,7 +509,7 @@ void DIALOG_CONFIGURE_PATHS::OnUpdateUI( wxUpdateUIEvent& event ) void DIALOG_CONFIGURE_PATHS::OnGridSize( wxSizeEvent& event ) { - AdjustGridColumns( event.GetSize().GetX() ); + m_gridWidthsDirty = true; event.Skip(); } diff --git a/common/dialogs/dialog_configure_paths_base.cpp b/common/dialogs/dialog_configure_paths_base.cpp index c10f640338..9a7916034e 100644 --- a/common/dialogs/dialog_configure_paths_base.cpp +++ b/common/dialogs/dialog_configure_paths_base.cpp @@ -155,10 +155,12 @@ DIALOG_CONFIGURE_PATHS_BASE::DIALOG_CONFIGURE_PATHS_BASE( wxWindow* parent, wxWi this->Centre( wxBOTH ); // Connect Events + m_EnvVars->Connect( wxEVT_GRID_CELL_CHANGED, wxGridEventHandler( DIALOG_CONFIGURE_PATHS_BASE::OnGridCellChange ), NULL, this ); m_EnvVars->Connect( wxEVT_SIZE, wxSizeEventHandler( DIALOG_CONFIGURE_PATHS_BASE::OnGridSize ), NULL, this ); m_EnvVars->Connect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( DIALOG_CONFIGURE_PATHS_BASE::OnUpdateUI ), NULL, this ); m_btnAddEnvVar->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_CONFIGURE_PATHS_BASE::OnAddEnvVar ), NULL, this ); m_btnDeleteEnvVar->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_CONFIGURE_PATHS_BASE::OnRemoveEnvVar ), NULL, this ); + m_SearchPaths->Connect( wxEVT_GRID_CELL_CHANGED, wxGridEventHandler( DIALOG_CONFIGURE_PATHS_BASE::OnGridCellChange ), NULL, this ); m_SearchPaths->Connect( wxEVT_GRID_CELL_RIGHT_CLICK, wxGridEventHandler( DIALOG_CONFIGURE_PATHS_BASE::OnGridCellRightClick ), NULL, this ); m_SearchPaths->Connect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( DIALOG_CONFIGURE_PATHS_BASE::OnUpdateUI ), NULL, this ); m_btnAddSearchPath->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_CONFIGURE_PATHS_BASE::OnAddSearchPath ), NULL, this ); @@ -171,10 +173,12 @@ DIALOG_CONFIGURE_PATHS_BASE::DIALOG_CONFIGURE_PATHS_BASE( wxWindow* parent, wxWi DIALOG_CONFIGURE_PATHS_BASE::~DIALOG_CONFIGURE_PATHS_BASE() { // Disconnect Events + m_EnvVars->Disconnect( wxEVT_GRID_CELL_CHANGED, wxGridEventHandler( DIALOG_CONFIGURE_PATHS_BASE::OnGridCellChange ), NULL, this ); m_EnvVars->Disconnect( wxEVT_SIZE, wxSizeEventHandler( DIALOG_CONFIGURE_PATHS_BASE::OnGridSize ), NULL, this ); m_EnvVars->Disconnect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( DIALOG_CONFIGURE_PATHS_BASE::OnUpdateUI ), NULL, this ); m_btnAddEnvVar->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_CONFIGURE_PATHS_BASE::OnAddEnvVar ), NULL, this ); m_btnDeleteEnvVar->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_CONFIGURE_PATHS_BASE::OnRemoveEnvVar ), NULL, this ); + m_SearchPaths->Disconnect( wxEVT_GRID_CELL_CHANGED, wxGridEventHandler( DIALOG_CONFIGURE_PATHS_BASE::OnGridCellChange ), NULL, this ); m_SearchPaths->Disconnect( wxEVT_GRID_CELL_RIGHT_CLICK, wxGridEventHandler( DIALOG_CONFIGURE_PATHS_BASE::OnGridCellRightClick ), NULL, this ); m_SearchPaths->Disconnect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( DIALOG_CONFIGURE_PATHS_BASE::OnUpdateUI ), NULL, this ); m_btnAddSearchPath->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_CONFIGURE_PATHS_BASE::OnAddSearchPath ), NULL, this ); diff --git a/common/dialogs/dialog_configure_paths_base.fbp b/common/dialogs/dialog_configure_paths_base.fbp index b07b7a1636..310bb506c6 100644 --- a/common/dialogs/dialog_configure_paths_base.fbp +++ b/common/dialogs/dialog_configure_paths_base.fbp @@ -195,7 +195,7 @@ - + OnGridCellChange @@ -550,7 +550,7 @@ - + OnGridCellChange OnGridCellRightClick diff --git a/common/dialogs/dialog_configure_paths_base.h b/common/dialogs/dialog_configure_paths_base.h index 6a488ba4ea..68e5bdc773 100644 --- a/common/dialogs/dialog_configure_paths_base.h +++ b/common/dialogs/dialog_configure_paths_base.h @@ -53,6 +53,7 @@ class DIALOG_CONFIGURE_PATHS_BASE : public DIALOG_SHIM wxButton* m_sdbSizerHelp; // Virtual event handlers, overide them in your derived class + virtual void OnGridCellChange( wxGridEvent& event ) { event.Skip(); } virtual void OnGridSize( wxSizeEvent& event ) { event.Skip(); } virtual void OnUpdateUI( wxUpdateUIEvent& event ) { event.Skip(); } virtual void OnAddEnvVar( wxCommandEvent& event ) { event.Skip(); } diff --git a/cvpcb/CMakeLists.txt b/cvpcb/CMakeLists.txt index 44ab8347e7..c80ef0818f 100644 --- a/cvpcb/CMakeLists.txt +++ b/cvpcb/CMakeLists.txt @@ -25,10 +25,10 @@ set( CVPCB_DIALOGS dialogs/dialog_display_options_base.cpp dialogs/dialog_config_equfiles_base.cpp dialogs/dialog_config_equfiles.cpp - ../pcbnew/dialogs/dialog_fp_lib_table.cpp - ../pcbnew/dialogs/dialog_fp_lib_table_base.cpp ../pcbnew/dialogs/dialog_fp_plugin_options.cpp ../pcbnew/dialogs/dialog_fp_plugin_options_base.cpp + ../pcbnew/dialogs/panel_fp_lib_table.cpp + ../pcbnew/dialogs/panel_fp_lib_table_base.cpp ) set( CVPCB_SRCS diff --git a/eeschema/CMakeLists.txt b/eeschema/CMakeLists.txt index fcf21d74fa..87177f7b30 100644 --- a/eeschema/CMakeLists.txt +++ b/eeschema/CMakeLists.txt @@ -70,8 +70,6 @@ set( EESCHEMA_DLGS dialogs/dialog_sch_sheet_props_base.cpp dialogs/dialog_schematic_find.cpp dialogs/dialog_schematic_find_base.cpp - dialogs/dialog_sym_lib_table.cpp - dialogs/dialog_sym_lib_table_base.cpp dialogs/dialog_symbol_remap.cpp dialogs/dialog_symbol_remap_base.cpp dialogs/dialog_update_fields.cpp @@ -84,6 +82,8 @@ set( EESCHEMA_DLGS dialogs/panel_eeschema_settings_base.cpp dialogs/panel_libedit_settings.cpp dialogs/panel_libedit_settings_base.cpp + dialogs/panel_sym_lib_table.cpp + dialogs/panel_sym_lib_table_base.cpp ) set( EESCHEMA_WIDGETS diff --git a/eeschema/dialogs/dialog_sym_lib_table.cpp b/eeschema/dialogs/panel_sym_lib_table.cpp similarity index 86% rename from eeschema/dialogs/dialog_sym_lib_table.cpp rename to eeschema/dialogs/panel_sym_lib_table.cpp index 9e8335e22c..01f41f7079 100644 --- a/eeschema/dialogs/dialog_sym_lib_table.cpp +++ b/eeschema/dialogs/panel_sym_lib_table.cpp @@ -23,7 +23,7 @@ #include #include -#include +#include #include #include #include @@ -78,20 +78,21 @@ public: class SYMBOL_GRID_TRICKS : public GRID_TRICKS { public: - SYMBOL_GRID_TRICKS( wxGrid* aGrid ) : - GRID_TRICKS( aGrid ) + SYMBOL_GRID_TRICKS( DIALOG_EDIT_LIBRARY_TABLES* aParent, wxGrid* aGrid ) : + GRID_TRICKS( aGrid ), + m_dialog( aParent ) { } protected: + DIALOG_EDIT_LIBRARY_TABLES* m_dialog; /// handle specialized clipboard text, with leading "(sym_lib_table" or /// spreadsheet formatted text. virtual void paste_text( const wxString& cb_text ) override { - SYMBOL_LIB_TABLE_GRID* tbl = (SYMBOL_LIB_TABLE_GRID*) m_grid->GetTable(); - - size_t ndx = cb_text.find( "(sym_lib_table" ); + SYMBOL_LIB_TABLE_GRID* tbl = (SYMBOL_LIB_TABLE_GRID*) m_grid->GetTable(); + size_t ndx = cb_text.find( "(sym_lib_table" ); if( ndx != std::string::npos ) { @@ -109,7 +110,7 @@ protected: } catch( PARSE_ERROR& pe ) { - DisplayError( NULL, pe.What() ); + DisplayError( m_dialog, pe.What() ); parsed = false; } @@ -136,15 +137,16 @@ protected: }; -DIALOG_SYMBOL_LIB_TABLE::DIALOG_SYMBOL_LIB_TABLE( wxTopLevelWindow* aParent, - SYMBOL_LIB_TABLE* aGlobal, - SYMBOL_LIB_TABLE* aProject ) : - DIALOG_SYMBOL_LIB_TABLE_BASE( aParent ), +PANEL_SYM_LIB_TABLE::PANEL_SYM_LIB_TABLE( DIALOG_EDIT_LIBRARY_TABLES* aParent, + SYMBOL_LIB_TABLE* aGlobal, + SYMBOL_LIB_TABLE* aProject ) : + PANEL_SYM_LIB_TABLE_BASE( aParent ), m_global( aGlobal ), - m_project( aProject ) + m_project( aProject ), + m_parent( aParent ) { // For user info, shows the table filenames: - m_PrjTableFilename->SetLabel( Prj().SymbolLibTableName() ); + m_PrjTableFilename->SetLabel( m_parent->Prj().SymbolLibTableName() ); m_GblTableFilename->SetLabel( SYMBOL_LIB_TABLE::GetGlobalTableFileName() ); // wxGrid only supports user owned tables if they exist past end of ~wxGrid(), @@ -157,8 +159,8 @@ DIALOG_SYMBOL_LIB_TABLE::DIALOG_SYMBOL_LIB_TABLE( wxTopLevelWindow* aParent, m_project_grid->SetDefaultRowSize( m_project_grid->GetDefaultRowSize() + 4 ); // add Cut, Copy, and Paste to wxGrids - m_global_grid->PushEventHandler( new SYMBOL_GRID_TRICKS( m_global_grid ) ); - m_project_grid->PushEventHandler( new SYMBOL_GRID_TRICKS( m_project_grid ) ); + m_global_grid->PushEventHandler( new SYMBOL_GRID_TRICKS( m_parent, m_global_grid ) ); + m_project_grid->PushEventHandler( new SYMBOL_GRID_TRICKS( m_parent, m_project_grid ) ); m_global_grid->AutoSizeColumns( false ); m_project_grid->AutoSizeColumns( false ); @@ -211,21 +213,10 @@ DIALOG_SYMBOL_LIB_TABLE::DIALOG_SYMBOL_LIB_TABLE( wxTopLevelWindow* aParent, m_move_up_button->SetBitmap( KiBitmap( small_up_xpm ) ); m_move_down_button->SetBitmap( KiBitmap( small_down_xpm ) ); m_browse_button->SetBitmap( KiBitmap( folder_xpm ) ); - - m_sdbSizerOK->SetDefault(); - - SetSizeInDU( 450, 400 ); - Center(); - - FinishDialogSettings(); - - // On some window managers (Unity, XFCE), this dialog is not always raised, depending on - // how this dialog is run. - Raise(); } -DIALOG_SYMBOL_LIB_TABLE::~DIALOG_SYMBOL_LIB_TABLE() +PANEL_SYM_LIB_TABLE::~PANEL_SYM_LIB_TABLE() { // Delete the GRID_TRICKS. // Any additional event handlers should be popped before the window is deleted. @@ -234,14 +225,14 @@ DIALOG_SYMBOL_LIB_TABLE::~DIALOG_SYMBOL_LIB_TABLE() } -bool DIALOG_SYMBOL_LIB_TABLE::Show( bool aShow ) +bool PANEL_SYM_LIB_TABLE::Show( bool aShow ) { if( aShow ) { m_cur_grid = ( m_pageNdx == 0 ) ? m_global_grid : m_project_grid; // for ALT+A handling, we want the initial focus to be on the first selected grid. - SetInitialFocus( m_cur_grid ); + m_parent->SetInitialFocus( m_cur_grid ); } else { @@ -249,14 +240,14 @@ bool DIALOG_SYMBOL_LIB_TABLE::Show( bool aShow ) // We must do this on Show( false ) because when the first grid is hidden it // gives focus to the next one (which is then hidden), but the result is that // we save the wrong grid if we do it after this. - m_pageNdx = m_auinotebook->GetSelection(); + m_pageNdx = (unsigned) std::max( 0, m_auinotebook->GetSelection() ); } - return DIALOG_SHIM::Show( aShow ); + return wxPanel::Show( aShow ); } -bool DIALOG_SYMBOL_LIB_TABLE::verifyTables() +bool PANEL_SYM_LIB_TABLE::verifyTables() { for( int t=0; t<2; ++t ) { @@ -278,9 +269,9 @@ bool DIALOG_SYMBOL_LIB_TABLE::verifyTables() } else if( ( illegalCh = LIB_ID::FindIllegalLibNicknameChar( nick, LIB_ID::ID_SCH ) ) ) { - wxString msg = wxString::Format( - _( "Illegal character \"%c\" in Nickname: \"%s\"" ), - illegalCh, GetChars( nick ) ); + wxString msg = wxString::Format( _( "Illegal character '%c' in Nickname: \"%s\"" ), + illegalCh, + nick ); // show the tabbed panel holding the grid we have flunked: if( &model != cur_model() ) @@ -318,10 +309,7 @@ bool DIALOG_SYMBOL_LIB_TABLE::verifyTables() if( nick1 == nick2 ) { - wxString msg = wxString::Format( - _( "Duplicate Nickname: \"%s\" in rows %d and %d" ), - GetChars( nick1 ), r1+1, r2+1 - ); + wxString msg = wxString::Format( _( "Duplicate Nickname: \"%s\"." ), nick1 ); // show the tabbed panel holding the grid we have flunked: if( &model != cur_model() ) @@ -344,17 +332,17 @@ bool DIALOG_SYMBOL_LIB_TABLE::verifyTables() } -void DIALOG_SYMBOL_LIB_TABLE::pageChangedHandler( wxAuiNotebookEvent& event ) +void PANEL_SYM_LIB_TABLE::pageChangedHandler( wxAuiNotebookEvent& event ) { m_cur_grid = ( m_auinotebook->GetSelection() == 0 ) ? m_global_grid : m_project_grid; } -void DIALOG_SYMBOL_LIB_TABLE::browseLibrariesHandler( wxCommandEvent& event ) +void PANEL_SYM_LIB_TABLE::browseLibrariesHandler( wxCommandEvent& event ) { - wxFileDialog dlg( this, _( "Select Library" ), Prj().GetProjectPath(), - wxEmptyString, SchematicLibraryFileWildcard(), - wxFD_OPEN | wxFD_FILE_MUST_EXIST | wxFD_MULTIPLE ); + wxFileDialog dlg( this, _( "Select Library" ), m_parent->Prj().GetProjectPath(), + wxEmptyString, SchematicLibraryFileWildcard(), + wxFD_OPEN | wxFD_FILE_MUST_EXIST | wxFD_MULTIPLE ); dlg.SetDirectory( m_lastBrowseDir ); @@ -365,6 +353,7 @@ void DIALOG_SYMBOL_LIB_TABLE::browseLibrariesHandler( wxCommandEvent& event ) m_lastBrowseDir = dlg.GetDirectory(); + const ENV_VAR_MAP& envVars = Pgm().GetLocalEnvVariables(); bool skipRemainingDuplicates = false; wxArrayString files; dlg.GetFilenames( files ); @@ -419,9 +408,12 @@ void DIALOG_SYMBOL_LIB_TABLE::browseLibrariesHandler( wxCommandEvent& event ) SCH_IO_MGR::ShowType( SCH_IO_MGR::SCH_LEGACY ) ); // try to use path normalized to an environmental variable or project path - wxString normalizedPath = NormalizePath( filePath, &Pgm().GetLocalEnvVariables(), &Prj() ); - m_cur_grid->SetCellValue( last_row, COL_URI, - normalizedPath.IsEmpty() ? fn.GetFullPath() : normalizedPath ); + wxString path = NormalizePath( filePath, &envVars, &m_parent->Prj() ); + + if( path.IsEmpty() ) + path = fn.GetFullPath(); + + m_cur_grid->SetCellValue( last_row, COL_URI, path ); } } @@ -433,7 +425,7 @@ void DIALOG_SYMBOL_LIB_TABLE::browseLibrariesHandler( wxCommandEvent& event ) } -void DIALOG_SYMBOL_LIB_TABLE::appendRowHandler( wxCommandEvent& event ) +void PANEL_SYM_LIB_TABLE::appendRowHandler( wxCommandEvent& event ) { if( m_cur_grid->AppendRows( 1 ) ) { @@ -451,7 +443,7 @@ void DIALOG_SYMBOL_LIB_TABLE::appendRowHandler( wxCommandEvent& event ) } -void DIALOG_SYMBOL_LIB_TABLE::deleteRowHandler( wxCommandEvent& event ) +void PANEL_SYM_LIB_TABLE::deleteRowHandler( wxCommandEvent& event ) { int curRow = m_cur_grid->GetGridCursorRow(); int curCol = m_cur_grid->GetGridCursorCol(); @@ -501,7 +493,7 @@ void DIALOG_SYMBOL_LIB_TABLE::deleteRowHandler( wxCommandEvent& event ) } -void DIALOG_SYMBOL_LIB_TABLE::moveUpHandler( wxCommandEvent& event ) +void PANEL_SYM_LIB_TABLE::moveUpHandler( wxCommandEvent& event ) { SYMBOL_LIB_TABLE_GRID* tbl = cur_model(); int curRow = m_cur_grid->GetGridCursorRow(); @@ -528,7 +520,7 @@ void DIALOG_SYMBOL_LIB_TABLE::moveUpHandler( wxCommandEvent& event ) } -void DIALOG_SYMBOL_LIB_TABLE::moveDownHandler( wxCommandEvent& event ) +void PANEL_SYM_LIB_TABLE::moveDownHandler( wxCommandEvent& event ) { SYMBOL_LIB_TABLE_GRID* tbl = cur_model(); int curRow = m_cur_grid->GetGridCursorRow(); @@ -555,12 +547,12 @@ void DIALOG_SYMBOL_LIB_TABLE::moveDownHandler( wxCommandEvent& event ) } -bool DIALOG_SYMBOL_LIB_TABLE::TransferDataFromWindow() +bool PANEL_SYM_LIB_TABLE::TransferDataFromWindow() { // Commit any pending in-place edits and close the editor m_cur_grid->DisableCellEditControl(); - if( !wxDialog::TransferDataFromWindow() || !verifyTables() ) + if( !verifyTables() ) return false; if( *global_model() != *m_global ) @@ -583,7 +575,7 @@ bool DIALOG_SYMBOL_LIB_TABLE::TransferDataFromWindow() } -void DIALOG_SYMBOL_LIB_TABLE::populateEnvironReadOnlyTable() +void PANEL_SYM_LIB_TABLE::populateEnvironReadOnlyTable() { wxRegEx re( ".*?(\\$\\{(.+?)\\})|(\\$\\((.+?)\\)).*?", wxRE_ADVANCED ); wxASSERT( re.IsValid() ); // wxRE_ADVANCED is required. @@ -644,7 +636,7 @@ void DIALOG_SYMBOL_LIB_TABLE::populateEnvironReadOnlyTable() } -void DIALOG_SYMBOL_LIB_TABLE::adjustPathSubsGridColumns( int aWidth ) +void PANEL_SYM_LIB_TABLE::adjustPathSubsGridColumns( int aWidth ) { // Account for scroll bars aWidth -= ( m_path_subs_grid->GetSize().x - m_path_subs_grid->GetClientSize().x ); @@ -654,7 +646,7 @@ void DIALOG_SYMBOL_LIB_TABLE::adjustPathSubsGridColumns( int aWidth ) } -void DIALOG_SYMBOL_LIB_TABLE::onSizeGrid( wxSizeEvent& event ) +void PANEL_SYM_LIB_TABLE::onSizeGrid( wxSizeEvent& event ) { adjustPathSubsGridColumns( event.GetSize().GetX() ); @@ -662,22 +654,22 @@ void DIALOG_SYMBOL_LIB_TABLE::onSizeGrid( wxSizeEvent& event ) } -SYMBOL_LIB_TABLE_GRID* DIALOG_SYMBOL_LIB_TABLE::global_model() const +SYMBOL_LIB_TABLE_GRID* PANEL_SYM_LIB_TABLE::global_model() const { return (SYMBOL_LIB_TABLE_GRID*) m_global_grid->GetTable(); } -SYMBOL_LIB_TABLE_GRID* DIALOG_SYMBOL_LIB_TABLE::project_model() const +SYMBOL_LIB_TABLE_GRID* PANEL_SYM_LIB_TABLE::project_model() const { return (SYMBOL_LIB_TABLE_GRID*) m_project_grid->GetTable(); } -SYMBOL_LIB_TABLE_GRID* DIALOG_SYMBOL_LIB_TABLE::cur_model() const +SYMBOL_LIB_TABLE_GRID* PANEL_SYM_LIB_TABLE::cur_model() const { return (SYMBOL_LIB_TABLE_GRID*) m_cur_grid->GetTable(); } -size_t DIALOG_SYMBOL_LIB_TABLE::m_pageNdx = 0; +size_t PANEL_SYM_LIB_TABLE::m_pageNdx = 0; diff --git a/eeschema/dialogs/dialog_sym_lib_table.h b/eeschema/dialogs/panel_sym_lib_table.h similarity index 83% rename from eeschema/dialogs/dialog_sym_lib_table.h rename to eeschema/dialogs/panel_sym_lib_table.h index 6a71332b8a..a2f3944fdc 100644 --- a/eeschema/dialogs/dialog_sym_lib_table.h +++ b/eeschema/dialogs/panel_sym_lib_table.h @@ -1,82 +1,84 @@ -/* - * This program source code file is part of KiCad, a free EDA CAD application. - * - * Copyright (C) 2017 Wayne Stambaugh - * Copyright (C) 2017 KiCad Developers, see AUTHORS.txt for contributors. - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation, either version 3 of the License, or (at your - * option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see . - */ - -#ifndef _DIALOG_SYM_LIB_TABLE_H_ -#define _DIALOG_SYM_LIB_TABLE_H_ - -#include - -class SYMBOL_LIB_TABLE; -class SYMBOL_LIB_TABLE_GRID; - - -/** - * Dialog to show and edit symbol library tables. - */ -class DIALOG_SYMBOL_LIB_TABLE : public DIALOG_SYMBOL_LIB_TABLE_BASE -{ - -public: - DIALOG_SYMBOL_LIB_TABLE( wxTopLevelWindow* aParent, SYMBOL_LIB_TABLE* aGlobal, - SYMBOL_LIB_TABLE* aProject ); - virtual ~DIALOG_SYMBOL_LIB_TABLE(); - - bool Show( bool aShow ) override; - -private: - /** - * Trim important fields, removes blank row entries, and checks for duplicates. - * - * @return bool - true if tables are OK, else false. - */ - bool verifyTables(); - - void pageChangedHandler( wxAuiNotebookEvent& event ) override; - void browseLibrariesHandler( wxCommandEvent& event ) override; - void appendRowHandler( wxCommandEvent& event ) override; - void deleteRowHandler( wxCommandEvent& event ) override; - void moveUpHandler( wxCommandEvent& event ) override; - void moveDownHandler( wxCommandEvent& event ) override; - void onSizeGrid( wxSizeEvent& event ) override; - void adjustPathSubsGridColumns( int aWidth ); - - bool TransferDataFromWindow() override; - - /// Populate the readonly environment variable table with names and values - /// by examining all the full_uri columns. - void populateEnvironReadOnlyTable(); - - // Caller's tables are modified only on OK button and successful verification. - SYMBOL_LIB_TABLE* m_global; - SYMBOL_LIB_TABLE* m_project; - - SYMBOL_LIB_TABLE_GRID* global_model() const; - - SYMBOL_LIB_TABLE_GRID* project_model() const; - - SYMBOL_LIB_TABLE_GRID* cur_model() const; - - wxGrid* m_cur_grid; ///< changed based on tab choice - static size_t m_pageNdx; ///< Remember the last notebook page selected during a session - - wxString m_lastBrowseDir; ///< last browsed directory -}; - -#endif // _DIALOG_SYM_LIB_TABLE_H_ +/* + * This program source code file is part of KiCad, a free EDA CAD application. + * + * Copyright (C) 2017 Wayne Stambaugh + * Copyright (C) 2017 KiCad Developers, see AUTHORS.txt for contributors. + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation, either version 3 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + */ + +#ifndef PANEL_SYM_LIB_TABLE_H +#define PANEL_SYM_LIB_TABLE_H + +#include +#include + +class SYMBOL_LIB_TABLE; +class SYMBOL_LIB_TABLE_GRID; + + +/** + * Dialog to show and edit symbol library tables. + */ +class PANEL_SYM_LIB_TABLE : public PANEL_SYM_LIB_TABLE_BASE +{ + +public: + PANEL_SYM_LIB_TABLE( DIALOG_EDIT_LIBRARY_TABLES* aParent, SYMBOL_LIB_TABLE* aGlobal, + SYMBOL_LIB_TABLE* aProject ); + virtual ~PANEL_SYM_LIB_TABLE(); + + bool Show( bool aShow ) override; + +private: + /** + * Trim important fields, removes blank row entries, and checks for duplicates. + * + * @return bool - true if tables are OK, else false. + */ + bool verifyTables(); + + void pageChangedHandler( wxAuiNotebookEvent& event ) override; + void browseLibrariesHandler( wxCommandEvent& event ) override; + void appendRowHandler( wxCommandEvent& event ) override; + void deleteRowHandler( wxCommandEvent& event ) override; + void moveUpHandler( wxCommandEvent& event ) override; + void moveDownHandler( wxCommandEvent& event ) override; + void onSizeGrid( wxSizeEvent& event ) override; + void adjustPathSubsGridColumns( int aWidth ); + + bool TransferDataFromWindow() override; + + /// Populate the readonly environment variable table with names and values + /// by examining all the full_uri columns. + void populateEnvironReadOnlyTable(); + + // Caller's tables are modified only on OK button and successful verification. + SYMBOL_LIB_TABLE* m_global; + SYMBOL_LIB_TABLE* m_project; + + SYMBOL_LIB_TABLE_GRID* global_model() const; + + SYMBOL_LIB_TABLE_GRID* project_model() const; + + SYMBOL_LIB_TABLE_GRID* cur_model() const; + + DIALOG_EDIT_LIBRARY_TABLES* m_parent; + + wxGrid* m_cur_grid; ///< changed based on tab choice + static size_t m_pageNdx; ///< Remember the last notebook page selected during a session + wxString m_lastBrowseDir; ///< last browsed directory +}; + +#endif // PANEL_SYM_LIB_TABLE_H diff --git a/eeschema/dialogs/dialog_sym_lib_table_base.cpp b/eeschema/dialogs/panel_sym_lib_table_base.cpp similarity index 79% rename from eeschema/dialogs/dialog_sym_lib_table_base.cpp rename to eeschema/dialogs/panel_sym_lib_table_base.cpp index 70bb3d1752..260da51c65 100644 --- a/eeschema/dialogs/dialog_sym_lib_table_base.cpp +++ b/eeschema/dialogs/panel_sym_lib_table_base.cpp @@ -5,14 +5,12 @@ // PLEASE DO *NOT* EDIT THIS FILE! /////////////////////////////////////////////////////////////////////////// -#include "dialog_sym_lib_table_base.h" +#include "panel_sym_lib_table_base.h" /////////////////////////////////////////////////////////////////////////// -DIALOG_SYMBOL_LIB_TABLE_BASE::DIALOG_SYMBOL_LIB_TABLE_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : DIALOG_SHIM( parent, id, title, pos, size, style ) +PANEL_SYM_LIB_TABLE_BASE::PANEL_SYM_LIB_TABLE_BASE( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style ) : wxPanel( parent, id, pos, size, style ) { - this->SetSizeHints( wxSize( -1,-1 ), wxDefaultSize ); - wxBoxSizer* bSizer1; bSizer1 = new wxBoxSizer( wxVERTICAL ); @@ -191,47 +189,29 @@ DIALOG_SYMBOL_LIB_TABLE_BASE::DIALOG_SYMBOL_LIB_TABLE_BASE( wxWindow* parent, wx bSizer1->Add( sbSizer1, 0, wxALL|wxEXPAND, 5 ); - wxBoxSizer* m_bottom_sizer; - m_bottom_sizer = new wxBoxSizer( wxVERTICAL ); - - m_sdbSizer = new wxStdDialogButtonSizer(); - m_sdbSizerOK = new wxButton( this, wxID_OK ); - m_sdbSizer->AddButton( m_sdbSizerOK ); - m_sdbSizerCancel = new wxButton( this, wxID_CANCEL ); - m_sdbSizer->AddButton( m_sdbSizerCancel ); - m_sdbSizer->Realize(); - - m_bottom_sizer->Add( m_sdbSizer, 0, wxEXPAND, 5 ); - - - bSizer1->Add( m_bottom_sizer, 0, 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_SYMBOL_LIB_TABLE_BASE::pageChangedHandler ), NULL, this ); - m_append_button->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_SYMBOL_LIB_TABLE_BASE::appendRowHandler ), NULL, this ); - m_browse_button->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_SYMBOL_LIB_TABLE_BASE::browseLibrariesHandler ), NULL, this ); - m_delete_button->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_SYMBOL_LIB_TABLE_BASE::deleteRowHandler ), NULL, this ); - m_move_up_button->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_SYMBOL_LIB_TABLE_BASE::moveUpHandler ), NULL, this ); - m_move_down_button->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_SYMBOL_LIB_TABLE_BASE::moveDownHandler ), NULL, this ); - m_path_subs_grid->Connect( wxEVT_SIZE, wxSizeEventHandler( DIALOG_SYMBOL_LIB_TABLE_BASE::onSizeGrid ), NULL, this ); + m_auinotebook->Connect( wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGED, wxAuiNotebookEventHandler( PANEL_SYM_LIB_TABLE_BASE::pageChangedHandler ), NULL, this ); + m_append_button->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_SYM_LIB_TABLE_BASE::appendRowHandler ), NULL, this ); + m_browse_button->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_SYM_LIB_TABLE_BASE::browseLibrariesHandler ), NULL, this ); + m_delete_button->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_SYM_LIB_TABLE_BASE::deleteRowHandler ), NULL, this ); + m_move_up_button->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_SYM_LIB_TABLE_BASE::moveUpHandler ), NULL, this ); + m_move_down_button->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_SYM_LIB_TABLE_BASE::moveDownHandler ), NULL, this ); + m_path_subs_grid->Connect( wxEVT_SIZE, wxSizeEventHandler( PANEL_SYM_LIB_TABLE_BASE::onSizeGrid ), NULL, this ); } -DIALOG_SYMBOL_LIB_TABLE_BASE::~DIALOG_SYMBOL_LIB_TABLE_BASE() +PANEL_SYM_LIB_TABLE_BASE::~PANEL_SYM_LIB_TABLE_BASE() { // Disconnect Events - m_auinotebook->Disconnect( wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGED, wxAuiNotebookEventHandler( DIALOG_SYMBOL_LIB_TABLE_BASE::pageChangedHandler ), NULL, this ); - m_append_button->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_SYMBOL_LIB_TABLE_BASE::appendRowHandler ), NULL, this ); - m_browse_button->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_SYMBOL_LIB_TABLE_BASE::browseLibrariesHandler ), NULL, this ); - m_delete_button->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_SYMBOL_LIB_TABLE_BASE::deleteRowHandler ), NULL, this ); - m_move_up_button->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_SYMBOL_LIB_TABLE_BASE::moveUpHandler ), NULL, this ); - m_move_down_button->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_SYMBOL_LIB_TABLE_BASE::moveDownHandler ), NULL, this ); - m_path_subs_grid->Disconnect( wxEVT_SIZE, wxSizeEventHandler( DIALOG_SYMBOL_LIB_TABLE_BASE::onSizeGrid ), NULL, this ); + m_auinotebook->Disconnect( wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGED, wxAuiNotebookEventHandler( PANEL_SYM_LIB_TABLE_BASE::pageChangedHandler ), NULL, this ); + m_append_button->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_SYM_LIB_TABLE_BASE::appendRowHandler ), NULL, this ); + m_browse_button->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_SYM_LIB_TABLE_BASE::browseLibrariesHandler ), NULL, this ); + m_delete_button->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_SYM_LIB_TABLE_BASE::deleteRowHandler ), NULL, this ); + m_move_up_button->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_SYM_LIB_TABLE_BASE::moveUpHandler ), NULL, this ); + m_move_down_button->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_SYM_LIB_TABLE_BASE::moveDownHandler ), NULL, this ); + m_path_subs_grid->Disconnect( wxEVT_SIZE, wxSizeEventHandler( PANEL_SYM_LIB_TABLE_BASE::onSizeGrid ), NULL, this ); } diff --git a/eeschema/dialogs/dialog_sym_lib_table_base.fbp b/eeschema/dialogs/panel_sym_lib_table_base.fbp similarity index 97% rename from eeschema/dialogs/dialog_sym_lib_table_base.fbp rename to eeschema/dialogs/panel_sym_lib_table_base.fbp index ae4785d351..ce76451685 100644 --- a/eeschema/dialogs/dialog_sym_lib_table_base.fbp +++ b/eeschema/dialogs/panel_sym_lib_table_base.fbp @@ -11,11 +11,11 @@ res UTF-8 connect - dialog_sym_lib_table_base + panel_sym_lib_table_base 1000 none 1 - MyProject1 + sym_lib_table . @@ -26,34 +26,28 @@ UI 0 0 - + 0 wxAUI_MGR_DEFAULT - wxBOTH - 0 + 1 1 - decl_pure_virtual - + impl_virtual 0 wxID_ANY - -1,-1 - DIALOG_SYMBOL_LIB_TABLE_BASE + + PANEL_SYM_LIB_TABLE_BASE - -1,-1 - wxCAPTION|wxCLOSE_BOX|wxDEFAULT_DIALOG_STYLE|wxMAXIMIZE_BOX|wxRESIZE_BORDER|wxSYSTEM_MENU - DIALOG_SHIM; dialog_shim.h - Symbol Libraries + 500,300 + ; forward_declare - - - + wxTAB_TRAVERSAL @@ -61,12 +55,8 @@ - - - - @@ -1660,43 +1650,6 @@ - - 5 - wxEXPAND - 0 - - - m_bottom_sizer - wxVERTICAL - none - - 5 - wxEXPAND - 0 - - 0 - 1 - 0 - 0 - 0 - 1 - 0 - 0 - - m_sdbSizer - protected - - - - - - - - - - - - diff --git a/eeschema/dialogs/dialog_sym_lib_table_base.h b/eeschema/dialogs/panel_sym_lib_table_base.h similarity index 57% rename from eeschema/dialogs/dialog_sym_lib_table_base.h rename to eeschema/dialogs/panel_sym_lib_table_base.h index dc028d90c3..4a35b3a0db 100644 --- a/eeschema/dialogs/dialog_sym_lib_table_base.h +++ b/eeschema/dialogs/panel_sym_lib_table_base.h @@ -5,13 +5,12 @@ // PLEASE DO *NOT* EDIT THIS FILE! /////////////////////////////////////////////////////////////////////////// -#ifndef __DIALOG_SYM_LIB_TABLE_BASE_H__ -#define __DIALOG_SYM_LIB_TABLE_BASE_H__ +#ifndef __PANEL_SYM_LIB_TABLE_BASE_H__ +#define __PANEL_SYM_LIB_TABLE_BASE_H__ #include #include #include -#include "dialog_shim.h" #include #include #include @@ -28,15 +27,14 @@ #include #include #include -#include /////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// -/// Class DIALOG_SYMBOL_LIB_TABLE_BASE +/// Class PANEL_SYM_LIB_TABLE_BASE /////////////////////////////////////////////////////////////////////////////// -class DIALOG_SYMBOL_LIB_TABLE_BASE : public DIALOG_SHIM +class PANEL_SYM_LIB_TABLE_BASE : public wxPanel { private: @@ -56,25 +54,22 @@ class DIALOG_SYMBOL_LIB_TABLE_BASE : public DIALOG_SHIM wxBitmapButton* m_move_up_button; wxBitmapButton* m_move_down_button; wxGrid* m_path_subs_grid; - wxStdDialogButtonSizer* m_sdbSizer; - wxButton* m_sdbSizerOK; - wxButton* m_sdbSizerCancel; // Virtual event handlers, overide them in your derived class - virtual void pageChangedHandler( wxAuiNotebookEvent& event ) = 0; - virtual void appendRowHandler( wxCommandEvent& event ) = 0; - virtual void browseLibrariesHandler( wxCommandEvent& event ) = 0; - virtual void deleteRowHandler( wxCommandEvent& event ) = 0; - virtual void moveUpHandler( wxCommandEvent& event ) = 0; - virtual void moveDownHandler( wxCommandEvent& event ) = 0; - virtual void onSizeGrid( wxSizeEvent& event ) = 0; + virtual void pageChangedHandler( wxAuiNotebookEvent& event ) { event.Skip(); } + virtual void appendRowHandler( wxCommandEvent& event ) { event.Skip(); } + virtual void browseLibrariesHandler( wxCommandEvent& event ) { event.Skip(); } + virtual void deleteRowHandler( wxCommandEvent& event ) { event.Skip(); } + virtual void moveUpHandler( wxCommandEvent& event ) { event.Skip(); } + virtual void moveDownHandler( wxCommandEvent& event ) { event.Skip(); } + virtual void onSizeGrid( wxSizeEvent& event ) { event.Skip(); } public: - DIALOG_SYMBOL_LIB_TABLE_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Symbol Libraries"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxCAPTION|wxCLOSE_BOX|wxDEFAULT_DIALOG_STYLE|wxMAXIMIZE_BOX|wxRESIZE_BORDER|wxSYSTEM_MENU ); - ~DIALOG_SYMBOL_LIB_TABLE_BASE(); + PANEL_SYM_LIB_TABLE_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 500,300 ), long style = wxTAB_TRAVERSAL ); + ~PANEL_SYM_LIB_TABLE_BASE(); }; -#endif //__DIALOG_SYM_LIB_TABLE_BASE_H__ +#endif //__PANEL_SYM_LIB_TABLE_BASE_H__ diff --git a/eeschema/sch_base_frame.cpp b/eeschema/sch_base_frame.cpp index 09bcb783d9..a94ae5a25e 100644 --- a/eeschema/sch_base_frame.cpp +++ b/eeschema/sch_base_frame.cpp @@ -34,7 +34,7 @@ #include #include -#include "dialogs/dialog_sym_lib_table.h" +#include "dialogs/panel_sym_lib_table.h" @@ -270,8 +270,10 @@ void SCH_BASE_FRAME::OnConfigurePaths( wxCommandEvent& aEvent ) void SCH_BASE_FRAME::OnEditSymbolLibTable( wxCommandEvent& aEvent ) { - DIALOG_SYMBOL_LIB_TABLE dlg( this, &SYMBOL_LIB_TABLE::GetGlobalLibTable(), - Prj().SchSymbolLibTable() ); + DIALOG_EDIT_LIBRARY_TABLES dlg( this, _( "Footprint Libraries" ) ); + + dlg.InstallPanel( new PANEL_SYM_LIB_TABLE( &dlg, &SYMBOL_LIB_TABLE::GetGlobalLibTable(), + Prj().SchSymbolLibTable() ) ); if( dlg.ShowModal() == wxID_CANCEL ) return; @@ -294,6 +296,15 @@ void SCH_BASE_FRAME::OnEditSymbolLibTable( wxCommandEvent& aEvent ) } +void SCH_BASE_FRAME::InstallLibraryTablesPanel( DIALOG_EDIT_LIBRARY_TABLES* aDialog ) +{ + SYMBOL_LIB_TABLE* globalTable = &SYMBOL_LIB_TABLE::GetGlobalLibTable(); + SYMBOL_LIB_TABLE* projectTable = Prj().SchSymbolLibTable(); + + aDialog->InstallPanel( new PANEL_SYM_LIB_TABLE( aDialog, globalTable, projectTable ) ); +} + + LIB_ALIAS* SCH_BASE_FRAME::GetLibAlias( const LIB_ID& aLibId, bool aUseCacheLib, bool aShowErrorMsg ) { diff --git a/eeschema/sch_base_frame.h b/eeschema/sch_base_frame.h index a6e0ea4ef2..317142f774 100644 --- a/eeschema/sch_base_frame.h +++ b/eeschema/sch_base_frame.h @@ -208,6 +208,11 @@ public: virtual void OnEditSymbolLibTable( wxCommandEvent& aEvent ); + /** + * Allows Eeschema to install the symbol library tables into the edit libraries dialog. + */ + void InstallLibraryTablesPanel( DIALOG_EDIT_LIBRARY_TABLES* aDialog ) override; + /** * Load symbol from symbol library table. * diff --git a/eeschema/symbol_lib_table.h b/eeschema/symbol_lib_table.h index 072c510c2a..e780d77eca 100644 --- a/eeschema/symbol_lib_table.h +++ b/eeschema/symbol_lib_table.h @@ -102,7 +102,7 @@ private: class SYMBOL_LIB_TABLE : public LIB_TABLE { friend class SYMBOL_LIB_TABLE_GRID; - friend class DIALOG_SYMBOL_LIB_TABLE; + friend class PANEL_SYM_LIB_TABLE; static int m_modifyHash; ///< helper for GetModifyHash() diff --git a/include/dialog_configure_paths.h b/include/dialog_configure_paths.h index 92b3c23838..311cf5da11 100644 --- a/include/dialog_configure_paths.h +++ b/include/dialog_configure_paths.h @@ -47,6 +47,7 @@ public: protected: // Various button callbacks void OnGridCellRightClick( wxGridEvent& event ) override; + void OnGridCellChange( wxGridEvent& event ) override; void OnGridSize( wxSizeEvent& event ) override; void OnUpdateUI( wxUpdateUIEvent& event ) override; void OnGridCellChanging( wxGridEvent& event ); @@ -60,7 +61,6 @@ protected: void AppendEnvVar( const wxString& aName, const wxString& aPath, bool isExternal ); void AppendSearchPath( const wxString& aName, const wxString& aPath, const wxString& aDesc ); - void AdjustGridColumns( int aWidth ); /** * Determine if a particular ENV_VAR is protected @@ -77,6 +77,7 @@ private: wxString m_curdir; wxTextValidator m_aliasValidator; + bool m_gridWidthsDirty; }; #endif // _DIALOG_CONFIGURE_PATHS_H_ diff --git a/pcbnew/CMakeLists.txt b/pcbnew/CMakeLists.txt index 3fd957c18f..0c7e1e7f63 100644 --- a/pcbnew/CMakeLists.txt +++ b/pcbnew/CMakeLists.txt @@ -82,8 +82,6 @@ set( PCBNEW_DIALOGS dialogs/dialog_find_base.cpp dialogs/dialog_footprint_wizard_list.cpp dialogs/dialog_footprint_wizard_list_base.cpp - dialogs/dialog_fp_lib_table.cpp - dialogs/dialog_fp_lib_table_base.cpp dialogs/dialog_fp_plugin_options.cpp dialogs/dialog_fp_plugin_options_base.cpp dialogs/dialog_gen_footprint_position_file_base.cpp @@ -148,6 +146,8 @@ set( PCBNEW_DIALOGS dialogs/dialog_track_via_size_base.cpp dialogs/dialog_update_pcb.cpp dialogs/dialog_update_pcb_base.cpp + dialogs/panel_fp_lib_table.cpp + dialogs/panel_fp_lib_table_base.cpp dialogs/panel_modedit_defaults.cpp dialogs/panel_modedit_defaults_base.cpp dialogs/panel_modedit_display_options.cpp diff --git a/pcbnew/dialogs/dialog_fp_plugin_options.cpp b/pcbnew/dialogs/dialog_fp_plugin_options.cpp index 72d0b27c26..41f6601efe 100644 --- a/pcbnew/dialogs/dialog_fp_plugin_options.cpp +++ b/pcbnew/dialogs/dialog_fp_plugin_options.cpp @@ -55,7 +55,8 @@ public: DIALOG_FP_PLUGIN_OPTIONS_BASE( aParent ), m_callers_options( aOptions ), m_result( aResult ), - m_initial_help( INITIAL_HELP ) + m_initial_help( INITIAL_HELP ), + m_grid_widths_dirty( true ) { SetTitle( wxString::Format( _( "Options for Library \"%s\"" ), aNickname ) ); @@ -123,8 +124,6 @@ public: delete props; } - adjustGridColumns( m_grid->GetRect().GetWidth() ); - return true; } @@ -159,6 +158,7 @@ private: wxString* m_result; PROPERTIES m_choices; wxString m_initial_help; + bool m_grid_widths_dirty; int appendRow() { @@ -195,6 +195,7 @@ private: row = appendRow(); m_grid->SetCellValue( row, 0, option ); + m_grid_widths_dirty = true; } } @@ -241,37 +242,40 @@ private: int curRow = m_grid->GetGridCursorRow(); m_grid->DeleteRows( curRow ); + m_grid_widths_dirty = true; curRow = std::max( 0, curRow - 1 ); m_grid->MakeCellVisible( curRow, m_grid->GetGridCursorCol() ); m_grid->SetGridCursor( curRow, m_grid->GetGridCursorCol() ); } - void onUpdateUI( wxUpdateUIEvent& ) override + void onGridCellChange( wxGridEvent& aEvent ) override { - if( !m_grid->IsCellEditControlShown() ) - adjustGridColumns( m_grid->GetRect().GetWidth() ); - } - - void onSize( wxSizeEvent& aEvent ) override - { - adjustGridColumns( aEvent.GetSize().GetX() ); + m_grid_widths_dirty = true; aEvent.Skip(); } - //---------------------------------------------------------- - - void adjustGridColumns( int aWidth ) + void onUpdateUI( wxUpdateUIEvent& ) override { - m_grid->Freeze(); + if( m_grid_widths_dirty && !m_grid->IsCellEditControlShown() ) + { + int width = m_grid->GetClientRect().GetWidth(); - m_grid->AutoSizeColumn( 0 ); - m_grid->SetColSize( 0, std::max( 120, m_grid->GetColSize( 0 ) ) ); + m_grid->AutoSizeColumn( 0 ); + m_grid->SetColSize( 0, std::max( 120, m_grid->GetColSize( 0 ) ) ); - m_grid->SetColSize( 1, aWidth - m_grid->GetColSize( 0 ) ); + m_grid->SetColSize( 1, width - m_grid->GetColSize( 0 ) ); - m_grid->Thaw(); + m_grid_widths_dirty = false; + } + } + + void onSize( wxSizeEvent& aEvent ) override + { + m_grid_widths_dirty = true; + + aEvent.Skip(); } }; diff --git a/pcbnew/dialogs/dialog_fp_plugin_options_base.cpp b/pcbnew/dialogs/dialog_fp_plugin_options_base.cpp index 4bcfae14f4..113db0d17e 100644 --- a/pcbnew/dialogs/dialog_fp_plugin_options_base.cpp +++ b/pcbnew/dialogs/dialog_fp_plugin_options_base.cpp @@ -110,6 +110,7 @@ DIALOG_FP_PLUGIN_OPTIONS_BASE::DIALOG_FP_PLUGIN_OPTIONS_BASE( wxWindow* parent, this->Centre( wxBOTH ); // Connect Events + m_grid->Connect( wxEVT_GRID_CELL_CHANGED, wxGridEventHandler( DIALOG_FP_PLUGIN_OPTIONS_BASE::onGridCellChange ), NULL, this ); m_grid->Connect( wxEVT_SIZE, wxSizeEventHandler( DIALOG_FP_PLUGIN_OPTIONS_BASE::onSize ), NULL, this ); m_grid->Connect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( DIALOG_FP_PLUGIN_OPTIONS_BASE::onUpdateUI ), NULL, this ); m_append_button->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FP_PLUGIN_OPTIONS_BASE::onAppendRow ), NULL, this ); @@ -122,6 +123,7 @@ DIALOG_FP_PLUGIN_OPTIONS_BASE::DIALOG_FP_PLUGIN_OPTIONS_BASE( wxWindow* parent, DIALOG_FP_PLUGIN_OPTIONS_BASE::~DIALOG_FP_PLUGIN_OPTIONS_BASE() { // Disconnect Events + m_grid->Disconnect( wxEVT_GRID_CELL_CHANGED, wxGridEventHandler( DIALOG_FP_PLUGIN_OPTIONS_BASE::onGridCellChange ), NULL, this ); m_grid->Disconnect( wxEVT_SIZE, wxSizeEventHandler( DIALOG_FP_PLUGIN_OPTIONS_BASE::onSize ), NULL, this ); m_grid->Disconnect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( DIALOG_FP_PLUGIN_OPTIONS_BASE::onUpdateUI ), NULL, this ); m_append_button->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FP_PLUGIN_OPTIONS_BASE::onAppendRow ), NULL, this ); diff --git a/pcbnew/dialogs/dialog_fp_plugin_options_base.fbp b/pcbnew/dialogs/dialog_fp_plugin_options_base.fbp index d334f066b3..a0ee45dd64 100644 --- a/pcbnew/dialogs/dialog_fp_plugin_options_base.fbp +++ b/pcbnew/dialogs/dialog_fp_plugin_options_base.fbp @@ -204,7 +204,7 @@ - + onGridCellChange diff --git a/pcbnew/dialogs/dialog_fp_plugin_options_base.h b/pcbnew/dialogs/dialog_fp_plugin_options_base.h index 4002dca0b5..58a8c7b5eb 100644 --- a/pcbnew/dialogs/dialog_fp_plugin_options_base.h +++ b/pcbnew/dialogs/dialog_fp_plugin_options_base.h @@ -51,6 +51,7 @@ class DIALOG_FP_PLUGIN_OPTIONS_BASE : public DIALOG_SHIM wxButton* m_sdbSizer1Cancel; // Virtual event handlers, overide them in your derived class + virtual void onGridCellChange( wxGridEvent& event ) = 0; virtual void onSize( wxSizeEvent& event ) = 0; virtual void onUpdateUI( wxUpdateUIEvent& event ) = 0; virtual void onAppendRow( wxCommandEvent& event ) = 0; diff --git a/pcbnew/dialogs/dialog_fp_lib_table.cpp b/pcbnew/dialogs/panel_fp_lib_table.cpp similarity index 97% rename from pcbnew/dialogs/dialog_fp_lib_table.cpp rename to pcbnew/dialogs/panel_fp_lib_table.cpp index 9abb0598fa..3604dbb98a 100644 --- a/pcbnew/dialogs/dialog_fp_lib_table.cpp +++ b/pcbnew/dialogs/panel_fp_lib_table.cpp @@ -38,7 +38,7 @@ #include #include #include <3d_viewer.h> // for KISYS3DMOD -#include +#include #include #include #include @@ -150,22 +150,26 @@ public: class FP_GRID_TRICKS : public GRID_TRICKS { public: - FP_GRID_TRICKS( wxGrid* aGrid ) : GRID_TRICKS( aGrid ) - { - } + FP_GRID_TRICKS( DIALOG_EDIT_LIBRARY_TABLES* aParent, wxGrid* aGrid ) : + GRID_TRICKS( aGrid ), + m_dialog( aParent ) + { } protected: + DIALOG_EDIT_LIBRARY_TABLES* m_dialog; + void optionsEditor( int aRow ) { FP_LIB_TABLE_GRID* tbl = (FP_LIB_TABLE_GRID*) m_grid->GetTable(); + if( tbl->GetNumberRows() > aRow ) { LIB_TABLE_ROW* row = tbl->at( (size_t) aRow ); const wxString& options = row->GetOptions(); wxString result = options; - InvokePluginOptionsEditor( wxGetTopLevelParent( m_grid ), row->GetNickName(), - row->GetType(), options, &result ); + InvokePluginOptionsEditor( m_dialog, row->GetNickName(), row->GetType(), options, + &result ); if( options != result ) { @@ -228,7 +232,7 @@ protected: } catch( PARSE_ERROR& pe ) { - DisplayError( NULL, pe.What() ); + DisplayError( m_dialog, pe.What() ); parsed = false; } @@ -255,7 +259,8 @@ protected: }; -PANEL_FP_LIB_TABLE::PANEL_FP_LIB_TABLE( DIALOG_EDIT_LIBRARY_TABLES* aParent, FP_LIB_TABLE* aGlobal, +PANEL_FP_LIB_TABLE::PANEL_FP_LIB_TABLE( DIALOG_EDIT_LIBRARY_TABLES* aParent, + FP_LIB_TABLE* aGlobal, FP_LIB_TABLE* aProject ) : PANEL_FP_LIB_TABLE_BASE( aParent ), m_global( aGlobal ), @@ -276,8 +281,8 @@ PANEL_FP_LIB_TABLE::PANEL_FP_LIB_TABLE( DIALOG_EDIT_LIBRARY_TABLES* aParent, FP_ m_project_grid->SetDefaultRowSize( m_project_grid->GetDefaultRowSize() + 4 ); // add Cut, Copy, and Paste to wxGrids - m_global_grid->PushEventHandler( new FP_GRID_TRICKS( m_global_grid ) ); - m_project_grid->PushEventHandler( new FP_GRID_TRICKS( m_project_grid ) ); + m_global_grid->PushEventHandler( new FP_GRID_TRICKS( m_parent, m_global_grid ) ); + m_project_grid->PushEventHandler( new FP_GRID_TRICKS( m_parent, m_project_grid ) ); m_global_grid->AutoSizeColumns( false ); m_project_grid->AutoSizeColumns( false ); @@ -393,7 +398,7 @@ bool PANEL_FP_LIB_TABLE::verifyTables() { wxString msg = wxString::Format( _( "Illegal character '%c' in Nickname: \"%s\"" ), illegalCh, - GetChars( nick ) ); + nick ); // show the tabbed panel holding the grid we have flunked: if( &model != cur_model() ) diff --git a/pcbnew/dialogs/dialog_fp_lib_table.h b/pcbnew/dialogs/panel_fp_lib_table.h similarity index 98% rename from pcbnew/dialogs/dialog_fp_lib_table.h rename to pcbnew/dialogs/panel_fp_lib_table.h index 6f1d6e7272..786b46f342 100644 --- a/pcbnew/dialogs/dialog_fp_lib_table.h +++ b/pcbnew/dialogs/panel_fp_lib_table.h @@ -21,7 +21,7 @@ #define PANEL_FP_LIB_TABLE_H #include -#include "dialog_fp_lib_table_base.h" +#include class FP_LIB_TABLE; class FP_LIB_TABLE_GRID; diff --git a/pcbnew/dialogs/dialog_fp_lib_table_base.cpp b/pcbnew/dialogs/panel_fp_lib_table_base.cpp similarity index 99% rename from pcbnew/dialogs/dialog_fp_lib_table_base.cpp rename to pcbnew/dialogs/panel_fp_lib_table_base.cpp index d18383bd71..a9886c32ff 100644 --- a/pcbnew/dialogs/dialog_fp_lib_table_base.cpp +++ b/pcbnew/dialogs/panel_fp_lib_table_base.cpp @@ -5,7 +5,7 @@ // PLEASE DO *NOT* EDIT THIS FILE! /////////////////////////////////////////////////////////////////////////// -#include "dialog_fp_lib_table_base.h" +#include "panel_fp_lib_table_base.h" /////////////////////////////////////////////////////////////////////////// diff --git a/pcbnew/dialogs/dialog_fp_lib_table_base.fbp b/pcbnew/dialogs/panel_fp_lib_table_base.fbp similarity index 99% rename from pcbnew/dialogs/dialog_fp_lib_table_base.fbp rename to pcbnew/dialogs/panel_fp_lib_table_base.fbp index 574ddf5882..a355b984c3 100644 --- a/pcbnew/dialogs/dialog_fp_lib_table_base.fbp +++ b/pcbnew/dialogs/panel_fp_lib_table_base.fbp @@ -11,11 +11,11 @@ res UTF-8 connect - dialog_fp_lib_table_base + panel_fp_lib_table_base 1000 none 1 - MyProject1 + panel_fp_lib_table . diff --git a/pcbnew/dialogs/dialog_fp_lib_table_base.h b/pcbnew/dialogs/panel_fp_lib_table_base.h similarity index 95% rename from pcbnew/dialogs/dialog_fp_lib_table_base.h rename to pcbnew/dialogs/panel_fp_lib_table_base.h index 6e27c454cd..ce48ee96e3 100644 --- a/pcbnew/dialogs/dialog_fp_lib_table_base.h +++ b/pcbnew/dialogs/panel_fp_lib_table_base.h @@ -5,8 +5,8 @@ // PLEASE DO *NOT* EDIT THIS FILE! /////////////////////////////////////////////////////////////////////////// -#ifndef __DIALOG_FP_LIB_TABLE_BASE_H__ -#define __DIALOG_FP_LIB_TABLE_BASE_H__ +#ifndef __PANEL_FP_LIB_TABLE_BASE_H__ +#define __PANEL_FP_LIB_TABLE_BASE_H__ #include #include @@ -72,4 +72,4 @@ class PANEL_FP_LIB_TABLE_BASE : public wxPanel }; -#endif //__DIALOG_FP_LIB_TABLE_BASE_H__ +#endif //__PANEL_FP_LIB_TABLE_BASE_H__