2007-06-05 12:10:51 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
2009-04-06 10:56:17 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
// Name: dialog_eeschema_config.cpp
|
2008-04-09 17:27:59 +00:00
|
|
|
// Purpose:
|
2007-06-05 12:10:51 +00:00
|
|
|
// Author: jean-pierre Charras
|
|
|
|
// Created: 17/02/2006 21:14:46
|
2009-04-06 10:56:17 +00:00
|
|
|
// Copyright: Kicad Team
|
|
|
|
// Licence: GPL
|
2007-06-05 12:10:51 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#include "fctsys.h"
|
2009-02-04 15:25:03 +00:00
|
|
|
#include "appl_wxstruct.h"
|
2007-06-05 12:10:51 +00:00
|
|
|
#include "common.h"
|
2009-02-04 15:25:03 +00:00
|
|
|
#include "confirm.h"
|
|
|
|
#include "gestfich.h"
|
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
#include "program.h"
|
|
|
|
#include "libcmp.h"
|
|
|
|
#include "general.h"
|
|
|
|
|
|
|
|
#include "protos.h"
|
|
|
|
#include "netlist.h"
|
|
|
|
|
|
|
|
#include "id.h"
|
|
|
|
|
2009-04-06 10:56:17 +00:00
|
|
|
#include "dialog_eeschema_config_fbp.h"
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2009-04-06 10:56:17 +00:00
|
|
|
class DIALOG_EESCHEMA_CONFIG : public DIALOG_EESCHEMA_CONFIG_FBP
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2009-04-06 10:56:17 +00:00
|
|
|
private:
|
|
|
|
WinEDA_SchematicFrame* m_Parent;
|
|
|
|
bool m_LibListChanged;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2009-04-06 10:56:17 +00:00
|
|
|
private:
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2009-04-06 10:56:17 +00:00
|
|
|
// Virtual event handlers, overide them in your derived class
|
|
|
|
void Init();
|
|
|
|
virtual void OnCloseWindow( wxCloseEvent& event );
|
|
|
|
virtual void OnSaveCfgClick( wxCommandEvent& event );
|
|
|
|
virtual void OnRemoveLibClick( wxCommandEvent& event );
|
|
|
|
virtual void OnAddOrInsertLibClick( wxCommandEvent& event );
|
|
|
|
virtual void OnLibPathSelClick( wxCommandEvent& event );
|
|
|
|
virtual void OnOkClick( wxCommandEvent& event );
|
|
|
|
virtual void OnCancelClick( wxCommandEvent& event );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
|
2009-04-06 10:56:17 +00:00
|
|
|
public:
|
|
|
|
DIALOG_EESCHEMA_CONFIG( WinEDA_SchematicFrame * parent );
|
|
|
|
~DIALOG_EESCHEMA_CONFIG() {};
|
|
|
|
};
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
|
2009-04-06 10:56:17 +00:00
|
|
|
/******************************************************************/
|
|
|
|
void WinEDA_SchematicFrame::InstallConfigFrame( const wxPoint& pos )
|
|
|
|
/******************************************************************/
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2009-04-06 10:56:17 +00:00
|
|
|
DIALOG_EESCHEMA_CONFIG* CfgFrame = new DIALOG_EESCHEMA_CONFIG( this );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2009-04-06 10:56:17 +00:00
|
|
|
CfgFrame->ShowModal(); CfgFrame->Destroy();
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-04-06 10:56:17 +00:00
|
|
|
/*******************************************************************************/
|
|
|
|
DIALOG_EESCHEMA_CONFIG::DIALOG_EESCHEMA_CONFIG( WinEDA_SchematicFrame* parent )
|
|
|
|
: DIALOG_EESCHEMA_CONFIG_FBP( parent )
|
|
|
|
/*******************************************************************************/
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2009-04-06 10:56:17 +00:00
|
|
|
wxString msg;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2009-04-06 10:56:17 +00:00
|
|
|
m_Parent = parent;
|
|
|
|
m_LibListChanged = false;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2009-04-06 10:56:17 +00:00
|
|
|
Init();
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2009-04-06 10:56:17 +00:00
|
|
|
msg = _( "from " ) + wxGetApp().m_CurrentOptionFile;
|
|
|
|
SetTitle( msg );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2009-04-06 10:56:17 +00:00
|
|
|
if( GetSizer() )
|
|
|
|
GetSizer()->SetSizeHints( this );
|
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
|
2009-04-06 10:56:17 +00:00
|
|
|
/***********************************/
|
|
|
|
void DIALOG_EESCHEMA_CONFIG::Init()
|
|
|
|
/***********************************/
|
|
|
|
{
|
|
|
|
SetFont( *g_DialogFont );
|
|
|
|
SetFocus();
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2009-04-06 10:56:17 +00:00
|
|
|
// Display current files extension (info)
|
|
|
|
wxString msg = m_InfoCmpFileExt->GetLabel() + g_NetCmpExtBuffer;
|
|
|
|
m_InfoCmpFileExt->SetLabel( msg );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2009-04-06 10:56:17 +00:00
|
|
|
msg = m_InfoNetFileExt->GetLabel() + NetlistFileExtension;
|
|
|
|
m_InfoNetFileExt->SetLabel( msg );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2009-04-06 10:56:17 +00:00
|
|
|
msg = m_InfoLibFileExt->GetLabel() + CompLibFileExtension;
|
|
|
|
m_InfoLibFileExt->SetLabel( msg );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2009-04-06 10:56:17 +00:00
|
|
|
msg = m_InfoSymbFileExt->GetLabel() + g_SymbolExtBuffer;
|
|
|
|
m_InfoSymbFileExt->SetLabel( msg );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2009-04-06 10:56:17 +00:00
|
|
|
msg = m_InfoSchFileExt->GetLabel() + SchematicFileExtension;
|
|
|
|
m_InfoSchFileExt->SetLabel( msg );
|
2008-04-09 17:27:59 +00:00
|
|
|
|
2009-04-06 10:56:17 +00:00
|
|
|
// Init currently availlable netlist formats
|
2007-11-10 14:35:04 +00:00
|
|
|
wxArrayString NetlistNameItems;
|
2009-04-06 10:56:17 +00:00
|
|
|
NetlistNameItems.Add( wxT( "Pcbnew" ) );
|
|
|
|
NetlistNameItems.Add( wxT( "OrcadPcb2" ) );
|
|
|
|
NetlistNameItems.Add( wxT( "CadStar" ) );
|
|
|
|
NetlistNameItems.Add( wxT( "Spice" ) );
|
2009-04-10 13:39:03 +00:00
|
|
|
|
2009-04-06 10:56:17 +00:00
|
|
|
// Add extra neltlist format (using external converter)
|
2007-11-10 14:35:04 +00:00
|
|
|
msg = ReturnUserNetlistTypeName( true );
|
2009-04-06 10:56:17 +00:00
|
|
|
while( !msg.IsEmpty() )
|
2007-11-10 14:35:04 +00:00
|
|
|
{
|
2009-04-06 10:56:17 +00:00
|
|
|
NetlistNameItems.Add( msg );
|
2007-11-10 14:35:04 +00:00
|
|
|
msg = ReturnUserNetlistTypeName( false );
|
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2009-04-06 10:56:17 +00:00
|
|
|
m_NetFormatBox->InsertItems( NetlistNameItems, 0 );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2009-04-06 10:56:17 +00:00
|
|
|
if( g_NetFormat > (int) m_NetFormatBox->GetCount() )
|
|
|
|
g_NetFormat = NET_TYPE_PCBNEW;
|
|
|
|
m_NetFormatBox->SetSelection( g_NetFormat - NET_TYPE_PCBNEW );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2009-04-06 10:56:17 +00:00
|
|
|
m_ListLibr->InsertItems( g_LibName_List, 0 );
|
|
|
|
m_LibDirCtrl->SetValue( g_UserLibDirBuffer );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-04-06 10:56:17 +00:00
|
|
|
/******************************************************************/
|
|
|
|
void DIALOG_EESCHEMA_CONFIG::OnCancelClick( wxCommandEvent& event )
|
|
|
|
/******************************************************************/
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2009-04-06 10:56:17 +00:00
|
|
|
EndModal( -1 );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**************************************************************/
|
2009-04-06 10:56:17 +00:00
|
|
|
void DIALOG_EESCHEMA_CONFIG::OnOkClick( wxCommandEvent& event )
|
2007-06-05 12:10:51 +00:00
|
|
|
/**************************************************************/
|
|
|
|
{
|
2009-04-06 10:56:17 +00:00
|
|
|
// Set new netlist format
|
|
|
|
g_NetFormat = m_NetFormatBox->GetSelection() + NET_TYPE_PCBNEW;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2009-04-06 10:56:17 +00:00
|
|
|
// Set new default path lib
|
2009-04-10 13:39:03 +00:00
|
|
|
if ( g_UserLibDirBuffer != m_LibDirCtrl->GetValue() )
|
|
|
|
{
|
|
|
|
g_UserLibDirBuffer = m_LibDirCtrl->GetValue();
|
|
|
|
m_LibListChanged = true;
|
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2009-04-10 13:39:03 +00:00
|
|
|
// Set new active library list if the list of default path was modified
|
2009-04-06 10:56:17 +00:00
|
|
|
if( m_LibListChanged )
|
|
|
|
{
|
|
|
|
// Recreate lib list
|
|
|
|
g_LibName_List.Clear();
|
|
|
|
for ( unsigned ii = 0; ii < m_ListLibr->GetCount(); ii ++ )
|
|
|
|
g_LibName_List.Add(m_ListLibr->GetString(ii) );
|
2009-04-06 18:54:57 +00:00
|
|
|
|
2009-04-06 10:56:17 +00:00
|
|
|
// take new list in account
|
|
|
|
LoadLibraries( m_Parent );
|
|
|
|
if( m_Parent->m_ViewlibFrame )
|
|
|
|
m_Parent->m_ViewlibFrame->ReCreateListLib();
|
|
|
|
}
|
|
|
|
if ( event.GetId() != ID_SAVE_CFG )
|
|
|
|
EndModal( 0 );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2009-04-06 10:56:17 +00:00
|
|
|
/**************************************************************/
|
|
|
|
void DIALOG_EESCHEMA_CONFIG::OnCloseWindow( wxCloseEvent& event )
|
|
|
|
/**************************************************************/
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2009-04-06 10:56:17 +00:00
|
|
|
EndModal( 0 );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2009-02-07 20:11:09 +00:00
|
|
|
|
2008-04-09 17:27:59 +00:00
|
|
|
|
2009-04-06 10:56:17 +00:00
|
|
|
/*********************************************************************/
|
|
|
|
void DIALOG_EESCHEMA_CONFIG::OnRemoveLibClick( wxCommandEvent& event )
|
|
|
|
/*********************************************************************/
|
2009-04-09 13:21:26 +00:00
|
|
|
/* Remove a library to the library list.
|
|
|
|
* The real list (g_LibName_List) is not changed, so the change can be cancelled
|
|
|
|
*/
|
2009-04-06 10:56:17 +00:00
|
|
|
{
|
|
|
|
int ii;
|
2009-04-05 20:49:15 +00:00
|
|
|
|
2009-04-06 10:56:17 +00:00
|
|
|
ii = m_ListLibr->GetSelection();
|
|
|
|
if( ii < 0 )
|
|
|
|
return;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2009-04-06 10:56:17 +00:00
|
|
|
m_ListLibr->Delete(ii);
|
|
|
|
m_LibListChanged = TRUE;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-04-06 10:56:17 +00:00
|
|
|
/**************************************************************************/
|
|
|
|
void DIALOG_EESCHEMA_CONFIG::OnAddOrInsertLibClick( wxCommandEvent& event )
|
|
|
|
/**************************************************************************/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2009-04-09 13:21:26 +00:00
|
|
|
/* 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 cancelled
|
2009-04-06 10:56:17 +00:00
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2009-04-08 18:06:22 +00:00
|
|
|
int ii;
|
|
|
|
wxString tmp;
|
|
|
|
wxFileName fn;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2009-04-06 10:56:17 +00:00
|
|
|
ii = m_ListLibr->GetSelection();
|
2009-04-08 18:06:22 +00:00
|
|
|
if( ii == wxNOT_FOUND && event.GetId() != ID_ADD_LIB )
|
2009-04-06 10:56:17 +00:00
|
|
|
ii = 0;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2009-04-06 10:56:17 +00:00
|
|
|
wxString libpath = m_LibDirCtrl->GetValue();
|
|
|
|
if ( libpath.IsEmpty() )
|
|
|
|
libpath = g_RealLibDirBuffer;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2009-04-06 10:56:17 +00:00
|
|
|
wxFileDialog FilesDialog( this, _( "Library files:" ), libpath,
|
2009-04-08 18:06:22 +00:00
|
|
|
wxEmptyString, CompLibFileWildcard,
|
2009-04-06 10:56:17 +00:00
|
|
|
wxFD_DEFAULT_STYLE | wxFD_MULTIPLE );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2009-04-08 18:06:22 +00:00
|
|
|
if( FilesDialog.ShowModal() != wxID_OK )
|
2009-04-06 10:56:17 +00:00
|
|
|
return;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2009-04-06 10:56:17 +00:00
|
|
|
wxArrayString Filenames;
|
|
|
|
FilesDialog.GetPaths( Filenames );
|
|
|
|
|
|
|
|
for( unsigned jj = 0; jj < Filenames.GetCount(); jj++ )
|
|
|
|
{
|
2009-04-08 18:06:22 +00:00
|
|
|
fn = Filenames[jj];
|
|
|
|
|
|
|
|
/* 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 path. */
|
|
|
|
if( wxGetApp().GetLibraryPathList().Index( fn.GetPath() ) == wxNOT_FOUND )
|
|
|
|
tmp = fn.GetPathWithSep() + fn.GetName();
|
|
|
|
else
|
|
|
|
tmp = fn.GetName();
|
2009-04-06 10:56:17 +00:00
|
|
|
|
|
|
|
//Add or insert new library name, if not already in list
|
2009-04-08 18:06:22 +00:00
|
|
|
if( m_ListLibr->FindString( tmp, fn.IsCaseSensitive() ) == wxNOT_FOUND )
|
2009-04-06 10:56:17 +00:00
|
|
|
{
|
|
|
|
m_LibListChanged = TRUE;
|
2009-04-08 18:06:22 +00:00
|
|
|
if( event.GetId() == ID_ADD_LIB )
|
2009-04-09 13:21:26 +00:00
|
|
|
m_ListLibr->Append( tmp );
|
2009-04-08 18:06:22 +00:00
|
|
|
else
|
2009-04-09 13:21:26 +00:00
|
|
|
m_ListLibr->Insert( tmp, ii++ );
|
2009-04-06 10:56:17 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-04-08 18:06:22 +00:00
|
|
|
wxString msg = wxT( "<" ) + tmp + wxT( "> : " ) +
|
|
|
|
_( "Library already in use" );
|
2009-04-06 10:56:17 +00:00
|
|
|
DisplayError( this, msg );
|
|
|
|
}
|
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-04-06 10:56:17 +00:00
|
|
|
/*******************************************************************/
|
|
|
|
void DIALOG_EESCHEMA_CONFIG::OnSaveCfgClick( wxCommandEvent& event )
|
|
|
|
/*******************************************************************/
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2009-04-06 10:56:17 +00:00
|
|
|
OnOkClick( event );
|
|
|
|
m_Parent->Save_Config( this );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-04-06 10:56:17 +00:00
|
|
|
/***********************************************************************/
|
|
|
|
void DIALOG_EESCHEMA_CONFIG::OnLibPathSelClick( wxCommandEvent& event )
|
|
|
|
/***********************************************************************/
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2009-04-06 10:56:17 +00:00
|
|
|
wxString path = m_LibDirCtrl->GetValue();
|
|
|
|
if ( path.IsEmpty() )
|
|
|
|
path = g_RealLibDirBuffer;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2009-04-06 10:56:17 +00:00
|
|
|
bool select = EDA_DirectorySelector( _( " Default Path for libraries" ), /* Titre de la fenetre */
|
|
|
|
path, /* Chemin par defaut */
|
|
|
|
wxDD_DEFAULT_STYLE,
|
|
|
|
this, /* parent frame */
|
|
|
|
wxDefaultPosition );
|
2008-04-09 17:27:59 +00:00
|
|
|
|
2009-04-06 10:56:17 +00:00
|
|
|
if( !select )
|
|
|
|
return;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2009-04-06 10:56:17 +00:00
|
|
|
m_LibDirCtrl->SetValue( path );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|