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

📄 preferencesdialog.cpp

📁 Powerful and Portable GPS application -- support Linux, Windows, Windows CE GPS navigation and Map m
💻 CPP
字号:
/* *  Roadnav *  PreferencesDialog.cpp * *  Copyright (c) 2004 - 2007 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 preferences dialog box./////////////////////////////////////////////////////////////////////////////////#ifdef HAVE_CONFIG_H#  include <config.h>#endif#include <wx/wx.h>#include <wx/notebook.h>#ifdef _MSC_VER#pragma warning(disable: 4786)#endif#include "App.h"#include "PreferencesDialog.h"#include "KeyboardDialog.h"enum{	idKeyboard};#define TIMER_TICK	1//////////////////////////////////////////////////////////////////////////////////// PreferencesDialog event table/////////////////////////////////////////////////////////////////////////////////BEGIN_EVENT_TABLE(PreferencesDialog, wxDialog)	EVT_BUTTON(wxID_OK, PreferencesDialog::OnOk)	EVT_BUTTON(wxID_CANCEL, PreferencesDialog::OnCancel)	EVT_BUTTON(idKeyboard, PreferencesDialog::OnKeyboard)	EVT_TIMER(TIMER_TICK, PreferencesDialog::OnTimer)END_EVENT_TABLE()//////////////////////////////////////////////////////////////////////////////////// \brief Constructor for preferences dialog.////// This mostly just creates the individual pages, which is where the actual/// settings are read/set./////////////////////////////////////////////////////////////////////////////////PreferencesDialog::PreferencesDialog(wxWindow *parent, MapControl * pctlMap, wxFont * pFont, IMapControlData * pMapControlData, ThemeManager * pThemeManager)             : wxDialog(parent, -1, wxString(wxT("Preferences")), wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL | wxDEFAULT_DIALOG_STYLE){	wxNotebook * pctlNotebook;	wxBoxSizer * sizerWnd;	m_pMapControlData = pMapControlData;	m_pThemeManager = pThemeManager;	m_pctlMap = pctlMap;		if (pFont)		SetFont(*pFont);			sizerWnd = new wxBoxSizer(wxVERTICAL);	#if wxCHECK_VERSION(2, 6, 0)	pctlNotebook = new wxNotebook(this, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL);#else	pctlNotebook = new wxNotebook(this, -1, wxDefaultPosition, wxSize(400, 300), wxTAB_TRAVERSAL);#endif	sizerWnd->Add(pctlNotebook,				0,				wxGROW,				0	);	//////////////////////////////////////////////////////////////////////////	// General settings page	//////////////////////////////////////////////////////////////////////////	m_pwndGeneral = new PreferencesPageGeneral(pctlNotebook);	pctlNotebook->AddPage(m_pwndGeneral, wxT("General"));	//////////////////////////////////////////////////////////////////////////	// GPS settings page	//////////////////////////////////////////////////////////////////////////	m_pwndGPS = new PreferencesPageGPS(pctlNotebook);	pctlNotebook->AddPage(m_pwndGPS, wxT("GPS"));	//////////////////////////////////////////////////////////////////////////	// TTS settings page	//////////////////////////////////////////////////////////////////////////	m_pwndTTS = new PreferencesPageTTS(pctlNotebook);	pctlNotebook->AddPage(m_pwndTTS, wxT("TTS"));	//////////////////////////////////////////////////////////////////////////	// Themes settings page	//////////////////////////////////////////////////////////////////////////	m_pwndThemes = new PreferencesPageThemes(pctlNotebook, m_pMapControlData, m_pThemeManager);	pctlNotebook->AddPage(m_pwndThemes, wxT("Themes"));	//////////////////////////////////////////////////////////////////////////	// URLs settings page	//////////////////////////////////////////////////////////////////////////	m_pwndURLs = new PreferencesPageURLs(pctlNotebook);	pctlNotebook->AddPage(m_pwndURLs, wxT("URLs"));	//////////////////////////////////////////////////////////////////////////	// Units settings page	//////////////////////////////////////////////////////////////////////////	m_pwndUnits = new PreferencesPageUnits(pctlNotebook);	pctlNotebook->AddPage(m_pwndUnits, wxT("Units"));	//////////////////////////////////////////////////////////////////////////	// Routing settings page	//////////////////////////////////////////////////////////////////////////	m_pwndRouting = new PreferencesPageRouting(pctlNotebook);	pctlNotebook->AddPage(m_pwndRouting, wxT("Routing"));	//////////////////////////////////////////////////////////////////////////	// LCDproc settings page	//////////////////////////////////////////////////////////////////////////	m_pwndLCDproc = new PreferencesPageLCDproc(pctlNotebook);	pctlNotebook->AddPage(m_pwndLCDproc, wxT("LCD"));#ifdef USE_OPENSTREETMAP	//////////////////////////////////////////////////////////////////////////	// OpenStreetMap settings page	//////////////////////////////////////////////////////////////////////////	m_pwndOSM = new PreferencesPageOSM(pctlNotebook);	pctlNotebook->AddPage(m_pwndOSM, wxT("OSM"));#endif	//////////////////////////////////////////////////////////////////////////	// Scripting settings page	//////////////////////////////////////////////////////////////////////////#ifdef USE_SCRIPTING	m_pwndScripting = new PreferencesPageScripting(pctlNotebook);	pctlNotebook->AddPage(m_pwndScripting, wxT("Scripting"));#endif	//////////////////////////////////////////////////////////////////////////	// ok and cancel button	//////////////////////////////////////////////////////////////////////////    wxBoxSizer * sizerBottom = new wxBoxSizer(wxHORIZONTAL);    wxButton * btnOk = new wxButton(this, wxID_OK, wxT("&OK"));    sizerBottom->Add(btnOk, 0, wxALIGN_CENTER | wxALL, 5);    wxButton * btnCancel = new wxButton(this, wxID_CANCEL, wxT("&Cancel"));    sizerBottom->Add(btnCancel, 0, wxALIGN_CENTER | wxALL, 5);    wxButton * btnKeyboard = new wxButton(this, idKeyboard, wxT("&Keyboard"));    sizerBottom->Add(btnKeyboard, 0, wxALIGN_CENTER | wxALL, 5);	sizerWnd->Add(sizerBottom, 0, wxALIGN_CENTER, 0);			sizerWnd->Fit(this);	SetSizer(sizerWnd);	Layout();	sizerWnd->SetSizeHints(this);#ifdef __DARWIN__ 	wxSize szDlg;	szDlg = GetSize();	if (szDlg.GetWidth() < 650)	{		szDlg.SetWidth(650);		SetSize(szDlg);	}#endif	m_pwndFocused = NULL;	m_Timer = new wxTimer(this, TIMER_TICK);	m_Timer->Start(100);	//////////////////////////////////////////////////////////////////////////////	// Position dialog	//////////////////////////////////////////////////////////////////////////////	Center();}//////////////////////////////////////////////////////////////////////////////////// \brief Ok was pressed .. send this to the notebook pages/////////////////////////////////////////////////////////////////////////////////void PreferencesDialog::OnOk(wxCommandEvent& event){	m_Timer->Stop();	m_pwndGeneral->OnOk(event);	m_pwndGPS->OnOk(event);	m_pwndTTS->OnOk(event);	m_pwndThemes->OnOk(event);	m_pwndURLs->OnOk(event);	m_pwndUnits->OnOk(event);	m_pwndLCDproc->OnOk(event);	m_pwndRouting->OnOk(event);#ifdef USE_OPENSTREETMAP	m_pwndOSM->OnOk(event);#endif#ifdef USE_SCRIPTING	m_pwndScripting->OnOk(event);#endif		g_pConfig->Flush();		EndModal(wxID_OK);}//////////////////////////////////////////////////////////////////////////////////// \brief Cancel was pressed/////////////////////////////////////////////////////////////////////////////////void PreferencesDialog::OnCancel(wxCommandEvent& event){	m_Timer->Stop();	EndModal(wxID_CANCEL);}//////////////////////////////////////////////////////////////////////////////////// \brief Keyboard button pressed - activate onscreen keyboard (using/// KeyboardDialog)./////////////////////////////////////////////////////////////////////////////////void PreferencesDialog::OnKeyboard(wxCommandEvent & event){	if (!m_pwndFocused)		return;	KeyboardDialog dlg(	this, 						wxT("Keyboard"), 						m_pwndFocused, 						m_pctlMap->GetDetailSettings()->GetMiscColor(MiscColorBackground),						m_pctlMap->GetDetailSettings()->GetMiscColor(MiscColorForeground),						NULL);	m_Timer->Stop();	dlg.ShowModal();	m_Timer->Start(100);	m_pwndFocused->SetFocus();}//////////////////////////////////////////////////////////////////////////////////// \brief 100ms timer function. Tracks which wxTextCtrl has focus using/// m_pwndFocused./////////////////////////////////////////////////////////////////////////////////void PreferencesDialog::OnTimer(wxTimerEvent& event){	wxWindow * pwndFocused;	pwndFocused = wxWindow::FindFocus();		if (!pwndFocused)		return;	if (pwndFocused->IsKindOf(CLASSINFO(wxTextCtrl)))		m_pwndFocused = wxDynamicCast(pwndFocused, wxTextCtrl);;}

⌨️ 快捷键说明

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