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
63class OCPNPlatform; // forward
66class MyConfig; // Circular
67
68#ifndef __WXMSW__
69extern sigjmp_buf env; // global instance
70extern struct sigaction sa_all_old; // global instance
71#endif
72
73extern wxArrayString g_locale_catalog_array;
75void catch_signals(int signo);
76
77//--------------------------------------------------------------------------
78// Per-Platform Utility support
79//--------------------------------------------------------------------------
80
87class OCPNPlatform : public BasePlatform {
88public:
90 virtual ~OCPNPlatform();
91
92 // Internal Device Support
93 static bool hasInternalGPS(wxString profile = ""); // GPS
94
95 static bool hasInternalBT(wxString profile = ""); // Bluetooth
96 bool startBluetoothScan();
97 wxArrayString getBluetoothScanResults();
98 bool stopBluetoothScan();
99
100 // Per-Platform initialization support
101
102 // Called from MyApp() immediately upon entry to MyApp::OnInit()
103 static void Initialize_1(void);
104
105 // Called from MyApp() immediately before creation of MyFrame()
106 void Initialize_2(void);
107
108 // Called from MyApp()::OnInit() just after gFrame is created, so gFrame is
109 // available
110 void Initialize_3(void);
111
112 // Called from MyApp() just before end of MyApp::OnInit()
113 static void Initialize_4(void);
114
115 static void OnExit_1(void);
116 static void OnExit_2(void);
117
118 void SetDefaultOptions(void);
119 void SetUpgradeOptions(wxString vString, wxString vStringConfig);
120
121 void applyExpertMode(bool mode);
122
123 //--------------------------------------------------------------------------
124 // Platform Display Support
125 //--------------------------------------------------------------------------
126 virtual void ShowBusySpinner(void);
127 virtual void HideBusySpinner(void);
128 double getFontPointsperPixel(void);
142 wxSize getDisplaySize();
146 double GetDisplaySizeMM();
147 double GetDisplayAreaCM2();
148 virtual double GetDisplayDPmm();
149
153 void SetDisplaySizeMM(size_t monitor, double size);
154 unsigned int GetSelectRadiusPix();
155 double GetToolbarScaleFactor(int GUIScaleFactor);
156 double GetCompassScaleFactor(int GUIScaleFactor);
157
158 wxFileDialog *AdjustFileDialogFont(wxWindow *container, wxFileDialog *dlg);
159 wxDirDialog *AdjustDirDialogFont(wxWindow *container, wxDirDialog *dlg);
160
161 void PositionAISAlert(wxWindow *alert_window);
162 float GetChartScaleFactorExp(float scale_linear);
163 float GetMarkScaleFactorExp(float scale_linear);
164 // float GetDIPScaleFactor();
165 int GetStatusBarFieldCount();
166 bool GetFullscreen();
167 bool SetFullscreen(bool bFull);
168 bool AllowAlertDialog(const wxString &class_name);
169 double GetDisplayDensityFactor();
170 double m_pt_per_pixel;
171 long GetDefaultToolbarOrientation();
172
173 //--------------------------------------------------------------------------
174 // Per-Platform file/directory support
175 //--------------------------------------------------------------------------
176
177 MyConfig *GetConfigObject();
178
179 int DoFileSelectorDialog(wxWindow *parent, wxString *file_spec,
180 wxString Title, wxString initDir,
181 wxString suggestedName, wxString wildcard);
182 int DoDirSelectorDialog(wxWindow *parent, wxString *file_spec, wxString Title,
183 wxString initDir, bool b_addFiles = true);
184
185 //--------------------------------------------------------------------------
186 // Per-Platform Utility support
187 //--------------------------------------------------------------------------
188 void setChartTypeMaskSel(int mask, wxString &indicator);
189 bool isPlatformCapable(int flag);
190
191 int platformApplyPrivateSettingsString(wxString settings,
192 ArrayOfCDI *pDirArray);
193 void platformLaunchDefaultBrowser(wxString URL);
194
195 void SetLocaleSearchPrefixes(void);
196 wxString GetDefaultSystemLocale();
197
198#if wxUSE_XLOCALE
199 wxString GetAdjustedAppLocale();
200 wxString ChangeLocale(wxString &newLocaleID, wxLocale *presentLocale,
201 wxLocale **newLocale);
202#endif
203
204 //--------------------------------------------------------------------------
205 // Per-Platform OpenGL support
206 //--------------------------------------------------------------------------
207 bool BuildGLCaps(void *pbuf);
208 bool IsGLCapable();
209
210private:
211 wxString m_SData_Dir;
212};
213
214// Private colourPicker control
215//--------------------------------------------------------------------------
216
217class OCPNColourPickerCtrl : public wxBitmapButton {
218public:
220 OCPNColourPickerCtrl(wxWindow *parent, wxWindowID id,
221 const wxColour &initial = *wxBLACK,
222 const wxPoint &pos = wxDefaultPosition,
223 const wxSize &size = wxDefaultSize, long style = 0,
224 const wxValidator &validator = wxDefaultValidator,
225 const wxString &name = "");
226
227 bool Create(wxWindow *parent, wxWindowID id,
228 const wxColour &initial = *wxBLACK,
229 const wxPoint &pos = wxDefaultPosition,
230 const wxSize &size = wxDefaultSize, long style = 0,
231 const wxValidator &validator = wxDefaultValidator,
232 const wxString &name = "");
233
234 void OnButtonClick(wxCommandEvent &WXUNUSED(ev));
235 void InitColourData();
236 void SetColour(wxColour &c);
237 wxColour GetColour(void);
238
239protected:
240 virtual void UpdateColour();
241 wxSize DoGetBestSize() const;
242
243 void OnPaint(wxPaintEvent &event);
244
245 DECLARE_EVENT_TABLE();
246
247private:
248 wxBitmap m_bitmap;
249 wxColour m_colour;
250 wxColourData ms_data;
251};
252
253#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.
Utility functions.
OCPNPlatform * g_Platform
Global instance.
wxArrayString g_locale_catalog_array
Global instance.