Commit f26f2c13 authored by jerryjacobs's avatar jerryjacobs

Code cleaning and tab indenting + about update

parent 348cfa79
...@@ -58,13 +58,19 @@ InitKiCadAbout( wxAboutDialogInfo& info ) ...@@ -58,13 +58,19 @@ InitKiCadAbout( wxAboutDialogInfo& info )
<< ( wxT( " Ansi\n" ) ); << ( wxT( " Ansi\n" ) );
#endif #endif
/* Check for wxMSW */
#define FreeBSD
/**************************
* Check Operating System *
**************************/
#if defined __WINDOWS__ #if defined __WINDOWS__
description << ( wxT( "on Windows" ) ); description << ( wxT( "on Windows" ) );
/* Check for wxMAC */ /* Check for wxMAC */
# elif defined __WXMAC__ # elif defined __WXMAC__
description << ( wxT( "\non Macintosch" ) ); description << ( wxT( "on Macintosch" ) );
/* Linux 64 bits */ /* Linux 64 bits */
# elif defined _LP64 && __LINUX__ # elif defined _LP64 && __LINUX__
...@@ -73,10 +79,19 @@ InitKiCadAbout( wxAboutDialogInfo& info ) ...@@ -73,10 +79,19 @@ InitKiCadAbout( wxAboutDialogInfo& info )
/* Linux 32 bits */ /* Linux 32 bits */
# elif defined __LINUX__ # elif defined __LINUX__
description << ( wxT( "on 32 Bits GNU/Linux" ) ); description << ( wxT( "on 32 Bits GNU/Linux" ) );
/* OpenBSD */
# elif defined __OpenBSD__
description << ( wxT ("on OpenBSD") );
/* FreeBSD */
# elif defined __FreeBSD__
description << ( wxT ("on FreeBSD") );
#endif #endif
/* Websites */ /* Websites */
description << wxT( "\n\nKiCad on the web\n" ); description << wxT( "\n\nKiCad on the web\n\n" );
description << wxT( "http://iut-tice.ujf-grenoble.fr/kicad \n" ); description << wxT( "http://iut-tice.ujf-grenoble.fr/kicad \n" );
description << wxT( "http://kicad.sourceforge.net \n" ); description << wxT( "http://kicad.sourceforge.net \n" );
description << wxT( "http://www.kicadlib.org" ); description << wxT( "http://www.kicadlib.org" );
...@@ -113,15 +128,15 @@ InitKiCadAbout( wxAboutDialogInfo& info ) ...@@ -113,15 +128,15 @@ InitKiCadAbout( wxAboutDialogInfo& info )
info.AddTranslator( SetMsg( wxT( "Polish (PL) Mateusz Skowroński <skowri@gmail.com>" ) ) ); info.AddTranslator( SetMsg( wxT( "Polish (PL) Mateusz Skowroński <skowri@gmail.com>" ) ) );
info.AddTranslator( SetMsg( wxT( "Portuguese (PT) Renie Marquet <reniemarquet@uol.com.br>" ) ) ); info.AddTranslator( SetMsg( wxT( "Portuguese (PT) Renie Marquet <reniemarquet@uol.com.br>" ) ) );
info.AddTranslator( SetMsg( wxT( "Russian (RU) Igor Plyatov <plyatov@gmail.com>" ) ) ); info.AddTranslator( SetMsg( wxT( "Russian (RU) Igor Plyatov <plyatov@gmail.com>" ) ) );
info.AddTranslator( SetMsg( wxT( "Spanish (ES) Pedro Martin del Valle <pkicad@yahoo.es>" ) ) );
info.AddTranslator( SetMsg( wxT( "Spanish (ES) Iñigo Zuluaga <inigo_zuluaga@yahoo.es>" ) ) );
/* TODO are these all russian translators, placed them here now TODO /* TODO are these all russian translators, placed them here now TODO
TODO or else align them below other language maintainer with mail adres TODO*/ TODO or else align them below other language maintainer with mail adres TODO*/
info.AddTranslator( SetMsg( wxT( " Remy Halvick" ) ) ); info.AddTranslator( SetMsg( wxT( "\n\nRemy Halvick" ) ) );
info.AddTranslator( SetMsg( wxT( " David Briscoe" ) ) ); info.AddTranslator( SetMsg( wxT( "David Briscoe" ) ) );
info.AddTranslator( SetMsg( wxT( " Dominique Laigle" ) ) ); info.AddTranslator( SetMsg( wxT( "Dominique Laigle" ) ) );
info.AddTranslator( SetMsg( wxT( " Paul Burke" ) ) ); info.AddTranslator( SetMsg( wxT( "Paul Burke" ) ) );
info.AddTranslator( SetMsg( wxT( " Pedro Martin del Valle" ) ) );
info.AddTranslator( SetMsg( wxT( " Iñigo Zuluaga" ) ) );
/* Add programm credits for icons */ /* Add programm credits for icons */
info.AddArtist( wxT( "Icons by Iñigo Zuluaga" ) ); info.AddArtist( wxT( "Icons by Iñigo Zuluaga" ) );
......
/***************/ /* TODO ENGLISH BRIEF TODO */
/* edaappl.cpp */ /***
/***************/ * @file edaapl.cpp
* @brief methodes relative a la classe winEDA_App, communes
/*
* ROLE: methodes relative a la classe winEDA_App, communes
* aux environements window et linux * aux environements window et linux
*/ ***/
#define EDA_BASE #define EDA_BASE
#define COMMON_GLOBL #define COMMON_GLOBL
#ifdef KICAD_PYTHON #ifdef KICAD_PYTHON
#include <pyhandler.h> # include <pyhandler.h>
#endif #endif
#include "fctsys.h" #include "fctsys.h"
...@@ -27,34 +26,61 @@ ...@@ -27,34 +26,61 @@
#include "bitmaps.h" #include "bitmaps.h"
#define FONT_DEFAULT_SIZE 10 /* Default font size. #ifdef __UNIX__
* The real font size will be computed at run time */ # define TMP_FILE "/tmp/kicad.tmp"
#endif
/* A small class to handle the list od existing translations.
/* Just add new languages to the list. This macro will properly recalculate
* the size of the array. */
#define LANGUAGE_DESCR_COUNT ( sizeof( s_Language_List ) / \
sizeof( struct LANGUAGE_DESCR ) )
/* Default font size */
#define FONT_DEFAULT_SIZE 10 /* Default font size. */
/***
* @brief The real font size will be computed at run time
* A small class to handle the list od existing translations.
* the locale translation is automatic. * the locale translation is automatic.
* the selection of languages is mainly for mainteners's convenience (tests...) * the selection of languages is mainly for mainteners's convenience (tests...)\n
* To add a support to a new tranlation: * To add a support to a new tranlation:
* create a new icon (flag of the country) (see Lang_Fr.xpm as an exemple) * create a new icon (flag of the country) (see Lang_Fr.xpm as an exemple)
* add a new item to s_Language_List[LANGUAGE_DESCR_COUNT] * add a new item to s_Language_List[LANGUAGE_DESCR_COUNT]
* and set LANGUAGE_DESCR_COUNT to the new value * and set LANGUAGE_DESCR_COUNT to the new value
*/ ***/
struct LANGUAGE_DESCR struct
LANGUAGE_DESCR
{ {
int m_WX_Lang_Identifier; // wxWidget locale identifier (see wxWidget doc) /* wxWidgets locale identifier (See wxWidgets doc) */
int m_KI_Lang_Identifier; // kicad identifier used in menu selection (see id.h) int m_WX_Lang_Identifier;
const char** m_Lang_Icon; // the icon used in menus /* KiCad identifier used in menu selection (See id.h) */
const wxChar* m_Lang_Label; // Label used in menus int m_KI_Lang_Identifier;
bool m_DoNotTranslate; // set to true if the m_Lang_Label must not be translated /* The menu language icons */
const char** m_Lang_Icon;
/* Labels used in menus */
const wxChar* m_Lang_Label;
/* Set to true if the m_Lang_Label must not be translated */
bool m_DoNotTranslate;
}; };
static struct LANGUAGE_DESCR s_Language_List[] =
/***
* @brief Language list struct
***/
static struct
LANGUAGE_DESCR s_Language_List[] =
{ {
/* Default language */
{ {
wxLANGUAGE_DEFAULT, wxLANGUAGE_DEFAULT,
ID_LANGUAGE_DEFAULT, ID_LANGUAGE_DEFAULT,
lang_def_xpm, lang_def_xpm,
_( "Default" ) _( "Default" )
}, },
/* English language */
{ {
wxLANGUAGE_ENGLISH, wxLANGUAGE_ENGLISH,
ID_LANGUAGE_ENGLISH, ID_LANGUAGE_ENGLISH,
...@@ -62,84 +88,112 @@ static struct LANGUAGE_DESCR s_Language_List[] = ...@@ -62,84 +88,112 @@ static struct LANGUAGE_DESCR s_Language_List[] =
wxT( "English" ), wxT( "English" ),
true true
}, },
/* French language */
{ {
wxLANGUAGE_FRENCH, wxLANGUAGE_FRENCH,
ID_LANGUAGE_FRENCH, ID_LANGUAGE_FRENCH,
lang_fr_xpm, lang_fr_xpm,
_( "French" ) _( "French" )
}, },
/* Spanish language */
{ {
wxLANGUAGE_SPANISH, wxLANGUAGE_SPANISH,
ID_LANGUAGE_SPANISH, ID_LANGUAGE_SPANISH,
lang_es_xpm, lang_es_xpm,
_( "Spanish" ) _( "Spanish" )
}, },
/* Portugese language */
{ {
wxLANGUAGE_PORTUGUESE, wxLANGUAGE_PORTUGUESE,
ID_LANGUAGE_PORTUGUESE, ID_LANGUAGE_PORTUGUESE,
lang_pt_xpm, lang_pt_xpm,
_( "Portuguese" ) _( "Portuguese" )
}, },
/* Italian language */
{ {
wxLANGUAGE_ITALIAN, wxLANGUAGE_ITALIAN,
ID_LANGUAGE_ITALIAN, ID_LANGUAGE_ITALIAN,
lang_it_xpm, lang_it_xpm,
_( "Italian" ) _( "Italian" )
}, },
/* German language */
{ {
wxLANGUAGE_GERMAN, wxLANGUAGE_GERMAN,
ID_LANGUAGE_GERMAN, ID_LANGUAGE_GERMAN,
lang_de_xpm, lang_de_xpm,
_( "German" ) _( "German" )
}, },
/* Slovenian language */
{ {
wxLANGUAGE_SLOVENIAN, wxLANGUAGE_SLOVENIAN,
ID_LANGUAGE_SLOVENIAN, ID_LANGUAGE_SLOVENIAN,
lang_sl_xpm, lang_sl_xpm,
_( "Slovenian" ) _( "Slovenian" )
}, },
/* Hungarian language */
{ {
wxLANGUAGE_HUNGARIAN, wxLANGUAGE_HUNGARIAN,
ID_LANGUAGE_HUNGARIAN, ID_LANGUAGE_HUNGARIAN,
lang_hu_xpm, lang_hu_xpm,
_( "Hungarian" ) _( "Hungarian" )
}, },
/* Polish language */
{ {
wxLANGUAGE_POLISH, wxLANGUAGE_POLISH,
ID_LANGUAGE_POLISH, ID_LANGUAGE_POLISH,
lang_pl_xpm, lang_pl_xpm,
_( "Polish" ) _( "Polish" )
}, },
/* Czech language */
{ {
wxLANGUAGE_CZECH, wxLANGUAGE_CZECH,
ID_LANGUAGE_CZECH, ID_LANGUAGE_CZECH,
lang_cs_xpm, lang_cs_xpm,
_( "Czech" ) _( "Czech" )
}, },
/* Russian language */
{ {
wxLANGUAGE_RUSSIAN, wxLANGUAGE_RUSSIAN,
ID_LANGUAGE_RUSSIAN, ID_LANGUAGE_RUSSIAN,
lang_ru_xpm, lang_ru_xpm,
_( "Russian" ) _( "Russian" )
}, },
/* Korean language */
{ {
wxLANGUAGE_KOREAN, wxLANGUAGE_KOREAN,
ID_LANGUAGE_KOREAN, ID_LANGUAGE_KOREAN,
lang_ko_xpm, lang_ko_xpm,
_( "Korean" ) _( "Korean" )
}, },
/* Chinese simplified */
{ {
wxLANGUAGE_CHINESE_SIMPLIFIED, wxLANGUAGE_CHINESE_SIMPLIFIED,
ID_LANGUAGE_CHINESE_SIMPLIFIED, ID_LANGUAGE_CHINESE_SIMPLIFIED,
lang_chinese_xpm, lang_chinese_xpm,
_( "Chinese simplified" ) _( "Chinese simplified" )
}, },
/* Catalan language */
{ {
wxLANGUAGE_CATALAN, wxLANGUAGE_CATALAN,
ID_LANGUAGE_CATALAN, ID_LANGUAGE_CATALAN,
lang_catalan_xpm, lang_catalan_xpm,
_( "Catalan" ) _( "Catalan" )
}, },
/* Dutch language */
{ {
wxLANGUAGE_DUTCH, wxLANGUAGE_DUTCH,
ID_LANGUAGE_DUTCH, ID_LANGUAGE_DUTCH,
...@@ -148,15 +202,12 @@ static struct LANGUAGE_DESCR s_Language_List[] = ...@@ -148,15 +202,12 @@ static struct LANGUAGE_DESCR s_Language_List[] =
} }
}; };
/* Just add new languages to the list. This macro will properly recalculate
* the size of the array. */
#define LANGUAGE_DESCR_COUNT ( sizeof( s_Language_List ) / \
sizeof( struct LANGUAGE_DESCR ) )
/**************************/
/* WinEDA_App Constructor */
/**************************/
/***
* @brief WinEDA_App Constructor
* @details TODO
* @return none
***/
WinEDA_App::WinEDA_App() WinEDA_App::WinEDA_App()
{ {
m_Checker = NULL; m_Checker = NULL;
...@@ -168,15 +219,13 @@ WinEDA_App::WinEDA_App() ...@@ -168,15 +219,13 @@ WinEDA_App::WinEDA_App()
m_LanguageId = wxLANGUAGE_DEFAULT; m_LanguageId = wxLANGUAGE_DEFAULT;
m_Language_Menu = NULL; m_Language_Menu = NULL;
m_Locale = NULL; m_Locale = NULL;
m_PdfBrowserIsDefault = TRUE; m_PdfBrowserIsDefault = TRUE;
} }
/*************************/ /***
/* WinEDA_App Destructor */ * @brief WinEDA_App Destructor
/*************************/ ***/
WinEDA_App::~WinEDA_App() WinEDA_App::~WinEDA_App()
{ {
SaveSettings(); SaveSettings();
...@@ -196,9 +245,14 @@ WinEDA_App::~WinEDA_App() ...@@ -196,9 +245,14 @@ WinEDA_App::~WinEDA_App()
} }
/**************************************************/
void WinEDA_App::InitEDA_Appl( const wxString& name ) /***
/***************************************************/ * @brief TODO
* @param name TODO
* @return none
***/
void
WinEDA_App::InitEDA_Appl( const wxString& name )
{ {
wxString ident; wxString ident;
wxString EnvLang; wxString EnvLang;
...@@ -218,8 +272,8 @@ void WinEDA_App::InitEDA_Appl( const wxString& name ) ...@@ -218,8 +272,8 @@ void WinEDA_App::InitEDA_Appl( const wxString& name )
m_KicadEnv += UNIX_STRING_DIR_SEP; m_KicadEnv += UNIX_STRING_DIR_SEP;
} }
/* Prepare On Line Help. Use only lower case for help filenames, /* Prepare On Line Help. Use only lower case for help filenames,
* in order to avoid problems with upper/lower case filenames under windows and unix */ * in order to avoid problems with upper/lower case filenames under windows and unix */
#if defined ONLINE_HELP_FILES_FORMAT_IS_HTML #if defined ONLINE_HELP_FILES_FORMAT_IS_HTML
m_HelpFileName = name.Lower() + wxT( ".html" ); m_HelpFileName = name.Lower() + wxT( ".html" );
#elif defined ONLINE_HELP_FILES_FORMAT_IS_PDF #elif defined ONLINE_HELP_FILES_FORMAT_IS_PDF
...@@ -228,31 +282,49 @@ void WinEDA_App::InitEDA_Appl( const wxString& name ) ...@@ -228,31 +282,49 @@ void WinEDA_App::InitEDA_Appl( const wxString& name )
#error Help files format not defined #error Help files format not defined
#endif #endif
// Init parameters for configuration /* Init parameters for configuration */
SetVendorName( wxT( "kicad" ) ); SetVendorName( wxT( "kicad" ) );
SetAppName( name ); SetAppName( name );
m_EDA_Config = new wxConfig( name ); m_EDA_Config = new wxConfig( name );
m_EDA_CommonConfig = new wxConfig( wxT( "kicad_common" ) ); m_EDA_CommonConfig = new wxConfig( wxT( "kicad_common" ) );
/* Create the fontes used in dialogs and messages */ /* Create the fonts used in dialogs and messages */
g_StdFontPointSize = FONT_DEFAULT_SIZE; g_StdFontPointSize = FONT_DEFAULT_SIZE;
g_MsgFontPointSize = FONT_DEFAULT_SIZE; g_MsgFontPointSize = FONT_DEFAULT_SIZE;
g_DialogFontPointSize = FONT_DEFAULT_SIZE; g_DialogFontPointSize = FONT_DEFAULT_SIZE;
g_FixedFontPointSize = FONT_DEFAULT_SIZE; g_FixedFontPointSize = FONT_DEFAULT_SIZE;
g_StdFont = new wxFont( g_StdFontPointSize, wxFONTFAMILY_ROMAN,
wxNORMAL, wxNORMAL ); g_StdFont = new wxFont(
g_MsgFont = new wxFont( g_StdFontPointSize, wxFONTFAMILY_ROMAN, g_StdFontPointSize,
wxNORMAL, wxNORMAL ); wxFONTFAMILY_ROMAN,
g_DialogFont = new wxFont( g_DialogFontPointSize, wxFONTFAMILY_ROMAN, wxNORMAL,
wxNORMAL, wxNORMAL ); wxNORMAL );
g_ItalicFont = new wxFont( g_DialogFontPointSize,
g_MsgFont = new wxFont(
g_StdFontPointSize,
wxFONTFAMILY_ROMAN,
wxNORMAL,
wxNORMAL );
g_DialogFont = new wxFont(
g_DialogFontPointSize,
wxFONTFAMILY_ROMAN,
wxNORMAL,
wxNORMAL );
g_ItalicFont = new wxFont(
g_DialogFontPointSize,
wxFONTFAMILY_ROMAN, wxFONTFAMILY_ROMAN,
wxFONTSTYLE_ITALIC, wxFONTSTYLE_ITALIC,
wxNORMAL ); wxNORMAL );
g_FixedFont = new wxFont( g_FixedFontPointSize, wxFONTFAMILY_MODERN,
wxNORMAL, wxNORMAL );
/* installation des gestionnaires de visu d'images (pour help) */ g_FixedFont = new wxFont(
g_FixedFontPointSize,
wxFONTFAMILY_MODERN,
wxNORMAL,
wxNORMAL );
/* TODO installation des gestionnaires de visu d'images (pour help) TODO*/
wxImage::AddHandler( new wxPNGHandler ); wxImage::AddHandler( new wxPNGHandler );
wxImage::AddHandler( new wxGIFHandler ); wxImage::AddHandler( new wxGIFHandler );
wxImage::AddHandler( new wxJPEGHandler ); wxImage::AddHandler( new wxJPEGHandler );
...@@ -260,7 +332,6 @@ void WinEDA_App::InitEDA_Appl( const wxString& name ) ...@@ -260,7 +332,6 @@ void WinEDA_App::InitEDA_Appl( const wxString& name )
// Analyse the command line & init binary path // Analyse the command line & init binary path
SetBinDir(); SetBinDir();
ReadPdfBrowserInfos(); ReadPdfBrowserInfos();
// Internationalisation: loading the kicad suitable Dictionnary // Internationalisation: loading the kicad suitable Dictionnary
...@@ -272,7 +343,8 @@ void WinEDA_App::InitEDA_Appl( const wxString& name ) ...@@ -272,7 +343,8 @@ void WinEDA_App::InitEDA_Appl( const wxString& name )
{ {
} }
SetLocaleTo_Default(); // Set locale option for separator used in float numbers /* Set locale option for separator used in float numbers */
SetLocaleTo_Default();
#ifdef KICAD_PYTHON #ifdef KICAD_PYTHON
PyHandler::GetInstance()->SetAppName( name ); PyHandler::GetInstance()->SetAppName( name );
...@@ -280,18 +352,22 @@ void WinEDA_App::InitEDA_Appl( const wxString& name ) ...@@ -280,18 +352,22 @@ void WinEDA_App::InitEDA_Appl( const wxString& name )
} }
/***
* @brief Init online help
* @return none
***/
/*****************************************/ /*****************************************/
void WinEDA_App::InitOnLineHelp() void
WinEDA_App::InitOnLineHelp()
/*****************************************/ /*****************************************/
/* Init On Line Help
*/
{ {
wxString fullfilename = FindKicadHelpPath(); wxString fullfilename = FindKicadHelpPath();
#if defined ONLINE_HELP_FILES_FORMAT_IS_HTML #if defined ONLINE_HELP_FILES_FORMAT_IS_HTML
m_HelpFileName = fullfilename + wxT( ".html" ); m_HelpFileName = fullfilename + wxT( ".html" );
fullfilename += wxT( "kicad.hhp" ); fullfilename += wxT( "kicad.hhp" );
if( wxFileExists( fullfilename ) ) if( wxFileExists( fullfilename ) )
{ {
m_HtmlCtrl = new wxHtmlHelpController( wxHF_TOOLBAR | wxHF_CONTENTS | m_HtmlCtrl = new wxHtmlHelpController( wxHF_TOOLBAR | wxHF_CONTENTS |
...@@ -301,47 +377,56 @@ void WinEDA_App::InitOnLineHelp() ...@@ -301,47 +377,56 @@ void WinEDA_App::InitOnLineHelp()
m_HtmlCtrl->SetTitleFormat( wxT( "Kicad Help" ) ); m_HtmlCtrl->SetTitleFormat( wxT( "Kicad Help" ) );
m_HtmlCtrl->AddBook( fullfilename ); m_HtmlCtrl->AddBook( fullfilename );
} }
#elif defined ONLINE_HELP_FILES_FORMAT_IS_PDF #elif defined ONLINE_HELP_FILES_FORMAT_IS_PDF
m_HtmlCtrl = NULL; m_HtmlCtrl = NULL;
#else #else
#error Help files format not defined #error Help files format not defined
#endif #endif
} }
/***
* @brief Find the path to the executable and store it in WinEDA_App::m_BinDir
* @return TODO
***/
/*******************************/ /*******************************/
bool WinEDA_App::SetBinDir() bool
WinEDA_App::SetBinDir()
/*******************************/ /*******************************/
// Find the path to the executable and store it in WinEDA_App::m_BinDir
{ {
/* Apple MacOSx */
#ifdef __APPLE__ #ifdef __APPLE__
// Derive path from location of the app bundle /* Derive path from location of the app bundle */
CFBundleRef mainBundle = CFBundleGetMainBundle(); CFBundleRef mainBundle = CFBundleGetMainBundle();
if( mainBundle == NULL ) if( mainBundle == NULL )
return false; return false;
CFURLRef urlref = CFBundleCopyBundleURL( mainBundle ); CFURLRef urlref = CFBundleCopyBundleURL( mainBundle );
if( urlref == NULL ) if( urlref == NULL )
return false; return false;
CFStringRef str = CFURLCopyFileSystemPath( urlref, kCFURLPOSIXPathStyle ); CFStringRef str = CFURLCopyFileSystemPath( urlref, kCFURLPOSIXPathStyle );
if( str == NULL ) if( str == NULL )
return false; 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 );
delete[] native_str; delete[] native_str;
/* Linux and Unix */
#elif defined (__UNIX__) #elif defined (__UNIX__)
// Under Linux, if argv[0] doesn't the complete path to the executable, // Under Linux, if argv[0] doesn't the complete path to the executable,
// it's necessary to obtain it using "which <filename>". // it's necessary to obtain it using "which <filename>".
FILE* ftmp; FILE* ftmp;
#define TMP_FILE "/tmp/kicad.tmp"
char Line[1024]; char Line[1024];
char FileName[1024]; char FileName[1024];
wxString str_arg0; wxString str_arg0;
...@@ -353,6 +438,7 @@ bool WinEDA_App::SetBinDir() ...@@ -353,6 +438,7 @@ bool WinEDA_App::SetBinDir()
{ {
sprintf( FileName, "which %s > %s", CONV_TO_UTF8( str_arg0 ), TMP_FILE ); sprintf( FileName, "which %s > %s", CONV_TO_UTF8( str_arg0 ), TMP_FILE );
ii = system( FileName ); ii = system( FileName );
if( ( ftmp = fopen( TMP_FILE, "rt" ) ) != NULL ) if( ( ftmp = fopen( TMP_FILE, "rt" ) ) != NULL )
{ {
fgets( Line, 1000, ftmp ); fgets( Line, 1000, ftmp );
...@@ -363,9 +449,10 @@ bool WinEDA_App::SetBinDir() ...@@ -363,9 +449,10 @@ bool WinEDA_App::SetBinDir()
} }
else else
m_BinDir = argv[0]; m_BinDir = argv[0];
#else #else
m_BinDir = argv[0]; m_BinDir = argv[0];
#endif #endif /* __UNIX__ */
m_BinDir.Replace( WIN_STRING_DIR_SEP, UNIX_STRING_DIR_SEP ); m_BinDir.Replace( WIN_STRING_DIR_SEP, UNIX_STRING_DIR_SEP );
while( m_BinDir.Last() != '/' ) while( m_BinDir.Last() != '/' )
...@@ -375,12 +462,14 @@ bool WinEDA_App::SetBinDir() ...@@ -375,12 +462,14 @@ bool WinEDA_App::SetBinDir()
} }
/***
* @brief Get application settings
* @return none
***/
/*********************************/ /*********************************/
void WinEDA_App::GetSettings() void
WinEDA_App::GetSettings()
/*********************************/ /*********************************/
/* Get the last setup used (fontes, files opened...)
*/
{ {
wxString Line, Ident; wxString Line, Ident;
unsigned ii; unsigned ii;
...@@ -399,7 +488,7 @@ void WinEDA_App::GetSettings() ...@@ -399,7 +488,7 @@ void WinEDA_App::GetSettings()
if( !m_EDA_Config ) if( !m_EDA_Config )
return; return;
/* Last 10 project settings */
for( ii = 0; ii < 10; ii++ ) for( ii = 0; ii < 10; ii++ )
{ {
Ident = wxT( "LastProject" ); Ident = wxT( "LastProject" );
...@@ -411,6 +500,7 @@ void WinEDA_App::GetSettings() ...@@ -411,6 +500,7 @@ void WinEDA_App::GetSettings()
m_LastProject.Add( Line ); m_LastProject.Add( Line );
} }
/* Set default font sizes */
g_StdFontPointSize = m_EDA_Config->Read( wxT( "SdtFontSize" ), g_StdFontPointSize = m_EDA_Config->Read( wxT( "SdtFontSize" ),
FONT_DEFAULT_SIZE ); FONT_DEFAULT_SIZE );
g_MsgFontPointSize = m_EDA_Config->Read( wxT( "MsgFontSize" ), g_MsgFontPointSize = m_EDA_Config->Read( wxT( "MsgFontSize" ),
...@@ -420,27 +510,35 @@ void WinEDA_App::GetSettings() ...@@ -420,27 +510,35 @@ void WinEDA_App::GetSettings()
g_FixedFontPointSize = m_EDA_Config->Read( wxT( "FixedFontSize" ), g_FixedFontPointSize = m_EDA_Config->Read( wxT( "FixedFontSize" ),
FONT_DEFAULT_SIZE ); FONT_DEFAULT_SIZE );
/* Sdt font type */
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 );
/* Sdt font style */
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 );
/* Sdt font weight */
ii = m_EDA_Config->Read( wxT( "SdtFontWeight" ), wxNORMAL ); ii = m_EDA_Config->Read( wxT( "SdtFontWeight" ), wxNORMAL );
g_StdFont->SetWeight( ii ); g_StdFont->SetWeight( ii );
g_StdFont->SetPointSize( g_StdFontPointSize ); g_StdFont->SetPointSize( g_StdFontPointSize );
/* Msg font type */
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 );
/* Msg font style */
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 );
/* Msg font weight */
ii = m_EDA_Config->Read( wxT( "MsgFontWeight" ), wxNORMAL ); ii = m_EDA_Config->Read( wxT( "MsgFontWeight" ), wxNORMAL );
g_MsgFont->SetWeight( ii ); g_MsgFont->SetWeight( ii );
g_MsgFont->SetPointSize( g_MsgFontPointSize ); g_MsgFont->SetPointSize( g_MsgFontPointSize );
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 );
...@@ -464,58 +562,87 @@ void WinEDA_App::GetSettings() ...@@ -464,58 +562,87 @@ void WinEDA_App::GetSettings()
} }
/***
* @brief Save application settings
* @return none
***/
/**********************************/ /**********************************/
void WinEDA_App::SaveSettings() void
WinEDA_App::SaveSettings()
/**********************************/ /**********************************/
{ {
unsigned int ii; unsigned int i;
if( m_EDA_Config == NULL ) if( m_EDA_Config == NULL )
return; return;
m_EDA_Config->Write( wxT( "SdtFontSize" ), g_StdFontPointSize ); /* Sdt font settings */
m_EDA_Config->Write( wxT( "SdtFontType" ), g_StdFont->GetFaceName() ); m_EDA_Config->Write( wxT( "SdtFontSize" ),
m_EDA_Config->Write( wxT( "SdtFontStyle" ), g_StdFont->GetStyle() ); g_StdFontPointSize );
m_EDA_Config->Write( wxT( "SdtFontWeight" ), g_StdFont->GetWeight() ); m_EDA_Config->Write( wxT( "SdtFontType" ),
g_StdFont->GetFaceName() );
m_EDA_Config->Write( wxT( "MsgFontSize" ), g_MsgFontPointSize ); m_EDA_Config->Write( wxT( "SdtFontStyle" ),
m_EDA_Config->Write( wxT( "MsgFontType" ), g_MsgFont->GetFaceName() ); g_StdFont->GetStyle() );
m_EDA_Config->Write( wxT( "MsgFontStyle" ), g_MsgFont->GetStyle() ); m_EDA_Config->Write( wxT( "SdtFontWeight" ),
m_EDA_Config->Write( wxT( "MsgFontWeight" ), g_MsgFont->GetWeight() ); g_StdFont->GetWeight() );
m_EDA_Config->Write( wxT( "DialogFontSize" ), g_DialogFontPointSize ); /* Msg font settings */
m_EDA_Config->Write( wxT( "DialogFontType" ), g_DialogFont->GetFaceName() ); m_EDA_Config->Write( wxT( "MsgFontSize" ),
m_EDA_Config->Write( wxT( "DialogFontStyle" ), g_DialogFont->GetStyle() ); g_MsgFontPointSize );
m_EDA_Config->Write( wxT( "DialogFontWeight" ), g_DialogFont->GetWeight() ); m_EDA_Config->Write( wxT( "MsgFontType" ),
g_MsgFont->GetFaceName() );
m_EDA_Config->Write( wxT( "FixedFontSize" ), g_FixedFontPointSize ); m_EDA_Config->Write( wxT( "MsgFontStyle" ),
g_MsgFont->GetStyle() );
m_EDA_Config->Write( wxT( "ShowPageLimits" ), g_ShowPageLimits ); m_EDA_Config->Write( wxT( "MsgFontWeight" ),
g_MsgFont->GetWeight() );
m_EDA_Config->Write( wxT( "WorkingDir" ), wxGetCwd() );
/* Dialog font settings */
for( ii = 0; ii < 10; ii++ ) m_EDA_Config->Write( wxT( "DialogFontSize" ),
g_DialogFontPointSize );
m_EDA_Config->Write( wxT( "DialogFontType" ),
g_DialogFont->GetFaceName() );
m_EDA_Config->Write( wxT( "DialogFontStyle" ),
g_DialogFont->GetStyle() );
m_EDA_Config->Write( wxT( "DialogFontWeight" ),
g_DialogFont->GetWeight() );
/* Misc settings */
m_EDA_Config->Write( wxT( "FixedFontSize" ),
g_FixedFontPointSize );
m_EDA_Config->Write( wxT( "ShowPageLimits" ),
g_ShowPageLimits );
m_EDA_Config->Write( wxT( "WorkingDir" ),
wxGetCwd() );
/* Save last 10 project list */
for( i = 0; i < 10; i++ )
{ {
wxString msg = wxT( "LastProject" ); wxString msg = wxT( "LastProject" );
if( ii ) if( i )
msg << ii; msg << i;
if( ii < m_LastProject.GetCount() ) if( i < m_LastProject.GetCount() )
m_EDA_Config->Write( msg, m_LastProject[ii] ); m_EDA_Config->Write( msg, m_LastProject[i] );
else else
m_EDA_Config->Write( msg, wxEmptyString ); m_EDA_Config->Write( msg, wxEmptyString );
} }
} }
/*********************************************/ /***
bool WinEDA_App::SetLanguage( bool first_time ) * @brief Set the dictionary file name for internationalization
/*********************************************/
/* Set the dictionary file name for internationalization
* the files are in kicad/internat/xx or kicad/internat/xx_XX * the files are in kicad/internat/xx or kicad/internat/xx_XX
* and are named kicad.mo * and are named kicad.mo
*/ *
* @param first_time TODO
* @return TODO
***/
/*********************************************/
bool
WinEDA_App::SetLanguage( bool first_time )
/*********************************************/
{ {
wxString DictionaryName( wxT( "kicad" ) ); // dictionary file name without extend (full name is kicad.mo) wxString DictionaryName( wxT( "kicad" ) ); // dictionary file name without extend (full name is kicad.mo)
wxString BaseDictionaryPath( wxT( "internat" ) ); // Real path is kicad/internat/xx_XX or kicad/internat/xx wxString BaseDictionaryPath( wxT( "internat" ) ); // Real path is kicad/internat/xx_XX or kicad/internat/xx
...@@ -542,23 +669,27 @@ bool WinEDA_App::SetLanguage( bool first_time ) ...@@ -542,23 +669,27 @@ bool WinEDA_App::SetLanguage( bool first_time )
m_Locale->AddCatalog( DictionaryName ); m_Locale->AddCatalog( DictionaryName );
SetLanguageList( NULL ); SetLanguageList( NULL );
return m_Locale->IsOk(); return m_Locale->IsOk();
} }
/**************************************************/
void WinEDA_App::SetLanguageIdentifier( int menu_id )
/**************************************************/
/* return in m_LanguageId the wxWidgets language identifier Id /***
* @brief Return in m_LanguageId the wxWidgets language identifier Id
* from the kicad menu id (internal menu identifier) * from the kicad menu id (internal menu identifier)
*/ * @param menu_id TODO
* @return none
***/
/**************************************************/
void
WinEDA_App::SetLanguageIdentifier( int menu_id )
/**************************************************/
{ {
unsigned int ii; unsigned int ii;
wxLogDebug( wxT( "Select language ID %d from %d possible languages." ), wxLogDebug( wxT( "Select language ID %d from %d possible languages." ),
menu_id, LANGUAGE_DESCR_COUNT ); menu_id,
LANGUAGE_DESCR_COUNT );
for( ii = 0; ii < LANGUAGE_DESCR_COUNT; ii++ ) for( ii = 0; ii < LANGUAGE_DESCR_COUNT; ii++ )
{ {
...@@ -571,12 +702,16 @@ void WinEDA_App::SetLanguageIdentifier( int menu_id ) ...@@ -571,12 +702,16 @@ void WinEDA_App::SetLanguageIdentifier( int menu_id )
} }
/***
* @brief Create menu list for language choice.
* @param MasterMenu TODO
* @return TODO
***/
/*********************************************************/ /*********************************************************/
wxMenu* WinEDA_App::SetLanguageList( wxMenu* MasterMenu ) wxMenu*
WinEDA_App::SetLanguageList( wxMenu* MasterMenu )
/*********************************************************/ /*********************************************************/
/* Create menu list for language choice.
*/
{ {
wxMenuItem* item; wxMenuItem* item;
unsigned int ii; unsigned int ii;
...@@ -589,8 +724,10 @@ wxMenu* WinEDA_App::SetLanguageList( wxMenu* MasterMenu ) ...@@ -589,8 +724,10 @@ wxMenu* WinEDA_App::SetLanguageList( wxMenu* MasterMenu )
wxString MenuLabel = s_Language_List[ii].m_DoNotTranslate ? wxString MenuLabel = s_Language_List[ii].m_DoNotTranslate ?
s_Language_List[ii].m_Lang_Label : s_Language_List[ii].m_Lang_Label :
wxGetTranslation( s_Language_List[ii].m_Lang_Label ); wxGetTranslation( s_Language_List[ii].m_Lang_Label );
item = new wxMenuItem( m_Language_Menu, s_Language_List[ii].m_KI_Lang_Identifier, item = new wxMenuItem( m_Language_Menu, s_Language_List[ii].m_KI_Lang_Identifier,
MenuLabel, wxEmptyString, wxITEM_CHECK ); MenuLabel, wxEmptyString, wxITEM_CHECK );
SETBITMAPS( s_Language_List[ii].m_Lang_Icon ); SETBITMAPS( s_Language_List[ii].m_Lang_Icon );
m_Language_Menu->Append( item ); m_Language_Menu->Append( item );
} }
...@@ -599,17 +736,17 @@ wxMenu* WinEDA_App::SetLanguageList( wxMenu* MasterMenu ) ...@@ -599,17 +736,17 @@ wxMenu* WinEDA_App::SetLanguageList( wxMenu* MasterMenu )
for( ii = 0; ii < LANGUAGE_DESCR_COUNT; ii++ ) for( ii = 0; ii < LANGUAGE_DESCR_COUNT; ii++ )
{ {
if( m_LanguageId == s_Language_List[ii].m_WX_Lang_Identifier ) if( m_LanguageId == s_Language_List[ii].m_WX_Lang_Identifier )
m_Language_Menu->Check( s_Language_List[ii].m_KI_Lang_Identifier, m_Language_Menu->Check( s_Language_List[ii].m_KI_Lang_Identifier, true );
true );
else else
m_Language_Menu->Check( s_Language_List[ii].m_KI_Lang_Identifier, m_Language_Menu->Check( s_Language_List[ii].m_KI_Lang_Identifier, false );
false );
} }
if( MasterMenu ) if( MasterMenu )
{ {
ADD_MENUITEM_WITH_HELP_AND_SUBMENU( MasterMenu, m_Language_Menu, ADD_MENUITEM_WITH_HELP_AND_SUBMENU( MasterMenu,
ID_LANGUAGE_CHOICE, _( "Language" ), m_Language_Menu,
ID_LANGUAGE_CHOICE,
_( "Language" ),
_( "Select application language (only for testing!)" ), _( "Select application language (only for testing!)" ),
language_xpm ); language_xpm );
} }
...@@ -617,15 +754,18 @@ wxMenu* WinEDA_App::SetLanguageList( wxMenu* MasterMenu ) ...@@ -617,15 +754,18 @@ wxMenu* WinEDA_App::SetLanguageList( wxMenu* MasterMenu )
} }
/***
* @brief Run init scripts
* @return TODO
***/
/**********************/ /**********************/
int WinEDA_App::OnRun() int
WinEDA_App::OnRun()
/**********************/ /**********************/
/* Run init scripts
*/
{ {
#ifdef KICAD_PYTHON # ifdef KICAD_PYTHON
PyHandler::GetInstance()->RunScripts(); PyHandler::GetInstance()->RunScripts();
#endif # endif
return wxApp::OnRun(); return wxApp::OnRun();
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment