beautify
This commit is contained in:
parent
ce04867e84
commit
8eff8df94b
|
@ -277,7 +277,7 @@ wxString ReturnPcbLayerName( int layer_number, bool omitSpacePadding )
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
|
|
||||||
#if 0 && defined(DEBUG)
|
#if 1 && defined(DEBUG)
|
||||||
|
|
||||||
// Dick: this code is working fine, but we have no place to store the layer names yet.
|
// Dick: this code is working fine, but we have no place to store the layer names yet.
|
||||||
|
|
||||||
|
@ -293,12 +293,12 @@ wxString ReturnPcbLayerName( int layer_number, bool omitSpacePadding )
|
||||||
#if 1 // my specific layer names
|
#if 1 // my specific layer names
|
||||||
static const wxString layer_name_list[] = {
|
static const wxString layer_name_list[] = {
|
||||||
_( "H2 Bottom" ), _( "Power" ), _( "V2 Signal" ), _( "H1 Signal" ),
|
_( "H2 Bottom" ), _( "Power" ), _( "V2 Signal" ), _( "H1 Signal" ),
|
||||||
_( "Ground" ), _( "Inner L5 " ), _( "Inner L6 " ), _( "Inner L7 " ),
|
_( "Ground" ), _( "Inner L5" ), _( "Inner L6" ), _( "Inner L7" ),
|
||||||
_( "Inner L8 " ), _( "Inner L9 " ), _( "Inner L10" ), _( "Inner L11" ),
|
_( "Inner L8" ), _( "Inner L9" ), _( "Inner L10" ), _( "Inner L11" ),
|
||||||
_( "Inner L12" ), _( "Inner L13" ), _( "Inner L14" ), _( "Component" ),
|
_( "Inner L12" ), _( "Inner L13" ), _( "Inner L14" ), _( "Component" ),
|
||||||
_( "Adhes Cop" ), _( "Adhes Cmp" ), _( "SoldP Cop" ), _( "SoldP Cmp" ),
|
_( "Adhes Cop" ), _( "Adhes Cmp" ), _( "SoldP Cop" ), _( "SoldP Cmp" ),
|
||||||
_( "SilkS Cop" ), _( "SilkS Cmp" ), _( "Mask Cop " ), _( "Mask Cmp " ),
|
_( "SilkS Cop" ), _( "SilkS Cmp" ), _( "Mask Cop" ), _( "Mask Cmp" ),
|
||||||
_( "Drawings " ), _( "Comments " ), _( "Eco1 " ), _( "Eco2 " ),
|
_( "Drawings " ), _( "Comments" ), _( "Eco1" ), _( "Eco2" ),
|
||||||
_( "Edges Pcb" ), _( "BAD INDEX" ),
|
_( "Edges Pcb" ), _( "BAD INDEX" ),
|
||||||
};
|
};
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -118,8 +118,8 @@ void WinEDA_App::InitEDA_Appl( const wxString& name )
|
||||||
|
|
||||||
/* Init kicad environment
|
/* Init kicad environment
|
||||||
* the environment variable KICAD (if exists) gives the kicad path:
|
* the environment variable KICAD (if exists) gives the kicad path:
|
||||||
* something like set KICAD=d:\kicad
|
* something like set KICAD=d:\kicad
|
||||||
*/
|
*/
|
||||||
m_Env_Defined = wxGetEnv( wxT( "KICAD" ), &m_KicadEnv );
|
m_Env_Defined = wxGetEnv( wxT( "KICAD" ), &m_KicadEnv );
|
||||||
if( m_Env_Defined ) // ensure m_KicadEnv ends by "/"
|
if( m_Env_Defined ) // ensure m_KicadEnv ends by "/"
|
||||||
{
|
{
|
||||||
|
@ -214,7 +214,7 @@ bool WinEDA_App::SetBinDir()
|
||||||
if (str == NULL) return false;
|
if (str == NULL) return false;
|
||||||
char *native_str = NULL;
|
char *native_str = NULL;
|
||||||
int len = CFStringGetMaximumSizeForEncoding(CFStringGetLength(str),
|
int len = CFStringGetMaximumSizeForEncoding(CFStringGetLength(str),
|
||||||
kCFStringEncodingUTF8) + 1;
|
kCFStringEncodingUTF8) + 1;
|
||||||
native_str = new char[len];
|
native_str = new char[len];
|
||||||
CFStringGetCString(str, native_str, len, kCFStringEncodingUTF8);
|
CFStringGetCString(str, native_str, len, kCFStringEncodingUTF8);
|
||||||
m_BinDir = CONV_FROM_UTF8(native_str);
|
m_BinDir = CONV_FROM_UTF8(native_str);
|
||||||
|
@ -270,7 +270,8 @@ void WinEDA_App::GetSettings()
|
||||||
wxString Line, Ident;
|
wxString Line, Ident;
|
||||||
unsigned ii;
|
unsigned ii;
|
||||||
|
|
||||||
m_HelpSize.x = 500; m_HelpSize.y = 400;
|
m_HelpSize.x = 500;
|
||||||
|
m_HelpSize.y = 400;
|
||||||
|
|
||||||
if( m_EDA_CommonConfig )
|
if( m_EDA_CommonConfig )
|
||||||
{
|
{
|
||||||
|
@ -285,8 +286,11 @@ void WinEDA_App::GetSettings()
|
||||||
|
|
||||||
for( ii = 0; ii < 10; ii++ )
|
for( ii = 0; ii < 10; ii++ )
|
||||||
{
|
{
|
||||||
Ident = wxT( "LastProject" ); if( ii )
|
Ident = wxT( "LastProject" );
|
||||||
|
|
||||||
|
if( ii )
|
||||||
Ident << ii;
|
Ident << ii;
|
||||||
|
|
||||||
if( m_EDA_Config->Read( Ident, &Line ) )
|
if( m_EDA_Config->Read( Ident, &Line ) )
|
||||||
m_LastProject.Add( Line );
|
m_LastProject.Add( Line );
|
||||||
}
|
}
|
||||||
|
@ -299,6 +303,7 @@ void WinEDA_App::GetSettings()
|
||||||
Line = m_EDA_Config->Read( wxT( "SdtFontType" ), wxEmptyString );
|
Line = m_EDA_Config->Read( wxT( "SdtFontType" ), wxEmptyString );
|
||||||
if( !Line.IsEmpty() )
|
if( !Line.IsEmpty() )
|
||||||
g_StdFont->SetFaceName( Line );
|
g_StdFont->SetFaceName( Line );
|
||||||
|
|
||||||
ii = m_EDA_Config->Read( wxT( "SdtFontStyle" ), wxFONTFAMILY_ROMAN );
|
ii = m_EDA_Config->Read( wxT( "SdtFontStyle" ), wxFONTFAMILY_ROMAN );
|
||||||
g_StdFont->SetStyle( ii );
|
g_StdFont->SetStyle( ii );
|
||||||
ii = m_EDA_Config->Read( wxT( "SdtFontWeight" ), wxNORMAL );
|
ii = m_EDA_Config->Read( wxT( "SdtFontWeight" ), wxNORMAL );
|
||||||
|
@ -309,6 +314,7 @@ void WinEDA_App::GetSettings()
|
||||||
Line = m_EDA_Config->Read( wxT( "MsgFontType" ), wxEmptyString );
|
Line = m_EDA_Config->Read( wxT( "MsgFontType" ), wxEmptyString );
|
||||||
if( !Line.IsEmpty() )
|
if( !Line.IsEmpty() )
|
||||||
g_MsgFont->SetFaceName( Line );
|
g_MsgFont->SetFaceName( Line );
|
||||||
|
|
||||||
ii = m_EDA_Config->Read( wxT( "MsgFontStyle" ), wxFONTFAMILY_ROMAN );
|
ii = m_EDA_Config->Read( wxT( "MsgFontStyle" ), wxFONTFAMILY_ROMAN );
|
||||||
g_MsgFont->SetStyle( ii );
|
g_MsgFont->SetStyle( ii );
|
||||||
ii = m_EDA_Config->Read( wxT( "MsgFontWeight" ), wxNORMAL );
|
ii = m_EDA_Config->Read( wxT( "MsgFontWeight" ), wxNORMAL );
|
||||||
|
@ -318,6 +324,7 @@ void WinEDA_App::GetSettings()
|
||||||
Line = m_EDA_Config->Read( wxT( "DialogFontType" ), wxEmptyString );
|
Line = m_EDA_Config->Read( wxT( "DialogFontType" ), wxEmptyString );
|
||||||
if( !Line.IsEmpty() )
|
if( !Line.IsEmpty() )
|
||||||
g_DialogFont->SetFaceName( Line );
|
g_DialogFont->SetFaceName( Line );
|
||||||
|
|
||||||
ii = m_EDA_Config->Read( wxT( "DialogFontStyle" ), wxFONTFAMILY_ROMAN );
|
ii = m_EDA_Config->Read( wxT( "DialogFontStyle" ), wxFONTFAMILY_ROMAN );
|
||||||
g_DialogFont->SetStyle( ii );
|
g_DialogFont->SetStyle( ii );
|
||||||
ii = m_EDA_Config->Read( wxT( "DialogFontWeight" ), wxNORMAL );
|
ii = m_EDA_Config->Read( wxT( "DialogFontWeight" ), wxNORMAL );
|
||||||
|
@ -343,7 +350,6 @@ void WinEDA_App::SaveSettings()
|
||||||
{
|
{
|
||||||
unsigned int ii;
|
unsigned int ii;
|
||||||
|
|
||||||
|
|
||||||
if( m_EDA_Config == NULL )
|
if( m_EDA_Config == NULL )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/**************************************************/
|
/**************************************************/
|
||||||
/* projet_config : routines de trace du cartouche */
|
/* projet_config : routines de trace du cartouche */
|
||||||
/**************************************************/
|
/**************************************************/
|
||||||
|
|
||||||
#include "fctsys.h"
|
#include "fctsys.h"
|
||||||
#include "gr_basic.h"
|
#include "gr_basic.h"
|
||||||
|
@ -13,341 +13,386 @@
|
||||||
|
|
||||||
|
|
||||||
/*********************************************************************/
|
/*********************************************************************/
|
||||||
static bool ReCreatePrjConfig(const wxString & local_config_filename,
|
static bool ReCreatePrjConfig( const wxString& local_config_filename,
|
||||||
const wxString & GroupName, bool ForceUseLocalConfig)
|
const wxString& GroupName, bool ForceUseLocalConfig )
|
||||||
/*********************************************************************/
|
/*********************************************************************/
|
||||||
|
|
||||||
/* Cree ou recree la configuration locale de kicad (filename.pro)
|
/* Cree ou recree la configuration locale de kicad (filename.pro)
|
||||||
initialise:
|
* initialise:
|
||||||
g_Prj_Config
|
* g_Prj_Config
|
||||||
g_Prj_Config_LocalFilename
|
* g_Prj_Config_LocalFilename
|
||||||
g_Prj_Default_Config_FullFilename
|
* g_Prj_Default_Config_FullFilename
|
||||||
return:
|
* return:
|
||||||
TRUE si config locale
|
* TRUE si config locale
|
||||||
FALSE si default config
|
* FALSE si default config
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
// free old config
|
// free old config
|
||||||
if ( g_Prj_Config ) delete g_Prj_Config;
|
if( g_Prj_Config )
|
||||||
g_Prj_Config = NULL;
|
delete g_Prj_Config;
|
||||||
|
g_Prj_Config = NULL;
|
||||||
|
|
||||||
// Init local Config filename
|
// Init local Config filename
|
||||||
if ( local_config_filename.IsEmpty() ) g_Prj_Config_LocalFilename = wxT("kicad");
|
if( local_config_filename.IsEmpty() )
|
||||||
else g_Prj_Config_LocalFilename = local_config_filename;
|
g_Prj_Config_LocalFilename = wxT( "kicad" );
|
||||||
|
else
|
||||||
|
g_Prj_Config_LocalFilename = local_config_filename;
|
||||||
|
|
||||||
ChangeFileNameExt( g_Prj_Config_LocalFilename, g_Prj_Config_Filename_ext );
|
ChangeFileNameExt( g_Prj_Config_LocalFilename, g_Prj_Config_Filename_ext );
|
||||||
|
|
||||||
// Init local config filename
|
// Init local config filename
|
||||||
if ( ForceUseLocalConfig || wxFileExists(g_Prj_Config_LocalFilename) )
|
if( ForceUseLocalConfig || wxFileExists( g_Prj_Config_LocalFilename ) )
|
||||||
{
|
{
|
||||||
g_Prj_Default_Config_FullFilename.Empty();
|
g_Prj_Default_Config_FullFilename.Empty();
|
||||||
g_Prj_Config = new wxFileConfig(wxEmptyString, wxEmptyString,
|
g_Prj_Config = new wxFileConfig( wxEmptyString, wxEmptyString,
|
||||||
g_Prj_Config_LocalFilename, wxEmptyString,
|
g_Prj_Config_LocalFilename, wxEmptyString,
|
||||||
wxCONFIG_USE_RELATIVE_PATH);
|
wxCONFIG_USE_RELATIVE_PATH );
|
||||||
g_Prj_Config->DontCreateOnDemand();
|
|
||||||
|
|
||||||
if ( ForceUseLocalConfig ) return TRUE;
|
g_Prj_Config->DontCreateOnDemand();
|
||||||
|
|
||||||
// Test de la bonne version du fichier (ou groupe) de configuration
|
if( ForceUseLocalConfig )
|
||||||
int version = -1, def_version = 0;
|
return TRUE;
|
||||||
g_Prj_Config->SetPath(GroupName);
|
|
||||||
version = g_Prj_Config->Read( wxT("version"), def_version);
|
// Test de la bonne version du fichier (ou groupe) de configuration
|
||||||
g_Prj_Config->SetPath(UNIX_STRING_DIR_SEP);
|
int version = -1, def_version = 0;
|
||||||
if ( version > 0 ) return TRUE;
|
g_Prj_Config->SetPath( GroupName );
|
||||||
else delete g_Prj_Config; // Version incorrecte
|
version = g_Prj_Config->Read( wxT( "version" ), def_version );
|
||||||
}
|
g_Prj_Config->SetPath( UNIX_STRING_DIR_SEP );
|
||||||
|
if( version > 0 )
|
||||||
|
return TRUE;
|
||||||
|
else
|
||||||
|
delete g_Prj_Config; // Version incorrecte
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Fichier local non trouve ou invalide
|
// Fichier local non trouve ou invalide
|
||||||
g_Prj_Config_LocalFilename.Empty();
|
g_Prj_Config_LocalFilename.Empty();
|
||||||
g_Prj_Default_Config_FullFilename =
|
g_Prj_Default_Config_FullFilename =
|
||||||
ReturnKicadDatasPath() +
|
ReturnKicadDatasPath() +
|
||||||
wxT("template/kicad") +
|
wxT( "template/kicad" ) +
|
||||||
g_Prj_Config_Filename_ext;
|
g_Prj_Config_Filename_ext;
|
||||||
|
|
||||||
// Recreate new config
|
// Recreate new config
|
||||||
g_Prj_Config = new wxFileConfig(wxEmptyString, wxEmptyString,
|
g_Prj_Config = new wxFileConfig( wxEmptyString, wxEmptyString,
|
||||||
wxEmptyString, g_Prj_Default_Config_FullFilename,
|
wxEmptyString, g_Prj_Default_Config_FullFilename,
|
||||||
wxCONFIG_USE_RELATIVE_PATH);
|
wxCONFIG_USE_RELATIVE_PATH );
|
||||||
g_Prj_Config->DontCreateOnDemand();
|
|
||||||
|
|
||||||
return FALSE;
|
g_Prj_Config->DontCreateOnDemand();
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/***************************************************************************************/
|
/***************************************************************************************/
|
||||||
void WinEDA_App::WriteProjectConfig(const wxString & local_config_filename,
|
void WinEDA_App::WriteProjectConfig( const wxString& local_config_filename,
|
||||||
const wxString & GroupName, PARAM_CFG_BASE ** List)
|
const wxString& GroupName, PARAM_CFG_BASE** List )
|
||||||
/***************************************************************************************/
|
/***************************************************************************************/
|
||||||
/* enregistrement de la config "projet"*/
|
/* enregistrement de la config "projet"*/
|
||||||
{
|
{
|
||||||
const PARAM_CFG_BASE * pt_cfg;
|
const PARAM_CFG_BASE* pt_cfg;
|
||||||
wxString msg;
|
wxString msg;
|
||||||
|
|
||||||
ReCreatePrjConfig(local_config_filename, GroupName,
|
ReCreatePrjConfig( local_config_filename, GroupName,
|
||||||
FORCE_LOCAL_CONFIG);
|
FORCE_LOCAL_CONFIG );
|
||||||
/* Write date ( surtout pour eviter bug de wxFileConfig
|
|
||||||
qui se trompe de rubrique si declaration [xx] en premiere ligne
|
|
||||||
(en fait si groupe vide) */
|
|
||||||
g_Prj_Config->SetPath(UNIX_STRING_DIR_SEP);
|
|
||||||
msg = DateAndTime();
|
|
||||||
g_Prj_Config->Write( wxT("update"), msg);
|
|
||||||
msg = GetAppName();
|
|
||||||
g_Prj_Config->Write( wxT("last_client"), msg);
|
|
||||||
|
|
||||||
/* ecriture de la configuration */
|
/* Write date ( surtout pour eviter bug de wxFileConfig
|
||||||
g_Prj_Config->DeleteGroup(GroupName); // Erase all datas
|
* qui se trompe de rubrique si declaration [xx] en premiere ligne
|
||||||
g_Prj_Config->Flush();
|
* (en fait si groupe vide) */
|
||||||
|
g_Prj_Config->SetPath( UNIX_STRING_DIR_SEP );
|
||||||
|
msg = DateAndTime();
|
||||||
|
|
||||||
g_Prj_Config->SetPath(GroupName);
|
g_Prj_Config->Write( wxT( "update" ), msg );
|
||||||
g_Prj_Config->Write( wxT("version"), CONFIG_VERSION);
|
msg = GetAppName();
|
||||||
g_Prj_Config->SetPath(UNIX_STRING_DIR_SEP);
|
|
||||||
|
|
||||||
for( ; *List != NULL ; List++)
|
g_Prj_Config->Write( wxT( "last_client" ), msg );
|
||||||
{
|
|
||||||
pt_cfg = *List;
|
|
||||||
if ( pt_cfg->m_Group ) g_Prj_Config->SetPath(pt_cfg->m_Group);
|
|
||||||
else g_Prj_Config->SetPath(GroupName);
|
|
||||||
|
|
||||||
switch( pt_cfg->m_Type )
|
/* ecriture de la configuration */
|
||||||
{
|
g_Prj_Config->DeleteGroup( GroupName ); // Erase all datas
|
||||||
case PARAM_INT:
|
g_Prj_Config->Flush();
|
||||||
#undef PTCFG
|
|
||||||
#define PTCFG ((PARAM_CFG_INT *)pt_cfg)
|
|
||||||
if (PTCFG->m_Pt_param == NULL) break;
|
|
||||||
if ( pt_cfg->m_Setup)
|
|
||||||
m_EDA_Config->Write(pt_cfg->m_Ident, *PTCFG->m_Pt_param);
|
|
||||||
else
|
|
||||||
g_Prj_Config->Write(pt_cfg->m_Ident, *PTCFG->m_Pt_param);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case PARAM_SETCOLOR:
|
g_Prj_Config->SetPath( GroupName );
|
||||||
#undef PTCFG
|
g_Prj_Config->Write( wxT( "version" ), CONFIG_VERSION );
|
||||||
#define PTCFG ((PARAM_CFG_SETCOLOR *)pt_cfg)
|
g_Prj_Config->SetPath( UNIX_STRING_DIR_SEP );
|
||||||
if (PTCFG->m_Pt_param == NULL) break;
|
|
||||||
if ( pt_cfg->m_Setup)
|
|
||||||
m_EDA_Config->Write(pt_cfg->m_Ident, *PTCFG->m_Pt_param);
|
|
||||||
else
|
|
||||||
g_Prj_Config->Write(pt_cfg->m_Ident, *PTCFG->m_Pt_param);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case PARAM_DOUBLE:
|
for( ; *List != NULL; List++ )
|
||||||
#undef PTCFG
|
{
|
||||||
#define PTCFG ((PARAM_CFG_DOUBLE *)pt_cfg)
|
pt_cfg = *List;
|
||||||
if (PTCFG->m_Pt_param == NULL) break;
|
if( pt_cfg->m_Group )
|
||||||
if ( pt_cfg->m_Setup)
|
g_Prj_Config->SetPath( pt_cfg->m_Group );
|
||||||
m_EDA_Config->Write(pt_cfg->m_Ident, *PTCFG->m_Pt_param);
|
else
|
||||||
else
|
g_Prj_Config->SetPath( GroupName );
|
||||||
g_Prj_Config->Write(pt_cfg->m_Ident, *PTCFG->m_Pt_param);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case PARAM_BOOL:
|
switch( pt_cfg->m_Type )
|
||||||
#undef PTCFG
|
{
|
||||||
#define PTCFG ((PARAM_CFG_BOOL *)pt_cfg)
|
case PARAM_INT:
|
||||||
if (PTCFG->m_Pt_param == NULL) break;
|
#undef PTCFG
|
||||||
if ( pt_cfg->m_Setup)
|
#define PTCFG ( (PARAM_CFG_INT*) pt_cfg )
|
||||||
m_EDA_Config->Write(pt_cfg->m_Ident, (int)*PTCFG->m_Pt_param);
|
if( PTCFG->m_Pt_param == NULL )
|
||||||
else
|
break;
|
||||||
g_Prj_Config->Write(pt_cfg->m_Ident, (int)*PTCFG->m_Pt_param);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case PARAM_WXSTRING:
|
if( pt_cfg->m_Setup )
|
||||||
#undef PTCFG
|
m_EDA_Config->Write( pt_cfg->m_Ident, *PTCFG->m_Pt_param );
|
||||||
#define PTCFG ((PARAM_CFG_WXSTRING *)pt_cfg)
|
else
|
||||||
if (PTCFG->m_Pt_param == NULL) break;
|
g_Prj_Config->Write( pt_cfg->m_Ident, *PTCFG->m_Pt_param );
|
||||||
if ( pt_cfg->m_Setup)
|
break;
|
||||||
m_EDA_Config->Write(pt_cfg->m_Ident, *PTCFG->m_Pt_param);
|
|
||||||
else
|
|
||||||
g_Prj_Config->Write(pt_cfg->m_Ident, *PTCFG->m_Pt_param);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case PARAM_LIBNAME_LIST:
|
case PARAM_SETCOLOR:
|
||||||
{
|
#undef PTCFG
|
||||||
#undef PTCFG
|
#define PTCFG ( (PARAM_CFG_SETCOLOR*) pt_cfg )
|
||||||
#define PTCFG ((PARAM_CFG_LIBNAME_LIST *)pt_cfg)
|
if( PTCFG->m_Pt_param == NULL )
|
||||||
if (PTCFG->m_Pt_param == NULL) break;
|
break;
|
||||||
wxArrayString * libname_list = PTCFG->m_Pt_param;
|
|
||||||
if ( libname_list == NULL ) break;
|
|
||||||
unsigned indexlib = 0;
|
|
||||||
wxString cle_config;
|
|
||||||
for ( ; indexlib < libname_list->GetCount(); indexlib++ )
|
|
||||||
{
|
|
||||||
cle_config = pt_cfg->m_Ident;
|
|
||||||
// We use indexlib+1 because first lib name is LibName1
|
|
||||||
cle_config << (indexlib+1);
|
|
||||||
g_Prj_Config->Write(cle_config, libname_list->Item(indexlib));
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case PARAM_COMMAND_ERASE: // Erase all datas
|
if( pt_cfg->m_Setup )
|
||||||
if ( pt_cfg->m_Ident )
|
m_EDA_Config->Write( pt_cfg->m_Ident, *PTCFG->m_Pt_param );
|
||||||
{
|
else
|
||||||
m_EDA_Config->DeleteGroup(pt_cfg->m_Ident);
|
g_Prj_Config->Write( pt_cfg->m_Ident, *PTCFG->m_Pt_param );
|
||||||
g_Prj_Config->DeleteGroup(pt_cfg->m_Ident);
|
break;
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
g_Prj_Config->SetPath(UNIX_STRING_DIR_SEP);
|
case PARAM_DOUBLE:
|
||||||
delete g_Prj_Config;
|
#undef PTCFG
|
||||||
g_Prj_Config = NULL;
|
#define PTCFG ( (PARAM_CFG_DOUBLE*) pt_cfg )
|
||||||
|
if( PTCFG->m_Pt_param == NULL )
|
||||||
|
break;
|
||||||
|
|
||||||
|
if( pt_cfg->m_Setup )
|
||||||
|
m_EDA_Config->Write( pt_cfg->m_Ident, *PTCFG->m_Pt_param );
|
||||||
|
else
|
||||||
|
g_Prj_Config->Write( pt_cfg->m_Ident, *PTCFG->m_Pt_param );
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PARAM_BOOL:
|
||||||
|
#undef PTCFG
|
||||||
|
#define PTCFG ( (PARAM_CFG_BOOL*) pt_cfg )
|
||||||
|
if( PTCFG->m_Pt_param == NULL )
|
||||||
|
break;
|
||||||
|
|
||||||
|
if( pt_cfg->m_Setup )
|
||||||
|
m_EDA_Config->Write( pt_cfg->m_Ident, (int) *PTCFG->m_Pt_param );
|
||||||
|
else
|
||||||
|
g_Prj_Config->Write( pt_cfg->m_Ident, (int) *PTCFG->m_Pt_param );
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PARAM_WXSTRING:
|
||||||
|
#undef PTCFG
|
||||||
|
#define PTCFG ( (PARAM_CFG_WXSTRING*) pt_cfg )
|
||||||
|
if( PTCFG->m_Pt_param == NULL )
|
||||||
|
break;
|
||||||
|
|
||||||
|
if( pt_cfg->m_Setup )
|
||||||
|
m_EDA_Config->Write( pt_cfg->m_Ident, *PTCFG->m_Pt_param );
|
||||||
|
else
|
||||||
|
g_Prj_Config->Write( pt_cfg->m_Ident, *PTCFG->m_Pt_param );
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PARAM_LIBNAME_LIST:
|
||||||
|
{
|
||||||
|
#undef PTCFG
|
||||||
|
#define PTCFG ( (PARAM_CFG_LIBNAME_LIST*) pt_cfg )
|
||||||
|
if( PTCFG->m_Pt_param == NULL )
|
||||||
|
break;
|
||||||
|
|
||||||
|
wxArrayString* libname_list = PTCFG->m_Pt_param;
|
||||||
|
if( libname_list == NULL )
|
||||||
|
break;
|
||||||
|
|
||||||
|
unsigned indexlib = 0;
|
||||||
|
wxString cle_config;
|
||||||
|
for( ; indexlib < libname_list->GetCount(); indexlib++ )
|
||||||
|
{
|
||||||
|
cle_config = pt_cfg->m_Ident;
|
||||||
|
|
||||||
|
// We use indexlib+1 because first lib name is LibName1
|
||||||
|
cle_config << (indexlib + 1);
|
||||||
|
g_Prj_Config->Write( cle_config, libname_list->Item( indexlib ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case PARAM_COMMAND_ERASE: // Erase all datas
|
||||||
|
if( pt_cfg->m_Ident )
|
||||||
|
{
|
||||||
|
m_EDA_Config->DeleteGroup( pt_cfg->m_Ident );
|
||||||
|
g_Prj_Config->DeleteGroup( pt_cfg->m_Ident );
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
g_Prj_Config->SetPath( UNIX_STRING_DIR_SEP );
|
||||||
|
delete g_Prj_Config;
|
||||||
|
g_Prj_Config = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/***************************************************************************************/
|
/***************************************************************************************/
|
||||||
bool WinEDA_App::ReadProjectConfig(const wxString & local_config_filename,
|
bool WinEDA_App::ReadProjectConfig( const wxString& local_config_filename,
|
||||||
const wxString & GroupName, PARAM_CFG_BASE ** List,
|
const wxString& GroupName, PARAM_CFG_BASE** List,
|
||||||
bool Load_Only_if_New)
|
bool Load_Only_if_New )
|
||||||
/***************************************************************************************/
|
/***************************************************************************************/
|
||||||
|
|
||||||
/* Lecture de la config "projet"
|
/* Lecture de la config "projet"
|
||||||
*** si Load_Only_if_New == TRUE, elle n'est lue que si elle
|
*** si Load_Only_if_New == TRUE, elle n'est lue que si elle
|
||||||
*** est differente de la config actuelle (dates differentes)
|
*** est differente de la config actuelle (dates differentes)
|
||||||
|
*
|
||||||
return:
|
* return:
|
||||||
TRUE si lue.
|
* TRUE si lue.
|
||||||
Met a jour en plus:
|
* Met a jour en plus:
|
||||||
g_EDA_Appl->m_CurrentOptionFileDateAndTime
|
* g_EDA_Appl->m_CurrentOptionFileDateAndTime
|
||||||
g_EDA_Appl->m_CurrentOptionFile
|
* g_EDA_Appl->m_CurrentOptionFile
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
const PARAM_CFG_BASE * pt_cfg;
|
const PARAM_CFG_BASE* pt_cfg;
|
||||||
wxString timestamp;
|
wxString timestamp;
|
||||||
|
|
||||||
if ( List == NULL )return FALSE;
|
if( List == NULL )
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
ReCreatePrjConfig(local_config_filename, GroupName, FALSE);
|
ReCreatePrjConfig( local_config_filename, GroupName, FALSE );
|
||||||
|
|
||||||
g_Prj_Config->SetPath(UNIX_STRING_DIR_SEP);
|
g_Prj_Config->SetPath( UNIX_STRING_DIR_SEP );
|
||||||
timestamp = g_Prj_Config->Read( wxT("update") );
|
timestamp = g_Prj_Config->Read( wxT( "update" ) );
|
||||||
if ( Load_Only_if_New && ( !timestamp.IsEmpty() ) &&
|
if( Load_Only_if_New && ( !timestamp.IsEmpty() )
|
||||||
(timestamp == g_EDA_Appl->m_CurrentOptionFileDateAndTime) )
|
&& (timestamp == g_EDA_Appl->m_CurrentOptionFileDateAndTime) )
|
||||||
{
|
{
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_EDA_Appl->m_CurrentOptionFileDateAndTime = timestamp;
|
g_EDA_Appl->m_CurrentOptionFileDateAndTime = timestamp;
|
||||||
|
|
||||||
if ( ! g_Prj_Default_Config_FullFilename.IsEmpty() )
|
if( !g_Prj_Default_Config_FullFilename.IsEmpty() )
|
||||||
g_EDA_Appl->m_CurrentOptionFile = g_Prj_Default_Config_FullFilename;
|
g_EDA_Appl->m_CurrentOptionFile = g_Prj_Default_Config_FullFilename;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ( wxPathOnly(g_Prj_Config_LocalFilename).IsEmpty() )
|
if( wxPathOnly( g_Prj_Config_LocalFilename ).IsEmpty() )
|
||||||
g_EDA_Appl->m_CurrentOptionFile =
|
g_EDA_Appl->m_CurrentOptionFile =
|
||||||
wxGetCwd() + STRING_DIR_SEP + g_Prj_Config_LocalFilename;
|
wxGetCwd() + STRING_DIR_SEP + g_Prj_Config_LocalFilename;
|
||||||
else
|
else
|
||||||
g_EDA_Appl->m_CurrentOptionFile = g_Prj_Config_LocalFilename;
|
g_EDA_Appl->m_CurrentOptionFile = g_Prj_Config_LocalFilename;
|
||||||
}
|
}
|
||||||
|
|
||||||
for( ; *List != NULL ; List++)
|
for( ; *List != NULL; List++ )
|
||||||
{
|
{
|
||||||
pt_cfg = *List;
|
pt_cfg = *List;
|
||||||
if ( pt_cfg->m_Group ) g_Prj_Config->SetPath(pt_cfg->m_Group);
|
if( pt_cfg->m_Group )
|
||||||
else g_Prj_Config->SetPath(GroupName);
|
g_Prj_Config->SetPath( pt_cfg->m_Group );
|
||||||
switch( pt_cfg->m_Type )
|
else
|
||||||
{
|
g_Prj_Config->SetPath( GroupName );
|
||||||
case PARAM_INT:
|
|
||||||
{
|
|
||||||
#undef PTCFG
|
|
||||||
#define PTCFG ((PARAM_CFG_INT *)pt_cfg)
|
|
||||||
int itmp;
|
|
||||||
if ( pt_cfg->m_Setup)
|
|
||||||
itmp = m_EDA_Config->Read(pt_cfg->m_Ident, PTCFG->m_Default );
|
|
||||||
else
|
|
||||||
itmp = g_Prj_Config->Read(pt_cfg->m_Ident, PTCFG->m_Default );
|
|
||||||
if( (itmp < PTCFG->m_Min) || (itmp > PTCFG->m_Max) )
|
|
||||||
itmp = PTCFG->m_Default;
|
|
||||||
*PTCFG->m_Pt_param = itmp;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case PARAM_SETCOLOR:
|
switch( pt_cfg->m_Type )
|
||||||
{
|
{
|
||||||
#undef PTCFG
|
case PARAM_INT:
|
||||||
#define PTCFG ((PARAM_CFG_SETCOLOR *)pt_cfg)
|
{
|
||||||
int itmp;
|
#undef PTCFG
|
||||||
if ( pt_cfg->m_Setup)
|
#define PTCFG ( (PARAM_CFG_INT*) pt_cfg )
|
||||||
itmp = m_EDA_Config->Read(pt_cfg->m_Ident, PTCFG->m_Default );
|
int itmp;
|
||||||
else
|
if( pt_cfg->m_Setup )
|
||||||
itmp = g_Prj_Config->Read(pt_cfg->m_Ident, PTCFG->m_Default );
|
itmp = m_EDA_Config->Read( pt_cfg->m_Ident, PTCFG->m_Default );
|
||||||
if( (itmp < 0) || (itmp > MAX_COLOR) )
|
else
|
||||||
itmp = PTCFG->m_Default;
|
itmp = g_Prj_Config->Read( pt_cfg->m_Ident, PTCFG->m_Default );
|
||||||
*PTCFG->m_Pt_param = itmp;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case PARAM_DOUBLE:
|
if( (itmp < PTCFG->m_Min) || (itmp > PTCFG->m_Max) )
|
||||||
{
|
itmp = PTCFG->m_Default;
|
||||||
#undef PTCFG
|
|
||||||
#define PTCFG ((PARAM_CFG_DOUBLE *)pt_cfg)
|
|
||||||
double ftmp = 0; wxString msg;
|
|
||||||
if ( pt_cfg->m_Setup)
|
|
||||||
msg = m_EDA_Config->Read(pt_cfg->m_Ident, wxT("") );
|
|
||||||
else
|
|
||||||
msg = g_Prj_Config->Read(pt_cfg->m_Ident, wxT("") );
|
|
||||||
|
|
||||||
if ( msg.IsEmpty() ) ftmp = PTCFG->m_Default;
|
*PTCFG->m_Pt_param = itmp;
|
||||||
else
|
break;
|
||||||
{
|
}
|
||||||
msg.ToDouble(&ftmp);
|
|
||||||
if( (ftmp < PTCFG->m_Min) || (ftmp > PTCFG->m_Max) )
|
|
||||||
ftmp = PTCFG->m_Default;
|
|
||||||
}
|
|
||||||
*PTCFG->m_Pt_param = ftmp;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case PARAM_BOOL:
|
case PARAM_SETCOLOR:
|
||||||
{
|
{
|
||||||
#undef PTCFG
|
#undef PTCFG
|
||||||
#define PTCFG ((PARAM_CFG_BOOL *)pt_cfg)
|
#define PTCFG ( (PARAM_CFG_SETCOLOR*) pt_cfg )
|
||||||
int itmp;
|
int itmp;
|
||||||
if ( pt_cfg->m_Setup)
|
if( pt_cfg->m_Setup )
|
||||||
itmp = m_EDA_Config->Read(pt_cfg->m_Ident, PTCFG->m_Default );
|
itmp = m_EDA_Config->Read( pt_cfg->m_Ident, PTCFG->m_Default );
|
||||||
else
|
else
|
||||||
itmp = g_Prj_Config->Read(pt_cfg->m_Ident, PTCFG->m_Default );
|
itmp = g_Prj_Config->Read( pt_cfg->m_Ident, PTCFG->m_Default );
|
||||||
*PTCFG->m_Pt_param = itmp ? TRUE : FALSE;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case PARAM_WXSTRING:
|
if( (itmp < 0) || (itmp > MAX_COLOR) )
|
||||||
{
|
itmp = PTCFG->m_Default;
|
||||||
#undef PTCFG
|
|
||||||
#define PTCFG ((PARAM_CFG_WXSTRING *)pt_cfg)
|
|
||||||
if (PTCFG->m_Pt_param == NULL) break;
|
|
||||||
if ( pt_cfg->m_Setup)
|
|
||||||
*PTCFG->m_Pt_param = m_EDA_Config->Read(pt_cfg->m_Ident );
|
|
||||||
else
|
|
||||||
*PTCFG->m_Pt_param = g_Prj_Config->Read(pt_cfg->m_Ident );
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case PARAM_LIBNAME_LIST:
|
*PTCFG->m_Pt_param = itmp;
|
||||||
{
|
break;
|
||||||
#undef PTCFG
|
}
|
||||||
#define PTCFG ((PARAM_CFG_LIBNAME_LIST *)pt_cfg)
|
|
||||||
int indexlib = 1; // We start indexlib to 1 because first lib name is LibName1
|
|
||||||
wxString libname, id_lib;
|
|
||||||
wxArrayString * libname_list = PTCFG->m_Pt_param;
|
|
||||||
while ( 1 )
|
|
||||||
{
|
|
||||||
id_lib = pt_cfg->m_Ident; id_lib << indexlib; indexlib++;
|
|
||||||
libname = g_Prj_Config->Read(id_lib, wxT("") );
|
|
||||||
if( libname.IsEmpty() ) break;
|
|
||||||
libname_list->Add(libname);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case PARAM_COMMAND_ERASE:
|
case PARAM_DOUBLE:
|
||||||
break;
|
{
|
||||||
}
|
#undef PTCFG
|
||||||
}
|
#define PTCFG ( (PARAM_CFG_DOUBLE*) pt_cfg )
|
||||||
|
double ftmp = 0; wxString msg;
|
||||||
|
if( pt_cfg->m_Setup )
|
||||||
|
msg = m_EDA_Config->Read( pt_cfg->m_Ident, wxT( "" ) );
|
||||||
|
else
|
||||||
|
msg = g_Prj_Config->Read( pt_cfg->m_Ident, wxT( "" ) );
|
||||||
|
|
||||||
delete g_Prj_Config;
|
if( msg.IsEmpty() )
|
||||||
g_Prj_Config = NULL;
|
ftmp = PTCFG->m_Default;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
msg.ToDouble( &ftmp );
|
||||||
|
if( (ftmp < PTCFG->m_Min) || (ftmp > PTCFG->m_Max) )
|
||||||
|
ftmp = PTCFG->m_Default;
|
||||||
|
}
|
||||||
|
*PTCFG->m_Pt_param = ftmp;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
return TRUE;
|
case PARAM_BOOL:
|
||||||
|
{
|
||||||
|
#undef PTCFG
|
||||||
|
#define PTCFG ( (PARAM_CFG_BOOL*) pt_cfg )
|
||||||
|
int itmp;
|
||||||
|
if( pt_cfg->m_Setup )
|
||||||
|
itmp = m_EDA_Config->Read( pt_cfg->m_Ident, PTCFG->m_Default );
|
||||||
|
else
|
||||||
|
itmp = g_Prj_Config->Read( pt_cfg->m_Ident, PTCFG->m_Default );
|
||||||
|
|
||||||
|
*PTCFG->m_Pt_param = itmp ? TRUE : FALSE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case PARAM_WXSTRING:
|
||||||
|
{
|
||||||
|
#undef PTCFG
|
||||||
|
#define PTCFG ( (PARAM_CFG_WXSTRING*) pt_cfg )
|
||||||
|
if( PTCFG->m_Pt_param == NULL )
|
||||||
|
break;
|
||||||
|
|
||||||
|
if( pt_cfg->m_Setup )
|
||||||
|
*PTCFG->m_Pt_param = m_EDA_Config->Read( pt_cfg->m_Ident );
|
||||||
|
else
|
||||||
|
*PTCFG->m_Pt_param = g_Prj_Config->Read( pt_cfg->m_Ident );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case PARAM_LIBNAME_LIST:
|
||||||
|
{
|
||||||
|
#undef PTCFG
|
||||||
|
#define PTCFG ( (PARAM_CFG_LIBNAME_LIST*) pt_cfg )
|
||||||
|
int indexlib = 1; // We start indexlib to 1 because first lib name is LibName1
|
||||||
|
wxString libname, id_lib;
|
||||||
|
wxArrayString* libname_list = PTCFG->m_Pt_param;
|
||||||
|
while( 1 )
|
||||||
|
{
|
||||||
|
id_lib = pt_cfg->m_Ident; id_lib << indexlib; indexlib++;
|
||||||
|
libname = g_Prj_Config->Read( id_lib, wxT( "" ) );
|
||||||
|
if( libname.IsEmpty() )
|
||||||
|
break;
|
||||||
|
libname_list->Add( libname );
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case PARAM_COMMAND_ERASE:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
delete g_Prj_Config;
|
||||||
|
g_Prj_Config = NULL;
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -355,114 +400,124 @@ wxString timestamp;
|
||||||
/* Constructeurs des descripteurs de structs de configuration */
|
/* Constructeurs des descripteurs de structs de configuration */
|
||||||
/**************************************************************/
|
/**************************************************************/
|
||||||
|
|
||||||
PARAM_CFG_BASE::PARAM_CFG_BASE(const wxChar * ident, const paramcfg_id type,
|
PARAM_CFG_BASE::PARAM_CFG_BASE( const wxChar* ident, const paramcfg_id type,
|
||||||
const wxChar * group)
|
const wxChar* group )
|
||||||
{
|
{
|
||||||
m_Ident = ident;
|
m_Ident = ident;
|
||||||
m_Type = type;
|
m_Type = type;
|
||||||
m_Group = group;
|
m_Group = group;
|
||||||
m_Setup = FALSE;
|
m_Setup = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
PARAM_CFG_INT::PARAM_CFG_INT(const wxChar * ident, int * ptparam,
|
PARAM_CFG_INT::PARAM_CFG_INT( const wxChar* ident, int* ptparam,
|
||||||
int default_val, int min, int max,
|
int default_val, int min, int max,
|
||||||
const wxChar * group)
|
const wxChar* group ) :
|
||||||
: PARAM_CFG_BASE(ident, PARAM_INT, group)
|
PARAM_CFG_BASE( ident, PARAM_INT, group )
|
||||||
{
|
{
|
||||||
m_Pt_param = ptparam;
|
m_Pt_param = ptparam;
|
||||||
m_Default = default_val;
|
m_Default = default_val;
|
||||||
m_Min = min;
|
m_Min = min;
|
||||||
m_Max = max;
|
m_Max = max;
|
||||||
}
|
}
|
||||||
|
|
||||||
PARAM_CFG_INT::PARAM_CFG_INT(bool Insetup, const wxChar * ident, int * ptparam,
|
|
||||||
int default_val, int min, int max,
|
PARAM_CFG_INT::PARAM_CFG_INT( bool Insetup, const wxChar* ident, int* ptparam,
|
||||||
const wxChar * group)
|
int default_val, int min, int max,
|
||||||
: PARAM_CFG_BASE(ident, PARAM_INT, group)
|
const wxChar* group ) :
|
||||||
|
PARAM_CFG_BASE( ident, PARAM_INT, group )
|
||||||
{
|
{
|
||||||
m_Pt_param = ptparam;
|
m_Pt_param = ptparam;
|
||||||
m_Default = default_val;
|
m_Default = default_val;
|
||||||
m_Min = min;
|
m_Min = min;
|
||||||
m_Max = max;
|
m_Max = max;
|
||||||
m_Setup = Insetup;
|
m_Setup = Insetup;
|
||||||
}
|
}
|
||||||
|
|
||||||
PARAM_CFG_SETCOLOR::PARAM_CFG_SETCOLOR(const wxChar * ident, int * ptparam,
|
|
||||||
int default_val, const wxChar * group)
|
PARAM_CFG_SETCOLOR::PARAM_CFG_SETCOLOR( const wxChar* ident, int* ptparam,
|
||||||
: PARAM_CFG_BASE(ident, PARAM_SETCOLOR, group)
|
int default_val, const wxChar* group ) :
|
||||||
|
PARAM_CFG_BASE( ident, PARAM_SETCOLOR, group )
|
||||||
{
|
{
|
||||||
m_Pt_param = ptparam;
|
m_Pt_param = ptparam;
|
||||||
m_Default = default_val;
|
m_Default = default_val;
|
||||||
}
|
}
|
||||||
|
|
||||||
PARAM_CFG_SETCOLOR::PARAM_CFG_SETCOLOR(bool Insetup, const wxChar * ident, int * ptparam,
|
|
||||||
int default_val, const wxChar * group)
|
PARAM_CFG_SETCOLOR::PARAM_CFG_SETCOLOR( bool Insetup, const wxChar* ident, int* ptparam,
|
||||||
: PARAM_CFG_BASE(ident, PARAM_SETCOLOR, group)
|
int default_val, const wxChar* group ) :
|
||||||
|
PARAM_CFG_BASE( ident, PARAM_SETCOLOR, group )
|
||||||
{
|
{
|
||||||
m_Pt_param = ptparam;
|
m_Pt_param = ptparam;
|
||||||
m_Default = default_val;
|
m_Default = default_val;
|
||||||
m_Setup = Insetup;
|
m_Setup = Insetup;
|
||||||
}
|
}
|
||||||
|
|
||||||
PARAM_CFG_DOUBLE::PARAM_CFG_DOUBLE(const wxChar * ident, double * ptparam,
|
|
||||||
double default_val, double min , double max,
|
PARAM_CFG_DOUBLE::PARAM_CFG_DOUBLE( const wxChar* ident, double* ptparam,
|
||||||
const wxChar * group)
|
double default_val, double min, double max,
|
||||||
: PARAM_CFG_BASE(ident, PARAM_DOUBLE, group)
|
const wxChar* group ) :
|
||||||
|
PARAM_CFG_BASE( ident, PARAM_DOUBLE, group )
|
||||||
{
|
{
|
||||||
m_Pt_param = ptparam;
|
m_Pt_param = ptparam;
|
||||||
m_Default = default_val;
|
m_Default = default_val;
|
||||||
m_Min = min;
|
m_Min = min;
|
||||||
m_Max = max;
|
m_Max = max;
|
||||||
}
|
|
||||||
PARAM_CFG_DOUBLE::PARAM_CFG_DOUBLE(bool Insetup, const wxChar * ident, double * ptparam,
|
|
||||||
double default_val, double min , double max,
|
|
||||||
const wxChar * group)
|
|
||||||
: PARAM_CFG_BASE(ident, PARAM_DOUBLE, group)
|
|
||||||
{
|
|
||||||
m_Pt_param = ptparam;
|
|
||||||
m_Default = default_val;
|
|
||||||
m_Min = min;
|
|
||||||
m_Max = max;
|
|
||||||
m_Setup = Insetup;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PARAM_CFG_BOOL::PARAM_CFG_BOOL(const wxChar * ident, bool * ptparam,
|
|
||||||
int default_val, const wxChar * group)
|
PARAM_CFG_DOUBLE::PARAM_CFG_DOUBLE( bool Insetup, const wxChar* ident, double* ptparam,
|
||||||
: PARAM_CFG_BASE(ident, PARAM_BOOL, group)
|
double default_val, double min, double max,
|
||||||
|
const wxChar* group ) :
|
||||||
|
PARAM_CFG_BASE( ident, PARAM_DOUBLE, group )
|
||||||
{
|
{
|
||||||
m_Pt_param = ptparam;
|
m_Pt_param = ptparam;
|
||||||
m_Default = default_val ? TRUE : FALSE;
|
m_Default = default_val;
|
||||||
|
m_Min = min;
|
||||||
|
m_Max = max;
|
||||||
|
m_Setup = Insetup;
|
||||||
}
|
}
|
||||||
|
|
||||||
PARAM_CFG_BOOL::PARAM_CFG_BOOL(bool Insetup, const wxChar * ident, bool * ptparam,
|
|
||||||
int default_val, const wxChar * group)
|
PARAM_CFG_BOOL::PARAM_CFG_BOOL( const wxChar* ident, bool* ptparam,
|
||||||
: PARAM_CFG_BASE(ident, PARAM_BOOL, group)
|
int default_val, const wxChar* group ) :
|
||||||
|
PARAM_CFG_BASE( ident, PARAM_BOOL, group )
|
||||||
{
|
{
|
||||||
m_Pt_param = ptparam;
|
m_Pt_param = ptparam;
|
||||||
m_Default = default_val ? TRUE : FALSE;
|
m_Default = default_val ? TRUE : FALSE;
|
||||||
m_Setup = Insetup;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PARAM_CFG_WXSTRING::PARAM_CFG_WXSTRING(const wxChar * ident,
|
|
||||||
wxString * ptparam, const wxChar * group)
|
PARAM_CFG_BOOL::PARAM_CFG_BOOL( bool Insetup, const wxChar* ident, bool* ptparam,
|
||||||
: PARAM_CFG_BASE(ident, PARAM_WXSTRING, group)
|
int default_val, const wxChar* group ) :
|
||||||
|
PARAM_CFG_BASE( ident, PARAM_BOOL, group )
|
||||||
{
|
{
|
||||||
m_Pt_param = ptparam;
|
m_Pt_param = ptparam;
|
||||||
|
m_Default = default_val ? TRUE : FALSE;
|
||||||
|
m_Setup = Insetup;
|
||||||
}
|
}
|
||||||
|
|
||||||
PARAM_CFG_WXSTRING::PARAM_CFG_WXSTRING(bool Insetup, const wxChar * ident,
|
|
||||||
wxString * ptparam, const wxChar * group)
|
PARAM_CFG_WXSTRING::PARAM_CFG_WXSTRING( const wxChar* ident,
|
||||||
: PARAM_CFG_BASE(ident, PARAM_WXSTRING, group)
|
wxString* ptparam, const wxChar* group ) :
|
||||||
|
PARAM_CFG_BASE( ident, PARAM_WXSTRING, group )
|
||||||
{
|
{
|
||||||
m_Pt_param = ptparam;
|
m_Pt_param = ptparam;
|
||||||
m_Setup = Insetup;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PARAM_CFG_LIBNAME_LIST::PARAM_CFG_LIBNAME_LIST(const wxChar * ident,
|
|
||||||
wxArrayString * ptparam, const wxChar * group)
|
PARAM_CFG_WXSTRING::PARAM_CFG_WXSTRING( bool Insetup, const wxChar* ident,
|
||||||
: PARAM_CFG_BASE(ident, PARAM_LIBNAME_LIST, group)
|
wxString* ptparam, const wxChar* group ) :
|
||||||
|
PARAM_CFG_BASE( ident, PARAM_WXSTRING, group )
|
||||||
{
|
{
|
||||||
m_Pt_param = ptparam;
|
m_Pt_param = ptparam;
|
||||||
|
m_Setup = Insetup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
PARAM_CFG_LIBNAME_LIST::PARAM_CFG_LIBNAME_LIST( const wxChar* ident,
|
||||||
|
wxArrayString* ptparam, const wxChar* group ) :
|
||||||
|
PARAM_CFG_BASE( ident, PARAM_LIBNAME_LIST, group )
|
||||||
|
{
|
||||||
|
m_Pt_param = ptparam;
|
||||||
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/***********************************/
|
/***********************************/
|
||||||
/** pcbcfg() : configuration **/
|
/** pcbcfg() : configuration **/
|
||||||
/***********************************/
|
/***********************************/
|
||||||
|
|
||||||
/* lit ou met a jour la configuration de PCBNEW */
|
/* lit ou met a jour la configuration de PCBNEW */
|
||||||
|
|
||||||
|
@ -21,193 +21,200 @@
|
||||||
|
|
||||||
/* Variables locales */
|
/* Variables locales */
|
||||||
|
|
||||||
#define HOTKEY_FILENAME wxT("pcbnew")
|
#define HOTKEY_FILENAME wxT( "pcbnew" )
|
||||||
|
|
||||||
/***********************************************************/
|
/***********************************************************/
|
||||||
void WinEDA_PcbFrame::Process_Config(wxCommandEvent& event)
|
void WinEDA_PcbFrame::Process_Config( wxCommandEvent& event )
|
||||||
/***********************************************************/
|
/***********************************************************/
|
||||||
{
|
{
|
||||||
int id = event.GetId();
|
int id = event.GetId();
|
||||||
wxPoint pos;
|
wxPoint pos;
|
||||||
wxClientDC dc(DrawPanel);
|
|
||||||
wxString FullFileName;
|
|
||||||
|
|
||||||
DrawPanel->PrepareGraphicContext(&dc);
|
wxClientDC dc( DrawPanel );
|
||||||
|
|
||||||
pos = GetPosition();
|
wxString FullFileName;
|
||||||
pos.x += 20; pos.y += 20;
|
|
||||||
|
|
||||||
switch( id )
|
DrawPanel->PrepareGraphicContext( &dc );
|
||||||
{
|
|
||||||
case ID_COLORS_SETUP :
|
|
||||||
DisplayColorSetupFrame(this, pos);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case ID_CONFIG_REQ : // Creation de la fenetre de configuration
|
pos = GetPosition();
|
||||||
InstallConfigFrame(pos);
|
pos.x += 20;
|
||||||
break;
|
pos.y += 20;
|
||||||
|
|
||||||
case ID_PCB_TRACK_SIZE_SETUP:
|
switch( id )
|
||||||
case ID_PCB_LOOK_SETUP:
|
{
|
||||||
case ID_OPTIONS_SETUP:
|
case ID_COLORS_SETUP:
|
||||||
case ID_PCB_DRAWINGS_WIDTHS_SETUP:
|
DisplayColorSetupFrame( this, pos );
|
||||||
InstallPcbOptionsFrame(pos, &dc, id);
|
break;
|
||||||
break;
|
|
||||||
|
|
||||||
case ID_PCB_PAD_SETUP:
|
case ID_CONFIG_REQ: // Creation de la fenetre de configuration
|
||||||
InstallPadOptionsFrame( NULL, NULL, pos);
|
InstallConfigFrame( pos );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ID_CONFIG_SAVE:
|
case ID_PCB_TRACK_SIZE_SETUP:
|
||||||
Update_config(this);
|
case ID_PCB_LOOK_SETUP:
|
||||||
break;
|
case ID_OPTIONS_SETUP:
|
||||||
|
case ID_PCB_DRAWINGS_WIDTHS_SETUP:
|
||||||
|
InstallPcbOptionsFrame( pos, &dc, id );
|
||||||
|
break;
|
||||||
|
|
||||||
case ID_CONFIG_READ:
|
case ID_PCB_PAD_SETUP:
|
||||||
FullFileName = GetScreen()->m_FileName.AfterLast('/');
|
InstallPadOptionsFrame( NULL, NULL, pos );
|
||||||
ChangeFileNameExt(FullFileName, g_Prj_Config_Filename_ext);
|
break;
|
||||||
FullFileName = EDA_FileSelector(_("Read config file"),
|
|
||||||
wxPathOnly(GetScreen()->m_FileName),/* 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()) break;
|
|
||||||
if ( ! wxFileExists(FullFileName) )
|
|
||||||
{
|
|
||||||
wxString msg;
|
|
||||||
msg.Printf(_("File %s not found"), FullFileName.GetData());
|
|
||||||
DisplayError(this, msg); break;
|
|
||||||
}
|
|
||||||
Read_Config(FullFileName );
|
|
||||||
break;
|
|
||||||
|
|
||||||
case ID_PREFERENCES_CREATE_CONFIG_HOTKEYS:
|
case ID_CONFIG_SAVE:
|
||||||
FullFileName = ReturnHotkeyConfigFilePath( g_ConfigFileLocationChoice );
|
Update_config( this );
|
||||||
FullFileName += HOTKEY_FILENAME;
|
break;
|
||||||
FullFileName += DEFAULT_HOTKEY_FILENAME_EXT;
|
|
||||||
WriteHotkeyConfigFile(FullFileName, s_Pcbnew_Editor_Hokeys_Descr, true);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case ID_PREFERENCES_READ_CONFIG_HOTKEYS:
|
case ID_CONFIG_READ:
|
||||||
Read_Hotkey_Config( this, true);
|
FullFileName = GetScreen()->m_FileName.AfterLast( '/' );
|
||||||
break;
|
ChangeFileNameExt( FullFileName, g_Prj_Config_Filename_ext );
|
||||||
|
FullFileName = EDA_FileSelector( _( "Read config file" ),
|
||||||
|
wxPathOnly( GetScreen()->m_FileName ), /* 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() )
|
||||||
|
break;
|
||||||
|
if( !wxFileExists( FullFileName ) )
|
||||||
|
{
|
||||||
|
wxString msg;
|
||||||
|
msg.Printf( _( "File %s not found" ), FullFileName.GetData() );
|
||||||
|
DisplayError( this, msg ); break;
|
||||||
|
}
|
||||||
|
Read_Config( FullFileName );
|
||||||
|
break;
|
||||||
|
|
||||||
case ID_PREFERENCES_EDIT_CONFIG_HOTKEYS:
|
case ID_PREFERENCES_CREATE_CONFIG_HOTKEYS:
|
||||||
{
|
FullFileName = ReturnHotkeyConfigFilePath( g_ConfigFileLocationChoice );
|
||||||
FullFileName = ReturnHotkeyConfigFilePath( g_ConfigFileLocationChoice );
|
FullFileName += HOTKEY_FILENAME;
|
||||||
FullFileName += HOTKEY_FILENAME;
|
FullFileName += DEFAULT_HOTKEY_FILENAME_EXT;
|
||||||
FullFileName += DEFAULT_HOTKEY_FILENAME_EXT;
|
WriteHotkeyConfigFile( FullFileName, s_Pcbnew_Editor_Hokeys_Descr, true );
|
||||||
wxString editorname = GetEditorName();
|
break;
|
||||||
if ( !editorname.IsEmpty() )
|
|
||||||
ExecuteFile(this, editorname, FullFileName);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case ID_PREFERENCES_HOTKEY_PATH_IS_HOME:
|
case ID_PREFERENCES_READ_CONFIG_HOTKEYS:
|
||||||
case ID_PREFERENCES_HOTKEY_PATH_IS_KICAD:
|
Read_Hotkey_Config( this, true );
|
||||||
HandleHotkeyConfigMenuSelection( this, id );
|
break;
|
||||||
break;
|
|
||||||
|
|
||||||
case ID_PREFERENCES_HOTKEY_SHOW_CURRENT_LIST: // Display Current hotkey list for eeschema
|
case ID_PREFERENCES_EDIT_CONFIG_HOTKEYS:
|
||||||
DisplayHotkeyList( this, s_Board_Editor_Hokeys_Descr );
|
{
|
||||||
break;
|
FullFileName = ReturnHotkeyConfigFilePath( g_ConfigFileLocationChoice );
|
||||||
|
FullFileName += HOTKEY_FILENAME;
|
||||||
|
FullFileName += DEFAULT_HOTKEY_FILENAME_EXT;
|
||||||
|
wxString editorname = GetEditorName();
|
||||||
|
if( !editorname.IsEmpty() )
|
||||||
|
ExecuteFile( this, editorname, FullFileName );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
default:
|
case ID_PREFERENCES_HOTKEY_PATH_IS_HOME:
|
||||||
DisplayError(this, wxT("WinEDA_PcbFrame::Process_Config internal error"));
|
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_Board_Editor_Hokeys_Descr );
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
DisplayError( this, wxT( "WinEDA_PcbFrame::Process_Config internal error" ) );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/***************************************************************/
|
/***************************************************************/
|
||||||
bool Read_Hotkey_Config( WinEDA_DrawFrame * frame, bool verbose )
|
bool Read_Hotkey_Config( WinEDA_DrawFrame* frame, bool verbose )
|
||||||
/***************************************************************/
|
/***************************************************************/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Read the hotkey files config for pcbnew and module_edit
|
* Read the hotkey files config for pcbnew and module_edit
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
wxString FullFileName = ReturnHotkeyConfigFilePath( g_ConfigFileLocationChoice );
|
wxString FullFileName = ReturnHotkeyConfigFilePath( g_ConfigFileLocationChoice );
|
||||||
FullFileName += HOTKEY_FILENAME;
|
|
||||||
FullFileName += DEFAULT_HOTKEY_FILENAME_EXT;
|
FullFileName += HOTKEY_FILENAME;
|
||||||
return frame->ReadHotkeyConfigFile(FullFileName, s_Pcbnew_Editor_Hokeys_Descr, verbose);
|
FullFileName += DEFAULT_HOTKEY_FILENAME_EXT;
|
||||||
|
return frame->ReadHotkeyConfigFile( FullFileName, s_Pcbnew_Editor_Hokeys_Descr, verbose );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**************************************************************************/
|
/**************************************************************************/
|
||||||
bool Read_Config(const wxString & project_name)
|
bool Read_Config( const wxString& project_name )
|
||||||
/*************************************************************************/
|
/*************************************************************************/
|
||||||
|
|
||||||
/* lit la configuration, si elle n'a pas deja ete lue
|
/* lit la configuration, si elle n'a pas deja ete lue
|
||||||
1 - lit <nom fichier brd>.pro
|
* 1 - lit <nom fichier brd>.pro
|
||||||
2 - si non trouve lit <chemin de *.exe>/kicad.pro
|
* 2 - si non trouve lit <chemin de *.exe>/kicad.pro
|
||||||
3 - si non trouve: init des variables aux valeurs par defaut
|
* 3 - si non trouve: init des variables aux valeurs par defaut
|
||||||
|
*
|
||||||
Retourne TRUE si lu, FALSE si config non lue ou non modifiée
|
* Retourne TRUE si lu, FALSE si config non lue ou non modifiée
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
wxString FullFileName;
|
wxString FullFileName;
|
||||||
int ii;
|
int ii;
|
||||||
|
|
||||||
g_Prj_Config_Filename_ext = wxT(".pro");
|
g_Prj_Config_Filename_ext = wxT( ".pro" );
|
||||||
FullFileName = project_name;
|
FullFileName = project_name;
|
||||||
ChangeFileNameExt(FullFileName, g_Prj_Config_Filename_ext);
|
ChangeFileNameExt( FullFileName, g_Prj_Config_Filename_ext );
|
||||||
|
|
||||||
/* Init des valeurs par defaut */
|
/* Init des valeurs par defaut */
|
||||||
g_LibName_List.Clear();
|
g_LibName_List.Clear();
|
||||||
|
|
||||||
g_EDA_Appl->ReadProjectConfig( FullFileName,
|
g_EDA_Appl->ReadProjectConfig( FullFileName,
|
||||||
GROUP, ParamCfgList, FALSE);
|
GROUP, ParamCfgList, FALSE );
|
||||||
|
|
||||||
/* Traitement des variables particulieres: */
|
/* Traitement des variables particulieres: */
|
||||||
|
|
||||||
SetRealLibraryPath( wxT("modules") );
|
SetRealLibraryPath( wxT( "modules" ) );
|
||||||
|
|
||||||
if (ScreenPcb)
|
if( ScreenPcb )
|
||||||
{
|
{
|
||||||
ScreenPcb->m_Diviseur_Grille = Pcbdiv_grille;
|
ScreenPcb->m_Diviseur_Grille = Pcbdiv_grille;
|
||||||
ScreenPcb->m_UserGrid = g_UserGrid;
|
ScreenPcb->m_UserGrid = g_UserGrid;
|
||||||
ScreenPcb->m_UserGridUnit = g_UserGrid_Unit;
|
ScreenPcb->m_UserGridUnit = g_UserGrid_Unit;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_DesignSettings.m_TrackWidthHistory[0] = g_DesignSettings.m_CurrentTrackWidth;
|
g_DesignSettings.m_TrackWidthHistory[0] = g_DesignSettings.m_CurrentTrackWidth;
|
||||||
g_DesignSettings.m_ViaSizeHistory[0] = g_DesignSettings.m_CurrentViaSize;
|
g_DesignSettings.m_ViaSizeHistory[0] = g_DesignSettings.m_CurrentViaSize;
|
||||||
for ( ii = 1; ii < HISTORY_NUMBER; ii++)
|
for( ii = 1; ii < HISTORY_NUMBER; ii++ )
|
||||||
{
|
{
|
||||||
g_DesignSettings.m_TrackWidthHistory[ii] = 0;
|
g_DesignSettings.m_TrackWidthHistory[ii] = 0;
|
||||||
g_DesignSettings.m_ViaSizeHistory[ii] = 0;
|
g_DesignSettings.m_ViaSizeHistory[ii] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**********************************************************/
|
/**********************************************************/
|
||||||
void WinEDA_PcbFrame::Update_config(wxWindow * displayframe)
|
void WinEDA_PcbFrame::Update_config( wxWindow* displayframe )
|
||||||
/***********************************************************/
|
/***********************************************************/
|
||||||
/* enregistrement de la config */
|
/* enregistrement de la config */
|
||||||
{
|
{
|
||||||
wxString FullFileName;
|
wxString FullFileName;
|
||||||
wxString mask;
|
wxString mask;
|
||||||
|
|
||||||
mask = wxT("*") + g_Prj_Config_Filename_ext;
|
mask = wxT( "*" ) + g_Prj_Config_Filename_ext;
|
||||||
FullFileName = GetScreen()->m_FileName.AfterLast('/');
|
FullFileName = GetScreen()->m_FileName.AfterLast( '/' );
|
||||||
ChangeFileNameExt(FullFileName, g_Prj_Config_Filename_ext);
|
ChangeFileNameExt( FullFileName, g_Prj_Config_Filename_ext );
|
||||||
|
|
||||||
FullFileName = EDA_FileSelector(_("Save preferences"),
|
FullFileName = EDA_FileSelector( _( "Save preferences" ),
|
||||||
wxPathOnly(GetScreen()->m_FileName), /* Chemin par defaut */
|
wxPathOnly( GetScreen()->m_FileName ), /* Chemin par defaut */
|
||||||
FullFileName, /* nom fichier par defaut */
|
FullFileName, /* nom fichier par defaut */
|
||||||
g_Prj_Config_Filename_ext, /* extension par defaut */
|
g_Prj_Config_Filename_ext, /* extension par defaut */
|
||||||
mask, /* Masque d'affichage */
|
mask, /* Masque d'affichage */
|
||||||
displayframe,
|
displayframe,
|
||||||
wxFD_SAVE,
|
wxFD_SAVE,
|
||||||
TRUE
|
TRUE
|
||||||
);
|
);
|
||||||
if ( FullFileName.IsEmpty() ) return;
|
if( FullFileName.IsEmpty() )
|
||||||
|
return;
|
||||||
|
|
||||||
Pcbdiv_grille = GetScreen()->m_Diviseur_Grille;
|
Pcbdiv_grille = GetScreen()->m_Diviseur_Grille;
|
||||||
|
|
||||||
/* ecriture de la configuration */
|
/* ecriture de la configuration */
|
||||||
g_EDA_Appl->WriteProjectConfig(FullFileName, wxT("/pcbnew"), ParamCfgList);
|
g_EDA_Appl->WriteProjectConfig( FullFileName, wxT( "/pcbnew" ), ParamCfgList );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue