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

📄 locationpageaddress.cpp

📁 Powerful and Portable GPS application -- support Linux, Windows, Windows CE GPS navigation and Map m
💻 CPP
字号:
/* *  Roadnav *  LocationPageAddress.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////// \brief This location page allows a street address to be entered./////////////////////////////////////////////////////////////////////////////////#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 <wx/valgen.h>#include <vector>#include "App.h"#include "LocationPageAddress.h"#include "libroadnav/MapLookup.h"#include "libroadnav/MapState.h"#include "libroadnav/Map.h"#include "libroadnav/MapAbbreviations.h"#include "libroadnav/MapZip.h"#include "libroadnav/MapRepresentations.h"#include "libroadnav/MapControlDataImporter_GNISDECI.h"#include "libroadnav/MapControlDataImporter_TigerLine.h"#include "libroadnav/MapSupport.h"#include "Support.h"using namespace std;//////////////////////////////////////////////////////////////////////////////////// Event table for LocationPageAddress/////////////////////////////////////////////////////////////////////////////////BEGIN_EVENT_TABLE(LocationPageAddress, wxPanel)END_EVENT_TABLE()//////////////////////////////////////////////////////////////////////////////////// \brief Constructor - create the controls/////////////////////////////////////////////////////////////////////////////////LocationPageAddress::LocationPageAddress(wxWindow *parent, MapControl * pctlMap)             : wxPanel(parent, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL | wxNO_BORDER){	wxBoxSizer * sizerWnd = new wxBoxSizer(wxVERTICAL);	m_pctlMap = pctlMap;	//////////////////////////////////////////////////////////////////////////////	// street entry	//////////////////////////////////////////////////////////////////////////////	sizerWnd->Add(					new wxStaticText(this, -1, wxT("Street"), wxDefaultPosition),					1, 					wxALIGN_LEFT | wxALIGN_BOTTOM | wxLEFT | wxRIGHT | wxTOP, 					5);	m_ctlStreet = new wxTextCtrl(this, -1, m_strStreet, wxDefaultPosition, wxSize(200, -1), 0, wxGenericValidator(&m_strStreet));    sizerWnd->Add(m_ctlStreet, 1, wxGROW | wxALL, 5);	//////////////////////////////////////////////////////////////////////////////	// city entry	//////////////////////////////////////////////////////////////////////////////	sizerWnd->Add(					new wxStaticText(this, -1, wxT("City"), wxDefaultPosition),					1, 					wxALIGN_LEFT | wxALIGN_BOTTOM | wxLEFT | wxRIGHT | wxTOP, 					5);	m_ctlCity = new wxTextCtrl(this, -1, m_strCity, wxDefaultPosition, wxDefaultSize, 0, wxGenericValidator(&m_strCity));    sizerWnd->Add(m_ctlCity, 1, wxGROW | wxALL, 5);	//////////////////////////////////////////////////////////////////////////////	// state entry	//////////////////////////////////////////////////////////////////////////////	sizerWnd->Add(					new wxStaticText(this, -1, wxT("State"), wxDefaultPosition),					1, 					wxALIGN_LEFT | wxALIGN_BOTTOM | wxLEFT | wxRIGHT | wxTOP, 					5);	m_ctlState = new wxTextCtrl(this, -1, m_strState, wxDefaultPosition, wxDefaultSize, 0, wxGenericValidator(&m_strState));    sizerWnd->Add(m_ctlState, 1, wxGROW | wxALL, 5);	//////////////////////////////////////////////////////////////////////////	// Set up the sizer	//////////////////////////////////////////////////////////////////////////    m_ctlStreet->SetFocus();	sizerWnd->Fit(this);	SetSizer(sizerWnd);	Layout();	sizerWnd->SetSizeHints(this);	m_mapWndToAutoComplete[m_ctlState] = &m_cAutoCompleteState;		m_mapWndToAutoComplete[m_ctlCity] = &m_cAutoCompleteCity;		m_mapWndToAutoComplete[m_ctlStreet] = &m_cAutoCompleteStreet;}///////////////////////////////////////////////////////////////////////////////// /// \brief Parse the entered addresses.////// This function parses the address that was entered into it and returns/// an Address pointer. Multiple calls to GetAddress will return the same/// pointer since FindAddress is used./////////////////////////////////////////////////////////////////////////////////Address LocationPageAddress::GetAddress(wxString * pstrErrorMsg, bool bRoadsOnly){	if (pstrErrorMsg)		*pstrErrorMsg = m_strErrorMsg;			return m_cAddress;}///////////////////////////////////////////////////////////////////////////////// /// \brief Set the text fields to a certain address./////////////////////////////////////////////////////////////////////////////////void LocationPageAddress::SetAddress(Address cAddress){	m_strStreet = wxT("");	if (cAddress.m_iStreetNumber)		m_strStreet += wxString::Format(wxT("%d "), cAddress.m_iStreetNumber);	m_strStreet += cAddress.m_strStreetName + wxT(" ") + cAddress.m_strStreetType;	m_strCity = cAddress.m_strCityName;	m_strState = cAddress.m_strStateName;	m_strState = StateAbbreviationByName(m_strState);	TransferDataToWindow();}///////////////////////////////////////////////////////////////////////////////// /// \brief Indicates if the location dialog may close. Returns false if the/// address is invalid./////////////////////////////////////////////////////////////////////////////////bool LocationPageAddress::MayClose(bool bRoadsOnly){	const bool * pbVisibility;	wxString strState;	int iTotalDownload;	wxString strRecommendedStreet;	wxString strRecommendedCity;	wxString strRecommendedState;	if (bRoadsOnly)		pbVisibility = OnlyRoadsVisibility();	else		pbVisibility = AllVisibility();	//////////////////////////////////////////////////////////////////////////	// state .. convert to abbreviation if necessary	//////////////////////////////////////////////////////////////////////////	strState = StateAbbreviationByName(m_strState);	if (strState == wxT(""))		strState = m_strState;			strState = strState.MakeUpper();	iTotalDownload = DownloadCityState(m_strCity, m_strState, m_pctlMap->GetMapControlData());	m_cAddress = FindAddress(m_strStreet, m_strCity, m_strState, pbVisibility, NULL, &m_strErrorMsg, &strRecommendedStreet, &strRecommendedCity, &strRecommendedState);	if (!m_cAddress.m_bValid)	{		if (iTotalDownload)		{			m_strErrorMsg = wxT("Maps unavailable for that address. Please download them first.");		}		else if (strRecommendedStreet != wxT(""))		{			wxMessageDialog dlgError(this, m_strErrorMsg, wxT("Error"), wxYES_NO | wxICON_ERROR);						if (dlgError.ShowModal() == wxID_YES)			{				m_strStreet = strRecommendedStreet;				TransferDataToWindow();				return MayClose(bRoadsOnly);			}			return false;		}		else if (strRecommendedCity != wxT(""))		{			wxMessageDialog dlgError(this, m_strErrorMsg, wxT("Error"), wxYES_NO | wxICON_ERROR);						if (dlgError.ShowModal() == wxID_YES)			{				m_strCity = strRecommendedCity;				TransferDataToWindow();				return MayClose(bRoadsOnly);			}			return false;		}		else if (strRecommendedState != wxT(""))		{			wxMessageDialog dlgError(this, m_strErrorMsg, wxT("Error"), wxYES_NO | wxICON_ERROR);						if (dlgError.ShowModal() == wxID_YES)			{				m_strState = strRecommendedState;				TransferDataToWindow();				return MayClose(bRoadsOnly);			}			return false;		}		wxMessageDialog dlgError(this, m_strErrorMsg, wxT("Error"), wxOK | wxICON_ERROR);		dlgError.ShowModal();		return false;	}	return true;	}void LocationPageAddress::UpdateAutoCompletionObjects(bool bRoadsOnly){	m_cAutoCompleteCity.SetState(m_ctlState->GetValue());	m_cAutoCompleteStreet.SetState(m_ctlState->GetValue());	m_cAutoCompleteStreet.SetCity(m_ctlCity->GetValue());	if (bRoadsOnly)		m_cAutoCompleteStreet.SetVisibility(OnlyRoadsVisibility());	else		m_cAutoCompleteStreet.SetVisibility(AllVisibility());}

⌨️ 快捷键说明

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