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

📄 frame.cpp

📁 roadnav 内含一个基于wxWindows库的车载导航系统。编译后
💻 CPP
📖 第 1 页 / 共 5 页
字号:
	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);		//////////////////////////////////////////////////////////////////////////////	// 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));	m_ctlMap->Enable3DMode(m_menuView->IsChecked(idView3DMode));	//////////////////////////////////////////////////////////////////////////////	// Initialize scripting	//////////////////////////////////////////////////////////////////////////////#ifdef USE_SCRIPTING	m_pScripting = new Scripting(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);	ApplyPreferences();			m_pfrmDirections->SetFont(GetFont());		LCDprocInit();	//////////////////////////////////////////////////////////////////////////	// Start up the helper threads	//////////////////////////////////////////////////////////////////////////		m_GPSMonitorThread = new GPSMonitorThread(this);	m_GPSMonitorThread->Create();	m_GPSMonitorThread->Run();	m_DownloadThread = new DownloadThread(this, idRefreshMapControl);	m_DownloadThread->Create();	m_DownloadThread->Run();		m_ptmrInit = new wxTimer(this, TIMER_INIT);	m_ptmrInit->Start(1, true);}//////////////////////////////////////////////////////////////////////////////////// \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();		OnMapRecentered(ev);}#ifdef USE_SCRIPTINGvoid MapFrame::OnTimerScripting(wxTimerEvent& event){	m_pScripting->Pump();}#endif//////////////////////////////////////////////////////////////////////////////////// \brief MapFrame destructor/////////////////////////////////////////////////////////////////////////////////MapFrame::~MapFrame(){	m_ThemeManager.Save(g_pConfig);	delete m_ptmrInit;}//////////////////////////////////////////////////////////////////////////////////// \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;}void MapFrame::SetThemeManager(const ThemeManager& themeMgr){   m_ThemeManager = themeMgr;   if ( m_SolarTimer.IsDaytime() )   {      const MapAppearanceSettings & theme = m_ThemeManager.GetDayTheme();      m_MapAppearanceSettings = theme;   }   else   {      const MapAppearanceSettings & theme = m_ThemeManager.GetNightTheme();      m_MapAppearanceSettings = theme;   }}//////////////////////////////////////////////////////////////////////////////////// \brief Provides access to the theme manager/////////////////////////////////////////////////////////////////////////////////const ThemeManager& MapFrame::GetThemeManager() const{	return m_ThemeManager;}//////////////////////////////////////////////////////////////////////////////////// \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){	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();}//////////////////////////////////////////////////////////////////////////////////// \brief Select the appropriate theme for the current time/////////////////////////////////////////////////////////////////////////////////void MapFrame::UpdateTheme(){	bool bViewPhotos;	g_pConfig->Read(wxT("AerialPhotosVisible"), &bViewPhotos, false);	if ( bViewPhotos )	{		m_MapAppearanceSettings = m_ThemeManager.GetPhotoTheme();	}	else	{		switch( m_ThemeManager.GetThemeUsage() )		{			case ThemeManager::AutoSwap:				m_SolarTimer.Start();				if ( m_SolarTimer.IsDaytime() || !m_SolarTimer.Valid())					m_MapAppearanceSettings = m_ThemeManager.GetDayTheme();				else					m_MapAppearanceSettings = m_ThemeManager.GetNightTheme();				break;						case ThemeManager::Night:				m_SolarTimer.Stop();				m_MapAppearanceSettings = m_ThemeManager.GetNightTheme();				break;						case ThemeManager::Day:				m_SolarTimer.Stop();				m_MapAppearanceSettings = m_ThemeManager.GetDayTheme();				break;		}	}	//////////////////////////////////////////////////////////////////////////////	// Apply the skin	//////////////////////////////////////////////////////////////////////////////	wxString strSkinPath;	if (m_SolarTimer.IsDaytime())		g_pConfig->Read(wxT("SkinPath-Day"), &strSkinPath, wxT("Default-Day"));	else		g_pConfig->Read(wxT("SkinPath-Night"), &strSkinPath, wxT("Default-Night"));	bool bSkinLoaded = false;	if (strSkinPath != wxT(""))		bSkinLoaded = !LoadSkin(strSkinPath, true);	if (!bSkinLoaded)	{		LoadSkin(wxT("<?xml version=\"1.0\">\<roadnavskin>\	<layout>\		<control name=\"map\">\			<region>\				<topleft>\					<x/>\					<y/>\				</topleft>\				<bottomright>\					<x multiplier=\"1\"/>\					<y multiplier=\"1\"/>\				</bottomright>\			</region>\		</control>\	</layout>\</roadnavskin>"),			false);	}	m_pfrmGPS->SetFont(GetFont());	m_pfrmGPS->SetBackgroundStyle(wxBG_STYLE_COLOUR);		m_pfrmGPS->SetBackgroundColour(m_MapAppearanceSettings.GetMiscColor(MiscColorBackground));	m_pfrmGPS->SetForegroundColour(m_MapAppearanceSettings.GetMiscColor(MiscColorForeground));	m_pfrmGPS->SafeRefresh();	m_pfrmWhatsNearBy->SetFont(GetFont());	m_pfrmWhatsNearBy->SetBackgroundStyle(wxBG_STYLE_COLOUR);		m_pfrmWhatsNearBy->SetBackgroundColour(m_MapAppearanceSettings.GetMiscColor(MiscColorBackground));	m_pfrmWhatsNearBy->SetForegroundColour(m_MapAppearanceSettings.GetMiscColor(MiscColorForeground));}#if defined _WINDOWS/////////////////////////////////////////////////////////////////////////////////

⌨️ 快捷键说明

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