Cvpcb: fix issues relatives to .equ files management:

* Add dialog to edit the list of active equ files.
* allows use of our environment variables in .equ file names.
This commit is contained in:
jean-pierre charras 2015-01-11 18:22:45 +01:00
parent 0cb7c3dc7d
commit 972329527e
22 changed files with 1673 additions and 2853 deletions

View File

@ -490,6 +490,7 @@ void PARAM_CFG_LIBNAME_LIST::ReadParam( wxConfigBase* aConfig ) const
id_lib << indexlib; id_lib << indexlib;
indexlib++; indexlib++;
libname = aConfig->Read( id_lib, wxT( "" ) ); libname = aConfig->Read( id_lib, wxT( "" ) );
if( libname.IsEmpty() ) if( libname.IsEmpty() )
break; break;
// file names are stored using Unix notation // file names are stored using Unix notation

View File

@ -331,8 +331,14 @@ bool PROJECT::ConfigLoad( const SEARCH_STACK& aSList, const wxString& aGroupNam
m_pro_date_and_time = timestamp; m_pro_date_and_time = timestamp;
// We do not want expansion of env var values when reading our project config file
bool state = cfg.get()->IsExpandingEnvVars();
cfg.get()->SetExpandEnvVars( false );
wxConfigLoadParams( cfg.get(), aParams, aGroupName ); wxConfigLoadParams( cfg.get(), aParams, aGroupName );
cfg.get()->SetExpandEnvVars( state );
return true; return true;
} }

View File

@ -31,6 +31,8 @@ set( CVPCB_DIALOGS
dialogs/fp_conflict_assignment_selector.cpp dialogs/fp_conflict_assignment_selector.cpp
dialogs/dialog_display_options.cpp dialogs/dialog_display_options.cpp
dialogs/dialog_display_options_base.cpp 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.cpp
../pcbnew/dialogs/dialog_fp_lib_table_base.cpp ../pcbnew/dialogs/dialog_fp_lib_table_base.cpp
../pcbnew/dialogs/dialog_fp_plugin_options.cpp ../pcbnew/dialogs/dialog_fp_plugin_options.cpp

View File

@ -1,7 +1,7 @@
/* /*
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 1992-2012 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 1992-2015 KiCad Developers, see AUTHORS.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -31,7 +31,6 @@
#include <common.h> #include <common.h>
#include <kiface_i.h> #include <kiface_i.h>
#include <project.h> #include <project.h>
#include <confirm.h>
#include <gestfich.h> #include <gestfich.h>
#include <pgm_base.h> #include <pgm_base.h>
#include <kicad_string.h> #include <kicad_string.h>
@ -99,25 +98,18 @@ void CVPCB_MAINFRAME::AssocieModule( wxCommandEvent& event )
return; return;
// Find equivalents in all available files. // Find equivalents in all available files.
for( ii = 0; ii < m_AliasLibNames.GetCount(); ii++ ) for( ii = 0; ii < m_EquFilesNames.GetCount(); ii++ )
{ {
fn = m_AliasLibNames[ii]; if( m_EquFilesNames[ii].StartsWith( wxT("${") ) )
fn = wxExpandEnvVars( m_EquFilesNames[ii] );
if( !fn.HasExt() )
{
fn.SetExt( FootprintAliasFileExtension );
// above fails if filename has more than one point
}
else else
{ fn = m_EquFilesNames[ii];
fn.SetExt( fn.GetExt() + wxT( "." ) + FootprintAliasFileExtension );
}
tmp = search.FindValidPath( fn.GetFullPath() ); tmp = search.FindValidPath( fn.GetFullPath() );
if( !tmp ) if( !tmp )
{ {
msg.Printf( _( "Footprint alias library file '%s' could not be found in the " msg.Printf( _( "Footprint equ file '%s' could not be found in the "
"default search paths." ), "default search paths." ),
GetChars( fn.GetFullName() ) ); GetChars( fn.GetFullName() ) );
wxMessageBox( msg, FMT_TITLE_LIB_LOAD_ERROR, wxOK | wxICON_ERROR ); wxMessageBox( msg, FMT_TITLE_LIB_LOAD_ERROR, wxOK | wxICON_ERROR );
@ -128,7 +120,7 @@ void CVPCB_MAINFRAME::AssocieModule( wxCommandEvent& event )
if( file == NULL ) if( file == NULL )
{ {
msg.Printf( _( "Error opening alias library '%s'." ), GetChars( tmp ) ); msg.Printf( _( "Error opening equ file '%s'." ), GetChars( tmp ) );
wxMessageBox( msg, FMT_TITLE_LIB_LOAD_ERROR, wxOK | wxICON_ERROR ); wxMessageBox( msg, FMT_TITLE_LIB_LOAD_ERROR, wxOK | wxICON_ERROR );
continue; continue;
} }
@ -160,7 +152,7 @@ void CVPCB_MAINFRAME::AssocieModule( wxCommandEvent& event )
} }
// Display the number of footprint aliases. // Display the number of footprint aliases.
msg.Printf( _( "%d footprint aliases found." ), aliases.size() ); msg.Printf( _( "%d footprint/cmp equivalences found." ), aliases.size() );
SetStatusText( msg, 0 ); SetStatusText( msg, 0 );
m_skipComponentSelect = true; m_skipComponentSelect = true;

View File

@ -1,7 +1,7 @@
/* /*
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 2007 Jean-Pierre Charras, jean-pierre.charras * Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
@ -50,7 +50,7 @@ PARAM_CFG_ARRAY& CVPCB_MAINFRAME::GetProjectFileParameters()
m_projectFileParams.push_back( new PARAM_CFG_BASE( GROUP_PCB_LIBS, PARAM_COMMAND_ERASE ) ); m_projectFileParams.push_back( new PARAM_CFG_BASE( GROUP_PCB_LIBS, PARAM_COMMAND_ERASE ) );
m_projectFileParams.push_back( new PARAM_CFG_LIBNAME_LIST( m_projectFileParams.push_back( new PARAM_CFG_LIBNAME_LIST(
wxT( "EquName" ), &m_AliasLibNames, GROUP_CVP_EQU ) ); wxT( "EquName" ), &m_EquFilesNames, GROUP_CVP_EQU ) );
m_projectFileParams.push_back( new PARAM_CFG_WXSTRING( m_projectFileParams.push_back( new PARAM_CFG_WXSTRING(
wxT( "NetIExt" ), &m_NetlistFileExtension ) ); wxT( "NetIExt" ), &m_NetlistFileExtension ) );
@ -64,9 +64,8 @@ void CVPCB_MAINFRAME::LoadProjectFile()
PROJECT& prj = Prj(); PROJECT& prj = Prj();
m_ModuleLibNames.Clear(); m_ModuleLibNames.Clear();
m_AliasLibNames.Clear(); m_EquFilesNames.Clear();
// was: Pgm().ReadProjectConfig( fn.GetFullPath(), GROUP, GetProjectFileParameters(), false );
prj.ConfigLoad( Kiface().KifaceSearch(), GROUP_CVP, GetProjectFileParameters() ); prj.ConfigLoad( Kiface().KifaceSearch(), GROUP_CVP, GetProjectFileParameters() );
if( m_NetlistFileExtension.IsEmpty() ) if( m_NetlistFileExtension.IsEmpty() )
@ -77,26 +76,14 @@ void CVPCB_MAINFRAME::LoadProjectFile()
void CVPCB_MAINFRAME::SaveProjectFile( wxCommandEvent& aEvent ) void CVPCB_MAINFRAME::SaveProjectFile( wxCommandEvent& aEvent )
{ {
PROJECT& prj = Prj(); PROJECT& prj = Prj();
wxFileName fn = prj.AbsolutePath( m_NetlistFileName.GetFullPath() ); SetTitle( wxString::Format( _( "Project file: '%s'" ), GetChars( prj.GetProjectFullName() ) ) );
wxFileName fn = prj.GetProjectFullName();
fn.SetExt( ProjectFileExtension );
if( aEvent.GetId() == ID_SAVE_PROJECT_AS || !m_NetlistFileName.IsOk() )
{
wxFileDialog dlg( this, _( "Save Project File" ), fn.GetPath(),
wxEmptyString, ProjectFileWildcard, wxFD_SAVE );
if( dlg.ShowModal() == wxID_CANCEL )
return;
fn = dlg.GetPath();
if( !fn.HasExt() )
fn.SetExt( ProjectFileExtension );
}
if( !IsWritable( fn ) ) if( !IsWritable( fn ) )
{
wxMessageBox( _( "Project file '%s' is not writable" ), fn.GetFullPath() );
return; return;
}
wxString pro_name = fn.GetFullPath(); wxString pro_name = fn.GetFullPath();

View File

@ -1,7 +1,7 @@
/* /*
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 2009 Jean-Pierre Charras, jean-pierre.charras * Copyright (C) 2015 Jean-Pierre Charras, jean-pierre.charras
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net> * Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
* *
@ -69,8 +69,8 @@ BEGIN_EVENT_TABLE( CVPCB_MAINFRAME, EDA_BASE_FRAME )
EVT_MENU( wxID_HELP, CVPCB_MAINFRAME::GetKicadHelp ) EVT_MENU( wxID_HELP, CVPCB_MAINFRAME::GetKicadHelp )
EVT_MENU( wxID_ABOUT, CVPCB_MAINFRAME::GetKicadAbout ) EVT_MENU( wxID_ABOUT, CVPCB_MAINFRAME::GetKicadAbout )
EVT_MENU( ID_SAVE_PROJECT, CVPCB_MAINFRAME::SaveProjectFile ) EVT_MENU( ID_SAVE_PROJECT, CVPCB_MAINFRAME::SaveProjectFile )
EVT_MENU( ID_SAVE_PROJECT_AS, CVPCB_MAINFRAME::SaveProjectFile )
EVT_MENU( ID_CVPCB_CONFIG_KEEP_OPEN_ON_SAVE, CVPCB_MAINFRAME::OnKeepOpenOnSave ) EVT_MENU( ID_CVPCB_CONFIG_KEEP_OPEN_ON_SAVE, CVPCB_MAINFRAME::OnKeepOpenOnSave )
EVT_MENU( ID_CVPCB_EQUFILES_LIST_EDIT, CVPCB_MAINFRAME::OnEditEquFilesList )
// Toolbar events // Toolbar events
EVT_TOOL( ID_CVPCB_QUIT, CVPCB_MAINFRAME::OnQuit ) EVT_TOOL( ID_CVPCB_QUIT, CVPCB_MAINFRAME::OnQuit )
@ -160,6 +160,7 @@ CVPCB_MAINFRAME::CVPCB_MAINFRAME( KIWAY* aKiway, wxWindow* aParent ) :
m_auimgr.SetManagedWindow( this ); m_auimgr.SetManagedWindow( this );
UpdateTitle();
EDA_PANEINFO horiz; EDA_PANEINFO horiz;
horiz.HorizontalToolbarPane(); horiz.HorizontalToolbarPane();
@ -369,10 +370,12 @@ void CVPCB_MAINFRAME::ToPreviousNA( wxCommandEvent& event )
void CVPCB_MAINFRAME::SaveQuitCvpcb( wxCommandEvent& aEvent ) void CVPCB_MAINFRAME::SaveQuitCvpcb( wxCommandEvent& aEvent )
{ {
if( aEvent.GetId() == wxID_SAVEAS ) wxString fullFilename;
m_NetlistFileName.Clear();
if( SaveCmpLinkFile( m_NetlistFileName.GetFullPath() ) > 0 ) if( aEvent.GetId() != wxID_SAVEAS )
fullFilename = m_NetlistFileName.GetFullPath();
if( SaveCmpLinkFile( fullFilename ) > 0 )
{ {
m_modified = false; m_modified = false;
@ -744,18 +747,21 @@ bool CVPCB_MAINFRAME::LoadFootprintFiles()
void CVPCB_MAINFRAME::UpdateTitle() void CVPCB_MAINFRAME::UpdateTitle()
{ {
wxString title = wxString::Format( wxT( "Cvpcb %s " ), GetChars( GetBuildVersion() ) ); wxString title = wxString::Format( wxT( "Cvpcb %s " ), GetChars( GetBuildVersion() ) );
PROJECT& prj = Prj();
wxFileName fn = prj.GetProjectFullName();
if( m_NetlistFileName.IsOk() && m_NetlistFileName.FileExists() ) if( fn.IsOk() && fn.FileExists() )
{ {
title += m_NetlistFileName.GetFullPath(); title += wxString::Format( _("Project: '%s' (netlist: '%s')"),
GetChars( fn.GetFullPath() ),
GetChars( m_NetlistFileName.GetFullName() )
);
if( !m_NetlistFileName.IsFileWritable() ) if( !fn.IsFileWritable() )
title += _( " [Read Only]" ); title += _( " [Read Only]" );
} }
else else
{ title += _( "[no project]" );
title += _( "[no file]" );
}
SetTitle( title ); SetTitle( title );
} }

View File

@ -51,10 +51,10 @@
COLORS_DESIGN_SETTINGS g_ColorsSettings; COLORS_DESIGN_SETTINGS g_ColorsSettings;
// Constant string definitions for CvPcb // Constant string definitions for CvPcb
const wxString FootprintAliasFileExtension( wxT( "equ" ) ); const wxString EquFileExtension( wxT( "equ" ) );
// Wildcard for schematic retroannotation (import footprint names in schematic): // Wildcard for schematic retroannotation (import footprint names in schematic):
const wxString FootprintAliasFileWildcard( _( "KiCad footprint alias files (*.equ)|*.equ" ) ); const wxString EquFilesWildcard( _( "Component/footprint equ files (*.equ)|*.equ" ) );
#if 0 // add this logic to OpenProjectFiles() #if 0 // add this logic to OpenProjectFiles()

View File

@ -36,8 +36,8 @@
#define LISTB_STYLE ( wxSUNKEN_BORDER | wxLC_NO_HEADER | wxLC_REPORT | wxLC_VIRTUAL | \ #define LISTB_STYLE ( wxSUNKEN_BORDER | wxLC_NO_HEADER | wxLC_REPORT | wxLC_VIRTUAL | \
wxLC_SINGLE_SEL | wxVSCROLL | wxHSCROLL ) wxLC_SINGLE_SEL | wxVSCROLL | wxHSCROLL )
extern const wxString FootprintAliasFileExtension; extern const wxString EquFileExtension;
extern const wxString FootprintAliasFileWildcard; extern const wxString EquFilesWildcard;
#endif /* __CVPCB_H__ */ #endif /* __CVPCB_H__ */

View File

@ -56,5 +56,6 @@ enum id_cvpcb_frm
ID_CVPCB_FOOTPRINT_DISPLAY_BY_LIBRARY_LIST, ID_CVPCB_FOOTPRINT_DISPLAY_BY_LIBRARY_LIST,
ID_CVPCB_CONFIG_KEEP_OPEN_ON_SAVE, ID_CVPCB_CONFIG_KEEP_OPEN_ON_SAVE,
ID_CVPCB_LIBRARY_LIST, ID_CVPCB_LIBRARY_LIST,
ID_CVPCB_EQUFILES_LIST_EDIT,
ID_CVPCB_LIB_TABLE_EDIT ID_CVPCB_LIB_TABLE_EDIT
}; };

View File

@ -66,7 +66,7 @@ public:
wxAuiToolBar* m_mainToolBar; wxAuiToolBar* m_mainToolBar;
wxFileName m_NetlistFileName; wxFileName m_NetlistFileName;
wxArrayString m_ModuleLibNames; wxArrayString m_ModuleLibNames;
wxArrayString m_AliasLibNames; wxArrayString m_EquFilesNames;
wxString m_NetlistFileExtension; wxString m_NetlistFileExtension;
wxString m_DocModulesFileName; wxString m_DocModulesFileName;
FOOTPRINT_LIST m_footprints; FOOTPRINT_LIST m_footprints;
@ -137,10 +137,16 @@ public:
/** /**
* Function OnEditLibraryTable * Function OnEditLibraryTable
* envokes the footpirnt library table edit dialog. * envokes the footprint library table edit dialog.
*/ */
void OnEditFootprintLibraryTable( wxCommandEvent& aEvent ); void OnEditFootprintLibraryTable( wxCommandEvent& aEvent );
/**
* Function OnEditEquFilesList
* envokes the equ files list edit dialog.
*/
void OnEditEquFilesList( wxCommandEvent& aEvent );
void OnKeepOpenOnSave( wxCommandEvent& event ); void OnKeepOpenOnSave( wxCommandEvent& event );
void DisplayModule( wxCommandEvent& event ); void DisplayModule( wxCommandEvent& event );

View File

@ -0,0 +1,284 @@
/**
* @file dialog_config_equfiles.cpp
*/
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 1992-2015 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 2
* 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, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <fctsys.h>
#include <pgm_base.h>
#include <common.h>
#include <confirm.h>
#include <gestfich.h>
#include <id.h>
#include <project.h> // For PROJECT_VAR_NAME definition
#include <fp_lib_table.h> // For KISYSMOD definition
#include <cvpcb.h>
#include <cvpcb_mainframe.h>
#include <dialog_config_equfiles.h>
#include <wildcards_and_files_ext.h>
DIALOG_CONFIG_EQUFILES::DIALOG_CONFIG_EQUFILES( CVPCB_MAINFRAME* aParent ) :
DIALOG_CONFIG_EQUFILES_BASE( aParent )
{
m_Parent = aParent;
m_Config = Pgm().CommonSettings();
PROJECT& prj = Prj();
SetTitle( wxString::Format( _( "Project file: '%s'" ), GetChars( prj.GetProjectFullName() ) ) );
Init( );
GetSizer()->SetSizeHints( this );
Center();
}
void CVPCB_MAINFRAME::OnEditEquFilesList( wxCommandEvent& aEvent )
{
DIALOG_CONFIG_EQUFILES dlg( this );
dlg.ShowModal();
}
void DIALOG_CONFIG_EQUFILES::Init()
{
m_sdbSizerOK->SetDefault();
m_ListChanged = false;
m_ListEquiv->InsertItems( m_Parent->m_EquFilesNames, 0 );
if( getEnvVarCount() < 2 )
m_gridEnvVars->AppendRows(2 - getEnvVarCount() );
wxString evValue;
int row = 0;
m_gridEnvVars->SetCellValue( row++, 0, PROJECT_VAR_NAME );
m_gridEnvVars->SetCellValue( row, 0, FP_LIB_TABLE::GlobalPathEnvVariableName() );
for( row = 0; row < getEnvVarCount(); row++ )
{
if( wxGetEnv( m_gridEnvVars->GetCellValue( row, 0 ), &evValue ) )
m_gridEnvVars->SetCellValue( row, 1, evValue );
}
m_gridEnvVars->AutoSizeColumns();
}
void DIALOG_CONFIG_EQUFILES::OnCancelClick( wxCommandEvent& event )
{
EndModal( wxID_CANCEL );
}
void DIALOG_CONFIG_EQUFILES::OnOkClick( wxCommandEvent& event )
{
// Save new equ file list if the files list was modified
if( m_ListChanged )
{
// Recreate equ list
m_Parent->m_EquFilesNames.Clear();
for( unsigned ii = 0; ii < m_ListEquiv->GetCount(); ii++ )
m_Parent->m_EquFilesNames.Add( m_ListEquiv->GetString( ii ) );
wxCommandEvent evt( ID_SAVE_PROJECT );
m_Parent->SaveProjectFile( evt );
}
EndModal( wxID_OK );
}
void DIALOG_CONFIG_EQUFILES::OnCloseWindow( wxCloseEvent& event )
{
EndModal( wxID_CANCEL );
}
/********************************************************************/
void DIALOG_CONFIG_EQUFILES::OnButtonMoveUp( wxCommandEvent& event )
/********************************************************************/
{
wxListBox * list = m_ListEquiv;
wxArrayInt selections;
list->GetSelections( selections );
if ( selections.GetCount() <= 0 ) // No selection.
return;
if( selections[0] == 0 ) // The first lib is selected. cannot move up it
return;
wxArrayString libnames = list->GetStrings();
for( size_t ii = 0; ii < selections.GetCount(); ii++ )
{
int jj = selections[ii];
EXCHG( libnames[jj], libnames[jj-1] );
}
list->Set( libnames );
// Reselect previously selected names
for( size_t ii = 0; ii < selections.GetCount(); ii++ )
{
int jj = selections[ii];
list->SetSelection( jj-1 );
}
m_ListChanged = true;
}
/*********************************************************************/
void DIALOG_CONFIG_EQUFILES::OnButtonMoveDown( wxCommandEvent& event )
/*********************************************************************/
{
wxArrayInt selections;
m_ListEquiv->GetSelections( selections );
if ( selections.GetCount() <= 0 ) // No selection.
return;
// The last lib is selected. cannot move down it
if( selections.Last() == int( m_ListEquiv->GetCount()-1 ) )
return;
wxArrayString libnames = m_ListEquiv->GetStrings();
for( int ii = selections.GetCount()-1; ii >= 0; ii-- )
{
int jj = selections[ii];
EXCHG( libnames[jj], libnames[jj+1]);
}
m_ListEquiv->Set( libnames );
// Reselect previously selected names
for( size_t ii = 0; ii < selections.GetCount(); ii++ )
{
int jj = selections[ii];
m_ListEquiv->SetSelection(jj+1);
}
m_ListChanged = true;
}
/* Remove a library to the library list.
* The real list (g_LibName_List) is not changed, so the change can be canceled
*/
void DIALOG_CONFIG_EQUFILES::OnRemoveFiles( wxCommandEvent& event )
{
wxArrayInt selections;
m_ListEquiv->GetSelections( selections );
std::sort( selections.begin(), selections.end() );
for( int ii = selections.GetCount()-1; ii >= 0; ii-- )
{
m_ListEquiv->Delete(selections[ii] );
m_ListChanged = true;
}
}
/* Insert or add a library to the library list:
* The new library is put in list before (insert button) the selection,
* or added (add button) to end of list
*/
void DIALOG_CONFIG_EQUFILES::OnAddFiles( wxCommandEvent& event )
{
wxString equFilename, wildcard;
wxFileName fn;
wildcard = EquFilesWildcard;
wxListBox* list = m_ListEquiv;
// Get a default path to open the file dialog:
wxString libpath;
wxArrayInt selectedRows = m_gridEnvVars->GetSelectedRows();
int row = selectedRows.GetCount() ? selectedRows[0] :
m_gridEnvVars->GetGridCursorRow();
libpath = m_gridEnvVars->GetCellValue( wxGridCellCoords( row, 1 ) );
wxFileDialog FilesDialog( this, _( "Equ files:" ), libpath,
wxEmptyString, wildcard,
wxFD_DEFAULT_STYLE | wxFD_MULTIPLE );
if( FilesDialog.ShowModal() != wxID_OK )
return;
wxArrayString Filenames;
FilesDialog.GetPaths( Filenames );
for( unsigned jj = 0; jj < Filenames.GetCount(); jj++ )
{
fn = Filenames[jj];
equFilename.Empty();
if( isPathRelativeAllowed() ) // try to use relative path
{
for( row = 0; row < getEnvVarCount(); row++ )
{
libpath = m_gridEnvVars->GetCellValue( wxGridCellCoords( row, 1 ) );
if( fn.MakeRelativeTo( libpath ) )
{
equFilename.Printf( wxT("${%s}%c%s"),
GetChars( m_gridEnvVars->GetCellValue( wxGridCellCoords( row, 0 ) ) ),
fn.GetPathSeparator(),
GetChars( fn.GetFullPath() ) );
break;
}
}
}
if( equFilename.IsEmpty() )
equFilename = Filenames[jj];
// Add or insert new library name, if not already in list
if( list->FindString( equFilename, fn.IsCaseSensitive() ) == wxNOT_FOUND )
{
m_ListChanged = true;
equFilename.Replace( wxT("\\"), wxT("/") ); // Use unix separators only.
list->Append( equFilename );
}
else
{
wxString msg;
msg.Printf( _( "File '%s'already in list" ), equFilename.GetData() );
DisplayError( this, msg );
}
}
}

View File

