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
94
95 wxStandardPaths& GetStdPaths();
96
101 wxString GetWinPluginBaseDir();
102
103 wxString& GetSharedDataDir();
104 wxString& GetExePath();
105 wxString& GetHomeDir();
106 wxString GetWritableDocumentsDir();
107
116 wxString GetPluginDataPath();
117
118 wxString& GetConfigFileName();
119 wxString& GetLogFileName() { return mlog_file; }
120
121 bool isFlatpacked() { return m_isFlatpacked; }
122
123 bool isPlatformCapable(int flag);
124 OCPN_OSDetail* GetOSDetail() { return m_osDetail; }
125
126 void CloseLogFile(void);
127 virtual bool InitializeLogFile(void) = 0;
128 wxString& GetLargeLogMessage(void) { return large_log_message; }
129 FILE* GetLogFilePtr() { return flog; }
130
131 wxString NormalizePath(const wxString& full_path);
132
133 virtual wxSize getDisplaySize() { return wxSize(); }
134 virtual double GetDisplaySizeMM() { return 1.0; }
135 virtual double GetDisplayDPmm() { return 1.0; }
136 virtual unsigned int GetSelectRadiusPix();
137
144 double GetDisplayDIPMult(wxWindow* win);
145
150 virtual int GetSvgStdIconSize(const wxWindow* w, bool touch) = 0;
151
152 static void ShowBusySpinner();
153 static void HideBusySpinner();
154
155protected:
156 bool DetectOSDetail(OCPN_OSDetail* detail);
157
158 wxString m_default_private_datadir;
159 wxString m_PrivateDataDir;
160 wxString m_PluginsDir;
161 bool m_isFlatpacked;
162 wxString m_homeDir;
163 wxString m_exePath;
164 wxString m_SData_Dir;
165 wxString m_config_file_name;
166 wxString m_pluginDataPath;
167 wxString mlog_file;
168
169 OCPN_OSDetail* m_osDetail;
170
171 FILE* flog;
172 wxLog* m_old_logger;
173 wxString large_log_message;
174
175 std::vector<int> m_displaySizeMMOverride;
176
177#ifdef _MSC_VER
178 bool GetWindowsMonitorSize(int* width, int* height);
179#endif
180 int m_monitorWidth, m_monitorHeight;
181 bool m_bdisableWindowsDisplayEnum;
182 static bool m_isBusy;
183};
184
186public:
187 BasePlatform();
189
190 bool InitializeLogFile() override;
191
192 wxSize getDisplaySize() override;
193 double GetDisplaySizeMM() override;
194 double GetDisplayDPmm() override;
195 int GetSvgStdIconSize(const wxWindow* w, bool touch) override;
196};
197
198#endif // BASEPLATFORM_H
wxString * GetPrivateDataDirPtr()
Legacy compatibility syntactic sugar for GetPrivateDataDir().
virtual int GetSvgStdIconSize(const wxWindow *w, bool touch)=0
Return icon size roughly corresponding to height of a char in w, tweaked to be "big enough" for touch...
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.
wxString GetSupplementalLicenseString()
Android license details, otherwise "".
int GetSvgStdIconSize(const wxWindow *w, bool touch) override
Return icon size roughly corresponding to height of a char in w, tweaked to be "big enough" for touch...