OpenCPN Partial API docs
Loading...
Searching...
No Matches
base_platform.h
1/***************************************************************************
2 *
3 * Project: OpenCPN
4 * Purpose: Basic platform specific support utilities without GUI deps.
5 * Author: David Register
6 *
7 ***************************************************************************
8 * Copyright (C) 2015 by David S. Register *
9 * *
10 * This program is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License as published by *
12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. *
14 * *
15 * This program is distributed in the hope that it will be useful, *
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
18 * GNU General Public License for more details. *
19 * *
20 * You should have received a copy of the GNU General Public License *
21 * along with this program; if not, write to the *
22 * Free Software Foundation, Inc., *
23 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
24 **************************************************************************/
25
26#ifndef BASEPLATFORM_H
27#define BASEPLATFORM_H
28
29#include <stdio.h>
30#include <vector>
31
32#include <wx/wxprec.h>
33
34#ifndef WX_PRECOMP
35#include <wx/wx.h>
36#endif // precompiled headers
37
38#include <wx/gdicmn.h>
39#include <wx/log.h>
40#include <wx/stdpaths.h>
41#include <wx/clrpicker.h>
42#include <wx/colourdata.h>
43#include <wx/colordlg.h>
44
45#define PLATFORM_CAP_PLUGINS 1
46#define PLATFORM_CAP_FASTPAN 2
47
48class BasePlatform; // forward
49
51extern BasePlatform* g_BasePlatform;
52
53typedef struct {
54 char tsdk[20];
55 char hn[20];
56 char msdk[20];
57} PlatSpec;
58
59void appendOSDirSlash(wxString* path);
60
62 OCPN_OSDetail() {};
63 ~OCPN_OSDetail() {};
64
65 std::string osd_name;
66 std::string osd_version;
67 std::vector<std::string> osd_names_like;
68 std::string osd_arch;
69 std::string osd_ID;
70};
71
73public:
74 AbstractPlatform() = default;
75 virtual ~AbstractPlatform() = default;
76
78 wxString& GetPrivateDataDir();
79
81 wxString& DefaultPrivateDataDir();
82
83 wxString* GetPluginDirPtr();
84 wxString* GetSharedDataDirPtr();
85
87 wxString* GetPrivateDataDirPtr();
88
90 wxString& GetPluginDir();
91
92 wxStandardPaths& GetStdPaths();
93
98 wxString GetWinPluginBaseDir();
99
100 wxString& GetSharedDataDir();
101 wxString& GetExePath();
102 wxString& GetHomeDir();
103 wxString GetWritableDocumentsDir();
104
113 wxString GetPluginDataPath();
114
115 wxString& GetConfigFileName();
116 wxString& GetLogFileName() { return mlog_file; }
117
118 bool isFlatpacked() { return m_isFlatpacked; }
119
120 bool isPlatformCapable(int flag);
121 OCPN_OSDetail* GetOSDetail() { return m_osDetail; }
122
123 void CloseLogFile(void);
124 virtual bool InitializeLogFile(void) = 0;
125 wxString& GetLargeLogMessage(void) { return large_log_message; }
126 FILE* GetLogFilePtr() { return flog; }
127
128 wxString NormalizePath(const wxString& full_path);
129
130 virtual wxSize getDisplaySize() { return wxSize(); }
131 virtual double GetDisplaySizeMM() { return 1.0; }
132 virtual double GetDisplayDPmm() { return 1.0; }
133 virtual unsigned int GetSelectRadiusPix();
134
141 double GetDisplayDIPMult(wxWindow* win);
142
143 static void ShowBusySpinner();
144 static void HideBusySpinner();
145
146protected:
147 bool DetectOSDetail(OCPN_OSDetail* detail);
148
149 wxString m_default_private_datadir;
150 wxString m_PrivateDataDir;
151 wxString m_PluginsDir;
152 bool m_isFlatpacked;
153 wxString m_homeDir;
154 wxString m_exePath;
155 wxString m_SData_Dir;
156 wxString m_config_file_name;
157 wxString m_pluginDataPath;
158 wxString mlog_file;
159
160 OCPN_OSDetail* m_osDetail;
161
162 FILE* flog;
163 wxLog* m_old_logger;
164 wxString large_log_message;
165
166 std::vector<int> m_displaySizeMMOverride;
167
168#ifdef _MSC_VER
169 bool GetWindowsMonitorSize(int* width, int* height);
170#endif
171 int m_monitorWidth, m_monitorHeight;
172 bool m_bdisableWindowsDisplayEnum;
173 static bool m_isBusy;
174};
175
177public:
178 BasePlatform();
180
181 bool InitializeLogFile() override;
182
183 wxSize getDisplaySize() override;
184 double GetDisplaySizeMM() override;
185 double GetDisplayDPmm() override;
186};
187
188#endif // BASEPLATFORM_H
wxString * GetPrivateDataDirPtr()
Legacy compatibility syntactic sugar for GetPrivateDataDir().
wxString & GetPluginDir()
The original in-tree plugin directory, sometimes not user-writable.
wxString GetWinPluginBaseDir()
Base directory for user writable windows plugins, reflects winPluginDir option, defaults to LOCALAPPD...
wxString & DefaultPrivateDataDir()
Return dir path for opencpn.log, etc., does not respect -c option.
double GetDisplayDIPMult(wxWindow *win)
Get the display scaling factor for DPI-aware rendering.
wxString GetPluginDataPath()
Return ';'-separated list of base directories for plugin data.
wxString & GetPrivateDataDir()
Return dir path for opencpn.log, etc., respecting -c cli option.