@ -0,0 +1,70 @@
/**
* @file dialog_config_equfiles.h
*/
/*
* This program source code file is part of KICAD, a free EDA CAD application.
*
* Copyright (C) 2010-2015 Jean-Pierre Charras jp.charras at wanadoo.fr
* Copyright (C) 1992-2015 Kicad Developers, see CHANGELOG.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 2
* 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, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef _DIALOG_CONFIG_EQUFILES_H_
#define _DIALOG_CONFIG_EQUFILES_H_
#include <dialog_config_equfiles_base.h>
class DIALOG_CONFIG_EQUFILES : public DIALOG_CONFIG_EQUFILES_BASE
{
private:
CVPCB_MAINFRAME* m_Parent;
wxConfigBase* m_Config;
wxString m_UserLibDirBufferImg;
bool m_ListChanged;
private:
void Init();
// Virtual event handlers
void OnCloseWindow( wxCloseEvent& event );
void OnOkClick( wxCommandEvent& event );
void OnCancelClick( wxCommandEvent& event );
void OnAddFiles( wxCommandEvent& event );
void OnRemoveFiles( wxCommandEvent& event );
void OnButtonMoveUp( wxCommandEvent& event );
void OnButtonMoveDown( wxCommandEvent& event );
int getEnvVarCount() // Get the number of rows in env var table
{
return m_gridEnvVars->GetTable()->GetRowsCount();
}
bool isPathRelativeAllowed()
{
return m_rbPathOptionChoice->GetSelection() == 1;
}
public:
DIALOG_CONFIG_EQUFILES( CVPCB_MAINFRAME* parent );
~DIALOG_CONFIG_EQUFILES() {};
};
#endif // _DIALOG_CONFIG_EQUFILES_H_

View File

@ -0,0 +1,144 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Jun 5 2014)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
///////////////////////////////////////////////////////////////////////////
#include "dialog_config_equfiles_base.h"
///////////////////////////////////////////////////////////////////////////
DIALOG_CONFIG_EQUFILES_BASE::DIALOG_CONFIG_EQUFILES_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : DIALOG_SHIM( parent, id, title, pos, size, style )
{
this->SetSizeHints( wxDefaultSize, wxDefaultSize );
wxBoxSizer* bMainSizer;
bMainSizer = new wxBoxSizer( wxVERTICAL );
wxStaticBoxSizer* sbEquivChoiceSizer;
sbEquivChoiceSizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Footprint alias files (.equ files)") ), wxHORIZONTAL );
wxBoxSizer* bSizerFlist;
bSizerFlist = new wxBoxSizer( wxVERTICAL );
m_ListEquiv = new wxListBox( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0, NULL, wxLB_EXTENDED|wxLB_HSCROLL|wxLB_NEEDED_SB|wxLB_SINGLE );
m_ListEquiv->SetMinSize( wxSize( 350,-1 ) );
bSizerFlist->Add( m_ListEquiv, 1, wxRIGHT|wxLEFT|wxEXPAND, 5 );
sbEquivChoiceSizer->Add( bSizerFlist, 1, wxEXPAND, 5 );
wxBoxSizer* bSizerButtons;
bSizerButtons = new wxBoxSizer( wxVERTICAL );
m_buttonAddEqu = new wxButton( this, ID_ADD_EQU, _("Add"), wxDefaultPosition, wxDefaultSize, 0 );
bSizerButtons->Add( m_buttonAddEqu, 0, wxALIGN_CENTER_HORIZONTAL|wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
m_buttonRemoveEqu = new wxButton( this, ID_REMOVE_EQU, _("Remove"), wxDefaultPosition, wxDefaultSize, 0 );
m_buttonRemoveEqu->SetToolTip( _("Unload the selected library") );
bSizerButtons->Add( m_buttonRemoveEqu, 0, wxALIGN_CENTER_HORIZONTAL|wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
m_buttonMoveUp = new wxButton( this, ID_EQU_UP, _("Move Up"), wxDefaultPosition, wxDefaultSize, 0 );
bSizerButtons->Add( m_buttonMoveUp, 0, wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
m_buttonMoveDown = new wxButton( this, ID_EQU_DOWN, _("Move Down"), wxDefaultPosition, wxDefaultSize, 0 );
bSizerButtons->Add( m_buttonMoveDown, 0, wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
sbEquivChoiceSizer->Add( bSizerButtons, 0, wxALIGN_CENTER_VERTICAL, 5 );
bMainSizer->Add( sbEquivChoiceSizer, 1, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 5 );
wxBoxSizer* bSizerLower;
bSizerLower = new wxBoxSizer( wxHORIZONTAL );
wxBoxSizer* bSizerEnvVar;
bSizerEnvVar = new wxBoxSizer( wxVERTICAL );
m_staticText2 = new wxStaticText( this, wxID_ANY, _("Available environment variables for relative paths:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText2->Wrap( -1 );
bSizerEnvVar->Add( m_staticText2, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
m_gridEnvVars = new wxGrid( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );
// Grid
m_gridEnvVars->CreateGrid( 2, 2 );
m_gridEnvVars->EnableEditing( true );
m_gridEnvVars->EnableGridLines( true );
m_gridEnvVars->EnableDragGridSize( false );
m_gridEnvVars->SetMargins( 0, 0 );
// Columns
m_gridEnvVars->EnableDragColMove( false );
m_gridEnvVars->EnableDragColSize( true );
m_gridEnvVars->SetColLabelSize( 30 );
m_gridEnvVars->SetColLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE );
// Rows
m_gridEnvVars->AutoSizeRows();
m_gridEnvVars->EnableDragRowSize( true );
m_gridEnvVars->SetRowLabelSize( 30 );
m_gridEnvVars->SetRowLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE );
// Label Appearance
// Cell Defaults
m_gridEnvVars->SetDefaultCellAlignment( wxALIGN_LEFT, wxALIGN_TOP );
bSizerEnvVar->Add( m_gridEnvVars, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
bSizerLower->Add( bSizerEnvVar, 1, wxEXPAND, 5 );
wxString m_rbPathOptionChoiceChoices[] = { _("Absolute path"), _("Relative path") };
int m_rbPathOptionChoiceNChoices = sizeof( m_rbPathOptionChoiceChoices ) / sizeof( wxString );
m_rbPathOptionChoice = new wxRadioBox( this, wxID_ANY, _("Path option:"), wxDefaultPosition, wxDefaultSize, m_rbPathOptionChoiceNChoices, m_rbPathOptionChoiceChoices, 1, wxRA_SPECIFY_COLS );
m_rbPathOptionChoice->SetSelection( 1 );
bSizerLower->Add( m_rbPathOptionChoice, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
bMainSizer->Add( bSizerLower, 0, wxEXPAND, 5 );
m_staticline2 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
bMainSizer->Add( m_staticline2, 0, wxEXPAND|wxALL, 5 );
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();
bMainSizer->Add( m_sdbSizer, 0, wxALL|wxEXPAND, 5 );
this->SetSizer( bMainSizer );
this->Layout();
this->Centre( wxBOTH );
// Connect Events
this->Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_CONFIG_EQUFILES_BASE::OnCloseWindow ) );
m_buttonAddEqu->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_CONFIG_EQUFILES_BASE::OnAddFiles ), NULL, this );
m_buttonRemoveEqu->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_CONFIG_EQUFILES_BASE::OnRemoveFiles ), NULL, this );
m_buttonMoveUp->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_CONFIG_EQUFILES_BASE::OnButtonMoveUp ), NULL, this );
m_buttonMoveDown->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_CONFIG_EQUFILES_BASE::OnButtonMoveDown ), NULL, this );
m_sdbSizerCancel->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_CONFIG_EQUFILES_BASE::OnCancelClick ), NULL, this );
m_sdbSizerOK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_CONFIG_EQUFILES_BASE::OnOkClick ), NULL, this );
}
DIALOG_CONFIG_EQUFILES_BASE::~DIALOG_CONFIG_EQUFILES_BASE()
{
// Disconnect Events
this->Disconnect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_CONFIG_EQUFILES_BASE::OnCloseWindow ) );
m_buttonAddEqu->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_CONFIG_EQUFILES_BASE::OnAddFiles ), NULL, this );
m_buttonRemoveEqu->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_CONFIG_EQUFILES_BASE::OnRemoveFiles ), NULL, this );
m_buttonMoveUp->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_CONFIG_EQUFILES_BASE::OnButtonMoveUp ), NULL, this );
m_buttonMoveDown->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_CONFIG_EQUFILES_BASE::OnButtonMoveDown ), NULL, this );
m_sdbSizerCancel->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_CONFIG_EQUFILES_BASE::OnCancelClick ), NULL, this );
m_sdbSizerOK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_CONFIG_EQUFILES_BASE::OnOkClick ), NULL, this );
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,80 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Jun 5 2014)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
///////////////////////////////////////////////////////////////////////////
#ifndef __DIALOG_CONFIG_EQUFILES_BASE_H__
#define __DIALOG_CONFIG_EQUFILES_BASE_H__
#include <wx/artprov.h>
#include <wx/xrc/xmlres.h>
#include <wx/intl.h>
class DIALOG_SHIM;
#include "dialog_shim.h"
#include <wx/string.h>
#include <wx/listbox.h>
#include <wx/gdicmn.h>
#include <wx/font.h>
#include <wx/colour.h>
#include <wx/settings.h>
#include <wx/sizer.h>
#include <wx/button.h>
#include <wx/statbox.h>
#include <wx/stattext.h>
#include <wx/grid.h>
#include <wx/radiobox.h>
#include <wx/statline.h>
#include <wx/dialog.h>
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
/// Class DIALOG_CONFIG_EQUFILES_BASE
///////////////////////////////////////////////////////////////////////////////
class DIALOG_CONFIG_EQUFILES_BASE : public DIALOG_SHIM
{
private:
protected:
enum
{
ID_ADD_EQU = 1000,
ID_REMOVE_EQU,
ID_EQU_UP,
ID_EQU_DOWN
};
wxListBox* m_ListEquiv;
wxButton* m_buttonAddEqu;
wxButton* m_buttonRemoveEqu;
wxButton* m_buttonMoveUp;
wxButton* m_buttonMoveDown;
wxStaticText* m_staticText2;
wxGrid* m_gridEnvVars;
wxRadioBox* m_rbPathOptionChoice;
wxStaticLine* m_staticline2;
wxStdDialogButtonSizer* m_sdbSizer;
wxButton* m_sdbSizerOK;
wxButton* m_sdbSizerCancel;
// Virtual event handlers, overide them in your derived class
virtual void OnCloseWindow( wxCloseEvent& event ) { event.Skip(); }
virtual void OnAddFiles( wxCommandEvent& event ) { event.Skip(); }
virtual void OnRemoveFiles( wxCommandEvent& event ) { event.Skip(); }
virtual void OnButtonMoveUp( wxCommandEvent& event ) { event.Skip(); }
virtual void OnButtonMoveDown( wxCommandEvent& event ) { event.Skip(); }
virtual void OnCancelClick( wxCommandEvent& event ) { event.Skip(); }
virtual void OnOkClick( wxCommandEvent& event ) { event.Skip(); }
public:
DIALOG_CONFIG_EQUFILES_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 454,284 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
~DIALOG_CONFIG_EQUFILES_BASE();
};
#endif //__DIALOG_CONFIG_EQUFILES_BASE_H__

View File

@ -1,494 +0,0 @@
/**
* @file dialog_cvpcb_config.cpp
*/
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2012 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 2012 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-2012 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 2
* 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, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <fctsys.h>
#include <wx/tokenzr.h>
#include <pgm_base.h>
#include <common.h>
#include <confirm.h>
#include <gestfich.h>
#include <id.h>
#include <macros.h>
#include <cvpcb.h>
#include <cvpcb_mainframe.h>
#include <dialog_cvpcb_config.h>
#include <wildcards_and_files_ext.h>
DIALOG_CVPCB_CONFIG::DIALOG_CVPCB_CONFIG( CVPCB_MAINFRAME* aParent ) :
DIALOG_CVPCB_CONFIG_FBP( aParent )
{
wxString title;
wxFileName fn = aParent->m_NetlistFileName;
fn.SetExt( ProjectFileExtension );
m_Parent = aParent;
m_Config = Pgm().CommonSettings();
Init( );
title.Format( _( "Project file: '%s'" ), GetChars( fn.GetFullPath() ) );
SetTitle( title );
if( GetSizer() )
{
GetSizer()->SetSizeHints( this );
}
m_sdbSizer2OK->SetDefault();
}
void DIALOG_CVPCB_CONFIG::Init()
{
wxString msg;
SetFocus();
m_LibListChanged = false;
m_LibPathChanged = false;
m_UserLibDirBufferImg = m_Parent->m_UserLibraryPath;
m_ListLibr->InsertItems( m_Parent->m_ModuleLibNames, 0 );
m_ListEquiv->InsertItems( m_Parent->m_AliasLibNames, 0 );
m_TextHelpModulesFileName->SetValue( m_Parent->m_DocModulesFileName );
// Load user libs paths:
wxStringTokenizer Token( m_UserLibDirBufferImg, wxT( ";\n\r" ) );
while( Token.HasMoreTokens() )
{
wxString path = Token.GetNextToken();
if( wxFileName::DirExists( path ) )
m_listUserPaths->Append( path );
}
// Display actual libraries paths:
wxPathList libpaths = Pgm().GetLibraryPathList();
for( unsigned ii = 0; ii < libpaths.GetCount(); ii++ )
{
m_DefaultLibraryPathslistBox->Append( libpaths[ii] );
}
// select the first path after the current path project
if( libpaths.GetCount() > 1 )
m_DefaultLibraryPathslistBox->Select( 1 );
}
void DIALOG_CVPCB_CONFIG::OnCancelClick( wxCommandEvent& event )
{
// Recreate the user lib path
if( m_LibPathChanged )
{
for( unsigned ii = 0; ii < m_ListLibr->GetCount(); ii++ )
Pgm().RemoveLibraryPath( m_listUserPaths->GetString( ii ) );
Pgm().InsertLibraryPath( m_Parent->m_UserLibraryPath, 1 );
}
EndModal( wxID_CANCEL );
}
void DIALOG_CVPCB_CONFIG::OnOkClick( wxCommandEvent& event )
{
m_Parent->m_DocModulesFileName = m_TextHelpModulesFileName->GetValue();
// Recreate the user lib path
if( m_LibPathChanged )
{
m_Parent->m_UserLibraryPath.Empty();
for( unsigned ii = 0; ii < m_listUserPaths->GetCount(); ii++ )
{
if( ii > 0 )
m_Parent->m_UserLibraryPath << wxT( ";" );
m_Parent->m_UserLibraryPath << m_listUserPaths->GetString( ii );
}
}
// Set new active library list if the lib list of if default path list was modified
if( m_LibListChanged || m_LibPathChanged )
{
// Recreate lib list
m_Parent->m_ModuleLibNames.Clear();
for( unsigned ii = 0; ii < m_ListLibr->GetCount(); ii++ )
m_Parent->m_ModuleLibNames.Add( m_ListLibr->GetString( ii ) );
// Recreate equ list
m_Parent->m_AliasLibNames.Clear();
for( unsigned ii = 0; ii < m_ListEquiv->GetCount(); ii++ )
m_Parent->m_AliasLibNames.Add( m_ListEquiv->GetString( ii ) );
m_Parent->LoadFootprintFiles();
m_Parent->BuildFOOTPRINTS_LISTBOX();
m_Parent->BuildLIBRARY_LISTBOX();
}
wxCommandEvent evt( ID_SAVE_PROJECT );
m_Parent->SaveProjectFile( evt );
EndModal( wxID_OK );
}
void DIALOG_CVPCB_CONFIG::OnCloseWindow( wxCloseEvent& event )
{
EndModal( 0 );
}
/********************************************************************/
void DIALOG_CVPCB_CONFIG::OnButtonUpClick( wxCommandEvent& event )
/********************************************************************/
{
wxListBox * list = m_ListLibr;
if( (event.GetId() == ID_EQU_UP) || (event.GetId() == ID_EQU_DOWN) )
{
list = m_ListEquiv;
}
wxArrayInt selections;
list->GetSelections( selections );
if ( selections.GetCount() <= 0 ) // No selection.
return;
if( selections[0] == 0 ) // The first lib is selected. cannot move up it
return;
wxArrayString libnames = list->GetStrings();
for( size_t ii = 0; ii < selections.GetCount(); ii++ )
{
int jj = selections[ii];
EXCHG( libnames[jj], libnames[jj-1] );
}
list->Set( libnames );
// Reselect previously selected names
for( size_t ii = 0; ii < selections.GetCount(); ii++ )
{
int jj = selections[ii];
list->SetSelection( jj-1 );
}
m_LibListChanged = true;
}
/*********************************************************************/
void DIALOG_CVPCB_CONFIG::OnButtonDownClick( wxCommandEvent& event )
/*********************************************************************/
{
wxListBox * list = m_ListLibr;
if( (event.GetId() == ID_EQU_UP) || (event.GetId() == ID_EQU_DOWN) )
{
list = m_ListEquiv;
}
wxArrayInt selections;
list->GetSelections( selections );
if ( selections.GetCount() <= 0 ) // No selection.
return;
// The last lib is selected. cannot move down it
if( selections.Last() == (int)(list->GetCount()-1) )
return;
wxArrayString libnames = list->GetStrings();
for( int ii = selections.GetCount()-1; ii >= 0; ii-- )
{
int jj = selections[ii];
EXCHG( libnames[jj], libnames[jj+1]);
}
list->Set( libnames );
// Reselect previously selected names
for( size_t ii = 0; ii < selections.GetCount(); ii++ )
{
int jj = selections[ii];
list->SetSelection(jj+1);
}
m_LibListChanged = true;
}
/* Remove a library to the library list.
* The real list (g_LibName_List) is not changed, so the change can be canceled
*/
void DIALOG_CVPCB_CONFIG::OnRemoveLibClick( wxCommandEvent& event )
{
wxListBox * list = m_ListEquiv;
if( event.GetId() == ID_REMOVE_LIB )
list = m_ListLibr;
wxArrayInt selections;
list->GetSelections( selections );
for( int ii = selections.GetCount()-1; ii >= 0; ii-- )
{
list->Delete(selections[ii] );
m_LibListChanged = true;
}
}
/* Insert or add a library to the library list:
* The new library is put in list before (insert button) the selection,
* or added (add button) to end of list
* The real list (g_LibName_List) is not changed, so the change can be canceled
*/
void DIALOG_CVPCB_CONFIG::OnAddOrInsertLibClick( wxCommandEvent& event )
{
int ii;
wxString libfilename, wildcard;
wxFileName fn;
bool insert = false;
if( (event.GetId() == ID_INSERT_EQU) || (event.GetId() == ID_INSERT_LIB) )
insert = true;
wildcard = FootprintAliasFileWildcard;
wxListBox* list = m_ListEquiv;
if( (event.GetId() == ID_ADD_LIB) || (event.GetId() == ID_INSERT_LIB) )
{
list = m_ListLibr;
wildcard = LegacyFootprintLibPathWildcard;
}
wxArrayInt selections;
list->GetSelections(selections);
ii = selections.GetCount();
if( ii > 0 )
ii = selections[0];
else
ii = 0;
wxString libpath;
libpath = m_DefaultLibraryPathslistBox->GetStringSelection();
if( libpath.IsEmpty() )
libpath = Pgm().LastVisitedLibraryPath();
wxFileDialog FilesDialog( this, _( "Footprint library files:" ), libpath,
wxEmptyString, wildcard,
wxFD_DEFAULT_STYLE | wxFD_MULTIPLE );
if( FilesDialog.ShowModal() != wxID_OK )
return;
wxArrayString Filenames;
FilesDialog.GetPaths( Filenames );
for( unsigned jj = 0; jj < Filenames.GetCount(); jj++ )
{
fn = Filenames[jj];
if( jj == 0 )
Pgm().SaveLastVisitedLibraryPath( fn.GetPath() );
/* If the library path is already in the library search paths
* list, just add the library name to the list. Otherwise, add
* the library name with the full or relative path.
* the relative path, when possible is preferable,
* because it preserve use of default libraries paths, when the path
* is a sub path of these default paths
*/
libfilename = Pgm().FilenameWithRelativePathInSearchList( fn.GetFullPath() );
// Remove extension:
fn = libfilename;
fn.SetExt( wxEmptyString );
libfilename = fn.GetFullPath();
// Add or insert new library name, if not already in list
if( list->FindString( libfilename, fn.IsCaseSensitive() ) == wxNOT_FOUND )
{
m_LibListChanged = true;
if( ! insert )
list->Append( libfilename );
else
list->Insert( libfilename, ii++ );
}
else
{
wxString msg = wxT( "<" ) + libfilename + wxT( "> : " ) +
_( "Library already in use" );
DisplayError( this, msg );
}
}
}
void DIALOG_CVPCB_CONFIG::OnAddOrInsertPath( wxCommandEvent& event )
{
wxString path = Pgm().LastVisitedLibraryPath();
bool select = EDA_DirectorySelector( _( "Default Path for Libraries" ),
path,
wxDD_DEFAULT_STYLE,
this,
wxDefaultPosition );
if( !select )
return;
if( !wxFileName::DirExists( path ) ) // Should not occurs
return;
// Add or insert path if not already in list
if( m_listUserPaths->FindString( path ) == wxNOT_FOUND )
{
int ipos = m_listUserPaths->GetCount();
if( event.GetId() == ID_INSERT_PATH )
{
if( ipos )
ipos--;
int jj = m_listUserPaths->GetSelection();
if( jj >= 0 )
ipos = jj;
}
// Ask the user if this is a relative path
int diag = wxMessageBox( _( "Use a relative path?" ),
_( "Path type" ),
wxYES_NO | wxICON_QUESTION, this );
if( diag == wxYES )
{ // Make it relative
wxFileName fn = path;
fn.MakeRelativeTo( wxT( "." ) );
path = fn.GetPathWithSep() + fn.GetFullName();
}
m_listUserPaths->Insert( path, ipos );
m_LibPathChanged = true;
Pgm().InsertLibraryPath( path, ipos + 1 );
// Display actual libraries paths:
wxPathList libpaths = Pgm().GetLibraryPathList();
m_DefaultLibraryPathslistBox->Clear();
for( unsigned ii = 0; ii < libpaths.GetCount(); ii++ )
{
m_DefaultLibraryPathslistBox->Append( libpaths[ii] );
}
}
else
{
DisplayError( this, _( "Path already in use" ) );
}
Pgm().SaveLastVisitedLibraryPath( path );
}
void DIALOG_CVPCB_CONFIG::OnRemoveUserPath( wxCommandEvent& event )
{
int ii = m_listUserPaths->GetSelection();
if( ii < 0 )
ii = m_listUserPaths->GetCount() - 1;
if( ii >= 0 )
{
Pgm().RemoveLibraryPath( m_listUserPaths->GetStringSelection() );
m_listUserPaths->Delete( ii );
m_LibPathChanged = true;
}
// Display actual libraries paths:
wxPathList libpaths = Pgm().GetLibraryPathList();
m_DefaultLibraryPathslistBox->Clear();
for( unsigned ii = 0; ii < libpaths.GetCount(); ii++ )
{
m_DefaultLibraryPathslistBox->Append( libpaths[ii] );
}
}
void DIALOG_CVPCB_CONFIG::OnBrowseModDocFile( wxCommandEvent& event )
{
wxString FullFileName;
wxString docpath, filename;
docpath = Pgm().LastVisitedLibraryPath( wxT( "doc" ) );
wxFileDialog FilesDialog( this, _( "Footprint document file:" ), docpath,
wxEmptyString, PdfFileWildcard,
wxFD_DEFAULT_STYLE | wxFD_FILE_MUST_EXIST );
if( FilesDialog.ShowModal() != wxID_OK )
return;
FullFileName = FilesDialog.GetPath();
/* If the path is already in the library search paths
* list, just add the library name to the list. Otherwise, add
* the library name with the full or relative path.
* the relative path, when possible is preferable,
* because it preserve use of default libraries paths, when the path is
* a sub path of these default paths
*/
wxFileName fn = FullFileName;
Pgm().SaveLastVisitedLibraryPath( fn.GetPath() );
filename = Pgm().FilenameWithRelativePathInSearchList( FullFileName );
m_TextHelpModulesFileName->SetValue( filename );
}

View File

@ -1,46 +0,0 @@
/////////////////////////////////////////////////////////////////////////////
// Name: dialog_display_options.h
// Author: jean-pierre Charras
// Licence: GPL
/////////////////////////////////////////////////////////////////////////////
#ifndef _DIALOG_CVPCB_CONFIG_H_
#define _DIALOG_CVPCB_CONFIG_H_
#include <dialog_cvpcb_config_fbp.h>
class DIALOG_CVPCB_CONFIG : public DIALOG_CVPCB_CONFIG_FBP
{
private:
CVPCB_MAINFRAME* m_Parent;
wxConfigBase* m_Config;
wxString m_UserLibDirBufferImg;
bool m_LibListChanged;
bool m_LibPathChanged;
private:
void Init();
// Virtual event handlers
void OnCloseWindow( wxCloseEvent& event );
void OnOkClick( wxCommandEvent& event );
void OnCancelClick( wxCommandEvent& event );
void OnAddOrInsertLibClick( wxCommandEvent& event );
void OnRemoveLibClick( wxCommandEvent& event );
void OnBrowseModDocFile( wxCommandEvent& event );
void OnAddOrInsertPath( wxCommandEvent& event );
void OnRemoveUserPath( wxCommandEvent& event );
void OnButtonUpClick( wxCommandEvent& event );
void OnButtonDownClick( wxCommandEvent& event );
public:
DIALOG_CVPCB_CONFIG( CVPCB_MAINFRAME* parent );
~DIALOG_CVPCB_CONFIG() {};
};
#endif
// _DIALOG_CVPCB_CONFIG_H_

View File

@ -1,213 +0,0 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Apr 10 2012)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
///////////////////////////////////////////////////////////////////////////
#include "dialog_cvpcb_config_fbp.h"
///////////////////////////////////////////////////////////////////////////
DIALOG_CVPCB_CONFIG_FBP::DIALOG_CVPCB_CONFIG_FBP( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : DIALOG_SHIM( parent, id, title, pos, size, style )
{
this->SetSizeHints( wxDefaultSize, wxDefaultSize );
wxBoxSizer* bMainSizer;
bMainSizer = new wxBoxSizer( wxVERTICAL );
wxStaticBoxSizer* sbLibsChoiceSizer;
sbLibsChoiceSizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Footprint library files") ), wxHORIZONTAL );
m_ListLibr = new wxListBox( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0, NULL, wxLB_EXTENDED|wxLB_HSCROLL|wxLB_NEEDED_SB|wxLB_SINGLE );
m_ListLibr->SetToolTip( _("List of active library files.\nOnly library files in this list are loaded by Pcbnew.\nThe order of this list is important:\nPcbnew searchs for a given footprint using this list order priority.") );
m_ListLibr->SetMinSize( wxSize( 450,90 ) );
sbLibsChoiceSizer->Add( m_ListLibr, 1, wxEXPAND|wxRIGHT|wxLEFT, 5 );
wxBoxSizer* bSizerLibButtons;
bSizerLibButtons = new wxBoxSizer( wxVERTICAL );
m_buttonAddLib = new wxButton( this, ID_ADD_LIB, _("Add"), wxDefaultPosition, wxDefaultSize, 0 );
m_buttonAddLib->SetToolTip( _("Add a new library after the selected library, and load it") );
bSizerLibButtons->Add( m_buttonAddLib, 0, wxALIGN_CENTER_HORIZONTAL|wxLEFT|wxRIGHT, 5 );
m_buttonInsLib = new wxButton( this, ID_INSERT_LIB, _("Insert"), wxDefaultPosition, wxDefaultSize, 0 );
m_buttonInsLib->SetToolTip( _("Add a new library before the selected library, and load it") );
bSizerLibButtons->Add( m_buttonInsLib, 0, wxALIGN_CENTER_HORIZONTAL|wxLEFT|wxRIGHT, 5 );
m_buttonRemoveLib = new wxButton( this, ID_REMOVE_LIB, _("Remove"), wxDefaultPosition, wxDefaultSize, 0 );
m_buttonRemoveLib->SetToolTip( _("Unload the selected library") );
bSizerLibButtons->Add( m_buttonRemoveLib, 0, wxALIGN_CENTER_HORIZONTAL|wxLEFT|wxRIGHT, 5 );
m_buttonLibUp = new wxButton( this, ID_LIB_UP, _("Up"), wxDefaultPosition, wxDefaultSize, 0 );
bSizerLibButtons->Add( m_buttonLibUp, 0, wxRIGHT|wxLEFT, 5 );
m_buttonLibDown = new wxButton( this, ID_LIB_DOWN, _("Down"), wxDefaultPosition, wxDefaultSize, 0 );
bSizerLibButtons->Add( m_buttonLibDown, 0, wxRIGHT|wxLEFT, 5 );
sbLibsChoiceSizer->Add( bSizerLibButtons, 0, wxALIGN_CENTER_VERTICAL, 5 );
bMainSizer->Add( sbLibsChoiceSizer, 1, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 5 );
wxStaticBoxSizer* sbEquivChoiceSizer;
sbEquivChoiceSizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Footprint alias files") ), wxHORIZONTAL );
m_ListEquiv = new wxListBox( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0, NULL, wxLB_EXTENDED|wxLB_HSCROLL|wxLB_NEEDED_SB|wxLB_SINGLE );
m_ListEquiv->SetToolTip( _("List of active library files.\nOnly library files in this list are loaded by Pcbnew.\nThe order of this list is important:\nPcbnew searchs for a given footprint using this list order priority.") );
m_ListEquiv->SetMinSize( wxSize( 400,-1 ) );
sbEquivChoiceSizer->Add( m_ListEquiv, 1, wxEXPAND|wxRIGHT|wxLEFT, 5 );
wxBoxSizer* bSizerEquButtons;
bSizerEquButtons = new wxBoxSizer( wxVERTICAL );
m_buttonAddEqu = new wxButton( this, ID_ADD_EQU, _("Add"), wxDefaultPosition, wxDefaultSize, 0 );
m_buttonAddEqu->SetToolTip( _("Add a new library after the selected library, and load it") );
bSizerEquButtons->Add( m_buttonAddEqu, 0, wxALIGN_CENTER_HORIZONTAL|wxRIGHT|wxLEFT, 5 );
m_buttonInsEqu = new wxButton( this, ID_INSERT_EQU, _("Insert"), wxDefaultPosition, wxDefaultSize, 0 );
m_buttonInsEqu->SetToolTip( _("Add a new library before the selected library, and load it") );
bSizerEquButtons->Add( m_buttonInsEqu, 0, wxALIGN_CENTER_HORIZONTAL|wxLEFT|wxRIGHT, 5 );
m_buttonRemoveEqu = new wxButton( this, ID_REMOVE_EQU, _("Remove"), wxDefaultPosition, wxDefaultSize, 0 );
m_buttonRemoveEqu->SetToolTip( _("Unload the selected library") );
bSizerEquButtons->Add( m_buttonRemoveEqu, 0, wxALIGN_CENTER_HORIZONTAL|wxRIGHT|wxLEFT, 5 );
m_buttonEquUp = new wxButton( this, ID_EQU_UP, _("Up"), wxDefaultPosition, wxDefaultSize, 0 );
bSizerEquButtons->Add( m_buttonEquUp, 0, wxRIGHT|wxLEFT, 5 );
m_buttonEquDown = new wxButton( this, ID_EQU_DOWN, _("Down"), wxDefaultPosition, wxDefaultSize, 0 );
bSizerEquButtons->Add( m_buttonEquDown, 0, wxRIGHT|wxLEFT, 5 );
sbEquivChoiceSizer->Add( bSizerEquButtons, 0, wxALIGN_CENTER_VERTICAL, 5 );
bMainSizer->Add( sbEquivChoiceSizer, 1, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 5 );
wxStaticBoxSizer* sbModulesDocSizer;
sbModulesDocSizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Footprint documentation file") ), wxHORIZONTAL );
m_TextHelpModulesFileName = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
sbModulesDocSizer->Add( m_TextHelpModulesFileName, 1, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 );
m_buttonModDoc = new wxButton( this, ID_BROWSE_MOD_DOC, _("Browse"), wxDefaultPosition, wxDefaultSize, 0 );
sbModulesDocSizer->Add( m_buttonModDoc, 0, wxRIGHT|wxLEFT, 5 );
bMainSizer->Add( sbModulesDocSizer, 0, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 5 );
wxStaticBoxSizer* sbSizer4;
sbSizer4 = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("User defined search paths") ), wxHORIZONTAL );
wxBoxSizer* bUserListSizer;
bUserListSizer = new wxBoxSizer( wxVERTICAL );
m_listUserPaths = new wxListBox( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0, NULL, wxLB_NEEDED_SB );
m_listUserPaths->SetToolTip( _("Additional paths used in this project. The priority is higher than default KiCad paths.") );
m_listUserPaths->SetMinSize( wxSize( -1,70 ) );
bUserListSizer->Add( m_listUserPaths, 1, wxALIGN_CENTER_VERTICAL|wxEXPAND|wxRIGHT|wxLEFT, 5 );
sbSizer4->Add( bUserListSizer, 1, wxALIGN_CENTER_VERTICAL|wxALL|wxEXPAND, 5 );
wxBoxSizer* bUserPathsButtonsSizer;
bUserPathsButtonsSizer = new wxBoxSizer( wxVERTICAL );
m_buttonAddPath = new wxButton( this, ID_LIB_PATH_SEL, _("Add"), wxDefaultPosition, wxDefaultSize, 0 );
bUserPathsButtonsSizer->Add( m_buttonAddPath, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 );
m_buttonInsPath = new wxButton( this, ID_INSERT_PATH, _("Insert"), wxDefaultPosition, wxDefaultSize, 0 );
bUserPathsButtonsSizer->Add( m_buttonInsPath, 0, wxRIGHT|wxLEFT, 5 );
m_buttonRemovePath = new wxButton( this, ID_REMOVE_PATH, _("Remove"), wxDefaultPosition, wxDefaultSize, 0 );
bUserPathsButtonsSizer->Add( m_buttonRemovePath, 0, wxRIGHT|wxLEFT, 5 );
sbSizer4->Add( bUserPathsButtonsSizer, 0, wxALIGN_CENTER_VERTICAL, 5 );
bMainSizer->Add( sbSizer4, 1, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 5 );
wxStaticBoxSizer* sbSizer6;
sbSizer6 = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Current search path list") ), wxHORIZONTAL );
m_DefaultLibraryPathslistBox = new wxListBox( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0, NULL, wxLB_NEEDED_SB );
m_DefaultLibraryPathslistBox->SetToolTip( _("System and user paths used to search and load library files and component doc files.\nSorted by decreasing priority order.") );
m_DefaultLibraryPathslistBox->SetMinSize( wxSize( -1,70 ) );
sbSizer6->Add( m_DefaultLibraryPathslistBox, 1, wxEXPAND|wxRIGHT|wxLEFT, 5 );
bMainSizer->Add( sbSizer6, 1, wxALL|wxEXPAND, 5 );
m_staticline2 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
bMainSizer->Add( m_staticline2, 0, wxEXPAND|wxRIGHT|wxLEFT, 5 );
m_sdbSizer2 = new wxStdDialogButtonSizer();
m_sdbSizer2OK = new wxButton( this, wxID_OK );
m_sdbSizer2->AddButton( m_sdbSizer2OK );
m_sdbSizer2Cancel = new wxButton( this, wxID_CANCEL );
m_sdbSizer2->AddButton( m_sdbSizer2Cancel );
m_sdbSizer2->Realize();
bMainSizer->Add( m_sdbSizer2, 0, wxALL|wxEXPAND, 5 );
this->SetSizer( bMainSizer );
this->Layout();
this->Centre( wxBOTH );
// Connect Events
this->Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_CVPCB_CONFIG_FBP::OnCloseWindow ) );
m_buttonAddLib->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_CVPCB_CONFIG_FBP::OnAddOrInsertLibClick ), NULL, this );
m_buttonInsLib->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_CVPCB_CONFIG_FBP::OnAddOrInsertLibClick ), NULL, this );
m_buttonRemoveLib->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_CVPCB_CONFIG_FBP::OnRemoveLibClick ), NULL, this );
m_buttonLibUp->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_CVPCB_CONFIG_FBP::OnButtonUpClick ), NULL, this );
m_buttonLibDown->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_CVPCB_CONFIG_FBP::OnButtonDownClick ), NULL, this );
m_buttonAddEqu->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_CVPCB_CONFIG_FBP::OnAddOrInsertLibClick ), NULL, this );
m_buttonInsEqu->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_CVPCB_CONFIG_FBP::OnAddOrInsertLibClick ), NULL, this );
m_buttonRemoveEqu->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_CVPCB_CONFIG_FBP::OnRemoveLibClick ), NULL, this );
m_buttonEquUp->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_CVPCB_CONFIG_FBP::OnButtonUpClick ), NULL, this );
m_buttonEquDown->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_CVPCB_CONFIG_FBP::OnButtonDownClick ), NULL, this );
m_buttonModDoc->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_CVPCB_CONFIG_FBP::OnBrowseModDocFile ), NULL, this );
m_buttonAddPath->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_CVPCB_CONFIG_FBP::OnAddOrInsertPath ), NULL, this );
m_buttonInsPath->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_CVPCB_CONFIG_FBP::OnAddOrInsertPath ), NULL, this );
m_buttonRemovePath->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_CVPCB_CONFIG_FBP::OnRemoveUserPath ), NULL, this );
m_sdbSizer2Cancel->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_CVPCB_CONFIG_FBP::OnCancelClick ), NULL, this );
m_sdbSizer2OK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_CVPCB_CONFIG_FBP::OnOkClick ), NULL, this );
}
DIALOG_CVPCB_CONFIG_FBP::~DIALOG_CVPCB_CONFIG_FBP()
{
// Disconnect Events
this->Disconnect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_CVPCB_CONFIG_FBP::OnCloseWindow ) );
m_buttonAddLib->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_CVPCB_CONFIG_FBP::OnAddOrInsertLibClick ), NULL, this );
m_buttonInsLib->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_CVPCB_CONFIG_FBP::OnAddOrInsertLibClick ), NULL, this );
m_buttonRemoveLib->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_CVPCB_CONFIG_FBP::OnRemoveLibClick ), NULL, this );
m_buttonLibUp->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_CVPCB_CONFIG_FBP::OnButtonUpClick ), NULL, this );
m_buttonLibDown->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_CVPCB_CONFIG_FBP::OnButtonDownClick ), NULL, this );
m_buttonAddEqu->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_CVPCB_CONFIG_FBP::OnAddOrInsertLibClick ), NULL, this );
m_buttonInsEqu->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_CVPCB_CONFIG_FBP::OnAddOrInsertLibClick ), NULL, this );
m_buttonRemoveEqu->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_CVPCB_CONFIG_FBP::OnRemoveLibClick ), NULL, this );
m_buttonEquUp->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_CVPCB_CONFIG_FBP::OnButtonUpClick ), NULL, this );
m_buttonEquDown->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_CVPCB_CONFIG_FBP::OnButtonDownClick ), NULL, this );
m_buttonModDoc->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_CVPCB_CONFIG_FBP::OnBrowseModDocFile ), NULL, this );
m_buttonAddPath->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_CVPCB_CONFIG_FBP::OnAddOrInsertPath ), NULL, this );
m_buttonInsPath->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_CVPCB_CONFIG_FBP::OnAddOrInsertPath ), NULL, this );
m_buttonRemovePath->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_CVPCB_CONFIG_FBP::OnRemoveUserPath ), NULL, this );
m_sdbSizer2Cancel->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_CVPCB_CONFIG_FBP::OnCancelClick ), NULL, this );
m_sdbSizer2OK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_CVPCB_CONFIG_FBP::OnOkClick ), NULL, this );
}

File diff suppressed because it is too large Load Diff

View File

@ -95,11 +95,11 @@ void CVPCB_MAINFRAME::ReCreateMenuBar()
// Save the .cmp file // Save the .cmp file
AddMenuItem( filesMenu, wxID_SAVE, AddMenuItem( filesMenu, wxID_SAVE,
_( "&Save\tCtrl+S" ), SAVE_HLP_MSG, KiBitmap( save_xpm ) ); _( "&Save Cmp File\tCtrl+S" ), SAVE_HLP_MSG, KiBitmap( save_xpm ) );
// Save as the .cmp file // Save as the .cmp file
AddMenuItem( filesMenu, wxID_SAVEAS, AddMenuItem( filesMenu, wxID_SAVEAS,
_( "Save &As...\tCtrl+Shift+S" ), SAVE_AS_HLP_MSG, KiBitmap( save_xpm ) ); _( "Save Cmp File &As...\tCtrl+Shift+S" ), SAVE_AS_HLP_MSG, KiBitmap( save_xpm ) );
// Separator // Separator
filesMenu->AppendSeparator(); filesMenu->AppendSeparator();
@ -116,6 +116,12 @@ void CVPCB_MAINFRAME::ReCreateMenuBar()
_( "Edit Li&brary Table" ), _( "Setup footprint libraries" ), _( "Edit Li&brary Table" ), _( "Setup footprint libraries" ),
KiBitmap( library_table_xpm ) ); KiBitmap( library_table_xpm ) );
AddMenuItem( preferencesMenu, ID_CVPCB_EQUFILES_LIST_EDIT,
_( "Edit &Equ Files List" ),
_( "Setup equ files list (.equ files)\n"
"They are files which give the footprint name from the component value"),
KiBitmap( library_table_xpm ) );
// Language submenu // Language submenu
Pgm().AddMenuLanguageList( preferencesMenu ); Pgm().AddMenuLanguageList( preferencesMenu );
@ -134,11 +140,6 @@ void CVPCB_MAINFRAME::ReCreateMenuBar()
_( "Save changes to the project configuration file" ), _( "Save changes to the project configuration file" ),
KiBitmap( save_setup_xpm ) ); KiBitmap( save_setup_xpm ) );
AddMenuItem( preferencesMenu, ID_SAVE_PROJECT_AS,
_( "&Save Project File As" ),
_( "Save changes to a new project configuration file" ),
KiBitmap( save_setup_xpm ) );
// Menu Help: // Menu Help:
wxMenu* helpMenu = new wxMenu; wxMenu* helpMenu = new wxMenu;

