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

📄 frame.cpp

📁 Powerful and Portable GPS application -- support Linux, Windows, Windows CE GPS navigation and Map m
💻 CPP
📖 第 1 页 / 共 5 页
字号:
	m_menuView->Check(idViewGPSWindow, g_pConfig->Read(wxT("GPSWindowVisible"), (long int) 0));	m_menuView->AppendCheckItem(idViewWhatsNearByWindow, wxT("What's Nearby Window"));	m_menuView->Check(idViewWhatsNearByWindow, g_pConfig->Read(wxT("WhatsNearByWindowVisible"), (long int) 0));	m_menuView->AppendSeparator();	m_menuView->Append(idViewZoomIn, wxT("Zoom &In\t+"));	m_menuView->Append(idViewZoomOut, wxT("Zoom &Out\t-"));	m_menuView->Append(idViewZoomMax, wxT("Zoom Max"));	m_menuView->Append(idViewZoomMin, wxT("Zoom Min"));#if defined(__DARWIN__)	m_menuView->AppendCheckItem(idViewFullScreen, wxT("&Full Screen\tCtrl-Shift-F"));#else	m_menuView->AppendCheckItem(idViewFullScreen, wxT("&Full Screen\tF11"));#endif	m_menuView->Check(idViewFullScreen, FALSE);	//////////////////////////////////////////////////////////////////////////////	// Map Menu	//////////////////////////////////////////////////////////////////////////////	m_menuMap = new wxMenu;	m_menuMap->Append(idMapSetAddress, wxT("Set &Address...\tCtrl-A"));	m_menuMap->Append(idMapWaypoints, wxT("&Waypoints..."));	m_menuMap->Append(idMapSetAngle, wxT("Set Map Orientation..."));	m_menuMap->AppendCheckItem(idMapGetDirections, wxT("Get &Directions...\tCtrl-D"));	m_menuMap->Check(idMapGetDirections, (long int) 0);	//////////////////////////////////////////////////////////////////////////////	// Tools Menu	//////////////////////////////////////////////////////////////////////////////	wxMenu * menuTools = new wxMenu;	menuTools->AppendCheckItem(idToolsMeasure, wxT("Measure"));	menuTools->AppendCheckItem(idToolsZoom, wxT("Zoom"));	menuTools->AppendSeparator();	menuTools->Append(idToolsDownloadMaps, wxT("Download TIGER/Line &Maps (US)..."));#ifdef USE_OPENSTREETMAP	menuTools->Append(idToolsDownloadOSMMaps, wxT("Download &OpenStreetMap Maps (non-US)..."));	menuTools->Append(idToolsImportOSMMaps, wxT("Import O&penStreetMap XML Maps (non-US)..."));#endif	menuTools->Append(wxID_PREFERENCES, wxT("&Preferences..."));	//////////////////////////////////////////////////////////////////////////////	// Help Menu	//////////////////////////////////////////////////////////////////////////////	wxMenu * menuHelp = new wxMenu;	menuHelp->Append(wxID_ABOUT, wxT("&About..."));	//////////////////////////////////////////////////////////////////////////////	// Menu Bar	//////////////////////////////////////////////////////////////////////////////	wxMenuBar * mbMenu = new wxMenuBar(wxMB_DOCKABLE);	mbMenu->Append(menuFile, wxT("&File"));	mbMenu->Append(m_menuView, wxT("&View"));	mbMenu->Append(m_menuMap, wxT("&Map"));	mbMenu->Append(menuTools, wxT("&Tools"));	mbMenu->Append(menuHelp, wxT("&Help"));	SetMenuBar(mbMenu);	//////////////////////////////////////////////////////////////////////////	// Accelerators	//////////////////////////////////////////////////////////////////////////	wxAcceleratorEntry entries[15];	entries[0].Set(wxACCEL_NORMAL,	(int) wxT('+'),	idViewZoomIn);	entries[1].Set(wxACCEL_NORMAL,	(int) wxT('='),	idViewZoomIn);	entries[2].Set(wxACCEL_SHIFT,	(int) wxT('='),	idViewZoomIn);	entries[3].Set(wxACCEL_NORMAL,	(int) wxT('-'),	idViewZoomOut);	entries[4].Set(wxACCEL_NORMAL,	WXK_UP,		idMapMoveCenterUp);	entries[5].Set(wxACCEL_NORMAL,	WXK_DOWN,	idMapMoveCenterDown);	entries[6].Set(wxACCEL_NORMAL,	WXK_LEFT,	idMapMoveCenterLeft);	entries[7].Set(wxACCEL_NORMAL,	WXK_RIGHT,	idMapMoveCenterRight);#if defined(__DARWIN__)	entries[8].Set(wxACCEL_CTRL | wxACCEL_SHIFT,	(int) wxT('F'),	idViewFullScreen);#else	entries[8].Set(wxACCEL_NORMAL,	WXK_F11,	idViewFullScreen);#endif	entries[9].Set(wxACCEL_CTRL,	(int) wxT('A'),	idMapSetAddress);	entries[10].Set(wxACCEL_CTRL,	(int) wxT('D'),	idMapGetDirectionsAccel);	entries[11].Set(wxACCEL_CTRL,	(int) wxT('S'),	idFileSaveAs);	entries[12].Set(wxACCEL_CTRL,	(int) wxT('P'),	idFilePrint);	entries[13].Set(wxACCEL_CTRL, 	(int) wxT('T'),	idSolarTimerTest);	entries[14].Set(wxACCEL_NORMAL,	WXK_ESCAPE,	idEscape);	wxAcceleratorTable accel(sizeof(entries)/sizeof(wxAcceleratorEntry), entries);	SetAcceleratorTable(accel);		//////////////////////////////////////////////////////////////////////////	// Status Bar	//////////////////////////////////////////////////////////////////////////	CreateStatusBar(3);		//////////////////////////////////////////////////////////////////////////	// Create the GPS status miniframe	//////////////////////////////////////////////////////////////////////////	m_pfrmGPS = new GPSFrame(this);		//////////////////////////////////////////////////////////////////////////	// Create the directions miniframe	//////////////////////////////////////////////////////////////////////////	m_pfrmDirections = new DirectionsFrame(this);		//////////////////////////////////////////////////////////////////////////////	// Read config settings and apply them	//////////////////////////////////////////////////////////////////////////////	int iMarkerCount;	int iMarker;		m_ctlMap->ClearMarkers();	g_pConfig->Read(wxT("MarkerCount"), &iMarkerCount, 0);	for (iMarker = 0; iMarker < iMarkerCount; iMarker++)	{		wxString strMarker;		MapMarker cMarker;		g_pConfig->Read(wxString::Format(wxT("Marker%d"), iMarker), &strMarker, wxT(""));				cMarker.FromString(strMarker);				m_ctlMap->SetMarker(cMarker);	}		m_ctlMap->ClearMarker(wxT("GPS Position"));	m_ctlMap->ClearMarker(wxT("Starting Address"));	m_ctlMap->ClearMarker(wxT("Ending Address"));		double fCenterLong;	double fCenterLat;	g_pConfig->Read(wxT("CenterLong"), &fCenterLong, -82);	g_pConfig->Read(wxT("CenterLat"), &fCenterLat, 40);	m_ctlMap->SetCenterCoordinates(Point(fCenterLong, fCenterLat));	double fMapAngle;	g_pConfig->Read(wxT("MapAngle"), &fMapAngle, 0);	m_ctlMap->SetAngle(fMapAngle);	int iDetailLevel;	g_pConfig->Read(wxT("DetailLevel"), &iDetailLevel, 1);	m_ctlMap->SetDetailLevel(iDetailLevel);		for (iDetailLevel = 0; iDetailLevel <= LAST_RECORD_TYPE; iDetailLevel++)		m_ariRoadTypeZoomingDetailLevels[iDetailLevel] = g_pConfig->Read(wxString::Format(wxT("RoadTypeZoomingDetailLevels%d"), iDetailLevel), -1);		//////////////////////////////////////////////////////////////////////////////	// Restore the previous size and position of this frame	//////////////////////////////////////////////////////////////////////////////	RestoreWindowPosition(g_pConfig, this, wxT("Window"));	//////////////////////////////////////////////////////////////////////////////	// Restore the previous size and position of the GPS window	//////////////////////////////////////////////////////////////////////////////	RestoreWindowPosition(g_pConfig, m_pfrmGPS, wxT("GPSWindow"));	//////////////////////////////////////////////////////////////////////////////	// Restore the previous size and position of the directions window	//////////////////////////////////////////////////////////////////////////////	RestoreWindowPosition(g_pConfig, m_pfrmDirections, wxT("DirectionsWindow"));	//////////////////////////////////////////////////////////////////////////////	// Restore the previous size and position of the what's nearby window	//////////////////////////////////////////////////////////////////////////////	RestoreWindowPosition(g_pConfig, m_pfrmWhatsNearBy, wxT("WhatsNearByWindow"));	//////////////////////////////////////////////////////////////////////////////	// Maximize if it was maximized before	//////////////////////////////////////////////////////////////////////////////	int iIsMaximized;	g_pConfig->Read(wxT("IsMaximized"), &iIsMaximized, 1);	if (iIsMaximized)		Maximize();	//////////////////////////////////////////////////////////////////////////////	// Sync map control to menu state	//////////////////////////////////////////////////////////////////////////////	if (m_menuView->IsChecked(idViewGPSWindow))		m_pfrmGPS->Show();	else		m_pfrmGPS->Hide();		if (m_menuView->IsChecked(idViewWhatsNearByWindow))		m_pfrmWhatsNearBy->Show();	else		m_pfrmWhatsNearBy->Hide();		m_ctlMap->ShowCompass(m_menuView->IsChecked(idViewCompass));	m_ctlMap->ShowScale(m_menuView->IsChecked(idViewScale));	m_ctlMap->ShowAerialPhotos(m_menuView->IsChecked(idViewAerialPhotos), g_pConfig->Read(wxT("AutoDownloadMaps"), (int) 1));	m_ctlMap->Enable3DMode(m_menuView->IsChecked(idView3DMode));	//////////////////////////////////////////////////////////////////////////////	// Initialize scripting	//////////////////////////////////////////////////////////////////////////////#ifdef USE_SCRIPTING	m_pScripting = new Scripting(this, m_ctlMap);		if (g_pConfig->Read(wxT("ScriptingStartupScriptEnabled"), (long) 0))	{		// run script		m_pScripting->RunFromFile(g_pConfig->Read(wxT("ScriptingStartupScriptFilename"), wxT("")));				// erase script if erase option enabled		if (g_pConfig->Read(wxT("ScriptingStartupScriptErase"), (long) 0))			wxRemoveFile(g_pConfig->Read(wxT("ScriptingStartupScriptFilename"), wxT("")));	}		m_ptmrScripting = new wxTimer(this, TIMER_SCRIPTING);	m_ptmrScripting->Start(500, false);#endif	//////////////////////////////////////////////////////////////////////////////	// Load up the theme definitions	//////////////////////////////////////////////////////////////////////////////	m_ThemeManager.Load(g_pConfig);	//////////////////////////////////////////////////////////////////////////	// Start up the helper threads	//////////////////////////////////////////////////////////////////////////		m_GPSMonitorThread = new GPSMonitorThread(this);	m_GPSMonitorThread->Create();	m_DownloadThread = new DownloadThread(this, idRefreshMapControl);	m_DownloadThread->Create();	m_DownloadThread->Run();		m_ptmrInit = new wxTimer(this, TIMER_INIT);	m_ptmrInit->Start(1, true);	m_ptmrConfigFlush = new wxTimer(this, TIMER_CONFIGFLUSH);	m_ptmrConfigFlush->Start(60 * 1000, false);}//////////////////////////////////////////////////////////////////////////////////// \brief Periodically flush all settings to disk./////////////////////////////////////////////////////////////////////////////////void MapFrame::OnTimerConfigFlush(wxTimerEvent& event){	if (g_pConfig->Read(wxT("MarkerCount"), (long) 0) != m_ctlMap->GetMarkerCount())		SaveMarkers();	g_pConfig->Flush();}//////////////////////////////////////////////////////////////////////////////////// \brief Initialization function called 1ms after MapFrame is created.////// This function just calls MapInit after MapFrame has finished/// initializing. It can't be called earlier due to some wxMSW sockets /// glitches that occasionally cause a hang in wxURL when wxURL is used/// before a wxFrame is fully initialized./////////////////////////////////////////////////////////////////////////////////void MapFrame::OnTimerInit(wxTimerEvent& event){	wxCommandEvent ev;		MapInit();	ApplyPreferences();			LCDprocInit();	OnMapRecentered(ev);	m_GPSMonitorThread->Run();}#ifdef USE_SCRIPTING//////////////////////////////////////////////////////////////////////////////////// \brief 0.5 second timer function that pumps the scripting engine./////////////////////////////////////////////////////////////////////////////////void MapFrame::OnTimerScripting(wxTimerEvent& event){	m_pScripting->Pump();}#endif//////////////////////////////////////////////////////////////////////////////////// \brief MapFrame destructor/////////////////////////////////////////////////////////////////////////////////MapFrame::~MapFrame(){	m_ThemeManager.Save(g_pConfig);	delete m_ptmrInit;	delete m_ptmrConfigFlush;}//////////////////////////////////////////////////////////////////////////////////// \brief Determine whether the mouse is in measure, zoom, or neither mode/////////////////////////////////////////////////////////////////////////////////EToolMode MapFrame::GetToolMode() const{   return m_ToolMode;}//////////////////////////////////////////////////////////////////////////////////// \brief Put the mouse into measure, zoom, or neither mode/////////////////////////////////////////////////////////////////////////////////void MapFrame::SetToolMode(EToolMode mode){   m_ToolMode = mode;}//////////////////////////////////////////////////////////////////////////////////// \brief Provides access to the MapControlData object/////////////////////////////////////////////////////////////////////////////////IMapControlData& MapFrame::GetMapControlData(){	return m_cRecords;}//////////////////////////////////////////////////////////////////////////////////// \brief Provides access the MapAppearanceSettings object/////////////////////////////////////////////////////////////////////////////////MapAppearanceSettings& MapFrame::GetMapAppearanceSettings(){	return m_MapAppearanceSettings;}//////////////////////////////////////////////////////////////////////////////////// \brief Idle handler - update the status bar as necessary/////////////////////////////////////////////////////////////////////////////////void MapFrame::OnIdle(wxIdleEvent & event){	if (!IsShown())		return;			wxString strOldText;	wxString strNewText;	strOldText = GetStatusBar()->GetStatusText(2);	strNewText = wxString::Format(wxT("Detail Level: %d"), m_ctlMap->GetDetailLevel());	if (strOldText != strNewText)		SetStatusText(strNewText, 2);		{		bool bNewGPSData = false;		wxGPSEvent evGPS;				if (m_bGPSJustRun)		{			m_mtxGPS.Lock();			m_bNewGPSData = false;			m_bGPSJustRun = false;			m_mtxGPS.Unlock();		}				m_mtxGPS.Lock();		bNewGPSData = m_bNewGPSData;		evGPS = m_evGPS;		m_mtxGPS.Unlock();				if (bNewGPSData)		{			OnGPSUpdateIdle(evGPS);						m_mtxGPS.Lock();			m_bNewGPSData = false;			m_bGPSJustRun = true;			m_mtxGPS.Unlock();						event.RequestMore();		}	}}//////////////////////////////////////////////////////////////////////////////////// \brief EVT_SOLAR handler - handle transition to daytime/nighttime/////////////////////////////////////////////////////////////////////////////////void MapFrame::OnSolarEvent(SolarEvent& event){	UpdateTheme();	m_ctlMap->MapUpdated(UPDATED_THEME);}//////////////////////////////////////////////////////////////////////////////////// \brief Select the appropriate theme for the current time/////////////////////////////////////////////////////////////////////////////////void MapFrame::UpdateTheme()

⌨️ 快捷键说明

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