2008-02-26 19:19:54 +00:00
|
|
|
/******************************************************/
|
|
|
|
/** eeconfig.cpp : routines et menus de configuration */
|
|
|
|
/*******************************************************/
|
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
#include "fctsys.h"
|
2009-02-04 15:25:03 +00:00
|
|
|
#include "appl_wxstruct.h"
|
2009-01-29 14:26:20 +00:00
|
|
|
#include "gr_basic.h"
|
2007-06-05 12:10:51 +00:00
|
|
|
#include "common.h"
|
2009-02-04 15:25:03 +00:00
|
|
|
#include "id.h"
|
|
|
|
#include "class_drawpanel.h"
|
|
|
|
#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 "eeconfig.h"
|
|
|
|
#include "worksheet.h"
|
2007-09-06 11:52:26 +00:00
|
|
|
#include "hotkeys.h"
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* Variables locales */
|
|
|
|
|
|
|
|
|
2008-02-26 19:19:54 +00:00
|
|
|
#define HOTKEY_FILENAME wxT( "eeschema" )
|
2007-09-10 04:51:01 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/*********************************************************************/
|
2008-02-26 19:19:54 +00:00
|
|
|
void WinEDA_SchematicFrame::Process_Config( wxCommandEvent& event )
|
2007-06-05 12:10:51 +00:00
|
|
|
/*********************************************************************/
|
|
|
|
{
|
2009-04-05 20:49:15 +00:00
|
|
|
int id = event.GetId();
|
|
|
|
wxPoint pos;
|
|
|
|
wxFileName fn;
|
2008-02-26 19:19:54 +00:00
|
|
|
|
|
|
|
wxGetMousePosition( &pos.x, &pos.y );
|
|
|
|
|
|
|
|
pos.y += 5;
|
|
|
|
|
|
|
|
switch( id )
|
|
|
|
{
|
|
|
|
case ID_COLORS_SETUP:
|
|
|
|
DisplayColorSetupFrame( this, pos );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_CONFIG_REQ: // Creation de la fenetre de configuration
|
|
|
|
InstallConfigFrame( pos );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_OPTIONS_SETUP:
|
|
|
|
DisplayOptionFrame( this, pos );
|
2008-12-08 15:27:13 +00:00
|
|
|
DrawPanel->Refresh( TRUE ); // Redraw, because grid settings may have changed.
|
2008-02-26 19:19:54 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_CONFIG_SAVE:
|
|
|
|
Save_Config( this );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_CONFIG_READ:
|
|
|
|
{
|
2009-04-05 20:49:15 +00:00
|
|
|
fn = g_RootSheet->m_AssociatedScreen->m_FileName;
|
|
|
|
fn.SetExt( ProjectFileExtension );
|
|
|
|
|
|
|
|
wxFileDialog dlg( this, _( "Read Project File" ), fn.GetPath(),
|
|
|
|
fn.GetFullName(), ProjectFileWildcard,
|
|
|
|
wxFD_OPEN | wxFD_FILE_MUST_EXIST );
|
|
|
|
|
|
|
|
if( dlg.ShowModal() == wxID_CANCEL )
|
2008-02-26 19:19:54 +00:00
|
|
|
break;
|
2009-04-05 20:49:15 +00:00
|
|
|
|
|
|
|
Read_Config( fn.GetFullPath(), TRUE );
|
2008-02-26 19:19:54 +00:00
|
|
|
}
|
2008-12-08 15:27:13 +00:00
|
|
|
break;
|
2008-02-26 19:19:54 +00:00
|
|
|
|
|
|
|
case ID_PREFERENCES_CREATE_CONFIG_HOTKEYS:
|
2009-04-05 20:49:15 +00:00
|
|
|
fn = wxFileName( ReturnHotkeyConfigFilePath( g_ConfigFileLocationChoice ),
|
|
|
|
HOTKEY_FILENAME,
|
|
|
|
DEFAULT_HOTKEY_FILENAME_EXT );
|
|
|
|
WriteHotkeyConfigFile( fn.GetFullPath(), s_Eeschema_Hokeys_Descr, true );
|
2008-02-26 19:19:54 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_PREFERENCES_READ_CONFIG_HOTKEYS:
|
|
|
|
Read_Hotkey_Config( this, true );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_PREFERENCES_EDIT_CONFIG_HOTKEYS:
|
|
|
|
{
|
2009-04-05 20:49:15 +00:00
|
|
|
fn = wxFileName( ReturnHotkeyConfigFilePath( g_ConfigFileLocationChoice ),
|
|
|
|
HOTKEY_FILENAME, DEFAULT_HOTKEY_FILENAME_EXT );
|
|
|
|
wxString editorname = wxGetApp().GetEditorName();
|
2008-02-26 19:19:54 +00:00
|
|
|
if( !editorname.IsEmpty() )
|
2009-04-05 20:49:15 +00:00
|
|
|
ExecuteFile( this, editorname, QuoteFullPath( fn ) );
|
2008-02-26 19:19:54 +00:00
|
|
|
}
|
2008-12-08 15:27:13 +00:00
|
|
|
break;
|
2008-02-26 19:19:54 +00:00
|
|
|
|
|
|
|
case ID_PREFERENCES_HOTKEY_PATH_IS_HOME:
|
|
|
|
case ID_PREFERENCES_HOTKEY_PATH_IS_KICAD:
|
|
|
|
HandleHotkeyConfigMenuSelection( this, id );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_PREFERENCES_HOTKEY_SHOW_CURRENT_LIST: // Display Current hotkey list for eeschema
|
|
|
|
DisplayHotkeyList( this, s_Schematic_Hokeys_Descr );
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2009-04-05 20:49:15 +00:00
|
|
|
DisplayError( this, wxT( "WinEDA_SchematicFrame::Process_Config " \
|
|
|
|
"internal error" ) );
|
2008-02-26 19:19:54 +00:00
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-08-21 19:37:31 +00:00
|
|
|
/***************************************************************/
|
2008-02-26 19:19:54 +00:00
|
|
|
bool Read_Hotkey_Config( WinEDA_DrawFrame* frame, bool verbose )
|
2007-08-21 19:37:31 +00:00
|
|
|
/***************************************************************/
|
2008-02-26 19:19:54 +00:00
|
|
|
|
2007-08-21 19:37:31 +00:00
|
|
|
/*
|
|
|
|
* Read the hotkey files config for eeschema and libedit
|
2008-02-26 19:19:54 +00:00
|
|
|
*/
|
2007-08-21 19:37:31 +00:00
|
|
|
{
|
2008-12-08 15:27:13 +00:00
|
|
|
wxString FullFileName = ReturnHotkeyConfigFilePath(
|
|
|
|
g_ConfigFileLocationChoice );
|
2007-08-23 01:40:50 +00:00
|
|
|
|
2008-02-26 19:19:54 +00:00
|
|
|
FullFileName += HOTKEY_FILENAME;
|
|
|
|
FullFileName += DEFAULT_HOTKEY_FILENAME_EXT;
|
2008-12-08 15:27:13 +00:00
|
|
|
frame->ReadHotkeyConfigFile( FullFileName,
|
|
|
|
s_Eeschema_Hokeys_Descr,
|
|
|
|
verbose );
|
2008-02-26 19:19:54 +00:00
|
|
|
|
|
|
|
return TRUE;
|
2007-08-21 19:37:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/***********************************************************************/
|
2008-02-26 19:19:54 +00:00
|
|
|
bool Read_Config( const wxString& CfgFileName, bool ForceRereadConfig )
|
2007-06-05 12:10:51 +00:00
|
|
|
/***********************************************************************/
|
|
|
|
|
2008-02-26 19:19:54 +00:00
|
|
|
/* lit la configuration, si elle n'a pas deja ete lue
|
2008-12-08 15:27:13 +00:00
|
|
|
* 1 - lit <nom fichier root>.pro
|
|
|
|
* 2 - si non trouve lit <chemin des binaires>../template/kicad.pro
|
|
|
|
* 3 - si non trouve: init des variables aux valeurs par defaut
|
2008-02-26 19:19:54 +00:00
|
|
|
*
|
2008-12-08 15:27:13 +00:00
|
|
|
* Retourne TRUE si lu, FALSE si config non lue
|
2008-02-26 19:19:54 +00:00
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2009-04-05 20:49:15 +00:00
|
|
|
wxFileName fn;
|
2008-12-08 15:27:13 +00:00
|
|
|
bool IsRead = TRUE;
|
|
|
|
wxArrayString liblist_tmp = g_LibName_List;
|
|
|
|
WinEDA_SchematicFrame* frame;
|
|
|
|
|
|
|
|
frame = (WinEDA_SchematicFrame*)wxGetApp().GetTopWindow();
|
2008-02-26 19:19:54 +00:00
|
|
|
|
|
|
|
if( CfgFileName.IsEmpty() )
|
2009-04-05 20:49:15 +00:00
|
|
|
fn = g_RootSheet->m_AssociatedScreen->m_FileName;
|
2008-02-26 19:19:54 +00:00
|
|
|
else
|
2009-04-05 20:49:15 +00:00
|
|
|
fn = CfgFileName;
|
2008-02-26 19:19:54 +00:00
|
|
|
g_LibName_List.Clear();
|
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
/* Change the schematic file extension (.sch) to the project file
|
|
|
|
* extension (.pro). */
|
|
|
|
fn.SetExt( ProjectFileExtension );
|
|
|
|
|
2009-04-09 18:39:39 +00:00
|
|
|
wxGetApp().RemoveLibraryPath( g_UserLibDirBuffer );
|
2009-04-05 20:49:15 +00:00
|
|
|
|
|
|
|
if( !wxGetApp().ReadProjectConfig( fn.GetFullPath(), GROUP, ParamCfgList,
|
|
|
|
ForceRereadConfig ? FALSE : TRUE ) )
|
2008-02-26 19:19:54 +00:00
|
|
|
{
|
|
|
|
g_LibName_List = liblist_tmp;
|
|
|
|
IsRead = FALSE;
|
|
|
|
}
|
|
|
|
|
2009-04-09 18:39:39 +00:00
|
|
|
/* User library path takes precedent over default library search paths. */
|
|
|
|
wxGetApp().InsertLibraryPath( g_UserLibDirBuffer, 1 );
|
2008-02-26 19:19:54 +00:00
|
|
|
|
|
|
|
// If the list is void, load the libraries "power.lib" and "device.lib"
|
|
|
|
if( g_LibName_List.GetCount() == 0 )
|
|
|
|
{
|
|
|
|
g_LibName_List.Add( wxT( "power" ) );
|
|
|
|
g_LibName_List.Add( wxT( "device" ) );
|
|
|
|
}
|
|
|
|
|
2008-12-08 15:27:13 +00:00
|
|
|
if( frame )
|
2008-02-26 19:19:54 +00:00
|
|
|
{
|
2008-12-08 15:27:13 +00:00
|
|
|
frame->SetDrawBgColor( g_DrawBgColor );
|
2008-02-26 19:19:54 +00:00
|
|
|
}
|
|
|
|
|
2008-12-08 15:27:13 +00:00
|
|
|
LoadLibraries( frame );
|
2008-02-26 19:19:54 +00:00
|
|
|
|
|
|
|
return IsRead;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/****************************************************************/
|
2008-02-26 19:19:54 +00:00
|
|
|
void WinEDA_SchematicFrame::Save_Config( wxWindow* displayframe )
|
2007-06-05 12:10:51 +00:00
|
|
|
/***************************************************************/
|
|
|
|
{
|
2009-04-05 20:49:15 +00:00
|
|
|
wxFileName fn;
|
|
|
|
|
|
|
|
fn = g_RootSheet->m_AssociatedScreen->m_FileName /*ConfigFileName*/;
|
|
|
|
fn.SetExt( ProjectFileExtension );
|
|
|
|
|
|
|
|
wxFileDialog dlg( this, _( "Save Project Settings" ), wxGetCwd(),
|
|
|
|
fn.GetFullName(), ProjectFileWildcard,
|
|
|
|
wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
|
|
|
|
|
|
|
|
if( dlg.ShowModal() == wxID_CANCEL )
|
2008-02-26 19:19:54 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
/* ecriture de la configuration */
|
2009-04-05 20:49:15 +00:00
|
|
|
wxGetApp().WriteProjectConfig( dlg.GetPath(), GROUP, ParamCfgList );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Load the EESchema configuration parameters.
|
|
|
|
*/
|
|
|
|
void WinEDA_SchematicFrame::LoadSettings()
|
|
|
|
{
|
|
|
|
WinEDA_DrawFrame::LoadSettings();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Save the EESchema configuration parameters.
|
|
|
|
*/
|
|
|
|
void WinEDA_SchematicFrame::SaveSettings()
|
|
|
|
{
|
|
|
|
WinEDA_DrawFrame::SaveSettings();
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|