⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 preferencespagegeneral.cpp

📁 roadnav 内含一个基于wxWindows库的车载导航系统。编译后
💻 CPP
字号:
/* *  Roadnav *  PreferencesPageGeneral.cpp * *  Copyright (c) 2004 - 2006 Richard L. Lynch <rllynch@users.sourceforge.net> * *  This program is free software; you can redistribute it and/or *  modify it under the terms of version 2 of the GNU General Public License *  as published by the Free Software Foundation. * *  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., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA *////////////////////////////////////////////////////////////////////////////////// \file////// Contains the general page of the preferences dialog box./////////////////////////////////////////////////////////////////////////////////#ifdef HAVE_CONFIG_H#  include <config.h>#endif#ifdef _MSC_VER#pragma warning(disable: 4786)#pragma warning(disable: 4800)#endif#include <wx/wx.h>#include <vector>#include "libroadnav/Map.h"#include "libroadnav/DownloadFiles.h"#include "libroadnav/MapSupport.h"#include "App.h"#include "PreferencesPageGeneral.h"#include "SerialIO.h"#include "wxSkinnableFrame.h"using namespace std;enum{	idClearCache,	idClearMaps};//////////////////////////////////////////////////////////////////////////////////// PreferencesPageGeneral event table/////////////////////////////////////////////////////////////////////////////////BEGIN_EVENT_TABLE(PreferencesPageGeneral, wxPanel)	EVT_BUTTON(idClearCache, PreferencesPageGeneral::OnClearCache)	EVT_BUTTON(idClearMaps, PreferencesPageGeneral::OnClearMaps)END_EVENT_TABLE()//////////////////////////////////////////////////////////////////////////////////// \brief PreferencesPageGeneral constructor - create controls and initialize them/////////////////////////////////////////////////////////////////////////////////PreferencesPageGeneral::PreferencesPageGeneral(wxWindow *parent)             : wxPanel(parent, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL){	wxBoxSizer * psizerWnd;	wxFlexGridSizer * psizerGrid;	int i;		psizerGrid = new wxFlexGridSizer(2, 5, 10);		//////////////////////////////////////////////////////////////////////////	// Automatic download maps label	//////////////////////////////////////////////////////////////////////////	psizerGrid->Add(		new wxStaticText(this, -1, wxT("Automatically download maps")),		0,		wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT,		0	);		//////////////////////////////////////////////////////////////////////////	// Automatic download maps check box	//////////////////////////////////////////////////////////////////////////	m_pctlAutoDownloadMaps = new wxCheckBox(this, -1, wxT(""));	g_pConfig->Read(wxT("AutoDownloadMaps"), &i, 1);	m_pctlAutoDownloadMaps->SetValue(i);	psizerGrid->Add(		m_pctlAutoDownloadMaps, 		0,		wxALIGN_LEFT,		0	);	{		//////////////////////////////////////////////////////////////////////////		// Day Skin Path Label		//////////////////////////////////////////////////////////////////////////		psizerGrid->Add(			new wxStaticText(this, -1, wxT("Daytime Skin")),			0,			wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT,			0		);				//////////////////////////////////////////////////////////////////////////		// Day Skin Path Entry		//////////////////////////////////////////////////////////////////////////		vector<wxString> vSkins = EnumerateSkins();		wxString * strSkins = new wxString[vSkins.size()];		int nSkins = vSkins.size();		unsigned int iSkin;		for (iSkin = 0; iSkin < vSkins.size(); iSkin++)			strSkins[iSkin] = vSkins[iSkin];		m_pctlSkinPathDay = new wxComboBox(this, -1, g_pConfig->Read(wxT("SkinPath-Day"), wxT("Default-Day")), wxDefaultPosition, wxSize(200, -1), nSkins, strSkins, wxCB_DROPDOWN | wxCB_SORT);		delete [] strSkins;		psizerGrid->Add(			m_pctlSkinPathDay,			0,			wxALIGN_LEFT,			0		);	}		{		//////////////////////////////////////////////////////////////////////////		// Night Skin Path Label		//////////////////////////////////////////////////////////////////////////		psizerGrid->Add(			new wxStaticText(this, -1, wxT("Nighttime Skin")),			0,			wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT,			0		);				//////////////////////////////////////////////////////////////////////////		// Night Skin Path Entry		//////////////////////////////////////////////////////////////////////////		vector<wxString> vSkins = EnumerateSkins();		wxString * strSkins = new wxString[vSkins.size()];		int nSkins = vSkins.size();		unsigned int iSkin;		for (iSkin = 0; iSkin < vSkins.size(); iSkin++)			strSkins[iSkin] = vSkins[iSkin];		m_pctlSkinPathNight = new wxComboBox(this, -1, g_pConfig->Read(wxT("SkinPath-Night"), wxT("Default-Night")), wxDefaultPosition, wxSize(200, -1), nSkins, strSkins, wxCB_DROPDOWN | wxCB_SORT);		delete [] strSkins;		psizerGrid->Add(			m_pctlSkinPathNight,			0,			wxALIGN_LEFT,			0		);	}		//////////////////////////////////////////////////////////////////////////	// Proxy Host Label	//////////////////////////////////////////////////////////////////////////	psizerGrid->Add(		new wxStaticText(this, -1, wxT("Proxy Host")),		0,		wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT,		0	);		//////////////////////////////////////////////////////////////////////////	// Proxy Host Entry	//////////////////////////////////////////////////////////////////////////	m_pctlProxyHost = new wxTextCtrl(this, -1, g_pConfig->Read(wxT("ProxyHost"), wxT("")), wxDefaultPosition, wxSize(250, -1));	psizerGrid->Add(		m_pctlProxyHost,		0,		wxALIGN_LEFT,		0	);		//////////////////////////////////////////////////////////////////////////	// Proxy Port Label	//////////////////////////////////////////////////////////////////////////	psizerGrid->Add(		new wxStaticText(this, -1, wxT("Proxy Port")),		0,		wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT,		0	);		//////////////////////////////////////////////////////////////////////////	// Proxy Port Entry	//////////////////////////////////////////////////////////////////////////	long lPort = 0;	g_pConfig->Read(wxT("ProxyPort"), &lPort);	m_pctlProxyPort = new wxTextCtrl(this, -1, wxString::Format(wxT("%ld"), lPort), wxDefaultPosition, wxSize(250, -1));	psizerGrid->Add(		m_pctlProxyPort,		0,		wxALIGN_LEFT,		0	);		//////////////////////////////////////////////////////////////////////////	// North always points up label	//////////////////////////////////////////////////////////////////////////	psizerGrid->Add(		new wxStaticText(this, -1, wxT("North always points up")),		0,		wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT,		0	);		//////////////////////////////////////////////////////////////////////////	// North always points up check box	//////////////////////////////////////////////////////////////////////////	m_pctlNorthAlwaysUp = new wxCheckBox(this, -1, wxT(""));	g_pConfig->Read(wxT("NorthAlwaysUp"), &i, 0);	m_pctlNorthAlwaysUp->SetValue(i);	psizerGrid->Add(		m_pctlNorthAlwaysUp, 		0,		wxALIGN_LEFT,		0	);	//////////////////////////////////////////////////////////////////////////	// Antialiasing label	//////////////////////////////////////////////////////////////////////////	psizerGrid->Add(		new wxStaticText(this, -1, wxT("Antialiased maps")),		0,		wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT,		0	);		//////////////////////////////////////////////////////////////////////////	// Antialiasing check box	//////////////////////////////////////////////////////////////////////////	m_pctlAntiAliasedMaps = new wxCheckBox(this, -1, wxT(""));	g_pConfig->Read(wxT("AntialiasedMaps"), &i, 1);	m_pctlAntiAliasedMaps->SetValue(i);	psizerGrid->Add(		m_pctlAntiAliasedMaps, 		0,		wxALIGN_LEFT,		0	);	//////////////////////////////////////////////////////////////////////////	// Verbalize directions label	//////////////////////////////////////////////////////////////////////////	psizerGrid->Add(		new wxStaticText(this, -1, wxT("Verbalize directions")),		0,		wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT,		0	);		//////////////////////////////////////////////////////////////////////////	// Verbalize directions check box	//////////////////////////////////////////////////////////////////////////	m_pctlLiveDirectionsTTS = new wxCheckBox(this, -1, wxT(""));	g_pConfig->Read(wxT("LiveDirectionsTTS"), &i, 1);	m_pctlLiveDirectionsTTS->SetValue(i);	psizerGrid->Add(		m_pctlLiveDirectionsTTS, 		0,		wxALIGN_LEFT,		0	);	//////////////////////////////////////////////////////////////////////////	// Zoom maps Label	//////////////////////////////////////////////////////////////////////////	psizerGrid->Add(		new wxStaticText(this, -1, wxT("Zoom Maps")),		0,		wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT,		0	);		//////////////////////////////////////////////////////////////////////////	// Zoom maps Entry	//////////////////////////////////////////////////////////////////////////	double fDrawingScaleFactor;	g_pConfig->Read(wxT("DrawingScaleFactor"), &fDrawingScaleFactor, 1);	m_pctlZoomMaps = new wxTextCtrl(this, -1, wxString::Format(wxT("%.2f"), fDrawingScaleFactor), wxDefaultPosition, wxSize(250, -1));	psizerGrid->Add(		m_pctlZoomMaps,		0,		wxALIGN_LEFT,		0	);		//////////////////////////////////////////////////////////////////////////	// Speed Controlled Zooming Cutoffs Label	//////////////////////////////////////////////////////////////////////////	psizerGrid->Add(		new wxStaticText(this, -1, wxT("Speed Controlled Zooming Cutoffs (mph)")),		0,		wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT,		0	);		//////////////////////////////////////////////////////////////////////////	// Speed Controlled Zooming Cutoffs Entry	//////////////////////////////////////////////////////////////////////////	wxString strSpeedControlledCutoffs;	g_pConfig->Read(wxT("SpeedControlledDetailLevelCutoffs"), &strSpeedControlledCutoffs, wxT("25, 50"));	m_pctlSpeedControlledCutoffs = new wxTextCtrl(this, -1, strSpeedControlledCutoffs, wxDefaultPosition, wxSize(250, -1));	psizerGrid->Add(		m_pctlSpeedControlledCutoffs,		0,		wxALIGN_LEFT,		0	);		//////////////////////////////////////////////////////////////////////////	// Home zip code label	//////////////////////////////////////////////////////////////////////////	psizerGrid->Add(		new wxStaticText(this, -1, wxT("Home Zip Code")),		0,		wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT,		0	);		//////////////////////////////////////////////////////////////////////////	// Home zip code	//////////////////////////////////////////////////////////////////////////   int zipHome;	g_pConfig->Read(wxT("HomeZipCode"), &zipHome, 0);	m_pctlHomeZip = new wxTextCtrl(this, -1, wxString::Format(wxT("%05d"), zipHome), wxDefaultPosition, wxSize(250, -1));	psizerGrid->Add(		m_pctlHomeZip,		0,		wxALIGN_LEFT,		0	);	//////////////////////////////////////////////////////////////////////////	// Clear cache button	//////////////////////////////////////////////////////////////////////////	wxButton * pctlClearCache = new wxButton(this, idClearCache, wxT("Clear Cache"));	psizerGrid->Add(		pctlClearCache,		0,		wxALIGN_RIGHT,		0	);	//////////////////////////////////////////////////////////////////////////	// Clear maps button	//////////////////////////////////////////////////////////////////////////	wxButton * pctlClearMaps = new wxButton(this, idClearMaps, wxT("Clear Map Data"));	psizerGrid->Add(		pctlClearMaps,		0,		wxALIGN_LEFT,		0	);	//////////////////////////////////////////////////////////////////////////	// psizerWnd just adds a border to psizerGrid	//////////////////////////////////////////////////////////////////////////		psizerWnd = new wxBoxSizer(wxVERTICAL);	psizerWnd->Add(		psizerGrid,		0,		wxALL | wxGROW,		10	);		//////////////////////////////////////////////////////////////////////////	// Set up the sizer	//////////////////////////////////////////////////////////////////////////	m_pctlAutoDownloadMaps->SetFocus();	psizerWnd->Fit(this);	SetSizer(psizerWnd);	Layout();	psizerWnd->SetSizeHints(this);	}void PreferencesPageGeneral::OnClearCache(wxCommandEvent& event){	if (wxMessageBox(wxT("This will erase all cached downloads. It will not affect the data used to draw the maps. Are you sure you want to continue?"), wxT("Confirm"), wxYES_NO | wxNO_DEFAULT | wxICON_QUESTION, this) == wxYES)	{		ClearDownloadCache();		wxMessageBox(wxT("Cache cleared."), wxT("Information"), wxOK | wxICON_INFORMATION, this);	}}void PreferencesPageGeneral::OnClearMaps(wxCommandEvent& event){	if (wxMessageBox(wxT("This will erase all compiled map data. It is recommended you restart Roadnav after performing this operation. Are you sure you want to continue?"), wxT("Confirm"), wxYES_NO | wxNO_DEFAULT | wxICON_QUESTION, this) == wxYES)	{		ClearCompiledMapData();		wxMessageBox(wxT("Map data cleared. Please restart Roadnav."), wxT("Information"), wxOK | wxICON_INFORMATION, this);	}}//////////////////////////////////////////////////////////////////////////////////// \brief Ok was pressed .. save the settings/////////////////////////////////////////////////////////////////////////////////void PreferencesPageGeneral::OnOk(wxCommandEvent& event){	g_pConfig->Write(wxT("AutoDownloadMaps"), m_pctlAutoDownloadMaps->GetValue());	g_pConfig->Write(wxT("AntiAliasedMaps"), m_pctlAntiAliasedMaps->GetValue());	g_pConfig->Write(wxT("NorthAlwaysUp"), m_pctlNorthAlwaysUp->GetValue());	g_pConfig->Write(wxT("LiveDirectionsTTS"), m_pctlLiveDirectionsTTS->GetValue());	g_pConfig->Write(wxT("SkinPath-Day"), m_pctlSkinPathDay->GetValue());	g_pConfig->Write(wxT("SkinPath-Night"), m_pctlSkinPathNight->GetValue());	g_pConfig->Write(wxT("ProxyHost"), m_pctlProxyHost->GetValue());	g_pConfig->Write(wxT("SpeedControlledDetailLevelCutoffs"), m_pctlSpeedControlledCutoffs->GetValue());	long lPort = 0;	m_pctlProxyPort->GetValue().ToLong(&lPort);	g_pConfig->Write(wxT("ProxyPort"), lPort);	double fDrawingScaleFactor = 1;	m_pctlZoomMaps->GetValue().ToDouble(&fDrawingScaleFactor);	if (fDrawingScaleFactor < 1e-5)		fDrawingScaleFactor = 1e-5;	if (fDrawingScaleFactor > 10)		fDrawingScaleFactor = 10;	g_pConfig->Write(wxT("DrawingScaleFactor"), fDrawingScaleFactor);   long lHomeZip;   m_pctlHomeZip->GetValue().ToLong(&lHomeZip);   g_pConfig->Write(wxT("HomeZipCode"), lHomeZip);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -