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 void LaunchLocalHelp();
181 void DoHelpDialog(void);
182
183 int platformApplyPrivateSettingsString(wxString settings,
184 ArrayOfCDI *pDirArray);
185 void platformLaunchDefaultBrowser(wxString URL);
186
187 void SetLocaleSearchPrefixes(void);
188 wxString GetDefaultSystemLocale();
189
190#if wxUSE_XLOCALE
191 wxString GetAdjustedAppLocale();
192 wxString ChangeLocale(wxString &newLocaleID, wxLocale *presentLocale,
193 wxLocale **newLocale);
194#endif
195
196 //--------------------------------------------------------------------------
197 // Per-Platform OpenGL support
198 //--------------------------------------------------------------------------
199 bool BuildGLCaps(void *pbuf);
200 bool IsGLCapable();
201
202private:
203 wxString m_SData_Dir;
204};
205
206// Private colourPicker control
207//--------------------------------------------------------------------------
208
209class OCPNColourPickerCtrl : public wxBitmapButton {
210public:
212 OCPNColourPickerCtrl(wxWindow *parent, wxWindowID id,
213 const wxColour &initial = *wxBLACK,
214 const wxPoint &pos = wxDefaultPosition,
215 const wxSize &size = wxDefaultSize, long style = 0,
216 const wxValidator &validator = wxDefaultValidator,
217 const wxString &name = _T(""));
218
219 bool Create(wxWindow *parent, wxWindowID id,
220 const wxColour &initial = *wxBLACK,
221 const wxPoint &pos = wxDefaultPosition,
222 const wxSize &size = wxDefaultSize, long style = 0,
223 const wxValidator &validator = wxDefaultValidator,
224 const wxString &name = _T(""));
225
226 void OnButtonClick(wxCommandEvent &WXUNUSED(ev));
227 void InitColourData();
228 void SetColour(wxColour &c);
229 wxColour GetColour(void);
230
231protected:
232 virtual void UpdateColour();
233 wxSize DoGetBestSize() const;
234
235 void OnPaint(wxPaintEvent &event);
236
237 DECLARE_EVENT_TABLE();
238
239private:
240 wxBitmap m_bitmap;
241 wxColour m_colour;
242 wxColourData ms_data;
243};
244
245#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.