Commit 0e27f45f authored by Wayne Stambaugh's avatar Wayne Stambaugh

Encapsulate EDA_APP class.

parent d4635805
......@@ -113,7 +113,7 @@ void EDA_3D_FRAME::OnCloseWindow( wxCloseEvent& Event )
void EDA_3D_FRAME::GetSettings()
{
wxString text;
wxConfig* config = wxGetApp().m_EDA_Config; // Current config used by application
wxConfig* config = wxGetApp().GetSettings(); // Current config used by application
if( config )
{
......@@ -140,7 +140,7 @@ void EDA_3D_FRAME::GetSettings()
void EDA_3D_FRAME::SaveSettings()
{
wxString text;
wxConfig* Config = wxGetApp().m_EDA_Config; // Current config used by application
wxConfig* Config = wxGetApp().GetSettings(); // Current config used by application
if( !Config )
return;
......
......@@ -100,10 +100,8 @@ EDA_BASE_FRAME::EDA_BASE_FRAME( wxWindow* father,
EDA_BASE_FRAME::~EDA_BASE_FRAME()
{
if( wxGetApp().m_HtmlCtrl )
delete wxGetApp().m_HtmlCtrl;
wxGetApp().m_HtmlCtrl = NULL;
if( wxGetApp().GetHtmlHelpController() )
wxGetApp().SetHtmlHelpController( NULL );
delete m_autoSaveTimer;
......@@ -174,7 +172,7 @@ void EDA_BASE_FRAME::LoadSettings()
int Ypos_min;
wxConfig* config;
config = wxGetApp().m_EDA_Config;
config = wxGetApp().GetSettings();
int maximized = 0;
......@@ -219,7 +217,7 @@ void EDA_BASE_FRAME::SaveSettings()
wxString text;
wxConfig* config;
config = wxGetApp().m_EDA_Config;
config = wxGetApp().GetSettings();
if( ( config == NULL ) || IsIconized() )
return;
......@@ -275,7 +273,7 @@ void EDA_BASE_FRAME::UpdateFileHistory( const wxString& FullFileName,
wxFileHistory * fileHistory = aFileHistory;
if( fileHistory == NULL )
fileHistory = & wxGetApp().m_fileHistory;
fileHistory = & wxGetApp().GetFileHistory();
fileHistory->AddFileToHistory( FullFileName );
}
......@@ -289,7 +287,7 @@ wxString EDA_BASE_FRAME::GetFileFromHistory( int cmdId, const wxString& type,
wxFileHistory * fileHistory = aFileHistory;
if( fileHistory == NULL )
fileHistory = & wxGetApp().m_fileHistory;
fileHistory = & wxGetApp().GetFileHistory();
int baseId = fileHistory->GetBaseId();
......@@ -321,28 +319,28 @@ void EDA_BASE_FRAME::GetKicadHelp( wxCommandEvent& event )
/* We have to get document for beginners,
* or the the full specific doc
* if event id is wxID_INDEX, we want the document for beginners.
* else the specific doc file (its name is in wxGetApp().m_HelpFileName)
* else the specific doc file (its name is in wxGetApp().GetHelpFileName())
* The document for beginners is the same for all KiCad utilities
*/
if( event.GetId() == wxID_INDEX )
{
// Temporary change the help filename
wxString tmp = wxGetApp().m_HelpFileName;
wxString tmp = wxGetApp().GetHelpFileName();
// Search for "getting_started_in_kicad.pdf" or "Getting_Started_in_KiCad.pdf"
wxGetApp().m_HelpFileName = wxT( "getting_started_in_kicad.pdf" );
wxGetApp().GetHelpFileName() = wxT( "getting_started_in_kicad.pdf" );
wxString helpFile = wxGetApp().GetHelpFile();
if( !helpFile )
{ // Try to find "Getting_Started_in_KiCad.pdf"
wxGetApp().m_HelpFileName = wxT( "Getting_Started_in_KiCad.pdf" );
wxGetApp().GetHelpFileName() = wxT( "Getting_Started_in_KiCad.pdf" );
helpFile = wxGetApp().GetHelpFile();
}
if( !helpFile )
{
msg.Printf( _( "Help file %s could not be found." ),
GetChars( wxGetApp().m_HelpFileName ) );
GetChars( wxGetApp().GetHelpFileName() ) );
DisplayError( this, msg );
}
else
......@@ -350,26 +348,26 @@ void EDA_BASE_FRAME::GetKicadHelp( wxCommandEvent& event )
GetAssociatedDocument( this, helpFile );
}
wxGetApp().m_HelpFileName = tmp;
wxGetApp().SetHelpFileName( tmp );
return;
}
#if defined ONLINE_HELP_FILES_FORMAT_IS_HTML
if( wxGetApp().m_HtmlCtrl == NULL )
if( wxGetApp().GetHtmlHelpController() == NULL )
{
wxGetApp().InitOnLineHelp();
}
if( wxGetApp().m_HtmlCtrl )
if( wxGetApp().GetHtmlHelpController() )
{
wxGetApp().m_HtmlCtrl->DisplayContents();
wxGetApp().m_HtmlCtrl->Display( wxGetApp().m_HelpFileName );
wxGetApp().GetHtmlHelpController()->DisplayContents();
wxGetApp().GetHtmlHelpController()->Display( wxGetApp().GetHelpFileName() );
}
else
{
msg.Printf( _( "Help file %s not found." ), GetChars( wxGetApp().m_HelpFileName ) );
msg.Printf( _( "Help file %s not found." ), GetChars( wxGetApp().GetHelpFileName() ) );
DisplayError( this, msg );
}
......@@ -379,7 +377,7 @@ void EDA_BASE_FRAME::GetKicadHelp( wxCommandEvent& event )
if( !helpFile )
{
msg.Printf( _( "Help file %s could not be found." ),
GetChars( wxGetApp().m_HelpFileName ) );
GetChars( wxGetApp().GetHelpFileName() ) );
DisplayError( this, msg );
}
else
......@@ -395,7 +393,7 @@ void EDA_BASE_FRAME::GetKicadHelp( wxCommandEvent& event )
void EDA_BASE_FRAME::OnSelectPreferredEditor( wxCommandEvent& event )
{
wxFileName fn = wxGetApp().m_EditorName;
wxFileName fn = wxGetApp().GetEditorName();
wxString wildcard( wxT( "*" ) );
#ifdef __WINDOWS__
......@@ -411,11 +409,11 @@ void EDA_BASE_FRAME::OnSelectPreferredEditor( wxCommandEvent& event )
if( dlg.ShowModal() == wxID_CANCEL )
return;
wxASSERT( wxGetApp().m_EDA_CommonConfig );
wxASSERT( wxGetApp().GetCommonSettings() );
wxConfig* cfg = wxGetApp().m_EDA_CommonConfig;
wxGetApp().m_EditorName = dlg.GetPath();
cfg->Write( wxT( "Editor" ), wxGetApp().m_EditorName );
wxConfig* cfg = wxGetApp().GetCommonSettings();
wxGetApp().SetEditorName( dlg.GetPath() );
cfg->Write( wxT( "Editor" ), wxGetApp().GetEditorName() );
}
......
......@@ -829,9 +829,9 @@ void EDA_DRAW_FRAME::UpdateStatusBar()
void EDA_DRAW_FRAME::LoadSettings()
{
wxASSERT( wxGetApp().m_EDA_Config != NULL );
wxASSERT( wxGetApp().GetSettings() != NULL );
wxConfig* cfg = wxGetApp().m_EDA_Config;
wxConfig* cfg = wxGetApp().GetSettings();
EDA_BASE_FRAME::LoadSettings();
cfg->Read( m_FrameName + CursorShapeEntryKeyword, &m_cursorShape, ( long )0 );
......@@ -851,9 +851,9 @@ void EDA_DRAW_FRAME::LoadSettings()
void EDA_DRAW_FRAME::SaveSettings()
{
wxASSERT( wxGetApp().m_EDA_Config != NULL );
wxASSERT( wxGetApp().GetSettings() != NULL );
wxConfig* cfg = wxGetApp().m_EDA_Config;
wxConfig* cfg = wxGetApp().GetSettings();
EDA_BASE_FRAME::SaveSettings();
cfg->Write( m_FrameName + CursorShapeEntryKeyword, m_cursorShape );
......
......@@ -102,8 +102,8 @@ EDA_DRAW_PANEL::EDA_DRAW_PANEL( EDA_DRAW_FRAME* parent, int id,
m_mouseCaptureCallback = NULL;
m_endMouseCaptureCallback = NULL;
if( wxGetApp().m_EDA_Config )
wxGetApp().m_EDA_Config->Read( wxT( "AutoPAN" ), &m_AutoPAN_Enable, true );
if( wxGetApp().GetSettings() )
wxGetApp().GetSettings()->Read( wxT( "AutoPAN" ), &m_AutoPAN_Enable, true );
m_AutoPAN_Request = false;
m_Block_Enable = false;
......@@ -123,7 +123,7 @@ EDA_DRAW_PANEL::EDA_DRAW_PANEL( EDA_DRAW_FRAME* parent, int id,
EDA_DRAW_PANEL::~EDA_DRAW_PANEL()
{
wxGetApp().m_EDA_Config->Write( wxT( "AutoPAN" ), m_AutoPAN_Enable );
wxGetApp().GetSettings()->Write( wxT( "AutoPAN" ), m_AutoPAN_Enable );
}
......
......@@ -16,25 +16,17 @@
void EDA_APP::ReadPdfBrowserInfos()
{
wxASSERT( m_EDA_CommonConfig != NULL );
wxASSERT( m_commonSettings != NULL );
m_PdfBrowserIsDefault = m_EDA_CommonConfig->Read( wxT( "PdfBrowserIsDefault" ), true );
m_PdfBrowser = m_EDA_CommonConfig->Read( wxT( "PdfBrowserName" ), wxEmptyString );
if( m_PdfBrowser.IsEmpty() )
m_PdfBrowserIsDefault = true;
m_PdfBrowser = m_commonSettings->Read( wxT( "PdfBrowserName" ), wxEmptyString );
}
void EDA_APP::WritePdfBrowserInfos()
{
wxASSERT( m_EDA_CommonConfig != NULL );
if( m_PdfBrowser.IsEmpty() )
m_PdfBrowserIsDefault = true;
wxASSERT( m_commonSettings != NULL );
m_EDA_CommonConfig->Write( wxT( "PdfBrowserIsDefault" ), m_PdfBrowserIsDefault );
m_EDA_CommonConfig->Write( wxT( "PdfBrowserName" ), m_PdfBrowser );
m_commonSettings->Write( wxT( "PdfBrowserName" ), m_PdfBrowser );
}
......
/***
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 2008-2011 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @file edaapl.cpp
*
* @brief For the main application: init functions, and language selection
* (locale handling)
***/
* @brief For the main application: init functions, and language selection
* (locale handling)
*/
#include "fctsys.h"
#include "gr_basic.h"
......@@ -246,15 +271,13 @@ static struct LANGUAGE_DESCR s_Language_List[] =
EDA_APP::EDA_APP()
{
m_Checker = NULL;
m_HtmlCtrl = NULL;
m_EDA_Config = NULL;
m_Env_Defined = false;
m_LanguageId = wxLANGUAGE_DEFAULT;
m_PdfBrowserIsDefault = true;
m_Checker = NULL;
m_HtmlCtrl = NULL;
m_settings = NULL;
m_LanguageId = wxLANGUAGE_DEFAULT;
m_Locale = NULL;
m_ProjectConfig = NULL;
m_EDA_CommonConfig = NULL;
m_projectSettings = NULL;
m_commonSettings = NULL;
}
......@@ -263,13 +286,13 @@ EDA_APP::~EDA_APP()
SaveSettings();
/* delete user datas */
if( m_ProjectConfig )
delete m_ProjectConfig;
if( m_projectSettings )
delete m_projectSettings;
if( m_EDA_CommonConfig )
delete m_EDA_CommonConfig;
if( m_commonSettings )
delete m_commonSettings;
delete m_EDA_Config;
delete m_settings;
if( m_Checker )
delete m_Checker;
......@@ -289,9 +312,9 @@ void EDA_APP::InitEDA_Appl( const wxString& aName, EDA_APP_T aId )
* the environment variable KICAD (if exists) gives the kicad path:
* something like set KICAD=d:\kicad
*/
m_Env_Defined = wxGetEnv( wxT( "KICAD" ), &m_KicadEnv );
bool isDefined = wxGetEnv( wxT( "KICAD" ), &m_KicadEnv );
if( m_Env_Defined ) // ensure m_KicadEnv ends by "/"
if( isDefined ) // ensure m_KicadEnv ends by "/"
{
m_KicadEnv.Replace( WIN_STRING_DIR_SEP, UNIX_STRING_DIR_SEP );
......@@ -313,10 +336,10 @@ void EDA_APP::InitEDA_Appl( const wxString& aName, EDA_APP_T aId )
SetVendorName( wxT( "KiCad" ) );
SetAppName( aName.Lower() );
SetTitle( aName );
m_EDA_Config = new wxConfig();
wxASSERT( m_EDA_Config != NULL );
m_EDA_CommonConfig = new wxConfig( CommonConfigPath );
wxASSERT( m_EDA_CommonConfig != NULL );
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 );
......@@ -332,7 +355,7 @@ void EDA_APP::InitEDA_Appl( const wxString& aName, EDA_APP_T aId )
// Internationalization: loading the kicad suitable Dictionary
wxString languageSel;
m_EDA_CommonConfig->Read( languageCfgKey, &languageSel);
m_commonSettings->Read( languageCfgKey, &languageSel);
m_LanguageId = wxLANGUAGE_DEFAULT;
// Search for the current selection
......@@ -356,6 +379,15 @@ void EDA_APP::InitEDA_Appl( const wxString& aName, EDA_APP_T aId )
}
void EDA_APP::SetHtmlHelpController( wxHtmlHelpController* aController )
{
if( m_HtmlCtrl )
delete m_HtmlCtrl;
m_HtmlCtrl = aController;
}
void EDA_APP::InitOnLineHelp()
{
wxString fullfilename = FindKicadHelpPath();
......@@ -369,7 +401,7 @@ void EDA_APP::InitOnLineHelp()
m_HtmlCtrl = new wxHtmlHelpController( wxHF_TOOLBAR | wxHF_CONTENTS |
wxHF_PRINT | wxHF_OPEN_FILES
/*| wxHF_SEARCH */ );
m_HtmlCtrl->UseConfig( m_EDA_CommonConfig );
m_HtmlCtrl->UseConfig( m_commonSettings );
m_HtmlCtrl->SetTitleFormat( wxT( "KiCad Help" ) );
m_HtmlCtrl->AddBook( fullfilename );
}
......@@ -620,7 +652,7 @@ void EDA_APP::SetDefaultSearchPaths( void )
void EDA_APP::GetSettings( bool aReopenLastUsedDirectory )
{
wxASSERT( m_EDA_Config != NULL && m_EDA_CommonConfig != NULL );
wxASSERT( m_settings != NULL && m_commonSettings != NULL );
wxString Line;
......@@ -628,7 +660,7 @@ void EDA_APP::GetSettings( bool aReopenLastUsedDirectory )
m_HelpSize.y = 400;
wxString languageSel;
m_EDA_CommonConfig->Read( languageCfgKey, &languageSel );
m_commonSettings->Read( languageCfgKey, &languageSel );
m_LanguageId = wxLANGUAGE_DEFAULT;
// Search for the current selection
......@@ -641,21 +673,21 @@ void EDA_APP::GetSettings( bool aReopenLastUsedDirectory )
}
}
m_EditorName = m_EDA_CommonConfig->Read( wxT( "Editor" ) );
m_EditorName = m_commonSettings->Read( wxT( "Editor" ) );
m_fileHistory.Load( *m_EDA_Config );
m_fileHistory.Load( *m_settings );
m_EDA_Config->Read( wxT( "ShowPageLimits" ), &g_ShowPageLimits );
m_settings->Read( wxT( "ShowPageLimits" ), &g_ShowPageLimits );
if( aReopenLastUsedDirectory )
{
if( m_EDA_Config->Read( wxT( "WorkingDir" ), &Line ) && wxDirExists( Line ) )
if( m_settings->Read( wxT( "WorkingDir" ), &Line ) && wxDirExists( Line ) )
{
wxSetWorkingDirectory( Line );
}
}
m_EDA_Config->Read( wxT( "BgColor" ), &g_DrawBgColor );
m_settings->Read( wxT( "BgColor" ), &g_DrawBgColor );
/* Load per-user search paths from settings file */
......@@ -664,8 +696,8 @@ void EDA_APP::GetSettings( bool aReopenLastUsedDirectory )
while( 1 )
{
upath = m_EDA_CommonConfig->Read( wxString::Format( wxT( "LibraryPath%d" ), i ),
wxT( "" ) );
upath = m_commonSettings->Read( wxString::Format( wxT( "LibraryPath%d" ), i ),
wxT( "" ) );
if( upath.IsSameAs( wxT( "" ) ) )
break;
......@@ -678,13 +710,13 @@ void EDA_APP::GetSettings( bool aReopenLastUsedDirectory )
void EDA_APP::SaveSettings()
{
wxASSERT( m_EDA_Config != NULL );
m_EDA_Config->Write( wxT( "ShowPageLimits" ), g_ShowPageLimits );
m_EDA_Config->Write( wxT( "WorkingDir" ), wxGetCwd() );
m_EDA_Config->Write( wxT( "BgColor" ), g_DrawBgColor );
wxASSERT( m_settings != NULL );
m_settings->Write( wxT( "ShowPageLimits" ), g_ShowPageLimits );
m_settings->Write( wxT( "WorkingDir" ), wxGetCwd() );
m_settings->Write( wxT( "BgColor" ), g_DrawBgColor );
/* Save the file history list */
m_fileHistory.Save( *m_EDA_Config );
m_fileHistory.Save( *m_settings );
}
......@@ -734,7 +766,7 @@ bool EDA_APP::SetLanguage( bool first_time )
}
}
m_EDA_CommonConfig->Write( languageCfgKey, languageSel );
m_commonSettings->Write( languageCfgKey, languageSel );
}
// Test if floating point notation is working (bug in cross compilation, using wine)
......
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 2008-2011 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @file gestfich.cpp
* @brief Functions for file management
......@@ -272,14 +297,14 @@ wxString FindKicadHelpPath()
bool PathFound = false;
/* find kicad/help/ */
tmp = wxGetApp().m_BinDir;
tmp = wxGetApp().GetExecutablePath();
if( tmp.Last() == '/' )
tmp.RemoveLast();
FullPath = tmp.BeforeLast( '/' ); // cd ..
FullPath += wxT( "/doc/help/" );
LocaleString = wxGetApp().m_Locale->GetCanonicalName();
LocaleString = wxGetApp().GetLocale()->GetCanonicalName();
wxString path_tmp = FullPath;
#ifdef __WINDOWS__
......@@ -292,9 +317,9 @@ wxString FindKicadHelpPath()
}
/* find kicad/help/ from environment variable KICAD */
if( !PathFound && wxGetApp().m_Env_Defined )
if( !PathFound && wxGetApp().IsKicadEnvVariableDefined() )
{
FullPath = wxGetApp().m_KicadEnv + wxT( "/doc/help/" );
FullPath = wxGetApp().GetKicadEnvVariable() + wxT( "/doc/help/" );
if( wxDirExists( FullPath ) )
PathFound = true;
......@@ -352,7 +377,7 @@ wxString FindKicadFile( const wxString& shortname )
/* Test the presence of the file in the directory shortname of
* the KiCad binary path.
*/
FullFileName = wxGetApp().m_BinDir + shortname;
FullFileName = wxGetApp().GetExecutablePath() + shortname;
if( wxFileExists( FullFileName ) )
return FullFileName;
......@@ -360,9 +385,9 @@ wxString FindKicadFile( const wxString& shortname )
/* Test the presence of the file in the directory shortname
* defined by the environment variable KiCad.
*/
if( wxGetApp().m_Env_Defined )
if( wxGetApp().IsKicadEnvVariableDefined() )
{
FullFileName = wxGetApp().m_KicadEnv + shortname;
FullFileName = wxGetApp().GetKicadEnvVariable() + shortname;
if( wxFileExists( FullFileName ) )
return FullFileName;
......@@ -416,22 +441,21 @@ wxString ReturnKicadDatasPath()
bool PathFound = false;
wxString data_path;
if( wxGetApp().m_Env_Defined ) // Path defined by the KICAD environment variable.
if( wxGetApp().IsKicadEnvVariableDefined() ) // Path defined by the KICAD environment variable.
{
data_path = wxGetApp().m_KicadEnv;
data_path = wxGetApp().GetKicadEnvVariable();
PathFound = true;
}
else // Path of executables.
{
wxString tmp = wxGetApp().m_BinDir;
wxString tmp = wxGetApp().GetExecutablePath();
#ifdef __WINDOWS__
tmp.MakeLower();
#endif
if( tmp.Contains( wxT( "kicad" ) ) )
{
#ifdef __WINDOWS__
tmp = wxGetApp().m_BinDir;
tmp = wxGetApp().GetExecutablePath();
#endif
if( tmp.Last() == '/' )
tmp.RemoveLast();
......@@ -523,7 +547,7 @@ wxString& EDA_APP::GetEditorName()
if( !editorname.IsEmpty() )
{
m_EditorName = editorname;
m_EDA_CommonConfig->Write( wxT( "Editor" ), m_EditorName );
m_commonSettings->Write( wxT( "Editor" ), m_EditorName );
}
return m_EditorName;
......@@ -539,10 +563,10 @@ bool OpenPDF( const wxString& file )
wxGetApp().ReadPdfBrowserInfos();
if( !wxGetApp().m_PdfBrowserIsDefault ) // Run the preferred PDF Browser
if( !wxGetApp().UseSystemPdfBrowser() ) // Run the preferred PDF Browser
{
AddDelimiterString( filename );
command = wxGetApp().m_PdfBrowser + wxT( " " ) + filename;
command = wxGetApp().GetPdfBrowserFileName() + wxT( " " ) + filename;
}
else
{
......@@ -554,13 +578,15 @@ bool OpenPDF( const wxString& file )
success = filetype->GetOpenCommand( &command, params );
delete filetype;
#ifndef __WINDOWS__
// Bug ? under linux wxWidgets returns acroread as PDF viewer, even
// Bug ? under linux wxWidgets returns acroread as PDF viewer, even if
// it does not exist.
if( command.StartsWith( wxT( "acroread" ) ) ) // Workaround
success = false;
#endif
if( success && !command.IsEmpty() )
{
success = ProcessExecute( command );
......@@ -576,6 +602,7 @@ bool OpenPDF( const wxString& file )
{
#ifndef __WINDOWS__
AddDelimiterString( filename );
/* here is a list of PDF viewers candidates */
const static wxString tries[] =
{
......
This diff is collapsed.
......@@ -185,7 +185,7 @@ CVPCB_MAINFRAME::CVPCB_MAINFRAME( const wxString& title, long style ) :
CVPCB_MAINFRAME::~CVPCB_MAINFRAME()
{
wxConfig* config = wxGetApp().m_EDA_Config;
wxConfig* config = wxGetApp().GetSettings();
if( config )
{
......@@ -199,9 +199,9 @@ CVPCB_MAINFRAME::~CVPCB_MAINFRAME()
void CVPCB_MAINFRAME::LoadSettings()
{
wxASSERT( wxGetApp().m_EDA_Config != NULL );
wxASSERT( wxGetApp().GetSettings() != NULL );
wxConfig* cfg = wxGetApp().m_EDA_Config;
wxConfig* cfg = wxGetApp().GetSettings();
EDA_BASE_FRAME::LoadSettings();
cfg->Read( KeepCvpcbOpenEntry, &m_KeepCvpcbOpen, true );
......@@ -212,9 +212,9 @@ void CVPCB_MAINFRAME::LoadSettings()
void CVPCB_MAINFRAME::SaveSettings()
{
wxASSERT( wxGetApp().m_EDA_Config != NULL );
wxASSERT( wxGetApp().GetSettings() != NULL );
wxConfig* cfg = wxGetApp().m_EDA_Config;
wxConfig* cfg = wxGetApp().GetSettings();
EDA_BASE_FRAME::SaveSettings();
cfg->Write( KeepCvpcbOpenEntry, m_KeepCvpcbOpen );
......@@ -278,10 +278,10 @@ void CVPCB_MAINFRAME::OnCloseWindow( wxCloseEvent& Event )
}
// Close the help frame
if( wxGetApp().m_HtmlCtrl )
if( wxGetApp().GetHtmlHelpController() )
{
if( wxGetApp().m_HtmlCtrl->GetFrame() ) // returns NULL if no help frame active
wxGetApp().m_HtmlCtrl->GetFrame()->Close( true );
if( wxGetApp().GetHtmlHelpController()->GetFrame() )// returns NULL if no help frame active
wxGetApp().GetHtmlHelpController()->GetFrame()->Close( true );
}
if( m_NetlistFileName.IsOk() )
......
......@@ -29,7 +29,7 @@ DIALOG_CVPCB_CONFIG::DIALOG_CVPCB_CONFIG( CVPCB_MAINFRAME* parent ) :
fn.SetExt( ProjectFileExtension );
m_Parent = parent;
m_Config = wxGetApp().m_EDA_CommonConfig;
m_Config = wxGetApp().GetCommonSettings();
Init( );
title = _( "Project file: " ) + fn.GetFullPath();
......
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 2004-2011 KiCad Developers, see change_log.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @file cvpcb/menubar.cpp
* @brief (Re)Create the menubar for CvPcb
......@@ -49,11 +73,11 @@ void CVPCB_MAINFRAME::ReCreateMenuBar()
// Add this menu to list menu managed by m_fileHistory
// (the file history will be updated when adding/removing files in history
if( openRecentMenu )
wxGetApp().m_fileHistory.RemoveMenu( openRecentMenu );
wxGetApp().GetFileHistory().RemoveMenu( openRecentMenu );
openRecentMenu = new wxMenu();
wxGetApp().m_fileHistory.UseMenu( openRecentMenu );
wxGetApp().m_fileHistory.AddFilesToMenu();
wxGetApp().GetFileHistory().UseMenu( openRecentMenu );
wxGetApp().GetFileHistory().AddFilesToMenu();
AddMenuItem( filesMenu, openRecentMenu, -1,
_( "Open &Recent" ),
_( "Open a recent opened netlist document" ),
......
......@@ -39,7 +39,7 @@
void CVPCB_MAINFRAME::ReCreateHToolbar()
{
wxConfig* config = wxGetApp().m_EDA_Config;
wxConfig* config = wxGetApp().GetSettings();
if( m_mainToolBar != NULL )
return;
......
......@@ -54,7 +54,7 @@ DIALOG_ANNOTATE::DIALOG_ANNOTATE( SCH_EDIT_FRAME* parent )
void DIALOG_ANNOTATE::InitValues()
/*********************************/
{
m_Config = wxGetApp().m_EDA_Config;
m_Config = wxGetApp().GetSettings();
SetFocus(); // needed to close dialog by escape key
if( m_Config )
{
......
......@@ -61,7 +61,7 @@ DIALOG_SVG_PRINT::DIALOG_SVG_PRINT( EDA_DRAW_FRAME* parent ) :
DIALOG_SVG_PRINT_base( parent )
{
m_Parent = parent;
m_Config = wxGetApp().m_EDA_Config;
m_Config = wxGetApp().GetSettings();
}
......
......@@ -111,7 +111,7 @@ static char s_ExportSeparator[] = ("\t;,.");
DIALOG_BUILD_BOM::DIALOG_BUILD_BOM( EDA_DRAW_FRAME* parent ) :
DIALOG_BUILD_BOM_BASE( parent )
{
m_Config = wxGetApp().m_EDA_Config;
m_Config = wxGetApp().GetSettings();
wxASSERT( m_Config != NULL );
m_Parent = parent;
......
......@@ -53,7 +53,7 @@ DIALOG_EESCHEMA_CONFIG::DIALOG_EESCHEMA_CONFIG( SCH_EDIT_FRAME* aSchFrame,
Init();
msg = _( "from " ) + wxGetApp().m_CurrentOptionFile;
msg = _( "from " ) + wxGetApp().GetCurrentOptionFile();
SetTitle( msg );
if( GetSizer() )
......
......@@ -511,11 +511,11 @@ PARAM_CFG_ARRAY& SCH_EDIT_FRAME::GetConfigurationSettings( void )
void SCH_EDIT_FRAME::LoadSettings()
{
wxASSERT( wxGetApp().m_EDA_Config != NULL );
wxASSERT( wxGetApp().GetSettings() != NULL );
long tmp;
wxConfig* cfg = wxGetApp().m_EDA_Config;
wxConfig* cfg = wxGetApp().GetSettings();
EDA_DRAW_FRAME::LoadSettings();
......@@ -607,9 +607,9 @@ void SCH_EDIT_FRAME::LoadSettings()
void SCH_EDIT_FRAME::SaveSettings()
{
wxASSERT( wxGetApp().m_EDA_Config != NULL );
wxASSERT( wxGetApp().GetSettings() != NULL );
wxConfig* cfg = wxGetApp().m_EDA_Config;
wxConfig* cfg = wxGetApp().GetSettings();
EDA_DRAW_FRAME::SaveSettings();
......
......@@ -291,8 +291,8 @@ void LIB_EDIT_FRAME::LoadSettings()
EDA_DRAW_FRAME::LoadSettings();
wxConfigPathChanger cpc( wxGetApp().m_EDA_Config, m_configPath );
cfg = wxGetApp().m_EDA_Config;
wxConfigPathChanger cpc( wxGetApp().GetSettings(), m_configPath );
cfg = wxGetApp().GetSettings();
m_lastLibExportPath = cfg->Read( lastLibExportPathEntry, ::wxGetCwd() );
m_lastLibImportPath = cfg->Read( lastLibImportPathEntry, ::wxGetCwd() );
......@@ -312,8 +312,8 @@ void LIB_EDIT_FRAME::SaveSettings()
EDA_DRAW_FRAME::SaveSettings();
wxConfigPathChanger cpc( wxGetApp().m_EDA_Config, m_configPath );
cfg = wxGetApp().m_EDA_Config;
wxConfigPathChanger cpc( wxGetApp().GetSettings(), m_configPath );
cfg = wxGetApp().GetSettings();
cfg->Write( lastLibExportPathEntry, m_lastLibExportPath );
cfg->Write( lastLibImportPathEntry, m_lastLibImportPath );
......
......@@ -86,11 +86,11 @@ void SCH_EDIT_FRAME::ReCreateMenuBar()
// Add this menu to list menu managed by m_fileHistory
// (the file history will be updated when adding/removing files in history
if( openRecentMenu )
wxGetApp().m_fileHistory.RemoveMenu( openRecentMenu );
wxGetApp().GetFileHistory().RemoveMenu( openRecentMenu );
openRecentMenu = new wxMenu();
wxGetApp().m_fileHistory.UseMenu( openRecentMenu );
wxGetApp().m_fileHistory.AddFilesToMenu( openRecentMenu );
wxGetApp().GetFileHistory().UseMenu( openRecentMenu );
wxGetApp().GetFileHistory().AddFilesToMenu( openRecentMenu );
AddMenuItem( fileMenu, openRecentMenu,
wxID_ANY, _( "Open &Recent" ),
_( "Open a recent opened schematic project" ),
......
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @file netlist_control.cpp
* @brief Dialog box for creating netlists.
......@@ -58,8 +83,8 @@ wxString ReturnUserNetlistTypeName( bool first_item )
msg = CUSTOM_NETLIST_TITLE;
msg << index + 1;
if( wxGetApp().m_EDA_Config )
name = wxGetApp().m_EDA_Config->Read( msg );
if( wxGetApp().GetSettings() )
name = wxGetApp().GetSettings()->Read( msg );
return name;
}
......@@ -332,7 +357,7 @@ void NETLIST_DIALOG::InstallCustomPages()
msg = CUSTOM_NETLIST_COMMAND;
msg << ii + 1;
wxString Command = wxGetApp().m_EDA_Config->Read( msg );
wxString Command = wxGetApp().GetSettings()->Read( msg );
CurrPage->m_LowBoxSizer->Add( new wxStaticText( CurrPage,
-1, _( "Netlist command:" ) ), 0,
......@@ -372,7 +397,7 @@ void NETLIST_DIALOG::AddNewPluginPanel( wxCommandEvent& event )
wxString FullFileName, Mask, Path;
Mask = wxT( "*" );
Path = wxGetApp().m_BinDir;
Path = wxGetApp().GetExecutablePath();
FullFileName = EDA_FileSelector( _( "Plugin files:" ),
Path,
FullFileName,
......@@ -650,7 +675,7 @@ void NETLIST_DIALOG::RunSimulator( wxCommandEvent& event )
void NETLIST_DIALOG::WriteCurrentNetlistSetup( void )
{
wxString msg, Command;
wxConfig* config = wxGetApp().m_EDA_Config;
wxConfig* config = wxGetApp().GetSettings();
NetlistUpdateOpt();
......
......@@ -513,8 +513,8 @@ void LIB_VIEW_FRAME::LoadSettings( )
EDA_DRAW_FRAME::LoadSettings();
wxConfigPathChanger cpc( wxGetApp().m_EDA_Config, m_configPath );
cfg = wxGetApp().m_EDA_Config;
wxConfigPathChanger cpc( wxGetApp().GetSettings(), m_configPath );
cfg = wxGetApp().GetSettings();
m_LibListSize.x = 150; // default width of libs list
m_CmpListSize.x = 150; // default width of component list
......@@ -537,8 +537,8 @@ void LIB_VIEW_FRAME::SaveSettings()
EDA_DRAW_FRAME::SaveSettings();
wxConfigPathChanger cpc( wxGetApp().m_EDA_Config, m_configPath );
cfg = wxGetApp().m_EDA_Config;
wxConfigPathChanger cpc( wxGetApp().GetSettings(), m_configPath );
cfg = wxGetApp().GetSettings();
if ( m_LibListSize.x )
cfg->Write( LIBLIST_WIDTH_KEY, m_LibListSize.x );
......
......@@ -110,7 +110,7 @@ DIALOG_PRINT_USING_PRINTER::DIALOG_PRINT_USING_PRINTER( GERBVIEW_FRAME* parent )
/*************************************************************************************/
{
m_Parent = parent;
m_Config = wxGetApp().m_EDA_Config;
m_Config = wxGetApp().GetSettings();
InitValues( );
......
......@@ -200,7 +200,7 @@ double GERBVIEW_FRAME::BestZoom()
void GERBVIEW_FRAME::LoadSettings()
{
wxConfig* config = wxGetApp().m_EDA_Config;
wxConfig* config = wxGetApp().GetSettings();
if( config == NULL )
return;
......@@ -245,7 +245,7 @@ void GERBVIEW_FRAME::LoadSettings()
void GERBVIEW_FRAME::SaveSettings()
{
wxConfig* config = wxGetApp().m_EDA_Config;
wxConfig* config = wxGetApp().GetSettings();
if( config == NULL )
return;
......
......@@ -82,11 +82,11 @@ void GERBVIEW_FRAME::ReCreateMenuBar( void )
// Add this menu to list menu managed by m_fileHistory
// (the file history will be updated when adding/removing files in history
if( openRecentGbrMenu )
wxGetApp().m_fileHistory.RemoveMenu( openRecentGbrMenu );
wxGetApp().GetFileHistory().RemoveMenu( openRecentGbrMenu );
openRecentGbrMenu = new wxMenu();
wxGetApp().m_fileHistory.UseMenu( openRecentGbrMenu );
wxGetApp().m_fileHistory.AddFilesToMenu();
wxGetApp().GetFileHistory().UseMenu( openRecentGbrMenu );
wxGetApp().GetFileHistory().AddFilesToMenu();
AddMenuItem( fileMenu, openRecentGbrMenu,
wxID_ANY,
_( "Open &Recent Gerber File" ),
......
......@@ -283,7 +283,7 @@ void LAYERS_MAP_DIALOG::OnResetClick( wxCommandEvent& event )
*/
void LAYERS_MAP_DIALOG::OnStoreSetup( wxCommandEvent& event )
{
wxConfig* config = wxGetApp().m_EDA_Config;
wxConfig* config = wxGetApp().GetSettings();
config->Write( wxT("BrdLayersCount"), m_itemsCount );
wxString key;
......@@ -296,7 +296,7 @@ void LAYERS_MAP_DIALOG::OnStoreSetup( wxCommandEvent& event )
void LAYERS_MAP_DIALOG::OnGetSetup( wxCommandEvent& event )
{
wxConfig* config = wxGetApp().m_EDA_Config;
wxConfig* config = wxGetApp().GetSettings();
config->Read( wxT("BrdLayersCount"), &m_exportBoardCopperLayersCount );
normalizeBrdLayersCount();
......
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 2008-2011 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @file appl_wxstruct.h
* @brief Base class implementation for all KiCad applications.
......@@ -34,43 +59,55 @@ class wxHtmlHelpController;
*/
class EDA_APP : public wxApp
{
public:
EDA_APP_T m_Id; /* Used mainly to handle default paths libs
* m_Id = APP_EESCHEMA_T, APP_PCBNEW_T ... */
wxString m_Project;
protected:
/// Used mainly to handle default paths libs m_Id = APP_EESCHEMA_T, APP_PCBNEW_T ...
EDA_APP_T m_Id;
/// Used to prevent multiple instances of an application from being run at the same time.
wxSingleInstanceChecker* m_Checker;
wxPoint m_HelpPos;
wxSize m_HelpSize;
wxHtmlHelpController* m_HtmlCtrl;
wxConfig* m_EDA_Config;
wxConfig* m_EDA_CommonConfig;
wxFileConfig* m_ProjectConfig;
wxString m_HelpFileName;
wxString m_EditorName;
wxString m_CurrentOptionFile;
wxString m_CurrentOptionFileDateAndTime;
wxString m_Project;
/// The application specific configuration settings.
wxConfig* m_settings;
/// The configuration settings common to all KiCad applications.
wxConfig* m_commonSettings;
/// The current project specific settings.
wxFileConfig* m_projectSettings;
/// KiCad executable path.
wxString m_BinDir;
wxString m_BinDir; /* KiCad executable path.*/
wxString m_KicadEnv; /* environment variable KICAD */
bool m_Env_Defined; // true if environment KICAD is defined.
/// The KICAD system environment variable.
wxString m_KicadEnv;
/// The current locale.
wxLocale* m_Locale;
/// The current language setting.
int m_LanguageId;
/// The file name of the the program selected for browsing pdf files.
wxString m_PdfBrowser;
wxLocale* m_Locale; // The current locale.
int m_LanguageId; // The current language setting.
wxString m_PdfBrowser; // Name of the selected browser,
// for browsing pdf datasheets
bool m_PdfBrowserIsDefault; // True if the pdf browser is the
// default (m_PdfBrowser not used)
wxPathList m_searchPaths;
wxFileHistory m_fileHistory;
protected:
wxString m_HelpFileName;
wxString m_EditorName;
wxString m_CurrentOptionFile;
wxString m_CurrentOptionFileDateAndTime;
wxPoint m_HelpPos;
wxSize m_HelpSize;
wxHtmlHelpController* m_HtmlCtrl;
wxString m_Title;
wxPathList m_libSearchPaths;
wxFileName m_projectFileName;
wxString m_LastVisitedLibPath;
public: EDA_APP();
public:
EDA_APP();
~EDA_APP();
/**
......@@ -80,6 +117,40 @@ public: EDA_APP();
*/
bool OnInit();
wxHtmlHelpController* GetHtmlHelpController() { return m_HtmlCtrl; }
void SetHtmlHelpController( wxHtmlHelpController* aController );
wxString GetHelpFileName() const { return m_HelpFileName; }
void SetHelpFileName( const wxString& aFileName ) { m_HelpFileName = aFileName; }
wxConfig* GetSettings() { return m_settings; }
wxConfig* GetCommonSettings() { return m_commonSettings; }
wxString GetEditorName() const { return m_EditorName; }
void SetEditorName( const wxString& aFileName ) { m_EditorName = aFileName; }
wxString GetCurrentOptionFile() const { return m_CurrentOptionFile; }
bool IsKicadEnvVariableDefined() const { return !m_KicadEnv.IsEmpty(); }
wxString GetKicadEnvVariable() const { return m_KicadEnv; }
wxString GetExecutablePath() const { return m_BinDir; }
wxLocale* GetLocale() { return m_Locale; }
wxString GetPdfBrowserFileName() const { return m_PdfBrowser; }
void SetPdfBrowserFileName( const wxString& aFileName ) { m_PdfBrowser = aFileName; }
bool UseSystemPdfBrowser() const { return m_PdfBrowser.IsEmpty(); }
wxFileHistory& GetFileHistory() { return m_fileHistory; }
/**
* Function SetBinDir
* finds the path to the executable and store it in EDA_APP::m_BinDir
......@@ -183,7 +254,7 @@ public: EDA_APP();
/**
* Function SaveCurrentSetupValues
* Save the current setup values in m_EDA_Config
* Save the current setup values in m_settings
* saved parameters are parameters that have the .m_Setup member set to
* true
* @param aList = array of PARAM_CFG_BASE pointers
......@@ -193,7 +264,7 @@ public: EDA_APP();
/**
* Function ReadCurrentSetupValues
* Read the current setup values previously saved, from m_EDA_Config
* Read the current setup values previously saved, from m_settings
* saved parameters are parameters that have the .m_Setup member set to
* true
* @param aList = array of PARAM_CFG_BASE pointers
......
......@@ -142,12 +142,12 @@ void KICAD_MANAGER_FRAME::OnCloseWindow( wxCloseEvent& Event )
SaveSettings();
// Close the help frame
if( wxGetApp().m_HtmlCtrl )
if( wxGetApp().GetHtmlHelpController() )
{
if( wxGetApp().m_HtmlCtrl->GetFrame() ) // returns NULL if no help frame active
wxGetApp().m_HtmlCtrl->GetFrame()->Close( true );
if( wxGetApp().GetHtmlHelpController()->GetFrame() ) // returns NULL if no help frame active
wxGetApp().GetHtmlHelpController()->GetFrame()->Close( true );
wxGetApp().m_HtmlCtrl = NULL;
wxGetApp().SetHtmlHelpController( NULL );
}
m_LeftWin->Show( false );
......@@ -258,9 +258,9 @@ void KICAD_MANAGER_FRAME::ClearMsg()
void KICAD_MANAGER_FRAME::LoadSettings()
{
wxASSERT( wxGetApp().m_EDA_Config != NULL );
wxASSERT( wxGetApp().GetSettings() != NULL );
wxConfig* cfg = wxGetApp().m_EDA_Config;
wxConfig* cfg = wxGetApp().GetSettings();
EDA_BASE_FRAME::LoadSettings();
cfg->Read( TreeFrameWidthEntry, &m_LeftWin_Width );
......@@ -269,9 +269,9 @@ void KICAD_MANAGER_FRAME::LoadSettings()
void KICAD_MANAGER_FRAME::SaveSettings()
{
wxASSERT( wxGetApp().m_EDA_Config != NULL );
wxASSERT( wxGetApp().GetSettings() != NULL );
wxConfig* cfg = wxGetApp().m_EDA_Config;
wxConfig* cfg = wxGetApp().GetSettings();
EDA_BASE_FRAME::SaveSettings();
......
......@@ -121,11 +121,11 @@ void KICAD_MANAGER_FRAME::ReCreateMenuBar()
// Add this menu to list menu managed by m_fileHistory
// (the file history will be updated when adding/removing files in history
if( openRecentMenu )
wxGetApp().m_fileHistory.RemoveMenu( openRecentMenu );
wxGetApp().GetFileHistory().RemoveMenu( openRecentMenu );
openRecentMenu = new wxMenu();
wxGetApp().m_fileHistory.UseMenu( openRecentMenu );
wxGetApp().m_fileHistory.AddFilesToMenu( );
wxGetApp().GetFileHistory().UseMenu( openRecentMenu );
wxGetApp().GetFileHistory().AddFilesToMenu( );
AddMenuItem( fileMenu, openRecentMenu,
wxID_ANY,
_( "Open &Recent" ),
......@@ -211,7 +211,7 @@ void KICAD_MANAGER_FRAME::ReCreateMenuBar()
SubMenuPdfBrowserChoice->Append( item );
SubMenuPdfBrowserChoice->Check( ID_SELECT_DEFAULT_PDF_BROWSER,
wxGetApp().m_PdfBrowserIsDefault );
wxGetApp().UseSystemPdfBrowser() );
// Favourite
item = new wxMenuItem( SubMenuPdfBrowserChoice,
......@@ -225,7 +225,7 @@ void KICAD_MANAGER_FRAME::ReCreateMenuBar()
SubMenuPdfBrowserChoice->Append( item );
SubMenuPdfBrowserChoice->AppendSeparator();
SubMenuPdfBrowserChoice->Check( ID_SELECT_PREFERED_PDF_BROWSER,
!wxGetApp().m_PdfBrowserIsDefault );
!wxGetApp().UseSystemPdfBrowser() );
// Append PDF Viewer submenu to preferences
AddMenuItem( SubMenuPdfBrowserChoice,
......
/*******************/
/* preferences.cpp */
/*******************/
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 2008-2011 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @file preferences.cpp
*/
#ifdef __GNUG__
#pragma implementation
......@@ -18,20 +43,19 @@
void KICAD_MANAGER_FRAME::OnUpdateDefaultPdfBrowser( wxUpdateUIEvent& event )
{
event.Check( wxGetApp().m_PdfBrowserIsDefault );
event.Check( wxGetApp().UseSystemPdfBrowser() );
}
void KICAD_MANAGER_FRAME::OnSelectDefaultPdfBrowser( wxCommandEvent& event )
{
wxGetApp().m_PdfBrowserIsDefault = true;
wxGetApp().WritePdfBrowserInfos();
}
void KICAD_MANAGER_FRAME::OnUpdatePreferredPdfBrowser( wxUpdateUIEvent& event )
{
event.Check( !wxGetApp().m_PdfBrowserIsDefault );
event.Check( !wxGetApp().UseSystemPdfBrowser() );
}
......@@ -39,7 +63,7 @@ void KICAD_MANAGER_FRAME::OnSelectPreferredPdfBrowser( wxCommandEvent& event )
{
bool select = event.GetId() == ID_SELECT_PREFERED_PDF_BROWSER_NAME;
if( !wxGetApp().m_PdfBrowser && !select )
if( !wxGetApp().GetPdfBrowserFileName() && !select )
{
DisplayError( this,
_( "You must choose a PDF viewer before using this option." ) );
......@@ -54,7 +78,7 @@ void KICAD_MANAGER_FRAME::OnSelectPreferredPdfBrowser( wxCommandEvent& event )
wildcard = _( "Executable files (" ) + wildcard + wxT( ")|" ) + wildcard;
wxGetApp().ReadPdfBrowserInfos();
wxFileName fn = wxGetApp().m_PdfBrowser;
wxFileName fn = wxGetApp().GetPdfBrowserFileName();
wxFileDialog dlg( this, _( "Select Preferred Pdf Browser" ), fn.GetPath(),
fn.GetFullName(), wildcard,
wxFD_OPEN | wxFD_FILE_MUST_EXIST );
......@@ -62,11 +86,11 @@ void KICAD_MANAGER_FRAME::OnSelectPreferredPdfBrowser( wxCommandEvent& event )
if( dlg.ShowModal() == wxID_CANCEL )
return;
wxGetApp().m_PdfBrowser = dlg.GetPath();
wxGetApp().m_PdfBrowserIsDefault = wxGetApp().m_PdfBrowser.IsEmpty();
wxGetApp().SetPdfBrowserFileName( dlg.GetPath() );
wxGetApp().WritePdfBrowserInfos();
}
void KICAD_MANAGER_FRAME::SetLanguage( wxCommandEvent& event )
{
EDA_BASE_FRAME::SetLanguage( event );
......
......@@ -522,9 +522,9 @@ void PCB_BASE_FRAME::unitsChangeRefresh()
void PCB_BASE_FRAME::LoadSettings()
{
wxASSERT( wxGetApp().m_EDA_Config != NULL );
wxASSERT( wxGetApp().GetSettings() != NULL );
wxConfig* cfg = wxGetApp().m_EDA_Config;
wxConfig* cfg = wxGetApp().GetSettings();
EDA_DRAW_FRAME::LoadSettings();
......@@ -566,9 +566,9 @@ void PCB_BASE_FRAME::LoadSettings()
void PCB_BASE_FRAME::SaveSettings()
{
wxASSERT( wxGetApp().m_EDA_Config != NULL );
wxASSERT( wxGetApp().GetSettings() != NULL );
wxConfig* cfg = wxGetApp().m_EDA_Config;
wxConfig* cfg = wxGetApp().GetSettings();
EDA_DRAW_FRAME::SaveSettings();
cfg->Write( m_FrameName + UserGridSizeXEntry, m_UserGridSize.x );
......
......@@ -52,8 +52,8 @@ DIALOG_SVG_PRINT::DIALOG_SVG_PRINT( EDA_DRAW_FRAME* parent ) :
DIALOG_SVG_PRINT_base( parent )
{
m_Parent = (PCB_BASE_FRAME*) parent;
m_Config = wxGetApp().m_EDA_Config;
initDialog( );
m_Config = wxGetApp().GetSettings();
initDialog();
GetSizer()->SetSizeHints( this );
Centre();
m_buttonBoard->SetDefault();
......
......@@ -34,7 +34,7 @@ DIALOG_COPPER_ZONE::DIALOG_COPPER_ZONE( PCB_EDIT_FRAME* parent, ZONE_SETTING* zo
DIALOG_COPPER_ZONE_BASE( parent )
{
m_Parent = parent;
m_Config = wxGetApp().m_EDA_Config;
m_Config = wxGetApp().GetSettings();
m_Zone_Setting = zone_setting;
m_NetSortingByPadCount = true; // false = alphabetic sort, true = pad count sort
m_OnExitCode = ZONE_ABORT;
......
......@@ -54,7 +54,8 @@ void DIALOG_FREEROUTE::MyInit()
m_FreeRouteSetupChanged = false;
wxString msg;
wxGetApp().m_EDA_Config->Read( FREEROUTE_URL_KEY, &msg );
wxGetApp().GetSettings()->Read( FREEROUTE_URL_KEY, &msg );
if( msg.IsEmpty() )
m_FreerouteURLName->SetValue( wxT( "http://www.freerouting.net/" ) );
else
......@@ -140,8 +141,8 @@ void DIALOG_FREEROUTE::OnOKButtonClick( wxCommandEvent& event )
{
if( m_FreeRouteSetupChanged ) // Save new config
{
wxGetApp().m_EDA_Config->Write( FREEROUTE_URL_KEY,
m_FreerouteURLName->GetValue() );
wxGetApp().GetSettings()->Write( FREEROUTE_URL_KEY,
m_FreerouteURLName->GetValue() );
}
EndModal(wxID_OK);
......
......@@ -100,7 +100,7 @@ DIALOG_GENDRILL::~DIALOG_GENDRILL()
void DIALOG_GENDRILL::initDialog()
{
SetFocus(); // Under wxGTK: mandatory to close dialog by the ESC key
wxConfig* Config = wxGetApp().m_EDA_Config;
wxConfig* Config = wxGetApp().GetSettings();
if( Config )
{
......@@ -234,7 +234,7 @@ void DIALOG_GENDRILL::UpdateConfig()
{
SetParams();
wxConfig* Config = wxGetApp().m_EDA_Config;
wxConfig* Config = wxGetApp().GetSettings();
if( Config )
{
......
......@@ -21,9 +21,7 @@
#include "dialog_pcbnew_config_libs_and_paths.h"
/*****************************************************************/
void PCB_EDIT_FRAME::InstallConfigFrame( )
/*****************************************************************/
{
DIALOG_PCBNEW_CONFIG_LIBS dialog( this );
dialog.ShowModal();
......@@ -33,11 +31,11 @@ void PCB_EDIT_FRAME::InstallConfigFrame( )
DIALOG_PCBNEW_CONFIG_LIBS::DIALOG_PCBNEW_CONFIG_LIBS( PCB_EDIT_FRAME* parent ):
DIALOG_PCBNEW_CONFIG_LIBS_FBP(parent)
{
m_Config = wxGetApp().m_EDA_CommonConfig;
m_Config = wxGetApp().GetCommonSettings();
Init( );
wxString title = _( "from " ) + wxGetApp().m_CurrentOptionFile;
wxString title = _( "from " ) + wxGetApp().GetCurrentOptionFile();
SetTitle( title );
m_sdbSizer1OK->SetDefault();
......
......@@ -85,7 +85,7 @@ DIALOG_PRINT_FOR_MODEDIT::DIALOG_PRINT_FOR_MODEDIT( EDA_DRAW_FRAME* parent ) :
{
m_Parent = parent;
s_Parameters.m_ForceCentered = true;
m_Config = wxGetApp().m_EDA_Config;
m_Config = wxGetApp().GetSettings();
InitValues();
m_buttonPrint->SetDefault();
......
......@@ -120,7 +120,7 @@ DIALOG_PRINT_USING_PRINTER::DIALOG_PRINT_USING_PRINTER( PCB_EDIT_FRAME* parent )
/*************************************************************************************/
{
m_Parent = parent;
m_Config = wxGetApp().m_EDA_Config;
m_Config = wxGetApp().GetSettings();
InitValues( );
......
......@@ -1066,7 +1066,7 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
case ID_POPUP_PCB_DISPLAY_FOOTPRINT_DOC:
{
wxConfig* cfg = wxGetApp().m_EDA_CommonConfig;
wxConfig* cfg = wxGetApp().GetCommonSettings();
cfg->Read( wxT( "module_doc_file" ), g_DocModulesFileName );
GetAssociatedDocument( this, g_DocModulesFileName, &wxGetApp().GetLibraryPathList() );
}
......
......@@ -51,7 +51,7 @@ public:
DIALOG_EXPORT_3DFILE_BASE( parent )
{
m_parent = parent;
m_config = wxGetApp().m_EDA_Config;
m_config = wxGetApp().GetSettings();
SetFocus();
m_config->Read( OPTKEY_OUTPUT_UNIT, &m_unitsOpt );
m_config->Read( OPTKEY_3DFILES_OPT, &m_3DFilesOpt );
......
......@@ -51,7 +51,7 @@ MODULE* FOOTPRINT_EDIT_FRAME::Import_Module()
bool Footprint_Is_GPCB_Format = false;
wxString LastOpenedPathForLoading;
wxConfig* Config = wxGetApp().m_EDA_Config;
wxConfig* Config = wxGetApp().GetSettings();
if( Config )
Config->Read( EXPORT_IMPORT_LASTPATH_KEY, &LastOpenedPathForLoading );
......@@ -145,7 +145,7 @@ void FOOTPRINT_EDIT_FRAME::Export_Module( MODULE* aModule, bool aCreateSysLib )
wxFileName fn;
FILE* file;
wxString msg, path, title, wildcard;
wxConfig* Config = wxGetApp().m_EDA_Config;
wxConfig* Config = wxGetApp().GetSettings();
if( aModule == NULL )
return;
......
......@@ -78,11 +78,11 @@ void PCB_EDIT_FRAME::ReCreateMenuBar()
// Add this menu to list menu managed by m_fileHistory
// (the file history will be updated when adding/removing files in history
if( openRecentMenu )
wxGetApp().m_fileHistory.RemoveMenu( openRecentMenu );
wxGetApp().GetFileHistory().RemoveMenu( openRecentMenu );
openRecentMenu = new wxMenu();
wxGetApp().m_fileHistory.UseMenu( openRecentMenu );
wxGetApp().m_fileHistory.AddFilesToMenu();
wxGetApp().GetFileHistory().UseMenu( openRecentMenu );
wxGetApp().GetFileHistory().AddFilesToMenu();
AddMenuItem( filesMenu, openRecentMenu,
-1, _( "Open &Recent" ),
_( "Open a recent opened board" ),
......
......@@ -544,7 +544,7 @@ void PCB_EDIT_FRAME::ShowDesignRulesEditor( wxCommandEvent& event )
void PCB_EDIT_FRAME::LoadSettings()
{
wxConfig* config = wxGetApp().m_EDA_Config;
wxConfig* config = wxGetApp().GetSettings();
if( config == NULL )
return;
......@@ -572,7 +572,7 @@ void PCB_EDIT_FRAME::LoadSettings()
void PCB_EDIT_FRAME::SaveSettings()
{
wxConfig* config = wxGetApp().m_EDA_Config;
wxConfig* config = wxGetApp().GetSettings();
if( config == NULL )
return;
......
......@@ -91,7 +91,7 @@ DIALOG_PLOT::DIALOG_PLOT( PCB_EDIT_FRAME* parent ) :
DIALOG_PLOT_BASE( parent )
{
m_Parent = parent;
m_Config = wxGetApp().m_EDA_Config;
m_Config = wxGetApp().GetSettings();
Init_Dialog();
......
......@@ -479,10 +479,10 @@ int PCB_EDIT_FRAME::Begin_Zone( wxDC* DC )
zone->SetNetNameFromNetCode( );
}
wxGetApp().m_EDA_Config->Read( ZONE_THERMAL_RELIEF_GAP_STRING_KEY,
&g_Zone_Default_Setting.m_ThermalReliefGap );
wxGetApp().m_EDA_Config->Read( ZONE_THERMAL_RELIEF_COPPER_WIDTH_STRING_KEY,
&g_Zone_Default_Setting.m_ThermalReliefCopperBridge );
wxGetApp().GetSettings()->Read( ZONE_THERMAL_RELIEF_GAP_STRING_KEY,
&g_Zone_Default_Setting.m_ThermalReliefGap );
wxGetApp().GetSettings()->Read( ZONE_THERMAL_RELIEF_COPPER_WIDTH_STRING_KEY,
&g_Zone_Default_Setting.m_ThermalReliefCopperBridge );
g_Zone_Default_Setting.m_CurrentZone_Layer = zone->GetLayer();
DIALOG_COPPER_ZONE* frame = new DIALOG_COPPER_ZONE( this, &g_Zone_Default_Setting );
......
......@@ -152,10 +152,10 @@ void DialogNonCopperZonesEditor::OnOkClick( wxCommandEvent& event )
break;
}
if( wxGetApp().m_EDA_Config )
if( wxGetApp().GetSettings() )
{
wxGetApp().m_EDA_Config->Write( ZONE_NET_OUTLINES_HATCH_OPTION_KEY,
(long) g_Zone_Default_Setting.m_Zone_HatchingStyle );
wxGetApp().GetSettings()->Write( ZONE_NET_OUTLINES_HATCH_OPTION_KEY,
(long) g_Zone_Default_Setting.m_Zone_HatchingStyle );
}
if( m_OrientEdgesOpt->GetSelection() == 0 )
......
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