📄 app.cpp
字号:
/* * Roadnav * App.cpp * * Copyright (c) 2004 - 2006 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////// Application code.////// Contains the entry point for the application.///////////////////////////////////////////////////////////////////////////////// #ifdef HAVE_CONFIG_H# include <config.h>#endif#ifdef _MSC_VER#pragma warning(disable: 4786)#endif#include <wx/wx.h>#include <wx/image.h>#include <wx/config.h>#include <wx/fs_zip.h>#include <wx/fs_inet.h>#include <wx/socket.h>#include <wx/stdpaths.h>#include "App.h"#include "Frame.h"#include "libroadnav/Map.h"#include "TTS.h"#include "libroadnav/URLs.h"#include "libroadnav/MapSupport.h"#include "Support.h"#include "libroadnav/DownloadFiles.h"#include "libroadnav/Debug.h"#include "splash.xpm"wxConfigBase * g_pConfig = NULL;IMPLEMENT_APP(MapApp)#if !LIBROADNAV_CHECK_VERSION(0, 16)#error Requires at least version 0.16 of LibRoadnav#endif#if !wxCHECK_VERSION(2, 6, 2)#error Requires at least version 2.6.2 of wxWidgets#endif///////////////////////////////////////////////////////////////////////////////// /// \brief Show the splash screen/////////////////////////////////////////////////////////////////////////////////void MapApp::ShowSplash(){ wxBitmap bmpSplash(splash_xpm); m_wndSplash = new wxSplashScreen( bmpSplash, wxSPLASH_CENTRE_ON_SCREEN | wxSPLASH_NO_TIMEOUT, 0, NULL, -1, wxDefaultPosition, wxDefaultSize, wxSIMPLE_BORDER | wxFRAME_NO_TASKBAR ); m_wndSplash->SetTitle(wxT(PACKAGE)); wxYield();}//////////////////////////////////////////////////////////////////////////////////// \brief Hide the splash screen/////////////////////////////////////////////////////////////////////////////////void MapApp::HideSplash(){ delete m_wndSplash;}//////////////////////////////////////////////////////////////////////////////////// \brief Initialization code/////////////////////////////////////////////////////////////////////////////////bool MapApp::OnInit(){ wxApp::OnInit(); //////////////////////////////////////////////////////////////// // For some reason, if a wxScreenDC is not instantiated, it's // not possible to focus the Roadnav window under OSX. //////////////////////////////////////////////////////////////// wxScreenDC dcScreen; //////////////////////////////////////////////////////////////// // Initialize stuff //////////////////////////////////////////////////////////////// wxInitAllImageHandlers(); wxFileSystem::AddHandler(new wxZipFSHandler); wxFileSystem::AddHandler(new wxInternetFSHandler); SetVendorName(wxT("")); SetAppName(wxT(PACKAGE)); g_pConfig = wxConfigBase::Get(); g_pConfig->SetRecordDefaults(); wxSocketBase::Initialize(); //////////////////////////////////////////////////////////////// // Splash screen on, if debug mode not used ////////////////////////////////////////////////////////////////#ifndef _DEBUG ShowSplash();#endif //////////////////////////////////////////////////////////////// // Set up configuration object //////////////////////////////////////////////////////////////// SetURLConfig(g_pConfig); //////////////////////////////////////////////////////////////// // Common data path //////////////////////////////////////////////////////////////// SetCommonDataPath(RoadnavCommonDirectory()); //////////////////////////////////////////////////////////////// // Local data path //////////////////////////////////////////////////////////////// wxFileName fnLocal; wxStandardPathsBase & p = wxStandardPaths::Get(); fnLocal.AssignDir(p.GetUserDataDir() + wxT("data")); if (!fnLocal.DirExists()) fnLocal.Mkdir(0755); fnLocal.AppendDir(wxT("compiled_maps")); SetLocalDataPath(fnLocal.GetFullPath()); ////////////////////////////////////////////////////////////////////////////// // Download cache directory ////////////////////////////////////////////////////////////////////////////// wxFileName fnCache; fnCache.AssignDir(p.GetUserDataDir() + wxT("data")); fnCache.AppendDir(wxT("http_cache")); SetDownloadCacheDirectory(fnCache.GetFullPath()); ////////////////////////////////////////////////////////////////////////////// // Proxy settings ////////////////////////////////////////////////////////////////////////////// long lPort = 0; SetProxyHost(g_pConfig->Read(wxT("ProxyHost"), wxT(""))); g_pConfig->Read(wxT("ProxyPort"), &lPort); SetProxyPort(lPort); TTSLoad(); //////////////////////////////////////////////////////////////// // Eliminate splash screen ////////////////////////////////////////////////////////////////#ifndef _DEBUG HideSplash();#endif //////////////////////////////////////////////////////////////// // Bring up the main window //////////////////////////////////////////////////////////////// MapFrame * pfMain = new MapFrame(wxT("Roadnav")); pfMain->Show(TRUE); SetTopWindow(pfMain); return TRUE; }void MapApp::OnInitCmdLine(wxCmdLineParser & parser){ wxApp::OnInitCmdLine(parser); #ifdef LIBROADNAV_DEBUG parser.AddSwitch(wxT("d"), wxT("debug"), wxT("Enable debugging"));#endif}bool MapApp::OnCmdLineParsed(wxCmdLineParser & parser){ bool bContinue = true; if (!wxApp::OnCmdLineParsed(parser)) bContinue = false; #ifdef LIBROADNAV_DEBUG if (parser.Found(wxT("d"))) LibRoadnavDebugEnable();#endif return bContinue;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -