📄 settings.cpp
字号:
/* ---------------------------------------------------------------------------- * Copyright (C) 2004 by egnite Software GmbH * * 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, write to the Free Software Foundation, Inc., * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * ---------------------------------------------------------------------------- * Parts are * * Copyright (C) 1998, 1999, 2000 Red Hat, Inc. * * 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, write to the Free Software Foundation, Inc., * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * ---------------------------------------------------------------------------- *//* * $Log: settings.cpp,v $ * Revision 1.7 2005/11/24 09:44:30 haraldkipp * wxWidget failed to built with unicode support, which results in a number * of compile errors. Fixed by Torben Mikael Hansen. * * Revision 1.6 2005/07/20 09:23:15 haraldkipp * Prepend current directory to the default file paths. * * Revision 1.5 2004/09/17 13:03:48 haraldkipp * New settings page for tool options * * Revision 1.4 2004/09/07 19:20:07 haraldkipp * Initial/default lib/inc dirs updated * * Revision 1.3 2004/08/18 17:22:28 haraldkipp * STK500 is the default programmer * * Revision 1.2 2004/08/18 13:34:20 haraldkipp * Now working on Linux * * Revision 1.1 2004/08/03 15:04:59 haraldkipp * Another change of everything * */#include "nutconf.h"#include "settings.h"IMPLEMENT_DYNAMIC_CLASS(CSettings, wxObject)/*! * \brief Default constructor. */CSettings::CSettings(){ int idx; wxString cwd = ::wxGetCwd();#ifdef __WXMSW__ cwd.Replace(wxT("\\"), wxT("/"));#endif if((idx = cwd.Find(wxT("/nut/"))) > -1) { cwd = cwd.Left(idx); } if(cwd.Length() > 1 && cwd.Last() == '/') { cwd = cwd.BeforeLast('/'); } m_configname_default = cwd + wxT("/nut/conf/ethernut21.conf"); m_repositoryname_default = cwd + wxT("/nut/conf/repository.nut"); m_firstidir_default = wxEmptyString; m_lastidir_default = wxEmptyString; m_buildpath_default = cwd + wxT("/nutbld"); m_lib_dir_default = cwd + wxT("/nutbld/lib"); m_source_dir_default = cwd + wxT("/nut"); m_platform_default = wxT("Select one"); m_app_dir_default = cwd + wxT("/nutapp"); m_programmer_default = wxT("avr-uisp-stk500"); m_toolpath_default = cwd + wxT("/nut/tools/win32;\"(Add compiler paths here)\";"); wxConfigBase *pConfig = wxConfigBase::Get(); if (pConfig) { wxString lastPath = pConfig->GetPath(); pConfig->SetPath(wxT("/Settings")); pConfig->Read(wxT("ConfigName"), &m_configname, m_configname_default); pConfig->Read(wxT("RepositoryName"), &m_repositoryname, m_repositoryname_default); pConfig->Read(wxT("BuildPath"), &m_buildpath, m_buildpath_default); pConfig->Read(wxT("FirstInclude"), &m_firstidir, m_firstidir_default); pConfig->Read(wxT("LastInclude"), &m_lastidir, m_lastidir_default); pConfig->Read(wxT("InstallPath"), &m_lib_dir, m_lib_dir_default); pConfig->Read(wxT("SourceDirectory"), &m_source_dir, m_source_dir_default); pConfig->Read(wxT("TargetPlatform"), &m_platform, m_platform_default); pConfig->Read(wxT("ToolPath"), &m_toolpath, m_toolpath_default); pConfig->Read(wxT("ApplicationDirectory"), &m_app_dir, m_app_dir_default); pConfig->Read(wxT("Programmer"), &m_programmer, m_programmer_default); pConfig->SetPath(lastPath); }}/*! * \brief Default destructor. */CSettings::~CSettings(){}bool CSettings::Save(){ wxConfigBase *pConfig = wxConfigBase::Get(); if (pConfig) { wxString lastPath = pConfig->GetPath(); pConfig->SetPath(wxT("/Settings")); pConfig->Write(wxT("ConfigName"), m_configname); pConfig->Write(wxT("RepositoryName"), m_repositoryname); pConfig->Write(wxT("BuildPath"), m_buildpath); pConfig->Write(wxT("FirstInclude"), m_firstidir); pConfig->Write(wxT("LastInclude"), m_lastidir); pConfig->Write(wxT("InstallPath"), m_lib_dir); pConfig->Write(wxT("SourceDirectory"), m_source_dir); pConfig->Write(wxT("TargetPlatform"), m_platform); pConfig->Write(wxT("ToolPath"), m_toolpath); pConfig->Write(wxT("ApplicationDirectory"), m_app_dir); pConfig->Write(wxT("Programmer"), m_programmer); pConfig->SetPath(lastPath); } return true;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -