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