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

📄 locationdialog.cpp

📁 Powerful and Portable GPS application -- support Linux, Windows, Windows CE GPS navigation and Map m
💻 CPP
📖 第 1 页 / 共 2 页
字号:
/* *  Roadnav *  LocationDialog.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////// Dialog box allowing a user to enter an address.////// Also includes functionality to parse the address./// The dialog box remembers recent valid addresses./////////////////////////////////////////////////////////////////////////////////#ifdef HAVE_CONFIG_H#  include <config.h>#endif#ifdef _MSC_VER#pragma warning(disable: 4786)#endif#include <wx/wx.h>#include <wx/valgen.h>#include "LocationDialog.h"#include "libroadnav/Map.h"#include "libroadnav/MapLookup.h"#include "libroadnav/MapState.h"#include "App.h"#include "libroadnav/MapAbbreviations.h"#include "libroadnav/MapZip.h"#include "libroadnav/MapRepresentations.h"#include "libroadnav/MapControlDataImporter_TigerLine.h"#include "KeyboardDialog.h"#include "Scripting.h"#include <vector>using namespace std;///////////////////////////////////////////////////////////////////////////////// button IDs//////////////////////////////////////////////////////////////////////////////enum{	idOldAddresses,	idAdd,	idUpdate,	idDelete,	idIconBrowse,	idKeyboard,#ifdef USE_SCRIPTING	idExport,	idExportAll,#endif};#define TIMER_TICK	1///////////////////////////////////////////////////////////////////////////////// Event table for LocationDialog//////////////////////////////////////////////////////////////////////////////BEGIN_EVENT_TABLE(LocationDialog, wxDialog)	EVT_BUTTON(wxID_OK, LocationDialog::OnOk)	EVT_BUTTON(wxID_CANCEL, LocationDialog::OnCancel)	EVT_BUTTON(idAdd, LocationDialog::OnAdd)	EVT_BUTTON(idUpdate, LocationDialog::OnUpdate)	EVT_BUTTON(idDelete, LocationDialog::OnDelete)	EVT_BUTTON(idIconBrowse, LocationDialog::OnIconBrowse)	EVT_LISTBOX(idOldAddresses, LocationDialog::OnOldAddress)	EVT_LISTBOX_DCLICK(idOldAddresses, LocationDialog::OnOldAddressDoubleClick)	EVT_BUTTON(idKeyboard, LocationDialog::OnKeyboard)	EVT_TIMER(TIMER_TICK, LocationDialog::OnTimer)#ifdef USE_SCRIPTING	EVT_BUTTON(idExport, LocationDialog::OnExport)	EVT_BUTTON(idExportAll, LocationDialog::OnExportAll)#endifEND_EVENT_TABLE()//////////////////////////////////////////////////////////////////////////////////// \brief LocationDialog constructor - Creates the various controls in the /// dialog box/////////////////////////////////////////////////////////////////////////////////LocationDialog::LocationDialog(wxWindow *parent, MapControl * pctlMap, int iFlags, wxFont * pFont) : wxDialog(parent, -1, wxString(wxT("Enter an address"))){	wxBoxSizer *sizerWnd = new wxBoxSizer(wxHORIZONTAL);	wxBoxSizer *sizerRight = new wxBoxSizer(wxVERTICAL);		m_pcAutoComplete = NULL;	m_bRoadsOnly = false;		m_iFlags = iFlags;		if (pFont)		SetFont(*pFont);		//////////////////////////////////////////////////////////////////////////////	// default title	//////////////////////////////////////////////////////////////////////////////	m_strTitle = wxT("Enter an address");	//////////////////////////////////////////////////////////////////////////////	// Save arguments to member variables	//////////////////////////////////////////////////////////////////////////////	m_pctlMap = pctlMap;	//////////////////////////////////////////////////////////////////////////////	// Create notebook containing a page for each way an address can be entered.	//////////////////////////////////////////////////////////////////////////////#if wxCHECK_VERSION(2, 5, 0)	m_pctlNotebook = new wxNotebook(this, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL);#else	m_pctlNotebook = new wxNotebook(this, -1, wxDefaultPosition, wxSize(300, 200), wxTAB_TRAVERSAL);	wxNotebookSizer * pnbsNotebook = new wxNotebookSizer(m_pctlNotebook);#endif	//////////////////////////////////////////////////////////////////////////	// Address entry	//////////////////////////////////////////////////////////////////////////	m_pwndAddress = new LocationPageAddress(m_pctlNotebook, m_pctlMap);	m_pctlNotebook->AddPage(m_pwndAddress, wxT("Address"));	//////////////////////////////////////////////////////////////////////////	// Coordinate entry	//////////////////////////////////////////////////////////////////////////	m_pwndCoordinates = new LocationPageCoordinates(m_pctlNotebook);	m_pctlNotebook->AddPage(m_pwndCoordinates, wxT("Coordinates"));		//////////////////////////////////////////////////////////////////////////////	// waypoint name entry	//////////////////////////////////////////////////////////////////////////////	sizerRight->Add(					new wxStaticText(this, -1, wxT("Waypoint Name (optional)"), wxDefaultPosition),					0, 					wxALIGN_LEFT | wxALIGN_BOTTOM | wxLEFT | wxRIGHT | wxTOP, 					5);	m_ctlName = new wxTextCtrl(this, -1, m_strName, wxDefaultPosition, wxDefaultSize, 0, wxGenericValidator(&m_strName));    sizerRight->Add(m_ctlName, 0, wxGROW | wxALL, 5);	//////////////////////////////////////////////////////////////////////////////	// waypoint icon filename entry	//////////////////////////////////////////////////////////////////////////////	sizerRight->Add(					new wxStaticText(this, -1, wxT("Icon Filename (optional)"), wxDefaultPosition),					0, 					wxALIGN_LEFT | wxALIGN_BOTTOM | wxLEFT | wxRIGHT | wxTOP, 					5);	wxBoxSizer * sizerIcon = new wxBoxSizer(wxHORIZONTAL);	m_ctlIconFilename = new wxTextCtrl(this, -1, m_strIconFilename, wxDefaultPosition, wxDefaultSize, 0, wxGenericValidator(&m_strIconFilename));	sizerIcon->Add(m_ctlIconFilename, 1, wxGROW | wxALL, 5);	wxButton * btnIconBrowse= new wxButton(this, idIconBrowse, wxT("&Browse..."));	sizerIcon->Add(btnIconBrowse, 0, wxALIGN_RIGHT | wxALL, 5);	sizerRight->Add(sizerIcon, 0, wxGROW | wxALL, 0);	//////////////////////////////////////////////////////////////////////////	// Scale icon checkbox	//////////////////////////////////////////////////////////////////////////	m_bScaleIcon = false;	m_ctlScaleIcon = new wxCheckBox(this, -1, wxT("Scale Icon"), wxDefaultPosition, wxDefaultSize, 0, wxGenericValidator(&m_bScaleIcon));	sizerRight->Add(					m_ctlScaleIcon, 					0,					wxALIGN_LEFT | wxALIGN_BOTTOM | wxALL, 					5);	//////////////////////////////////////////////////////////////////////////	// Show callout box checkbox	//////////////////////////////////////////////////////////////////////////	m_bShowCalloutBox = false;	m_ctlShowCalloutBox = new wxCheckBox(this, -1, wxT("Show Callout Box"), wxDefaultPosition, wxDefaultSize, 0, wxGenericValidator(&m_bShowCalloutBox));	sizerRight->Add(					m_ctlShowCalloutBox, 					0,					wxALIGN_LEFT | wxALIGN_BOTTOM | wxALL, 					5);	//////////////////////////////////////////////////////////////////////////	// Show small label checkbox	//////////////////////////////////////////////////////////////////////////	m_bShowSmallLabel = true;	m_ctlShowSmallLabel = new wxCheckBox(this, -1, wxT("Show Small Label"), wxDefaultPosition, wxDefaultSize, 0, wxGenericValidator(&m_bShowSmallLabel));	sizerRight->Add(					m_ctlShowSmallLabel, 					0,					wxALIGN_LEFT | wxALIGN_BOTTOM | wxALL, 					5);	//////////////////////////////////////////////////////////////////////////	// Visible checkbox	//////////////////////////////////////////////////////////////////////////	m_bVisible = true;	m_ctlVisible = new wxCheckBox(this, -1, wxT("Visible"), wxDefaultPosition, wxDefaultSize, 0, wxGenericValidator(&m_bVisible));	sizerRight->Add(					m_ctlVisible, 					0,					wxALIGN_LEFT | wxALIGN_BOTTOM | wxALL, 					5);	//////////////////////////////////////////////////////////////////////////////	// list of old queries	//////////////////////////////////////////////////////////////////////////////	wxBoxSizer * sizerMarkerMgmtOutside = new wxBoxSizer(wxHORIZONTAL);	m_ctlOldAddresses = new wxListBox(						this,						idOldAddresses,						wxDefaultPosition,						wxSize(300, 100)					);				sizerMarkerMgmtOutside->Add(m_ctlOldAddresses, 1, wxGROW | wxALL, 0);	//////////////////////////////////////////////////////////////////////////////	// Add/update/delete buttons if selected in iFlags	//////////////////////////////////////////////////////////////////////////////	if ((iFlags & ADFLAG_MARKERMANAGEMENTBUTTONS) && m_pctlMap)	{		wxBoxSizer * sizerMarkerMgmtRight = new wxBoxSizer(wxVERTICAL);		sizerMarkerMgmtOutside->Add(sizerMarkerMgmtRight, 0, wxGROW | wxALL, 5);		wxButton * btnAdd = new wxButton(this, idAdd, wxT("&Add"));		wxButton * btnUpdate = new wxButton(this, idUpdate, wxT("&Update"));		wxButton * btnDelete = new wxButton(this, idDelete, wxT("&Delete"));		sizerMarkerMgmtRight->Add(btnAdd, 0, wxALIGN_CENTER | wxALL, 5);		sizerMarkerMgmtRight->Add(btnUpdate, 0, wxALIGN_CENTER | wxALL, 5);		sizerMarkerMgmtRight->Add(btnDelete, 0, wxALIGN_CENTER | wxALL, 5);#ifdef USE_SCRIPTING		m_btnExportAll = new wxButton(this, idExportAll, wxT("Export A&ll"));		sizerMarkerMgmtRight->Add(m_btnExportAll, 0, wxALIGN_CENTER | wxALL, 5);#endif    	}	sizerRight->Add(sizerMarkerMgmtOutside, 0, wxGROW | wxALL, 5);	//////////////////////////////////////////////////////////////////////////////	// 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);	if (iFlags & ADFLAG_CANCELBUTTON)	{		wxButton * btnCancel = new wxButton(this, wxID_CANCEL, wxT("&Cancel"));		sizerBottom->Add(btnCancel, 0, wxALIGN_CENTER | wxALL, 5);	}    m_btnKeyboard = new wxButton(this, idKeyboard, wxT("&Keyboard"));    sizerBottom->Add(m_btnKeyboard, 0, wxALIGN_CENTER | wxALL, 5);#ifdef USE_SCRIPTING	m_btnExport = new wxButton(this, idExport, wxT("&Export"));	sizerBottom->Add(m_btnExport, 0, wxALIGN_CENTER | wxALL, 5);#endif    	sizerRight->Add(sizerBottom, 0, wxALIGN_CENTER, 0);	//////////////////////////////////////////////////////////////////////////////	// layout stuff	//////////////////////////////////////////////////////////////////////////////		sizerWnd->Add(m_pctlNotebook,				1,				wxGROW | wxALL,				5	);	sizerWnd->Add(sizerRight, 1, wxALL | wxGROW, 0);	    SetAutoLayout(TRUE);    SetSizer(sizerWnd);    sizerWnd->SetSizeHints(this);    sizerWnd->Fit(this);    btnOk->SetDefault();		m_pwndAddress->SetFocus();		//////////////////////////////////////////////////////////////////////////////	// Focus tracking	//////////////////////////////////////////////////////////////////////////////	m_pwndFocused = NULL;	m_Timer = new wxTimer(this, TIMER_TICK);	m_Timer->Start(100);	//////////////////////////////////////////////////////////////////////////////	// Position dialog	//////////////////////////////////////////////////////////////////////////////	Center();}//////////////////////////////////////////////////////////////////////////////////// \brief LocationDialog destructor - delete m_Timer/////////////////////////////////////////////////////////////////////////////////LocationDialog::~LocationDialog(){	delete m_Timer;}//////////////////////////////////////////////////////////////////////////////////// \brief Populate the list box with any markers available./////////////////////////////////////////////////////////////////////////////////void LocationDialog::PopulateListBox(){	int i;		m_ctlOldAddresses->Clear();	if (m_pctlMap)	{		for (i = 0; i < m_pctlMap->GetMarkerCount(); i++)		{			MapMarker & cMarker = m_pctlMap->GetMarker(i);			m_ctlOldAddresses->Append(cMarker.m_strName + wxT(" (") + cMarker.m_cAddress.FormatAddress(false, true) + wxT(")"));		}	}}///////////////////////////////////////////////////////////////////////////////// /// \brief This function initializes the prior addresses box, sets the title, /// and shows the dialog modally./////////////////////////////////////////////////////////////////////////////////int LocationDialog::ShowModal(){	PopulateListBox();	SetTitle(m_strTitle);	return wxDialog::ShowModal();}//////////////////////////////////////////////////////////////////////////////////// \brief Ok pressed - Saves the edit controls to member variables./////////////////////////////////////////////////////////////////////////////////void LocationDialog::OnOk(wxCommandEvent& event){	m_Timer->Stop();		UpdateData();	if (!(m_iFlags & ADFLAG_MARKERMANAGEMENTBUTTONS))		if (!MayClose())			return;	EndModal(wxID_OK);}/////////////////////////////////////////////////////////////////////////////////

⌨️ 快捷键说明

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