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" ) );
|
|
|
|
|
|
|
|
// 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
|
|
|
|
g_UserLibDirBuffer = m_LibDirCtrl->GetValue();
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2009-04-06 10:56:17 +00:00
|
|
|
// Set new active lib list
|
|
|
|
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 )
|
|
|
|
/*********************************************************************/
|
|
|
|
{
|
|
|
|
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-06 10:56:17 +00:00
|
|
|
/* Insert or add a library to the existing library list:
|
|
|
|
* New library is put in list before (insert) or after (add)
|
|
|
|
* the selection
|
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2009-04-06 10:56:17 +00:00
|
|
|
int ii;
|
|
|
|
wxString FullLibName, ShortLibName, Mask;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2009-04-06 10:56:17 +00:00
|
|
|
ii = m_ListLibr->GetSelection();
|
|
|
|
if( ii < 0 )
|
|
|
|
ii = 0;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2009-04-06 10:56:17 +00:00
|
|
|
if( event.GetId() == ID_ADD_LIB )
|
|
|
|
{
|
|
|
|
if( m_ListLibr->GetCount() != 0 )
|
|
|
|
ii++; /* Add after selection */
|
|
|
|
}
|
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
|
|
|
Mask = wxT( "*" ) + CompLibFileExtension;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2009-04-06 10:56:17 +00:00
|
|
|
wxFileDialog FilesDialog( this, _( "Library files:" ), libpath,
|
|
|
|
wxEmptyString, Mask,
|
|
|
|
wxFD_DEFAULT_STYLE | wxFD_MULTIPLE );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2009-04-06 10:56:17 +00:00
|
|
|
int diag = FilesDialog.ShowModal();
|
|
|
|
if( diag != wxID_OK )
|
|
|
|
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++ )
|
|
|
|
{
|
|
|
|
FullLibName = Filenames[jj];
|
|
|
|
ShortLibName = MakeReducedFileName( FullLibName, libpath, CompLibFileExtension );
|
|
|
|
if( ShortLibName.IsEmpty() ) //Just in case...
|
|
|
|
continue;
|
|
|
|
|
|
|
|
//Add or insert new library name, if not already in list
|
|
|
|
#ifdef __WINDOWS__
|
|
|
|
bool case_sensitive = false;
|
|
|
|
#else
|
|
|
|
bool case_sensitive = true;
|
|
|
|
#endif
|
|
|
|
if( m_ListLibr->FindString( ShortLibName, case_sensitive ) == wxNOT_FOUND )
|
|
|
|
{
|
|
|
|
m_LibListChanged = TRUE;
|
|
|
|
m_ListLibr->Insert( ShortLibName, ii );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
wxString msg;
|
|
|
|
msg << wxT( "<" ) << ShortLibName << wxT( "> : " ) << _( "Library already in use" );
|
|
|
|
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
|
|
|
}
|