2007-06-05 12:10:51 +00:00
|
|
|
/******************************************************/
|
|
|
|
/** eeconfig.cpp : routines et menus de configuration */
|
2007-09-20 09:13:40 +00:00
|
|
|
/*******************************************************/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
#include "fctsys.h"
|
|
|
|
#include "common.h"
|
|
|
|
#include "program.h"
|
|
|
|
#include "libcmp.h"
|
|
|
|
#include "general.h"
|
|
|
|
#include "protos.h"
|
|
|
|
#include "eeconfig.h"
|
|
|
|
#include "worksheet.h"
|
2007-08-21 19:37:31 +00:00
|
|
|
#include "hotkeys_basic.h"
|
2007-09-06 11:52:26 +00:00
|
|
|
#include "hotkeys.h"
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
#include "id.h"
|
|
|
|
|
|
|
|
/* Variables locales */
|
|
|
|
|
|
|
|
|
2007-09-10 04:51:01 +00:00
|
|
|
#define HOTKEY_FILENAME wxT("eeschema")
|
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/*********************************************************************/
|
|
|
|
void WinEDA_SchematicFrame::Process_Config(wxCommandEvent& event)
|
|
|
|
/*********************************************************************/
|
|
|
|
{
|
|
|
|
int id = event.GetId();
|
|
|
|
wxPoint pos;
|
2007-08-21 19:37:31 +00:00
|
|
|
wxString FullFileName;
|
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
wxGetMousePosition(&pos.x, &pos.y);
|
|
|
|
|
|
|
|
pos.y += 5;
|
|
|
|
switch ( id )
|
2007-09-24 07:14:01 +00:00
|
|
|
{
|
2007-06-05 12:10:51 +00:00
|
|
|
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);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_CONFIG_SAVE:
|
|
|
|
Save_Config(this);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_CONFIG_READ:
|
2007-09-24 07:14:01 +00:00
|
|
|
{
|
2007-06-05 12:10:51 +00:00
|
|
|
wxString mask( wxT("*") ); mask += g_Prj_Config_Filename_ext;
|
2007-08-21 19:37:31 +00:00
|
|
|
FullFileName = ScreenSch->m_FileName;
|
2007-06-05 12:10:51 +00:00
|
|
|
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 */
|
|
|
|
mask, /* Masque d'affichage */
|
|
|
|
this,
|
|
|
|
wxFD_OPEN,
|
|
|
|
TRUE /* ne change pas de repertoire courant */
|
|
|
|
);
|
|
|
|
if ( FullFileName.IsEmpty() ) break;
|
|
|
|
if ( ! wxFileExists(FullFileName) )
|
2007-09-24 07:14:01 +00:00
|
|
|
{
|
2007-06-05 12:10:51 +00:00
|
|
|
wxString msg = _("File ") + FullFileName +_("not found");;
|
|
|
|
DisplayError(this, msg); break;
|
|
|
|
}
|
2007-09-24 07:14:01 +00:00
|
|
|
Read_Config(FullFileName, TRUE );
|
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
break;
|
|
|
|
|
2007-08-21 19:37:31 +00:00
|
|
|
case ID_PREFERENCES_CREATE_CONFIG_HOTKEYS:
|
2007-09-19 15:29:50 +00:00
|
|
|
FullFileName = ReturnHotkeyConfigFilePath( g_ConfigFileLocationChoice );
|
2007-09-10 04:51:01 +00:00
|
|
|
FullFileName += HOTKEY_FILENAME;
|
2007-08-21 19:37:31 +00:00
|
|
|
FullFileName += DEFAULT_HOTKEY_FILENAME_EXT;
|
2007-09-06 11:52:26 +00:00
|
|
|
WriteHotkeyConfigFile(FullFileName, s_Eeschema_Hokeys_Descr, true);
|
2007-08-21 19:37:31 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_PREFERENCES_READ_CONFIG_HOTKEYS:
|
|
|
|
Read_Hotkey_Config( this, true);
|
|
|
|
break;
|
|
|
|
|
2007-09-19 15:29:50 +00:00
|
|
|
case ID_PREFERENCES_EDIT_CONFIG_HOTKEYS:
|
2007-09-24 07:14:01 +00:00
|
|
|
{
|
2007-09-19 15:29:50 +00:00
|
|
|
FullFileName = ReturnHotkeyConfigFilePath( g_ConfigFileLocationChoice );
|
|
|
|
FullFileName += HOTKEY_FILENAME;
|
|
|
|
FullFileName += DEFAULT_HOTKEY_FILENAME_EXT;
|
|
|
|
wxString editorname = GetEditorName();
|
|
|
|
if ( !editorname.IsEmpty() )
|
|
|
|
ExecuteFile(this, editorname, FullFileName);
|
2007-09-24 07:14:01 +00:00
|
|
|
}
|
2007-09-19 15:29:50 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_PREFERENCES_HOTKEY_PATH_IS_HOME:
|
|
|
|
case ID_PREFERENCES_HOTKEY_PATH_IS_KICAD:
|
2007-09-20 09:13:40 +00:00
|
|
|
HandleHotkeyConfigMenuSelection( this, id );
|
2007-09-19 15:29:50 +00:00
|
|
|
break;
|
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
default:
|
|
|
|
DisplayError(this, wxT("WinEDA_SchematicFrame::Process_Config internal error") );
|
2007-09-24 07:14:01 +00:00
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-08-21 19:37:31 +00:00
|
|
|
/***************************************************************/
|
|
|
|
bool Read_Hotkey_Config( WinEDA_DrawFrame * frame, bool verbose )
|
|
|
|
/***************************************************************/
|
|
|
|
/*
|
|
|
|
* Read the hotkey files config for eeschema and libedit
|
|
|
|
*/
|
|
|
|
{
|
2007-09-19 15:29:50 +00:00
|
|
|
wxString FullFileName = ReturnHotkeyConfigFilePath( g_ConfigFileLocationChoice );
|
2007-09-10 04:51:01 +00:00
|
|
|
FullFileName += HOTKEY_FILENAME;
|
2007-08-21 19:37:31 +00:00
|
|
|
FullFileName += DEFAULT_HOTKEY_FILENAME_EXT;
|
2007-09-06 11:52:26 +00:00
|
|
|
frame->ReadHotkeyConfigFile(FullFileName, s_Eeschema_Hokeys_Descr, verbose);
|
2007-08-23 01:40:50 +00:00
|
|
|
|
|
|
|
return TRUE;
|
2007-08-21 19:37:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/***********************************************************************/
|
|
|
|
bool Read_Config( const wxString & CfgFileName, bool ForceRereadConfig )
|
|
|
|
/***********************************************************************/
|
|
|
|
/* lit la configuration, si elle n'a pas deja ete lue
|
|
|
|
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
|
|
|
|
|
|
|
|
Retourne TRUE si lu, FALSE si config non lue
|
|
|
|
*/
|
|
|
|
{
|
|
|
|
wxString FullFileName;
|
|
|
|
bool IsRead = TRUE;
|
|
|
|
wxArrayString liblist_tmp = g_LibName_List;
|
|
|
|
|
|
|
|
if ( CfgFileName.IsEmpty() ) FullFileName = ScreenSch->m_FileName;
|
|
|
|
else FullFileName = CfgFileName;
|
|
|
|
g_LibName_List.Clear();
|
|
|
|
|
|
|
|
if ( ! EDA_Appl->ReadProjectConfig(FullFileName,
|
|
|
|
GROUP, ParamCfgList, ForceRereadConfig ? FALSE : TRUE) ) // Config non lue
|
|
|
|
{
|
|
|
|
g_LibName_List = liblist_tmp;
|
|
|
|
IsRead = FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Traitement des variables particulieres: */
|
|
|
|
SetRealLibraryPath( wxT("library") );
|
|
|
|
|
|
|
|
// 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") );
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( EDA_Appl->SchematicFrame )
|
|
|
|
{
|
|
|
|
EDA_Appl->SchematicFrame->SetDrawBgColor(g_DrawBgColor);
|
|
|
|
EDA_Appl->SchematicFrame->m_Draw_Grid = g_ShowGrid;
|
|
|
|
}
|
|
|
|
|
|
|
|
LoadLibraries(EDA_Appl->SchematicFrame);
|
|
|
|
|
|
|
|
return IsRead;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/****************************************************************/
|
|
|
|
void WinEDA_SchematicFrame::Save_Config(wxWindow * displayframe)
|
|
|
|
/***************************************************************/
|
|
|
|
{
|
|
|
|
wxString path;
|
|
|
|
wxString FullFileName;
|
|
|
|
wxString mask( wxT("*") );
|
|
|
|
|
|
|
|
mask += g_Prj_Config_Filename_ext;
|
|
|
|
FullFileName = ScreenSch->m_FileName.AfterLast('/') /*ConfigFileName*/;
|
|
|
|
ChangeFileNameExt( FullFileName, g_Prj_Config_Filename_ext );
|
|
|
|
|
|
|
|
path = wxGetCwd();
|
2007-09-14 10:07:38 +00:00
|
|
|
FullFileName = EDA_FileSelector(_("Save preferences"),
|
2007-06-05 12:10:51 +00:00
|
|
|
path, /* Chemin par defaut */
|
|
|
|
FullFileName, /* nom fichier par defaut */
|
|
|
|
g_Prj_Config_Filename_ext, /* extension par defaut */
|
|
|
|
mask, /* Masque d'affichage */
|
|
|
|
displayframe,
|
|
|
|
wxFD_SAVE,
|
|
|
|
TRUE
|
|
|
|
);
|
|
|
|
if ( FullFileName.IsEmpty() ) return;
|
|
|
|
|
|
|
|
/* ecriture de la configuration */
|
|
|
|
EDA_Appl->WriteProjectConfig(FullFileName, GROUP, ParamCfgList);
|
|
|
|
}
|
2007-09-24 07:14:01 +00:00
|
|
|
|