View File

@ -5,7 +5,7 @@
/* /*
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 2012 Jean-Pierre Charras, jean-pierre.charras * Copyright (C) 2015 Jean-Pierre Charras, jean-pierre.charras
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net> * Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
* *
@ -385,8 +385,9 @@ int CVPCB_MAINFRAME::SaveCmpLinkFile( const wxString& aFullFileName )
} }
else else
{ {
wxFileDialog dlg( this, _( "Save Component Footprint Link File" ), wxEmptyString, wxFileDialog dlg( this, _( "Save Component Footprint Link File" ),
_( "Unnamed file" ), ComponentFileWildcard, wxFD_SAVE ); Prj().GetProjectPath(),
wxT( "noname" ), ComponentFileWildcard, wxFD_SAVE );
if( dlg.ShowModal() == wxID_CANCEL ) if( dlg.ShowModal() == wxID_CANCEL )
return -1; return -1;
@ -395,47 +396,13 @@ int CVPCB_MAINFRAME::SaveCmpLinkFile( const wxString& aFullFileName )
if( !fn.HasExt() ) if( !fn.HasExt() )
fn.SetExt( ComponentFileExtension ); fn.SetExt( ComponentFileExtension );
#if 0 // RHH 6-Jul-14: We did not auto generate the
// footprint table. And the dialog which does suppport editing does the saving.
// Besides, this is not the place to do this, it belies the name of this
// function.
// Save the project specific footprint library table.
if( !Prj().PcbFootprintLibs()->IsEmpty( false ) )
{
wxString fp_lib_tbl = Prj().FootprintLibTblName();
if( wxFileName::FileExists( fp_lib_tbl )
&& IsOK( this, _( "A footprint library table already exists in this path.\n\nDo "
"you want to overwrite it?" ) ) )
{
try
{
Prj().PcbFootprintLibs()->Save( fp_lib_tbl );
}
catch( const IO_ERROR& ioe )
{
wxString msg = wxString::Format( _(
"An error occurred attempting to save the "
"footprint library table '%s'\n\n%s" ),
GetChars( fp_lib_tbl ),
GetChars( ioe.errorText )
);
DisplayError( this, msg );
}
}
}
#endif
} }
if( !IsWritable( fn.GetFullPath() ) ) if( !IsWritable( fn.GetFullPath() ) || WriteComponentLinkFile( fn.GetFullPath() ) == 0 )
return 0;
if( WriteComponentLinkFile( fn.GetFullPath() ) == 0 )
{ {
DisplayError( this, _( "Unable to create component footprint link file (.cmp)" ) ); DisplayError( this,
wxString::Format( _( "Unable to create component footprint link file '%s'" ),
fn.GetFullPath() ) );
return 0; return 0;
} }

View File

@ -69,10 +69,6 @@ void CVPCB_MAINFRAME::ReCreateHToolbar()
KiBitmap( show_footprint_xpm ), KiBitmap( show_footprint_xpm ),
_( "View selected footprint" ) ); _( "View selected footprint" ) );
m_mainToolBar->AddTool( ID_CVPCB_AUTO_ASSOCIE, wxEmptyString,
KiBitmap( auto_associe_xpm ),
_( "Perform automatic footprint association" ) );
m_mainToolBar->AddSeparator(); m_mainToolBar->AddSeparator();
m_mainToolBar->AddTool( ID_CVPCB_GOTO_PREVIOUSNA, wxEmptyString, m_mainToolBar->AddTool( ID_CVPCB_GOTO_PREVIOUSNA, wxEmptyString,
KiBitmap( left_xpm ), KiBitmap( left_xpm ),
@ -83,6 +79,10 @@ void CVPCB_MAINFRAME::ReCreateHToolbar()
_( "Select next unlinked component" ) ); _( "Select next unlinked component" ) );
m_mainToolBar->AddSeparator(); m_mainToolBar->AddSeparator();
m_mainToolBar->AddTool( ID_CVPCB_AUTO_ASSOCIE, wxEmptyString,
KiBitmap( auto_associe_xpm ),
_( "Perform automatic footprint association" ) );
m_mainToolBar->AddTool( ID_CVPCB_DEL_ASSOCIATIONS, wxEmptyString, m_mainToolBar->AddTool( ID_CVPCB_DEL_ASSOCIATIONS, wxEmptyString,
KiBitmap( delete_association_xpm ), KiBitmap( delete_association_xpm ),
_( "Delete all associations (links)" ) ); _( "Delete all associations (links)" ) );
@ -92,7 +92,6 @@ void CVPCB_MAINFRAME::ReCreateHToolbar()
KiBitmap( datasheet_xpm ), KiBitmap( datasheet_xpm ),
_( "Display footprint documentation" ) ); _( "Display footprint documentation" ) );
m_mainToolBar->AddSeparator();
m_mainToolBar->AddSeparator(); m_mainToolBar->AddSeparator();
m_mainToolBar->AddTool( ID_CVPCB_FOOTPRINT_DISPLAY_FILTERED_LIST, m_mainToolBar->AddTool( ID_CVPCB_FOOTPRINT_DISPLAY_FILTERED_LIST,
KiBitmap( module_filtered_list_xpm ), KiBitmap( module_filtered_list_xpm ),