Finish project frame library table editing.

Fixes: lp:1782761
* https://bugs.launchpad.net/kicad/+bug/1782761
This commit is contained in:
Jeff Young 2018-07-20 18:46:56 +01:00
parent bd90341e91
commit c1df78d531
26 changed files with 290 additions and 325 deletions

View File

@ -76,8 +76,6 @@ DIALOG_SHIM::DIALOG_SHIM( wxWindow* aParent, wxWindowID id, const wxString& titl
aParent = aParent->GetParent();
kiwayHolder = dynamic_cast<KIWAY_HOLDER*>( aParent );
}
wxASSERT_MSG( kiwayHolder, "Dialog parent is not a KIWAY_HOLDER" );
}
if( kiwayHolder )

View File

@ -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();
}

View File

@ -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 );

View File

@ -195,7 +195,7 @@
<event name="OnChar"></event>
<event name="OnEnterWindow"></event>
<event name="OnEraseBackground"></event>
<event name="OnGridCellChange"></event>
<event name="OnGridCellChange">OnGridCellChange</event>
<event name="OnGridCellLeftClick"></event>
<event name="OnGridCellLeftDClick"></event>
<event name="OnGridCellRightClick"></event>
@ -550,7 +550,7 @@
<event name="OnChar"></event>
<event name="OnEnterWindow"></event>
<event name="OnEraseBackground"></event>
<event name="OnGridCellChange"></event>
<event name="OnGridCellChange">OnGridCellChange</event>
<event name="OnGridCellLeftClick"></event>
<event name="OnGridCellLeftDClick"></event>
<event name="OnGridCellRightClick">OnGridCellRightClick</event>

View File

@ -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(); }

View File

@ -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

View File

@ -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

View File

@ -23,7 +23,7 @@
#include <fctsys.h>
#include <project.h>
#include <dialog_sym_lib_table.h>
#include <panel_sym_lib_table.h>
#include <lib_id.h>
#include <symbol_lib_table.h>
#include <lib_table_lexer.h>
@ -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;

View File

@ -1,82 +1,84 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2017 Wayne Stambaugh <stambaughw@gmail.com>
* 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 <http://www.gnu.org/licenses/>.
*/
#ifndef _DIALOG_SYM_LIB_TABLE_H_
#define _DIALOG_SYM_LIB_TABLE_H_
#include <dialog_sym_lib_table_base.h>
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 <stambaughw@gmail.com>
* 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 <http://www.gnu.org/licenses/>.
*/
#ifndef PANEL_SYM_LIB_TABLE_H
#define PANEL_SYM_LIB_TABLE_H
#include <dialog_edit_library_tables.h>
#include <panel_sym_lib_table_base.h>
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

View File

@ -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 );
}

View File

@ -11,11 +11,11 @@
<property name="embedded_files_path">res</property>
<property name="encoding">UTF-8</property>
<property name="event_generation">connect</property>
<property name="file">dialog_sym_lib_table_base</property>
<property name="file">panel_sym_lib_table_base</property>
<property name="first_id">1000</property>
<property name="help_provider">none</property>
<property name="internationalize">1</property>
<property name="name">MyProject1</property>
<property name="name">sym_lib_table</property>
<property name="namespace"></property>
<property name="path">.</property>
<property name="precompiled_header"></property>
@ -26,34 +26,28 @@
<property name="ui_table">UI</property>
<property name="use_enum">0</property>
<property name="use_microsoft_bom">0</property>
<object class="Dialog" expanded="1">
<object class="Panel" expanded="1">
<property name="aui_managed">0</property>
<property name="aui_manager_style">wxAUI_MGR_DEFAULT</property>
<property name="bg"></property>
<property name="center">wxBOTH</property>
<property name="context_help"></property>
<property name="context_menu">0</property>
<property name="context_menu">1</property>
<property name="enabled">1</property>
<property name="event_handler">decl_pure_virtual</property>
<property name="extra_style"></property>
<property name="event_handler">impl_virtual</property>
<property name="fg"></property>
<property name="font"></property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="maximum_size"></property>
<property name="minimum_size">-1,-1</property>
<property name="name">DIALOG_SYMBOL_LIB_TABLE_BASE</property>
<property name="minimum_size"></property>
<property name="name">PANEL_SYM_LIB_TABLE_BASE</property>
<property name="pos"></property>
<property name="size">-1,-1</property>
<property name="style">wxCAPTION|wxCLOSE_BOX|wxDEFAULT_DIALOG_STYLE|wxMAXIMIZE_BOX|wxRESIZE_BORDER|wxSYSTEM_MENU</property>
<property name="subclass">DIALOG_SHIM; dialog_shim.h</property>
<property name="title">Symbol Libraries</property>
<property name="size">500,300</property>
<property name="subclass">; forward_declare</property>
<property name="tooltip"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnActivate"></event>
<event name="OnActivateApp"></event>
<property name="window_style">wxTAB_TRAVERSAL</property>
<event name="OnAuiFindManager"></event>
<event name="OnAuiPaneButton"></event>
<event name="OnAuiPaneClose"></event>
@ -61,12 +55,8 @@
<event name="OnAuiPaneRestore"></event>
<event name="OnAuiRender"></event>
<event name="OnChar"></event>
<event name="OnClose"></event>
<event name="OnEnterWindow"></event>
<event name="OnEraseBackground"></event>
<event name="OnHibernate"></event>
<event name="OnIconize"></event>
<event name="OnIdle"></event>
<event name="OnInitDialog"></event>
<event name="OnKeyDown"></event>
<event name="OnKeyUp"></event>
@ -1660,43 +1650,6 @@
</object>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxEXPAND</property>
<property name="proportion">0</property>
<object class="wxBoxSizer" expanded="1">
<property name="minimum_size"></property>
<property name="name">m_bottom_sizer</property>
<property name="orient">wxVERTICAL</property>
<property name="permission">none</property>
<object class="sizeritem" expanded="0">
<property name="border">5</property>
<property name="flag">wxEXPAND</property>
<property name="proportion">0</property>
<object class="wxStdDialogButtonSizer" expanded="0">
<property name="Apply">0</property>
<property name="Cancel">1</property>
<property name="ContextHelp">0</property>
<property name="Help">0</property>
<property name="No">0</property>
<property name="OK">1</property>
<property name="Save">0</property>
<property name="Yes">0</property>
<property name="minimum_size"></property>
<property name="name">m_sdbSizer</property>
<property name="permission">protected</property>
<event name="OnApplyButtonClick"></event>
<event name="OnCancelButtonClick"></event>
<event name="OnContextHelpButtonClick"></event>
<event name="OnHelpButtonClick"></event>
<event name="OnNoButtonClick"></event>
<event name="OnOKButtonClick"></event>
<event name="OnSaveButtonClick"></event>
<event name="OnYesButtonClick"></event>
</object>
</object>
</object>
</object>
</object>
</object>
</object>

