OpenCPN Partial API docs
Loading...
Searching...
No Matches
ocpn_platform.h
Go to the documentation of this file.
1/**************************************************************************
2 * Copyright (C) 2015 by David S. Register *
3 * *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
8 * *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
13 * *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, see <https://www.gnu.org/licenses/>. *
16 **************************************************************************/
17
24#ifndef OCPNPLATFORM_H
25#define OCPNPLATFORM_H
26
27#include <cstdio>
28#include <string>
29#include <vector>
30
31#ifndef __WXMSW__
32#include <signal.h>
33#include <setjmp.h>
34#endif
35
36// if wxWidgets headers have not been included, include them now
37#ifndef _WX_DEFS_H_
38#include <wx/wxprec.h>
39
40#ifndef WX_PRECOMP
41#include <wx/wx.h>
42#endif // precompiled headers
43
44#endif // _WX_DEFS_H_
45
46#include <wx/bmpbuttn.h>
47#include <wx/clrpicker.h>
48#include <wx/colordlg.h>
49#include <wx/colour.h>
50#include <wx/colourdata.h>
51#include <wx/dirdlg.h>
52#include <wx/filedlg.h>
53#include <wx/gdicmn.h>
54#include <wx/stdpaths.h>
55#include <wx/string.h>
56#include <wx/validate.h>
57#include <wx/window.h>
58
59#include "model/base_platform.h"
60#include "chartdbs.h"
61#include "navutil.h"
62
63#ifdef ocpnUSE_GL
64#include "gl_chart_canvas.h"
65#endif
66
67class OCPNPlatform; // forward
70class MyConfig; // Circular
71
72#ifndef __WXMSW__
73extern sigjmp_buf env; // global instance
74extern struct sigaction sa_all_old; // global instance
75#endif
76
77extern wxArrayString g_locale_catalog_array;
79#ifdef ocpnUSE_GL
80extern OCPN_GLCaps *GL_Caps;
81#endif
82
83constexpr int kGpsTimeoutSeconds = 10;
84
85void catch_signals(int signo);
86
87//--------------------------------------------------------------------------
88// Per-Platform Utility support
89//--------------------------------------------------------------------------
90
97class OCPNPlatform : public BasePlatform {
98public:
100 virtual ~OCPNPlatform();
101
102 // Internal Device Support
103 static bool hasInternalGPS(wxString profile = ""); // GPS
104
105 static bool hasInternalBT(wxString profile = ""); // Bluetooth
106 bool startBluetoothScan();
107 wxArrayString getBluetoothScanResults();
108 bool stopBluetoothScan();
109
110 // Per-Platform initialization support
111
112 // Called from MyApp() immediately upon entry to MyApp::OnInit()
113 static void Initialize_1(void);
114
115 // Called from MyApp() immediately before creation of MyFrame()
116 void Initialize_2(void);
117
118 // Called from MyApp()::OnInit() just after gFrame is created, so gFrame is
119 // available
120 void Initialize_3(void);
121
122 // Called from MyApp() just before end of MyApp::OnInit()
123 static void Initialize_4(void);
124
125 static void OnExit_1(void);
126 static void OnExit_2(void);
127
128 void SetDefaultOptions(void);
129 void SetUpgradeOptions(wxString vString, wxString vStringConfig);
130
131 void applyExpertMode(bool mode);
132
133 //--------------------------------------------------------------------------
134 // Platform Display Support
135 //--------------------------------------------------------------------------
136 virtual void ShowBusySpinner(void);
137 virtual void HideBusySpinner(void);
138 double getFontPointsperPixel(void);
152 wxSize getDisplaySize();
156 double GetDisplaySizeMM();
157 double GetDisplayAreaCM2();
158 virtual double GetDisplayDPmm();
159
163 void SetDisplaySizeMM(size_t monitor, double size);
164 unsigned int GetSelectRadiusPix();
165 double GetToolbarScaleFactor(int GUIScaleFactor);
166 double GetCompassScaleFactor(int GUIScaleFactor);
167
168 wxFileDialog *AdjustFileDialogFont(wxWindow *container, wxFileDialog *dlg);
169 wxDirDialog *AdjustDirDialogFont(wxWindow *container, wxDirDialog *dlg);
170
171 void PositionAISAlert(wxWindow *alert_window);
172 float GetChartScaleFactorExp(float scale_linear);
173 float GetMarkScaleFactorExp(float scale_linear);
174 // float GetDIPScaleFactor();
175 int GetStatusBarFieldCount();
176 bool GetFullscreen();
177 bool SetFullscreen(bool bFull);
178 bool AllowAlertDialog(const wxString &class_name);
179 double GetDisplayDensityFactor();
180 double m_pt_per_pixel;
181 long GetDefaultToolbarOrientation();
182
183 //--------------------------------------------------------------------------
184 // Per-Platform file/directory support
185 //--------------------------------------------------------------------------
186
187 MyConfig *GetConfigObject();
188
189 int DoFileSelectorDialog(wxWindow *parent, wxString *file_spec,
190 wxString Title, wxString initDir,
191 wxString suggestedName, wxString wildcard);
192 int DoDirSelectorDialog(wxWindow *parent, wxString *file_spec, wxString Title,
193 wxString initDir, bool b_addFiles = true);
194
195 //--------------------------------------------------------------------------
196 // Per-Platform Utility support
197 //--------------------------------------------------------------------------
198 void setChartTypeMaskSel(int mask, wxString &indicator);
199 bool isPlatformCapable(int flag);
200
201 int platformApplyPrivateSettingsString(wxString settings,
202 ArrayOfCDI *pDirArray);
203 void platformLaunchDefaultBrowser(wxString URL);
204
205 void SetLocaleSearchPrefixes(void);
206 wxString GetDefaultSystemLocale();
207
208#if wxUSE_XLOCALE
209 wxString GetAdjustedAppLocale();
210 wxString ChangeLocale(wxString &newLocaleID, wxLocale *presentLocale,
211 wxLocale **newLocale);
212#endif
213
214 //--------------------------------------------------------------------------
215 // Per-Platform OpenGL support
216 //--------------------------------------------------------------------------
217 bool BuildGLCaps(void *pbuf);
218 bool IsGLCapable();
219
220private:
221 wxString m_SData_Dir;
222};
223
224// Private colourPicker control
225//--------------------------------------------------------------------------
226
227class OCPNColourPickerCtrl : public wxBitmapButton {
228public:
230 OCPNColourPickerCtrl(wxWindow *parent, wxWindowID id,
231 const wxColour &initial = *wxBLACK,
232 const wxPoint &pos = wxDefaultPosition,
233 const wxSize &size = wxDefaultSize, long style = 0,
234 const wxValidator &validator = wxDefaultValidator,
235 const wxString &name = "");
236
237 bool Create(wxWindow *parent, wxWindowID id,
238 const wxColour &initial = *wxBLACK,
239 const wxPoint &pos = wxDefaultPosition,
240 const wxSize &size = wxDefaultSize, long style = 0,
241 const wxValidator &validator = wxDefaultValidator,
242 const wxString &name = "");
243
244 void OnButtonClick(wxCommandEvent &WXUNUSED(ev));
245 void InitColourData();
246 void SetColour(wxColour &c);
247 wxColour GetColour(void);
248
249protected:
250 virtual void UpdateColour();
251 wxSize DoGetBestSize() const;
252
253 void OnPaint(wxPaintEvent &event);
254
255 DECLARE_EVENT_TABLE();
256
257private:
258 wxBitmap m_bitmap;
259 wxColour m_colour;
260 wxColourData ms_data;
261};
262
263#endif // guard
Basic platform specific support utilities without GUI deps.
Basic chart info storage.
Provides platform-specific support utilities for OpenCPN.
void SetDisplaySizeMM(size_t monitor, double size)
Set the width of the monitor in millimeters.
wxSize getDisplaySize()
Get the display size in logical pixels.
double GetDisplaySizeMM()
Get the width of the screen in millimeters.
OpenGL chart rendering canvas.
Utility functions.
constexpr int kGpsTimeoutSeconds
Default GPS timeout.
OCPNPlatform * g_Platform
Global instance.
wxArrayString g_locale_catalog_array
Global instance.