📄 preferencespagegps.cpp
字号:
/* * Roadnav * PreferencesPageGPS.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 GPS 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 "PreferencesPageGPS.h"#include "SerialIO.h"#include "GPSMonitorThread.h"enum { idGPSType, idIconBrowse};BEGIN_EVENT_TABLE(PreferencesPageGPS, wxPanel) EVT_COMBOBOX(idGPSType, PreferencesPageGPS::OnGPSTypeChange) EVT_BUTTON(idIconBrowse, PreferencesPageGPS::OnIconBrowse)END_EVENT_TABLE()//////////////////////////////////////////////////////////////////////////////////// \brief PreferencesPageGPS constructor - create and initialize controls/////////////////////////////////////////////////////////////////////////////////PreferencesPageGPS::PreferencesPageGPS(wxWindow *parent) : wxPanel(parent, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL){ wxBoxSizer * psizerWnd; wxFlexGridSizer * psizerGrid; wxString strSel; psizerGrid = new wxFlexGridSizer(2, 5, 10); ////////////////////////////////////////////////////////////////////////// // GPS type label ////////////////////////////////////////////////////////////////////////// psizerGrid->Add( new wxStaticText(this, -1, wxT("GPS Type")), 0, wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT, 0 ); ////////////////////////////////////////////////////////////////////////// // GPS type selection ////////////////////////////////////////////////////////////////////////// wxArrayString arOptions; m_pctlGPSType = new wxComboBox(this, idGPSType, wxT(""), wxDefaultPosition, wxSize(200, -1), arOptions, wxCB_DROPDOWN | wxCB_READONLY); m_pctlGPSType->Append(wxT("None")); m_pctlGPSType->Append(wxT("Auto Detect"));#ifdef ROADNAV_SERIAL_SUPPORT m_pctlGPSType->Append(wxT("Serial/USB"));#endif#ifdef HAVE_LIBGPS m_pctlGPSType->Append(wxT("gpsd"));#endif#ifdef HAVE_SIMULATED_GPS_SUPPORT m_pctlGPSType->Append(wxT("Simulated"));#endif // add to the sizer psizerGrid->Add(m_pctlGPSType, 0, wxGROW, 0 ); switch (GPSMonitorThread::GetGPSType()) { default: case GPSTypeNone: m_pctlGPSType->SetValue(wxT("None")); break; case GPSTypeAutoDetect: case GPSTypeAutoDetectInProgress: m_pctlGPSType->SetValue(wxT("Auto Detect")); break;#ifdef ROADNAV_SERIAL_SUPPORT case GPSTypeSerial: m_pctlGPSType->SetValue(wxT("Serial/USB")); break;#endif#ifdef HAVE_LIBGPS case GPSTypeGPSD: m_pctlGPSType->SetValue(wxT("gpsd")); break;#endif#ifdef HAVE_SIMULATED_GPS_SUPPORT case GPSTypeSimulated: m_pctlGPSType->SetValue(wxT("Simulated")); break;#endif } #ifdef ROADNAV_SERIAL_SUPPORT int iBaudRate; int iSel; int i; bool bDone; ////////////////////////////////////////////////////////////////////////// // Serial port label ////////////////////////////////////////////////////////////////////////// psizerGrid->Add( new wxStaticText(this, -1, wxT("Serial port")), 0, wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT, 0 ); ////////////////////////////////////////////////////////////////////////// // Serial port selection ////////////////////////////////////////////////////////////////////////// m_pctlSerialPort = new wxComboBox(this, -1, wxT(""), wxDefaultPosition, wxSize(200, -1)); // start by enumerating the serial ports and adding them to the combo box i = 0; bDone = false; while (!bDone) { wxString strName; strName = EnumSerialPort(i); if (strName != wxT("")) { i++; m_pctlSerialPort->Append(strName); } else { bDone = true; } } // add to the sizer psizerGrid->Add(m_pctlSerialPort, 0, wxGROW, 0 ); g_pConfig->Read(wxT("GPSSerialPort"), &strSel, wxT("")); iSel = m_pctlSerialPort->FindString(strSel); if (iSel >= 0) m_pctlSerialPort->SetSelection(iSel); // if user value is listed, select it by number else if (strSel != wxT("")) m_pctlSerialPort->SetValue(strSel); // if user value is not listed, enter it as a string else if (m_pctlSerialPort->GetCount() > 0) m_pctlSerialPort->SetSelection(0); // if user value is blank and serial ports were detected, select the first serial port ////////////////////////////////////////////////////////////////////////// // Baud rate label ////////////////////////////////////////////////////////////////////////// psizerGrid->Add( new wxStaticText(this, -1, wxT("Baud rate")), 0, wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT, 0 ); ////////////////////////////////////////////////////////////////////////// // Baud rate selection ////////////////////////////////////////////////////////////////////////// m_pctlBaudRate = new wxComboBox(this, -1, wxT("")); m_pctlBaudRate->Append(wxT("1200")); m_pctlBaudRate->Append(wxT("2400")); m_pctlBaudRate->Append(wxT("4800")); m_pctlBaudRate->Append(wxT("9600")); m_pctlBaudRate->Append(wxT("19200")); m_pctlBaudRate->Append(wxT("38400")); g_pConfig->Read(wxT("GPSBaudRate"), &iBaudRate, 4800); strSel = wxString::Format(wxT("%d"), iBaudRate); iSel = m_pctlBaudRate->FindString(strSel); if (iSel >= 0) m_pctlBaudRate->SetSelection(iSel); else m_pctlBaudRate->SetValue(strSel); psizerGrid->Add(m_pctlBaudRate, 0, wxGROW, 0 );#endif#ifdef HAVE_LIBGPS ////////////////////////////////////////////////////////////////////////// // gpsd Host Label ////////////////////////////////////////////////////////////////////////// psizerGrid->Add( new wxStaticText(this, -1, wxT("gpsd Host")), 0, wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT, 0 ); ////////////////////////////////////////////////////////////////////////// // gpsd Host Entry ////////////////////////////////////////////////////////////////////////// m_pctlgpsdHost = new wxTextCtrl(this, -1, g_pConfig->Read(wxT("gpsdHost"), wxT("localhost")), wxDefaultPosition, wxSize(250, -1)); psizerGrid->Add( m_pctlgpsdHost, 0, wxALIGN_LEFT, 0 ); ////////////////////////////////////////////////////////////////////////// // gpsd Port Label ////////////////////////////////////////////////////////////////////////// psizerGrid->Add( new wxStaticText(this, -1, wxT("gpsd Port")), 0, wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT, 0 ); ////////////////////////////////////////////////////////////////////////// // gpsd Port Entry ////////////////////////////////////////////////////////////////////////// m_pctlgpsdPort = new wxTextCtrl(this, -1, g_pConfig->Read(wxT("gpsdPort"), wxT("2947")), wxDefaultPosition, wxSize(250, -1)); psizerGrid->Add( m_pctlgpsdPort, 0, wxALIGN_LEFT, 0 ); ////////////////////////////////////////////////////////////////////////// // gpsd check compatibility Label ////////////////////////////////////////////////////////////////////////// psizerGrid->Add( new wxStaticText(this, -1, wxT("Check gpsd Server Compatibility")), 0, wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT, 0 ); ////////////////////////////////////////////////////////////////////////// // gpsd Port Entry ////////////////////////////////////////////////////////////////////////// m_pctlgpsdCompatibilityCheck = new wxCheckBox(this, -1, wxT("")); m_pctlgpsdCompatibilityCheck->SetValue(g_pConfig->Read(wxT("gpsdCompatibilityCheck"), (long) 1)); psizerGrid->Add(
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -