EDA_APP::EDA_APP() { m_Checker = NULL; m_oneInstancePerFileChecker = NULL; m_HtmlCtrl = NULL; m_settings = NULL; setLanguageId( wxLANGUAGE_DEFAULT ); m_Locale = NULL; m_projectSettings = NULL; m_commonSettings = NULL; ForceSystemPdfBrowser( false ); }
PGM_BASE::PGM_BASE() { m_pgm_checker = NULL; m_locale = NULL; m_common_settings = NULL; m_show_env_var_dialog = true; setLanguageId( wxLANGUAGE_DEFAULT ); ForceSystemPdfBrowser( false ); }
void EDA_APP::SetLanguageIdentifier( int menu_id ) { wxLogDebug( wxT( "Select language ID %d from %zd possible languages." ), menu_id, DIM( s_Languages ) ); for( unsigned ii = 0; ii < DIM( s_Languages ); ii++ ) { if( menu_id == s_Languages[ii].m_KI_Lang_Identifier ) { setLanguageId( s_Languages[ii].m_WX_Lang_Identifier ); break; } } }
PGM_BASE::PGM_BASE() { m_pgm_checker = NULL; m_file_checker = NULL; m_html_ctrl = NULL; m_locale = NULL; m_common_settings = NULL; m_wx_app = NULL; setLanguageId( wxLANGUAGE_DEFAULT ); ForceSystemPdfBrowser( false ); }
void PGM_BASE::loadCommonSettings() { wxASSERT( m_common_settings ); m_help_size.x = 500; m_help_size.y = 400; wxString languageSel; m_common_settings->Read( languageCfgKey, &languageSel ); setLanguageId( wxLANGUAGE_DEFAULT ); // Search for the current selection for( unsigned ii = 0; ii < DIM( s_Languages ); ii++ ) { if( s_Languages[ii].m_Lang_Label == languageSel ) { setLanguageId( s_Languages[ii].m_WX_Lang_Identifier ); break; } } m_editor_name = m_common_settings->Read( wxT( "Editor" ) ); }
bool EDA_APP::SetLanguage( bool first_time ) { bool retv = true; // dictionary file name without extend (full name is kicad.mo) wxString DictionaryName( wxT( "kicad" ) ); delete m_Locale; m_Locale = new wxLocale; #if wxCHECK_VERSION( 2, 9, 0 ) if( !m_Locale->Init( m_LanguageId ) ) #else if( !m_Locale->Init( m_LanguageId, wxLOCALE_CONV_ENCODING ) ) #endif { wxLogDebug( wxT( "This language is not supported by the system." ) ); setLanguageId( wxLANGUAGE_DEFAULT ); delete m_Locale; m_Locale = new wxLocale; m_Locale->Init(); retv = false; } else if( !first_time ) { wxLogDebug( wxT( "Search for dictionary %s.mo in %s" ), GetChars( DictionaryName ), GetChars( m_Locale->GetName() ) ); } if( !first_time ) { wxString languageSel; // Search for the current selection for( unsigned ii = 0; ii < DIM( s_Languages ); ii++ ) { if( s_Languages[ii].m_WX_Lang_Identifier == m_LanguageId ) { languageSel = s_Languages[ii].m_Lang_Label; break; } } m_commonSettings->Write( languageCfgKey, languageSel ); } // Test if floating point notation is working (bug in cross compilation, using wine) // Make a conversion double <=> string double dtst = 0.5; wxString msg; extern bool g_DisableFloatingPointLocalNotation; // See common.cpp g_DisableFloatingPointLocalNotation = false; msg << dtst; double result; msg.ToDouble( &result ); if( result != dtst ) // string to double encode/decode does not work! Bug detected { // Disable floating point localization: g_DisableFloatingPointLocalNotation = true; SetLocaleTo_C_standard( ); } if( !m_Locale->IsLoaded( DictionaryName ) ) m_Locale->AddCatalog( DictionaryName ); if( !retv ) return retv; return m_Locale->IsOk(); }
void EDA_APP::GetSettings( bool aReopenLastUsedDirectory ) { wxASSERT( m_settings != NULL && m_commonSettings != NULL ); m_HelpSize.x = 500; m_HelpSize.y = 400; wxString languageSel; m_commonSettings->Read( languageCfgKey, &languageSel ); setLanguageId( wxLANGUAGE_DEFAULT ); // Search for the current selection for( unsigned ii = 0; ii < DIM( s_Languages ); ii++ ) { if( s_Languages[ii].m_Lang_Label == languageSel ) { setLanguageId( s_Languages[ii].m_WX_Lang_Identifier ); break; } } m_EditorName = m_commonSettings->Read( wxT( "Editor" ) ); m_fileHistory.Load( *m_settings ); m_settings->Read( showPageLimitsKey, &g_ShowPageLimits ); if( aReopenLastUsedDirectory ) { wxString dir; if( m_settings->Read( workingDirKey, &dir ) && wxDirExists( dir ) ) { wxSetWorkingDirectory( dir ); } } // FIXME OSX Mountain Lion (10.8) // Seems that Read doesn't found anything and ColorFromInt Asserts - I'm unable to reproduce // on 10.7 // In general terms I think is better have a failsafe default than an uninit variable int draw_bg_color = (int)BLACK; // Default for all apps but Eeschema if( m_Id == APP_EESCHEMA_T ) draw_bg_color = (int)WHITE; // Default for Eeschema m_settings->Read( backgroundColorKey, &draw_bg_color ); g_DrawBgColor = ColorFromInt( draw_bg_color ); // Load per-user search paths from settings file wxString upath; int i = 1; while( 1 ) { upath = m_commonSettings->Read( wxString::Format( wxT( "LibraryPath%d" ), i ), wxT( "" ) ); if( upath.IsSameAs( wxT( "" ) ) ) break; m_libSearchPaths.Add( upath ); i++; } }
void EDA_APP::InitEDA_Appl( const wxString& aName, EDA_APP_T aId ) { m_Id = aId; m_Checker = new wxSingleInstanceChecker( aName.Lower() + wxT( "-" ) + wxGetUserId() ); // Init KiCad environment // the environment variable KICAD (if exists) gives the kicad path: // something like set KICAD=d:\kicad bool isDefined = wxGetEnv( wxT( "KICAD" ), &m_KicadEnv ); if( isDefined ) // ensure m_KicadEnv ends by "/" { m_KicadEnv.Replace( WIN_STRING_DIR_SEP, UNIX_STRING_DIR_SEP ); if( !m_KicadEnv.IsEmpty() && m_KicadEnv.Last() != '/' ) m_KicadEnv += UNIX_STRING_DIR_SEP; } // Prepare On Line Help. Use only lower case for help file names, in order to // avoid problems with upper/lower case file names under windows and unix. #if defined ONLINE_HELP_FILES_FORMAT_IS_HTML m_HelpFileName = aName.Lower() + wxT( ".html" ); #elif defined ONLINE_HELP_FILES_FORMAT_IS_PDF m_HelpFileName = aName.Lower() + wxT( ".pdf" ); #else #error Help files format not defined #endif // Init parameters for configuration SetVendorName( wxT( "KiCad" ) ); SetAppName( aName.Lower() ); SetTitle( aName ); m_settings = new wxConfig(); wxASSERT( m_settings != NULL ); m_commonSettings = new wxConfig( CommonConfigPath ); wxASSERT( m_commonSettings != NULL ); // Install some image handlers, mainly for help wxImage::AddHandler( new wxPNGHandler ); wxImage::AddHandler( new wxGIFHandler ); wxImage::AddHandler( new wxJPEGHandler ); wxFileSystem::AddHandler( new wxZipFSHandler ); // Analyze the command line & init binary path SetBinDir(); SetDefaultSearchPaths(); SetLanguagePath(); ReadPdfBrowserInfos(); // Internationalization: loading the kicad suitable Dictionary wxString languageSel; m_commonSettings->Read( languageCfgKey, &languageSel); setLanguageId( wxLANGUAGE_DEFAULT ); // Search for the current selection for( unsigned ii = 0; ii < DIM( s_Languages ); ii++ ) { if( s_Languages[ii].m_Lang_Label == languageSel ) { setLanguageId( s_Languages[ii].m_WX_Lang_Identifier ); break; } } bool succes = SetLanguage( true ); if( !succes ) { } // Set locale option for separator used in float numbers SetLocaleTo_Default(); }
bool PGM_BASE::SetLanguage( bool first_time ) { bool retv = true; if( first_time ) { setLanguageId( wxLANGUAGE_DEFAULT ); // First time SetLanguage is called, the user selected language id is set // from commun user config settings wxString languageSel; m_common_settings->Read( languageCfgKey, &languageSel ); // Search for the current selection for( unsigned ii = 0; ii < DIM( s_Languages ); ii++ ) { if( s_Languages[ii].m_Lang_Label == languageSel ) { setLanguageId( s_Languages[ii].m_WX_Lang_Identifier ); break; } } } // dictionary file name without extend (full name is kicad.mo) wxString dictionaryName( wxT( "kicad" ) ); delete m_locale; m_locale = new wxLocale; if( !m_locale->Init( m_language_id ) ) { wxLogDebug( wxT( "This language is not supported by the system." ) ); setLanguageId( wxLANGUAGE_DEFAULT ); delete m_locale; m_locale = new wxLocale; m_locale->Init(); retv = false; } else if( !first_time ) { wxLogDebug( wxT( "Search for dictionary %s.mo in %s" ), GetChars( dictionaryName ), GetChars( m_locale->GetName() ) ); } if( !first_time ) { // If we are here, the user has selected an other language. // Therefore the new prefered language name is stored in common config. // Do NOT store the wxWidgets language Id, it can change between wxWidgets // versions, for a given language wxString languageSel; // Search for the current selection for( unsigned ii = 0; ii < DIM( s_Languages ); ii++ ) { if( s_Languages[ii].m_WX_Lang_Identifier == m_language_id ) { languageSel = s_Languages[ii].m_Lang_Label; break; } } m_common_settings->Write( languageCfgKey, languageSel ); } // Test if floating point notation is working (bug in cross compilation, using wine) // Make a conversion double <=> string double dtst = 0.5; wxString msg; extern bool g_DisableFloatingPointLocalNotation; // See common.cpp g_DisableFloatingPointLocalNotation = false; msg << dtst; double result; msg.ToDouble( &result ); if( result != dtst ) // string to double encode/decode does not work! Bug detected { // Disable floating point localization: g_DisableFloatingPointLocalNotation = true; SetLocaleTo_C_standard( ); } if( !m_locale->IsLoaded( dictionaryName ) ) m_locale->AddCatalog( dictionaryName ); if( !retv ) return retv; return m_locale->IsOk(); }