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 OCPNPlatform; // forward
59extern OCPNPlatform *g_Platform;
61class MyConfig;
62class ArrayOfCDI;
63
64//--------------------------------------------------------------------------
65// Per-Platform Utility support
66//--------------------------------------------------------------------------
67
68// #ifdef __WXQT__
69// extern bool LoadQtStyleSheet(wxString &sheet_file);
70// extern QString getQtStyleSheet( void );
71// #endif
72
79class OCPNPlatform : public BasePlatform {
80public:
82 virtual ~OCPNPlatform();
83
84 // Internal Device Support
85 static bool hasInternalGPS(wxString profile = _T("")); // GPS
86
87 static bool hasInternalBT(wxString profile = _T("")); // Bluetooth
88 bool startBluetoothScan();
89 wxArrayString getBluetoothScanResults();
90 bool stopBluetoothScan();
91
92 // Per-Platform initialization support
93
94 // Called from MyApp() immediately upon entry to MyApp::OnInit()
95 static void Initialize_1(void);
96
97 // Called from MyApp() immediately before creation of MyFrame()
98 void Initialize_2(void);
99
100 // Called from MyApp()::OnInit() just after gFrame is created, so gFrame is
101 // available
102 void Initialize_3(void);
103
104 // Called from MyApp() just before end of MyApp::OnInit()
105 static void Initialize_4(void);
106
107 static void OnExit_1(void);
108 static void OnExit_2(void);
109
110 void SetDefaultOptions(void);
111 void SetUpgradeOptions(wxString vString, wxString vStringConfig);
112
113 void applyExpertMode(bool mode);
114
115 //--------------------------------------------------------------------------
116 // Platform Display Support
117 //--------------------------------------------------------------------------
118 virtual void ShowBusySpinner(void);
119 virtual void HideBusySpinner(void);
120 double getFontPointsperPixel(void);
134 wxSize getDisplaySize();
138 double GetDisplaySizeMM();
139 double GetDisplayAreaCM2();
140 virtual double GetDisplayDPmm();
141
145 void SetDisplaySizeMM(size_t monitor, double size);
146 unsigned int GetSelectRadiusPix();
147 double GetToolbarScaleFactor(int GUIScaleFactor);
148 double GetCompassScaleFactor(int GUIScaleFactor);
149
150 wxFileDialog *AdjustFileDialogFont(wxWindow *container, wxFileDialog *dlg);
151 wxDirDialog *AdjustDirDialogFont(wxWindow *container, wxDirDialog *dlg);
152
153 void PositionAISAlert(wxWindow *alert_window);
154 float GetChartScaleFactorExp(float scale_linear);
155 float GetMarkScaleFactorExp(float scale_linear);
156 // float GetDIPScaleFactor();
157 int GetStatusBarFieldCount();
158 bool GetFullscreen();
159 bool SetFullscreen(bool bFull);
160 bool AllowAlertDialog(const wxString &class_name);
161 double GetDisplayDensityFactor();
162 double m_pt_per_pixel;
163 long GetDefaultToolbarOrientation();
164
165 //--------------------------------------------------------------------------
166 // Per-Platform file/directory support
167 //--------------------------------------------------------------------------
168
169 MyConfig *GetConfigObject();
170
171 int DoFileSelectorDialog(wxWindow *parent, wxString *file_spec,
172 wxString Title, wxString initDir,
173 wxString suggestedName, wxString wildcard);
174 int DoDirSelectorDialog(wxWindow *parent, wxString *file_spec, wxString Title,
175 wxString initDir, bool b_addFiles = true);
176
177 //--------------------------------------------------------------------------
178 // Per-Platform Utility support
179 //--------------------------------------------------------------------------
180 void setChartTypeMaskSel(int mask, wxString &indicator);
181 bool isPlatformCapable(int flag);
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.