KiCad PCB EDA Suite
bin_mod.cpp
Go to the documentation of this file.
1 /*
2  * This program source code file is part of KiCad, a free EDA CAD application.
3  *
4  * Copyright (C) 2014 CERN
5  * Copyright (C) 2014 KiCad Developers, see CHANGELOG.TXT for contributors.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, you may find one here:
19  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20  * or you may search the http://www.gnu.org website for the version 2 license,
21  * or you may write to the Free Software Foundation, Inc.,
22  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23  */
24 
25 #include <bin_mod.h>
26 #include <common.h>
27 
28 
29 BIN_MOD::BIN_MOD( const char* aName ) :
30  m_name( aName ),
31  m_config( 0 )
32 {
33 }
34 
35 
37 {
38  // do an OS specific wxConfig instantiation, using the bin_mod (EXE/DLL/DSO) name.
39  m_config = GetNewConfig( wxString::FromUTF8( m_name ) );
40 
41  // wxWidgets' implementation of this is *very* expensive, and we don't use them anyway.
42  m_config->SetExpandEnvVars( false );
43 
44  m_history.Load( *m_config );
45 
46  // Prepare On Line Help. Use only lower case for help file names, in order to
47  // avoid problems with upper/lower case file names under windows and unix.
48  // Help files are now using html format.
49  // Old help files used pdf format.
50  // so when searching a help file, the .html file will be searched,
51  // and if not found, the .pdf file will be searched.
52  m_help_file = wxString::FromUTF8( m_name ); // no ext given. can be .html or .pdf
53 }
54 
55 
57 {
58  if( m_config )
59  {
60  m_history.Save( *m_config );
61 
62  // Deleting a wxConfigBase writes its contents to disk if changed.
63  // Might be NULL if called twice, in which case nothing happens.
64  delete m_config;
65  m_config = 0;
66  }
67 }
68 
69 
71 {
72  End();
73 }
74 
void Init()
Definition: bin_mod.cpp:36
wxConfigBase * GetNewConfig(const wxString &aProgName)
Create a new wxConfig so we can put configuration files in a more proper place for each platform...
Definition: common.cpp:198
~BIN_MOD()
Definition: bin_mod.cpp:70
wxString m_help_file
Definition: bin_mod.h:59
wxFileHistory m_history
Definition: bin_mod.h:58
The common library.
BIN_MOD(const char *aName)
Definition: bin_mod.cpp:29
wxConfigBase * m_config
maybe from $HOME/.${m_name}
Definition: bin_mod.h:57
const char * m_name
name of this binary module, static C string.
Definition: bin_mod.h:55
void End()
Definition: bin_mod.cpp:56