2009-11-23 20:18:47 +00:00
|
|
|
/******************************************/
|
|
|
|
/* appl_wxstruct.h */
|
|
|
|
/* Base application class implementation. */
|
|
|
|
/******************************************/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
#ifndef APPL_WXSTRUCT_H
|
|
|
|
#define APPL_WXSTRUCT_H
|
|
|
|
|
2009-01-17 20:31:19 +00:00
|
|
|
/* Use wxFileHistory for most recently used file handling. */
|
|
|
|
#include <wx/docview.h>
|
2009-02-04 15:25:03 +00:00
|
|
|
#include <wx/config.h>
|
2009-04-05 20:49:15 +00:00
|
|
|
#include <wx/filename.h>
|
2009-04-23 15:02:18 +00:00
|
|
|
#include "param_config.h"
|
|
|
|
|
2009-02-04 15:25:03 +00:00
|
|
|
|
2009-04-12 14:39:54 +00:00
|
|
|
enum id_app_type {
|
|
|
|
APP_TYPE_UNKOWN,
|
|
|
|
APP_TYPE_EESCHEMA,
|
|
|
|
APP_TYPE_PCBNEW,
|
|
|
|
APP_TYPE_CVPCB,
|
|
|
|
APP_TYPE_GERBVIEW,
|
2010-10-04 12:58:07 +00:00
|
|
|
APP_TYPE_KICAD
|
2009-04-12 14:39:54 +00:00
|
|
|
};
|
2009-01-17 20:31:19 +00:00
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
class wxConfigBase;
|
|
|
|
class wxFileConfig;
|
2009-02-04 15:25:03 +00:00
|
|
|
class wxSingleInstanceChecker;
|
|
|
|
class wxHtmlHelpController;
|
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-08-14 19:24:48 +00:00
|
|
|
/**********************************************/
|
|
|
|
/* Class representing the entire Application */
|
|
|
|
/**********************************************/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-08-14 19:24:48 +00:00
|
|
|
class WinEDA_App : public wxApp
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
|
|
|
public:
|
2009-11-23 20:18:47 +00:00
|
|
|
id_app_type m_Id; /* Used mainly to handle
|
|
|
|
* default paths libs
|
|
|
|
* m_Id = APP_TYPE_EESCHEMA,
|
|
|
|
* APP_TYPE_PCBNEW ...
|
|
|
|
*/
|
|
|
|
wxString m_Project;
|
2007-08-14 19:24:48 +00:00
|
|
|
wxSingleInstanceChecker* m_Checker;
|
|
|
|
|
2008-12-05 16:03:05 +00:00
|
|
|
wxPoint m_HelpPos;
|
|
|
|
wxSize m_HelpSize;
|
|
|
|
wxHtmlHelpController* m_HtmlCtrl;
|
2009-04-05 20:49:15 +00:00
|
|
|
wxConfig* m_EDA_Config;
|
|
|
|
wxConfig* m_EDA_CommonConfig;
|
|
|
|
wxFileConfig* m_ProjectConfig;
|
2008-12-05 16:03:05 +00:00
|
|
|
wxString m_HelpFileName;
|
2009-04-05 20:49:15 +00:00
|
|
|
wxString m_EditorName;
|
2009-11-23 20:18:47 +00:00
|
|
|
wxString m_CurrentOptionFile;
|
2008-12-05 16:03:05 +00:00
|
|
|
wxString m_CurrentOptionFileDateAndTime;
|
|
|
|
|
2009-11-23 20:18:47 +00:00
|
|
|
wxString m_BinDir; /* Kicad executable path.*/
|
|
|
|
wxString m_KicadEnv; /* environment variable KICAD */
|
|
|
|
bool m_Env_Defined; // TRUE if environment KICAD is
|
|
|
|
// defined.
|
|
|
|
|
|
|
|
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;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
protected:
|
2009-11-23 20:18:47 +00:00
|
|
|
wxString m_Title;
|
|
|
|
wxPathList m_libSearchPaths;
|
|
|
|
wxFileName m_projectFileName;
|
|
|
|
wxString m_LastVisitedLibPath;
|
2009-04-05 20:49:15 +00:00
|
|
|
|
2009-11-23 20:18:47 +00:00
|
|
|
public: WinEDA_App();
|
2007-09-01 12:00:30 +00:00
|
|
|
~WinEDA_App();
|
2010-12-21 12:41:17 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Function OnInit
|
|
|
|
* this is the first executed function (like main() )
|
|
|
|
* @return true if the appliction can be started.
|
|
|
|
*/
|
2009-04-12 14:39:54 +00:00
|
|
|
bool OnInit();
|
|
|
|
|
|
|
|
bool SetBinDir();
|
|
|
|
void SetDefaultSearchPaths( void );
|
|
|
|
|
2010-12-21 12:41:17 +00:00
|
|
|
/**
|
|
|
|
* Function MacOpenFile
|
|
|
|
* Specific to MacOSX. Not used under Linux or Windows
|
|
|
|
* MacOSX: Needed for file association
|
|
|
|
* http://wiki.wxwidgets.org/WxMac-specific_topics
|
|
|
|
*/
|
2010-01-16 19:42:58 +00:00
|
|
|
virtual void MacOpenFile(const wxString &fileName);
|
|
|
|
|
2010-11-12 15:17:10 +00:00
|
|
|
/**
|
|
|
|
* Function InitEDA_Appl
|
2009-11-23 20:18:47 +00:00
|
|
|
* initialize some general parameters
|
2009-04-14 16:45:22 +00:00
|
|
|
* - Default paths (help, libs, bin)and configuration files names
|
2009-04-12 14:39:54 +00:00
|
|
|
* - Language and locale
|
|
|
|
* - fonts
|
|
|
|
* @param aName : used as paths in configuration files
|
|
|
|
* @param aId = flag : LIBRARY_TYPE_EESCHEMA or LIBRARY_TYPE_PCBNEW
|
2009-11-23 20:18:47 +00:00
|
|
|
* used to choose what default library path must be used
|
2009-04-12 14:39:54 +00:00
|
|
|
*/
|
2009-11-23 20:18:47 +00:00
|
|
|
void InitEDA_Appl( const wxString& aName,
|
|
|
|
id_app_type aId = APP_TYPE_UNKOWN );
|
2007-08-14 19:24:48 +00:00
|
|
|
|
2009-04-12 14:39:54 +00:00
|
|
|
bool SetLanguage( bool first_time = FALSE );
|
2009-01-18 10:15:10 +00:00
|
|
|
|
2010-11-12 15:17:10 +00:00
|
|
|
/**
|
|
|
|
* Function AddMenuLanguageList
|
2009-04-05 20:49:15 +00:00
|
|
|
*
|
|
|
|
* Create menu list for language choice, and add it as submenu to a main
|
|
|
|
* menu
|
|
|
|
*
|
2009-11-23 20:18:47 +00:00
|
|
|
* @param MasterMenu : The main menu. The sub menu list will be
|
|
|
|
* accessible from the menu item with id
|
|
|
|
* ID_LANGUAGE_CHOICE
|
2009-04-05 20:49:15 +00:00
|
|
|
*
|
2009-01-18 10:15:10 +00:00
|
|
|
* @return the sub menu Language list
|
|
|
|
*/
|
2009-04-12 14:39:54 +00:00
|
|
|
void AddMenuLanguageList( wxMenu* MasterMenu );
|
|
|
|
void SetLanguageIdentifier( int menu_id );
|
|
|
|
void SetLanguagePath( void );
|
|
|
|
void InitOnLineHelp();
|
2007-08-14 19:24:48 +00:00
|
|
|
|
2010-11-12 15:17:10 +00:00
|
|
|
/**
|
|
|
|
* Function GetSettings
|
2009-07-03 07:32:48 +00:00
|
|
|
* Get application settings
|
2009-11-23 20:18:47 +00:00
|
|
|
* @param aReopenLastUsedDirectory = true to switch to last opened
|
|
|
|
* directory, false to use current CWD
|
2009-07-03 07:32:48 +00:00
|
|
|
* @return none
|
|
|
|
*/
|
2009-11-23 20:18:47 +00:00
|
|
|
void GetSettings( bool aReopenLastUsedDirectory );
|
2009-07-03 07:32:48 +00:00
|
|
|
|
2009-04-12 14:39:54 +00:00
|
|
|
void SaveSettings();
|
|
|
|
|
|
|
|
void WriteProjectConfig( const wxString& local_config_filename,
|
|
|
|
const wxString& GroupName,
|
|
|
|
PARAM_CFG_BASE** List );
|
2009-04-23 15:02:18 +00:00
|
|
|
void WriteProjectConfig( const wxString& fileName,
|
|
|
|
const wxString& GroupName,
|
2009-05-21 17:42:42 +00:00
|
|
|
PARAM_CFG_ARRAY& params );
|
2009-04-05 20:49:15 +00:00
|
|
|
|
2010-11-12 15:17:10 +00:00
|
|
|
/**
|
2010-11-12 16:59:16 +00:00
|
|
|
* Function SaveCurrentSetupValues
|
2009-03-28 20:02:34 +00:00
|
|
|
* Save the current setup values in m_EDA_Config
|
2009-11-23 20:18:47 +00:00
|
|
|
* saved parameters are parameters that have the .m_Setup member set to
|
|
|
|
* true
|
2009-03-28 20:02:34 +00:00
|
|
|
* @param aList = array of PARAM_CFG_BASE pointers
|
2009-04-12 14:39:54 +00:00
|
|
|
*/
|
|
|
|
void SaveCurrentSetupValues( PARAM_CFG_BASE** aList );
|
2009-05-21 17:42:42 +00:00
|
|
|
void SaveCurrentSetupValues( PARAM_CFG_ARRAY& List );
|
2009-03-28 20:02:34 +00:00
|
|
|
|
2010-11-12 15:17:10 +00:00
|
|
|
/**
|
2010-11-12 16:59:16 +00:00
|
|
|
* Function ReadCurrentSetupValues
|
2009-03-28 20:02:34 +00:00
|
|
|
* Raed the current setup values previously saved, from m_EDA_Config
|
2009-11-23 20:18:47 +00:00
|
|
|
* saved parameters are parameters that have the .m_Setup member set to
|
|
|
|
* true
|
2009-03-28 20:02:34 +00:00
|
|
|
* @param aList = array of PARAM_CFG_BASE pointers
|
|
|
|
*/
|
2009-04-12 14:39:54 +00:00
|
|
|
void ReadCurrentSetupValues( PARAM_CFG_BASE** aList );
|
2009-05-21 17:42:42 +00:00
|
|
|
void ReadCurrentSetupValues( PARAM_CFG_ARRAY& List );
|
2009-03-28 20:02:34 +00:00
|
|
|
|
2009-11-23 20:18:47 +00:00
|
|
|
bool ReadProjectConfig( const wxString& local_config_filename,
|
|
|
|
const wxString& GroupName,
|
2009-04-23 15:02:18 +00:00
|
|
|
PARAM_CFG_BASE** List,
|
2009-11-23 20:18:47 +00:00
|
|
|
bool Load_Only_if_New );
|
|
|
|
bool ReadProjectConfig( const wxString& local_config_filename,
|
|
|
|
const wxString& GroupName,
|
2009-05-21 17:42:42 +00:00
|
|
|
PARAM_CFG_ARRAY& List,
|
2009-11-23 20:18:47 +00:00
|
|
|
bool Load_Only_if_New );
|
2009-04-12 14:39:54 +00:00
|
|
|
bool ReCreatePrjConfig( const wxString& local_config_filename,
|
|
|
|
const wxString& GroupName,
|
|
|
|
bool ForceUseLocalConfig );
|
2007-08-14 19:24:48 +00:00
|
|
|
|
2009-04-12 14:39:54 +00:00
|
|
|
void ReadPdfBrowserInfos();
|
|
|
|
void WritePdfBrowserInfos();
|
2009-01-29 14:26:20 +00:00
|
|
|
|
2009-04-12 14:39:54 +00:00
|
|
|
wxString FindFileInSearchPaths( const wxString& filename,
|
|
|
|
const wxArrayString* subdirs = NULL );
|
2009-01-29 14:26:20 +00:00
|
|
|
|
2009-04-12 14:39:54 +00:00
|
|
|
wxString GetHelpFile( void );
|
|
|
|
wxString GetLibraryFile( const wxString& filename );
|
2009-04-05 20:49:15 +00:00
|
|
|
wxString& GetEditorName();
|
|
|
|
|
|
|
|
const wxString& GetTitle() { return m_Title; }
|
|
|
|
void SetTitle( const wxString& title ) { m_Title = title; }
|
|
|
|
|
|
|
|
wxPathList& GetLibraryPathList() { return m_libSearchPaths; }
|
2009-04-08 18:06:22 +00:00
|
|
|
wxString FindLibraryPath( const wxString& fileName );
|
2009-04-12 14:39:54 +00:00
|
|
|
|
2009-04-14 16:45:22 +00:00
|
|
|
/** FindLibraryPath
|
|
|
|
* Kicad saves user defined library files that are not in the standard
|
|
|
|
* library search path list with the full file path. Calling the library
|
|
|
|
* search path list with a user library file will fail. This helper method
|
|
|
|
* solves that problem.
|
|
|
|
* @param fileName
|
|
|
|
* @return a wxEmptyString if library file is not found.
|
|
|
|
*/
|
2009-04-08 18:06:22 +00:00
|
|
|
wxString FindLibraryPath( const wxFileName& fileName )
|
|
|
|
{
|
|
|
|
return FindLibraryPath( fileName.GetFullPath() );
|
|
|
|
}
|
2009-04-12 14:39:54 +00:00
|
|
|
|
2009-11-23 20:18:47 +00:00
|
|
|
|
2009-04-14 16:45:22 +00:00
|
|
|
/** ReturnLastVisitedLibraryPath
|
|
|
|
* Returns the last visited library directory, or (if void) the first
|
|
|
|
* path in lib path list ( but not the CWD )
|
2009-11-23 20:18:47 +00:00
|
|
|
* @param aSubPathToSearch = Preferred sub path to search in path list
|
2009-04-14 16:45:22 +00:00
|
|
|
*/
|
2009-11-23 20:18:47 +00:00
|
|
|
wxString ReturnLastVisitedLibraryPath(
|
|
|
|
const wxString& aSubPathToSearch = wxEmptyString );
|
|
|
|
void SaveLastVisitedLibraryPath( const wxString& aPath );
|
2009-04-14 16:45:22 +00:00
|
|
|
|
2009-04-15 15:53:21 +00:00
|
|
|
/** ReturnFilenameWithRelativePathInLibPath
|
2009-11-23 20:18:47 +00:00
|
|
|
* @return a short filename (with extension) with only a relative path if
|
|
|
|
* this filename can be found in library paths
|
2009-04-15 15:53:21 +00:00
|
|
|
* @param aFullFilename = filename with path and extension.
|
|
|
|
*/
|
2009-11-23 20:18:47 +00:00
|
|
|
wxString ReturnFilenameWithRelativePathInLibPath(
|
|
|
|
const wxString& aFullFilename );
|
2009-04-18 14:14:40 +00:00
|
|
|
|
2010-11-12 15:17:10 +00:00
|
|
|
/**
|
|
|
|
* Function RemoveLibraryPath
|
2009-04-18 14:14:40 +00:00
|
|
|
* Removes the given path(s) from the library path list
|
2009-11-23 20:18:47 +00:00
|
|
|
* @param aPaths = path or path list to remove. paths must be separated by
|
|
|
|
* ";"
|
2009-04-18 14:14:40 +00:00
|
|
|
*/
|
2009-11-23 20:18:47 +00:00
|
|
|
void RemoveLibraryPath( const wxString& aPaths );
|
2009-04-18 14:14:40 +00:00
|
|
|
|
2010-11-12 15:17:10 +00:00
|
|
|
/**
|
|
|
|
* Function InsertLibraryPath
|
2009-04-18 14:14:40 +00:00
|
|
|
* insert path(s) int lib paths list.
|
|
|
|
* @param aPaths = path or path list to add. paths must be separated by ";"
|
|
|
|
* @param aIndex = insertion point
|
2009-04-14 16:45:22 +00:00
|
|
|
*/
|
2009-11-23 20:18:47 +00:00
|
|
|
void InsertLibraryPath( const wxString& aPaths, size_t aIndex );
|
2007-06-05 12:10:51 +00:00
|
|
|
};
|
|
|
|
|
2008-12-05 16:03:05 +00:00
|
|
|
/*
|
|
|
|
* Use wxGetApp() to access WinEDA_App. It is not necessary to keep copies
|
|
|
|
* of the application pointer all over the place or worse yet in a global
|
|
|
|
* variable.
|
|
|
|
*/
|
2010-10-04 12:58:07 +00:00
|
|
|
DECLARE_APP( WinEDA_App )
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
#endif /* APPL_WXSTRUCT_H */
|