OpenCPN Partial API docs
Loading...
Searching...
No Matches
OCPNPlatform.h
1/***************************************************************************
2 *
3 * Project: OpenCPN
4 * Purpose: OpenCPN Platform specific support utilities
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 OCPNPLATFORM_H
27#define OCPNPLATFORM_H
28
29#include <cstdio>
30#include <string>
31#include <vector>
32
33// if wxWidgets headers have not been included, include them now
34#ifndef _WX_DEFS_H_
35#include <wx/wxprec.h>
36
37#ifndef WX_PRECOMP
38#include <wx/wx.h>
39#endif // precompiled headers
40
41#endif // _WX_DEFS_H_
42
43#include <wx/bmpbuttn.h>
44#include <wx/clrpicker.h>
45#include <wx/colordlg.h>
46#include <wx/colour.h>
47#include <wx/colourdata.h>
48#include <wx/dirdlg.h>
49#include <wx/filedlg.h>
50#include <wx/gdicmn.h>
51#include <wx/stdpaths.h>
52#include <wx/string.h>
53#include <wx/validate.h>
54#include <wx/window.h>
55
56#include "model/base_platform.h"
57
58class MyConfig;
59class ArrayOfCDI;
60
61//--------------------------------------------------------------------------
62// Per-Platform Utility support
63//--------------------------------------------------------------------------
64
65// #ifdef __WXQT__
66// extern bool LoadQtStyleSheet(wxString &sheet_file);
67// extern QString getQtStyleSheet( void );
68// #endif
69
76class OCPNPlatform : public BasePlatform {
77public:
79 virtual ~OCPNPlatform();
80
81 // Internal Device Support
82 static bool hasInternalGPS(wxString profile = _T("")); // GPS
83
84 static bool hasInternalBT(wxString profile = _T("")); // Bluetooth
85 bool startBluetoothScan();
86 wxArrayString getBluetoothScanResults();
87 bool stopBluetoothScan();
88
89 // Per-Platform initialization support
90
91 // Called from MyApp() immediately upon entry to MyApp::OnInit()
92 static void Initialize_1(void);
93
94 // Called from MyApp() immediately before creation of MyFrame()
95 void Initialize_2(void);
96
97 // Called from MyApp()::OnInit() just after gFrame is created, so gFrame is
98 // available
99 void Initialize_3(void);
100
101 // Called from MyApp() just before end of MyApp::OnInit()
102 static void Initialize_4(void);
103
104 static void OnExit_1(void);
105 static void OnExit_2(void);
106
107 void SetDefaultOptions(void);
108 void SetUpgradeOptions(wxString vString, wxString vStringConfig);
109
110 void applyExpertMode(bool mode);
111
112 //--------------------------------------------------------------------------
113 // Platform Display Support
114 //--------------------------------------------------------------------------
115 virtual void ShowBusySpinner(void);
116 virtual void HideBusySpinner(void);
117 double getFontPointsperPixel(void);
131 wxSize getDisplaySize();
135 double GetDisplaySizeMM();
136 double GetDisplayAreaCM2();
137 virtual double GetDisplayDPmm();
138
142 void SetDisplaySizeMM(size_t monitor, double size);
143 unsigned int GetSelectRadiusPix();
144 double GetToolbarScaleFactor(int GUIScaleFactor);
145 double GetCompassScaleFactor(int GUIScaleFactor);
146
147 wxFileDialog *AdjustFileDialogFont(wxWindow *container, wxFileDialog *dlg);
148 wxDirDialog *AdjustDirDialogFont(wxWindow *container, wxDirDialog *dlg);
149
150 void PositionAISAlert(wxWindow *alert_window);
151 float GetChartScaleFactorExp(float scale_linear);
152 float GetMarkScaleFactorExp(float scale_linear);
153 // float GetDIPScaleFactor();
154 int GetStatusBarFieldCount();
155 bool GetFullscreen();
156 bool SetFullscreen(bool bFull);
157 bool AllowAlertDialog(const wxString &class_name);
158 double GetDisplayDensityFactor();
159 double m_pt_per_pixel;
160 long GetDefaultToolbarOrientation();
161
162 //--------------------------------------------------------------------------
163 // Per-Platform file/directory support
164 //--------------------------------------------------------------------------
165
166 MyConfig *GetConfigObject();
167 wxString GetSupplementalLicenseString();
168
169 int DoFileSelectorDialog(wxWindow *parent, wxString *file_spec,
170 wxString Title, wxString initDir,
171 wxString suggestedName, wxString wildcard);
172 int DoDirSelectorDialog(wxWindow *parent, wxString *file_spec, wxString Title,
173 wxString initDir, bool b_addFiles = true);
174
175 //--------------------------------------------------------------------------
176 // Per-Platform Utility support
177 //--------------------------------------------------------------------------
178 void setChartTypeMaskSel(int mask, wxString &indicator);
179 bool isPlatformCapable(int flag);
180
181 int platformApplyPrivateSettingsString(wxString settings,
182 ArrayOfCDI *pDirArray);
183 void platformLaunchDefaultBrowser(wxString URL);
184
185 void SetLocaleSearchPrefixes(void);
186 wxString GetDefaultSystemLocale();
187
188#if wxUSE_XLOCALE
189 wxString GetAdjustedAppLocale();
190 wxString ChangeLocale(wxString &newLocaleID, wxLocale *presentLocale,
191 wxLocale **newLocale);
192#endif
193
194 //--------------------------------------------------------------------------
195 // Per-Platform OpenGL support
196 //--------------------------------------------------------------------------
197 bool BuildGLCaps(void *pbuf);
198 bool IsGLCapable();
199
200private:
201 wxString m_SData_Dir;
202};
203
204// Private colourPicker control
205//--------------------------------------------------------------------------
206
207class OCPNColourPickerCtrl : public wxBitmapButton {
208public:
210 OCPNColourPickerCtrl(wxWindow *parent, wxWindowID id,
211 const wxColour &initial = *wxBLACK,
212 const wxPoint &pos = wxDefaultPosition,
213 const wxSize &size = wxDefaultSize, long style = 0,
214 const wxValidator &validator = wxDefaultValidator,
215 const wxString &name = _T(""));
216
217 bool Create(wxWindow *parent, wxWindowID id,
218 const wxColour &initial = *wxBLACK,
219 const wxPoint &pos = wxDefaultPosition,
220 const wxSize &size = wxDefaultSize, long style = 0,
221 const wxValidator &validator = wxDefaultValidator,
222 const wxString &name = _T(""));
223
224 void OnButtonClick(wxCommandEvent &WXUNUSED(ev));
225 void InitColourData();
226 void SetColour(wxColour &c);
227 wxColour GetColour(void);
228
229protected:
230 virtual void UpdateColour();
231 wxSize DoGetBestSize() const;
232
233 void OnPaint(wxPaintEvent &event);
234
235 DECLARE_EVENT_TABLE();
236
237private:
238 wxBitmap m_bitmap;
239 wxColour m_colour;
240 wxColourData ms_data;
241};
242
243#endif // guard
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.