2008-12-08 15:27:13 +00:00
|
|
|
/***************************************/
|
|
|
|
/** menucfg : configuration de CVPCB **/
|
|
|
|
/***************************************/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
/* cree et/ou affiche et modifie la configuration de CVPCB */
|
|
|
|
|
|
|
|
#include "fctsys.h"
|
|
|
|
#include "common.h"
|
|
|
|
|
|
|
|
#include "cvpcb.h"
|
|
|
|
#include "protos.h"
|
|
|
|
|
|
|
|
|
2008-12-08 15:27:13 +00:00
|
|
|
/*****************************************/
|
|
|
|
/* classe pour la frame de Configuration */
|
|
|
|
/*****************************************/
|
2007-06-05 12:10:51 +00:00
|
|
|
#include "dialog_cvpcb_config.cpp"
|
|
|
|
|
|
|
|
|
|
|
|
/***************************************************/
|
2007-09-13 11:55:46 +00:00
|
|
|
void WinEDA_CvpcbFrame::CreateConfigWindow()
|
2007-06-05 12:10:51 +00:00
|
|
|
/***************************************************/
|
|
|
|
/* Creation de la fenetre de configuration de CVPCB */
|
|
|
|
{
|
2008-12-08 15:27:13 +00:00
|
|
|
KiConfigCvpcbFrame* ConfigFrame = new KiConfigCvpcbFrame( this );
|
|
|
|
|
|
|
|
ConfigFrame->ShowModal(); ConfigFrame->Destroy();
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*********************************************/
|
2007-09-13 11:55:46 +00:00
|
|
|
void KiConfigCvpcbFrame::SetDialogDatas()
|
2007-06-05 12:10:51 +00:00
|
|
|
/*********************************************/
|
|
|
|
{
|
2008-12-08 15:27:13 +00:00
|
|
|
m_ListLibr->InsertItems( g_LibName_List, 0 );
|
|
|
|
m_ListEquiv->InsertItems( g_ListName_Equ, 0 );
|
|
|
|
|
|
|
|
m_LibDirCtrl = new WinEDA_EnterText( this,
|
|
|
|
_( "Lib Dir:" ), g_UserLibDirBuffer,
|
|
|
|
m_RightBoxSizer, wxDefaultSize );
|
|
|
|
|
|
|
|
m_NetInputExtCtrl = new WinEDA_EnterText( this,
|
|
|
|
_( "Net Input Ext:" ),
|
|
|
|
NetInExtBuffer,
|
|
|
|
m_NetExtBoxSizer, wxDefaultSize );
|
|
|
|
|
|
|
|
wxString DocModuleFileName =
|
|
|
|
wxGetApp().m_EDA_CommonConfig->Read( DOC_FOOTPRINTS_LIST_KEY,
|
|
|
|
DEFAULT_FOOTPRINTS_LIST_FILENAME );
|
|
|
|
m_TextHelpModulesFileName = new WinEDA_EnterText( this,
|
|
|
|
_( "Module Doc File:" ),
|
|
|
|
DocModuleFileName,
|
|
|
|
m_RightBoxSizer,
|
|
|
|
wxDefaultSize );
|
|
|
|
|
|
|
|
/* Create info on Files ext */
|
|
|
|
wxStaticText* StaticText;
|
|
|
|
wxString text;
|
|
|
|
text.Printf( wxT( "%s %s" ), _( "Cmp ext:" ), g_ExtCmpBuffer.GetData() );
|
|
|
|
StaticText = new wxStaticText( this, -1, text );
|
|
|
|
m_FileExtList->Add(
|
|
|
|
StaticText,
|
|
|
|
wxGROW | wxLEFT | wxRIGHT | wxTOP | wxBOTTOM |
|
|
|
|
wxADJUST_MINSIZE );
|
|
|
|
|
|
|
|
text.Printf( wxT( "%s %s" ), _( "Lib ext:" ), LibExtBuffer.GetData() );
|
|
|
|
StaticText = new wxStaticText( this, -1, text );
|
|
|
|
m_FileExtList->Add(
|
|
|
|
StaticText,
|
|
|
|
wxGROW | wxLEFT | wxRIGHT | wxTOP | wxBOTTOM |
|
|
|
|
wxADJUST_MINSIZE );
|
|
|
|
|
|
|
|
text.Printf( wxT( "%s %s" ), _( "NetOut ext:" ), NetExtBuffer.GetData() );
|
|
|
|
StaticText = new wxStaticText( this, -1, text );
|
|
|
|
m_FileExtList->Add(
|
|
|
|
StaticText,
|
|
|
|
wxGROW | wxLEFT | wxRIGHT | wxTOP | wxBOTTOM |
|
|
|
|
wxADJUST_MINSIZE );
|
|
|
|
|
|
|
|
text.Printf( wxT( "%s %s" ), _( "Equiv ext:" ),
|
|
|
|
g_EquivExtBuffer.GetData() );
|
|
|
|
StaticText = new wxStaticText( this, -1, text );
|
|
|
|
m_FileExtList->Add(
|
|
|
|
StaticText,
|
|
|
|
wxGROW | wxLEFT | wxRIGHT | wxTOP | wxBOTTOM |
|
|
|
|
wxADJUST_MINSIZE );
|
|
|
|
|
|
|
|
text.Printf( wxT( "%s %s" ), _( "Retro ext:" ), ExtRetroBuffer.GetData() );
|
|
|
|
StaticText = new wxStaticText( this, -1, text );
|
|
|
|
m_FileExtList->Add(
|
|
|
|
StaticText,
|
|
|
|
wxGROW | wxLEFT | wxRIGHT | wxTOP | wxBOTTOM |
|
|
|
|
wxADJUST_MINSIZE );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2008-12-08 15:27:13 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/********************************************************/
|
2008-12-08 15:27:13 +00:00
|
|
|
void KiConfigCvpcbFrame::AcceptCfg( wxCommandEvent& event )
|
2007-06-05 12:10:51 +00:00
|
|
|
/********************************************************/
|
|
|
|
{
|
2008-12-08 15:27:13 +00:00
|
|
|
Update();
|
|
|
|
Close();
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2008-12-08 15:27:13 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/**********************************/
|
2007-09-13 11:55:46 +00:00
|
|
|
void KiConfigCvpcbFrame::Update()
|
2007-06-05 12:10:51 +00:00
|
|
|
/**********************************/
|
|
|
|
{
|
2008-12-08 15:27:13 +00:00
|
|
|
wxString msg;
|
|
|
|
|
|
|
|
if( !m_DoUpdate )
|
|
|
|
return;
|
|
|
|
NetInExtBuffer = m_NetInputExtCtrl->GetValue();
|
|
|
|
wxGetApp().m_EDA_CommonConfig->Write( DOC_FOOTPRINTS_LIST_KEY,
|
|
|
|
m_TextHelpModulesFileName->GetValue() );
|
|
|
|
|
|
|
|
msg = m_LibDirCtrl->GetValue();
|
|
|
|
if( msg != g_UserLibDirBuffer )
|
|
|
|
{
|
|
|
|
g_UserLibDirBuffer = m_LibDirCtrl->GetValue();
|
|
|
|
SetRealLibraryPath( wxT( "modules" ) );
|
|
|
|
listlib();
|
|
|
|
ListModIsModified = 1;
|
|
|
|
m_Parent->BuildFootprintListBox();
|
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/****************************************************/
|
2008-12-08 15:27:13 +00:00
|
|
|
void KiConfigCvpcbFrame::SaveCfg( wxCommandEvent& event )
|
2007-06-05 12:10:51 +00:00
|
|
|
/****************************************************/
|
|
|
|
{
|
2008-12-08 15:27:13 +00:00
|
|
|
Update();
|
|
|
|
Save_Config( this );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2008-12-08 15:27:13 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/******************************************************/
|
2008-12-08 15:27:13 +00:00
|
|
|
void KiConfigCvpcbFrame::ReadOldCfg( wxCommandEvent& event )
|
2007-06-05 12:10:51 +00:00
|
|
|
/******************************************************/
|
|
|
|
{
|
2008-12-08 15:27:13 +00:00
|
|
|
wxString line;
|
|
|
|
|
|
|
|
NetInNameBuffer.Replace( WIN_STRING_DIR_SEP, UNIX_STRING_DIR_SEP );
|
|
|
|
|
|
|
|
wxString FullFileName = NetInNameBuffer.AfterLast( '/' );
|
|
|
|
|
|
|
|
ChangeFileNameExt( FullFileName, g_Prj_Config_Filename_ext );
|
|
|
|
|
|
|
|
FullFileName = EDA_FileSelector( _( "Read config file" ),
|
|
|
|
wxGetCwd(), /* Chemin par defaut */
|
|
|
|
FullFileName, /* nom fichier par defaut */
|
|
|
|
g_Prj_Config_Filename_ext, /* extension par defaut */
|
|
|
|
FullFileName, /* Masque d'affichage */
|
|
|
|
this,
|
|
|
|
wxFD_OPEN,
|
|
|
|
TRUE /* ne change pas de repertoire courant */
|
|
|
|
);
|
|
|
|
if( FullFileName.IsEmpty() )
|
|
|
|
return;
|
|
|
|
if( !wxFileExists( FullFileName ) )
|
|
|
|
{
|
|
|
|
line.Printf( _( "File %s not found" ), FullFileName.GetData() );
|
|
|
|
DisplayError( this, line ); return;
|
|
|
|
}
|
|
|
|
|
|
|
|
Read_Config( FullFileName );
|
|
|
|
m_DoUpdate = FALSE;
|
|
|
|
Close( TRUE );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*******************************************************/
|
2008-12-08 15:27:13 +00:00
|
|
|
void KiConfigCvpcbFrame::LibDelFct( wxCommandEvent& event )
|
2007-06-05 12:10:51 +00:00
|
|
|
/*******************************************************/
|
|
|
|
{
|
2008-12-08 15:27:13 +00:00
|
|
|
int ii;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2008-12-08 15:27:13 +00:00
|
|
|
ii = m_ListLibr->GetSelection();
|
|
|
|
if( ii < 0 )
|
|
|
|
return;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2008-12-08 15:27:13 +00:00
|
|
|
ListModIsModified = 1;
|
|
|
|
g_LibName_List.RemoveAt( ii );
|
2008-08-01 17:41:51 +00:00
|
|
|
|
2008-12-08 15:27:13 +00:00
|
|
|
/* suppression de la reference dans la liste des librairies */
|
|
|
|
m_ListLibr->Delete( ii );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2008-12-08 15:27:13 +00:00
|
|
|
g_UserLibDirBuffer = m_LibDirCtrl->GetValue();
|
|
|
|
SetRealLibraryPath( wxT( "modules" ) );
|
|
|
|
listlib();
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2008-12-08 15:27:13 +00:00
|
|
|
m_Parent->BuildFootprintListBox();
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2008-12-08 15:27:13 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/********************************************************/
|
2008-12-08 15:27:13 +00:00
|
|
|
void KiConfigCvpcbFrame::LibAddFct( wxCommandEvent& event )
|
2007-06-05 12:10:51 +00:00
|
|
|
/********************************************************/
|
|
|
|
{
|
2008-12-08 15:27:13 +00:00
|
|
|
int ii;
|
|
|
|
wxString FullFileName, ShortLibName, mask;
|
|
|
|
|
|
|
|
ii = m_ListLibr->GetSelection();
|
|
|
|
if( event.GetId() == ADD_LIB ) /* Ajout apres selection */
|
|
|
|
{
|
|
|
|
ii++;
|
|
|
|
}
|
|
|
|
if( ii < 0 )
|
|
|
|
ii = 0;
|
|
|
|
|
|
|
|
Update();
|
|
|
|
mask = wxT( "*" ) + LibExtBuffer;
|
|
|
|
|
|
|
|
wxFileDialog FilesDialog( this, _( "Library files:" ), g_RealLibDirBuffer,
|
|
|
|
wxEmptyString, mask,
|
|
|
|
wxFD_DEFAULT_STYLE | wxFD_MULTIPLE );
|
|
|
|
|
|
|
|
FilesDialog.ShowModal();
|
|
|
|
wxArrayString Filenames;
|
|
|
|
FilesDialog.GetPaths( Filenames );
|
|
|
|
|
|
|
|
if( Filenames.GetCount() == 0 )
|
|
|
|
return;
|
|
|
|
|
|
|
|
for( unsigned jj = 0; jj < Filenames.GetCount(); jj++ )
|
|
|
|
{
|
|
|
|
FullFileName = Filenames[jj];
|
|
|
|
ShortLibName = MakeReducedFileName( FullFileName,
|
|
|
|
g_RealLibDirBuffer,
|
|
|
|
LibExtBuffer );
|
|
|
|
|
|
|
|
//Add or insert new library name
|
|
|
|
if( g_LibName_List.Index( ShortLibName ) == wxNOT_FOUND )
|
|
|
|
{
|
|
|
|
ListModIsModified = 1;
|
|
|
|
g_LibName_List.Insert( ShortLibName, ii++ );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
wxString msg;
|
|
|
|
msg << wxT( "<" ) << ShortLibName << wxT( "> : " ) << _(
|
|
|
|
"Library already in use" );
|
|
|
|
DisplayError( this, msg );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
g_UserLibDirBuffer = m_LibDirCtrl->GetValue();
|
|
|
|
SetRealLibraryPath( wxT( "modules" ) );
|
|
|
|
listlib();
|
|
|
|
|
|
|
|
m_Parent->BuildFootprintListBox();
|
|
|
|
|
|
|
|
m_ListLibr->Clear();
|
|
|
|
m_ListLibr->InsertItems( g_LibName_List, 0 );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/********************************************************/
|
2008-12-08 15:27:13 +00:00
|
|
|
void KiConfigCvpcbFrame::EquDelFct( wxCommandEvent& event )
|
2007-06-05 12:10:51 +00:00
|
|
|
/********************************************************/
|
|
|
|
{
|
2008-12-08 15:27:13 +00:00
|
|
|
int ii;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2008-12-08 15:27:13 +00:00
|
|
|
ii = m_ListEquiv->GetSelection();
|
|
|
|
if( ii < 0 )
|
|
|
|
return;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2008-12-08 15:27:13 +00:00
|
|
|
g_ListName_Equ.RemoveAt( ii );
|
|
|
|
m_ListEquiv->Delete( ii );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2008-12-08 15:27:13 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/********************************************************/
|
2008-12-08 15:27:13 +00:00
|
|
|
void KiConfigCvpcbFrame::EquAddFct( wxCommandEvent& event )
|
2007-06-05 12:10:51 +00:00
|
|
|
/********************************************************/
|
|
|
|
{
|
2008-12-08 15:27:13 +00:00
|
|
|
int ii;
|
|
|
|
wxString FullFileName, ShortLibName, mask;
|
|
|
|
|
|
|
|
ii = m_ListEquiv->GetSelection();
|
|
|
|
if( event.GetId() == ADD_EQU )
|
|
|
|
ii++; /* Ajout apres selection */
|
|
|
|
if( ii < 0 )
|
|
|
|
ii = 0;
|
|
|
|
|
|
|
|
Update();
|
|
|
|
mask = wxT( "*" ) + g_EquivExtBuffer;
|
|
|
|
|
|
|
|
wxFileDialog FilesDialog( this, _( "Equiv Files:" ), g_RealLibDirBuffer,
|
|
|
|
wxEmptyString, mask,
|
|
|
|
wxFD_DEFAULT_STYLE | wxFD_MULTIPLE );
|
|
|
|
|
|
|
|
FilesDialog.ShowModal();
|
|
|
|
wxArrayString Filenames;
|
|
|
|
FilesDialog.GetFilenames( Filenames );
|
|
|
|
|
|
|
|
if( Filenames.GetCount() == 0 )
|
|
|
|
return;
|
|
|
|
|
|
|
|
for( unsigned jj = 0; jj < Filenames.GetCount(); jj++ )
|
|
|
|
{
|
|
|
|
FullFileName = Filenames[jj];
|
|
|
|
ShortLibName = MakeReducedFileName( FullFileName,
|
|
|
|
g_RealLibDirBuffer,
|
|
|
|
g_EquivExtBuffer );
|
|
|
|
|
|
|
|
//Add or insert new equiv library name
|
|
|
|
if( g_ListName_Equ.Index( ShortLibName ) == wxNOT_FOUND )
|
|
|
|
{
|
|
|
|
g_ListName_Equ.Insert( ShortLibName, ii++ );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
wxString msg;
|
|
|
|
msg << wxT( "<" ) << ShortLibName << wxT( "> : " ) << _(
|
|
|
|
"Library already in use" );
|
|
|
|
DisplayError( this, msg );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Update display list */
|
|
|
|
g_UserLibDirBuffer = m_LibDirCtrl->GetValue();
|
|
|
|
SetRealLibraryPath( wxT( "modules" ) );
|
|
|
|
listlib();
|
|
|
|
|
|
|
|
m_ListEquiv->Clear();
|
|
|
|
m_ListEquiv->InsertItems( g_ListName_Equ, 0 );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|