View File

@ -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 <wx/artprov.h>
#include <wx/xrc/xmlres.h>
#include <wx/intl.h>
#include "dialog_shim.h"
#include <wx/string.h>
#include <wx/stattext.h>
#include <wx/gdicmn.h>
@ -28,15 +27,14 @@
#include <wx/bmpbuttn.h>
#include <wx/button.h>
#include <wx/statbox.h>
#include <wx/dialog.h>
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
/// 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__

View File

@ -34,7 +34,7 @@
#include <symbol_lib_table.h>
#include <dialog_configure_paths.h>
#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 )
{

View File

@ -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.
*

View File

@ -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()

View File

@ -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_

View File

@ -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

View File

@ -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();
}
//-----</event handlers>-----------------------------------------------------
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();
}
};

View File

@ -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 );

View File

@ -204,7 +204,7 @@
<event name="OnChar"></event>
<event name="OnEnterWindow"></event>
<event name="OnEraseBackground"></event>
<event name="OnGridCellChange"></event>
<event name="OnGridCellChange">onGridCellChange</event>
<event name="OnGridCellLeftClick"></event>
<event name="OnGridCellLeftDClick"></event>
<event name="OnGridCellRightClick"></event>

View File

@ -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;

View File

@ -38,7 +38,7 @@
#include <fctsys.h>
#include <project.h>
#include <3d_viewer.h> // for KISYS3DMOD
#include <dialog_fp_lib_table.h>
#include <panel_fp_lib_table.h>
#include <lib_id.h>
#include <fp_lib_table.h>
#include <lib_table_lexer.h>
@ -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() )

View File

@ -21,7 +21,7 @@
#define PANEL_FP_LIB_TABLE_H
#include <dialog_edit_library_tables.h>
#include "dialog_fp_lib_table_base.h"
#include <panel_fp_lib_table_base.h>
class FP_LIB_TABLE;
class FP_LIB_TABLE_GRID;

View File

@ -5,7 +5,7 @@
// PLEASE DO *NOT* EDIT THIS FILE!
///////////////////////////////////////////////////////////////////////////
#include "dialog_fp_lib_table_base.h"
#include "panel_fp_lib_table_base.h"
///////////////////////////////////////////////////////////////////////////

View File

@ -11,11 +11,11 @@
<property name="embedded_files_path">res</property>
<property name="encoding">UTF-8</property>
<property name="event_generation">connect</property>
<property name="file">dialog_fp_lib_table_base</property>
<property name="file">panel_fp_lib_table_base</property>
<property name="first_id">1000</property>
<property name="help_provider">none</property>
<property name="internationalize">1</property>
<property name="name">MyProject1</property>
<property name="name">panel_fp_lib_table</property>
<property name="namespace"></property>
<property name="path">.</property>
<property name="precompiled_header"></property>

View File

@ -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 <wx/artprov.h>
#include <wx/xrc/xmlres.h>
@ -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__