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

📄 preferencespagerouting.cpp

📁 roadnav 内含一个基于wxWindows库的车载导航系统。编译后
💻 CPP
字号:
/*
 *  Roadnav
 *  PreferencesPageRouting.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 routing 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 "App.h"
#include "PreferencesPageRouting.h"
#include "SerialIO.h"
#include "GPSMonitorThread.h"
#include "libroadnav/MapControlDataEntry_Std.h"

BEGIN_EVENT_TABLE(PreferencesPageRouting, wxPanel)
END_EVENT_TABLE()

//////////////////////////////////////////////////////////////////////////////
///
/// \brief PreferencesPageRouting constructor - create and initialize controls
///
//////////////////////////////////////////////////////////////////////////////
PreferencesPageRouting::PreferencesPageRouting(wxWindow *parent)
             : wxPanel(parent, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL)
{
	wxBoxSizer * psizerWnd;
	double fPreferSmallRoads, fPreferLargeRoads, fPreferHighways;
	wxStaticText * pctlInstructions;
	int iScreenWidth;
	
	psizerWnd = new wxBoxSizer(wxVERTICAL);
	
	g_pConfig->Read(wxT("PreferSmallRoads"), &fPreferSmallRoads, 1);
	g_pConfig->Read(wxT("PreferLargeRoads"), &fPreferLargeRoads, 1.44);
	g_pConfig->Read(wxT("PreferHighways"), &fPreferHighways, 1.54);

	pctlInstructions = new wxStaticText(this, -1, wxT("Move sliders to the left to have routing avoid a particular type of road, or right to prefer that type of road."),
											wxDefaultPosition,
											wxDefaultSize,
											wxALIGN_CENTRE);
	
	iScreenWidth = wxSystemSettings::GetMetric(wxSYS_SCREEN_X);
	wxASSERT(iScreenWidth > 0);
	
	if (iScreenWidth > 0)
		pctlInstructions->Wrap(iScreenWidth / 2);

	//////////////////////////////////////////////////////////////////////////
	// Instructions label
	//////////////////////////////////////////////////////////////////////////
	psizerWnd->Add(
		pctlInstructions,
		0,
		wxALIGN_CENTER_VERTICAL | wxALIGN_CENTER | wxALL,
		10
	);
	
	

	//////////////////////////////////////////////////////////////////////////
	// Small roads label
	//////////////////////////////////////////////////////////////////////////
	psizerWnd->Add(
		new wxStaticText(this, -1, wxT("Small Roads")),
		0,
		wxALIGN_CENTER_VERTICAL | wxALIGN_LEFT | wxALL,
		10
	);

	//////////////////////////////////////////////////////////////////////////
	// Small roads slider 
	//////////////////////////////////////////////////////////////////////////
	m_pctlSmallRoadsSlider = new wxSlider(this, -1, (int) (fPreferSmallRoads * 10), 1, 60);
	psizerWnd->Add(m_pctlSmallRoadsSlider, 1, wxGROW | wxALL, 5);
	
	//////////////////////////////////////////////////////////////////////////
	// Large roads label
	//////////////////////////////////////////////////////////////////////////
	psizerWnd->Add(
		new wxStaticText(this, -1, wxT("Large Roads")),
		0,
		wxALIGN_CENTER_VERTICAL | wxALIGN_LEFT | wxALL,
		10
	);

	//////////////////////////////////////////////////////////////////////////
	// Large roads slider 
	//////////////////////////////////////////////////////////////////////////
	m_pctlLargeRoadsSlider = new wxSlider(this, -1, (int) (fPreferLargeRoads * 10), 1, 60);
	psizerWnd->Add(m_pctlLargeRoadsSlider, 1, wxGROW | wxALL, 5);
	
	//////////////////////////////////////////////////////////////////////////
	// Highways label
	//////////////////////////////////////////////////////////////////////////
	psizerWnd->Add(
		new wxStaticText(this, -1, wxT("Highways")),
		0,
		wxALIGN_CENTER_VERTICAL | wxALIGN_LEFT | wxALL,
		10
	);

	//////////////////////////////////////////////////////////////////////////
	// Highways slider 
	//////////////////////////////////////////////////////////////////////////
	m_pctlHighwaysSlider = new wxSlider(this, -1, (int) (fPreferHighways * 10), 1, 60);
	psizerWnd->Add(m_pctlHighwaysSlider, 1, wxGROW | wxALL, 5);
	
	//////////////////////////////////////////////////////////////////////////
	// Set up the sizer
	//////////////////////////////////////////////////////////////////////////
	m_pctlSmallRoadsSlider->SetFocus();
	psizerWnd->Fit(this);
	SetSizer(psizerWnd);
	Layout();
	psizerWnd->SetSizeHints(this);
}

//////////////////////////////////////////////////////////////////////////////
///
/// \brief Ok was pressed .. save the settings
///
//////////////////////////////////////////////////////////////////////////////
void PreferencesPageRouting::OnOk(wxCommandEvent& event)
{
	g_pConfig->Write(wxT("PreferSmallRoads"), m_pctlSmallRoadsSlider->GetValue() / 10.0);
	g_pConfig->Write(wxT("PreferLargeRoads"), m_pctlLargeRoadsSlider->GetValue() / 10.0);
	g_pConfig->Write(wxT("PreferHighways"), m_pctlHighwaysSlider->GetValue() / 10.0);
}

⌨️ 快捷键说明

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