OpenCPN Partial API docs
Loading...
Searching...
No Matches
options.cpp
Go to the documentation of this file.
1/**************************************************************************
2 * Copyright (C) 2010 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, write to the *
16 * Free Software Foundation, Inc., *
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
18 **************************************************************************/
19
25
26#include <chrono>
27#include <iterator>
28#include <list>
29#include <map>
30#include <memory>
31#include <sstream>
32
33#ifdef __linux__
34#include <unistd.h>
35#endif
36
37#include "gl_headers.h" // Must be included before anything using GL stuff
38
39#ifdef __MINGW32__
40#undef IPV6STRICT // mingw FTBS fix: missing struct ip_mreq
41#include <windows.h>
42#endif
43
44// For compilers that support precompilation, includes "wx/wx.h".
45#include <wx/wxprec.h>
46
47#ifndef WX_PRECOMP
48#include <wx/wx.h>
49#endif
50
51#include <wx/choice.h>
52#include <wx/clrpicker.h>
53#include <wx/dirdlg.h>
54#include <wx/dir.h>
55#include <wx/display.h>
56#include <wx/fontdata.h>
57#include <wx/fontdlg.h>
58#include <wx/imaglist.h>
59#include <wx/listbox.h>
60#include <wx/mediactrl.h>
61#include <wx/odcombo.h>
62#include <wx/progdlg.h>
63#include <wx/radiobox.h>
64#include <wx/regex.h>
65#include <wx/renderer.h>
66#include <wx/statline.h>
67#include <wx/stdpaths.h>
68#include <wx/textwrapper.h>
69#include <wx/tokenzr.h>
70
71#if defined(__WXGTK__) || defined(__WXQT__)
72#include <wx/colordlg.h>
73#endif
74
75#ifdef __WXGTK__
76#include "ocpn_fontdlg.h"
77#endif
78
79#include "config.h"
80
81#include "observable/evtvar.h"
83#include "o_sound/o_sound.h"
84
85#include "model/ais_decoder.h"
88#include "model/cmdline.h"
90#include "model/comm_util.h"
91#include "model/config_vars.h"
92#include "model/gui_events.h"
93#include "model/gui_vars.h"
94#include "model/idents.h"
95#include "model/multiplexer.h"
96#include "model/navutil_base.h"
97#include "model/own_ship.h"
98#include "model/routeman.h"
99#include "model/ser_ports.h"
100#include "model/svg_utils.h"
101
102#include "ais.h"
103#include "chart_ctx_factory.h"
104#include "chartdbs.h"
105#include "chcanv.h"
106#include "cm93.h"
107#include "config_mgr.h"
108#include "conn_params_panel.h"
109#include "connections_dlg.h"
110#include "displays.h"
111#include "dychart.h"
112#include "font_mgr.h"
113#include "mark_info.h"
114#include "navutil.h"
115#include "ocpn_platform.h"
116#include "options.h"
117#include "s52plib.h"
118#include "s52utils.h"
119#include "s57_load.h"
120#include "styles.h"
121#include "top_frame.h"
122#include "usb_devices.h"
123#include "waypointman_gui.h"
124
125#ifdef ocpnUSE_GL
126#include "gl_chart_canvas.h"
127extern GLuint g_raster_format;
128#endif
129
130// Centralized tooltip strings to avoid duplication. Keep translatable.
131static inline wxString ttDistance() {
132 return _(
133 "Horizontal measurements and distances. Examples: Distance between "
134 "geographic positions, visibility range, radar range.");
135}
136static inline wxString ttSpeed() {
137 return _("Vessel and surface speed measurements");
138}
139static inline wxString ttWindSpeed() {
140 return _("Wind speed measurements and forecasts");
141}
142static inline wxString ttDepth() {
143 return _("Measurements below the water surface");
144}
145static inline wxString ttHeight() {
146 return _(
147 "Vertical measurements above reference datum. Examples: Tide level, wave "
148 "height, air gap, mast clearance, elevation above reference datum.");
149}
150static inline wxString ttTemp() {
151 return _("Temperature measurements (air, water, engine)");
152}
153static inline wxString ttCoordFormat() {
154 return _("Coordinate display format for latitude and longitude");
155}
156
157#ifdef __linux__
158#include "udev_rule_mgr.h"
159#endif
160
161#ifdef __ANDROID__
162#include "androidUTIL.h"
163#endif
164
165#ifdef __ANDROID__
166#include <QtWidgets/QScroller>
167#endif
168
169#ifdef __WXOSX__
170#if wxCHECK_VERSION(3, 2, 0)
171#define SLIDER_STYLE wxSL_HORIZONTAL | wxSL_AUTOTICKS | wxSL_LABELS
172#else
173#define SLIDER_STYLE wxSL_HORIZONTAL | wxSL_AUTOTICKS
174#endif
175#else
176#define SLIDER_STYLE wxSL_HORIZONTAL | wxSL_AUTOTICKS | wxSL_LABELS
177#endif
178
179#define ID_CHOICE_NMEA wxID_HIGHEST + 1
180
181options* g_options; // global instance
182options* g_pOptions; // Duplicate to be removed FIXME (leamas)
183
184#if wxUSE_XLOCALE
185extern wxLocale* plocale_def_lang;
186#endif
187
188#ifdef ocpnUSE_GL
189extern ocpnGLOptions g_GLOptions;
190#endif
191
192#ifdef __ANDROID__
193extern int g_Android_SDK_Version;
194extern MigrateAssistantDialog* g_migrateDialog;
195#endif
196
197static wxString GetOCPNKnownLanguage(const wxString lang_canonical,
198 wxString& lang_dir);
199static wxString GetOCPNKnownLanguage(const wxString lang_canonical);
200
201#if wxUSE_XLOCALE
202static int lang_list[] = {
203 wxLANGUAGE_DEFAULT, wxLANGUAGE_ABKHAZIAN, wxLANGUAGE_AFAR,
204 wxLANGUAGE_AFRIKAANS, wxLANGUAGE_ALBANIAN, wxLANGUAGE_AMHARIC,
205 wxLANGUAGE_ARABIC, wxLANGUAGE_ARABIC_ALGERIA, wxLANGUAGE_ARABIC_BAHRAIN,
206 wxLANGUAGE_ARABIC_EGYPT, wxLANGUAGE_ARABIC_IRAQ, wxLANGUAGE_ARABIC_JORDAN,
207 wxLANGUAGE_ARABIC_KUWAIT, wxLANGUAGE_ARABIC_LEBANON,
208 wxLANGUAGE_ARABIC_LIBYA, wxLANGUAGE_ARABIC_MOROCCO, wxLANGUAGE_ARABIC_OMAN,
209 wxLANGUAGE_ARABIC_QATAR, wxLANGUAGE_ARABIC_SAUDI_ARABIA,
210 wxLANGUAGE_ARABIC_SUDAN, wxLANGUAGE_ARABIC_SYRIA, wxLANGUAGE_ARABIC_TUNISIA,
211 // wxLANGUAGE_ARABIC_UAE,
212 wxLANGUAGE_ARABIC_YEMEN, wxLANGUAGE_ARMENIAN, wxLANGUAGE_ASSAMESE,
213 wxLANGUAGE_AYMARA, wxLANGUAGE_AZERI, wxLANGUAGE_AZERI_CYRILLIC,
214 wxLANGUAGE_AZERI_LATIN, wxLANGUAGE_BASHKIR, wxLANGUAGE_BASQUE,
215 wxLANGUAGE_BELARUSIAN, wxLANGUAGE_BENGALI, wxLANGUAGE_BHUTANI,
216 wxLANGUAGE_BIHARI, wxLANGUAGE_BISLAMA, wxLANGUAGE_BRETON,
217 wxLANGUAGE_BULGARIAN, wxLANGUAGE_BURMESE, wxLANGUAGE_CAMBODIAN,
218 wxLANGUAGE_CATALAN,
219 // wxLANGUAGE_CHINESE,
220 // wxLANGUAGE_CHINESE_SIMPLIFIED,
221 // wxLANGUAGE_CHINESE_TRADITIONAL,
222 // wxLANGUAGE_CHINESE_HONGKONG,
223 // wxLANGUAGE_CHINESE_MACAU,
224 // wxLANGUAGE_CHINESE_SINGAPORE,
225 wxLANGUAGE_CHINESE_TAIWAN, wxLANGUAGE_CORSICAN, wxLANGUAGE_CROATIAN,
226 wxLANGUAGE_CZECH, wxLANGUAGE_DANISH, wxLANGUAGE_DUTCH,
227 wxLANGUAGE_DUTCH_BELGIAN, wxLANGUAGE_ENGLISH_UK, wxLANGUAGE_ENGLISH_US,
228 wxLANGUAGE_ENGLISH_AUSTRALIA, wxLANGUAGE_ENGLISH_BELIZE,
229 wxLANGUAGE_ENGLISH_BOTSWANA, wxLANGUAGE_ENGLISH_CANADA,
230 wxLANGUAGE_ENGLISH_CARIBBEAN, wxLANGUAGE_ENGLISH_DENMARK,
231 wxLANGUAGE_ENGLISH_EIRE, wxLANGUAGE_ENGLISH_JAMAICA,
232 wxLANGUAGE_ENGLISH_NEW_ZEALAND, wxLANGUAGE_ENGLISH_PHILIPPINES,
233 wxLANGUAGE_ENGLISH_SOUTH_AFRICA, wxLANGUAGE_ENGLISH_TRINIDAD,
234 wxLANGUAGE_ENGLISH_ZIMBABWE, wxLANGUAGE_ESPERANTO, wxLANGUAGE_ESTONIAN,
235 wxLANGUAGE_FAEROESE, wxLANGUAGE_FARSI, wxLANGUAGE_FIJI, wxLANGUAGE_FINNISH,
236 wxLANGUAGE_FRENCH, wxLANGUAGE_FRENCH_BELGIAN, wxLANGUAGE_FRENCH_CANADIAN,
237 wxLANGUAGE_FRENCH_LUXEMBOURG, wxLANGUAGE_FRENCH_MONACO,
238 wxLANGUAGE_FRENCH_SWISS, wxLANGUAGE_FRISIAN, wxLANGUAGE_GALICIAN,
239 wxLANGUAGE_GEORGIAN, wxLANGUAGE_GERMAN, wxLANGUAGE_GERMAN_AUSTRIAN,
240 wxLANGUAGE_GERMAN_BELGIUM, wxLANGUAGE_GERMAN_LIECHTENSTEIN,
241 wxLANGUAGE_GERMAN_LUXEMBOURG, wxLANGUAGE_GERMAN_SWISS, wxLANGUAGE_GREEK,
242 wxLANGUAGE_GREENLANDIC, wxLANGUAGE_GUARANI, wxLANGUAGE_GUJARATI,
243 wxLANGUAGE_HAUSA, wxLANGUAGE_HEBREW, wxLANGUAGE_HINDI, wxLANGUAGE_HUNGARIAN,
244 wxLANGUAGE_ICELANDIC, wxLANGUAGE_INDONESIAN, wxLANGUAGE_INTERLINGUA,
245 wxLANGUAGE_INTERLINGUE, wxLANGUAGE_INUKTITUT, wxLANGUAGE_INUPIAK,
246 wxLANGUAGE_IRISH, wxLANGUAGE_ITALIAN, wxLANGUAGE_ITALIAN_SWISS,
247 wxLANGUAGE_JAPANESE, wxLANGUAGE_JAVANESE, wxLANGUAGE_KANNADA,
248 wxLANGUAGE_KASHMIRI, wxLANGUAGE_KASHMIRI_INDIA, wxLANGUAGE_KAZAKH,
249 wxLANGUAGE_KERNEWEK, wxLANGUAGE_KINYARWANDA, wxLANGUAGE_KIRGHIZ,
250 wxLANGUAGE_KIRUNDI,
251 // wxLANGUAGE_KONKANI,
252 wxLANGUAGE_KOREAN, wxLANGUAGE_KURDISH, wxLANGUAGE_LAOTHIAN,
253 wxLANGUAGE_LATIN, wxLANGUAGE_LATVIAN, wxLANGUAGE_LINGALA,
254 wxLANGUAGE_LITHUANIAN, wxLANGUAGE_MACEDONIAN, wxLANGUAGE_MALAGASY,
255 wxLANGUAGE_MALAY, wxLANGUAGE_MALAYALAM, wxLANGUAGE_MALAY_BRUNEI_DARUSSALAM,
256 wxLANGUAGE_MALAY_MALAYSIA, wxLANGUAGE_MALTESE,
257 // wxLANGUAGE_MANIPURI,
258 wxLANGUAGE_MAORI, wxLANGUAGE_MARATHI, wxLANGUAGE_MOLDAVIAN,
259 wxLANGUAGE_MONGOLIAN, wxLANGUAGE_NAURU, wxLANGUAGE_NEPALI,
260 wxLANGUAGE_NEPALI_INDIA, wxLANGUAGE_NORWEGIAN_BOKMAL,
261 wxLANGUAGE_NORWEGIAN_NYNORSK, wxLANGUAGE_OCCITAN, wxLANGUAGE_ORIYA,
262 wxLANGUAGE_OROMO, wxLANGUAGE_PASHTO, wxLANGUAGE_POLISH,
263 wxLANGUAGE_PORTUGUESE, wxLANGUAGE_PORTUGUESE_BRAZILIAN, wxLANGUAGE_PUNJABI,
264 wxLANGUAGE_QUECHUA, wxLANGUAGE_RHAETO_ROMANCE, wxLANGUAGE_ROMANIAN,
265 wxLANGUAGE_RUSSIAN, wxLANGUAGE_RUSSIAN_UKRAINE, wxLANGUAGE_SAMOAN,
266 wxLANGUAGE_SANGHO, wxLANGUAGE_SANSKRIT, wxLANGUAGE_SCOTS_GAELIC,
267 wxLANGUAGE_SERBIAN, wxLANGUAGE_SERBIAN_CYRILLIC, wxLANGUAGE_SERBIAN_LATIN,
268 wxLANGUAGE_SERBO_CROATIAN, wxLANGUAGE_SESOTHO, wxLANGUAGE_SETSWANA,
269 wxLANGUAGE_SHONA, wxLANGUAGE_SINDHI, wxLANGUAGE_SINHALESE,
270 wxLANGUAGE_SISWATI, wxLANGUAGE_SLOVAK, wxLANGUAGE_SLOVENIAN,
271 wxLANGUAGE_SOMALI, wxLANGUAGE_SPANISH, wxLANGUAGE_SPANISH_ARGENTINA,
272 wxLANGUAGE_SPANISH_BOLIVIA, wxLANGUAGE_SPANISH_CHILE,
273 wxLANGUAGE_SPANISH_COLOMBIA, wxLANGUAGE_SPANISH_COSTA_RICA,
274 wxLANGUAGE_SPANISH_DOMINICAN_REPUBLIC, wxLANGUAGE_SPANISH_ECUADOR,
275 wxLANGUAGE_SPANISH_EL_SALVADOR, wxLANGUAGE_SPANISH_GUATEMALA,
276 wxLANGUAGE_SPANISH_HONDURAS, wxLANGUAGE_SPANISH_MEXICAN,
277 // wxLANGUAGE_SPANISH_MODERN,
278 wxLANGUAGE_SPANISH_NICARAGUA, wxLANGUAGE_SPANISH_PANAMA,
279 wxLANGUAGE_SPANISH_PARAGUAY, wxLANGUAGE_SPANISH_PERU,
280 wxLANGUAGE_SPANISH_PUERTO_RICO, wxLANGUAGE_SPANISH_URUGUAY,
281 wxLANGUAGE_SPANISH_US, wxLANGUAGE_SPANISH_VENEZUELA, wxLANGUAGE_SUNDANESE,
282 wxLANGUAGE_SWAHILI, wxLANGUAGE_SWEDISH, wxLANGUAGE_SWEDISH_FINLAND,
283 wxLANGUAGE_TAGALOG, wxLANGUAGE_TAJIK, wxLANGUAGE_TAMIL, wxLANGUAGE_TATAR,
284 wxLANGUAGE_TELUGU, wxLANGUAGE_THAI, wxLANGUAGE_TIBETAN, wxLANGUAGE_TIGRINYA,
285 wxLANGUAGE_TONGA, wxLANGUAGE_TSONGA, wxLANGUAGE_TURKISH, wxLANGUAGE_TURKMEN,
286 wxLANGUAGE_TWI, wxLANGUAGE_UIGHUR, wxLANGUAGE_UKRAINIAN, wxLANGUAGE_URDU,
287 wxLANGUAGE_URDU_INDIA, wxLANGUAGE_URDU_PAKISTAN, wxLANGUAGE_UZBEK,
288 wxLANGUAGE_UZBEK_CYRILLIC, wxLANGUAGE_UZBEK_LATIN, wxLANGUAGE_VIETNAMESE,
289 wxLANGUAGE_VOLAPUK, wxLANGUAGE_WELSH, wxLANGUAGE_WOLOF, wxLANGUAGE_XHOSA,
290 wxLANGUAGE_YIDDISH, wxLANGUAGE_YORUBA, wxLANGUAGE_ZHUANG, wxLANGUAGE_ZULU};
291#endif
292
293#ifdef __ANDROID__
294void prepareSlider(wxSlider* slider) {
295 slider->GetHandle()->setStyleSheet(
296 prepareAndroidSliderStyleSheet(slider->GetSize().x));
297 slider->GetHandle()->setAttribute(Qt::WA_AcceptTouchEvents);
298 slider->GetHandle()->grabGesture(Qt::PanGesture);
299 slider->GetHandle()->grabGesture(Qt::SwipeGesture);
300}
301#endif
302
304
305class ChartDirPanelHardBreakWrapper : public wxTextWrapper {
306public:
307 ChartDirPanelHardBreakWrapper(wxWindow* win, const wxString& text,
308 int widthMax) {
309 m_lineCount = 0;
310
311 // Replace all spaces in the string with a token character '^'
312 wxString textMod = text;
313 textMod.Replace(" ", "^");
314
315 // Replace all path separators with spaces
316 wxString sep = wxFileName::GetPathSeparator();
317 textMod.Replace(sep, " ");
318
319 Wrap(win, textMod, widthMax);
320
321 // walk the output array, repairing the substitutions
322 for (size_t i = 0; i < m_array.GetCount(); i++) {
323 wxString a = m_array[i];
324 a.Replace(" ", sep);
325 if (m_array.GetCount() > 1) {
326 if (i < m_array.GetCount() - 1) a += sep;
327 }
328 a.Replace("^", " ");
329 m_array[i] = a;
330 }
331 }
332 wxString const& GetWrapped() const { return m_wrapped; }
333 int const GetLineCount() const { return m_lineCount; }
334 wxArrayString GetLineArray() { return m_array; }
335
336protected:
337 virtual void OnOutputLine(const wxString& line) {
338 m_wrapped += line;
339 m_array.Add(line);
340 }
341 virtual void OnNewLine() {
342 m_wrapped += '\n';
343 m_lineCount++;
344 }
345
346private:
347 wxString m_wrapped;
348 int m_lineCount;
349 wxArrayString m_array;
350};
351
352class OCPNChartDirPanel : public wxPanel {
353public:
354 OCPNChartDirPanel(wxWindow* parent, wxWindowID id, const wxPoint& pos,
355 const wxSize& size, ChartDirInfo& cdi);
356 ~OCPNChartDirPanel();
357
358 void DoChartSelected();
359 void SetSelected(bool selected);
360 void OnPaint(wxPaintEvent& event);
361 // void OnEraseBackground( wxEraseEvent &event );
362 void OnSize(wxSizeEvent& event);
363 ChartDirInfo GetCDI() { return m_cdi; }
364 int GetUnselectedHeight() { return m_unselectedHeight; }
365 int GetRefHeight() { return m_refHeight; }
366 bool IsSelected() { return m_bSelected; }
367 void OnClickDown(wxMouseEvent& event);
368 void OnClickUp(wxMouseEvent& event);
369
370private:
371 // shopPanel *m_pContainer;
372 bool m_bSelected;
373 wxColour m_boxColour;
374 int m_unselectedHeight;
375 wxString m_pChartDir;
376 int m_refHeight;
377 ChartDirInfo m_cdi;
378
379 DECLARE_EVENT_TABLE()
380};
381
382BEGIN_EVENT_TABLE(OCPNChartDirPanel, wxPanel)
383EVT_PAINT(OCPNChartDirPanel::OnPaint)
384// EVT_ERASE_BACKGROUND( OCPNChartDirPanel::OnEraseBackground)
385EVT_SIZE(OCPNChartDirPanel::OnSize)
386END_EVENT_TABLE()
387
388OCPNChartDirPanel::OCPNChartDirPanel(wxWindow* parent, wxWindowID id,
389 const wxPoint& pos, const wxSize& size,
390 ChartDirInfo& cdi)
391 : wxPanel(parent, id, pos, size, wxBORDER_NONE) {
392 m_pChartDir = cdi.fullpath;
393
394 // On Android, shorten the displayed path name by removing well-known prefix
395 if (cdi.fullpath.StartsWith(
396 "/storage/emulated/0/Android/data/org.opencpn.opencpn/files"))
397 m_pChartDir = "..." + cdi.fullpath.Mid(58);
398
399 m_cdi = cdi;
400 m_bSelected = false;
401
402 m_refHeight = GetCharHeight();
403
404 m_unselectedHeight = 2 * m_refHeight;
405
406 // #ifdef __ANDROID__
407 // m_unselectedHeight = 2 * m_refHeight;
408 // #endif
409
410 SetMinSize(wxSize(-1, m_unselectedHeight));
411
412 Connect(wxEVT_LEFT_DOWN, wxMouseEventHandler(OCPNChartDirPanel::OnClickDown),
413 NULL, this);
414#ifdef __ANDROID__
415 Connect(wxEVT_LEFT_UP, wxMouseEventHandler(OCPNChartDirPanel::OnClickUp),
416 NULL, this);
417#endif
418}
419
420OCPNChartDirPanel::~OCPNChartDirPanel() {}
421
422static wxStopWatch swclick;
423#ifdef __ANDROID__
424static int downx, downy;
425#endif
426
427void OCPNChartDirPanel::OnClickDown(wxMouseEvent& event) {
428#ifdef __ANDROID__
429 swclick.Start();
430 event.GetPosition(&downx, &downy);
431#else
432 DoChartSelected();
433#endif
434}
435
436void OCPNChartDirPanel::OnClickUp(wxMouseEvent& event) {
437#ifdef __ANDROID__
438 qDebug() << swclick.Time();
439 if (swclick.Time() < 200) {
440 int upx, upy;
441 event.GetPosition(&upx, &upy);
442 if ((fabs(upx - downx) < GetCharWidth()) &&
443 (fabs(upy - downy) < GetCharWidth())) {
444 DoChartSelected();
445 }
446 }
447 swclick.Start();
448#endif
449}
450
451void OCPNChartDirPanel::DoChartSelected() {
452 if (!m_bSelected) {
453 SetSelected(true);
454 // m_pContainer->SelectChart( this );
455 } else {
456 SetSelected(false);
457 // m_pContainer->SelectChart( (OCPNChartDirPanel*)NULL );
458 }
459}
460
461void OCPNChartDirPanel::SetSelected(bool selected) {
462 m_bSelected = selected;
463
464 if (selected) {
465 m_boxColour =
466 wxSystemSettings::GetColour(wxSystemColour::wxSYS_COLOUR_HIGHLIGHT);
467 } else {
468 m_boxColour =
469 wxSystemSettings::GetColour(wxSystemColour::wxSYS_COLOUR_WINDOW);
470 }
471
472 Refresh(true);
473
474 g_pOptions->SetDirActionButtons();
475}
476
477// void OCPNChartDirPanel::OnEraseBackground( wxEraseEvent &event )
478// {
479// }
480
481void OCPNChartDirPanel::OnSize(wxSizeEvent& event) {
482 if (m_pChartDir.Length()) {
483 int x, y;
484 GetClientSize(&x, &y);
485
486 ChartDirPanelHardBreakWrapper wrapper(this, m_pChartDir, x * 9 / 10);
487 wxArrayString nameWrapped = wrapper.GetLineArray();
488
489 SetMinSize(wxSize(-1, (nameWrapped.GetCount() + 1) * m_refHeight));
490 }
491
492 event.Skip();
493}
494
495void OCPNChartDirPanel::OnPaint(wxPaintEvent& event) {
496 int width, height;
497 GetSize(&width, &height);
498 wxPaintDC dc(this);
499
500 dc.SetPen(*wxTRANSPARENT_PEN);
501 dc.SetBrush(wxBrush(GetBackgroundColour()));
502 dc.DrawRectangle(GetVirtualSize());
503
504 wxString nameString = m_pChartDir;
505 ChartDirPanelHardBreakWrapper wrapper(this, nameString, width * 9 / 10);
506 wxArrayString nameWrapped = wrapper.GetLineArray();
507
508 if (height < (int)(nameWrapped.GetCount() + 1) * m_refHeight) {
509 SetMinSize(wxSize(-1, (nameWrapped.GetCount() + 1) * m_refHeight));
510 GetParent()->GetSizer()->Layout();
511 }
512
513 if (m_bSelected) {
514 dc.SetBrush(wxBrush(m_boxColour));
515
516 dc.SetPen(wxPen(wxColor(0xCE, 0xD5, 0xD6), 3));
517
518 dc.DrawRoundedRectangle(0, 0, width - 1, height - 1, height / 10);
519
520 int offset = height / 10;
521 int text_x = offset * 2;
522
523 wxFont* dFont = GetOCPNScaledFont_PlugIn(_("Dialog"));
524 dc.SetFont(*dFont);
525
526 dc.SetTextForeground(
527 wxSystemSettings::GetColour(wxSystemColour::wxSYS_COLOUR_WINDOWTEXT));
528
529 int yd = height * 20 / 100;
530 for (size_t i = 0; i < nameWrapped.GetCount(); i++) {
531 if (i == 0)
532 dc.DrawText(nameWrapped[i], text_x, yd);
533 else
534 dc.DrawText(nameWrapped[i], text_x + GetCharWidth(), yd);
535 yd += GetCharHeight();
536 }
537 } // selected
538 else {
539 dc.SetBrush(wxBrush(m_boxColour));
540
541 dc.SetPen(wxPen(
542 wxSystemSettings::GetColour(wxSystemColour::wxSYS_COLOUR_WINDOWFRAME),
543 1));
544
545 int offset = height / 10;
546 dc.DrawRoundedRectangle(offset, offset, width - (2 * offset),
547 height - (2 * offset), height / 10);
548
549 int text_x = offset * 2;
550
551 wxFont* dFont = GetOCPNScaledFont_PlugIn(_("Dialog"));
552 dc.SetFont(*dFont);
553
554 dc.SetTextForeground(
555 wxSystemSettings::GetColour(wxSystemColour::wxSYS_COLOUR_WINDOWTEXT));
556
557 int yd = height * 20 / 100;
558 for (size_t i = 0; i < nameWrapped.GetCount(); i++) {
559 if (i == 0)
560 dc.DrawText(nameWrapped[i], text_x, yd);
561 else
562 dc.DrawText(nameWrapped[i], text_x + GetCharWidth(), yd);
563 yd += GetCharHeight();
564 }
565
566 } // not selected
567}
568
570
571static bool LoadAllPlugIns(bool load_enabled) {
572 g_Platform->ShowBusySpinner();
573 bool b = PluginLoader::GetInstance()->LoadAllPlugIns(load_enabled);
574 g_Platform->HideBusySpinner();
575 return b;
576}
577
578class OCPNCheckedListCtrl : public wxScrolledWindow {
579public:
580 OCPNCheckedListCtrl() {}
581
582 OCPNCheckedListCtrl(wxWindow* parent, wxWindowID id = -1,
583 const wxPoint& pt = wxDefaultPosition,
584 const wxSize& sz = wxDefaultSize,
585 long style = wxHSCROLL | wxVSCROLL,
586 const wxString& name = "scrolledWindow") {
587 Create(parent, id, pt, sz, style, name);
588 }
589
590 bool Create(wxWindow* parent, wxWindowID id = -1,
591 const wxPoint& pt = wxDefaultPosition,
592 const wxSize& sz = wxDefaultSize,
593 long style = wxHSCROLL | wxVSCROLL,
594 const wxString& name = "scrolledWindow");
595
596 virtual ~OCPNCheckedListCtrl() {}
597
598 unsigned int Append(wxString& label, bool benable = true,
599 bool bsizerLayout = true);
600 unsigned int GetCount() { return m_list.size(); }
601
602 void RunLayout();
603
604 void Clear();
605 void Check(int index, bool val);
606 bool IsChecked(int index);
607
608private:
609 wxBoxSizer* m_sizer;
610
611 std::vector<wxCheckBox*> m_list;
612};
613
614bool OCPNCheckedListCtrl::Create(wxWindow* parent, wxWindowID id,
615 const wxPoint& pt, const wxSize& sz,
616 long style, const wxString& name) {
617 if (!wxScrolledWindow::Create(parent, id, pt, sz, style, name)) return FALSE;
618
619#ifdef __ANDROID__
620 GetHandle()->setObjectName("OCPNCheckedListCtrl");
621 GetHandle()->setStyleSheet(getAdjustedDialogStyleSheet());
622#endif
623
624 SetScrollRate(0, 2);
625 m_sizer = new wxBoxSizer(wxVERTICAL);
626 SetSizer(m_sizer);
627
628 return TRUE;
629}
630
631unsigned int OCPNCheckedListCtrl::Append(wxString& label, bool benable,
632 bool bsizerLayout) {
633 wxCheckBox* cb = new wxCheckBox(this, wxID_ANY, label);
634 cb->Enable(benable);
635 cb->SetValue(!benable);
636 m_sizer->Add(cb);
637 if (bsizerLayout) m_sizer->Layout();
638
639 m_list.push_back(cb);
640
641 return m_list.size() - 1;
642}
643
644void OCPNCheckedListCtrl::Check(int index, bool val) {
645 wxCheckBox* cb = m_list[index];
646 if (cb) cb->SetValue(val);
647}
648
649bool OCPNCheckedListCtrl::IsChecked(int index) {
650 wxCheckBox* cb = m_list[index];
651 return cb ? cb->GetValue() : false;
652}
653
654void OCPNCheckedListCtrl::RunLayout() { m_sizer->Layout(); }
655
656void OCPNCheckedListCtrl::Clear() {
657 for (auto cb : m_list) delete cb;
658 m_list.clear();
659 Scroll(0, 0);
660}
661
662// Helper for conditional file name separator
663void appendOSDirSlash(wxString* pString);
664
665extern ArrayOfMmsiProperties g_MMSI_Props_Array;
666
670
671BEGIN_EVENT_TABLE(ConfigCreateDialog, wxDialog)
672EVT_BUTTON(ID_CONFIGEDIT_CANCEL, ConfigCreateDialog::OnConfigEditCancelClick)
673EVT_BUTTON(ID_CONFIGEDIT_OK, ConfigCreateDialog::OnConfigEditOKClick)
674END_EVENT_TABLE()
675
676ConfigCreateDialog::ConfigCreateDialog(wxWindow* parent, wxWindowID id,
677 const wxString& caption,
678 const wxPoint& pos, const wxSize& size,
679 long style)
680 : wxDialog(parent, id, caption, pos, size,
681 wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER) {
682 CreateControls();
683 GetSizer()->SetSizeHints(this);
684 Centre();
685}
686
687ConfigCreateDialog::~ConfigCreateDialog() {}
688
689void ConfigCreateDialog::CreateControls() {
690 wxBoxSizer* mainSizer = new wxBoxSizer(wxVERTICAL);
691 SetSizer(mainSizer);
692
693 mainSizer->Add(new wxStaticText(this, wxID_STATIC, _("Title")), 0,
694 wxALIGN_LEFT | wxLEFT | wxRIGHT | wxTOP, 5);
695
696 m_TitleCtl = new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition,
697 wxSize(40 * GetCharHeight(), -1), 0);
698 mainSizer->Add(m_TitleCtl, 0,
699 wxALIGN_LEFT | wxLEFT | wxRIGHT | wxBOTTOM | wxEXPAND, 5);
700
701 mainSizer->AddSpacer(2 * GetCharHeight());
702
703 mainSizer->Add(new wxStaticText(this, wxID_STATIC, _("Description")), 0,
704 wxALIGN_LEFT | wxLEFT | wxRIGHT | wxTOP, 5);
705
706 m_DescriptionCtl =
707 new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition,
708 wxSize(-1, 6 * GetCharHeight()), wxTE_MULTILINE);
709 mainSizer->Add(m_DescriptionCtl, 0,
710 wxALIGN_LEFT | wxLEFT | wxRIGHT | wxBOTTOM | wxEXPAND, 5);
711
712 mainSizer->AddSpacer(2 * GetCharHeight());
713
714 mainSizer->Add(
715 new wxStaticText(
716 this, wxID_STATIC,
717 _("Create a private configuration template based on current settings.\n\
718This template will be saved, and may be selected for further use at any time.\n\
719 ")),
720 0, wxALIGN_LEFT | wxLEFT | wxRIGHT | wxTOP, 5);
721
722 mainSizer->AddSpacer(2 * GetCharHeight());
723
724 wxBoxSizer* btnSizer = new wxBoxSizer(wxHORIZONTAL);
725 mainSizer->Add(btnSizer, 0, wxALIGN_RIGHT | wxALL, 5);
726
727 m_CancelButton = new wxButton(this, ID_CONFIGEDIT_CANCEL, _("Cancel"));
728 btnSizer->Add(m_CancelButton, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
729
730 m_OKButton = new wxButton(this, ID_CONFIGEDIT_OK, _("OK"));
731 btnSizer->Add(m_OKButton, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
732 m_OKButton->SetDefault();
733}
734
735void ConfigCreateDialog::OnConfigEditCancelClick(wxCommandEvent& event) {
736 EndModal(wxID_CANCEL);
737}
738
739void ConfigCreateDialog::OnConfigEditOKClick(wxCommandEvent& event) {
740 const wxString& title = m_TitleCtl->GetValue();
741 const wxString& desc = m_DescriptionCtl->GetValue();
742 m_createdTemplateGUID = ConfigMgr::Get().CreateNamedConfig(title, desc, "");
743 EndModal(wxID_OK);
744}
745
749
750BEGIN_EVENT_TABLE(MMSIEditDialog, wxDialog)
751EVT_BUTTON(ID_MMSIEDIT_CANCEL, MMSIEditDialog::OnMMSIEditCancelClick)
752EVT_BUTTON(ID_MMSIEDIT_OK, MMSIEditDialog::OnMMSIEditOKClick)
753END_EVENT_TABLE()
754
756 wxWindowID id, const wxString& caption,
757 const wxPoint& pos, const wxSize& size,
758 long style)
759 : wxDialog(parent, id, caption, pos, size,
760 wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER),
761 m_props(props) {
762 CreateControls();
763 GetSizer()->SetSizeHints(this);
764 Centre();
765}
766
767MMSIEditDialog::~MMSIEditDialog() { delete m_MMSICtl; }
768
769void MMSIEditDialog::CreateControls() {
770 wxBoxSizer* mainSizer = new wxBoxSizer(wxVERTICAL);
771 SetSizer(mainSizer);
772
773 wxStaticBox* mmsiBox =
774 new wxStaticBox(this, wxID_ANY, _("MMSI Extended Properties"));
775
776 wxStaticBoxSizer* mmsiSizer = new wxStaticBoxSizer(mmsiBox, wxVERTICAL);
777 mainSizer->Add(mmsiSizer, 0, wxEXPAND | wxALL, 5);
778
779 wxStaticText* mmsiLabel = new wxStaticText(this, wxID_STATIC, _("MMSI"));
780 mmsiLabel->SetToolTip(
781 _("Maritime Mobile Service Identity - A unique 9-digit number assigned "
782 "to a vessel or navigation aid. Used to identify vessels and devices "
783 "in AIS transmissions and DSC calls."));
784 mmsiSizer->Add(mmsiLabel, 0, wxALIGN_LEFT | wxLEFT | wxRIGHT | wxTOP, 5);
785
786 m_MMSICtl = new wxTextCtrl(this, ID_MMSI_CTL, wxEmptyString,
787 wxDefaultPosition, wxSize(180, -1), 0);
788 m_MMSICtl->SetToolTip(
789 _("Enter the 9-digit MMSI number for this vessel or station"));
790 mmsiSizer->Add(m_MMSICtl, 0,
791 wxALIGN_LEFT | wxLEFT | wxRIGHT | wxBOTTOM | wxEXPAND, 5);
792 m_MMSICtl->Bind(wxEVT_TEXT, &MMSIEditDialog::OnMMSIChanged, this);
793
794 wxStaticText* userLabelText = new wxStaticText(this, wxID_STATIC, _("Name"));
795 userLabelText->SetToolTip(
796 _("Display name for this vessel or device - can override names received "
797 "in AIS messages"));
798 mmsiSizer->Add(userLabelText, 0, wxALIGN_LEFT | wxLEFT | wxRIGHT | wxTOP, 5);
799
800 m_ShipNameCtl = new wxTextCtrl(this, wxID_ANY, wxEmptyString,
801 wxDefaultPosition, wxSize(180, -1), 0);
802 m_ShipNameCtl->SetToolTip(_(
803 "Set the name for this vessel or device. If specified, this name takes "
804 "precedence over names received via AIS messages. Note that standard AIS "
805 "only supports uppercase letters (A-Z), numbers, and limited "
806 "punctuation. Your manual entries are stored in the mmsitoname.csv file "
807 "and preserved across sessions."));
808 mmsiSizer->Add(m_ShipNameCtl, 0,
809 wxALIGN_LEFT | wxLEFT | wxRIGHT | wxBOTTOM | wxEXPAND, 5);
810
811 wxStaticBox* trackBox = new wxStaticBox(this, wxID_ANY, _("Tracking"));
812 trackBox->SetToolTip(_("Control how tracks are created for this MMSI"));
813 wxStaticBoxSizer* trackSizer = new wxStaticBoxSizer(trackBox, wxVERTICAL);
814
815 wxGridSizer* gridSizer = new wxGridSizer(0, 3, 0, 0);
816
817 m_rbTypeTrackDefault =
818 new wxRadioButton(this, wxID_ANY, _("Default tracking"),
819 wxDefaultPosition, wxDefaultSize, wxRB_GROUP);
820 m_rbTypeTrackDefault->SetToolTip(
821 _("Use the global tracking settings for this vessel"));
822 m_rbTypeTrackDefault->SetValue(TRUE);
823 gridSizer->Add(m_rbTypeTrackDefault, 0, wxALL, 5);
824
825 m_rbTypeTrackAlways = new wxRadioButton(this, wxID_ANY, _("Always track"));
826 m_rbTypeTrackAlways->SetToolTip(_(
827 "Always create a track for this vessel, regardless of global settings"));
828 gridSizer->Add(m_rbTypeTrackAlways, 0, wxALL, 5);
829
830 m_rbTypeTrackNever = new wxRadioButton(this, wxID_ANY, _(" Never track"));
831 m_rbTypeTrackNever->SetToolTip(
832 _("Never create a track for this vessel, regardless of global settings"));
833 gridSizer->Add(m_rbTypeTrackNever, 0, wxALL, 5);
834
835 m_cbTrackPersist = new wxCheckBox(this, wxID_ANY, _("Persistent"));
836 m_cbTrackPersist->SetToolTip(
837 _("Save this vessel's track between OpenCPN sessions. Useful for vessels "
838 "you want to monitor continuously over time."));
839 gridSizer->Add(m_cbTrackPersist, 0, wxALL, 5);
840
841 trackSizer->Add(gridSizer, 0, wxEXPAND, 0);
842 mmsiSizer->Add(trackSizer, 0, wxEXPAND, 0);
843
844 m_IgnoreButton = new wxCheckBox(this, wxID_ANY, _("Ignore this MMSI"));
845 m_IgnoreButton->SetToolTip(
846 _("When checked, AIS data for this MMSI will be ignored and the vessel "
847 "will not appear on the chart. Useful for suppressing shore stations, "
848 "permanently moored vessels, or duplicate AIS signals that you don't "
849 "need to monitor."));
850 mmsiSizer->Add(m_IgnoreButton, 0, wxEXPAND, 5);
851
852 m_MOBButton = new wxCheckBox(this, wxID_ANY,
853 _("Handle this MMSI as SART/PLB(AIS) MOB."));
854 m_MOBButton->SetToolTip(
855 _("When checked, OpenCPN will display a special icon for this device, "
856 "sound a distinctive alarm, and automatically create a temporary MOB "
857 "route from your vessel to this device in emergency. For crew safety "
858 "devices, you can assign the crew member's name using the Name "
859 "field above for quick identification."));
860 mmsiSizer->Add(m_MOBButton, 0, wxEXPAND, 5);
861
862 m_VDMButton =
863 new wxCheckBox(this, wxID_ANY, _("Convert AIVDM to AIVDO for this MMSI"));
864 m_VDMButton->SetToolTip(
865 _("When checked, converts AIS messages for this vessel from AIVDM (other "
866 "vessel) to AIVDO (own vessel) format."));
867 mmsiSizer->Add(m_VDMButton, 0, wxEXPAND, 5);
868
869 m_FollowerButton = new wxCheckBox(
870 this, wxID_ANY, _("This MMSI is my Follower - No CPA Alert"));
871 m_FollowerButton->SetToolTip(
872 _("When checked, disables CPA (Closest Point of Approach) alerts for "
873 "this vessel as it's considered intentionally following your vessel. "
874 "Follower vessels are displayed with a special own-ship style icon."));
875 mmsiSizer->Add(m_FollowerButton, 0, wxEXPAND, 5);
876
877 wxBoxSizer* btnSizer = new wxBoxSizer(wxHORIZONTAL);
878 mainSizer->Add(btnSizer, 0, wxALIGN_RIGHT | wxALL, 5);
879
880 m_CancelButton = new wxButton(this, ID_MMSIEDIT_CANCEL, _("Cancel"));
881 btnSizer->Add(m_CancelButton, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
882
883 m_OKButton = new wxButton(this, ID_MMSIEDIT_OK, _("OK"));
884 btnSizer->Add(m_OKButton, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
885 m_OKButton->SetDefault();
886
887 // Set initial values...
888 wxString sMMSI;
889 if (m_props->MMSI > 0)
890 sMMSI.Printf("%d", m_props->MMSI);
891 else
892 sMMSI = "";
893 m_MMSICtl->AppendText(sMMSI);
894
895 // Initialize user label with existing ship name if available
896 if (!m_props->m_ShipName.IsEmpty()) {
897 m_ShipNameCtl->SetValue(m_props->m_ShipName);
898 }
899
900 switch (m_props->TrackType) {
901 case TRACKTYPE_ALWAYS:
902 m_rbTypeTrackAlways->SetValue(TRUE);
903 break;
904 case TRACKTYPE_NEVER:
905 m_rbTypeTrackNever->SetValue(TRUE);
906 break;
907 default:
908 break;
909 }
910
911 m_cbTrackPersist->SetValue(m_props->m_bPersistentTrack);
912 m_IgnoreButton->SetValue(m_props->m_bignore);
913 m_MOBButton->SetValue(m_props->m_bMOB);
914 m_VDMButton->SetValue(m_props->m_bVDM);
915 m_FollowerButton->SetValue(m_props->m_bFollower);
916
917 SetColorScheme(GLOBAL_COLOR_SCHEME_RGB);
918}
919
920void MMSIEditDialog::SetColorScheme(ColorScheme cs) { DimeControl(this); }
921
922void MMSIEditDialog::OnMMSIEditCancelClick(wxCommandEvent& event) {
923 EndModal(wxID_CANCEL);
924}
925
926void MMSIEditDialog::Persist() {
927 if (m_props) {
928 if (m_rbTypeTrackDefault->GetValue())
929 m_props->TrackType = TRACKTYPE_DEFAULT;
930 else if (m_rbTypeTrackAlways->GetValue())
931 m_props->TrackType = TRACKTYPE_ALWAYS;
932 else
933 m_props->TrackType = TRACKTYPE_NEVER;
934
935 m_props->m_bignore = m_IgnoreButton->GetValue();
936 m_props->m_bMOB = m_MOBButton->GetValue();
937 m_props->m_bVDM = m_VDMButton->GetValue();
938 m_props->m_bFollower = m_FollowerButton->GetValue();
939 m_props->m_bPersistentTrack = m_cbTrackPersist->GetValue();
940
941 // Get user-defined ship name if provided.
942 wxString shipName = m_ShipNameCtl->GetValue().Upper();
943 if (!shipName.IsEmpty()) {
944 m_props->m_ShipName = shipName;
945
946 // Save the custom name to mmsitoname.csv file
947 wxString mmsi = m_MMSICtl->GetValue();
948 if (!mmsi.IsEmpty() && mmsi.Length() == 9 && mmsi.IsNumber()) {
949 g_pAIS->UpdateMMSItoNameFile(mmsi, shipName);
950 }
951 }
952 // If no user label provided and no existing name, try to get from AIS data
953 // or file
954 else if (m_props->m_ShipName == wxEmptyString) {
955 auto proptarget = g_pAIS->Get_Target_Data_From_MMSI(m_props->MMSI);
956 if (proptarget) {
957 wxString s = proptarget->GetFullName();
958 m_props->m_ShipName = s;
959 } else {
960 wxString GetShipNameFromFile(int);
961 m_props->m_ShipName = GetShipNameFromFile(m_props->MMSI);
962 }
963 }
964 }
965}
966
967void MMSIEditDialog::OnMMSIEditOKClick(wxCommandEvent& event) {
968 // Update the MmsiProperties by the passed pointer
969 if (m_props) {
970 long nmmsi;
971 m_MMSICtl->GetValue().ToLong(&nmmsi);
972 m_props->MMSI = nmmsi;
973 Persist();
974
975 if (m_MMSICtl->GetValue().Length() != 9) {
976 OCPNMessageDialog* dlg = new OCPNMessageDialog(
977 this,
978 _("An MMSI Id is generally a number of nine digits.\nPlease check "
979 "your entries and cancel if necessary."),
980 _("OpenCPN Info"), wxOK | wxCANCEL);
981
982 dlg->ShowWindowModalThenDo([this, dlg](int retcode) {
983 if (retcode == wxID_OK) {
984 Persist();
985 }
986 EndModal(retcode);
987 });
988 } else {
989 EndModal(wxID_OK);
990 }
991 }
992}
993
994void MMSIEditDialog::OnCtlUpdated(wxCommandEvent& event) {}
995
996void MMSIEditDialog::OnMMSIChanged(wxCommandEvent& event) {
997 wxString mmsi = m_MMSICtl->GetValue();
998
999 // Only proceed if we have a valid MMSI (9 digits)
1000 if (!mmsi.IsEmpty() && mmsi.Length() == 9 && mmsi.IsNumber()) {
1001 // First check for a stored name in mmsitoname.csv
1002 wxString shipName = g_pAIS->GetMMSItoNameEntry(mmsi);
1003
1004 // If no stored name found, try to get from AIS data
1005 if (shipName.IsEmpty()) {
1006 auto target = g_pAIS->Get_Target_Data_From_MMSI(wxAtoi(mmsi));
1007 if (target) {
1008 shipName = target->GetFullName();
1009 }
1010 }
1011
1012 // Update the ship name field if we found a name
1013 if (!shipName.IsEmpty()) {
1014 m_ShipNameCtl->SetValue(shipName);
1015 }
1016 }
1017
1018 event.Skip();
1019}
1020
1021BEGIN_EVENT_TABLE(MMSIListCtrl, wxListCtrl)
1022EVT_LIST_ITEM_SELECTED(ID_MMSI_PROPS_LIST, MMSIListCtrl::OnListItemClick)
1023EVT_LIST_ITEM_ACTIVATED(ID_MMSI_PROPS_LIST, MMSIListCtrl::OnListItemActivated)
1024EVT_LIST_ITEM_RIGHT_CLICK(ID_MMSI_PROPS_LIST,
1025 MMSIListCtrl::OnListItemRightClick)
1026EVT_MENU(ID_DEF_MENU_MMSI_EDIT, MMSIListCtrl::PopupMenuHandler)
1027EVT_MENU(ID_DEF_MENU_MMSI_DELETE, MMSIListCtrl::PopupMenuHandler)
1028END_EVENT_TABLE()
1029
1030MMSIListCtrl::MMSIListCtrl(wxWindow* parent, wxWindowID id, const wxPoint& pos,
1031 const wxSize& size, long style)
1032 : wxListCtrl(parent, id, pos, size, style) {
1033 m_parent = parent;
1034}
1035
1036MMSIListCtrl::~MMSIListCtrl() {}
1037
1038wxString MMSIListCtrl::OnGetItemText(long item, long column) const {
1039 wxString ret;
1040 MmsiProperties* props = g_MMSI_Props_Array[item];
1041
1042 if (!props) return ret;
1043 switch (column) {
1044 case mlMMSI:
1045 if (props->MMSI > 0) ret = wxString::Format("%d", props->MMSI);
1046 break;
1047 case mlTrackMode:
1048 switch (props->TrackType) {
1049 case TRACKTYPE_DEFAULT:
1050 ret = _("Default");
1051 break;
1052 case TRACKTYPE_ALWAYS:
1053 ret = _("Always");
1054 break;
1055 case TRACKTYPE_NEVER:
1056 ret = _("Never");
1057 break;
1058 default:
1059 ret = "???";
1060 }
1061 if (props->m_bPersistentTrack) ret.Append(", ").Append(_("Persistent"));
1062 break;
1063 case mlIgnore:
1064 if (props->m_bignore) ret = "X";
1065 break;
1066 case mlMOB:
1067 if (props->m_bMOB) ret = "X";
1068 break;
1069 case mlVDM:
1070 if (props->m_bVDM) ret = "X";
1071 break;
1072 case mlFollower:
1073 if (props->m_bFollower) ret = "X";
1074 break;
1075 case mlShipName:
1076 ret = props->m_ShipName;
1077 break;
1078 default:
1079 ret = "??";
1080 break;
1081 }
1082 return ret;
1083}
1084
1085void MMSIListCtrl::OnListItemClick(wxListEvent& event) {}
1086
1087void MMSIListCtrl::OnListItemActivated(wxListEvent& event) {
1088 MmsiProperties* props = g_MMSI_Props_Array.Item(event.GetIndex());
1089 MmsiProperties* props_new = new MmsiProperties(*props);
1090
1091 MMSIEditDialog* pd =
1092 new MMSIEditDialog(props_new, m_parent, -1, _("Edit MMSI Properties"),
1093 wxDefaultPosition, wxSize(200, 200));
1094
1095 if (pd->ShowModal() == wxID_OK) {
1096 g_MMSI_Props_Array.RemoveAt(event.GetIndex());
1097 delete props;
1098 g_MMSI_Props_Array.Insert(props_new, event.GetIndex());
1099 } else
1100 delete props_new;
1101
1102 pd->Destroy();
1103}
1104
1105void MMSIListCtrl::OnListItemRightClick(wxListEvent& event) {
1106 m_context_item = GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
1107 if (m_context_item == wxNOT_FOUND) return;
1108 wxMenu* menu = new wxMenu(_("MMSI Properties"));
1109
1110 wxMenuItem* item_edit =
1111 new wxMenuItem(menu, ID_DEF_MENU_MMSI_EDIT, _("Edit") + "...");
1112#ifdef __ANDROID__
1113 wxFont sFont = GetOCPNGUIScaledFont(_("Menu"));
1114 item_edit->SetFont(sFont);
1115#endif
1116 menu->Append(item_edit);
1117
1118 wxMenuItem* item_delete =
1119 new wxMenuItem(menu, ID_DEF_MENU_MMSI_DELETE, _("Delete"));
1120#ifdef __ANDROID__
1121 item_delete->SetFont(sFont);
1122#endif
1123 menu->Append(item_delete);
1124
1125#ifdef __WXMSW__
1126 wxFont* qFont = GetOCPNScaledFont(_("Menu"));
1127 item_edit->SetFont(*qFont);
1128 item_delete->SetFont(*qFont);
1129#endif
1130
1131 wxPoint p = ScreenToClient(wxGetMousePosition());
1132 PopupMenu(menu, p.x, p.y);
1133
1134 SetItemCount(g_MMSI_Props_Array.GetCount());
1135 Refresh(TRUE);
1136}
1137
1138void MMSIListCtrl::PopupMenuHandler(wxCommandEvent& event) {
1139 int context_item = m_context_item;
1140 MmsiProperties* props = g_MMSI_Props_Array[context_item];
1141
1142 if (!props) return;
1143
1144 switch (event.GetId()) {
1145 case ID_DEF_MENU_MMSI_EDIT: {
1146 MmsiProperties* props_new = new MmsiProperties(*props);
1147 MMSIEditDialog* pd =
1148 new MMSIEditDialog(props_new, m_parent, -1, _("Edit MMSI Properties"),
1149 wxDefaultPosition, wxSize(200, 200));
1150
1151 if (pd->ShowModal() == wxID_OK) {
1152 g_MMSI_Props_Array.RemoveAt(context_item);
1153 delete props;
1154 props_new->m_ShipName = GetShipNameFromFile(props_new->MMSI);
1155 g_MMSI_Props_Array.Insert(props_new, context_item);
1156 } else {
1157 delete props_new;
1158 }
1159 pd->Destroy();
1160
1161 if (g_options->pPropsPanel) g_options->pPropsPanel->UpdateMMSIList();
1162 break;
1163 }
1164 case ID_DEF_MENU_MMSI_DELETE:
1165 g_MMSI_Props_Array.RemoveAt(context_item);
1166 delete props;
1167
1168 if (g_options->pPropsPanel) g_options->pPropsPanel->UpdateMMSIList();
1169 break;
1170 }
1171}
1172
1173MMSI_Props_Panel::MMSI_Props_Panel(wxWindow* parent)
1174 : wxPanel(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize,
1175 wxBORDER_NONE) {
1176 m_pparent = parent;
1177
1178 wxFont* qFont = GetOCPNScaledFont(_("Dialog"));
1179 SetFont(*qFont);
1180
1181 wxBoxSizer* topSizer = new wxBoxSizer(wxVERTICAL);
1182 SetSizer(topSizer);
1183
1184 wxString MMSI_props_column_spec = "120;120;100;100;100;100;100;100";
1185 // Parse the global column width string as read from config file
1186 wxStringTokenizer tkz(MMSI_props_column_spec, ";");
1187 wxString s_width = tkz.GetNextToken();
1188 int width;
1189 long lwidth;
1190
1191 m_pListCtrlMMSI = new MMSIListCtrl(
1192 this, ID_MMSI_PROPS_LIST, wxDefaultPosition, wxSize(-1, -1),
1193 wxLC_REPORT | wxLC_SINGLE_SEL | wxLC_HRULES | wxLC_VRULES |
1194 wxBORDER_SUNKEN);
1195 // wxImageList* imglist = new wxImageList(16, 16, TRUE, 2);
1196
1197 ocpnStyle::Style* style = g_StyleManager->GetCurrentStyle();
1198 // imglist->Add(style->GetIcon("sort_asc"));
1199 // imglist->Add(style->GetIcon("sort_desc"));
1200
1201 // m_pListCtrlMMSI->AssignImageList( imglist, wxIMAGE_LIST_SMALL );
1202 int dx = GetCharWidth();
1203#ifdef __ANDROID__
1204 GetTextExtent("W", &dx, NULL, NULL, NULL, qFont);
1205#endif
1206
1207 m_pListCtrlMMSI->InsertColumn(mlMMSI, _("MMSI"), wxLIST_FORMAT_LEFT, dx * 10);
1208 m_pListCtrlMMSI->InsertColumn(mlTrackMode, _("Track Mode"),
1209 wxLIST_FORMAT_CENTER, dx * 20);
1210 m_pListCtrlMMSI->InsertColumn(mlIgnore, _("Ignore"), wxLIST_FORMAT_CENTER,
1211 dx * 7);
1212 m_pListCtrlMMSI->InsertColumn(mlMOB, _("MOB"), wxLIST_FORMAT_CENTER, dx * 5);
1213 m_pListCtrlMMSI->InsertColumn(mlVDM, _("VDM->VDO"), wxLIST_FORMAT_CENTER,
1214 dx * 10);
1215 m_pListCtrlMMSI->InsertColumn(mlShipName, _("Ship name"),
1216 wxLIST_FORMAT_CENTER, dx * 20);
1217 m_pListCtrlMMSI->InsertColumn(mlFollower, _("Follower"), wxLIST_FORMAT_CENTER,
1218 dx * 9); // Has
1219
1220 topSizer->Add(m_pListCtrlMMSI, 1, wxEXPAND | wxALL, 0);
1221
1222 m_pButtonNew = new wxButton(this, wxID_ANY, _("New..."), wxDefaultPosition,
1223 wxSize(200, -1));
1224 m_pButtonNew->Connect(wxEVT_COMMAND_BUTTON_CLICKED,
1225 wxCommandEventHandler(MMSI_Props_Panel::OnNewButton),
1226 NULL, this);
1227 topSizer->Add(m_pButtonNew, 0, wxALIGN_RIGHT | wxALL, 0);
1228
1229 topSizer->Layout();
1230
1231 // This is silly, but seems to be required for __WXMSW__ build
1232 // If not done, the SECOND invocation of the panel fails to expand the list
1233 // to the full wxSizer size....
1234 SetSize(GetSize().x, GetSize().y - 1);
1235
1236 SetColorScheme(GLOBAL_COLOR_SCHEME_RGB);
1237}
1238
1239MMSI_Props_Panel::~MMSI_Props_Panel() {}
1240
1241void MMSI_Props_Panel::OnNewButton(wxCommandEvent& event) {
1242 MmsiProperties* props = new MmsiProperties(-1);
1243
1244 MMSIEditDialog* pd =
1245 new MMSIEditDialog(props, m_parent, -1, _("Add MMSI Properties"),
1246 wxDefaultPosition, wxSize(200, 200));
1247
1248 DimeControl(pd);
1249 if (pd->ShowModal() == wxID_OK) {
1250 g_MMSI_Props_Array.Add(props);
1251 } else
1252 delete props;
1253
1254 UpdateMMSIList();
1255}
1256
1257void MMSI_Props_Panel::UpdateMMSIList() {
1258 // Capture the MMSI of the curently selected list item
1259 long selItemID = wxNOT_FOUND;
1260 m_pListCtrlMMSI->GetNextItem(selItemID, wxLIST_NEXT_ALL,
1261 wxLIST_STATE_SELECTED);
1262
1263 int selMMSI = wxNOT_FOUND;
1264 if (selItemID != wxNOT_FOUND) selMMSI = g_MMSI_Props_Array[selItemID]->MMSI;
1265
1266 m_pListCtrlMMSI->DeleteAllItems();
1267
1268 for (size_t i = 0; i < g_MMSI_Props_Array.GetCount(); i++) {
1269 wxListItem item;
1270 item.SetId(i);
1271 m_pListCtrlMMSI->InsertItem(item);
1272 for (int j = 0; j < mlFollower + 1; j++) {
1273 item.SetColumn(j);
1274 item.SetText(m_pListCtrlMMSI->OnGetItemText(i, j));
1275 m_pListCtrlMMSI->SetItem(item);
1276 }
1277 }
1278
1279 // Restore selected item
1280 long item_sel = wxNOT_FOUND;
1281 if (selItemID != wxNOT_FOUND && selMMSI != wxNOT_FOUND) {
1282 for (unsigned int i = 0; i < g_MMSI_Props_Array.GetCount(); i++) {
1283 if (g_MMSI_Props_Array[i]->MMSI == selMMSI) {
1284 item_sel = i;
1285 break;
1286 }
1287 }
1288 }
1289
1290 if (g_MMSI_Props_Array.GetCount() > 0)
1291 m_pListCtrlMMSI->SetItemState(item_sel,
1292 wxLIST_STATE_SELECTED | wxLIST_STATE_FOCUSED,
1293 wxLIST_STATE_SELECTED | wxLIST_STATE_FOCUSED);
1294
1295#ifdef __WXMSW__
1296 m_pListCtrlMMSI->Refresh(FALSE);
1297#endif
1298}
1299
1300void MMSI_Props_Panel::SetColorScheme(ColorScheme cs) { DimeControl(this); }
1301
1302// WX_DECLARE_OBJARRAY(wxBitmap, ArrayOfBitmaps);
1303// #include <wx/arrimpl.cpp>
1304// WX_DEFINE_OBJARRAY(ArrayOfBitmaps);
1305
1306class OCPNFatCombo : public wxOwnerDrawnComboBox {
1307public:
1308 OCPNFatCombo();
1309
1310 OCPNFatCombo(wxWindow* parent, wxWindowID id, const wxString& value = "",
1311 const wxPoint& pos = wxDefaultPosition,
1312 const wxSize& size = wxDefaultSize, int n = 0,
1313 const wxString choices[] = NULL, long style = 0,
1314 const wxValidator& validator = wxDefaultValidator,
1315 const wxString& name = "OCPNFatCombo");
1316
1317 ~OCPNFatCombo();
1318
1319 void OnDrawItem(wxDC& dc, const wxRect& rect, int item, int flags) const;
1320 wxCoord OnMeasureItem(size_t item) const;
1321 wxCoord OnMeasureItemWidth(size_t item) const;
1322 bool SetFont(const wxFont& font);
1323
1324 int Append(const wxString& item, wxBitmap bmp);
1325 void Clear();
1326
1327 const wxFont* dfont;
1328
1329private:
1330 int itemHeight;
1331 ArrayOfBitmaps bmpArray;
1332};
1333
1334OCPNFatCombo::OCPNFatCombo() : wxOwnerDrawnComboBox() {}
1335
1336OCPNFatCombo::OCPNFatCombo(wxWindow* parent, wxWindowID id,
1337 const wxString& value, const wxPoint& pos,
1338 const wxSize& size, int n, const wxString choices[],
1339 long style, const wxValidator& validator,
1340 const wxString& name)
1341 : wxOwnerDrawnComboBox(parent, id, value, pos, size, n, choices, style,
1342 validator, name) {
1343 double fontHeight =
1344 GetFont().GetPointSize() / g_Platform->getFontPointsperPixel();
1345 itemHeight = (int)wxRound(fontHeight);
1346 SetPopupMaxHeight(::wxGetDisplaySize().y / 2);
1347}
1348
1349OCPNFatCombo::~OCPNFatCombo() {}
1350
1351bool OCPNFatCombo::SetFont(const wxFont& font) {
1352 dfont = &font;
1353 return true;
1354}
1355
1356void OCPNFatCombo::OnDrawItem(wxDC& dc, const wxRect& rect, int item,
1357 int flags) const {
1358 int offset_x = 10;
1359 // dc.DrawBitmap(bmpArray.Item(item), rect.x, rect.y + (rect.height -
1360 // bmpHeight)/2, true);
1361 dc.SetFont(*dfont);
1362
1363 wxColor bg = wxSystemSettings::GetColour(wxSYS_COLOUR_LISTBOX);
1364 wxBrush br = wxBrush(bg);
1365 wxBrush sv = dc.GetBrush();
1366 dc.SetBrush(br);
1367 dc.DrawRectangle(0, 0, rect.width, rect.height);
1368 dc.SetBrush(sv);
1369 dc.SetTextForeground(wxColour(0, 0, 0));
1370
1371 if (flags & wxODCB_PAINTING_CONTROL) {
1372 wxString text = GetValue();
1373 int margin_x = 2;
1374 dc.DrawText(text, rect.x + margin_x + offset_x,
1375 (rect.height - dc.GetCharHeight()) / 2 + rect.y);
1376 } else {
1377 dc.SetBackground(wxBrush(br));
1378 dc.Clear();
1379 dc.DrawText(GetVListBoxComboPopup()->GetString(item), rect.x + 2 + offset_x,
1380 (rect.height - dc.GetCharHeight()) / 2 + rect.y);
1381 }
1382}
1383
1384wxCoord OCPNFatCombo::OnMeasureItem(size_t item) const {
1385 if (item < bmpArray.GetCount())
1386 return wxMax(itemHeight, bmpArray.Item(item).GetHeight());
1387
1388 return itemHeight * 12 / 10;
1389}
1390
1391wxCoord OCPNFatCombo::OnMeasureItemWidth(size_t item) const { return -1; }
1392
1393int OCPNFatCombo::Append(const wxString& item, wxBitmap bmp) {
1394 bmpArray.Add(bmp);
1395 int idx = wxOwnerDrawnComboBox::Append(item);
1396
1397 return idx;
1398}
1399
1400void OCPNFatCombo::Clear() {
1401 wxOwnerDrawnComboBox::Clear();
1402 bmpArray.Clear();
1403}
1404
1405BEGIN_EVENT_TABLE(options, wxDialog)
1406EVT_INIT_DIALOG(options::OnDialogInit)
1407EVT_CHECKBOX(ID_DEBUGCHECKBOX1, options::OnDebugcheckbox1Click)
1408EVT_BUTTON(ID_BUTTONADD, options::OnButtonaddClick)
1409EVT_BUTTON(ID_BUTTONDELETE, options::OnButtondeleteClick)
1410EVT_BUTTON(ID_PARSEENCBUTTON, options::OnButtonParseENC)
1411EVT_BUTTON(ID_REBUILDBUTTON, options::OnButtonRebuildChartDb)
1412EVT_BUTTON(ID_BUTTONCOMPRESS, options::OnButtoncompressClick)
1413EVT_BUTTON(ID_BUTTONMIGRATE, options::OnButtonmigrateClick)
1414EVT_BUTTON(ID_TCDATAADD, options::OnInsertTideDataLocation)
1415EVT_BUTTON(ID_TCDATADEL, options::OnRemoveTideDataLocation)
1416EVT_BUTTON(ID_APPLY, options::OnApplyClick)
1417EVT_BUTTON(xID_OK, options::OnXidOkClick)
1418EVT_BUTTON(wxID_CANCEL, options::OnCancelClick)
1419EVT_BUTTON(ID_BUTTONFONTCHOOSE, options::OnChooseFont)
1420EVT_BUTTON(ID_BUTTONFONT_RESET, options::OnResetFont)
1421EVT_BUTTON(ID_BUTTONECDISHELP, options::OnButtonEcdisHelp)
1422
1423EVT_CHOICE(ID_CHOICE_FONTELEMENT, options::OnFontChoice)
1424EVT_CLOSE(options::OnClose)
1425
1426#if defined(__WXGTK__) || defined(__WXQT__)
1427EVT_BUTTON(ID_BUTTONFONTCOLOR, options::OnChooseFontColor)
1428#endif
1429#ifdef ocpnUSE_GL
1430EVT_BUTTON(ID_OPENGLOPTIONS, options::OnOpenGLOptions)
1431#endif
1432EVT_CHOICE(ID_RADARDISTUNIT, options::OnDisplayCategoryRadioButton)
1433EVT_CHOICE(ID_DEPTHUNITSCHOICE, options::OnUnitsChoice)
1434EVT_CHOICE(ID_HEIGHTUNITSCHOICE, options::OnUnitsChoice)
1435EVT_BUTTON(ID_CLEARLIST, options::OnButtonClearClick)
1436EVT_BUTTON(ID_SELECTLIST, options::OnButtonSelectClick)
1437EVT_BUTTON(ID_SETSTDLIST, options::OnButtonSetStd)
1438EVT_CHOICE(ID_SHIPICONTYPE, options::OnShipTypeSelect)
1439EVT_CHOICE(ID_RADARRINGS, options::OnRadarringSelect)
1440EVT_CHOICE(ID_OPWAYPOINTRANGERINGS, options::OnWaypointRangeRingSelect)
1441EVT_CHAR_HOOK(options::OnCharHook)
1442
1443END_EVENT_TABLE()
1444
1445options::options(wxWindow* parent, OptionsCallbacks callbacks, wxWindowID id,
1446 const wxString& caption, const wxPoint& pos,
1447 const wxSize& size, long style)
1448 : pTrackRotateTime(0), m_callbacks(callbacks) {
1449 Init();
1450
1451 pParent = parent;
1452
1453 SetExtraStyle(wxWS_EX_BLOCK_EVENTS);
1454
1455 wxDialog::Create(parent, id, caption, pos, size, style, "Options");
1456 SetFont(*dialogFont);
1457
1458 CreateControls();
1459 RecalculateSize(size.x, size.y);
1460
1461 wxDEFINE_EVENT(EVT_COMPAT_OS_CHANGE, wxCommandEvent);
1462 obs::GlobalVar<wxString> compat_os(&g_compatOS);
1463 compat_os_listener.Listen(compat_os, this, EVT_COMPAT_OS_CHANGE);
1464 Bind(EVT_COMPAT_OS_CHANGE, [&](wxCommandEvent&) {
1465 PluginLoader::GetInstance()->LoadAllPlugIns(false);
1466 m_pPlugInCtrl->ReloadPluginPanels();
1467 });
1468 auto action = [&](wxCommandEvent& evt) {
1469 g_persist_active_route = m_persist_active_route_chkbox->IsChecked();
1470 };
1471 m_persist_active_route_chkbox->Bind(wxEVT_CHECKBOX, action);
1472 m_persist_active_route_chkbox->SetValue(g_persist_active_route);
1473 OnColorChange();
1474
1475 m_OnChartDb_finalize_listener.Init(
1476 GuiEvents::GetInstance().on_finalize_chartdbs,
1477 [&](ObservedEvt& ev) { OptionsFinalizeChartDBUpdate(); });
1478 Bind(wxEVT_SYS_COLOUR_CHANGED,
1479 [&](wxSysColourChangedEvent& ev) { OnColorChange(ev); });
1480}
1481
1482options::~options() {
1483 wxNotebook* nb =
1484 dynamic_cast<wxNotebook*>(m_pListbook->GetPage(m_pageCharts));
1485 if (nb)
1486 nb->Disconnect(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED,
1487 wxListbookEventHandler(options::OnChartsPageChange), NULL,
1488 this);
1489
1490 groupsPanel->EmptyChartGroupArray(m_pGroupArray);
1491
1492 delete m_pSerialArray;
1493 delete m_pGroupArray;
1494 delete m_topImgList;
1495
1496 // Take care of the plugin manager...
1497
1498 delete m_pPlugInCtrl;
1499 if (g_pi_manager) g_pi_manager->SetListPanelPtr(NULL);
1500#ifndef __ANDROID__
1501 delete m_PluginCatalogMgrPanel;
1502#endif
1503}
1504
1505#ifdef OCPN_OPTIONS_USE_LISTBOOK
1506void options::OnColorChange() {
1507 auto foreground = wxSystemSettings::GetColour(wxSYS_COLOUR_MENUTEXT);
1508 auto background = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW);
1509 m_pListbook->GetListView()->SetBackgroundColour(background);
1510 m_pListbook->GetListView()->SetForegroundColour(foreground);
1511}
1512#else
1513void options::OnColorChange() {}
1514#endif
1515
1516void options::OnColorChange(wxSysColourChangedEvent& ev) {
1517 OnColorChange();
1518 ev.Skip();
1519}
1520
1521// with AIS it's called very often
1522bool options::SendIdleEvents(wxIdleEvent& event) {
1523 if (IsShown()) return wxDialog::SendIdleEvents(event);
1524 return false;
1525}
1526
1527void options::OptionsFinalizeChartDBUpdate() {
1528 if (m_pWorkDirList)
1529 m_CurrentDirList =
1530 *m_pWorkDirList; // Perform a deep copy back to main database.
1531 // Re-enable RNC texture caching
1532 g_GLOptions.m_bTextureCompressionCaching = m_bTextureCacheingSave;
1533
1534 m_OKButton->Enable();
1535 m_CancelButton->Enable();
1536 m_ApplyButton->Enable();
1537}
1538
1539void options::RecalculateSize(int hint_x, int hint_y) {
1540 if (!g_bresponsive) {
1541 m_nCharWidthMax = GetSize().x / GetCharWidth();
1542
1543 // Protect against unreasonable small size
1544 // And also handle the empty config file init case.
1545 if ((hint_x < 200) || (hint_y < 200)) {
1546 // Constrain size on small displays
1547 int display_width, display_height;
1548 display_width = g_monitor_info[g_current_monitor].width;
1549 display_height = g_monitor_info[g_current_monitor].height;
1550
1551 if (display_height < 600) {
1552 SetSize(wxSize(GetOCPNCanvasWindow()->GetSize()));
1553 } else {
1554 vectorPanel->SetSizeHints(ps57Ctl);
1555 Fit();
1556 }
1557 }
1558
1559 CenterOnScreen();
1560 return;
1561 }
1562
1563 wxSize esize;
1564 esize.x = GetCharWidth() * 110;
1565 esize.y = GetCharHeight() * 40;
1566
1567 wxSize dsize = GetParent()->GetSize(); // GetClientSize();
1568 esize.y = wxMin(esize.y, dsize.y - 0 /*(2 * GetCharHeight())*/);
1569 esize.x = wxMin(esize.x, dsize.x - 0 /*(2 * GetCharHeight())*/);
1570 SetSize(esize);
1571
1572 wxSize fsize = GetSize();
1573 wxSize canvas_size = GetParent()->GetSize();
1574 wxPoint screen_pos = GetParent()->GetScreenPosition();
1575 int xp = (canvas_size.x - fsize.x) / 2;
1576 int yp = (canvas_size.y - fsize.y) / 2;
1577 Move(screen_pos.x + xp, screen_pos.y + yp);
1578
1579 m_nCharWidthMax = GetSize().x / GetCharWidth();
1580}
1581
1582void options::Init() {
1583 m_pWorkDirList = NULL;
1584
1585 pShowStatusBar = NULL;
1586 pShowMenuBar = NULL;
1587 pShowCompassWin = NULL;
1588 pSelCtl = NULL;
1589 // pActiveChartsList = NULL;
1590 m_scrollWinChartList = NULL;
1591 ps57CtlListBox = NULL;
1592 pDispCat = NULL;
1593 m_pSerialArray = NULL;
1594 pUpdateCheckBox = NULL;
1595 pParseENCButton = NULL;
1596 k_charts = 0;
1597 k_vectorcharts = 0;
1598 k_plugins = 0;
1599 m_pConfig = NULL;
1600
1601 pSoundDeviceIndex = NULL;
1602
1603 pCBNorthUp = NULL;
1604 pCBCourseUp = NULL;
1605 pCBLookAhead = NULL;
1606 pCDOQuilting = NULL;
1607 pPreserveScale = NULL;
1608 pSmoothPanZoom = NULL;
1609 pEnableZoomToCursor = NULL;
1610 m_Text_def_boat_speed = NULL;
1611
1612 pSDisplayGrid = NULL;
1613 pCDOOutlines = NULL;
1614 pSDepthUnits = NULL;
1615 pSLiveETA = NULL;
1616 pSDefaultBoatSpeed = NULL;
1617
1618 activeSizer = NULL;
1619 itemActiveChartStaticBox = NULL;
1620
1621 pCheck_SOUNDG = NULL;
1622 pCheck_META = NULL;
1623 pCheck_SHOWIMPTEXT = NULL;
1624 pCheck_SCAMIN = NULL;
1625 pCheck_ATONTEXT = NULL;
1626 pCheck_LDISTEXT = NULL;
1627 pCheck_XLSECTTEXT = NULL;
1628
1629 m_bVisitLang = FALSE;
1630 m_bVisitPlugins = FALSE;
1631 m_itemFontElementListBox = NULL;
1632 m_textSample = NULL;
1633 m_topImgList = NULL;
1634
1635 m_pListbook = NULL;
1636 m_pGroupArray = NULL;
1637 m_groups_changed = 0;
1638
1639 m_pageDisplay = -1;
1640 m_pageConnections = -1;
1641 m_pageCharts = -1;
1642 m_pageShips = -1;
1643 m_pageUI = -1;
1644 m_pagePlugins = -1;
1645 m_pageConnections = -1;
1646
1647 pEnableTenHertz = nullptr;
1648
1649 auto loader = PluginLoader::GetInstance();
1650 b_haveWMM = loader && loader->IsPlugInAvailable("WMM");
1651 b_oldhaveWMM = b_haveWMM;
1652
1653 lastPage = 0;
1654 m_bneedNew = false;
1655
1656 m_bForceNewToolbaronCancel = false;
1657
1658 m_cs = (ColorScheme)0;
1659
1660 // for deferred loading
1661 m_pPlugInCtrl = NULL;
1662 m_PluginCatalogMgrPanel = NULL;
1663
1664 m_pNMEAForm = NULL;
1665 // FIXME Do this in CTOR of connections dialog
1666 // mSelectedConnection = NULL;
1667
1668#ifdef __ANDROID__
1669 m_scrollRate = 1;
1670#else
1671 m_scrollRate = 15;
1672#endif
1673
1674 dialogFont = GetOCPNScaledFont(_("Dialog"));
1675
1676 m_bVectorInit = false;
1677
1678 // This variable is used by plugin callback function AddOptionsPage
1679 g_pOptions = this;
1680
1681 pCmdSoundString = NULL;
1682
1683 m_sconfigSelect_single = NULL;
1684 m_sconfigSelect_twovertical = NULL;
1685
1686 wxScreenDC dc;
1687 dc.SetFont(*dialogFont);
1688 int width, height;
1689 dc.GetTextExtent("H", &width, &height, NULL, NULL, dialogFont);
1690
1691 m_colourPickerDefaultSize =
1692 wxSize(4 * height, height * 2 * OCPN_GetWinDIPScaleFactor());
1693
1694 m_bcompact = false;
1695
1696 // wxSize dSize = g_Platform->getDisplaySize();
1697 // if ( dSize.x < width * 40)
1698 // m_bcompact = true;
1699
1700 double dsizemm = g_Platform->GetDisplaySizeMM();
1701 if (dsizemm < 80) // Probably and Android Phone, portrait mode
1702 m_bcompact = true;
1703
1704 auto sound_action = [](ObservedEvt ev) {
1705 auto sound = static_cast<o_sound::Sound*>(ev.GetClientData());
1706
1707 delete sound;
1708 };
1709 m_sound_done_listener.Init(m_on_sound_done, sound_action);
1710}
1711
1712// Distance format mapping helper functions
1714 wxString label;
1715 int enumValue;
1716};
1717
1718static const DistanceFormatMapping kDistanceFormats[] = {
1719 {_("Nautical miles"), DISTANCE_NMI},
1720 {_("Statute miles"), DISTANCE_MI},
1721 {_("Kilometers"), DISTANCE_KM},
1722 {_("Meters"), DISTANCE_M}};
1723
1724static const int kNumDistanceFormats =
1725 sizeof(kDistanceFormats) / sizeof(DistanceFormatMapping);
1726
1727// Get the index for a given distance format enum value
1728static int GetDistanceFormatIndex(int enumValue) {
1729 for (int i = 0; i < kNumDistanceFormats; i++) {
1730 if (kDistanceFormats[i].enumValue == enumValue) {
1731 return i;
1732 }
1733 }
1734 return 0; // Default to NMi
1735}
1736
1737// Get the enum value for a given index
1738static int GetDistanceFormatEnum(int index) {
1739 if (index >= 0 && index < kNumDistanceFormats) {
1740 return kDistanceFormats[index].enumValue;
1741 }
1742 return DISTANCE_NMI; // Default to NMi
1743}
1744
1745#if defined(__GNUC__) && __GNUC__ < 8
1746// Handle old gcc C++-11 bugs, remove when builders updated to gcc >= 8.1.1.
1747
1748static const wxString BAD_ACCESS_MSG = _(
1749 "The device selected is not accessible; opencpn will likely not be able\n"
1750 "to use this device as-is. You might want to exit OpenCPN, reboot and\n"
1751 "retry after creating a file called /etc/udev/rules.d/70-opencpn.rules\n"
1752 "with the following contents:\n\n"
1753 " KERNEL==\"ttyUSB*\", MODE=\"0666\"\n"
1754 " KERNEL==\"ttyACM*\", MODE=\"0666\"\n"
1755 " KERNEL==\"ttyS*\", MODE=\"0666\"\n\n"
1756 "For more info, see the file LINUX_DEVICES.md in the distribution docs.\n");
1757
1758#else
1759
1760static const wxString BAD_ACCESS_MSG = _(R"(
1761The device selected is not accessible; opencpn will likely not be able
1762to use this device as-is. You might want to exit OpenCPN, reboot and
1763retry after creating a file called /etc/udev/rules.d/70-opencpn.rules
1764with the following contents:
1765
1766 KERNEL=="ttyUSB*", MODE="0666"
1767 KERNEL=="ttyACM*", MODE="0666"
1768 KERNEL=="ttyS*", MODE="0666"
1769
1770For more info, see the file LINUX_DEVICES.md in the distribution docs.
1771)");
1772
1773#endif // defined(__GNUC__) && __GNUC__ < 8
1774
1775void options::OnDialogInit(wxInitDialogEvent& event) {}
1776
1777void options::CheckDeviceAccess(/*[[maybe_unused]]*/ wxString& path) {}
1778
1779size_t options::CreatePanel(const wxString& title) {
1780 size_t id = m_pListbook->GetPageCount();
1781 /* This is the default empty content for any top tab.
1782 It'll be replaced when we call AddPage */
1783 wxPanel* panel = new wxPanel(m_pListbook, wxID_ANY, wxDefaultPosition,
1784 wxDefaultSize, wxTAB_TRAVERSAL, title);
1785 m_pListbook->AddPage(panel, title, FALSE, id);
1786 return id;
1787}
1788
1789wxScrolledWindow* options::AddPage(size_t parent, const wxString& title) {
1790 if (parent > m_pListbook->GetPageCount() - 1) {
1791 wxLogMessage(
1792 wxString::Format("Warning: invalid parent in options::AddPage( %d, ",
1793 parent) +
1794 title + " )");
1795 return NULL;
1796 }
1797 wxNotebookPage* page = m_pListbook->GetPage(parent);
1798 wxNotebook* nb;
1799 wxScrolledWindow* sw;
1800
1801 int style = wxVSCROLL | wxTAB_TRAVERSAL;
1802 if ((nb = dynamic_cast<wxNotebook*>(page))) {
1803 // Check and avoid adding duplicate
1804 for (size_t i_page = 0; i_page < nb->GetPageCount(); i_page++) {
1805 wxString candidate_title = nb->GetPageText(i_page);
1806 if (candidate_title.IsSameAs(title))
1807 return static_cast<wxScrolledWindow*>(nb->GetPage(i_page));
1808 }
1809
1810 sw = new wxScrolledWindow(page, wxID_ANY, wxDefaultPosition, wxDefaultSize,
1811 style);
1812 sw->SetScrollRate(m_scrollRate, m_scrollRate);
1813 nb->AddPage(sw, title);
1814 } else if ((sw = dynamic_cast<wxScrolledWindow*>(page))) {
1815 wxString toptitle = m_pListbook->GetPageText(parent);
1816 wxNotebook* nb = new wxNotebook(m_pListbook, wxID_ANY, wxDefaultPosition,
1817 wxDefaultSize, wxNB_TOP);
1818 /* Only remove the tab from listbook, we still have original content in
1819 * {page} */
1820 m_pListbook->InsertPage(parent, nb, toptitle, FALSE, parent);
1821 m_pListbook->SetSelection(0); // avoid gtk assertions
1822 m_pListbook->RemovePage(parent + 1);
1823 wxString previoustitle = page->GetName();
1824 page->Reparent(nb);
1825 nb->Connect(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED,
1826 wxNotebookEventHandler(options::OnSubNBPageChange), NULL, this);
1827
1828 nb->AddPage(page, previoustitle);
1829 /* wxNotebookPage is hidden under wxGTK after RemovePage/Reparent
1830 * we must explicitely Show() it */
1831 page->Show();
1832 sw = new wxScrolledWindow(nb, wxID_ANY, wxDefaultPosition, wxDefaultSize,
1833 style);
1834 sw->SetScrollRate(m_scrollRate, m_scrollRate);
1835 nb->AddPage(sw, title);
1836 nb->ChangeSelection(0);
1837 } else { // This is the default content, we can replace it now
1838 sw = new wxScrolledWindow(m_pListbook, wxID_ANY, wxDefaultPosition,
1839 wxDefaultSize, style, title);
1840 sw->SetScrollRate(m_scrollRate, m_scrollRate);
1841 wxString toptitle = m_pListbook->GetPageText(parent);
1842 m_pListbook->InsertPage(parent, sw, toptitle, FALSE, parent);
1843 m_pListbook->SetSelection(0); // avoid gtk assertions
1844 m_pListbook->DeletePage(parent + 1);
1845 }
1846
1847#ifdef __ANDROID__
1848 sw->GetHandle()->setStyleSheet(getAdjustedDialogStyleSheet());
1849#endif
1850
1851 return sw;
1852}
1853
1854bool options::DeletePluginPage(wxScrolledWindow* page) {
1855 for (size_t i = 0; i < m_pListbook->GetPageCount(); i++) {
1856 wxNotebookPage* pg = m_pListbook->GetPage(i);
1857 auto nb = dynamic_cast<wxNotebook*>(pg);
1858
1859 if (nb) {
1860 for (size_t j = 0; j < nb->GetPageCount(); j++) {
1861 wxNotebookPage* spg = nb->GetPage(j);
1862 if (spg == page) {
1863 nb->DeletePage(j);
1864 if (nb->GetPageCount() != 1) return TRUE;
1865 /* There's only one page, remove inner notebook */
1866 spg = nb->GetPage(0);
1867 spg->Reparent(m_pListbook);
1868 nb->RemovePage(0);
1869 wxString toptitle = m_pListbook->GetPageText(i);
1870 m_pListbook->DeletePage(i);
1871 m_pListbook->InsertPage(i, spg, toptitle, FALSE, i);
1872 return TRUE;
1873 }
1874 }
1875 } else if (pg == page) {
1876 /* There's only one page, replace it with empty panel */
1877 m_pListbook->DeletePage(i);
1878 wxPanel* panel = new wxPanel(m_pListbook);
1879 wxString toptitle = m_pListbook->GetPageText(i);
1880 m_pListbook->InsertPage(i, panel, toptitle, FALSE, i);
1881 return TRUE;
1882 }
1883 }
1884 return FALSE;
1885}
1886
1887void options::CreatePanel_NMEA(size_t position, int border_size,
1888 int group_item_spacing) {
1889 assert(position < m_pListbook->GetPageCount() &&
1890 "Illegal NMEA window position");
1891 auto panel = new wxPanel(m_pListbook, wxID_ANY);
1892 wxString title = m_pListbook->GetPageText(position);
1893 m_pListbook->InsertPage(position, panel, title, false, position);
1894 m_pListbook->SetSelection(0); // avoid gtk assertions
1895 m_pListbook->DeletePage(position + 1);
1896 m_pNMEAForm = panel;
1897
1898 comm_dialog = new ConnectionsDlg(m_pNMEAForm, TheConnectionParams());
1899 auto vbox = new wxBoxSizer(wxVERTICAL);
1900 vbox->Add(comm_dialog, wxSizerFlags(1).Expand());
1901 m_pNMEAForm->SetSizer(vbox);
1902 m_pNMEAForm->Layout();
1903#ifdef __ANDROID__
1904 comm_dialog->GetHandle()->setStyleSheet(getAdjustedDialogStyleSheet());
1905#endif
1906}
1907
1908void options::CreatePanel_Ownship(size_t parent, int border_size,
1909 int group_item_spacing) {
1910 itemPanelShip = AddPage(parent, _("Own ship"));
1911
1912 ownShip = new wxBoxSizer(wxVERTICAL);
1913 itemPanelShip->SetSizer(ownShip);
1914
1915 // OwnShip Display options
1916 wxStaticBox* osdBox =
1917 new wxStaticBox(itemPanelShip, wxID_ANY, _("Display Options"));
1918 dispOptions = new wxStaticBoxSizer(osdBox, wxVERTICAL);
1919 ownShip->Add(dispOptions, 0, wxTOP | wxALL | wxEXPAND, border_size);
1920
1921 wxFlexGridSizer* dispOptionsGrid =
1922 new wxFlexGridSizer(0, 2, group_item_spacing, group_item_spacing);
1923 dispOptionsGrid->AddGrowableCol(1);
1924 dispOptions->Add(dispOptionsGrid, 0, wxALL | wxEXPAND, border_size);
1925
1926 wxStaticText* pStatic_OSCOG_Predictor = new wxStaticText(
1927 itemPanelShip, wxID_ANY, _("COG Predictor Length (min)"));
1928 dispOptionsGrid->Add(pStatic_OSCOG_Predictor, 0);
1929
1930 m_pText_OSCOG_Predictor = new wxTextCtrl(itemPanelShip, wxID_ANY, "TEXT");
1931 dispOptionsGrid->Add(m_pText_OSCOG_Predictor, 0, wxALIGN_RIGHT);
1932
1933 wxStaticText* pStatic_OSHDT_Predictor = new wxStaticText(
1934 itemPanelShip, wxID_ANY, _("Heading Predictor Length (NMi)"));
1935 dispOptionsGrid->Add(pStatic_OSHDT_Predictor, 0);
1936
1937 m_pText_OSHDT_Predictor = new wxTextCtrl(itemPanelShip, wxID_ANY, "TEXT");
1938 dispOptionsGrid->Add(m_pText_OSHDT_Predictor, 0, wxALIGN_RIGHT);
1939
1940 wxStaticText* iconTypeTxt =
1941 new wxStaticText(itemPanelShip, wxID_ANY, _("Ship Icon Type"));
1942 dispOptionsGrid->Add(iconTypeTxt, 0);
1943
1944 wxString iconTypes[] = {_("Default"), _("Real Scale Bitmap"),
1945 _("Real Scale Vector")};
1946
1947 m_pShipIconType = new wxChoice(
1948 itemPanelShip, ID_SHIPICONTYPE, wxDefaultPosition,
1949 wxSize(GetCharWidth() * 20, GetCharHeight() * 2), 3, iconTypes);
1950 dispOptionsGrid->Add(m_pShipIconType, 0,
1951 wxALIGN_RIGHT | wxLEFT | wxRIGHT | wxTOP,
1952 group_item_spacing);
1953
1954 realSizes = new wxFlexGridSizer(5, 2, group_item_spacing, group_item_spacing);
1955 realSizes->AddGrowableCol(1);
1956
1957 dispOptions->Add(realSizes, 0, wxEXPAND | wxLEFT, 30);
1958
1959 realSizes->Add(
1960 new wxStaticText(itemPanelShip, wxID_ANY, _("Length Over All (m)")), 1,
1961 wxALIGN_LEFT);
1962 m_pOSLength = new wxTextCtrl(itemPanelShip, 1, "TEXT ");
1963 realSizes->Add(m_pOSLength, 1, wxALIGN_RIGHT | wxALL, group_item_spacing);
1964
1965 realSizes->Add(
1966 new wxStaticText(itemPanelShip, wxID_ANY, _("Width Over All (m)")), 1,
1967 wxALIGN_LEFT);
1968 m_pOSWidth = new wxTextCtrl(itemPanelShip, wxID_ANY, "TEXT ");
1969 realSizes->Add(m_pOSWidth, 1, wxALIGN_RIGHT | wxALL, group_item_spacing);
1970
1971 realSizes->Add(
1972 new wxStaticText(itemPanelShip, wxID_ANY, _("GPS Offset from Bow (m)")),
1973 1, wxALIGN_LEFT);
1974 m_pOSGPSOffsetY = new wxTextCtrl(itemPanelShip, wxID_ANY, "TEXT ");
1975 realSizes->Add(m_pOSGPSOffsetY, 1, wxALIGN_RIGHT | wxALL, group_item_spacing);
1976
1977 realSizes->Add(new wxStaticText(itemPanelShip, wxID_ANY,
1978 _("GPS Offset from Midship (m)")),
1979 1, wxALIGN_LEFT);
1980 m_pOSGPSOffsetX = new wxTextCtrl(itemPanelShip, wxID_ANY, "TEXT ");
1981 realSizes->Add(m_pOSGPSOffsetX, 1, wxALIGN_RIGHT | wxALL, group_item_spacing);
1982
1983 realSizes->Add(
1984 new wxStaticText(itemPanelShip, wxID_ANY, _("Minimum Screen Size (mm)")),
1985 1, wxALIGN_LEFT);
1986 m_pOSMinSize = new wxTextCtrl(itemPanelShip, wxID_ANY, "TEXT ");
1987 realSizes->Add(m_pOSMinSize, 1, wxALIGN_RIGHT | wxALL, group_item_spacing);
1988
1989 // Radar rings
1990 wxFlexGridSizer* rrSelect =
1991 new wxFlexGridSizer(1, 2, group_item_spacing, group_item_spacing);
1992 rrSelect->AddGrowableCol(1);
1993 dispOptions->Add(rrSelect, 0, wxLEFT | wxRIGHT | wxEXPAND, border_size);
1994
1995 wxStaticText* rrTxt =
1996 new wxStaticText(itemPanelShip, wxID_ANY, _("Show range rings"));
1997 rrSelect->Add(rrTxt, 1, wxEXPAND | wxALL, group_item_spacing);
1998
1999 wxString rrAlt[] = {_("None"), "1", "2", "3", "4", "5",
2000 "6", "7", "8", "9", "10"};
2001 pNavAidRadarRingsNumberVisible =
2002 new wxChoice(itemPanelShip, ID_RADARRINGS, wxDefaultPosition,
2003 m_pShipIconType->GetSize(), 11, rrAlt);
2004 rrSelect->Add(pNavAidRadarRingsNumberVisible, 0, wxALIGN_RIGHT | wxALL,
2005 group_item_spacing);
2006
2007 radarGrid = new wxFlexGridSizer(0, 2, group_item_spacing, group_item_spacing);
2008 radarGrid->AddGrowableCol(1);
2009 dispOptions->Add(radarGrid, 0, wxLEFT | wxEXPAND, 30);
2010
2011 wxStaticText* distanceText =
2012 new wxStaticText(itemPanelShip, wxID_STATIC, _("Distance between rings"));
2013 radarGrid->Add(distanceText, 1, wxEXPAND | wxALL, group_item_spacing);
2014
2015 pNavAidRadarRingsStep = new wxTextCtrl(itemPanelShip, ID_OPTEXTCTRL, "",
2016 wxDefaultPosition, wxSize(100, -1), 0);
2017 radarGrid->Add(pNavAidRadarRingsStep, 0, wxALIGN_RIGHT | wxALL,
2018 group_item_spacing);
2019
2020 wxStaticText* unitText =
2021 new wxStaticText(itemPanelShip, wxID_STATIC, _("Distance Unit"));
2022 radarGrid->Add(unitText, 1, wxEXPAND | wxALL, group_item_spacing);
2023
2024 wxString pDistUnitsStrings[] = {_("Nautical miles"), _("Kilometers"),
2025 _("Minutes (time)")};
2026 m_itemRadarRingsUnits =
2027 new wxChoice(itemPanelShip, ID_RADARDISTUNIT, wxDefaultPosition,
2028 m_pShipIconType->GetSize(), 3, pDistUnitsStrings);
2029 radarGrid->Add(m_itemRadarRingsUnits, 0, wxALIGN_RIGHT | wxALL, border_size);
2030
2031 wxStaticText* colourText =
2032 new wxStaticText(itemPanelShip, wxID_STATIC, _("Range Ring Color"));
2033 radarGrid->Add(colourText, 1, wxEXPAND | wxALL, group_item_spacing);
2034
2035 m_colourOwnshipRangeRingColour =
2036 new OCPNColourPickerCtrl(itemPanelShip, wxID_ANY, *wxRED,
2037 wxDefaultPosition, m_colourPickerDefaultSize, 0,
2038 wxDefaultValidator, "ID_COLOUROSRANGECOLOUR");
2039 radarGrid->Add(m_colourOwnshipRangeRingColour, 0, wxALIGN_RIGHT, border_size);
2040
2041 // ship to active
2042 wxFlexGridSizer* shipToActiveGrid =
2043 new wxFlexGridSizer(1, 5, group_item_spacing, group_item_spacing);
2044 shipToActiveGrid->AddGrowableCol(1);
2045 dispOptions->Add(shipToActiveGrid, 0, wxALL | wxEXPAND, border_size);
2046 pShowshipToActive = new wxCheckBox(itemPanelShip, wxID_ANY,
2047 _("Show direction to Active Waypoint"));
2048 shipToActiveGrid->Add(pShowshipToActive, 0, wxALIGN_CENTER_VERTICAL | wxRIGHT,
2049 border_size);
2050
2051 wxStaticText* shipToActiveText1 =
2052 new wxStaticText(itemPanelShip, wxID_STATIC, _("Style"));
2053 shipToActiveGrid->Add(shipToActiveText1, 1,
2054 wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL, border_size);
2055
2056 wxString LineStyleChoices[] = {_("Default"), _("Solid"), _("Dot"),
2057 _("Long dash"), _("Short dash")};
2058 int LineStyleNChoices = sizeof(LineStyleChoices) / sizeof(wxString);
2059 m_shipToActiveStyle =
2060 new wxChoice(itemPanelShip, wxID_ANY, wxDefaultPosition, wxDefaultSize,
2061 LineStyleNChoices, LineStyleChoices, 0);
2062 m_shipToActiveStyle->SetSelection(0);
2063 shipToActiveGrid->Add(m_shipToActiveStyle, 0, wxALL, 5);
2064
2065 wxStaticText* shipToActiveText2 =
2066 new wxStaticText(itemPanelShip, wxID_STATIC, _("Color"));
2067 shipToActiveGrid->Add(shipToActiveText2, 1,
2068 wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL, border_size);
2069
2070 wxString m_LineColorChoices[] = {
2071 _("Default color"), _("Black"), _("Dark Red"), _("Dark Green"),
2072 _("Dark Yellow"), _("Dark Blue"), _("Dark Magenta"), _("Dark Cyan"),
2073 _("Light Gray"), _("Dark Gray"), _("Red"), _("Green"),
2074 _("Yellow"), _("Blue"), _("Magenta"), _("Cyan"),
2075 _("White")};
2076 int LineColorNChoices = sizeof(m_LineColorChoices) / sizeof(wxString);
2077 m_shipToActiveColor =
2078 new wxChoice(itemPanelShip, wxID_ANY, wxDefaultPosition, wxDefaultSize,
2079 LineColorNChoices, m_LineColorChoices, 0);
2080 m_shipToActiveColor->SetSelection(0);
2081 shipToActiveGrid->Add(m_shipToActiveColor, 0, wxALL, 5);
2082
2083 // Ship's data
2084 wxStaticBox* shipdata =
2085 new wxStaticBox(itemPanelShip, wxID_ANY, _("Ship's information"));
2086 wxStaticBoxSizer* datasizer = new wxStaticBoxSizer(shipdata, wxVERTICAL);
2087 ownShip->Add(datasizer, 0, wxGROW | wxALL, border_size);
2088
2089 wxFlexGridSizer* ownmmsisizer =
2090 new wxFlexGridSizer(0, 2, group_item_spacing, group_item_spacing);
2091 ownmmsisizer->AddGrowableCol(1);
2092 datasizer->Add(ownmmsisizer, 0, wxALL | wxEXPAND, border_size);
2093
2094 // Enter own ship mmsi for a AIS transponder connection.
2095 // Especially N2k devices may lack that info.
2096 wxStaticText* pStatic_ownshipmmsi =
2097 new wxStaticText(itemPanelShip, wxID_ANY,
2098 _("Own ship's MMSI. (If available) Nine digits"));
2099 ownmmsisizer->Add(pStatic_ownshipmmsi, 0);
2100
2101 // Make a rule for mmsi txt control input
2102 const wxString AllowDigits[] = {"0", "1", "2", "3", "4",
2103 "5", "6", "7", "8", "9"};
2104 wxArrayString ArrayAllowDigits(10, AllowDigits);
2105 wxTextValidator mmsiVal(wxFILTER_INCLUDE_CHAR_LIST);
2106 mmsiVal.SetIncludes(ArrayAllowDigits);
2107 m_pTxt_OwnMMSI = new wxTextCtrl(itemPanelShip, wxID_ANY, "",
2108 wxDefaultPosition, wxDefaultSize, 0, mmsiVal);
2109 ownmmsisizer->Add(m_pTxt_OwnMMSI, 0, wxALIGN_RIGHT);
2110
2111 // Ownship default boatspeed
2112 wxFlexGridSizer* ownshipsizer =
2113 new wxFlexGridSizer(0, 2, group_item_spacing, group_item_spacing);
2114 ownshipsizer->AddGrowableCol(1);
2115 datasizer->Add(ownshipsizer, 0, wxALL | wxEXPAND, border_size);
2116
2117 m_Text_def_boat_speed = new wxStaticText(
2118 itemPanelShip, wxID_ANY,
2119 _("Default Boat Speed ") + "(" + getUsrSpeedUnit() + ") ");
2120
2121 ownshipsizer->Add(m_Text_def_boat_speed, groupLabelFlagsHoriz);
2122 pSDefaultBoatSpeed =
2123 new wxTextCtrl(itemPanelShip, ID_DEFAULT_BOAT_SPEED, "",
2124 wxDefaultPosition, wxSize(50, -1), wxTE_RIGHT);
2125 ownshipsizer->Add(pSDefaultBoatSpeed, 0, wxALIGN_RIGHT, group_item_spacing);
2126
2127 // Tracks
2128 wxStaticBox* trackText =
2129 new wxStaticBox(itemPanelShip, wxID_ANY, _("Tracks"));
2130 wxStaticBoxSizer* trackSizer = new wxStaticBoxSizer(trackText, wxVERTICAL);
2131 wxBoxSizer* trackSizer1 = new wxBoxSizer(wxHORIZONTAL);
2132 ownShip->Add(trackSizer, 0, wxGROW | wxALL, border_size);
2133
2134 pTrackDaily = new wxCheckBox(itemPanelShip, ID_DAILYCHECKBOX,
2135 _("Automatic Daily Tracks at midnight"));
2136
2137 trackSizer1->Add(pTrackDaily, 0, wxALIGN_CENTER_VERTICAL | wxRIGHT,
2138 border_size);
2139
2140 trackSizer1->Add(0, 0, 1, wxEXPAND, 0);
2141
2142#if wxUSE_TIMEPICKCTRL
2143 pTrackDaily->SetLabel(_("Automatic Daily Tracks at"));
2144#ifdef __WXGTK__
2145 pTrackRotateTime =
2146 new TimeCtrl(itemPanelShip, ID_TRACKROTATETIME,
2147 wxDateTime((time_t)g_track_rotate_time).ToUTC(),
2148 wxDefaultPosition, wxDefaultSize, 0);
2149#else
2150 pTrackRotateTime =
2151 new wxTimePickerCtrl(itemPanelShip, ID_TRACKROTATETIME,
2152 wxDateTime((time_t)g_track_rotate_time).ToUTC(),
2153 wxDefaultPosition, wxDefaultSize, 0);
2154#endif // __WXGTK__
2155 trackSizer1->Add(pTrackRotateTime, 0, wxALIGN_CENTER_VERTICAL | wxRIGHT,
2156 border_size);
2157#endif // wxUSE_TIMEPICKCTRL
2158
2159 pTrackRotateComputerTime =
2160 new wxRadioButton(itemPanelShip, ID_TRACKROTATECOMPUTER, _("Computer"),
2161 wxDefaultPosition, wxDefaultSize, 0);
2162 trackSizer1->Add(pTrackRotateComputerTime, 0,
2163 wxALIGN_CENTER_VERTICAL | wxRIGHT, border_size);
2164
2165 pTrackRotateUTC =
2166 new wxRadioButton(itemPanelShip, ID_TRACKROTATEUTC, _("UTC"),
2167 wxDefaultPosition, wxDefaultSize, 0);
2168 trackSizer1->Add(pTrackRotateUTC, 0, wxALIGN_CENTER_VERTICAL | wxRIGHT,
2169 border_size);
2170
2171 pTrackRotateLMT =
2172 new wxRadioButton(itemPanelShip, ID_TRACKROTATELMT, _("LMT"),
2173 wxDefaultPosition, wxDefaultSize, 0);
2174 trackSizer1->Add(pTrackRotateLMT, 0, wxALIGN_CENTER_VERTICAL | wxRIGHT,
2175 border_size);
2176
2177 trackSizer->Add(trackSizer1, 1, wxEXPAND | wxALL, border_size);
2178
2179 wxFlexGridSizer* hTrackGrid =
2180 new wxFlexGridSizer(1, 3, group_item_spacing, group_item_spacing);
2181 hTrackGrid->AddGrowableCol(1);
2182 trackSizer->Add(hTrackGrid, 0, wxALL | wxEXPAND, border_size);
2183
2184 pTrackHighlite =
2185 new wxCheckBox(itemPanelShip, ID_TRACKHILITE, _("Highlight Tracks"));
2186 hTrackGrid->Add(pTrackHighlite, 1, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL,
2187 border_size);
2188 wxStaticText* trackColourText =
2189 new wxStaticText(itemPanelShip, wxID_STATIC, _("Highlight Color"));
2190 hTrackGrid->Add(trackColourText, 1, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL,
2191 border_size);
2192 m_colourTrackLineColour = new OCPNColourPickerCtrl(
2193 itemPanelShip, wxID_STATIC, *wxRED, wxDefaultPosition,
2194 m_colourPickerDefaultSize, 0, wxDefaultValidator, "ID_COLOURTRACKCOLOUR");
2195 hTrackGrid->Add(m_colourTrackLineColour, 1, wxALIGN_RIGHT, border_size);
2196
2197 wxFlexGridSizer* pTrackGrid =
2198 new wxFlexGridSizer(1, 2, group_item_spacing, group_item_spacing);
2199 pTrackGrid->AddGrowableCol(1);
2200 trackSizer->Add(pTrackGrid, 0, wxALL | wxEXPAND, border_size);
2201
2202 wxStaticText* tpText =
2203 new wxStaticText(itemPanelShip, wxID_STATIC, _("Tracking Precision"));
2204 pTrackGrid->Add(tpText, 1, wxEXPAND | wxALL, group_item_spacing);
2205
2206 wxString trackAlt[] = {_("Low"), _("Medium"), _("High")};
2207 pTrackPrecision = new wxChoice(itemPanelShip, wxID_ANY, wxDefaultPosition,
2208 m_pShipIconType->GetSize(), 3, trackAlt);
2209 pTrackGrid->Add(pTrackPrecision, 0, wxALIGN_RIGHT | wxALL,
2210 group_item_spacing);
2211}
2212
2213void options::CreatePanel_Routes(size_t parent, int border_size,
2214 int group_item_spacing) {
2215 itemPanelRoutes = AddPage(parent, _("Routes/Points"));
2216
2217 Routes = new wxBoxSizer(wxVERTICAL);
2218 itemPanelRoutes->SetSizer(Routes);
2219
2220 wxString pDistUnitsStrings[] = {_("Nautical miles"), _("Kilometers")};
2221
2222 wxString rrAlt[] = {_("None"), "1", "2", "3", "4", "5",
2223 "6", "7", "8", "9", "10"};
2224
2225 // Routes
2226 wxStaticBox* routeText =
2227 new wxStaticBox(itemPanelRoutes, wxID_ANY, _("New Routes"));
2228 wxStaticBoxSizer* routeSizer = new wxStaticBoxSizer(routeText, wxVERTICAL);
2229 Routes->Add(routeSizer, 0, wxGROW | wxALL, border_size);
2230
2231 wxStaticBox* activeRouteText =
2232 new wxStaticBox(itemPanelRoutes, wxID_ANY, _("Active Route"));
2233 wxStaticBoxSizer* activeRouteSizer =
2234 new wxStaticBoxSizer(activeRouteText, wxVERTICAL);
2235
2236 m_persist_active_route_chkbox = new wxCheckBox(
2237 itemPanelRoutes, wxID_ANY,
2238 _("Persist active route, automatically activate on start up"));
2239 activeRouteSizer->Add(m_persist_active_route_chkbox, 0, wxALL, 5);
2240 Routes->Add(activeRouteSizer, 0, wxGROW | wxALL, border_size);
2241
2242 routeSizer->AddSpacer(5);
2243
2244 // Default ICON
2245 wxFlexGridSizer* routepointiconSelect =
2246 new wxFlexGridSizer(1, 2, group_item_spacing, group_item_spacing);
2247 routepointiconSelect->AddGrowableCol(1);
2248 routeSizer->Add(routepointiconSelect, 0, wxLEFT | wxRIGHT | wxEXPAND,
2249 border_size);
2250
2251 wxStaticText* routepointiconTxt =
2252 new wxStaticText(itemPanelRoutes, wxID_ANY, _("Waypoint default icon"));
2253 routepointiconSelect->Add(routepointiconTxt, 1, wxEXPAND | wxALL,
2254 group_item_spacing);
2255
2256 pRoutepointDefaultIconChoice = new OCPNIconCombo(
2257 itemPanelRoutes, wxID_ANY, _("Combo!"), wxDefaultPosition, wxDefaultSize,
2258 0, NULL, wxCB_READONLY);
2259 routepointiconSelect->Add(pRoutepointDefaultIconChoice, 0,
2260 wxALIGN_RIGHT | wxALL, group_item_spacing);
2261
2262 pRoutepointDefaultIconChoice->SetPopupMaxHeight(::wxGetDisplaySize().y / 2);
2263
2264 // Accomodate scaling of icon
2265 int min_size = GetCharHeight() * 2;
2266 min_size = wxMax(min_size, (32 * g_MarkScaleFactorExp) + 4);
2267 pRoutepointDefaultIconChoice->SetMinSize(
2268 wxSize(GetCharHeight() * 15, min_size));
2269
2270 routeSizer->AddSpacer(5);
2271
2272 wxFlexGridSizer* pRouteGrid =
2273 new wxFlexGridSizer(1, 2, group_item_spacing, group_item_spacing);
2274 pRouteGrid->AddGrowableCol(1);
2275 routeSizer->Add(pRouteGrid, 0, wxALL | wxEXPAND, border_size);
2276
2277 wxStaticText* raText = new wxStaticText(itemPanelRoutes, wxID_STATIC,
2278 _("Waypoint Arrival Distance (NMi)"));
2279 pRouteGrid->Add(raText, 1, wxEXPAND | wxALL, group_item_spacing);
2280
2281 m_pText_ACRadius = new wxTextCtrl(itemPanelRoutes, -1, "TEXT ");
2282 pRouteGrid->Add(m_pText_ACRadius, 0, wxALL | wxALIGN_RIGHT,
2283 group_item_spacing);
2284
2285 pAdvanceRouteWaypointOnArrivalOnly =
2286 new wxCheckBox(itemPanelRoutes, ID_DAILYCHECKBOX,
2287 _("Advance route waypoint on arrival only"));
2288 routeSizer->Add(pAdvanceRouteWaypointOnArrivalOnly, 0, wxALL, 5);
2289
2290#ifdef __WXGTK__
2291 Routes->AddSpacer(8 * group_item_spacing);
2292 wxStaticLine* pln =
2293 new wxStaticLine(itemPanelRoutes, wxID_ANY, wxDefaultPosition,
2294 wxDefaultSize, wxLI_HORIZONTAL);
2295 Routes->Add(pln, 0, wxEXPAND);
2296#endif
2297
2298 // Waypoints
2299 wxStaticBox* waypointText =
2300 new wxStaticBox(itemPanelRoutes, wxID_ANY, _("New Marks"));
2301 wxStaticBoxSizer* waypointSizer =
2302 new wxStaticBoxSizer(waypointText, wxVERTICAL);
2303 Routes->Add(waypointSizer, 0, wxTOP | wxALL | wxEXPAND, border_size);
2304
2305 waypointSizer->AddSpacer(5);
2306
2307 // Default ICON
2308 wxFlexGridSizer* waypointiconSelect =
2309 new wxFlexGridSizer(1, 2, group_item_spacing, group_item_spacing);
2310 waypointiconSelect->AddGrowableCol(1);
2311 waypointSizer->Add(waypointiconSelect, 0, wxLEFT | wxRIGHT | wxEXPAND,
2312 border_size);
2313
2314 wxStaticText* waypointiconTxt =
2315 new wxStaticText(itemPanelRoutes, wxID_ANY, _("Mark default icon"));
2316 waypointiconSelect->Add(waypointiconTxt, 1, wxEXPAND | wxALL,
2317 group_item_spacing);
2318
2319 pWaypointDefaultIconChoice = new OCPNIconCombo(
2320 itemPanelRoutes, wxID_ANY, _("Combo!"), wxDefaultPosition, wxDefaultSize,
2321 0, NULL, wxCB_READONLY);
2322 waypointiconSelect->Add(pWaypointDefaultIconChoice, 0, wxALIGN_RIGHT | wxALL,
2323 group_item_spacing);
2324
2325 pWaypointDefaultIconChoice->SetPopupMaxHeight(::wxGetDisplaySize().y / 2);
2326
2327 // Accomodate scaling of icon
2328 int rmin_size = GetCharHeight() * 2;
2329 min_size = wxMax(rmin_size, (32 * g_MarkScaleFactorExp) + 4);
2330 pWaypointDefaultIconChoice->SetMinSize(
2331 wxSize(GetCharHeight() * 15, rmin_size));
2332
2333 waypointSizer->AddSpacer(5);
2334 // ScaMin
2335 wxFlexGridSizer* ScaMinSizer =
2336 new wxFlexGridSizer(1, 2, group_item_spacing, group_item_spacing);
2337 ScaMinSizer->AddGrowableCol(1);
2338 waypointSizer->Add(ScaMinSizer, 0, wxLEFT | wxRIGHT | wxEXPAND, border_size);
2339 pScaMinChckB =
2340 new wxCheckBox(itemPanelRoutes, wxID_ANY,
2341 _("Show marks only at a chartscale greater than 1 :"));
2342 ScaMinSizer->Add(pScaMinChckB, 0);
2343 m_pText_ScaMin = new wxTextCtrl(itemPanelRoutes, -1, "TEXTTEXTTEXT");
2344 ScaMinSizer->Add(m_pText_ScaMin, 0, wxALL | wxALIGN_RIGHT,
2345 group_item_spacing);
2346
2347 wxFlexGridSizer* ScaMaxSizer =
2348 new wxFlexGridSizer(1, 2, group_item_spacing, group_item_spacing);
2349 ScaMaxSizer->AddGrowableCol(1);
2350 waypointSizer->Add(ScaMaxSizer, 0, wxLEFT | wxRIGHT | wxEXPAND, border_size);
2351 wxStaticText* scaMaxLabel =
2352 new wxStaticText(itemPanelRoutes, wxID_ANY,
2353 _("Show marks only at a chartscale smaller than 1 :"));
2354 ScaMaxSizer->Add(scaMaxLabel, 0);
2355 m_pText_ScaMax = new wxTextCtrl(itemPanelRoutes, -1, "TEXTTEXTTEXT");
2356 ScaMaxSizer->Add(m_pText_ScaMax, 0, wxALL | wxALIGN_RIGHT,
2357 group_item_spacing);
2358
2359 // Overrule the Scamin settings
2360 pScaMinOverruleChckB =
2361 new wxCheckBox(itemPanelRoutes, wxID_ANY,
2362 _("Override the settings for chartscale based visibility "
2363 "and show always"));
2364 waypointSizer->Add(pScaMinOverruleChckB, 0, wxALL, 5);
2365
2366 waypointSizer->AddSpacer(5);
2367 // Range Rings
2368 wxFlexGridSizer* waypointrrSelect =
2369 new wxFlexGridSizer(1, 2, group_item_spacing, group_item_spacing);
2370 waypointrrSelect->AddGrowableCol(1);
2371 waypointSizer->Add(waypointrrSelect, 0, wxLEFT | wxRIGHT | wxEXPAND,
2372 border_size);
2373
2374 wxStaticText* waypointrrTxt =
2375 new wxStaticText(itemPanelRoutes, wxID_ANY, _("Mark range rings"));
2376 waypointrrSelect->Add(waypointrrTxt, 1, wxEXPAND | wxALL, group_item_spacing);
2377
2378 pWaypointRangeRingsNumber =
2379 new wxChoice(itemPanelRoutes, ID_OPWAYPOINTRANGERINGS, wxDefaultPosition,
2380 m_pShipIconType->GetSize(), 11, rrAlt);
2381 waypointrrSelect->Add(pWaypointRangeRingsNumber, 0, wxALIGN_RIGHT | wxALL,
2382 group_item_spacing);
2383
2384 waypointradarGrid =
2385 new wxFlexGridSizer(0, 2, group_item_spacing, group_item_spacing);
2386 waypointradarGrid->AddGrowableCol(1);
2387 waypointSizer->Add(waypointradarGrid, 0, wxLEFT | wxEXPAND, 30);
2388
2389 wxStaticText* waypointdistanceText = new wxStaticText(
2390 itemPanelRoutes, wxID_STATIC, _("Distance between rings"));
2391 waypointradarGrid->Add(waypointdistanceText, 1, wxEXPAND | wxALL,
2392 group_item_spacing);
2393
2394 pWaypointRangeRingsStep =
2395 new wxTextCtrl(itemPanelRoutes, ID_OPTEXTCTRL, "", wxDefaultPosition,
2396 wxSize(100, -1), 0);
2397 waypointradarGrid->Add(pWaypointRangeRingsStep, 0, wxALIGN_RIGHT | wxALL,
2398 group_item_spacing);
2399
2400 wxStaticText* waypointunitText =
2401 new wxStaticText(itemPanelRoutes, wxID_STATIC, _("Distance Unit"));
2402 waypointradarGrid->Add(waypointunitText, 1, wxEXPAND | wxALL,
2403 group_item_spacing);
2404
2405 m_itemWaypointRangeRingsUnits =
2406 new wxChoice(itemPanelRoutes, ID_RADARDISTUNIT, wxDefaultPosition,
2407 m_pShipIconType->GetSize(), 2, pDistUnitsStrings);
2408 waypointradarGrid->Add(m_itemWaypointRangeRingsUnits, 0,
2409 wxALIGN_RIGHT | wxALL, border_size);
2410
2411 wxStaticText* waypointrangeringsColour = new wxStaticText(
2412 itemPanelRoutes, wxID_STATIC, _("Waypoint Range Ring Colors"));
2413 waypointradarGrid->Add(waypointrangeringsColour, 1, wxEXPAND | wxALL, 1);
2414
2415 m_colourWaypointRangeRingsColour = new OCPNColourPickerCtrl(
2416 itemPanelRoutes, wxID_ANY, *wxRED, wxDefaultPosition,
2417 m_colourPickerDefaultSize, 0, wxDefaultValidator,
2418 "ID_COLOURWAYPOINTRANGERINGSCOLOUR");
2419 waypointradarGrid->Add(m_colourWaypointRangeRingsColour, 0,
2420 wxALIGN_RIGHT | wxALL, 1);
2421
2422 // Control Options
2423
2424#ifdef __WXGTK__
2425 Routes->AddSpacer(8 * group_item_spacing);
2426 wxStaticLine* pln1 =
2427 new wxStaticLine(itemPanelRoutes, wxID_ANY, wxDefaultPosition,
2428 wxDefaultSize, wxLI_HORIZONTAL);
2429 Routes->Add(pln1, 0, wxEXPAND);
2430#endif
2431
2432 wxStaticBox* waypointControl =
2433 new wxStaticBox(itemPanelRoutes, wxID_ANY, _("Control Options"));
2434 wxStaticBoxSizer* ControlSizer =
2435 new wxStaticBoxSizer(waypointControl, wxVERTICAL);
2436 Routes->Add(ControlSizer, 0, wxTOP | wxALL | wxEXPAND, border_size);
2437
2438 ControlSizer->AddSpacer(5);
2439
2440 pWayPointPreventDragging = new wxCheckBox(
2441 itemPanelRoutes, ID_DRAGGINGCHECKBOX,
2442 _("Lock marks and waypoints (Unless object property dialog visible)"));
2443 pWayPointPreventDragging->SetValue(FALSE);
2444 ControlSizer->Add(pWayPointPreventDragging, verticleInputFlags);
2445
2446 pConfirmObjectDeletion =
2447 new wxCheckBox(itemPanelRoutes, ID_DELETECHECKBOX,
2448 _("Confirm deletion of tracks and routes"));
2449 pConfirmObjectDeletion->SetValue(FALSE);
2450 ControlSizer->Add(pConfirmObjectDeletion, verticleInputFlags);
2451 ControlSizer->AddSpacer(5);
2452
2453 // Fill the default waypoint icon selector combo box
2454 pWaypointDefaultIconChoice->Clear();
2455 // Iterate on the Icon Descriptions, filling in the combo control
2456 bool fillCombo = true;
2457
2458 if (fillCombo) {
2459 for (int i = 0; i < pWayPointMan->GetNumIcons(); i++) {
2460 wxString* ps = pWayPointMan->GetIconDescription(i);
2461 wxBitmap bmp = pWayPointMan->GetIconBitmapForList(i, 2 * GetCharHeight());
2462
2463 pWaypointDefaultIconChoice->Append(*ps, bmp);
2464 }
2465 }
2466
2467 // find the correct item in the combo box
2468 int iconToSelect = -1;
2469 for (int i = 0; i < pWayPointMan->GetNumIcons(); i++) {
2470 if (*pWayPointMan->GetIconKey(i) == g_default_wp_icon) {
2471 iconToSelect = i;
2472 pWaypointDefaultIconChoice->Select(iconToSelect);
2473 break;
2474 }
2475 }
2476
2477 // Fill the default Routepoint icon selector combo box
2478 pRoutepointDefaultIconChoice->Clear();
2479 // Iterate on the Icon Descriptions, filling in the combo control
2480 fillCombo = true;
2481
2482 if (fillCombo) {
2483 for (int i = 0; i < pWayPointMan->GetNumIcons(); i++) {
2484 wxString* ps = pWayPointMan->GetIconDescription(i);
2485 wxBitmap bmp = pWayPointMan->GetIconBitmapForList(i, 2 * GetCharHeight());
2486
2487 pRoutepointDefaultIconChoice->Append(*ps, bmp);
2488 }
2489 }
2490
2491 // find the correct item in the combo box
2492 iconToSelect = -1;
2493 for (int i = 0; i < pWayPointMan->GetNumIcons(); i++) {
2494 if (*pWayPointMan->GetIconKey(i) == g_default_routepoint_icon) {
2495 iconToSelect = i;
2496 pRoutepointDefaultIconChoice->Select(iconToSelect);
2497 break;
2498 }
2499 }
2500
2501 // DimeControl(itemPanelRoutes);
2502}
2503
2504void options::CreatePanel_ChartsLoad(size_t parent, int border_size,
2505 int group_item_spacing) {
2506 chartPanelWin = AddPage(m_pageCharts, _("Chart Files"));
2507
2508 chartPanel = new wxBoxSizer(wxVERTICAL);
2509 chartPanelWin->SetSizer(chartPanel);
2510
2511 loadedBox = new wxStaticBox(chartPanelWin, wxID_ANY, _("Directories"));
2512 activeSizer = new wxStaticBoxSizer(loadedBox, wxHORIZONTAL);
2513 chartPanel->Add(activeSizer, 1, wxALL | wxEXPAND, border_size);
2514
2515 m_scrollWinChartList = new wxScrolledWindow(
2516 chartPanelWin, wxID_ANY, wxDefaultPosition,
2517 wxDLG_UNIT(this, wxSize(-1, -1)), wxBORDER_RAISED | wxVSCROLL);
2518
2519 activeSizer->Add(m_scrollWinChartList, 1, wxALL | wxEXPAND, 5);
2520
2521#ifndef __ANDROID__
2522 m_scrollRate = 5;
2523#else
2524 m_scrollRate = 1;
2525#endif
2526 m_scrollWinChartList->SetScrollRate(m_scrollRate, m_scrollRate);
2527
2528 boxSizerCharts = new wxBoxSizer(wxVERTICAL);
2529 m_scrollWinChartList->SetSizer(boxSizerCharts);
2530
2531 cmdButtonSizer = new wxBoxSizer(wxVERTICAL);
2532 activeSizer->Add(cmdButtonSizer, 0, wxALL, border_size);
2533
2534 wxString b1 = _("Add Directory...");
2535 wxString b2 = _("Remove Selected");
2536 wxString b3 = _("Compress Selected");
2537
2538 if (m_bcompact) {
2539 b1 = _("Add..");
2540 b2 = _("Remove");
2541 b3 = _("Compress");
2542 }
2543
2544 wxButton* addBtn = new wxButton(chartPanelWin, ID_BUTTONADD, b1);
2545 cmdButtonSizer->Add(addBtn, 1, wxALL | wxEXPAND, group_item_spacing);
2546
2547 cmdButtonSizer->AddSpacer(GetCharHeight());
2548
2549 m_removeBtn = new wxButton(chartPanelWin, ID_BUTTONDELETE, b2);
2550 cmdButtonSizer->Add(m_removeBtn, 1, wxALL | wxEXPAND, group_item_spacing);
2551 m_removeBtn->Disable();
2552
2553 cmdButtonSizer->AddSpacer(GetCharHeight());
2554
2555#ifdef OCPN_USE_LZMA
2556 m_compressBtn = new wxButton(chartPanelWin, ID_BUTTONCOMPRESS, b3);
2557 cmdButtonSizer->Add(m_compressBtn, 1, wxALL | wxEXPAND, group_item_spacing);
2558 m_compressBtn->Disable();
2559#else
2560 m_compressBtn = NULL;
2561#endif
2562
2563#ifdef __ANDROID__
2564 if (g_Android_SDK_Version >= 30) {
2565 m_migrateBtn =
2566 new wxButton(chartPanelWin, ID_BUTTONMIGRATE, _("Migrate Charts.."));
2567 cmdButtonSizer->Add(m_migrateBtn, 1, wxALL | wxEXPAND, group_item_spacing);
2568 }
2569#endif
2570
2571 cmdButtonSizer->AddSpacer(GetCharHeight());
2572
2573 wxStaticBox* itemStaticBoxUpdateStatic =
2574 new wxStaticBox(chartPanelWin, wxID_ANY, _("Update Control"));
2575 wxStaticBoxSizer* itemStaticBoxSizerUpdate =
2576 new wxStaticBoxSizer(itemStaticBoxUpdateStatic, wxVERTICAL);
2577 chartPanel->Add(itemStaticBoxSizerUpdate, 0, wxGROW | wxALL, 5);
2578
2579 wxFlexGridSizer* itemFlexGridSizerUpdate = new wxFlexGridSizer(1);
2580 itemFlexGridSizerUpdate->SetFlexibleDirection(wxHORIZONTAL);
2581
2582 pScanCheckBox = new wxCheckBox(chartPanelWin, ID_SCANCHECKBOX,
2583 _("Scan Charts and Update Database"));
2584 itemFlexGridSizerUpdate->Add(pScanCheckBox, 1, wxALL, 5);
2585
2586 pUpdateCheckBox = new wxCheckBox(chartPanelWin, ID_UPDCHECKBOX,
2587 _("Force Full Database Rebuild"));
2588 // itemFlexGridSizerUpdate->Add(pUpdateCheckBox, 1, wxALL, 5);
2589 pUpdateCheckBox->Hide();
2590
2591 pRebuildChartDatabase = new wxButton(chartPanelWin, ID_REBUILDBUTTON,
2592 _("Rebuild Chart Database"));
2593 itemFlexGridSizerUpdate->Add(pRebuildChartDatabase, 1, wxALL, 5);
2594
2595 pParseENCButton = new wxButton(chartPanelWin, ID_PARSEENCBUTTON,
2596 _("Prepare all ENC Charts"));
2597 itemFlexGridSizerUpdate->Add(pParseENCButton, 1, wxALL, 5);
2598
2599 itemStaticBoxSizerUpdate->Add(itemFlexGridSizerUpdate, 1, wxEXPAND, 5);
2600
2601 // Currently loaded chart dirs
2602 ActiveChartArray.Clear();
2603 for (size_t i = 0; i < m_CurrentDirList.GetCount(); i++) {
2604 ActiveChartArray.Add(m_CurrentDirList[i]);
2605 }
2606
2607 UpdateChartDirList();
2608
2609 chartPanel->Layout();
2610}
2611
2612void options::UpdateChartDirList() {
2613 // Clear the sizer, and delete all the child panels
2614 m_scrollWinChartList->GetSizer()->Clear(true);
2615 m_scrollWinChartList->ClearBackground();
2616
2617 panelVector.clear();
2618
2619 // Add new panels
2620 for (size_t i = 0; i < ActiveChartArray.GetCount(); i++) {
2621 OCPNChartDirPanel* chartPanel =
2622 new OCPNChartDirPanel(m_scrollWinChartList, wxID_ANY, wxDefaultPosition,
2623 wxSize(-1, -1), ActiveChartArray[i]);
2624 chartPanel->SetSelected(false);
2625
2626 m_scrollWinChartList->GetSizer()->Add(chartPanel, 0, wxEXPAND | wxALL, 0);
2627
2628 panelVector.push_back(chartPanel);
2629 }
2630
2631 m_scrollWinChartList->GetSizer()->Layout();
2632
2633 chartPanelWin->ClearBackground();
2634 chartPanelWin->Layout();
2635
2636 // There are some problems with wxScrolledWindow after add/removing items.
2637 // Typically, the problem is that blank space remains at the top of the
2638 // scrollable range of the window.
2639 // Workarounds here...
2640 // n.b. according to wx docs, none of this should be necessary...
2641#ifdef __ANDROID__
2642 // This works on Android, but seems pretty drastic
2643 wxSize sza = GetSize();
2644 sza.y -= 1;
2645 SetSize(sza);
2646#else
2647 // This works, except on Android
2648 m_scrollWinChartList->GetParent()->Layout();
2649#endif
2650
2651 m_scrollWinChartList->Scroll(0, 0);
2652}
2653
2654void options::UpdateTemplateTitleText() {
2655 if (!m_templateTitleText) return;
2656
2657 wxString activeTitle;
2658 if (!g_lastAppliedTemplateGUID.IsEmpty()) {
2659 activeTitle = ConfigMgr::Get().GetTemplateTitle(g_lastAppliedTemplateGUID);
2660
2661 bool configCompare =
2662 ConfigMgr::Get().CheckTemplateGUID(g_lastAppliedTemplateGUID);
2663 if (!configCompare) activeTitle += _(" [Modified]");
2664 m_templateTitleText->SetLabel(activeTitle);
2665 } else
2666 m_templateTitleText->SetLabel(_("None"));
2667}
2668
2669void options::CreatePanel_Configs(size_t parent, int border_size,
2670 int group_item_spacing) {
2671 m_DisplayConfigsPage = AddPage(parent, _("Templates"));
2672
2673 // if (m_bcompact) {
2674 //}
2675 // else
2676 {
2677 wxBoxSizer* wrapperSizer = new wxBoxSizer(wxVERTICAL);
2678 m_DisplayConfigsPage->SetSizer(wrapperSizer);
2679
2680 // Template management
2681
2682 wxStaticBox* templateStatusBox =
2683 new wxStaticBox(m_DisplayConfigsPage, wxID_ANY, _("Template Status"));
2684 m_templateStatusBoxSizer =
2685 new wxStaticBoxSizer(templateStatusBox, wxHORIZONTAL);
2686 wrapperSizer->Add(m_templateStatusBoxSizer, 1, wxALL | wxEXPAND,
2687 border_size);
2688
2689 wxBoxSizer* statSizer = new wxBoxSizer(wxVERTICAL);
2690 m_templateStatusBoxSizer->Add(statSizer, 0, wxALL | wxEXPAND, border_size);
2691
2692 m_staticTextLastAppled = new wxStaticText(
2693 m_DisplayConfigsPage, wxID_ANY, _("Last Applied Template Title:"));
2694 m_staticTextLastAppled->Hide();
2695
2696 statSizer->Add(m_staticTextLastAppled);
2697
2698 m_templateTitleText =
2699 new wxStaticText(m_DisplayConfigsPage, wxID_ANY, wxEmptyString);
2700 statSizer->Add(m_templateTitleText);
2701 m_templateTitleText->Hide();
2702
2703 UpdateTemplateTitleText();
2704
2705 wxStaticBox* configsBox =
2706 new wxStaticBox(m_DisplayConfigsPage, wxID_ANY, _("Saved Templates"));
2707 wxStaticBoxSizer* configSizer =
2708 new wxStaticBoxSizer(configsBox, wxHORIZONTAL);
2709 wrapperSizer->Add(configSizer, 4, wxALL | wxEXPAND, border_size);
2710
2711 wxPanel* cPanel = new wxPanel(m_DisplayConfigsPage, wxID_ANY);
2712 configSizer->Add(cPanel, 1, wxALL | wxEXPAND, border_size);
2713
2714 wxBoxSizer* boxSizercPanel = new wxBoxSizer(wxVERTICAL);
2715 cPanel->SetSizer(boxSizercPanel);
2716
2717 m_scrollWinConfigList =
2718 new wxScrolledWindow(cPanel, wxID_ANY, wxDefaultPosition, wxDefaultSize,
2719 wxBORDER_RAISED | wxVSCROLL);
2720 m_scrollWinConfigList->SetScrollRate(1, 1);
2721 boxSizercPanel->Add(m_scrollWinConfigList, 0, wxALL | wxEXPAND,
2722 border_size);
2723 m_scrollWinConfigList->SetMinSize(wxSize(-1, 15 * GetCharHeight()));
2724
2725 m_boxSizerConfigs = new wxBoxSizer(wxVERTICAL);
2726 m_scrollWinConfigList->SetSizer(m_boxSizerConfigs);
2727
2728 wxBoxSizer* btnSizer = new wxBoxSizer(wxVERTICAL);
2729 configSizer->Add(btnSizer);
2730
2731 // Add the "Insert/Remove" buttons
2732 wxButton* createButton =
2733 new wxButton(m_DisplayConfigsPage, wxID_ANY, _("Create Config..."));
2734 btnSizer->Add(createButton, 1, wxALL | wxEXPAND, group_item_spacing);
2735 createButton->Connect(wxEVT_COMMAND_BUTTON_CLICKED,
2736 wxCommandEventHandler(options::OnCreateConfig), NULL,
2737 this);
2738
2739 // wxButton* editButton = new wxButton(m_DisplayConfigsPage, wxID_ANY,
2740 // _("Edit Config...")); btnSizer->Add(editButton, 1, wxALL | wxEXPAND,
2741 // group_item_spacing); editButton->Connect(wxEVT_COMMAND_BUTTON_CLICKED,
2742 // wxCommandEventHandler(options::OnEditConfig), NULL, this);
2743
2744 m_configDeleteButton = new wxButton(m_DisplayConfigsPage, wxID_ANY,
2745 _("Delete Selected Config..."));
2746 btnSizer->Add(m_configDeleteButton, 1, wxALL | wxEXPAND,
2747 group_item_spacing);
2748 m_configDeleteButton->Connect(
2749 wxEVT_COMMAND_BUTTON_CLICKED,
2750 wxCommandEventHandler(options::OnDeleteConfig), NULL, this);
2751
2752 m_configApplyButton = new wxButton(m_DisplayConfigsPage, wxID_ANY,
2753 _("Apply Selected Config"));
2754 btnSizer->Add(m_configApplyButton, 1, wxALL | wxEXPAND, group_item_spacing);
2755 m_configApplyButton->Connect(wxEVT_COMMAND_BUTTON_CLICKED,
2756 wxCommandEventHandler(options::OnApplyConfig),
2757 NULL, this);
2758
2759 // Populate the configs list from the ConfigMgr
2760 ClearConfigList();
2761 BuildConfigList();
2762
2763 SetConfigButtonState();
2764 }
2765}
2766
2767void options::ClearConfigList() {
2768 if (m_scrollWinConfigList) {
2769 wxWindowList kids = m_scrollWinConfigList->GetChildren();
2770 for (unsigned int i = 0; i < kids.GetCount(); i++) {
2771 wxWindowList::compatibility_iterator node = kids.Item(i);
2772 wxWindow* win = node->GetData();
2773 auto pcp = dynamic_cast<wxPanel*>(win);
2774 if (pcp) {
2775 auto cPanel = dynamic_cast<ConfigPanel*>(pcp);
2776 if (cPanel) {
2777 cPanel->Destroy();
2778 }
2779 }
2780 }
2781 }
2782 SetConfigButtonState();
2783}
2784
2785void options::BuildConfigList() {
2786 wxArrayString configGUIDs = ConfigMgr::Get().GetConfigGUIDArray();
2787
2788 for (size_t i = 0; i < configGUIDs.GetCount(); i++) {
2789 wxPanel* pp =
2790 ConfigMgr::Get().GetConfigPanel(m_scrollWinConfigList, configGUIDs[i]);
2791 if (pp) {
2792 m_panelBackgroundUnselected = pp->GetBackgroundColour();
2793 m_boxSizerConfigs->Add(pp, 1, wxEXPAND);
2794 pp->Connect(wxEVT_LEFT_DOWN,
2795 wxMouseEventHandler(options::OnConfigMouseSelected), NULL,
2796 this);
2797
2798 // Set mouse handler for children of the panel, too.
2799 wxWindowList kids = pp->GetChildren();
2800 for (unsigned int i = 0; i < kids.GetCount(); i++) {
2801 wxWindowList::compatibility_iterator node = kids.Item(i);
2802 wxWindow* win = node->GetData();
2803 win->Connect(wxEVT_LEFT_DOWN,
2804 wxMouseEventHandler(options::OnConfigMouseSelected), NULL,
2805 this);
2806 }
2807 }
2808 }
2809
2810 m_boxSizerConfigs->Layout();
2811
2812 m_selectedConfigPanelGUID = "";
2813 SetConfigButtonState();
2814}
2815
2816void options::SetConfigButtonState() {
2817 m_configDeleteButton->Enable(!m_selectedConfigPanelGUID.IsEmpty());
2818 if (m_selectedConfigPanelGUID.StartsWith(
2819 "11111111")) // Cannot delete "Recovery" template
2820 m_configDeleteButton->Disable();
2821 m_configApplyButton->Enable(!m_selectedConfigPanelGUID.IsEmpty());
2822}
2823
2824void options::OnCreateConfig(wxCommandEvent& event) {
2825 ConfigCreateDialog* pd = new ConfigCreateDialog(
2826 this, -1, _("Create Config"), wxDefaultPosition, wxSize(200, 200));
2827 DimeControl(pd);
2828 pd->ShowWindowModalThenDo([this, pd](int retcode) {
2829 if (retcode == wxID_OK) {
2830 g_lastAppliedTemplateGUID = pd->GetCreatedTemplateGUID();
2831 UpdateTemplateTitleText();
2832
2833 ClearConfigList();
2834 BuildConfigList();
2835 m_DisplayConfigsPage->Layout();
2836 }
2837 SetConfigButtonState();
2838 });
2839}
2840
2841void options::OnEditConfig(wxCommandEvent& event) {}
2842
2843void options::OnDeleteConfig(wxCommandEvent& event) {
2844 if (m_selectedConfigPanelGUID.IsEmpty()) return;
2845
2846 ConfigMgr::Get().DeleteConfig(m_selectedConfigPanelGUID);
2847 m_selectedConfigPanelGUID = "";
2848
2849 ClearConfigList();
2850 BuildConfigList();
2851
2852 m_DisplayConfigsPage->Layout();
2853 SetConfigButtonState();
2854}
2855
2856void options::OnApplyConfig(wxCommandEvent& event) {
2857 if (m_selectedConfigPanelGUID.IsEmpty()) return;
2858
2859 // Record a few special items
2860 wxString currentLocale = g_locale;
2861
2862 // Apply any changed settings other than the target config template.
2863 wxCommandEvent evt;
2864 evt.SetId(ID_APPLY);
2865 OnApplyClick(evt);
2866
2867 // Then Apply the target config template
2868 bool bApplyStat = ConfigMgr::Get().ApplyConfigGUID(m_selectedConfigPanelGUID);
2869 if (bApplyStat) {
2870 // OCPNMessageBox(this, _("Configuration successfully applied."),
2871 // _("OpenCPN Info"), wxOK);
2872 g_lastAppliedTemplateGUID = m_selectedConfigPanelGUID;
2873 wxString activeTitle =
2874 ConfigMgr::Get().GetTemplateTitle(g_lastAppliedTemplateGUID);
2875 m_templateTitleText->SetLabel(activeTitle);
2876 m_templateTitleText->Show();
2877 m_staticTextLastAppled->Show();
2878 m_templateStatusBoxSizer->Layout();
2879 } else
2880 OCPNMessageBox(this, _("Problem applying selected configuration."),
2881 _("OpenCPN Info"), wxOK);
2882
2883 // Clear all selections
2884 if (m_scrollWinConfigList) {
2885 wxWindowList kids = m_scrollWinConfigList->GetChildren();
2886 for (unsigned int i = 0; i < kids.GetCount(); i++) {
2887 wxWindowList::compatibility_iterator node = kids.Item(i);
2888 wxWindow* win = node->GetData();
2889 auto pcp = dynamic_cast<wxPanel*>(win);
2890 if (pcp) {
2891 auto cPanel = dynamic_cast<ConfigPanel*>(pcp);
2892 if (cPanel) {
2893 cPanel->SetBackgroundColour(m_panelBackgroundUnselected);
2894 }
2895 }
2896 }
2897 }
2898 m_selectedConfigPanelGUID = wxEmptyString;
2899
2900 m_returnChanges |= CONFIG_CHANGED;
2901
2902 if (!currentLocale.IsSameAs(g_locale)) m_returnChanges |= LOCALE_CHANGED;
2903
2904 Finish();
2905}
2906
2907void options::OnConfigMouseSelected(wxMouseEvent& event) {
2908 wxPanel* selectedPanel = NULL;
2909 wxObject* obj = event.GetEventObject();
2910 if (obj) {
2911 auto panel = dynamic_cast<wxPanel*>(obj);
2912 if (panel) {
2913 selectedPanel = panel;
2914 }
2915 // Clicked on child?
2916 else {
2917 auto win = dynamic_cast<wxWindow*>(obj);
2918 if (win) {
2919 auto parentpanel = dynamic_cast<wxPanel*>(win->GetParent());
2920 if (parentpanel) {
2921 selectedPanel = parentpanel;
2922 }
2923 }
2924 }
2925
2926 if (m_scrollWinConfigList) {
2927 wxWindowList kids = m_scrollWinConfigList->GetChildren();
2928 for (unsigned int i = 0; i < kids.GetCount(); i++) {
2929 wxWindowList::compatibility_iterator node = kids.Item(i);
2930 wxWindow* win = node->GetData();
2931 auto panel = dynamic_cast<wxPanel*>(win);
2932 if (panel) {
2933 if (panel == selectedPanel) {
2934 panel->SetBackgroundColour(wxSystemSettings::GetColour(
2935 wxSystemColour::wxSYS_COLOUR_HIGHLIGHT));
2936 auto cPanel = dynamic_cast<ConfigPanel*>(panel);
2937 if (cPanel) m_selectedConfigPanelGUID = cPanel->GetConfigGUID();
2938 } else
2939 panel->SetBackgroundColour(m_panelBackgroundUnselected);
2940
2941 panel->Refresh(true);
2942 }
2943 }
2944 }
2945 m_DisplayConfigsPage->Layout();
2946 SetConfigButtonState();
2947 }
2948}
2949
2950void options::CreatePanel_Advanced(size_t parent, int border_size,
2951 int group_item_spacing) {
2952 m_ChartDisplayPage = AddPage(parent, _("Advanced"));
2953
2954 if (m_bcompact) {
2955 wxSize sz = g_Platform->getDisplaySize();
2956 double dpmm = g_Platform->GetDisplayDPmm();
2957
2958 wxBoxSizer* wrapperSizer = new wxBoxSizer(wxVERTICAL);
2959 m_ChartDisplayPage->SetSizer(wrapperSizer);
2960
2961 wxBoxSizer* itemBoxSizerUI = wrapperSizer;
2962
2963 // spacer
2964 itemBoxSizerUI->Add(0, border_size * 3);
2965 itemBoxSizerUI->Add(0, border_size * 3);
2966
2967 // Chart Display Options
2968 wxBoxSizer* boxCharts = new wxBoxSizer(wxVERTICAL);
2969 itemBoxSizerUI->Add(boxCharts, groupInputFlags);
2970
2971 pSkewComp = new wxCheckBox(m_ChartDisplayPage, ID_SKEWCOMPBOX,
2972 _("De-skew Raster Charts"));
2973 boxCharts->Add(pSkewComp, inputFlags);
2974
2975 itemBoxSizerUI->Add(0, border_size * 3);
2976 itemBoxSizerUI->Add(0, border_size * 3);
2977
2978 // OpenGL Options
2979#ifdef ocpnUSE_GL
2980 wxBoxSizer* OpenGLSizer = new wxBoxSizer(wxVERTICAL);
2981 itemBoxSizerUI->Add(OpenGLSizer, 0, 0, 0);
2982
2983 pOpenGL = new wxCheckBox(m_ChartDisplayPage, ID_OPENGLBOX,
2984 _("Use Accelerated Graphics (OpenGL)"));
2985 OpenGLSizer->Add(pOpenGL, inputFlags);
2986 pOpenGL->Enable(!g_bdisable_opengl && g_Platform->IsGLCapable());
2987
2988 auto* bOpenGL = new wxButton(m_ChartDisplayPage, ID_OPENGLOPTIONS,
2989 _("OpenGL Options") + "...");
2990 OpenGLSizer->Add(bOpenGL, inputFlags);
2991
2992 pOpenGL->Connect(wxEVT_COMMAND_CHECKBOX_CLICKED,
2993 wxCommandEventHandler(options::OnGLClicked), NULL, this);
2994#ifdef __ANDROID__
2995 pOpenGL->Hide();
2996 bOpenGL->Hide();
2997#endif
2998 itemBoxSizerUI->Add(0, border_size * 3);
2999 itemBoxSizerUI->Add(0, border_size * 3);
3000#endif // ocpnUSE_GL
3001
3002 // Course Up display update period
3003 wxStaticText* crat = new wxStaticText(m_ChartDisplayPage, wxID_ANY,
3004 _("Chart Rotation Averaging Time"));
3005 crat->Wrap(-1);
3006 wrapperSizer->Add(crat, 0,
3007 wxALL | wxEXPAND | wxALIGN_LEFT | wxALIGN_CENTRE_VERTICAL,
3008 group_item_spacing);
3009
3010 wxBoxSizer* pCOGUPFilterRow = new wxBoxSizer(wxHORIZONTAL);
3011 wrapperSizer->Add(pCOGUPFilterRow, 0, wxALL | wxEXPAND, group_item_spacing);
3012
3013 pCOGUPUpdateSecs =
3014 new wxTextCtrl(m_ChartDisplayPage, ID_OPTEXTCTRL, "", wxDefaultPosition,
3015 wxSize(sz.x / 5, -1), wxTE_RIGHT);
3016 pCOGUPFilterRow->Add(pCOGUPUpdateSecs, 0, wxALIGN_RIGHT | wxALL,
3017 group_item_spacing);
3018
3019 pCOGUPFilterRow->Add(
3020 new wxStaticText(m_ChartDisplayPage, wxID_ANY, _("seconds")),
3021 inputFlags);
3022
3023 itemBoxSizerUI->Add(0, border_size * 3);
3024 itemBoxSizerUI->Add(0, border_size * 3);
3025
3026 // Chart Zoom Scale Weighting
3027 wxStaticText* zoomTextHead = new wxStaticText(
3028 m_ChartDisplayPage, wxID_ANY, _("Chart Zoom/Scale Weighting"));
3029 zoomTextHead->Wrap(-1);
3030 itemBoxSizerUI->Add(
3031 zoomTextHead, 0,
3032 wxALL | wxEXPAND | wxALIGN_LEFT | wxALIGN_CENTRE_VERTICAL,
3033 group_item_spacing);
3034 itemBoxSizerUI->Add(0, border_size * 1);
3035
3036 itemBoxSizerUI->Add(
3037 new wxStaticText(m_ChartDisplayPage, wxID_ANY, _("Raster")),
3038 inputFlags);
3039
3040 m_pSlider_Zoom_Raster =
3041 new wxSlider(m_ChartDisplayPage, ID_RASTERZOOM, 0, -5, 5,
3042 wxDefaultPosition, m_sliderSize, SLIDER_STYLE);
3043
3044#ifdef __ANDROID__
3045 prepareSlider(m_pSlider_Zoom_Raster);
3046#endif
3047
3048 itemBoxSizerUI->Add(m_pSlider_Zoom_Raster, inputFlags);
3049
3050 itemBoxSizerUI->Add(
3051 new wxStaticText(m_ChartDisplayPage, wxID_ANY, _("Vector")),
3052 inputFlags);
3053
3054 m_pSlider_Zoom_Vector =
3055 new wxSlider(m_ChartDisplayPage, ID_VECZOOM, 0, -5, 5,
3056 wxDefaultPosition, m_sliderSize, SLIDER_STYLE);
3057
3058#ifdef __ANDROID__
3059 prepareSlider(m_pSlider_Zoom_Vector);
3060#endif
3061
3062 itemBoxSizerUI->Add(m_pSlider_Zoom_Vector, inputFlags);
3063
3064 itemBoxSizerUI->Add(
3065 new wxStaticText(m_ChartDisplayPage, wxID_ANY, _("CM93 Detail level")),
3066 inputFlags);
3067 m_pSlider_CM93_Zoom =
3068 new wxSlider(m_ChartDisplayPage, ID_CM93ZOOM, 0,
3069 -CM93_ZOOM_FACTOR_MAX_RANGE, CM93_ZOOM_FACTOR_MAX_RANGE,
3070 wxDefaultPosition, m_sliderSize, SLIDER_STYLE);
3071
3072#ifdef __ANDROID__
3073 prepareSlider(m_pSlider_CM93_Zoom);
3074#endif
3075
3076 itemBoxSizerUI->Add(m_pSlider_CM93_Zoom, 0, wxALL, border_size);
3077
3078 itemBoxSizerUI->Add(0, border_size * 3);
3079 itemBoxSizerUI->Add(0, border_size * 3);
3080 itemBoxSizerUI->Add(0, border_size * 3);
3081
3082#ifndef __ANDROID__
3083 // Display size/DPI
3084 itemBoxSizerUI->Add(new wxStaticText(m_ChartDisplayPage, wxID_ANY,
3085 _("Physical Screen Width")),
3086 inputFlags);
3087 wxBoxSizer* pDPIRow = new wxBoxSizer(wxHORIZONTAL);
3088 itemBoxSizerUI->Add(pDPIRow, 0, wxEXPAND);
3089
3090 pRBSizeAuto = new wxRadioButton(m_ChartDisplayPage, wxID_ANY, _("Auto"));
3091 pDPIRow->Add(pRBSizeAuto, inputFlags);
3092 pDPIRow->AddSpacer(10);
3093 pRBSizeManual = new wxRadioButton(m_ChartDisplayPage,
3094 ID_SIZEMANUALRADIOBUTTON, _("Manual:"));
3095 pDPIRow->Add(pRBSizeManual, inputFlags);
3096
3097 wxBoxSizer* pmmRow = new wxBoxSizer(wxHORIZONTAL);
3098 itemBoxSizerUI->Add(pmmRow, 0, wxEXPAND);
3099
3100 pScreenMM =
3101 new wxTextCtrl(m_ChartDisplayPage, ID_OPTEXTCTRL, "", wxDefaultPosition,
3102 wxSize(sz.x / 5, -1), wxTE_RIGHT);
3103 pmmRow->Add(pScreenMM, 0, wxALIGN_RIGHT | wxALL, group_item_spacing);
3104
3105 pmmRow->Add(new wxStaticText(m_ChartDisplayPage, wxID_ANY, _("mm")),
3106 inputFlags);
3107#endif
3108 // ChartBar Options
3109 itemBoxSizerUI->Add(
3110 new wxStaticText(m_ChartDisplayPage, wxID_ANY, _("Chart Bar")),
3111 inputFlags);
3112 wxBoxSizer* ChartBarSizer = new wxBoxSizer(wxHORIZONTAL);
3113 itemBoxSizerUI->Add(ChartBarSizer, 0, 0, 0);
3114
3115 pChartBarEX = new wxCheckBox(m_ChartDisplayPage, -1,
3116 _("Show extended chart bar information."));
3117 ChartBarSizer->Add(pChartBarEX, inputFlags);
3118
3119#ifndef __ANDROID__
3120 pRBSizeAuto->Connect(wxEVT_COMMAND_RADIOBUTTON_SELECTED,
3121 wxCommandEventHandler(options::OnSizeAutoButton), NULL,
3122 this);
3123 pRBSizeManual->Connect(wxEVT_COMMAND_RADIOBUTTON_SELECTED,
3124 wxCommandEventHandler(options::OnSizeManualButton),
3125 NULL, this);
3126#endif
3127 }
3128
3129 else {
3130 wxFlexGridSizer* itemBoxSizerUI = new wxFlexGridSizer(2);
3131 itemBoxSizerUI->SetHGap(border_size);
3132 // itemBoxSizerUI->AddGrowableCol( 0, 1 );
3133 // itemBoxSizerUI->AddGrowableCol( 1, 1 );
3134 // m_ChartDisplayPage->SetSizer( itemBoxSizerUI );
3135
3136 // wxFlexGridSizer grows wrongly in wx2.8, so we need to centre it in
3137 // another sizer instead of letting it grow.
3138 wxBoxSizer* wrapperSizer = new wxBoxSizer(wxVERTICAL);
3139 m_ChartDisplayPage->SetSizer(wrapperSizer);
3140 wrapperSizer->Add(itemBoxSizerUI, 1, wxALL | wxALIGN_CENTER, border_size);
3141
3142 // spacer
3143 itemBoxSizerUI->Add(0, border_size * 3);
3144 itemBoxSizerUI->Add(0, border_size * 3);
3145
3146 // Chart Display Options
3147 itemBoxSizerUI->Add(
3148 new wxStaticText(m_ChartDisplayPage, wxID_ANY, _("Chart Display")),
3149 groupLabelFlags);
3150 wxBoxSizer* boxCharts = new wxBoxSizer(wxVERTICAL);
3151 itemBoxSizerUI->Add(boxCharts, groupInputFlags);
3152
3153 pSkewComp = new wxCheckBox(m_ChartDisplayPage, ID_SKEWCOMPBOX,
3154 _("Show Skewed Raster Charts as North-Up"));
3155 boxCharts->Add(pSkewComp, verticleInputFlags);
3156
3157 // pFullScreenQuilt = new wxCheckBox(m_ChartDisplayPage,
3158 // ID_FULLSCREENQUILT,
3159 // _("Disable Full Screen Quilting"));
3160 // boxCharts->Add(pFullScreenQuilt, verticleInputFlags);
3161
3162 // pOverzoomEmphasis =
3163 // new wxCheckBox(m_ChartDisplayPage, ID_FULLSCREENQUILT,
3164 // _("Suppress blur/fog effects on overzoom"));
3165 // boxCharts->Add(pOverzoomEmphasis, verticleInputFlags);
3166 //
3167 // pOZScaleVector =
3168 // new wxCheckBox(m_ChartDisplayPage, ID_FULLSCREENQUILT,
3169 // _("Suppress scaled vector charts on overzoom"));
3170 // boxCharts->Add(pOZScaleVector, verticleInputFlags);
3171
3172 // spacer
3173 itemBoxSizerUI->Add(0, border_size * 3);
3174 itemBoxSizerUI->Add(0, border_size * 3);
3175
3176 // Course Up display update period
3177 itemBoxSizerUI->Add(new wxStaticText(m_ChartDisplayPage, wxID_ANY,
3178 _("Chart Rotation Averaging Time")),
3179 labelFlags);
3180 wxBoxSizer* pCOGUPFilterRow = new wxBoxSizer(wxHORIZONTAL);
3181 itemBoxSizerUI->Add(pCOGUPFilterRow, 0, wxALL | wxEXPAND,
3182 group_item_spacing);
3183
3184 pCOGUPUpdateSecs =
3185 new wxTextCtrl(m_ChartDisplayPage, ID_OPTEXTCTRL, "", wxDefaultPosition,
3186 wxSize(50, -1), wxTE_RIGHT);
3187 pCOGUPFilterRow->Add(pCOGUPUpdateSecs, 0, wxALL, group_item_spacing);
3188
3189 pCOGUPFilterRow->Add(
3190 new wxStaticText(m_ChartDisplayPage, wxID_ANY, _("seconds")),
3191 inputFlags);
3192
3193 // spacer
3194 itemBoxSizerUI->Add(0, border_size * 8);
3195 itemBoxSizerUI->Add(0, border_size * 8);
3196
3197 // Chart Zoom Scale Weighting
3198 wxStaticText* zoomTextHead = new wxStaticText(
3199 m_ChartDisplayPage, wxID_ANY, _("Chart Zoom/Scale Weighting"));
3200
3201 itemBoxSizerUI->Add(zoomTextHead, labelFlags);
3202 itemBoxSizerUI->Add(0, border_size * 1);
3203 itemBoxSizerUI->Add(0, border_size * 1);
3204
3205 wxStaticText* zoomText = new wxStaticText(
3206 m_ChartDisplayPage, wxID_ANY,
3207 _("With a lower value, the same zoom level shows a less detailed chart.\n\
3208With a higher value, the same zoom level shows a more detailed chart."));
3209
3210 smallFont = *dialogFont; // we can't use Smaller() because
3211 // wx2.8 doesn't support it
3212 smallFont.SetPointSize((smallFont.GetPointSize() / 1.2) +
3213 0.5); // + 0.5 to round instead of truncate
3214 zoomText->SetFont(smallFont);
3215 itemBoxSizerUI->Add(zoomText, 0, wxALL | wxEXPAND, group_item_spacing);
3216
3217 // spacer
3218 /*itemBoxSizerUI->Add(0, border_size * 8); itemBoxSizerUI->Add(0,
3219 * border_size * 8);*/
3220
3221 // wxSize sz = g_Platform->getDisplaySize();
3222
3223 itemBoxSizerUI->Add(
3224 new wxStaticText(m_ChartDisplayPage, wxID_ANY, _("Raster")),
3225 labelFlags);
3226 m_pSlider_Zoom_Raster =
3227 new wxSlider(m_ChartDisplayPage, ID_RASTERZOOM, 0, -5, 5,
3228 wxDefaultPosition, m_sliderSize, SLIDER_STYLE);
3229
3230#ifdef __ANDROID__
3231 prepareSlider(m_pSlider_Zoom_Raster);
3232#endif
3233
3234 itemBoxSizerUI->Add(m_pSlider_Zoom_Raster, inputFlags);
3235
3236 itemBoxSizerUI->Add(
3237 new wxStaticText(m_ChartDisplayPage, wxID_ANY, _("Vector")),
3238 labelFlags);
3239 m_pSlider_Zoom_Vector =
3240 new wxSlider(m_ChartDisplayPage, ID_VECZOOM, 0, -5, 5,
3241 wxDefaultPosition, m_sliderSize, SLIDER_STYLE);
3242
3243#ifdef __ANDROID__
3244 prepareSlider(m_pSlider_Zoom_Vector);
3245#endif
3246
3247 itemBoxSizerUI->Add(m_pSlider_Zoom_Vector, inputFlags);
3248
3249 // Spacer
3250 itemBoxSizerUI->Add(0, border_size * 3);
3251 itemBoxSizerUI->Add(0, border_size * 3);
3252
3253 itemBoxSizerUI->Add(
3254 new wxStaticText(m_ChartDisplayPage, wxID_ANY, _("CM93 Detail level")),
3255 labelFlags);
3256 m_pSlider_CM93_Zoom =
3257 new wxSlider(m_ChartDisplayPage, ID_CM93ZOOM, 0,
3258 -CM93_ZOOM_FACTOR_MAX_RANGE, CM93_ZOOM_FACTOR_MAX_RANGE,
3259 wxDefaultPosition, m_sliderSize, SLIDER_STYLE);
3260
3261#ifdef __ANDROID__
3262 prepareSlider(m_pSlider_CM93_Zoom);
3263#endif
3264
3265 itemBoxSizerUI->Add(m_pSlider_CM93_Zoom, 0, wxALL, border_size);
3266
3267 // spacer
3268 itemBoxSizerUI->Add(0, border_size * 3);
3269 itemBoxSizerUI->Add(0, border_size * 3);
3270 itemBoxSizerUI->Add(0, border_size * 3);
3271 itemBoxSizerUI->Add(0, border_size * 3);
3272 itemBoxSizerUI->Add(0, border_size * 3);
3273 itemBoxSizerUI->Add(0, border_size * 3);
3274
3275#ifndef __ANDROID__
3276 // Display size/DPI
3277 itemBoxSizerUI->Add(new wxStaticText(m_ChartDisplayPage, wxID_ANY,
3278 _("Physical Screen Width")),
3279 labelFlags);
3280 wxBoxSizer* pDPIRow = new wxBoxSizer(wxHORIZONTAL);
3281 itemBoxSizerUI->Add(pDPIRow, 0, wxEXPAND);
3282
3283 pRBSizeAuto = new wxRadioButton(m_ChartDisplayPage, wxID_ANY, _("Auto"));
3284 pDPIRow->Add(pRBSizeAuto, inputFlags);
3285 pDPIRow->AddSpacer(10);
3286 pRBSizeManual = new wxRadioButton(m_ChartDisplayPage,
3287 ID_SIZEMANUALRADIOBUTTON, _("Manual:"));
3288 pDPIRow->Add(pRBSizeManual, inputFlags);
3289
3290 pScreenMM =
3291 new wxTextCtrl(m_ChartDisplayPage, ID_OPTEXTCTRL, "", wxDefaultPosition,
3292 wxSize(3 * m_fontHeight, -1), wxTE_RIGHT);
3293 pDPIRow->Add(pScreenMM, 0, wxALL, group_item_spacing);
3294
3295 pDPIRow->Add(new wxStaticText(m_ChartDisplayPage, wxID_ANY, _("mm")),
3296 inputFlags);
3297
3298 pRBSizeAuto->Connect(wxEVT_COMMAND_RADIOBUTTON_SELECTED,
3299 wxCommandEventHandler(options::OnSizeAutoButton), NULL,
3300 this);
3301 pRBSizeManual->Connect(wxEVT_COMMAND_RADIOBUTTON_SELECTED,
3302 wxCommandEventHandler(options::OnSizeManualButton),
3303 NULL, this);
3304#endif
3305 // spacer
3306 itemBoxSizerUI->Add(0, border_size * 3);
3307 itemBoxSizerUI->Add(0, border_size * 3);
3308
3309#ifdef ocpnUSE_GL
3310
3311 // OpenGL Options
3312 itemBoxSizerUI->Add(
3313 new wxStaticText(m_ChartDisplayPage, wxID_ANY, _("Graphics")),
3314 labelFlags);
3315 wxBoxSizer* OpenGLSizer = new wxBoxSizer(wxHORIZONTAL);
3316 itemBoxSizerUI->Add(OpenGLSizer, 0, 0, 0);
3317
3318 pOpenGL = new wxCheckBox(m_ChartDisplayPage, ID_OPENGLBOX,
3319 _("Use Accelerated Graphics (OpenGL)"));
3320 OpenGLSizer->Add(pOpenGL, inputFlags);
3321 pOpenGL->Enable(!g_bdisable_opengl && g_Platform->IsGLCapable());
3322
3323 pOpenGL->Connect(wxEVT_COMMAND_CHECKBOX_CLICKED,
3324 wxCommandEventHandler(options::OnGLClicked), NULL, this);
3325
3326#ifdef __ANDROID__
3327 pOpenGL->Disable();
3328#endif
3329
3330 auto* bOpenGL = new wxButton(m_ChartDisplayPage, ID_OPENGLOPTIONS,
3331 _("Options") + "...");
3332 OpenGLSizer->Add(bOpenGL, inputFlags);
3333
3334 // spacer
3335 itemBoxSizerUI->Add(0, border_size * 3);
3336 itemBoxSizerUI->Add(0, border_size * 3);
3337
3338#endif
3339
3340 // ChartBar Options
3341 itemBoxSizerUI->Add(
3342 new wxStaticText(m_ChartDisplayPage, wxID_ANY, _("Chart Bar")),
3343 labelFlags);
3344 wxBoxSizer* ChartBarSizer = new wxBoxSizer(wxHORIZONTAL);
3345 itemBoxSizerUI->Add(ChartBarSizer, 0, 0, 0);
3346
3347 pChartBarEX = new wxCheckBox(m_ChartDisplayPage, -1,
3348 _("Show extended chart bar information."));
3349 ChartBarSizer->Add(pChartBarEX, inputFlags);
3350
3351 /*
3352 pTransparentToolbar =
3353 new wxCheckBox(m_ChartDisplayPage, ID_TRANSTOOLBARCHECKBOX,
3354 _("Enable Transparent Toolbar"));
3355 itemBoxSizerUI->Add(pTransparentToolbar, 0, wxALL, border_size);
3356 if (g_bopengl && !g_bTransparentToolbarInOpenGLOK)
3357 pTransparentToolbar->Disable();
3358 */
3359 }
3360#ifdef __WXGTK__
3361 m_ChartDisplayPage->Fit();
3362#endif
3363}
3364
3365void options::CreatePanel_VectorCharts(size_t parent, int border_size,
3366 int group_item_spacing) {
3367 ps57Ctl = AddPage(parent, _("Vector Chart Display"));
3368
3369 if (!m_bcompact) {
3370 vectorPanel = new wxBoxSizer(wxHORIZONTAL);
3371 ps57Ctl->SetSizer(vectorPanel);
3372
3373 // 1st column, all options except Mariner's Standard
3374 wxFlexGridSizer* optionsColumn = new wxFlexGridSizer(2);
3375 optionsColumn->SetHGap(border_size);
3376 optionsColumn->AddGrowableCol(0, 2);
3377 optionsColumn->AddGrowableCol(1, 3);
3378 vectorPanel->Add(optionsColumn, 3, wxALL | wxEXPAND, border_size);
3379
3380 // spacer
3381 optionsColumn->Add(new wxStaticText(ps57Ctl, wxID_ANY, ""));
3382 optionsColumn->Add(new wxStaticText(ps57Ctl, wxID_ANY, ""));
3383
3384 if (!g_useMUI) {
3385 // display category
3386 optionsColumn->Add(
3387 new wxStaticText(ps57Ctl, wxID_ANY, _("Display Category")),
3388 labelFlags);
3389 wxString pDispCatStrings[] = {_("Base"), _("Standard"), _("All"),
3390 _("Mariner's Standard")};
3391 pDispCat = new wxChoice(ps57Ctl, ID_RADARDISTUNIT, wxDefaultPosition,
3392 wxDefaultSize, 4, pDispCatStrings);
3393 optionsColumn->Add(pDispCat, 0, wxALL, 2);
3394 }
3395
3396 // spacer
3397 optionsColumn->Add(new wxStaticText(ps57Ctl, wxID_ANY, ""));
3398 optionsColumn->Add(new wxStaticText(ps57Ctl, wxID_ANY, ""));
3399
3400 // display options
3401 optionsColumn->Add(new wxStaticText(ps57Ctl, wxID_ANY, ""),
3402 groupLabelFlags);
3403
3404 wxBoxSizer* miscSizer = new wxBoxSizer(wxVERTICAL);
3405 optionsColumn->Add(miscSizer, groupInputFlags);
3406
3407 if (!g_useMUI) {
3408 pCheck_SOUNDG =
3409 new wxCheckBox(ps57Ctl, ID_SOUNDGCHECKBOX, _("Depth Soundings"));
3410 pCheck_SOUNDG->SetValue(FALSE);
3411 miscSizer->Add(pCheck_SOUNDG, verticleInputFlags);
3412 }
3413
3414 pCheck_META = new wxCheckBox(ps57Ctl, ID_METACHECKBOX,
3415 _("Chart Information Objects"));
3416 pCheck_META->SetValue(FALSE);
3417 miscSizer->Add(pCheck_META, verticleInputFlags);
3418
3419 if (!g_useMUI) {
3420 optionsColumn->Add(new wxStaticText(ps57Ctl, wxID_ANY, _("Buoys/Lights")),
3421 groupLabelFlags);
3422
3423 wxBoxSizer* lightSizer = new wxBoxSizer(wxVERTICAL);
3424 optionsColumn->Add(lightSizer, groupInputFlags);
3425
3426 pCheck_ATONTEXT =
3427 new wxCheckBox(ps57Ctl, ID_ATONTEXTCHECKBOX, _("Buoy/Light Labels"));
3428 pCheck_ATONTEXT->SetValue(FALSE);
3429 lightSizer->Add(pCheck_ATONTEXT, verticleInputFlags);
3430
3431 pCheck_LDISTEXT =
3432 new wxCheckBox(ps57Ctl, ID_LDISTEXTCHECKBOX, _("Light Descriptions"));
3433 pCheck_LDISTEXT->SetValue(FALSE);
3434 lightSizer->Add(pCheck_LDISTEXT, verticleInputFlags);
3435
3436 pCheck_XLSECTTEXT = new wxCheckBox(ps57Ctl, ID_LDISTEXTCHECKBOX,
3437 _("Extended Light Sectors"));
3438 pCheck_XLSECTTEXT->SetValue(FALSE);
3439 lightSizer->Add(pCheck_XLSECTTEXT, verticleInputFlags);
3440 }
3441
3442 optionsColumn->Add(new wxStaticText(ps57Ctl, wxID_ANY, _("Chart Texts")),
3443 groupLabelFlags);
3444
3445 wxBoxSizer* textSizer = new wxBoxSizer(wxVERTICAL);
3446 optionsColumn->Add(textSizer, groupInputFlags);
3447
3448 pCheck_NATIONALTEXT = new wxCheckBox(ps57Ctl, ID_NATIONALTEXTCHECKBOX,
3449 _("National text on chart"));
3450 pCheck_NATIONALTEXT->SetValue(FALSE);
3451 textSizer->Add(pCheck_NATIONALTEXT, verticleInputFlags);
3452
3453 pCheck_SHOWIMPTEXT =
3454 new wxCheckBox(ps57Ctl, ID_IMPTEXTCHECKBOX, _("Important Text Only"));
3455 pCheck_SHOWIMPTEXT->SetValue(FALSE);
3456 textSizer->Add(pCheck_SHOWIMPTEXT, verticleInputFlags);
3457
3458 pCheck_DECLTEXT =
3459 new wxCheckBox(ps57Ctl, ID_DECLTEXTCHECKBOX, _("De-Cluttered Text"));
3460 pCheck_DECLTEXT->SetValue(FALSE);
3461 textSizer->Add(pCheck_DECLTEXT, verticleInputFlags);
3462
3463 optionsColumn->Add(new wxStaticText(ps57Ctl, wxID_ANY, _("Chart Detail")),
3464 labelFlags);
3465 pCheck_SCAMIN = new wxCheckBox(ps57Ctl, ID_SCAMINCHECKBOX,
3466 _("Reduced Detail at Small Scale"));
3467 pCheck_SCAMIN->SetValue(FALSE);
3468 optionsColumn->Add(pCheck_SCAMIN, inputFlags);
3469
3470 optionsColumn->Add(new wxStaticText(ps57Ctl, wxID_ANY, ""), labelFlags);
3471 pCheck_SuperSCAMIN =
3472 new wxCheckBox(ps57Ctl, ID_SUPERSCAMINCHECKBOX,
3473 _("Additional detail reduction at Small Scale"));
3474 pCheck_SuperSCAMIN->SetValue(FALSE);
3475 optionsColumn->Add(pCheck_SuperSCAMIN, inputFlags);
3476
3477 // spacer
3478 optionsColumn->Add(0, border_size * 4);
3479 optionsColumn->Add(0, border_size * 4);
3480
3481 wxSize item_size = wxSize(-1, -1);
3482#ifdef __ANDROID__
3483 item_size = wxSize(m_fontHeight * 3, m_fontHeight);
3484#endif
3485
3486 // graphics options
3487 optionsColumn->Add(new wxStaticText(ps57Ctl, wxID_ANY, _("Graphics Style")),
3488 labelFlags);
3489 wxString pPointStyleStrings[] = {
3490 _("Paper Chart"),
3491 _("Simplified"),
3492 };
3493 pPointStyle = new wxChoice(ps57Ctl, ID_RADARDISTUNIT, wxDefaultPosition,
3494 item_size, 2, pPointStyleStrings);
3495 optionsColumn->Add(pPointStyle, inputFlags);
3496
3497 optionsColumn->Add(new wxStaticText(ps57Ctl, wxID_ANY, _("Boundaries")),
3498 labelFlags);
3499 wxString pBoundStyleStrings[] = {
3500 _("Plain"),
3501 _("Symbolized"),
3502 };
3503 pBoundStyle = new wxChoice(ps57Ctl, ID_RADARDISTUNIT, wxDefaultPosition,
3504 item_size, 2, pBoundStyleStrings);
3505 optionsColumn->Add(pBoundStyle, inputFlags);
3506
3507 optionsColumn->Add(new wxStaticText(ps57Ctl, wxID_ANY, _("Colors")),
3508 labelFlags);
3509 wxString pColorNumStrings[] = {
3510 _("2 Color"),
3511 _("4 Color"),
3512 };
3513 p24Color = new wxChoice(ps57Ctl, ID_RADARDISTUNIT, wxDefaultPosition,
3514 item_size, 2, pColorNumStrings);
3515 optionsColumn->Add(p24Color, inputFlags);
3516
3517 // spacer
3518 optionsColumn->Add(0, border_size * 4);
3519 optionsColumn->Add(0, border_size * 4);
3520
3521 item_size = wxSize(60, -1);
3522#ifdef __ANDROID__
3523 item_size = wxSize(m_fontHeight * 2, m_fontHeight);
3524#endif
3525
3526 // depth options
3527 optionsColumn->Add(new wxStaticText(ps57Ctl, wxID_ANY, _("Shallow Depth")),
3528 labelFlags);
3529 wxBoxSizer* depShalRow = new wxBoxSizer(wxHORIZONTAL);
3530 optionsColumn->Add(depShalRow);
3531 m_ShallowCtl = new wxTextCtrl(ps57Ctl, ID_OPTEXTCTRL, "", wxDefaultPosition,
3532 item_size, wxTE_RIGHT);
3533 depShalRow->Add(m_ShallowCtl, inputFlags);
3534 m_depthUnitsShal = new wxStaticText(ps57Ctl, wxID_ANY, _("meters"));
3535 depShalRow->Add(m_depthUnitsShal, inputFlags);
3536
3537 optionsColumn->Add(new wxStaticText(ps57Ctl, wxID_ANY, _("Safety Depth")),
3538 labelFlags);
3539 wxBoxSizer* depSafeRow = new wxBoxSizer(wxHORIZONTAL);
3540 optionsColumn->Add(depSafeRow);
3541 m_SafetyCtl = new wxTextCtrl(ps57Ctl, ID_OPTEXTCTRL, "", wxDefaultPosition,
3542 item_size, wxTE_RIGHT);
3543 depSafeRow->Add(m_SafetyCtl, inputFlags);
3544 m_depthUnitsSafe = new wxStaticText(ps57Ctl, wxID_ANY, _("meters"));
3545 depSafeRow->Add(m_depthUnitsSafe, inputFlags);
3546
3547 optionsColumn->Add(new wxStaticText(ps57Ctl, wxID_ANY, _("Deep Depth")),
3548 labelFlags);
3549 wxBoxSizer* depDeepRow = new wxBoxSizer(wxHORIZONTAL);
3550 optionsColumn->Add(depDeepRow);
3551 m_DeepCtl = new wxTextCtrl(ps57Ctl, ID_OPTEXTCTRL, "", wxDefaultPosition,
3552 item_size, wxTE_RIGHT);
3553 depDeepRow->Add(m_DeepCtl, inputFlags);
3554 m_depthUnitsDeep = new wxStaticText(ps57Ctl, wxID_ANY, _("meters"));
3555 depDeepRow->Add(m_depthUnitsDeep, inputFlags);
3556
3557 // 2nd column, Display Category / Mariner's Standard options
3558 wxBoxSizer* dispSizer = new wxBoxSizer(wxVERTICAL);
3559 vectorPanel->Add(dispSizer, 2, wxALL | wxEXPAND, border_size);
3560
3561 wxStaticBox* marinersBox =
3562 new wxStaticBox(ps57Ctl, wxID_ANY, _("User Standard Objects"));
3563 wxStaticBoxSizer* marinersSizer =
3564 new wxStaticBoxSizer(marinersBox, wxVERTICAL);
3565 dispSizer->Add(marinersSizer, 1, wxALL | wxEXPAND, border_size);
3566
3567 ps57CtlListBox = new OCPNCheckedListCtrl(
3568 ps57Ctl, ID_CHECKLISTBOX, wxDefaultPosition, wxSize(250, 350));
3569 marinersSizer->Add(ps57CtlListBox, 1, wxALL | wxEXPAND, group_item_spacing);
3570
3571 wxBoxSizer* btnRow1 = new wxBoxSizer(wxHORIZONTAL);
3572 itemButtonSelectList =
3573 new wxButton(ps57Ctl, ID_SELECTLIST, _("Select All"));
3574 btnRow1->Add(itemButtonSelectList, 1, wxALL | wxEXPAND, group_item_spacing);
3575 itemButtonClearList = new wxButton(ps57Ctl, ID_CLEARLIST, _("Clear All"));
3576 btnRow1->Add(itemButtonClearList, 1, wxALL | wxEXPAND, group_item_spacing);
3577 marinersSizer->Add(btnRow1);
3578
3579 wxBoxSizer* btnRow2 = new wxBoxSizer(wxHORIZONTAL);
3580 itemButtonSetStd =
3581 new wxButton(ps57Ctl, ID_SETSTDLIST, _("Reset to STANDARD"));
3582 btnRow2->Add(itemButtonSetStd, 1, wxALL | wxEXPAND, group_item_spacing);
3583 marinersSizer->Add(btnRow2);
3584
3585 }
3586
3587 else { // compact
3588 vectorPanel = new wxBoxSizer(wxVERTICAL);
3589 ps57Ctl->SetSizer(vectorPanel);
3590
3591 wxBoxSizer* optionsColumn = vectorPanel;
3592
3593 // spacer
3594 optionsColumn->Add(new wxStaticText(ps57Ctl, wxID_ANY, ""));
3595
3596 // display category
3597 if (!g_useMUI) {
3598 optionsColumn->Add(
3599 new wxStaticText(ps57Ctl, wxID_ANY, _("Display Category")),
3600 inputFlags);
3601 wxString pDispCatStrings[] = {_("Base"), _("Standard"), _("All"),
3602 _("Mariner's Standard")};
3603 pDispCat = new wxChoice(ps57Ctl, ID_RADARDISTUNIT, wxDefaultPosition,
3604 wxSize(350, -1), 4, pDispCatStrings);
3605 optionsColumn->Add(pDispCat, 0, wxALL, 2);
3606
3607 // spacer
3608 optionsColumn->Add(new wxStaticText(ps57Ctl, wxID_ANY, ""));
3609 }
3610
3611 // display options
3612
3613 wxBoxSizer* miscSizer = new wxBoxSizer(wxVERTICAL);
3614 optionsColumn->Add(miscSizer, groupInputFlags);
3615
3616 pCheck_SOUNDG =
3617 new wxCheckBox(ps57Ctl, ID_SOUNDGCHECKBOX, _("Depth Soundings"));
3618 pCheck_SOUNDG->SetValue(FALSE);
3619 miscSizer->Add(pCheck_SOUNDG, inputFlags);
3620
3621 pCheck_META = new wxCheckBox(ps57Ctl, ID_METACHECKBOX,
3622 _("Chart Information Objects"));
3623 pCheck_META->SetValue(FALSE);
3624 miscSizer->Add(pCheck_META, inputFlags);
3625
3626 wxBoxSizer* lightSizer = new wxBoxSizer(wxVERTICAL);
3627 optionsColumn->Add(lightSizer, groupInputFlags);
3628
3629 pCheck_ATONTEXT =
3630 new wxCheckBox(ps57Ctl, ID_ATONTEXTCHECKBOX, _("Buoy/Light Labels"));
3631 pCheck_ATONTEXT->SetValue(FALSE);
3632 lightSizer->Add(pCheck_ATONTEXT, inputFlags);
3633
3634 pCheck_LDISTEXT =
3635 new wxCheckBox(ps57Ctl, ID_LDISTEXTCHECKBOX, _("Light Descriptions"));
3636 pCheck_LDISTEXT->SetValue(FALSE);
3637 lightSizer->Add(pCheck_LDISTEXT, inputFlags);
3638
3639 pCheck_XLSECTTEXT = new wxCheckBox(ps57Ctl, ID_LDISTEXTCHECKBOX,
3640 _("Extended Light Sectors"));
3641 pCheck_XLSECTTEXT->SetValue(FALSE);
3642 lightSizer->Add(pCheck_XLSECTTEXT, inputFlags);
3643
3644 wxBoxSizer* textSizer = new wxBoxSizer(wxVERTICAL);
3645 optionsColumn->Add(textSizer, groupInputFlags);
3646
3647 pCheck_NATIONALTEXT = new wxCheckBox(ps57Ctl, ID_NATIONALTEXTCHECKBOX,
3648 _("National text on chart"));
3649 pCheck_NATIONALTEXT->SetValue(FALSE);
3650 textSizer->Add(pCheck_NATIONALTEXT, inputFlags);
3651
3652 pCheck_SHOWIMPTEXT =
3653 new wxCheckBox(ps57Ctl, ID_IMPTEXTCHECKBOX, _("Important Text Only"));
3654 pCheck_SHOWIMPTEXT->SetValue(FALSE);
3655 textSizer->Add(pCheck_SHOWIMPTEXT, inputFlags);
3656
3657 pCheck_DECLTEXT =
3658 new wxCheckBox(ps57Ctl, ID_DECLTEXTCHECKBOX, _("De-Cluttered Text"));
3659 pCheck_DECLTEXT->SetValue(FALSE);
3660 textSizer->Add(pCheck_DECLTEXT, inputFlags);
3661
3662 pCheck_SCAMIN = new wxCheckBox(ps57Ctl, ID_SCAMINCHECKBOX,
3663 _("Reduced Detail at Small Scale"));
3664 pCheck_SCAMIN->SetValue(FALSE);
3665 optionsColumn->Add(pCheck_SCAMIN, inputFlags);
3666
3667 optionsColumn->Add(new wxStaticText(ps57Ctl, wxID_ANY, ""), labelFlags);
3668 pCheck_SuperSCAMIN =
3669 new wxCheckBox(ps57Ctl, ID_SUPERSCAMINCHECKBOX,
3670 _("Additional detail reduction at Small Scale"));
3671 pCheck_SuperSCAMIN->SetValue(FALSE);
3672 optionsColumn->Add(pCheck_SuperSCAMIN, inputFlags);
3673
3674 // spacer
3675 optionsColumn->Add(0, border_size * 4);
3676 optionsColumn->Add(0, border_size * 4);
3677
3678 // graphics options
3679
3680 wxFlexGridSizer* StyleColumn = new wxFlexGridSizer(2);
3681 StyleColumn->SetHGap(border_size);
3682 StyleColumn->AddGrowableCol(0, 2);
3683 StyleColumn->AddGrowableCol(1, 3);
3684 optionsColumn->Add(StyleColumn);
3685
3686 StyleColumn->Add(new wxStaticText(ps57Ctl, wxID_ANY, _("Graphics Style")),
3687 inputFlags);
3688 wxString pPointStyleStrings[] = {
3689 _("Paper Chart"),
3690 _("Simplified"),
3691 };
3692 pPointStyle = new wxChoice(ps57Ctl, ID_RADARDISTUNIT, wxDefaultPosition,
3693 wxSize(m_fontHeight * 3, m_fontHeight), 2,
3694 pPointStyleStrings);
3695#ifdef __ANDROID__
3696 setChoiceStyleSheet(pPointStyle, m_fontHeight * 8 / 10);
3697#endif
3698
3699 StyleColumn->Add(pPointStyle, inputFlags);
3700
3701 StyleColumn->Add(new wxStaticText(ps57Ctl, wxID_ANY, _("Boundaries")),
3702 inputFlags);
3703 wxString pBoundStyleStrings[] = {
3704 _("Plain"),
3705 _("Symbolized"),
3706 };
3707 pBoundStyle = new wxChoice(ps57Ctl, ID_RADARDISTUNIT, wxDefaultPosition,
3708 wxSize(m_fontHeight * 3, m_fontHeight), 2,
3709 pBoundStyleStrings);
3710#ifdef __ANDROID__
3711 setChoiceStyleSheet(pBoundStyle, m_fontHeight * 8 / 10);
3712#endif
3713
3714 StyleColumn->Add(pBoundStyle, inputFlags);
3715
3716 StyleColumn->Add(new wxStaticText(ps57Ctl, wxID_ANY, _("Colors")),
3717 inputFlags);
3718
3719 wxString pColorNumStrings[] = {
3720 _("2 Color"),
3721 _("4 Color"),
3722 };
3723 p24Color = new wxChoice(ps57Ctl, ID_RADARDISTUNIT, wxDefaultPosition,
3724 wxSize(m_fontHeight * 3, m_fontHeight), 2,
3725 pColorNumStrings);
3726#ifdef __ANDROID__
3727 setChoiceStyleSheet(p24Color, m_fontHeight * 8 / 10);
3728#endif
3729 StyleColumn->Add(p24Color, inputFlags);
3730
3731 // spacer
3732 optionsColumn->Add(0, border_size * 4);
3733 optionsColumn->Add(0, border_size * 4);
3734
3735 wxFlexGridSizer* DepthColumn = new wxFlexGridSizer(3);
3736 DepthColumn->SetHGap(border_size);
3737 DepthColumn->AddGrowableCol(0, 3);
3738 DepthColumn->AddGrowableCol(1, 2);
3739 DepthColumn->AddGrowableCol(2, 3);
3740 optionsColumn->Add(DepthColumn);
3741
3742 // depth options
3743 DepthColumn->Add(new wxStaticText(ps57Ctl, wxID_ANY, _("Shallow Depth")),
3744 inputFlags);
3745 m_ShallowCtl =
3746 new wxTextCtrl(ps57Ctl, ID_OPTEXTCTRL, "", wxDefaultPosition,
3747 wxSize(m_fontHeight * 2, m_fontHeight), wxTE_RIGHT);
3748 DepthColumn->Add(m_ShallowCtl, inputFlags);
3749 m_depthUnitsShal = new wxStaticText(ps57Ctl, wxID_ANY, _("meters"));
3750 DepthColumn->Add(m_depthUnitsShal, inputFlags);
3751
3752 DepthColumn->Add(new wxStaticText(ps57Ctl, wxID_ANY, _("Safety Depth")),
3753 inputFlags);
3754 m_SafetyCtl =
3755 new wxTextCtrl(ps57Ctl, ID_OPTEXTCTRL, "", wxDefaultPosition,
3756 wxSize(m_fontHeight * 2, m_fontHeight), wxTE_RIGHT);
3757 DepthColumn->Add(m_SafetyCtl, inputFlags);
3758 m_depthUnitsSafe = new wxStaticText(ps57Ctl, wxID_ANY, _("meters"));
3759 DepthColumn->Add(m_depthUnitsSafe, inputFlags);
3760
3761 DepthColumn->Add(new wxStaticText(ps57Ctl, wxID_ANY, _("Deep Depth")),
3762 inputFlags);
3763 m_DeepCtl =
3764 new wxTextCtrl(ps57Ctl, ID_OPTEXTCTRL, "", wxDefaultPosition,
3765 wxSize(m_fontHeight * 2, m_fontHeight), wxTE_CENTER);
3766 DepthColumn->Add(m_DeepCtl, inputFlags);
3767 m_depthUnitsDeep = new wxStaticText(ps57Ctl, wxID_ANY, _("meters"));
3768 DepthColumn->Add(m_depthUnitsDeep, inputFlags);
3769
3770 // spacer
3771 optionsColumn->Add(0, border_size * 4);
3772 optionsColumn->Add(0, border_size * 4);
3773
3774 // Display Category / Mariner's Standard options
3775 wxBoxSizer* dispSizer = new wxBoxSizer(wxVERTICAL);
3776 vectorPanel->Add(dispSizer, 2, wxALL | wxEXPAND, border_size);
3777
3778 wxStaticBox* marinersBox =
3779 new wxStaticBox(ps57Ctl, wxID_ANY, _("User Standard Objects"));
3780 wxStaticBoxSizer* marinersSizer =
3781 new wxStaticBoxSizer(marinersBox, wxVERTICAL);
3782 dispSizer->Add(marinersSizer, 1, wxALL | wxEXPAND, border_size);
3783
3784 wxBoxSizer* btnRow1 = new wxBoxSizer(wxHORIZONTAL);
3785 itemButtonSelectList =
3786 new wxButton(ps57Ctl, ID_SELECTLIST, _("Select All"));
3787 btnRow1->Add(itemButtonSelectList, 1, wxALL | wxEXPAND, group_item_spacing);
3788 itemButtonClearList = new wxButton(ps57Ctl, ID_CLEARLIST, _("Clear All"));
3789 btnRow1->Add(itemButtonClearList, 1, wxALL | wxEXPAND, group_item_spacing);
3790 marinersSizer->Add(btnRow1);
3791
3792 wxBoxSizer* btnRow2 = new wxBoxSizer(wxHORIZONTAL);
3793 itemButtonSetStd =
3794 new wxButton(ps57Ctl, ID_SETSTDLIST, _("Reset to STANDARD"));
3795 btnRow2->Add(itemButtonSetStd, 1, wxALL | wxEXPAND, group_item_spacing);
3796 marinersSizer->Add(btnRow2);
3797
3798 ps57CtlListBox = new OCPNCheckedListCtrl(
3799 ps57Ctl, ID_CHECKLISTBOX, wxDefaultPosition, wxSize(250, 350));
3800
3801 marinersSizer->Add(ps57CtlListBox, 1, wxALL | wxEXPAND, group_item_spacing);
3802 }
3803}
3804
3805void options::CreatePanel_TidesCurrents(size_t parent, int border_size,
3806 int group_item_spacing) {
3807 wxScrolledWindow* tcPanel = AddPage(parent, _("Tides && Currents"));
3808
3809 wxBoxSizer* mainHBoxSizer = new wxBoxSizer(wxVERTICAL);
3810 tcPanel->SetSizer(mainHBoxSizer);
3811
3812 wxStaticBox* tcBox = new wxStaticBox(tcPanel, wxID_ANY, _("Active Datasets"));
3813 wxStaticBoxSizer* tcSizer = new wxStaticBoxSizer(tcBox, wxHORIZONTAL);
3814 mainHBoxSizer->Add(tcSizer, 1, wxALL | wxEXPAND, border_size);
3815
3816 tcDataSelected =
3817 new wxListCtrl(tcPanel, ID_TIDESELECTED, wxDefaultPosition,
3818 wxSize(100, -1), wxLC_REPORT | wxLC_NO_HEADER);
3819
3820 tcSizer->Add(tcDataSelected, 1, wxALL | wxEXPAND, border_size);
3821
3822 // Populate Selection List Control with the contents
3823 // of the Global static array
3824 tcDataSelected->DeleteAllItems();
3825
3826 // Add first column
3827 wxListItem col0;
3828 col0.SetId(0);
3829 col0.SetText("");
3830 col0.SetWidth(500);
3831 col0.SetAlign(wxLIST_FORMAT_LEFT);
3832
3833 tcDataSelected->InsertColumn(0, col0);
3834
3835 int w = 400, w1, h;
3836 unsigned int id = 0;
3837 for (auto ds : TideCurrentDataSet) {
3838 wxListItem li;
3839 li.SetId(id);
3840 tcDataSelected->InsertItem(li);
3841
3842 wxString setName = ds;
3843 tcDataSelected->SetItem(id, 0, setName);
3844 GetTextExtent(setName, &w1, &h);
3845 w = w1 > w ? w1 : w;
3846 ++id;
3847 }
3848
3849 // Disturbs Android Layout
3850#ifndef __ANDROID__
3851 tcDataSelected->SetColumnWidth(0, 20 + w);
3852#endif
3853
3854 // Add the "Insert/Remove" buttons
3855 wxButton* insertButton =
3856 new wxButton(tcPanel, ID_TCDATAADD, _("Add Dataset..."));
3857 wxButton* removeButton =
3858 new wxButton(tcPanel, ID_TCDATADEL, _("Remove Selected"));
3859
3860 wxBoxSizer* btnSizer = new wxBoxSizer(wxVERTICAL);
3861 tcSizer->Add(btnSizer);
3862
3863 btnSizer->Add(insertButton, 1, wxALL | wxEXPAND, group_item_spacing);
3864 btnSizer->Add(removeButton, 1, wxALL | wxEXPAND, group_item_spacing);
3865}
3866
3867void options::CreatePanel_ChartGroups(size_t parent, int border_size,
3868 int group_item_spacing) {
3869 // Special case for adding the tab here. We know this page has multiple tabs,
3870 // and we have the actual widgets in a separate class (because of its
3871 // complexity)
3872
3873 wxNotebook* chartsPageNotebook = (wxNotebook*)m_pListbook->GetPage(parent);
3874 wxScrolledWindow* sw = new ChartGroupsUI(chartsPageNotebook);
3875 sw->SetScrollRate(m_scrollRate, m_scrollRate);
3876 chartsPageNotebook->AddPage(sw, _("Chart Groups"));
3877 groupsPanel = dynamic_cast<ChartGroupsUI*>(sw);
3878
3879 groupsPanel->CreatePanel(parent, border_size, group_item_spacing);
3880}
3881
3882void ChartGroupsUI::CreatePanel(size_t parent, int border_size,
3883 int group_item_spacing) {
3884 modified = FALSE;
3885 m_border_size = border_size;
3886 m_group_item_spacing = group_item_spacing;
3887
3888 m_UIcomplete = FALSE;
3889
3890 CompletePanel();
3891}
3892
3893void ChartGroupsUI::CompletePanel() {
3894 m_panel = this;
3895 m_topSizer = new wxBoxSizer(wxVERTICAL);
3896 m_panel->SetSizer(m_topSizer);
3897
3898 // The chart file/dir tree
3899 wxStaticText* allChartsLabel =
3900 new wxStaticText(m_panel, wxID_ANY, _("All Available Charts"));
3901 m_topSizer->Add(allChartsLabel, 0, wxTOP | wxRIGHT | wxLEFT, m_border_size);
3902
3903 wxBoxSizer* sizerCharts = new wxBoxSizer(wxHORIZONTAL);
3904 m_topSizer->Add(sizerCharts, 1, wxALL | wxEXPAND, 5);
3905
3906 wxBoxSizer* activeListSizer = new wxBoxSizer(wxVERTICAL);
3907 sizerCharts->Add(activeListSizer, 1, wxALL | wxEXPAND, 5);
3908
3909#ifdef __ANDROID__
3910 allAvailableCtl =
3911 new wxGenericDirCtrl(m_panel, ID_GROUPAVAILABLE, "", wxDefaultPosition,
3912 wxDefaultSize, wxVSCROLL);
3913#else
3914 allAvailableCtl =
3915 new wxGenericDirCtrl(m_panel, ID_GROUPAVAILABLE, "", wxDefaultPosition,
3916 wxDefaultSize, wxVSCROLL);
3917#endif
3918 activeListSizer->Add(allAvailableCtl, 1, wxEXPAND);
3919
3920 m_pAddButton = new wxButton(m_panel, ID_GROUPINSERTDIR, _("Add"));
3921 m_pAddButton->Disable();
3922 m_pRemoveButton = new wxButton(m_panel, ID_GROUPREMOVEDIR, _("Remove Chart"));
3923 m_pRemoveButton->Disable();
3924
3925 m_pAddButton->Connect(wxEVT_COMMAND_BUTTON_CLICKED,
3926 wxCommandEventHandler(ChartGroupsUI::OnInsertChartItem),
3927 NULL, this);
3928 m_pRemoveButton->Connect(
3929 wxEVT_COMMAND_BUTTON_CLICKED,
3930 wxCommandEventHandler(ChartGroupsUI::OnRemoveChartItem), NULL, this);
3931
3932 wxBoxSizer* addRemove = new wxBoxSizer(wxVERTICAL);
3933 sizerCharts->Add(addRemove, 0, wxALL | wxEXPAND, m_border_size);
3934 addRemove->Add(m_pAddButton, 0, wxALL | wxEXPAND, m_group_item_spacing);
3935
3936 sizerCharts->AddSpacer(20); // Avoid potential scrollbar
3937
3938 // Add the Groups notebook control
3939 wxStaticText* groupsLabel =
3940 new wxStaticText(m_panel, wxID_ANY, _("Chart Groups"));
3941 m_topSizer->Add(groupsLabel, 0, wxTOP | wxRIGHT | wxLEFT, m_border_size);
3942
3943 wxBoxSizer* sizerGroups = new wxBoxSizer(wxHORIZONTAL);
3944 m_topSizer->Add(sizerGroups, 1, wxALL | wxEXPAND, 5);
3945
3946 wxBoxSizer* nbSizer = new wxBoxSizer(wxVERTICAL);
3947 sizerGroups->Add(nbSizer, 1, wxALL | wxEXPAND, m_border_size);
3948 m_GroupNB = new wxNotebook(m_panel, ID_GROUPNOTEBOOK, wxDefaultPosition,
3949 wxDefaultSize, wxNB_TOP);
3950 nbSizer->Add(m_GroupNB, 1, wxEXPAND);
3951
3952 m_GroupNB->Connect(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED,
3953 wxNotebookEventHandler(ChartGroupsUI::OnGroupPageChange),
3954 NULL, this);
3955
3956 // Add default (always present) Default Chart Group
3957 wxPanel* allActiveGroup =
3958 new wxPanel(m_GroupNB, -1, wxDefaultPosition, wxDefaultSize);
3959 m_GroupNB->AddPage(allActiveGroup, _("All Charts"));
3960
3961 wxBoxSizer* page0BoxSizer = new wxBoxSizer(wxHORIZONTAL);
3962 allActiveGroup->SetSizer(page0BoxSizer);
3963
3964 defaultAllCtl = new wxGenericDirCtrl(allActiveGroup, -1, "",
3965 wxDefaultPosition, wxDefaultSize);
3966
3967 // Set the Font for the All Active Chart Group tree to be italic, dimmed
3968 iFont = new wxFont(*dialogFont);
3969 iFont->SetStyle(wxFONTSTYLE_ITALIC);
3970 iFont->SetWeight(wxFONTWEIGHT_LIGHT);
3971
3972 page0BoxSizer->Add(defaultAllCtl, 1, wxALIGN_TOP | wxALL | wxEXPAND);
3973
3974 m_DirCtrlArray.Add(defaultAllCtl);
3975
3976 // Add the Chart Group (page) "New" and "Delete" buttons
3977 m_pNewGroupButton =
3978 new wxButton(m_panel, ID_GROUPNEWGROUP, _("New Group..."));
3979 m_pDeleteGroupButton =
3980 new wxButton(m_panel, ID_GROUPDELETEGROUP, _("Delete Group"));
3981 m_pDeleteGroupButton->Disable(); // for default "all Charts" group
3982
3983 m_pNewGroupButton->Connect(wxEVT_COMMAND_BUTTON_CLICKED,
3984 wxCommandEventHandler(ChartGroupsUI::OnNewGroup),
3985 NULL, this);
3986 m_pDeleteGroupButton->Connect(
3987 wxEVT_COMMAND_BUTTON_CLICKED,
3988 wxCommandEventHandler(ChartGroupsUI::OnDeleteGroup), NULL, this);
3989
3990 wxBoxSizer* newDeleteGrp = new wxBoxSizer(wxVERTICAL);
3991 sizerGroups->Add(newDeleteGrp, 0, wxALL, m_border_size);
3992
3993 newDeleteGrp->AddSpacer(25);
3994 newDeleteGrp->Add(m_pNewGroupButton, 0, wxALL | wxEXPAND,
3995 m_group_item_spacing);
3996 newDeleteGrp->AddSpacer(15);
3997 newDeleteGrp->Add(m_pDeleteGroupButton, 0, wxALL | wxEXPAND,
3998 m_group_item_spacing);
3999 newDeleteGrp->AddSpacer(25);
4000 newDeleteGrp->Add(m_pRemoveButton, 0, wxALL | wxEXPAND, m_group_item_spacing);
4001
4002 sizerGroups->AddSpacer(20); // Avoid potential scrollbar
4003
4004 // Connect this last, otherwise handler is called before all objects are
4005 // initialized.
4006 m_panel->Connect(wxEVT_COMMAND_TREE_SEL_CHANGED,
4007 wxTreeEventHandler(ChartGroupsUI::OnAvailableSelection),
4008 NULL, this);
4009
4010 m_UIcomplete = TRUE;
4011}
4012
4013void options::CreatePanel_Display(size_t parent, int border_size,
4014 int group_item_spacing) {
4015 // Skip the "General" tab for Android, nothing selectable there.
4016#ifdef __ANDROID__
4017 return;
4018#endif
4019
4020 pDisplayPanel = AddPage(parent, _("General"));
4021
4022 if (!m_bcompact) {
4023 wxFlexGridSizer* generalSizer = new wxFlexGridSizer(2);
4024 generalSizer->SetHGap(border_size);
4025 // generalSizer->AddGrowableCol( 0, 1 );
4026 // generalSizer->AddGrowableCol( 1, 1 );
4027 // pDisplayPanel->SetSizer( generalSizer );
4028
4029 // wxFlexGridSizer grows wrongly in wx2.8, so we need to centre it in
4030 // another sizer instead of letting it grow.
4031 wxBoxSizer* wrapperSizer = new wxBoxSizer(wxVERTICAL);
4032 pDisplayPanel->SetSizer(wrapperSizer);
4033 wrapperSizer->Add(generalSizer, 1, wxALL | wxALIGN_CENTER, border_size);
4034
4035 // spacer
4036 generalSizer->Add(0, border_size * 4);
4037 generalSizer->Add(0, border_size * 4);
4038
4039 if (!g_useMUI) {
4040 // Nav Mode
4041 generalSizer->Add(
4042 new wxStaticText(pDisplayPanel, wxID_ANY, _("Navigation Mode")),
4043 groupLabelFlags);
4044 wxBoxSizer* boxNavMode = new wxBoxSizer(wxVERTICAL);
4045 generalSizer->Add(boxNavMode, groupInputFlags);
4046
4047 wxBoxSizer* rowOrientation = new wxBoxSizer(wxHORIZONTAL);
4048 boxNavMode->Add(rowOrientation);
4049
4050 pCBNorthUp = new wxRadioButton(pDisplayPanel, wxID_ANY, _("North Up"));
4051 rowOrientation->Add(pCBNorthUp, inputFlags);
4052 pCBCourseUp =
4053 new wxRadioButton(pDisplayPanel, ID_COURSEUPCHECKBOX, _("Course Up"));
4054 rowOrientation->Add(pCBCourseUp,
4055 wxSizerFlags(0)
4056 .Align(wxALIGN_CENTRE_VERTICAL)
4057 .Border(wxLEFT, group_item_spacing * 2));
4058
4059 pCBLookAhead = new wxCheckBox(pDisplayPanel, ID_CHECK_LOOKAHEAD,
4060 _("Look Ahead Mode"));
4061 boxNavMode->Add(pCBLookAhead, verticleInputFlags);
4062
4063 // spacer
4064 generalSizer->Add(0, border_size * 4);
4065 generalSizer->Add(0, border_size * 4);
4066
4067 // Control Options
4068 generalSizer->Add(
4069 new wxStaticText(pDisplayPanel, wxID_ANY, _("Chart Display")),
4070 groupLabelFlags);
4071 wxBoxSizer* boxCharts = new wxBoxSizer(wxVERTICAL);
4072 generalSizer->Add(boxCharts, groupInputFlags);
4073
4074 pCDOQuilting = new wxCheckBox(pDisplayPanel, ID_QUILTCHECKBOX1,
4075 _("Enable Chart Quilting"));
4076 boxCharts->Add(pCDOQuilting, verticleInputFlags);
4077
4078 pPreserveScale =
4079 new wxCheckBox(pDisplayPanel, ID_PRESERVECHECKBOX,
4080 _("Preserve scale when switching charts"));
4081 boxCharts->Add(pPreserveScale, verticleInputFlags);
4082
4083 // spacer
4084 generalSizer->Add(0, border_size * 4);
4085 generalSizer->Add(0, border_size * 4);
4086 }
4087
4088 // Control Options
4089 generalSizer->Add(new wxStaticText(pDisplayPanel, wxID_ANY, _("Controls")),
4090 groupLabelFlags);
4091 wxBoxSizer* boxCtrls = new wxBoxSizer(wxVERTICAL);
4092 generalSizer->Add(boxCtrls, groupInputFlags);
4093
4094 pSmoothPanZoom = new wxCheckBox(pDisplayPanel, ID_SMOOTHPANZOOMBOX,
4095 _("Smooth Panning / Zooming"));
4096 boxCtrls->Add(pSmoothPanZoom, verticleInputFlags);
4097
4098 pEnableZoomToCursor =
4099 new wxCheckBox(pDisplayPanel, ID_ZTCCHECKBOX, _("Zoom to Cursor"));
4100 pEnableZoomToCursor->SetValue(FALSE);
4101 boxCtrls->Add(pEnableZoomToCursor, verticleInputFlags);
4102
4103 pEnableTenHertz = nullptr;
4104#ifndef ANDROID
4105 pEnableTenHertz = new wxCheckBox(pDisplayPanel, ID_TENHZCHECKBOX,
4106 _("Enable Ten Hz screen update"));
4107 pEnableTenHertz->SetValue(FALSE);
4108 boxCtrls->Add(pEnableTenHertz, verticleInputFlags);
4109#endif
4110
4111 if (!g_useMUI) {
4112 // spacer
4113 generalSizer->Add(0, border_size * 4);
4114 generalSizer->Add(0, border_size * 4);
4115
4116 // Display Options
4117 generalSizer->Add(
4118 new wxStaticText(pDisplayPanel, wxID_ANY, _("Display Features")),
4119 groupLabelFlags);
4120 wxBoxSizer* boxDisp = new wxBoxSizer(wxVERTICAL);
4121 generalSizer->Add(boxDisp, groupInputFlags);
4122
4123 pSDisplayGrid =
4124 new wxCheckBox(pDisplayPanel, ID_CHECK_DISPLAYGRID, _("Show Grid"));
4125 boxDisp->Add(pSDisplayGrid, verticleInputFlags);
4126
4127 pCDOOutlines = new wxCheckBox(pDisplayPanel, ID_OUTLINECHECKBOX1,
4128 _("Show Chart Outlines"));
4129 boxDisp->Add(pCDOOutlines, verticleInputFlags);
4130
4131 pSDepthUnits = new wxCheckBox(pDisplayPanel, ID_SHOWDEPTHUNITSBOX1,
4132 _("Show Depth Units"));
4133 boxDisp->Add(pSDepthUnits, verticleInputFlags);
4134 }
4135
4136#ifndef __ANDROID__
4137 // MultiChart selection panel
4138 if (g_Platform->GetDisplayAreaCM2() > 100) {
4139 wxStaticBox* itemStaticBoxScreenConfig =
4140 new wxStaticBox(pDisplayPanel, wxID_ANY, _("Canvas Layout"));
4141 wxStaticBoxSizer* itemStaticBoxSizerScreenConfig =
4142 new wxStaticBoxSizer(itemStaticBoxScreenConfig, wxHORIZONTAL);
4143 wrapperSizer->Add(itemStaticBoxSizerScreenConfig, 1, wxALL | wxEXPAND, 5);
4144
4145 // The standard screen configs...
4146 wxString iconDir = g_Platform->GetSharedDataDir();
4147 appendOSDirSlash(&iconDir);
4148 iconDir.append("uidata");
4149 appendOSDirSlash(&iconDir);
4150 iconDir.append("MUI_flat");
4151 appendOSDirSlash(&iconDir);
4152 int bmpSize = GetCharHeight() * 3;
4153
4154 wxBitmap bmp = LoadSVG(iconDir + "MUI_Sconfig_1.svg", bmpSize, bmpSize);
4155 m_sconfigSelect_single =
4156 new CanvasConfigSelect(pDisplayPanel, this, ID_SCREENCONFIG1, bmp);
4157 itemStaticBoxSizerScreenConfig->Add(m_sconfigSelect_single, 0,
4158 wxALIGN_LEFT);
4159
4160 itemStaticBoxSizerScreenConfig->AddSpacer(GetCharHeight());
4161
4162 bmp = LoadSVG(iconDir + "MUI_Sconfig_2.svg", bmpSize, bmpSize);
4163 m_sconfigSelect_twovertical =
4164 new CanvasConfigSelect(pDisplayPanel, this, ID_SCREENCONFIG2, bmp);
4165 itemStaticBoxSizerScreenConfig->Add(m_sconfigSelect_twovertical, 0,
4166 wxALIGN_LEFT);
4167
4168 itemStaticBoxSizerScreenConfig->AddSpacer(GetCharHeight());
4169 }
4170#endif
4171
4172 } else { // compact follows
4173 wxFlexGridSizer* generalSizer = new wxFlexGridSizer(2);
4174 generalSizer->SetHGap(border_size);
4175 // generalSizer->AddGrowableCol( 0, 1 );
4176 // generalSizer->AddGrowableCol( 1, 1 );
4177 // pDisplayPanel->SetSizer( generalSizer );
4178
4179 // wxFlexGridSizer grows wrongly in wx2.8, so we need to centre it in
4180 // another sizer instead of letting it grow.
4181 wxBoxSizer* wrapperSizer = new wxBoxSizer(wxVERTICAL);
4182 pDisplayPanel->SetSizer(wrapperSizer);
4183 wrapperSizer->Add(generalSizer, 1, wxALL | wxALIGN_CENTER, border_size);
4184
4185 // spacer
4186 generalSizer->Add(0, border_size * 4);
4187 generalSizer->Add(0, border_size * 4);
4188
4189 if (!g_useMUI) {
4190 // Nav Mode
4191 generalSizer->Add(
4192 new wxStaticText(pDisplayPanel, wxID_ANY, _("Navigation Mode")),
4193 groupLabelFlags);
4194 wxBoxSizer* boxNavMode = new wxBoxSizer(wxVERTICAL);
4195 generalSizer->Add(boxNavMode, groupInputFlags);
4196
4197 wxBoxSizer* rowOrientation = new wxBoxSizer(wxHORIZONTAL);
4198 boxNavMode->Add(rowOrientation);
4199
4200 pCBNorthUp = new wxRadioButton(pDisplayPanel, wxID_ANY, _("North Up"));
4201 rowOrientation->Add(pCBNorthUp, inputFlags);
4202 pCBCourseUp =
4203 new wxRadioButton(pDisplayPanel, ID_COURSEUPCHECKBOX, _("Course Up"));
4204 rowOrientation->Add(pCBCourseUp,
4205 wxSizerFlags(0)
4206 .Align(wxALIGN_CENTRE_VERTICAL)
4207 .Border(wxLEFT, group_item_spacing * 2));
4208
4209 pCBLookAhead = new wxCheckBox(pDisplayPanel, ID_CHECK_LOOKAHEAD,
4210 _("Look Ahead Mode"));
4211 boxNavMode->Add(pCBLookAhead, verticleInputFlags);
4212
4213 // spacer
4214 generalSizer->Add(0, border_size * 4);
4215 generalSizer->Add(0, border_size * 4);
4216
4217 // Control Options
4218 generalSizer->Add(
4219 new wxStaticText(pDisplayPanel, wxID_ANY, _("Chart Display")),
4220 groupLabelFlags);
4221 wxBoxSizer* boxCharts = new wxBoxSizer(wxVERTICAL);
4222 generalSizer->Add(boxCharts, groupInputFlags);
4223
4224 pCDOQuilting = new wxCheckBox(pDisplayPanel, ID_QUILTCHECKBOX1,
4225 _("Enable Chart Quilting"));
4226 boxCharts->Add(pCDOQuilting, verticleInputFlags);
4227
4228 pPreserveScale =
4229 new wxCheckBox(pDisplayPanel, ID_PRESERVECHECKBOX,
4230 _("Preserve scale when switching charts"));
4231 boxCharts->Add(pPreserveScale, verticleInputFlags);
4232
4233 // spacer
4234 generalSizer->Add(0, border_size * 4);
4235 generalSizer->Add(0, border_size * 4);
4236 }
4237
4238 // Control Options
4239 generalSizer->Add(new wxStaticText(pDisplayPanel, wxID_ANY, _("Controls")),
4240 groupLabelFlags);
4241 wxBoxSizer* boxCtrls = new wxBoxSizer(wxVERTICAL);
4242 generalSizer->Add(boxCtrls, groupInputFlags);
4243
4244 pSmoothPanZoom = new wxCheckBox(pDisplayPanel, ID_SMOOTHPANZOOMBOX,
4245 _("Smooth Panning / Zooming"));
4246 boxCtrls->Add(pSmoothPanZoom, verticleInputFlags);
4247 pEnableZoomToCursor =
4248 new wxCheckBox(pDisplayPanel, ID_ZTCCHECKBOX, _("Zoom to Cursor"));
4249 pEnableZoomToCursor->SetValue(FALSE);
4250 boxCtrls->Add(pEnableZoomToCursor, verticleInputFlags);
4251
4252#ifdef __ANDROID__
4253 pSmoothPanZoom->Hide();
4254 pEnableZoomToCursor->Hide();
4255#endif
4256
4257 // spacer
4258 generalSizer->Add(0, border_size * 4);
4259 generalSizer->Add(0, border_size * 4);
4260
4261 if (!g_useMUI) {
4262 // Display Options
4263 generalSizer->Add(
4264 new wxStaticText(pDisplayPanel, wxID_ANY, _("Display Features")),
4265 groupLabelFlags);
4266 wxBoxSizer* boxDisp = new wxBoxSizer(wxVERTICAL);
4267 generalSizer->Add(boxDisp, groupInputFlags);
4268
4269 pSDisplayGrid =
4270 new wxCheckBox(pDisplayPanel, ID_CHECK_DISPLAYGRID, _("Show Grid"));
4271 boxDisp->Add(pSDisplayGrid, verticleInputFlags);
4272
4273 pCDOOutlines = new wxCheckBox(pDisplayPanel, ID_OUTLINECHECKBOX1,
4274 _("Show Chart Outlines"));
4275 boxDisp->Add(pCDOOutlines, verticleInputFlags);
4276
4277 pSDepthUnits = new wxCheckBox(pDisplayPanel, ID_SHOWDEPTHUNITSBOX1,
4278 _("Show Depth Units"));
4279 boxDisp->Add(pSDepthUnits, verticleInputFlags);
4280 }
4281
4282 // CUSTOMIZATION - LIVE ETA OPTION
4283 // -------------------------------
4284 // Add a checkbox to activate live ETA option in status bar, and
4285 // Add a text field to set default boat speed (for calculation when
4286 // no GPS or when the boat is at the harbor).
4287
4288 // Spacer
4289 generalSizer->Add(0, border_size * 4);
4290 generalSizer->Add(0, border_size * 4);
4291
4292 // New menu status bar
4293 generalSizer->Add(
4294 new wxStaticText(pDisplayPanel, wxID_ANY, _("Status Bar")),
4295 groupLabelFlags);
4296 wxBoxSizer* boxDispStatusBar = new wxBoxSizer(wxVERTICAL);
4297 generalSizer->Add(boxDispStatusBar, groupInputFlags);
4298
4299 // Add option for live ETA
4300#ifndef __ANDROID__
4301 pSLiveETA = new wxCheckBox(pDisplayPanel, ID_CHECK_LIVEETA,
4302 _("Live ETA at Cursor"));
4303 boxDispStatusBar->Add(pSLiveETA, verticleInputFlags);
4304#endif
4305
4306 // Add text input for default boat speed
4307 // (for calculation, in case GPS speed is null)
4308 wxBoxSizer* defaultBoatSpeedSizer = new wxBoxSizer(wxHORIZONTAL);
4309 boxDispStatusBar->Add(defaultBoatSpeedSizer, wxALL, group_item_spacing);
4310 m_Text_def_boat_speed = new wxStaticText(
4311 pDisplayPanel, wxID_ANY,
4312 _("Default Boat Speed ") + "(" + getUsrSpeedUnit() + ") ");
4313 defaultBoatSpeedSizer->Add(m_Text_def_boat_speed, groupLabelFlagsHoriz);
4314 pSDefaultBoatSpeed =
4315 new wxTextCtrl(pDisplayPanel, ID_DEFAULT_BOAT_SPEED, "",
4316 wxDefaultPosition, wxSize(50, -1), wxTE_RIGHT);
4317 defaultBoatSpeedSizer->Add(pSDefaultBoatSpeed, 0, wxALIGN_CENTER_VERTICAL,
4318 group_item_spacing);
4319
4320 // --------------------------------------
4321 // END OF CUSTOMIZATION - LIVE ETA OPTION
4322
4323#ifndef __ANDROID__
4324 if (g_Platform->GetDisplayAreaCM2() > 100) {
4325 // MultiChart selection panel
4326 wxStaticBox* itemStaticBoxScreenConfig =
4327 new wxStaticBox(pDisplayPanel, wxID_ANY, _("Canvas Layout"));
4328 wxStaticBoxSizer* itemStaticBoxSizerScreenConfig =
4329 new wxStaticBoxSizer(itemStaticBoxScreenConfig, wxHORIZONTAL);
4330 wrapperSizer->Add(itemStaticBoxSizerScreenConfig, 1, wxALL | wxEXPAND, 5);
4331
4332 // The standard screen configs...
4333 wxString iconDir = g_Platform->GetSharedDataDir();
4334 appendOSDirSlash(&iconDir);
4335 iconDir.append("uidata");
4336 appendOSDirSlash(&iconDir);
4337 iconDir.append("MUI_flat");
4338 appendOSDirSlash(&iconDir);
4339 int bmpSize = GetCharHeight() * 3;
4340
4341 wxBitmap bmp = LoadSVG(iconDir + "MUI_Sconfig_1.svg", bmpSize, bmpSize);
4342 m_sconfigSelect_single =
4343 new CanvasConfigSelect(pDisplayPanel, this, ID_SCREENCONFIG1, bmp);
4344 itemStaticBoxSizerScreenConfig->Add(m_sconfigSelect_single, 0,
4345 wxALIGN_LEFT);
4346
4347 itemStaticBoxSizerScreenConfig->AddSpacer(GetCharHeight());
4348
4349 bmp = LoadSVG(iconDir + "MUI_Sconfig_2.svg", bmpSize, bmpSize);
4350 m_sconfigSelect_twovertical =
4351 new CanvasConfigSelect(pDisplayPanel, this, ID_SCREENCONFIG2, bmp);
4352 itemStaticBoxSizerScreenConfig->Add(m_sconfigSelect_twovertical, 0,
4353 wxALIGN_LEFT);
4354
4355 itemStaticBoxSizerScreenConfig->AddSpacer(GetCharHeight());
4356 }
4357#endif
4358 }
4359}
4360
4361void options::CreatePanel_Units(size_t parent, int border_size,
4362 int group_item_spacing) {
4363 wxScrolledWindow* panelUnits = AddPage(parent, _("Units"));
4364
4365 if (m_bcompact) {
4366 wxFlexGridSizer* unitsSizer = new wxFlexGridSizer(2);
4367 unitsSizer->SetHGap(border_size);
4368
4369 // wxFlexGridSizer grows wrongly in wx2.8, so we need to centre it in
4370 // another sizer instead of letting it grow.
4371 wxBoxSizer* wrapperSizer = new wxBoxSizer(wxVERTICAL);
4372 panelUnits->SetSizer(wrapperSizer);
4373
4374 wrapperSizer->Add(1, border_size * 24);
4375 wrapperSizer->Add(unitsSizer, 1, wxALL | wxALIGN_CENTER, border_size);
4376
4377 // spacer
4378 unitsSizer->Add(0, border_size * 4);
4379 unitsSizer->Add(0, border_size * 4);
4380
4381 // distance units
4382 unitsSizer->Add(new wxStaticText(panelUnits, wxID_ANY, _("Distance")),
4383 labelFlags);
4384 wxString pDistanceFormats[kNumDistanceFormats];
4385 for (int i = 0; i < kNumDistanceFormats; i++) {
4386 pDistanceFormats[i] = kDistanceFormats[i].label;
4387 }
4388 int m_DistanceFormatsNChoices = kNumDistanceFormats;
4389 pDistanceFormat =
4390 new wxChoice(panelUnits, ID_DISTANCEUNITSCHOICE, wxDefaultPosition,
4391 wxSize(m_fontHeight * 4, -1), m_DistanceFormatsNChoices,
4392 pDistanceFormats);
4393 // Distance between geographic positions, visibility range, radar range.
4394 pDistanceFormat->SetToolTip(ttDistance());
4395#ifdef __ANDROID__
4396 setChoiceStyleSheet(pDistanceFormat, m_fontHeight * 8 / 10);
4397#endif
4398 unitsSizer->Add(pDistanceFormat, inputFlags);
4399
4400 // speed units
4401 unitsSizer->Add(new wxStaticText(panelUnits, wxID_ANY, _("Speed")),
4402 labelFlags);
4403 wxString pSpeedFormats[] = {_("Knots"), _("Mph"), _("km/h"), _("m/s")};
4404 int m_SpeedFormatsNChoices = sizeof(pSpeedFormats) / sizeof(wxString);
4405 pSpeedFormat = new wxChoice(panelUnits, ID_SPEEDUNITSCHOICE,
4406 wxDefaultPosition, wxSize(m_fontHeight * 4, -1),
4407 m_SpeedFormatsNChoices, pSpeedFormats);
4408 pSpeedFormat->SetToolTip(ttSpeed());
4409#ifdef __ANDROID__
4410 setChoiceStyleSheet(pSpeedFormat, m_fontHeight * 8 / 10);
4411#endif
4412 unitsSizer->Add(pSpeedFormat, inputFlags);
4413
4414 // wind units
4415 unitsSizer->Add(new wxStaticText(panelUnits, wxID_ANY, _("Wind speed")),
4416 labelFlags);
4417 wxString pWindSpeedFormats[] = {_("Knots"), _("m/s"), _("Mph"), _("km/h")};
4418 int m_WindSpeedFormatsNChoices =
4419 sizeof(pWindSpeedFormats) / sizeof(wxString);
4420 pWindSpeedFormat =
4421 new wxChoice(panelUnits, ID_WINDSPEEDUNITCHOICE, wxDefaultPosition,
4422 wxSize(m_fontHeight * 4, -1), m_WindSpeedFormatsNChoices,
4423 pWindSpeedFormats);
4424 pWindSpeedFormat->SetToolTip(ttWindSpeed());
4425#ifdef __ANDROID__
4426 setChoiceStyleSheet(pWindSpeedFormat, m_fontHeight * 8 / 10);
4427#endif
4428 unitsSizer->Add(pWindSpeedFormat, inputFlags);
4429
4430 // depth units
4431 unitsSizer->Add(new wxStaticText(panelUnits, wxID_ANY, _("Depth")),
4432 labelFlags);
4433 wxString pDepthUnitStrings[] = {
4434 _("Feet"),
4435 _("Meters"),
4436 _("Fathoms"),
4437 };
4438 pDepthUnitSelect =
4439 new wxChoice(panelUnits, ID_DEPTHUNITSCHOICE, wxDefaultPosition,
4440 wxSize(m_fontHeight * 4, -1), 3, pDepthUnitStrings);
4441 // Distance below a reference surface (sea level, vessel draft)
4442 pDepthUnitSelect->SetToolTip(ttDepth());
4443#ifdef __ANDROID__
4444 setChoiceStyleSheet(pDepthUnitSelect, m_fontHeight * 8 / 10);
4445#endif
4446 unitsSizer->Add(pDepthUnitSelect, inputFlags);
4447
4448 // height units
4449 unitsSizer->Add(new wxStaticText(panelUnits, wxID_ANY, _("Height")),
4450 labelFlags);
4451 wxString pHeightUnitStrings[] = {
4452 _("Meters"),
4453 _("Feet"),
4454 };
4455 pHeightUnitSelect =
4456 new wxChoice(panelUnits, ID_HEIGHTUNITSCHOICE, wxDefaultPosition,
4457 wxSize(m_fontHeight * 4, -1), 2, pHeightUnitStrings);
4458 // Tide level, wave height, air gap, mast clearance, elevations above
4459 // reference datum
4460 pHeightUnitSelect->SetToolTip(ttHeight());
4461#ifdef __ANDROID__
4462 setChoiceStyleSheet(pHeightUnitSelect, m_fontHeight * 8 / 10);
4463#endif
4464 unitsSizer->Add(pHeightUnitSelect, inputFlags);
4465
4466 // temperature units
4467 unitsSizer->Add(new wxStaticText(panelUnits, wxID_ANY, _("Temperature")),
4468 labelFlags);
4469 wxString pTempUnitStrings[] = {
4470 _("Celsius"),
4471 _("Fahrenheit"),
4472 _("Kelvin"),
4473 };
4474 pTempFormat =
4475 new wxChoice(panelUnits, ID_TEMPUNITSCHOICE, wxDefaultPosition,
4476 wxSize(m_fontHeight * 4, -1), 3, pTempUnitStrings);
4477 pTempFormat->SetToolTip(ttTemp());
4478#ifdef __ANDROID__
4479 setChoiceStyleSheet(pTempFormat, m_fontHeight * 8 / 10);
4480#endif
4481 unitsSizer->Add(pTempFormat, inputFlags);
4482
4483 // spacer
4484 unitsSizer->Add(new wxStaticText(panelUnits, wxID_ANY, ""));
4485 unitsSizer->Add(new wxStaticText(panelUnits, wxID_ANY, ""));
4486
4487 // lat/long units
4488 unitsSizer->Add(new wxStaticText(panelUnits, wxID_ANY, _("Lat/Long")),
4489 labelFlags);
4490 wxString pSDMMFormats[] = {_("Degrees, Decimal Minutes"),
4491 _("Decimal Degrees"),
4492 _("Degrees, Minutes, Seconds")};
4493 int m_SDMMFormatsNChoices = sizeof(pSDMMFormats) / sizeof(wxString);
4494 pSDMMFormat = new wxChoice(panelUnits, ID_SDMMFORMATCHOICE,
4495 wxDefaultPosition, wxSize(m_fontHeight * 4, -1),
4496 m_SDMMFormatsNChoices, pSDMMFormats);
4497 pSDMMFormat->SetToolTip(ttCoordFormat());
4498#ifdef __ANDROID__
4499 setChoiceStyleSheet(pSDMMFormat, m_fontHeight * 8 / 10);
4500#endif
4501 unitsSizer->Add(pSDMMFormat, inputFlags);
4502
4503 // spacer
4504 unitsSizer->Add(0, border_size * 4);
4505 unitsSizer->Add(0, border_size * 4);
4506
4507 // Selection of timezone for date/time display format:
4508 // UTC, local time, or specific time zone.
4509 unitsSizer->Add(new wxStaticText(panelUnits, wxID_ANY, _("Date and Time")),
4510 groupLabelFlags);
4511
4512 wxBoxSizer* timezoneStyleBox = new wxBoxSizer(wxHORIZONTAL);
4513 unitsSizer->Add(timezoneStyleBox, groupInputFlags);
4514 wxBoxSizer* itemTimezoneBoxSizer = new wxBoxSizer(wxHORIZONTAL);
4515 timezoneStyleBox->Add(itemTimezoneBoxSizer, 1, wxEXPAND | wxALL,
4516 border_size);
4518 new wxRadioButton(panelUnits, ID_TIMEZONE_LOCAL_TIME, _("Local Time"),
4519 wxDefaultPosition, wxDefaultSize, 0);
4520 itemTimezoneBoxSizer->Add(pTimezoneLocalTime, 0,
4521 wxALIGN_CENTER_VERTICAL | wxRIGHT, border_size);
4522 pTimezoneUTC = new wxRadioButton(panelUnits, ID_TIMEZONE_UTC, _("UTC"),
4523 wxDefaultPosition, wxDefaultSize, 0);
4524 itemTimezoneBoxSizer->Add(pTimezoneUTC, 0,
4525 wxALIGN_CENTER_VERTICAL | wxRIGHT, border_size);
4526
4527 // spacer
4528 unitsSizer->Add(0, border_size * 4);
4529 unitsSizer->Add(0, border_size * 4);
4530
4531 // bearings (magnetic/true, variation)
4532 unitsSizer->Add(new wxStaticText(panelUnits, wxID_ANY, _("Bearings")),
4533 groupLabelFlags);
4534
4535 // "Mag Heading" checkbox
4536 pCBTrueShow =
4537 new wxCheckBox(panelUnits, ID_TRUESHOWCHECKBOX, _("Show true"));
4538 unitsSizer->Add(pCBTrueShow, 0, wxALL, group_item_spacing);
4539 unitsSizer->Add(new wxStaticText(panelUnits, wxID_ANY, ""));
4540
4541 pCBMagShow =
4542 new wxCheckBox(panelUnits, ID_MAGSHOWCHECKBOX, _("Show magnetic"));
4543 unitsSizer->Add(pCBMagShow, 0, wxALL, group_item_spacing);
4544 unitsSizer->Add(new wxStaticText(panelUnits, wxID_ANY, ""));
4545
4546 // Mag Heading user variation
4547
4548 wxStaticBox* itemStaticBoxVar = new wxStaticBox(panelUnits, wxID_ANY, "");
4549
4550 wxStaticBoxSizer* itemStaticBoxSizerVar =
4551 new wxStaticBoxSizer(itemStaticBoxVar, wxVERTICAL);
4552 wrapperSizer->Add(itemStaticBoxSizerVar, 0, wxALL | wxEXPAND, 5);
4553
4554 itemStaticBoxSizerVar->Add(0, border_size * 4);
4555
4556 itemStaticTextUserVar =
4557 new wxStaticText(panelUnits, wxID_ANY, _("Assumed magnetic variation"));
4558 itemStaticBoxSizerVar->Add(itemStaticTextUserVar, 1, wxEXPAND | wxALL,
4559 group_item_spacing);
4560
4561 wxBoxSizer* magVarSizer = new wxBoxSizer(wxHORIZONTAL);
4562 itemStaticBoxSizerVar->Add(magVarSizer, 1, wxEXPAND | wxALL,
4563 group_item_spacing);
4564
4565 pMagVar = new wxTextCtrl(panelUnits, ID_OPTEXTCTRL, "", wxDefaultPosition,
4566 wxSize(150, -1), wxTE_RIGHT);
4567 magVarSizer->AddSpacer(100);
4568
4569 magVarSizer->Add(pMagVar, 0, wxALIGN_CENTRE_VERTICAL, group_item_spacing);
4570
4571 itemStaticTextUserVar2 =
4572 new wxStaticText(panelUnits, wxID_ANY, _("deg (-W, +E)"));
4573
4574 magVarSizer->Add(itemStaticTextUserVar2, 0, wxALL | wxALIGN_CENTRE_VERTICAL,
4575 group_item_spacing);
4576
4577 itemStaticBoxSizerVar->Add(0, border_size * 40);
4578
4579 } else {
4580 wxFlexGridSizer* unitsSizer = new wxFlexGridSizer(2);
4581 unitsSizer->SetHGap(border_size);
4582
4583 int item_h_size = -1;
4584#ifdef __ANDROID__
4585 item_h_size = m_fontHeight * 4;
4586#endif
4587
4588 // wxFlexGridSizer grows wrongly in wx2.8, so we need to centre it in
4589 // another sizer instead of letting it grow.
4590 wxBoxSizer* wrapperSizer = new wxBoxSizer(wxVERTICAL);
4591 panelUnits->SetSizer(wrapperSizer);
4592 wrapperSizer->Add(unitsSizer, 1, wxALL | wxALIGN_CENTER, border_size);
4593
4594 // spacer
4595 unitsSizer->Add(0, border_size * 4);
4596 unitsSizer->Add(0, border_size * 4);
4597
4598 // distance units
4599 unitsSizer->Add(new wxStaticText(panelUnits, wxID_ANY, _("Distance")),
4600 labelFlags);
4601 wxString pDistanceFormats[kNumDistanceFormats];
4602 for (int i = 0; i < kNumDistanceFormats; i++) {
4603 pDistanceFormats[i] = kDistanceFormats[i].label;
4604 }
4605 int m_DistanceFormatsNChoices = kNumDistanceFormats;
4606 pDistanceFormat = new wxChoice(panelUnits, ID_DISTANCEUNITSCHOICE,
4607 wxDefaultPosition, wxSize(item_h_size, -1),
4608 m_DistanceFormatsNChoices, pDistanceFormats);
4609 pDistanceFormat->SetToolTip(ttDistance());
4610#ifdef __ANDROID__
4611 setChoiceStyleSheet(pDistanceFormat, m_fontHeight * 8 / 10);
4612#endif
4613 unitsSizer->Add(pDistanceFormat, inputFlags);
4614
4615 // speed units
4616 unitsSizer->Add(new wxStaticText(panelUnits, wxID_ANY, _("Speed")),
4617 labelFlags);
4618 wxString pSpeedFormats[] = {_("Knots"), _("Mph"), _("km/h"), _("m/s")};
4619 int m_SpeedFormatsNChoices = sizeof(pSpeedFormats) / sizeof(wxString);
4620 pSpeedFormat = new wxChoice(panelUnits, ID_SPEEDUNITSCHOICE,
4621 wxDefaultPosition, wxSize(item_h_size, -1),
4622 m_SpeedFormatsNChoices, pSpeedFormats);
4623 pSpeedFormat->SetToolTip(ttSpeed());
4624#ifdef __ANDROID__
4625 setChoiceStyleSheet(pSpeedFormat, m_fontHeight * 8 / 10);
4626#endif
4627 unitsSizer->Add(pSpeedFormat, inputFlags);
4628
4629 // wind units
4630 unitsSizer->Add(new wxStaticText(panelUnits, wxID_ANY, _("Wind speed")),
4631 labelFlags);
4632 wxString pWindSpeedFormats[] = {_("Knots"), _("m/s"), _("Mph"), _("km/h")};
4633 int m_WindSpeedFormatsNChoices =
4634 sizeof(pWindSpeedFormats) / sizeof(wxString);
4635 pWindSpeedFormat = new wxChoice(
4636 panelUnits, ID_WINDSPEEDUNITCHOICE, wxDefaultPosition,
4637 wxSize(item_h_size, -1), m_WindSpeedFormatsNChoices, pWindSpeedFormats);
4638 pWindSpeedFormat->SetToolTip(ttWindSpeed());
4639#ifdef __ANDROID__
4640 setChoiceStyleSheet(pWindSpeedFormat, m_fontHeight * 8 / 10);
4641#endif
4642 unitsSizer->Add(pWindSpeedFormat, inputFlags);
4643
4644 // depth units
4645 unitsSizer->Add(new wxStaticText(panelUnits, wxID_ANY, _("Depth")),
4646 labelFlags);
4647 wxString pDepthUnitStrings[] = {
4648 _("Feet"),
4649 _("Meters"),
4650 _("Fathoms"),
4651 };
4652 pDepthUnitSelect =
4653 new wxChoice(panelUnits, ID_DEPTHUNITSCHOICE, wxDefaultPosition,
4654 wxSize(item_h_size, -1), 3, pDepthUnitStrings);
4655 pDepthUnitSelect->SetToolTip(ttDepth());
4656#ifdef __ANDROID__
4657 setChoiceStyleSheet(pDepthUnitSelect, m_fontHeight * 8 / 10);
4658#endif
4659 unitsSizer->Add(pDepthUnitSelect, inputFlags);
4660
4661 // height units
4662 unitsSizer->Add(new wxStaticText(panelUnits, wxID_ANY, _("Height")),
4663 labelFlags);
4664 wxString pHeightUnitStrings[] = {
4665 _("Meters"),
4666 _("Feet"),
4667 };
4668 pHeightUnitSelect =
4669 new wxChoice(panelUnits, ID_HEIGHTUNITSCHOICE, wxDefaultPosition,
4670 wxSize(item_h_size, -1), 2, pHeightUnitStrings);
4671 pHeightUnitSelect->SetToolTip(ttHeight());
4672#ifdef __ANDROID__
4673 setChoiceStyleSheet(pHeightUnitSelect, m_fontHeight * 8 / 10);
4674#endif
4675 unitsSizer->Add(pHeightUnitSelect, inputFlags);
4676
4677 // temperature units
4678 unitsSizer->Add(new wxStaticText(panelUnits, wxID_ANY, _("Temperature")),
4679 labelFlags);
4680 wxString pTempUnitStrings[] = {
4681 _("Celsius"),
4682 _("Fahrenheit"),
4683 _("Kelvin"),
4684 };
4685 pTempFormat =
4686 new wxChoice(panelUnits, ID_TEMPUNITSCHOICE, wxDefaultPosition,
4687 wxSize(item_h_size, -1), 3, pTempUnitStrings);
4688 pTempFormat->SetToolTip(ttTemp());
4689#ifdef __ANDROID__
4690 setChoiceStyleSheet(pTempFormat, m_fontHeight * 8 / 10);
4691#endif
4692 unitsSizer->Add(pTempFormat, inputFlags);
4693
4694 // spacer
4695 unitsSizer->Add(new wxStaticText(panelUnits, wxID_ANY, ""));
4696 unitsSizer->Add(new wxStaticText(panelUnits, wxID_ANY, ""));
4697
4698 // lat/long units
4699 unitsSizer->Add(new wxStaticText(panelUnits, wxID_ANY, _("Lat/Long")),
4700 labelFlags);
4701 wxString pSDMMFormats[] = {_("Degrees, Decimal Minutes"),
4702 _("Decimal Degrees"),
4703 _("Degrees, Minutes, Seconds")};
4704 int m_SDMMFormatsNChoices = sizeof(pSDMMFormats) / sizeof(wxString);
4705 pSDMMFormat = new wxChoice(panelUnits, ID_SDMMFORMATCHOICE,
4706 wxDefaultPosition, wxSize(item_h_size, -1),
4707 m_SDMMFormatsNChoices, pSDMMFormats);
4708 pSDMMFormat->SetToolTip(ttCoordFormat());
4709#ifdef __ANDROID__
4710 setChoiceStyleSheet(pSDMMFormat, m_fontHeight * 8 / 10);
4711#endif
4712 unitsSizer->Add(pSDMMFormat, inputFlags);
4713
4714 // spacer
4715 unitsSizer->Add(0, border_size * 4);
4716 unitsSizer->Add(0, border_size * 4);
4717
4718 // Selection of timezone for date/time display format:
4719 // UTC, local time, or specific time zone.
4720 unitsSizer->Add(new wxStaticText(panelUnits, wxID_ANY, _("Date and Time")),
4721 groupLabelFlags);
4722
4723 wxBoxSizer* timezoneStyleBox = new wxBoxSizer(wxHORIZONTAL);
4724 unitsSizer->Add(timezoneStyleBox, groupInputFlags);
4725 wxBoxSizer* itemTimezoneBoxSizer = new wxBoxSizer(wxHORIZONTAL);
4726 timezoneStyleBox->Add(itemTimezoneBoxSizer, 1, wxEXPAND | wxALL,
4727 border_size);
4729 new wxRadioButton(panelUnits, ID_TIMEZONE_LOCAL_TIME, _("Local Time"),
4730 wxDefaultPosition, wxDefaultSize, 0);
4731 itemTimezoneBoxSizer->Add(pTimezoneLocalTime, 0,
4732 wxALIGN_CENTER_VERTICAL | wxRIGHT, border_size);
4733 pTimezoneUTC = new wxRadioButton(panelUnits, ID_TIMEZONE_UTC, _("UTC"),
4734 wxDefaultPosition, wxDefaultSize, 0);
4735 itemTimezoneBoxSizer->Add(pTimezoneUTC, 0,
4736 wxALIGN_CENTER_VERTICAL | wxRIGHT, border_size);
4737
4738 // spacer
4739 unitsSizer->Add(0, border_size * 4);
4740 unitsSizer->Add(0, border_size * 4);
4741
4742 // bearings (magnetic/true, variation)
4743 unitsSizer->Add(new wxStaticText(panelUnits, wxID_ANY, _("Bearings")),
4744 groupLabelFlags);
4745
4746 wxBoxSizer* bearingsSizer = new wxBoxSizer(wxVERTICAL);
4747 unitsSizer->Add(bearingsSizer, 0, 0, 0);
4748
4749 // "Mag Heading" checkbox
4750 pCBTrueShow = new wxCheckBox(panelUnits, ID_TRUESHOWCHECKBOX,
4751 _("Show true bearings and headings"));
4752 bearingsSizer->Add(pCBTrueShow, 0, wxALL, group_item_spacing);
4753 pCBMagShow = new wxCheckBox(panelUnits, ID_MAGSHOWCHECKBOX,
4754 _("Show magnetic bearings and headings."));
4755 bearingsSizer->Add(pCBMagShow, 0, wxALL, group_item_spacing);
4756
4757 bearingsSizer->AddSpacer(10);
4758
4759 // Mag Heading user variation
4760 wxBoxSizer* magVarSizer = new wxBoxSizer(wxHORIZONTAL);
4761 bearingsSizer->Add(magVarSizer, 0, wxALL, group_item_spacing);
4762
4763 itemStaticTextUserVar =
4764 new wxStaticText(panelUnits, wxID_ANY, wxEmptyString);
4765 itemStaticTextUserVar->SetLabel(
4766 _("WMM Plugin calculated magnetic variation"));
4767
4768 magVarSizer->Add(itemStaticTextUserVar, 0, wxALL | wxALIGN_CENTRE_VERTICAL,
4769 group_item_spacing);
4770
4771 pMagVar = new wxTextCtrl(panelUnits, ID_OPTEXTCTRL, "", wxDefaultPosition,
4772 wxSize(50, -1), wxTE_RIGHT);
4773 magVarSizer->Add(pMagVar, 0, wxALIGN_CENTRE_VERTICAL, group_item_spacing);
4774
4775 itemStaticTextUserVar2 =
4776 new wxStaticText(panelUnits, wxID_ANY, _("deg (-W, +E)"));
4777 magVarSizer->Add(itemStaticTextUserVar2, 0, wxALL | wxALIGN_CENTRE_VERTICAL,
4778 group_item_spacing);
4779
4780 bearingsSizer->AddSpacer(10);
4781
4782 wxStaticText* varText =
4783 new wxStaticText(panelUnits, wxID_ANY,
4784 _(" To set the magnetic variation manually,\n you "
4785 "must disable the WMM plugin."));
4786 smallFont = *dialogFont;
4787 smallFont.SetPointSize((smallFont.GetPointSize() / 1.2) +
4788 0.5); // + 0.5 to round instead of truncate
4789 varText->SetFont(smallFont);
4790
4791 bearingsSizer->Add(varText);
4792 }
4793#ifdef __WXGTK__
4794 panelUnits->Fit();
4795#endif
4796}
4797
4798class OCPNSoundPanel : public wxPanel {
4799public:
4800 OCPNSoundPanel(wxWindow* parent, wxWindowID id, const wxPoint& pos,
4801 const wxSize& size, wxString title, wxString checkLegend,
4802 wxString selectLegend, wxString* pSoundFile);
4803
4804 ~OCPNSoundPanel() { delete m_sound; }
4805
4806 void OnButtonSelectSound(wxCommandEvent& event);
4807 void OnButtonSPTestSound(wxCommandEvent& event);
4808 wxString SelectSoundFile();
4809 void SetSoundFileLabel(wxString file);
4810 wxCheckBox* GetCheckBox() { return m_pCheck_Sound; }
4811 wxString GetSoundFile() { return m_sound_file; }
4812
4813 wxCheckBox* m_pCheck_Sound;
4814 wxSize m_small_button_size;
4815 wxString m_sound_file;
4816 wxString* m_pSoundFile;
4817 wxStaticText* m_AudioFileNameText;
4818
4819 wxButton* SelSound;
4820 wxButton* TestSound;
4821 o_sound::Sound* m_sound;
4822
4825
4826 obs::Listener m_sound_sp_done_listener;
4827 bool m_soundPlaying;
4828
4829 DECLARE_EVENT_TABLE()
4830};
4831
4832#define ID_SELECTSOUND 9341
4833#define ID_TESTSOUND 9342
4834
4835BEGIN_EVENT_TABLE(OCPNSoundPanel, wxPanel)
4836EVT_BUTTON(ID_SELECTSOUND, OCPNSoundPanel::OnButtonSelectSound)
4837EVT_BUTTON(ID_TESTSOUND, OCPNSoundPanel::OnButtonSPTestSound)
4838
4839END_EVENT_TABLE()
4840
4841OCPNSoundPanel::OCPNSoundPanel(wxWindow* parent, wxWindowID id,
4842 const wxPoint& pos, const wxSize& size,
4843 wxString title, wxString checkLegend,
4844 wxString selectLegend, wxString* pSoundFile)
4845 : wxPanel(parent, id, pos, size, wxBORDER_NONE), m_soundPlaying(false) {
4846 wxFont* pif = FontMgr::Get().GetFont(_("Dialog"));
4847 SetFont(*pif);
4848
4849 m_pSoundFile = pSoundFile;
4850 if (pSoundFile) m_sound_file = *pSoundFile;
4851
4852 m_sound = o_sound::Factory();
4853
4854 int border_size = 4;
4855 int group_item_spacing = 2;
4856
4857 int font_size_y, font_descent, font_lead;
4858 GetTextExtent("0", NULL, &font_size_y, &font_descent, &font_lead);
4859 m_small_button_size = wxSize(-1, (int)(1.6 * (font_size_y + font_descent)));
4860
4861 wxBoxSizer* wrapperSizer = new wxBoxSizer(wxVERTICAL);
4862 SetSizer(wrapperSizer);
4863
4864 wxStaticBox* StaticBox1 = new wxStaticBox(this, wxID_ANY, title);
4865 wxStaticBoxSizer* StaticBoxSizer1 =
4866 new wxStaticBoxSizer(StaticBox1, wxVERTICAL);
4867 wrapperSizer->Add(StaticBoxSizer1, 0, wxALL | wxEXPAND, border_size);
4868
4869 m_pCheck_Sound = new wxCheckBox(this, ID_ANCHORALERTAUDIO, checkLegend);
4870 StaticBoxSizer1->Add(m_pCheck_Sound, 1, wxALL, group_item_spacing);
4871
4872 // Sound file
4873 wxString LabelWrapped;
4874
4875#ifdef __ANDROID__
4876 // Count the likely number of lines in the wrapped file name
4877 // to set the default wxStaticText size.
4878 ChartDirPanelHardBreakWrapper wrapper(this, m_sound_file,
4879 g_pOptions->GetSize().x * 8 / 10);
4880 wxArrayString LabelWrappedArray = wrapper.GetLineArray();
4881 for (unsigned int i = 0; i < LabelWrappedArray.GetCount(); i++) {
4882 LabelWrapped += "\n";
4883 }
4884 LabelWrapped += "\n";
4885#endif
4886
4887 m_AudioFileNameText = new wxStaticText(this, wxID_ANY, LabelWrapped);
4888 m_AudioFileNameText->Wrap(-1);
4889 StaticBoxSizer1->Add(m_AudioFileNameText, 0, wxALL | wxEXPAND, border_size);
4890
4891 SetSoundFileLabel(m_sound_file);
4892
4893 // Select/Test sound
4894 wxFlexGridSizer* soundSizer1 = new wxFlexGridSizer(3);
4895 soundSizer1->SetHGap(border_size * 2);
4896 StaticBoxSizer1->Add(soundSizer1, 1, wxALL | wxLEFT, border_size);
4897
4898 SelSound = new wxButton(this, ID_SELECTSOUND, selectLegend, wxDefaultPosition,
4899 m_small_button_size, 0);
4900 soundSizer1->Add(SelSound, 0, wxALL | wxALIGN_RIGHT, group_item_spacing);
4901 soundSizer1->AddSpacer(group_item_spacing * 4);
4902 TestSound = new wxButton(this, ID_TESTSOUND, _("Test"), wxDefaultPosition,
4903 m_small_button_size, 0);
4904 soundSizer1->Add(TestSound, 0, wxALL | wxALIGN_RIGHT, group_item_spacing);
4905 auto sound_action = [this](ObservedEvt ev) { m_soundPlaying = false; };
4906 m_sound_sp_done_listener.Init(m_on_sp_sound_done, sound_action);
4907}
4908
4909void OCPNSoundPanel::SetSoundFileLabel(wxString file) {
4910 wxString soundLabel = wxString(" " + _("Audio file name:") + "\n " + file);
4911
4912 ChartDirPanelHardBreakWrapper wrapper(this, soundLabel,
4913 g_pOptions->GetSize().x * 8 / 10);
4914 wxArrayString LabelWrappedArray = wrapper.GetLineArray();
4915 wxString LabelWrapped;
4916 for (unsigned int i = 0; i < LabelWrappedArray.GetCount(); i++) {
4917 if (i == 0)
4918 LabelWrapped += LabelWrappedArray[i].BeforeFirst('/');
4919 else
4920 LabelWrapped += LabelWrappedArray[i];
4921 LabelWrapped += "\n";
4922 }
4923
4924 m_AudioFileNameText->SetLabel(LabelWrapped);
4925 Layout();
4926}
4927
4928wxString OCPNSoundPanel::SelectSoundFile() {
4929 wxString sound_dir = g_Platform->GetSharedDataDir();
4930 sound_dir.Append("sounds");
4931 wxString sel_file;
4932 int response;
4933
4934#ifndef __ANDROID__
4935 wxFileDialog* popenDialog = new wxFileDialog(
4936 NULL, _("Select Sound File"), sound_dir, wxEmptyString,
4937 "WAV files (*.wav)|*.wav|All files (*.*)|*.*", wxFD_OPEN);
4938 if (g_bresponsive)
4939 popenDialog = g_Platform->AdjustFileDialogFont(this, popenDialog);
4940
4941 response = popenDialog->ShowModal();
4942 sel_file = popenDialog->GetPath();
4943 delete popenDialog;
4944
4945#else
4946 response = g_Platform->DoFileSelectorDialog(
4947 this, &sel_file, _("Select Sound File"), sound_dir, wxEmptyString, "*.*");
4948#endif
4949
4950 wxString rv;
4951 if (response == wxID_OK)
4952 return g_Platform->NormalizePath(sel_file);
4953 else
4954 return "";
4955}
4956
4957void OCPNSoundPanel::OnButtonSelectSound(wxCommandEvent& event) {
4958 wxString sel_file = SelectSoundFile();
4959
4960 if (!sel_file.IsEmpty()) {
4961 m_sound_file = g_Platform->NormalizePath(sel_file);
4962 if (m_pSoundFile) *m_pSoundFile = m_sound_file; // Update global variable
4963
4964 SetSoundFileLabel(m_sound_file);
4965 // g_anchorwatch_sound->Stop();
4966 }
4967}
4968
4969void OCPNSoundPanel::OnButtonSPTestSound(wxCommandEvent& event) {
4970 if (!m_soundPlaying) {
4971 m_sound->SetFinishedCallback(
4972 [&](void* snd) { m_on_sp_sound_done.Notify(snd); });
4973 if (m_sound->Load(m_sound_file, g_iSoundDeviceIndex)) {
4974 m_soundPlaying = true;
4975 m_sound->Play();
4976 }
4977 }
4978}
4979
4980void options::OnUXAudioEnableButtonClickAIS(wxCommandEvent& event) {
4981 if (event.IsChecked())
4982 m_pCheck_AlertAudio->SetValue(true);
4983 else {
4984 if (!m_soundPanelSART->GetCheckBox()->GetValue() &&
4985 !m_soundPanelDSC->GetCheckBox()->GetValue())
4986 m_pCheck_AlertAudio->SetValue(false);
4987 }
4988}
4989
4990void options::OnUXAudioEnableButtonClickSART(wxCommandEvent& event) {
4991 if (event.IsChecked())
4992 m_pCheck_AlertAudio->SetValue(true);
4993 else {
4994 if (!m_soundPanelAIS->GetCheckBox()->GetValue() &&
4995 !m_soundPanelDSC->GetCheckBox()->GetValue())
4996 m_pCheck_AlertAudio->SetValue(false);
4997 }
4998}
4999
5000void options::OnUXAudioEnableButtonClickDSC(wxCommandEvent& event) {
5001 if (event.IsChecked())
5002 m_pCheck_AlertAudio->SetValue(true);
5003 else {
5004 if (!m_soundPanelAIS->GetCheckBox()->GetValue() &&
5005 !m_soundPanelSART->GetCheckBox()->GetValue())
5006 m_pCheck_AlertAudio->SetValue(false);
5007 }
5008}
5009
5010void options::CreatePanel_Sounds(size_t parent, int border_size,
5011 int group_item_spacing) {
5012 wxScrolledWindow* panelSounds = AddPage(parent, _("Sounds"));
5013
5014 wxBoxSizer* wrapperSizer = new wxBoxSizer(wxVERTICAL);
5015 panelSounds->SetSizer(wrapperSizer);
5016
5017 // Anchor Alarm
5018 m_soundPanelAnchor = new OCPNSoundPanel(
5019 panelSounds, wxID_ANY, wxDefaultPosition, wxDefaultSize,
5020 _("Anchor Alarm"), _("Play Sound on Anchor Alarm."),
5021 _("Select Anchor Alarm Sound"), &g_anchorwatch_sound_file);
5022 wrapperSizer->Add(m_soundPanelAnchor, 1, wxALL | wxEXPAND, border_size);
5023
5024 // AIS Alert
5025 m_soundPanelAIS = new OCPNSoundPanel(
5026 panelSounds, wxID_ANY, wxDefaultPosition, wxDefaultSize, _("AIS Alert"),
5027 _("Play Sound on AIS Alert."), _("Select AIS Alert Sound"),
5028 &g_AIS_sound_file);
5029 wrapperSizer->Add(m_soundPanelAIS, 1, wxALL | wxEXPAND, border_size);
5030
5031 m_soundPanelAIS->GetCheckBox()->Connect(
5032 wxEVT_COMMAND_CHECKBOX_CLICKED,
5033 wxCommandEventHandler(options::OnUXAudioEnableButtonClickAIS), NULL,
5034 this);
5035
5036 // SART Alert
5037 m_soundPanelSART = new OCPNSoundPanel(
5038 panelSounds, wxID_ANY, wxDefaultPosition, wxDefaultSize, _("SART Alert"),
5039 _("Play Sound on AIS SART Alert."), _("Select AIS SART Alert Sound"),
5040 &g_SART_sound_file);
5041 wrapperSizer->Add(m_soundPanelSART, 1, wxALL | wxEXPAND, border_size);
5042
5043 m_soundPanelSART->GetCheckBox()->Connect(
5044 wxEVT_COMMAND_CHECKBOX_CLICKED,
5045 wxCommandEventHandler(options::OnUXAudioEnableButtonClickSART), NULL,
5046 this);
5047
5048 // DSC Call
5049 m_soundPanelDSC = new OCPNSoundPanel(
5050 panelSounds, wxID_ANY, wxDefaultPosition, wxDefaultSize, _("DSC Alert"),
5051 _("Play Sound on DSC notification."), _("Select DSC notification Sound"),
5052 &g_DSC_sound_file);
5053 wrapperSizer->Add(m_soundPanelDSC, 1, wxALL | wxEXPAND, border_size);
5054
5055 m_soundPanelDSC->GetCheckBox()->Connect(
5056 wxEVT_COMMAND_CHECKBOX_CLICKED,
5057 wxCommandEventHandler(options::OnUXAudioEnableButtonClickDSC), NULL,
5058 this);
5059
5060 // Sound Device Configuration
5061 wxStaticBox* StatBoxSoundConfig =
5062 new wxStaticBox(panelSounds, wxID_ANY, _("Sound Device Configuration"));
5063 wxStaticBoxSizer* StatBoxSoundConfigSizer =
5064 new wxStaticBoxSizer(StatBoxSoundConfig, wxVERTICAL);
5065 wrapperSizer->Add(StatBoxSoundConfigSizer, 0, wxALL | wxEXPAND, border_size);
5066
5067 auto sound = std::unique_ptr<o_sound::Sound>(o_sound::Factory());
5068 int deviceCount = sound->DeviceCount();
5069 wxLogMessage("options: got device count: %d", deviceCount);
5070 if (deviceCount >= 1) {
5071 wxArrayString labels;
5072 for (int i = 0; i < deviceCount; i += 1) {
5073 wxString label(sound->GetDeviceInfo(i));
5074 if (label == "") {
5075 std::ostringstream stm;
5076 stm << i;
5077 label = _("Unknown device :") + stm.str();
5078 }
5079 if (!sound->IsOutputDevice(i)) {
5080 std::ostringstream stm;
5081 stm << i;
5082 label = _("Input device :") + stm.str();
5083 }
5084 labels.Add(label);
5085 }
5086
5087 // if sound device index is uninitialized, set to "default", if found.
5088 // Otherwise, set to 0
5089 int iDefault = labels.Index("default");
5090
5091 if (g_iSoundDeviceIndex == -1) {
5092 if (iDefault >= 0)
5093 g_iSoundDeviceIndex = iDefault;
5094 else
5095 g_iSoundDeviceIndex = 0;
5096 }
5097
5098 pSoundDeviceIndex = new wxChoice();
5099 if (pSoundDeviceIndex) {
5100 pSoundDeviceIndex->Create(panelSounds, wxID_ANY, wxDefaultPosition,
5101 wxDefaultSize, labels);
5102 pSoundDeviceIndex->SetSelection(g_iSoundDeviceIndex);
5103 pSoundDeviceIndex->Show();
5104 wxFlexGridSizer* pSoundDeviceIndexGrid = new wxFlexGridSizer(2);
5105 StatBoxSoundConfigSizer->Add(pSoundDeviceIndexGrid, 0, wxALL | wxEXPAND,
5106 group_item_spacing);
5107
5108 stSoundDeviceIndex =
5109 new wxStaticText(panelSounds, wxID_STATIC, _("Sound Device"));
5110 pSoundDeviceIndexGrid->Add(stSoundDeviceIndex, 0, wxALL, 5);
5111 pSoundDeviceIndexGrid->Add(pSoundDeviceIndex, 0, wxALL, border_size);
5112 }
5113 }
5114
5115#ifndef __ANDROID__
5116 if ((bool)dynamic_cast<o_sound::SystemCmdSound*>(o_sound::Factory())) {
5117 wxBoxSizer* pSoundSizer = new wxBoxSizer(wxVERTICAL);
5118 StatBoxSoundConfigSizer->Add(pSoundSizer, 0, wxALL | wxEXPAND,
5119 group_item_spacing);
5120 pCmdSoundString =
5121 new wxTextCtrl(panelSounds, wxID_ANY, "", wxDefaultPosition,
5122 wxSize(450, -1), wxTE_LEFT);
5123 pSoundSizer->Add(
5124 new wxStaticText(panelSounds, wxID_ANY, _("Audio Play command:")), 0,
5125 wxALIGN_LEFT | wxALL);
5126 pSoundSizer->Add(pCmdSoundString, 1, wxEXPAND | wxALIGN_LEFT, border_size);
5127 }
5128#endif
5129
5130 if (!deviceCount) StatBoxSoundConfig->Hide();
5131
5132#ifdef __ANDROID__
5133 stSoundDeviceIndex->Hide();
5134 pSoundDeviceIndex->Hide();
5135#endif
5136}
5137
5138void options::CreatePanel_MMSI(size_t parent, int border_size,
5139 int group_item_spacing) {
5140 wxScrolledWindow* panelMMSI = AddPage(parent, _("MMSI Properties"));
5141
5142 wxBoxSizer* MMSISizer = new wxBoxSizer(wxVERTICAL);
5143 panelMMSI->SetSizer(MMSISizer);
5144
5145 // MMSI list control (panel)
5146 wxStaticBox* itemStaticBoxMMSI =
5147 new wxStaticBox(panelMMSI, wxID_ANY, _("MMSI Properties"));
5148 wxStaticBoxSizer* itemStaticBoxSizerMMSI =
5149 new wxStaticBoxSizer(itemStaticBoxMMSI, wxVERTICAL);
5150 MMSISizer->Add(itemStaticBoxSizerMMSI, 0, wxALL | wxEXPAND, border_size);
5151
5152 pPropsPanel = new MMSI_Props_Panel(panelMMSI);
5153
5154 pPropsPanel->UpdateMMSIList();
5155
5156 itemStaticBoxSizerMMSI->Add(pPropsPanel, 0, wxALL | wxEXPAND, border_size);
5157
5158 panelMMSI->Layout();
5159}
5160
5161void options::CreatePanel_AIS(size_t parent, int border_size,
5162 int group_item_spacing) {
5163 wxScrolledWindow* panelAIS = AddPage(parent, _("AIS Targets"));
5164
5165 wxBoxSizer* aisSizer = new wxBoxSizer(wxVERTICAL);
5166 panelAIS->SetSizer(aisSizer);
5167
5168 // CPA Box
5169 wxStaticBox* itemStaticBoxCPA =
5170 new wxStaticBox(panelAIS, wxID_ANY, _("CPA Calculation"));
5171 wxStaticBoxSizer* itemStaticBoxSizerCPA =
5172 new wxStaticBoxSizer(itemStaticBoxCPA, wxVERTICAL);
5173 aisSizer->Add(itemStaticBoxSizerCPA, 0, wxALL | wxEXPAND, border_size);
5174
5175 wxFlexGridSizer* pCPAGrid = new wxFlexGridSizer(2);
5176 pCPAGrid->AddGrowableCol(1);
5177 itemStaticBoxSizerCPA->Add(pCPAGrid, 0, wxALL | wxEXPAND, border_size);
5178
5179 m_pCheck_CPA_Max = new wxCheckBox(
5180 panelAIS, -1,
5181 _("No (T)CPA Alerts if target range is greater than (NMi)"));
5182 m_pCheck_CPA_Max->SetToolTip(
5183 _("Disable CPA (Closest Point of Approach) and TCPA (Time to CPA) alerts "
5184 "for targets beyond this distance from your vessel"));
5185 pCPAGrid->Add(m_pCheck_CPA_Max, 0, wxALL, group_item_spacing);
5186
5187 m_pText_CPA_Max = new wxTextCtrl(panelAIS, -1, "TEXT ");
5188 m_pText_CPA_Max->SetToolTip(
5189 _("Maximum distance in nautical miles at which Closest Point of Approach "
5190 "alerts will be triggered"));
5191 pCPAGrid->Add(m_pText_CPA_Max, 0, wxALL | wxALIGN_RIGHT, group_item_spacing);
5192
5193 m_pCheck_CPA_Warn =
5194 new wxCheckBox(panelAIS, -1, _("Warn if CPA less than (NMi)"));
5195 m_pCheck_CPA_Warn->SetToolTip(
5196 _("Enable warning alerts when targets have a Closest Point of Approach "
5197 "less than this distance"));
5198 pCPAGrid->Add(m_pCheck_CPA_Warn, 0, wxALL, group_item_spacing);
5199
5200 m_pText_CPA_Warn =
5201 new wxTextCtrl(panelAIS, -1, "TEXT ", wxDefaultPosition, wxSize(-1, -1));
5202 m_pText_CPA_Warn->SetToolTip(
5203 _("Distance threshold in nautical miles for CPA warning alerts"));
5204 pCPAGrid->Add(m_pText_CPA_Warn, 0, wxALL | wxALIGN_RIGHT, group_item_spacing);
5205
5206 m_pCheck_CPA_Warn->Connect(wxEVT_COMMAND_CHECKBOX_CLICKED,
5207 wxCommandEventHandler(options::OnCPAWarnClick),
5208 NULL, this);
5209
5210 m_pCheck_CPA_WarnT =
5211 new wxCheckBox(panelAIS, -1, _("...and TCPA is less than (min)"));
5212 m_pCheck_CPA_WarnT->SetToolTip(
5213 _("Additional time constraint - alerts only occur if the Time to Closest "
5214 "Point of Approach is less than this value"));
5215 pCPAGrid->Add(m_pCheck_CPA_WarnT, 0, wxALL, group_item_spacing);
5216
5217 m_pText_CPA_WarnT = new wxTextCtrl(panelAIS, -1, "TEXT ");
5218 m_pText_CPA_WarnT->SetToolTip(
5219 _("Time threshold in minutes for TCPA constraints"));
5220 pCPAGrid->Add(m_pText_CPA_WarnT, 0, wxALL | wxALIGN_RIGHT,
5221 group_item_spacing);
5222
5223 // Lost Targets
5224 wxStaticBox* lostBox = new wxStaticBox(panelAIS, wxID_ANY, _("Lost Targets"));
5225 wxStaticBoxSizer* lostSizer = new wxStaticBoxSizer(lostBox, wxVERTICAL);
5226 aisSizer->Add(lostSizer, 0, wxALL | wxEXPAND, 3);
5227
5228 wxFlexGridSizer* pLostGrid = new wxFlexGridSizer(2);
5229 pLostGrid->AddGrowableCol(1);
5230 lostSizer->Add(pLostGrid, 0, wxALL | wxEXPAND, border_size);
5231
5232 m_pCheck_Mark_Lost =
5233 new wxCheckBox(panelAIS, -1, _("Mark targets as lost after (min)"));
5234 m_pCheck_Mark_Lost->SetToolTip(
5235 _("Targets will be considered lost when no update is received for this "
5236 "time period"));
5237 pLostGrid->Add(m_pCheck_Mark_Lost, 1, wxALL, group_item_spacing);
5238
5239 m_pText_Mark_Lost = new wxTextCtrl(panelAIS, -1, "TEXT ");
5240 m_pText_Mark_Lost->SetToolTip(
5241 _("Time in minutes after which targets with no updates are marked as "
5242 "lost"));
5243 pLostGrid->Add(m_pText_Mark_Lost, 1, wxALL | wxALIGN_RIGHT,
5244 group_item_spacing);
5245
5246 m_pCheck_Remove_Lost =
5247 new wxCheckBox(panelAIS, -1, _("Remove lost targets after (min)"));
5248 m_pCheck_Remove_Lost->SetToolTip(
5249 _("Lost targets will be completely removed from display after this "
5250 "additional time period"));
5251 pLostGrid->Add(m_pCheck_Remove_Lost, 1, wxALL, group_item_spacing);
5252
5253 m_pText_Remove_Lost = new wxTextCtrl(panelAIS, -1, "TEXT ");
5254 m_pText_Remove_Lost->SetToolTip(_(
5255 "Time in minutes after which lost targets are removed from the display"));
5256 pLostGrid->Add(m_pText_Remove_Lost, 1, wxALL | wxALIGN_RIGHT,
5257 group_item_spacing);
5258
5259 if (g_bInlandEcdis) lostSizer->Hide(pLostGrid, true);
5260
5261 // Display
5262 wxStaticBox* displBox = new wxStaticBox(panelAIS, wxID_ANY, _("Display"));
5263 wxStaticBoxSizer* displSizer = new wxStaticBoxSizer(displBox, wxHORIZONTAL);
5264 aisSizer->Add(displSizer, 0, wxALL | wxEXPAND, border_size);
5265
5266 wxFlexGridSizer* pDisplayGrid = new wxFlexGridSizer(2);
5267 pDisplayGrid->AddGrowableCol(1);
5268 displSizer->Add(pDisplayGrid, 1, wxALL | wxEXPAND, border_size);
5269
5270 m_pCheck_Show_COG = new wxCheckBox(
5271 panelAIS, -1, _("Show target COG predictor arrow, length (min)"));
5272 m_pCheck_Show_COG->SetToolTip(
5273 _("Display a predictor arrow for each AIS target, showing its projected "
5274 "course over ground for the specified number of minutes."));
5275 pDisplayGrid->Add(m_pCheck_Show_COG, 1, wxALL | wxEXPAND, group_item_spacing);
5276
5277 m_pText_COG_Predictor = new wxTextCtrl(panelAIS, -1, "TEXT ");
5278 m_pText_COG_Predictor->SetToolTip(
5279 _("Set the length in minutes for the COG predictor arrow for AIS "
5280 "targets."));
5281 pDisplayGrid->Add(m_pText_COG_Predictor, 1, wxALL | wxALIGN_RIGHT,
5282 group_item_spacing);
5283
5284 m_pCheck_Sync_OCOG_ACOG = new wxCheckBox(
5285 panelAIS, -1, _("Sync AIS arrow length with own ship's COG predictor"));
5286 pDisplayGrid->Add(m_pCheck_Sync_OCOG_ACOG, 1, wxALL, group_item_spacing);
5287 m_pCheck_Sync_OCOG_ACOG->Connect(
5288 wxEVT_COMMAND_CHECKBOX_CLICKED,
5289 wxCommandEventHandler(options::OnSyncCogPredClick), NULL, this);
5290
5291 wxStaticText* pStatic_Dummy4a = new wxStaticText(panelAIS, -1, "");
5292 pDisplayGrid->Add(pStatic_Dummy4a, 1, wxALL, group_item_spacing);
5293
5294 m_pCheck_Show_Tracks =
5295 new wxCheckBox(panelAIS, -1, _("Show target tracks, length (min)"));
5296 m_pCheck_Show_Tracks->SetToolTip(
5297 _("Display the recent track (history) of each AIS target for the "
5298 "specified number of minutes."));
5299 pDisplayGrid->Add(m_pCheck_Show_Tracks, 1, wxALL, group_item_spacing);
5300
5301 m_pText_Track_Length = new wxTextCtrl(panelAIS, -1, "TEXT ");
5302 pDisplayGrid->Add(m_pText_Track_Length, 1, wxALL | wxALIGN_RIGHT,
5303 group_item_spacing);
5304
5305 m_pCheck_Hide_Moored = new wxCheckBox(
5306 panelAIS, -1, _("Suppress anchored/moored targets, speed max (kn)"));
5307 m_pCheck_Hide_Moored->SetToolTip(
5308 _("Hide AIS targets that are moving slower than this speed, typically "
5309 "indicating they are anchored or moored."));
5310 pDisplayGrid->Add(m_pCheck_Hide_Moored, 1, wxALL, group_item_spacing);
5311
5312 m_pText_Moored_Speed = new wxTextCtrl(panelAIS, -1, "TEXT ");
5313 pDisplayGrid->Add(m_pText_Moored_Speed, 1, wxALL | wxALIGN_RIGHT,
5314 group_item_spacing);
5315
5316 m_pCheck_Draw_Realtime_Prediction = new wxCheckBox(
5317 panelAIS, -1, _("Draw AIS realtime prediction, target speed min (kn)"));
5318 m_pCheck_Draw_Realtime_Prediction->SetToolTip(
5319 _("Show a real-time prediction vector for AIS targets moving faster than "
5320 "this speed."));
5321 pDisplayGrid->Add(m_pCheck_Draw_Realtime_Prediction, 1, wxALL,
5322 group_item_spacing);
5323
5324 m_pText_RealtPred_Speed = new wxTextCtrl(panelAIS, -1, "TEXT ");
5325 pDisplayGrid->Add(m_pText_RealtPred_Speed, 1, wxALL | wxALIGN_RIGHT,
5326 group_item_spacing);
5327
5328 m_pCheck_Scale_Priority = new wxCheckBox(
5329 panelAIS, -1,
5330 _("Allow attenuation of less critical targets if more than ... targets"));
5331 m_pCheck_Scale_Priority->SetToolTip(
5332 _("Reduce the display prominence of less critical AIS targets when the "
5333 "number of targets exceeds the specified value."));
5334 pDisplayGrid->Add(m_pCheck_Scale_Priority, 1, wxALL, group_item_spacing);
5335
5336 m_pText_Scale_Priority = new wxTextCtrl(panelAIS, -1, "TEXT ");
5337 pDisplayGrid->Add(m_pText_Scale_Priority, 1, wxALL | wxALIGN_RIGHT,
5338 group_item_spacing);
5339
5340 m_pCheck_Show_Area_Notices = new wxCheckBox(
5341 panelAIS, -1, _("Show area notices (from AIS binary messages)"));
5342 m_pCheck_Show_Area_Notices->SetToolTip(
5343 _("Display area notices received via AIS binary messages on the chart."));
5344 pDisplayGrid->Add(m_pCheck_Show_Area_Notices, 1, wxALL, group_item_spacing);
5345
5346 wxStaticText* pStatic_Dummy5 = new wxStaticText(panelAIS, -1, "");
5347 pDisplayGrid->Add(pStatic_Dummy5, 1, wxALL, group_item_spacing);
5348
5349 m_pCheck_Draw_Target_Size =
5350 new wxCheckBox(panelAIS, -1, _("Show AIS targets real size"));
5351 m_pCheck_Draw_Target_Size->SetToolTip(
5352 _("Display AIS targets using their actual reported size and shape on the "
5353 "chart."));
5354 pDisplayGrid->Add(m_pCheck_Draw_Target_Size, 1, wxALL, group_item_spacing);
5355
5356 wxStaticText* pStatic_Dummy6 = new wxStaticText(panelAIS, -1, "");
5357 pDisplayGrid->Add(pStatic_Dummy6, 1, wxALL, group_item_spacing);
5358
5359 m_pCheck_Show_Target_Name = new wxCheckBox(
5360 panelAIS, -1, _("Show names with AIS targets at scale greater than 1:"));
5361 m_pCheck_Show_Target_Name->SetToolTip(
5362 _("Display the name of AIS targets when the chart scale is greater than "
5363 "the specified value."));
5364 pDisplayGrid->Add(m_pCheck_Show_Target_Name, 1, wxALL, group_item_spacing);
5365
5366 m_pText_Show_Target_Name_Scale = new wxTextCtrl(panelAIS, -1, "TEXT ");
5367 pDisplayGrid->Add(m_pText_Show_Target_Name_Scale, 1, wxALL | wxALIGN_RIGHT,
5368 group_item_spacing);
5369
5370 m_pCheck_use_Wpl = new wxCheckBox(
5371 panelAIS, -1, _("Use WPL position messages. Action when received:"));
5372 m_pCheck_use_Wpl->SetToolTip(
5373 _("Enable processing of WPL (Waypoint Location) position messages from "
5374 "AIS and select the action to take when received."));
5375 pDisplayGrid->Add(m_pCheck_use_Wpl, 1, wxALL, group_item_spacing);
5376
5377 wxString Wpl_Action[] = {_("APRS position report"), _("Create mark")};
5378 m_pWplAction = new wxChoice(panelAIS, wxID_ANY, wxDefaultPosition,
5379 wxDefaultSize, 2, Wpl_Action);
5380 m_pWplAction->SetToolTip(
5381 _("Select the action to perform when a WPL message is received: create "
5382 "an Automatic Packet Reporting System (APRS) report or a mark on the "
5383 "chart."));
5384 pDisplayGrid->Add(m_pWplAction, 1, wxALIGN_RIGHT | wxALL, group_item_spacing);
5385
5386 // Rollover
5387 wxStaticBox* rolloverBox = new wxStaticBox(panelAIS, wxID_ANY, _("Rollover"));
5388 wxStaticBoxSizer* rolloverSizer =
5389 new wxStaticBoxSizer(rolloverBox, wxVERTICAL);
5390 aisSizer->Add(rolloverSizer, 0, wxALL | wxEXPAND, border_size);
5391
5392 pRollover = new wxCheckBox(panelAIS, ID_ROLLOVERBOX,
5393 _("Enable route/AIS info block"));
5394 pRollover->SetToolTip(
5395 _("Show a popup info block with details about routes and AIS targets "
5396 "when hovering over them."));
5397 rolloverSizer->Add(pRollover, 1, wxALL, 2 * group_item_spacing);
5398
5399 pRollover->Connect(wxEVT_COMMAND_CHECKBOX_CLICKED,
5400 wxCommandEventHandler(options::OnAISRolloverClick), NULL,
5401 this);
5402
5403 pStatic_CallSign =
5404 new wxStaticText(panelAIS, -1, _("\"Ship Name\" MMSI (Call Sign)"));
5405 pStatic_CallSign->SetToolTip(
5406 _("Display the ship name and MMSI (call sign) in the rollover info "
5407 "block."));
5408 rolloverSizer->Add(pStatic_CallSign, 1, wxALL, 2 * group_item_spacing);
5409
5410 m_pCheck_Rollover_Class =
5411 new wxCheckBox(panelAIS, -1, _("[Class] Type (Status)"));
5412 m_pCheck_Rollover_Class->SetToolTip(
5413 _("Show the AIS class, type, and status in the rollover info block."));
5414 rolloverSizer->Add(m_pCheck_Rollover_Class, 1, wxALL, 2 * group_item_spacing);
5415
5416 m_pCheck_Rollover_COG = new wxCheckBox(panelAIS, -1, _("SOG COG"));
5417 m_pCheck_Rollover_COG->SetToolTip(
5418 _("Show speed over ground (SOG) and course over ground (COG) in the "
5419 "rollover info block."));
5420 rolloverSizer->Add(m_pCheck_Rollover_COG, 1, wxALL, 2 * group_item_spacing);
5421
5422 m_pCheck_Rollover_CPA = new wxCheckBox(panelAIS, -1, _("CPA TCPA"));
5423 m_pCheck_Rollover_CPA->SetToolTip(
5424 _("Show Closest Point of Approach (CPA) and time to CPA (TCPA) in the "
5425 "rollover info block."));
5426 rolloverSizer->Add(m_pCheck_Rollover_CPA, 1, wxALL, 2 * group_item_spacing);
5427
5428 // Alert Box
5429 wxStaticBox* alertBox =
5430 new wxStaticBox(panelAIS, wxID_ANY, _("CPA/TCPA Alerts"));
5431 wxStaticBoxSizer* alertSizer = new wxStaticBoxSizer(alertBox, wxVERTICAL);
5432 aisSizer->Add(alertSizer, 0, wxALL | wxEXPAND, group_item_spacing);
5433
5434 wxFlexGridSizer* pAlertGrid = new wxFlexGridSizer(2);
5435 pAlertGrid->AddGrowableCol(1);
5436 alertSizer->Add(pAlertGrid, 0, wxALL | wxEXPAND, group_item_spacing);
5437
5438 m_pCheck_AlertDialog = new wxCheckBox(panelAIS, ID_AISALERTDIALOG,
5439 _("Show CPA/TCPA Alert Dialog"));
5440 pAlertGrid->Add(m_pCheck_AlertDialog, 0, wxALL, group_item_spacing);
5441
5442 m_pCheck_AlertDialog->Connect(
5443 wxEVT_COMMAND_CHECKBOX_CLICKED,
5444 wxCommandEventHandler(options::OnAlertEnableButtonClick), NULL, this);
5445
5446 // wxButton* m_SelSound =
5447 // new wxButton(panelAIS, ID_AISALERTSELECTSOUND, _("Select Alert
5448 // Sound"),
5449 // wxDefaultPosition, m_small_button_size, 0);
5450 // pAlertGrid->Add(m_SelSound, 0, wxALL | wxALIGN_RIGHT,
5451 // group_item_spacing);
5452
5453 wxStaticText* pStatic_Dummy5a = new wxStaticText(panelAIS, -1, "");
5454 pAlertGrid->Add(pStatic_Dummy5a, 1, wxALL, group_item_spacing);
5455
5456 m_pCheck_AlertAudio = new wxCheckBox(
5457 panelAIS, ID_AISALERTAUDIO,
5458 _("Play Sound on CPA/TCPA Alerts and DSC/SART emergencies."));
5459 pAlertGrid->Add(m_pCheck_AlertAudio, 0, wxALL, group_item_spacing);
5460
5461 m_pCheck_AlertAudio->Connect(
5462 wxEVT_COMMAND_CHECKBOX_CLICKED,
5463 wxCommandEventHandler(options::OnAlertAudioEnableButtonClick), NULL,
5464 this);
5465
5466 wxButton* m_pPlay_Sound =
5467 new wxButton(panelAIS, -1, _("Test AIS Alert Sound"), wxDefaultPosition,
5468 m_small_button_size, 0);
5469 pAlertGrid->Add(m_pPlay_Sound, 0, wxALL | wxALIGN_RIGHT, group_item_spacing);
5470
5471 m_pPlay_Sound->Connect(wxEVT_COMMAND_BUTTON_CLICKED,
5472 wxCommandEventHandler(options::OnButtonTestSound),
5473 NULL, this);
5474
5475 // wxStaticText* pStatic_Dummy5b = new wxStaticText(panelAIS, -1, "");
5476 // pAlertGrid->Add(pStatic_Dummy5b, 1, wxALL, group_item_spacing);
5477
5478 m_pCheck_Alert_Moored = new wxCheckBox(
5479 panelAIS, -1, _("Suppress Alerts for anchored/moored targets"));
5480 pAlertGrid->Add(m_pCheck_Alert_Moored, 1, wxALL, group_item_spacing);
5481
5482 wxStaticText* pStatic_Dummy2 = new wxStaticText(panelAIS, -1, "");
5483 pAlertGrid->Add(pStatic_Dummy2, 1, wxALL, group_item_spacing);
5484
5485 m_pCheck_Ack_Timout = new wxCheckBox(
5486 panelAIS, -1, _("Enable Target Alert Acknowledge timeout (min)"));
5487 pAlertGrid->Add(m_pCheck_Ack_Timout, 1, wxALL, group_item_spacing);
5488
5489 m_pText_ACK_Timeout = new wxTextCtrl(panelAIS, -1, "TEXT ");
5490 pAlertGrid->Add(m_pText_ACK_Timeout, 1, wxALL | wxALIGN_RIGHT,
5491 group_item_spacing);
5492
5493 panelAIS->Layout();
5494}
5495
5496class MouseZoomSlider : public wxSlider {
5497public:
5498 MouseZoomSlider(wxWindow* parent, wxSize size)
5499 : wxSlider(parent, wxID_ANY, 10, 1, 100, wxDefaultPosition, size,
5500 SLIDER_STYLE) {
5501 Show();
5502#ifdef __ANDROID__
5503 GetHandle()->setStyleSheet(getQtStyleSheet());
5504#endif
5505 }
5506};
5507
5508void options::CreatePanel_UI(size_t parent, int border_size,
5509 int group_item_spacing) {
5510 wxScrolledWindow* itemPanelFont = AddPage(parent, _("General Options"));
5511
5512 m_itemBoxSizerFontPanel = new wxBoxSizer(wxVERTICAL);
5513 itemPanelFont->SetSizer(m_itemBoxSizerFontPanel);
5514
5515 wxBoxSizer* langStyleBox = new wxBoxSizer(wxHORIZONTAL);
5516 m_itemBoxSizerFontPanel->Add(langStyleBox, 0, wxEXPAND | wxALL, border_size);
5517
5518 wxStaticBox* itemLangStaticBox =
5519 new wxStaticBox(itemPanelFont, wxID_ANY, _("Language"));
5520 wxStaticBoxSizer* itemLangStaticBoxSizer =
5521 new wxStaticBoxSizer(itemLangStaticBox, wxVERTICAL);
5522
5523 langStyleBox->Add(itemLangStaticBoxSizer, 1, wxEXPAND | wxALL, border_size);
5524
5525 wxSize langChoiceSize = wxSize(-1, -1);
5526#ifdef __ANDROID__
5527 // Need to set wxChoice vertical size explicitely in Android
5528 langChoiceSize = wxSize(-1, m_fontHeight * 3 / 4);
5529#endif
5530
5531 m_itemLangListBox = new wxChoice(itemPanelFont, ID_CHOICE_LANG,
5532 wxDefaultPosition, langChoiceSize);
5533
5534 itemLangStaticBoxSizer->Add(m_itemLangListBox, 0, wxEXPAND | wxALL,
5535 border_size);
5536#ifdef __ANDROID__
5537 // m_itemLangListBox->Disable();
5538#endif
5539
5540 // Fonts
5541 wxStaticBox* itemFontStaticBox =
5542 new wxStaticBox(itemPanelFont, wxID_ANY, _("Fonts"));
5543
5544 wxSize fontChoiceSize = wxSize(-1, -1);
5545
5546 int fLayout = wxHORIZONTAL;
5547#ifdef __ANDROID__
5548 // Compensate for very narrow displays on Android
5549 if (m_nCharWidthMax < 40) fLayout = wxVERTICAL;
5550
5551 // Need to set wxChoice vertical size explicitely in Android
5552 fontChoiceSize = wxSize(-1, m_fontHeight * 3 / 4);
5553#endif
5554
5555 wxStaticBoxSizer* itemFontStaticBoxSizer =
5556 new wxStaticBoxSizer(itemFontStaticBox, fLayout);
5557 m_itemBoxSizerFontPanel->Add(itemFontStaticBoxSizer, 0, wxEXPAND | wxALL,
5558 border_size);
5559
5560 m_itemFontElementListBox =
5561 new wxChoice(itemPanelFont, ID_CHOICE_FONTELEMENT, wxDefaultPosition,
5562 fontChoiceSize, 0, NULL, wxCB_SORT);
5563
5564 wxArrayString uniqueStrings = FontMgr::Get().GetDialogStrings(g_locale);
5565 for (size_t i = 0; i < uniqueStrings.GetCount(); i++) {
5566 m_itemFontElementListBox->Append(uniqueStrings[i]);
5567 }
5568
5569 if (uniqueStrings.GetCount()) m_itemFontElementListBox->SetSelection(0);
5570
5571 itemFontStaticBoxSizer->Add(m_itemFontElementListBox, 0, wxALL, border_size);
5572
5573 wxButton* itemFontChooseButton =
5574 new wxButton(itemPanelFont, ID_BUTTONFONTCHOOSE, _("Choose Font..."),
5575 wxDefaultPosition, wxDefaultSize, 0);
5576 itemFontStaticBoxSizer->Add(itemFontChooseButton, 0, wxALL, border_size);
5577#if defined(__WXGTK__) || defined(__WXQT__)
5578 wxButton* itemFontColorButton =
5579 new wxButton(itemPanelFont, ID_BUTTONFONTCOLOR, _("Choose Font Color..."),
5580 wxDefaultPosition, wxDefaultSize, 0);
5581 itemFontStaticBoxSizer->Add(itemFontColorButton, 0, wxALL, border_size);
5582#endif
5583 wxButton* itemFontResetButton =
5584 new wxButton(itemPanelFont, ID_BUTTONFONT_RESET, _("Reset to Default"),
5585 wxDefaultPosition, wxDefaultSize, 0);
5586 itemFontStaticBoxSizer->Add(itemFontResetButton, 0, wxALL, border_size);
5587
5588 m_textSample = new wxStaticText(itemPanelFont, wxID_ANY, _("Sample"),
5589 wxDefaultPosition, wxDefaultSize, 0);
5590 itemFontStaticBoxSizer->Add(m_textSample, 0, wxALL, border_size);
5591 wxCommandEvent e;
5592 OnFontChoice(e);
5593
5594#if 0
5595 wxStaticBox* itemStyleStaticBox =
5596 new wxStaticBox(itemPanelFont, wxID_ANY, _("Toolbar and Window Style"));
5597 wxStaticBoxSizer* itemStyleStaticBoxSizer =
5598 new wxStaticBoxSizer(itemStyleStaticBox, wxVERTICAL);
5599 langStyleBox->Add(itemStyleStaticBoxSizer, 1, wxEXPAND | wxALL, border_size);
5600
5601 m_itemStyleListBox = new wxChoice(itemPanelFont, ID_STYLESCOMBOBOX);
5602
5603 wxArrayPtrVoid styles = g_StyleManager->GetArrayOfStyles();
5604 for (unsigned int i = 0; i < styles.Count(); i++) {
5605 ocpnStyle::Style* style = (ocpnStyle::Style*)(styles[i]);
5606 m_itemStyleListBox->Append(style->name);
5607 }
5608 m_itemStyleListBox->SetStringSelection(
5609 g_StyleManager->GetCurrentStyle()->name);
5610 itemStyleStaticBoxSizer->Add(m_itemStyleListBox, 1, wxEXPAND | wxALL,
5611 border_size);
5612#endif
5613 wxStaticBox* miscOptionsBox =
5614 new wxStaticBox(itemPanelFont, wxID_ANY, _("Interface Options"));
5615 wxStaticBoxSizer* miscOptions =
5616 new wxStaticBoxSizer(miscOptionsBox, wxVERTICAL);
5617 m_itemBoxSizerFontPanel->Add(miscOptions, 0, wxALL | wxEXPAND, border_size);
5618
5619 pShowStatusBar =
5620 new wxCheckBox(itemPanelFont, ID_DEBUGCHECKBOX1, _("Show Status Bar"));
5621 pShowStatusBar->SetValue(FALSE);
5622 miscOptions->Add(pShowStatusBar, 0, wxALL, border_size);
5623
5624#ifndef __WXOSX__
5625 pShowMenuBar = new wxCheckBox(itemPanelFont, wxID_ANY, _("Show Menu Bar"));
5626 pShowMenuBar->SetValue(FALSE);
5627 miscOptions->Add(pShowMenuBar, 0, wxALL, border_size);
5628#endif
5629
5630#ifdef __ANDROID__
5631 pShowMenuBar->Hide();
5632#endif
5633
5634 pShowChartBar = new wxCheckBox(itemPanelFont, wxID_ANY, _("Show Chart Bar"));
5635 pShowChartBar->SetValue(g_bShowChartBar);
5636 miscOptions->Add(pShowChartBar, 0, wxALL, border_size);
5637
5638 pShowCompassWin = new wxCheckBox(itemPanelFont, wxID_ANY,
5639 _("Show Compass/GPS Status Window"));
5640 pShowCompassWin->SetValue(FALSE);
5641 miscOptions->Add(pShowCompassWin, 0, wxALL, border_size);
5642
5643 wxBoxSizer* pToolbarAutoHide = new wxBoxSizer(wxHORIZONTAL);
5644 miscOptions->Add(pToolbarAutoHide, 0, wxALL | wxEXPAND, group_item_spacing);
5645
5646 pToolbarAutoHideCB =
5647 new wxCheckBox(itemPanelFont, wxID_ANY, _("Enable Toolbar auto-hide"));
5648 pToolbarAutoHide->Add(pToolbarAutoHideCB, 0, wxALL, group_item_spacing);
5649 pToolbarHideSecs =
5650 new wxTextCtrl(itemPanelFont, ID_OPTEXTCTRL, "", wxDefaultPosition,
5651 wxSize(50, -1), wxTE_RIGHT);
5652 pToolbarAutoHide->Add(pToolbarHideSecs, 0, wxALL, group_item_spacing);
5653
5654 pToolbarAutoHide->Add(new wxStaticText(itemPanelFont, wxID_ANY, _("seconds")),
5655 group_item_spacing);
5656
5657 auto enable_debug_cb = new wxCheckBox(itemPanelFont, wxID_ANY,
5658 _("Enable Debug in root context menu"));
5659 enable_debug_cb->Bind(wxEVT_CHECKBOX, [enable_debug_cb](wxCommandEvent&) {
5660 g_enable_root_menu_debug = enable_debug_cb->IsChecked();
5661 });
5662 enable_debug_cb->SetValue(g_enable_root_menu_debug);
5663 miscOptions->Add(enable_debug_cb, 0, wxALL, border_size);
5664
5665 // Sound option
5666 pPlayShipsBells =
5667 new wxCheckBox(itemPanelFont, ID_BELLSCHECKBOX, _("Play Ships Bells"));
5668 miscOptions->Add(pPlayShipsBells, 0, wxALL | wxEXPAND, border_size);
5669
5670 // Mobile/Touchscreen checkboxes
5671 pMobile = new wxCheckBox(itemPanelFont, ID_MOBILEBOX,
5672 _("Enable Touchscreen interface"));
5673 miscOptions->Add(pMobile, 0, wxALL, border_size);
5674
5675 pResponsive = new wxCheckBox(itemPanelFont, ID_REPONSIVEBOX,
5676 _("Enable Scaled Graphics interface"));
5677 miscOptions->Add(pResponsive, 0, wxALL, border_size);
5678
5679 // These two options are always needed ON for Android
5680#ifdef __ANDROID__
5681 pMobile->Hide();
5682 pResponsive->Hide();
5683#endif
5684
5685 // "Responsive graphics" option deprecated in O58+
5686 pResponsive->Hide();
5687
5688 pZoomButtons =
5689 new wxCheckBox(itemPanelFont, ID_ZOOMBUTTONS, _("Show Zoom buttons"));
5690 miscOptions->Add(pZoomButtons, 0, wxALL, border_size);
5691#ifndef __ANDROID__
5692 pZoomButtons->Hide();
5693#endif
5694
5695 pHiconColors = new wxCheckBox(itemPanelFont, ID_HICONCOLORS,
5696 _("Use High Contrast Chart Colors"));
5697 miscOptions->Add(pHiconColors, 0, wxALL, border_size);
5698
5699 // Add option for live ETA
5700#ifndef __ANDROID__
5701 pSLiveETA = new wxCheckBox(itemPanelFont, ID_CHECK_LIVEETA,
5702 _("Show Live ETA at Cursor on Status Bar"));
5703 miscOptions->Add(pSLiveETA, 0, wxALL, border_size);
5704#endif
5705 pInlandEcdis =
5706 new wxCheckBox(itemPanelFont, ID_INLANDECDISBOX, _("Use Inland ECDIS"));
5707 miscOptions->Add(pInlandEcdis, 0, wxALL, border_size);
5708
5709 wxButton* itemEcdisHelp =
5710 new wxButton(itemPanelFont, ID_BUTTONECDISHELP, _("Inland ECDIS Manual"),
5711 wxDefaultPosition, wxDefaultSize, 0);
5712 miscOptions->Add(itemEcdisHelp, 0, wxALL, border_size);
5713
5714#ifdef __ANDROID__
5715 pInlandEcdis->Hide();
5716 itemEcdisHelp->Hide();
5717#endif
5718
5719 miscOptions->AddSpacer(10);
5720
5721 wxFlexGridSizer* sliderSizer;
5722 sliderSizer = new wxFlexGridSizer(0, 2, 0, 0);
5723 sliderSizer->AddGrowableCol(1);
5724 sliderSizer->SetFlexibleDirection(wxBOTH);
5725 sliderSizer->SetNonFlexibleGrowMode(wxFLEX_GROWMODE_SPECIFIED);
5726
5727 m_pSlider_GUI_Factor =
5728 new wxSlider(itemPanelFont, wxID_ANY, 0, -5, 5, wxDefaultPosition,
5729 m_sliderSize, SLIDER_STYLE);
5730 m_pSlider_GUI_Factor->Hide();
5731 sliderSizer->Add(new wxStaticText(itemPanelFont, wxID_ANY,
5732 _("User Interface scale factor")),
5733 inputFlags);
5734 sliderSizer->Add(m_pSlider_GUI_Factor, 0, wxALL, border_size);
5735 m_pSlider_GUI_Factor->Show();
5736
5737#ifdef __ANDROID__
5738 prepareSlider(m_pSlider_GUI_Factor);
5739#endif
5740
5741 m_pSlider_Chart_Factor =
5742 new wxSlider(itemPanelFont, wxID_ANY, 0, -5, 5, wxDefaultPosition,
5743 m_sliderSize, SLIDER_STYLE);
5744 m_pSlider_Chart_Factor->Hide();
5745 sliderSizer->Add(
5746 new wxStaticText(itemPanelFont, wxID_ANY, _("Chart Object scale factor")),
5747 inputFlags);
5748 sliderSizer->Add(m_pSlider_Chart_Factor, 0, wxALL, border_size);
5749 m_pSlider_Chart_Factor->Show();
5750
5751#ifdef __ANDROID__
5752 prepareSlider(m_pSlider_Chart_Factor);
5753#endif
5754
5755 m_pSlider_Ship_Factor =
5756 new wxSlider(itemPanelFont, wxID_ANY, 0, -5, 5, wxDefaultPosition,
5757 m_sliderSize, SLIDER_STYLE);
5758 m_pSlider_Ship_Factor->Hide();
5759 sliderSizer->Add(
5760 new wxStaticText(itemPanelFont, wxID_ANY, _("Ship scale factor")),
5761 inputFlags);
5762 sliderSizer->Add(m_pSlider_Ship_Factor, 0, wxALL, border_size);
5763 m_pSlider_Ship_Factor->Show();
5764
5765#ifdef __ANDROID__
5766 m_pSlider_Ship_Factor->GetHandle()->setStyleSheet(getQtStyleSheet());
5767#endif
5768
5769 m_pSlider_Text_Factor =
5770 new wxSlider(itemPanelFont, wxID_ANY, 0, -5, 5, wxDefaultPosition,
5771 m_sliderSize, SLIDER_STYLE);
5772 m_pSlider_Text_Factor->Hide();
5773 sliderSizer->Add(
5774 new wxStaticText(itemPanelFont, wxID_ANY, _("ENC Sounding factor")),
5775 inputFlags);
5776 sliderSizer->Add(m_pSlider_Text_Factor, 0, wxALL, border_size);
5777 m_pSlider_Text_Factor->Show();
5778
5779#ifdef __ANDROID__
5780 m_pSlider_Text_Factor->GetHandle()->setStyleSheet(getQtStyleSheet());
5781#endif
5782
5783 m_pSlider_ENCText_Factor =
5784 new wxSlider(itemPanelFont, wxID_ANY, 0, -5, 5, wxDefaultPosition,
5785 m_sliderSize, SLIDER_STYLE);
5786 m_pSlider_ENCText_Factor->Hide();
5787 sliderSizer->Add(
5788 new wxStaticText(itemPanelFont, wxID_ANY, _("ENC Text Scale")),
5789 inputFlags);
5790 sliderSizer->Add(m_pSlider_ENCText_Factor, 0, wxALL, border_size);
5791 m_pSlider_ENCText_Factor->Show();
5792
5793#ifdef __ANDROID__
5794 m_pSlider_ENCText_Factor->GetHandle()->setStyleSheet(getQtStyleSheet());
5795#endif
5796
5797 sliderSizer->Add(new wxStaticText(itemPanelFont, wxID_ANY,
5798 _("Mouse wheel zoom sensitivity")),
5799 inputFlags);
5800 m_pMouse_Zoom_Slider = new MouseZoomSlider(itemPanelFont, m_sliderSize);
5801 sliderSizer->Add(m_pMouse_Zoom_Slider, 0, wxALL, border_size);
5802
5803 miscOptions->Add(sliderSizer, 0, wxEXPAND, 5);
5804 miscOptions->AddSpacer(20);
5805}
5806
5807void options::OnResetFont(wxCommandEvent& event) {
5808 wxString itemElement;
5809 int i = m_itemFontElementListBox->GetSelection();
5810 if (i >= 0) {
5811 itemElement = m_itemFontElementListBox->GetString(i);
5812
5813 if (FontMgr::Get().ResetFontToDefault(itemElement)) {
5814 // Update the sample text with new default font
5815 wxFont* pFont = FontMgr::Get().GetFont(itemElement);
5816 wxColour colour = FontMgr::Get().GetFontColor(itemElement);
5817
5818 if (pFont) {
5819 m_textSample->SetFont(*pFont);
5820 m_textSample->SetForegroundColour(colour);
5821 m_textSample->Refresh();
5822 }
5823 // Force immediate update of UI elements
5824 top_frame::Get()->UpdateAllFonts();
5825 m_bfontChanged = true;
5826 OnFontChoice(event);
5827 }
5828 }
5829}
5830
5831void options::OnAlertEnableButtonClick(wxCommandEvent& event) {
5832 m_pCheck_AlertAudio->Enable(event.IsChecked());
5833 if (!event.IsChecked()) m_pCheck_AlertAudio->SetValue(false);
5834}
5835
5836void options::OnAlertAudioEnableButtonClick(wxCommandEvent& event) {
5837 if (event.IsChecked()) {
5838 m_soundPanelAIS->GetCheckBox()->SetValue(true);
5839 m_soundPanelSART->GetCheckBox()->SetValue(true);
5840 m_soundPanelDSC->GetCheckBox()->SetValue(true);
5841 }
5842}
5843
5844void options::CreateListbookIcons() {
5845 ocpnStyle::Style* style = g_StyleManager->GetCurrentStyle();
5846
5847 if (!g_bresponsive) {
5848 int sx = 40;
5849 int sy = 40;
5850 m_topImgList = new wxImageList(sx, sy, TRUE, 0);
5851
5852#if wxCHECK_VERSION(2, 8, 12)
5853 m_topImgList->Add(style->GetIcon("Display", sx, sy));
5854 m_topImgList->Add(style->GetIcon("Charts", sx, sy));
5855 m_topImgList->Add(style->GetIcon("Connections", sx, sy));
5856 m_topImgList->Add(style->GetIcon("Ship", sx, sy));
5857 m_topImgList->Add(style->GetIcon("UI", sx, sy));
5858 m_topImgList->Add(style->GetIcon("Plugins", sx, sy));
5859#else
5860 wxBitmap bmp;
5861 wxImage img;
5862 bmp = style->GetIcon("Display");
5863 img = bmp.ConvertToImage();
5864 img.ConvertAlphaToMask(128);
5865 bmp = wxBitmap(img);
5866 m_topImgList->Add(bmp);
5867 bmp = style->GetIcon("Charts");
5868 img = bmp.ConvertToImage();
5869 img.ConvertAlphaToMask(128);
5870 bmp = wxBitmap(img);
5871 m_topImgList->Add(bmp);
5872 bmp = style->GetIcon("Connections");
5873 img = bmp.ConvertToImage();
5874 img.ConvertAlphaToMask(128);
5875 bmp = wxBitmap(img);
5876 m_topImgList->Add(bmp);
5877 bmp = style->GetIcon("Ship");
5878 img = bmp.ConvertToImage();
5879 img.ConvertAlphaToMask(128);
5880 bmp = wxBitmap(img);
5881 m_topImgList->Add(bmp);
5882 bmp = style->GetIcon("UI");
5883 img = bmp.ConvertToImage();
5884 img.ConvertAlphaToMask(128);
5885 bmp = wxBitmap(img);
5886 m_topImgList->Add(bmp);
5887 bmp = style->GetIcon("Plugins");
5888 img = bmp.ConvertToImage();
5889 img.ConvertAlphaToMask(128);
5890 bmp = wxBitmap(img);
5891 m_topImgList->Add(bmp);
5892#endif
5893 } else {
5894 wxBitmap bmps;
5895 bmps = style->GetIcon("Display");
5896 int base_size = bmps.GetWidth();
5897 double tool_size = base_size;
5898
5899 double premult = 1.0;
5900
5901 // unless overridden by user, we declare the "best" size
5902 // to be roughly 6 mm square.
5903 double target_size = 6.0; // mm
5904
5905 double basic_tool_size_mm = tool_size / g_Platform->GetDisplayDPmm();
5906 premult = target_size / basic_tool_size_mm;
5907
5908 // Adjust the scale factor using the global GUI scale parameter
5909 double postmult = exp(g_GUIScaleFactor * (0.693 / 5.0)); // exp(2)
5910 postmult = wxMin(postmult, 3.0);
5911 postmult = wxMax(postmult, 1.0);
5912
5913 int sizeTab = base_size * postmult * premult;
5914
5915 m_topImgList = new wxImageList(sizeTab, sizeTab, TRUE, 1);
5916
5917 wxBitmap bmp;
5918 wxImage img, simg;
5919 bmp = style->GetIcon("Display");
5920 img = bmp.ConvertToImage();
5921 simg = img.Scale(sizeTab, sizeTab);
5922 bmp = wxBitmap(simg);
5923 m_topImgList->Add(bmp);
5924 bmp = style->GetIcon("Charts");
5925 img = bmp.ConvertToImage();
5926 simg = img.Scale(sizeTab, sizeTab);
5927 bmp = wxBitmap(simg);
5928 m_topImgList->Add(bmp);
5929 bmp = style->GetIcon("Connections");
5930 img = bmp.ConvertToImage();
5931 simg = img.Scale(sizeTab, sizeTab);
5932 bmp = wxBitmap(simg);
5933 m_topImgList->Add(bmp);
5934 bmp = style->GetIcon("Ship");
5935 img = bmp.ConvertToImage();
5936 simg = img.Scale(sizeTab, sizeTab);
5937 bmp = wxBitmap(simg);
5938 m_topImgList->Add(bmp);
5939 bmp = style->GetIcon("UI");
5940 img = bmp.ConvertToImage();
5941 simg = img.Scale(sizeTab, sizeTab);
5942 bmp = wxBitmap(simg);
5943 m_topImgList->Add(bmp);
5944 bmp = style->GetIcon("Plugins");
5945 img = bmp.ConvertToImage();
5946 simg = img.Scale(sizeTab, sizeTab);
5947 bmp = wxBitmap(simg);
5948 m_topImgList->Add(bmp);
5949 }
5950}
5951
5952void options::CreateControls() {
5953 int border_size = 4;
5954 // use for items within one group, with Add(...wxALL)
5955 int group_item_spacing = 2;
5956
5957 int font_size_y, font_descent, font_lead;
5958 GetTextExtent("0", NULL, &font_size_y, &font_descent, &font_lead);
5959 m_fontHeight = font_size_y + font_descent + font_lead;
5960
5961#ifdef __ANDROID__
5962 m_sliderSize =
5963 wxSize(wxMin(m_fontHeight * 8, g_Platform->getDisplaySize().x / 2),
5964 m_fontHeight * 8 / 10);
5965#else
5966 m_sliderSize =
5967 wxSize(wxMin(m_fontHeight * 8, g_Platform->getDisplaySize().x / 2),
5968 m_fontHeight * 2);
5969#endif
5970
5971 m_small_button_size =
5972 wxSize(-1, (int)(1.2 * (font_size_y + font_descent /*+ font_lead*/)));
5973
5974 m_nCharWidthMax = GetSize().x / GetCharWidth();
5975
5976 // Some members (pointers to controls) need to initialized
5977 pEnableZoomToCursor = NULL;
5978 pSmoothPanZoom = NULL;
5979
5980 // Check the display size.
5981 // If "small", adjust some factors to squish out some more white space
5982 int width, height;
5983 width = g_monitor_info[g_current_monitor].width;
5984 height = g_monitor_info[g_current_monitor].height;
5985
5986 if (!g_bresponsive && height <= 800) {
5987 border_size = 2;
5988 group_item_spacing = 1;
5989 }
5990
5991 labelFlags =
5992 wxSizerFlags(0).Align(wxALIGN_RIGHT).Border(wxALL, group_item_spacing);
5993 inputFlags = wxSizerFlags(0)
5994 .Align(wxALIGN_LEFT | wxALIGN_CENTRE_VERTICAL)
5995 .Border(wxALL, group_item_spacing);
5996 verticleInputFlags =
5997 wxSizerFlags(0).Align(wxALIGN_LEFT).Border(wxALL, group_item_spacing);
5998 groupLabelFlags = wxSizerFlags(0)
5999 .Align(wxALIGN_RIGHT | wxALIGN_TOP)
6000 .Border(wxALL, group_item_spacing);
6001 groupLabelFlagsHoriz =
6002 wxSizerFlags(0).Align(wxALIGN_TOP).Border(wxALL, group_item_spacing);
6003 groupInputFlags = wxSizerFlags(0)
6004 .Align(wxALIGN_LEFT | wxALIGN_TOP)
6005 .Border(wxBOTTOM, group_item_spacing * 2)
6006 .Expand();
6007
6008#ifdef __WXGTK__
6009 groupLabelFlags.Border(wxTOP, group_item_spacing + 3);
6010#endif
6011
6012 options* itemDialog1 = this;
6013
6014 wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxVERTICAL);
6015 itemDialog1->SetSizer(itemBoxSizer2);
6016
6017#ifdef __ANDROID__
6018 // Set Dialog Font by custom crafted Qt Stylesheet.
6019 wxFont* qFont = dialogFont;
6020
6021 wxString wqs = getFontQtStylesheet(qFont);
6022 wxCharBuffer sbuf = wqs.ToUTF8();
6023 QString qsb = QString(sbuf.data());
6024
6025 QString qsbq = getQtStyleSheet(); // basic scrollbars, etc
6026
6027 itemDialog1->GetHandle()->setStyleSheet(qsb +
6028 qsbq); // Concatenated style sheets
6029
6030#endif
6031
6032 int flags = 0;
6033
6034#ifdef OCPN_OPTIONS_USE_LISTBOOK
6035 flags = wxLB_TOP;
6036 m_pListbook = new wxListbook(itemDialog1, ID_NOTEBOOK, wxDefaultPosition,
6037 wxSize(-1, -1), flags);
6038 m_pListbook->Connect(wxEVT_COMMAND_LISTBOOK_PAGE_CHANGED,
6039 wxListbookEventHandler(options::OnPageChange), NULL,
6040 this);
6041#else
6042 flags = wxNB_TOP;
6043 m_pListbook = new wxNotebook(itemDialog1, ID_NOTEBOOK, wxDefaultPosition,
6044 wxSize(-1, -1), flags);
6045 m_pListbook->Connect(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED,
6046 wxNotebookEventHandler(options::OnTopNBPageChange), NULL,
6047 this);
6048#endif
6049
6050#ifdef __ANDROID__
6051 // In wxQT, we can dynamically style the little scroll buttons on a small
6052 // display, to make them bigger
6053 m_pListbook->GetHandle()->setStyleSheet(getListBookStyleSheet());
6054
6055#endif
6056
6057 CreateListbookIcons();
6058
6059 m_pListbook->SetImageList(m_topImgList);
6060 itemBoxSizer2->Add(m_pListbook, 1, wxALL | wxEXPAND, border_size);
6061
6062 m_OK_Cancel_Apply_buttons = new wxBoxSizer(wxHORIZONTAL);
6063 itemBoxSizer2->Add(m_OK_Cancel_Apply_buttons, 0, wxALIGN_RIGHT | wxALL,
6064 border_size);
6065
6066 m_OKButton = new wxButton(itemDialog1, xID_OK, _("Ok"));
6067 m_OKButton->SetDefault();
6068 m_OK_Cancel_Apply_buttons->Add(m_OKButton, 0, wxALIGN_CENTER_VERTICAL | wxALL,
6069 border_size);
6070
6071 m_CancelButton = new wxButton(itemDialog1, wxID_CANCEL, _("Cancel"));
6072 m_OK_Cancel_Apply_buttons->Add(m_CancelButton, 0,
6073 wxALIGN_CENTER_VERTICAL | wxALL, border_size);
6074
6075 m_ApplyButton = new wxButton(itemDialog1, ID_APPLY, _("Apply"));
6076 m_OK_Cancel_Apply_buttons->Add(m_ApplyButton, 0,
6077 wxALIGN_CENTER_VERTICAL | wxALL, border_size);
6078
6079 m_pageDisplay = CreatePanel(_("Display"));
6080 CreatePanel_Display(m_pageDisplay, border_size, group_item_spacing);
6081 CreatePanel_Units(m_pageDisplay, border_size, group_item_spacing);
6082 CreatePanel_Advanced(m_pageDisplay, border_size, group_item_spacing);
6083 CreatePanel_Configs(m_pageDisplay, border_size, group_item_spacing);
6084
6085 m_pageCharts = CreatePanel(_("Charts"));
6086 CreatePanel_ChartsLoad(m_pageCharts, border_size, group_item_spacing);
6087 CreatePanel_VectorCharts(m_pageCharts, border_size, group_item_spacing);
6088
6089 // ChartGroups must be created after ChartsLoad and must be at least third
6090 CreatePanel_ChartGroups(m_pageCharts, border_size, group_item_spacing);
6091 CreatePanel_TidesCurrents(m_pageCharts, border_size, group_item_spacing);
6092
6093 wxNotebook* nb =
6094 dynamic_cast<wxNotebook*>(m_pListbook->GetPage(m_pageCharts));
6095 if (nb) {
6096#ifdef OCPN_OPTIONS_USE_LISTBOOK
6097 nb->Connect(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED,
6098 wxListbookEventHandler(options::OnChartsPageChange), NULL,
6099 this);
6100#else
6101 nb->Connect(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED,
6102 wxNotebookEventHandler(options::OnChartsPageChange), NULL,
6103 this);
6104
6105#endif
6106 }
6107
6108 wxString ConnTab = _("Connections");
6109 if (g_Platform->GetDisplayDIPMult(wxTheApp->GetTopWindow()) < 1)
6110 ConnTab = _("Connect");
6111
6112 m_pageConnections = CreatePanel(ConnTab);
6113 CreatePanel_NMEA(m_pageConnections, border_size, group_item_spacing);
6114
6115 // SetDefaultConnectionParams();
6116
6117 m_pageShips = CreatePanel(_("Ships"));
6118 CreatePanel_Ownship(m_pageShips, border_size, group_item_spacing);
6119 CreatePanel_AIS(m_pageShips, border_size, group_item_spacing);
6120 CreatePanel_MMSI(m_pageShips, border_size, group_item_spacing);
6121
6122 CreatePanel_Routes(m_pageShips, border_size, group_item_spacing);
6123
6124 wxString UITab = _("User Interface");
6125 if (g_Platform->GetDisplayDIPMult(wxTheApp->GetTopWindow()) < 1)
6126 UITab = _("User");
6127
6128 m_pageUI = CreatePanel(UITab);
6129 CreatePanel_UI(m_pageUI, border_size, group_item_spacing);
6130 CreatePanel_Sounds(m_pageUI, border_size, group_item_spacing);
6131
6132 m_pagePlugins = CreatePanel(_("Plugins"));
6133 itemPanelPlugins = AddPage(m_pagePlugins, _("Plugins"));
6134
6135 itemBoxSizerPanelPlugins = new wxBoxSizer(wxVERTICAL);
6136 itemPanelPlugins->SetSizer(itemBoxSizerPanelPlugins);
6137
6138 // PlugIns can add panels, too
6139 if (g_pi_manager) g_pi_manager->NotifySetupOptions();
6140
6141 OnColorChange();
6142 SetColorScheme(static_cast<ColorScheme>(0));
6143
6144 // Set the maximum size of the entire settings dialog
6145 // leaving a slightly larger border for larger displays.
6146 int marginx = 10;
6147 int marginy = 40;
6148 if (width > 800) {
6149 marginx = 100;
6150 marginy = 100;
6151 }
6152
6153 SetSizeHints(-1, -1, width - marginx, height - marginy);
6154
6155#ifndef __WXGTK__
6156 // The s57 chart panel is the one which controls the minimum width required
6157 // to avoid horizontal scroll bars
6158 // vectorPanel->SetSizeHints(ps57Ctl);
6159#endif
6160}
6161
6162void options::SetInitialPage(int page_sel, int sub_page) {
6163 if (page_sel < (int)m_pListbook->GetPageCount())
6164 m_pListbook->SetSelection(page_sel);
6165 else
6166 m_pListbook->SetSelection(0);
6167
6168 if (sub_page >= 0) {
6169 for (size_t i = 0; i < m_pListbook->GetPageCount(); i++) {
6170 wxNotebookPage* pg = m_pListbook->GetPage(i);
6171 wxNotebook* nb = dynamic_cast<wxNotebook*>(pg);
6172 if (nb) {
6173 if (i == (size_t)page_sel) {
6174 if (sub_page < (int)nb->GetPageCount())
6175 nb->SetSelection(sub_page);
6176 else
6177 nb->SetSelection(0);
6178 } else
6179 nb->ChangeSelection(0);
6180 }
6181 }
6182 }
6183}
6184
6185void options::SetColorScheme(ColorScheme cs) {
6186 DimeControl(this);
6187
6188#ifdef OCPN_OPTIONS_USE_LISTBOOK
6189 wxListView* lv = m_pListbook->GetListView();
6190 lv->SetBackgroundColour(GetBackgroundColour());
6191
6192 if (m_cs != cs) {
6193 delete m_topImgList;
6194 CreateListbookIcons();
6195 m_pListbook->SetImageList(m_topImgList);
6196
6197 m_cs = cs;
6198 }
6199
6200#endif
6201
6202 // Some panels need specific color change method
6203 comm_dialog->SetColorScheme(cs);
6204}
6205
6206void options::OnAISRolloverClick(wxCommandEvent& event) {
6207 m_pCheck_Rollover_Class->Enable(event.IsChecked());
6208 m_pCheck_Rollover_COG->Enable(event.IsChecked());
6209 m_pCheck_Rollover_CPA->Enable(event.IsChecked());
6210 pStatic_CallSign->Enable(event.IsChecked());
6211}
6212
6213void options::OnCanvasConfigSelectClick(int ID, bool selected) {
6214 switch (ID) {
6215 case ID_SCREENCONFIG1:
6216 if (m_sconfigSelect_twovertical)
6217 m_sconfigSelect_twovertical->SetSelected(false);
6218 m_screenConfig = 0;
6219 break;
6220
6221 case ID_SCREENCONFIG2:
6222 if (m_sconfigSelect_single) m_sconfigSelect_single->SetSelected(false);
6223 m_screenConfig = 1;
6224 break;
6225 }
6226}
6227
6228void options::SetInitialSettings() {
6229 wxString s;
6230
6231 m_returnChanges = 0; // reset the flags
6232 m_bfontChanged = false;
6233 m_font_element_array.Clear();
6234
6235 b_oldhaveWMM = b_haveWMM;
6236 auto loader = PluginLoader::GetInstance();
6237 b_haveWMM = loader && loader->IsPlugInAvailable("WMM");
6238
6239 // Canvas configuration
6240 switch (g_canvasConfig) {
6241 case 0:
6242 default:
6243 if (m_sconfigSelect_single) m_sconfigSelect_single->SetSelected(true);
6244 if (m_sconfigSelect_twovertical)
6245 m_sconfigSelect_twovertical->SetSelected(false);
6246 break;
6247 case 1:
6248 if (m_sconfigSelect_single) m_sconfigSelect_single->SetSelected(false);
6249 if (m_sconfigSelect_twovertical)
6250 m_sconfigSelect_twovertical->SetSelected(true);
6251 break;
6252 }
6253 m_screenConfig = g_canvasConfig;
6254
6255 // Initial Charts Load
6256
6257 ActiveChartArray.Clear();
6258 for (size_t i = 0; i < m_CurrentDirList.GetCount(); i++) {
6259 ActiveChartArray.Add(m_CurrentDirList[i]);
6260 }
6261
6262 // ChartGroups
6263 if (m_pWorkDirList) {
6264 UpdateWorkArrayFromDisplayPanel();
6265 groupsPanel->SetDBDirs(*m_pWorkDirList);
6266
6267 // Make a deep copy of the current global Group Array
6268 groupsPanel->EmptyChartGroupArray(m_pGroupArray);
6269 delete m_pGroupArray;
6270 m_pGroupArray = groupsPanel->CloneChartGroupArray(g_pGroupArray);
6271 groupsPanel->SetGroupArray(m_pGroupArray);
6272 groupsPanel->SetInitialSettings();
6273 }
6274
6275 if (m_pConfig) {
6276 pShowStatusBar->SetValue(g_bShowStatusBar);
6277#ifndef __WXOSX__
6278 pShowMenuBar->SetValue(g_bShowMenuBar);
6279#endif
6280 pShowCompassWin->SetValue(g_bShowCompassWin);
6281 }
6282
6283 s.Printf("%d", g_COGAvgSec);
6284 pCOGUPUpdateSecs->SetValue(s);
6285
6286 if (pCDOOutlines) pCDOOutlines->SetValue(g_bShowOutlines);
6287 if (pCDOQuilting) pCDOQuilting->SetValue(g_bQuiltEnable);
6288 // if(pFullScreenQuilt) pFullScreenQuilt->SetValue(!g_bFullScreenQuilt);
6289 if (pSDepthUnits) pSDepthUnits->SetValue(g_bShowDepthUnits);
6290 if (pSkewComp) pSkewComp->SetValue(g_bskew_comp);
6291 pMobile->SetValue(g_btouch);
6292 pResponsive->SetValue(g_bresponsive);
6293 pRollover->SetValue(g_bRollover);
6294 m_pCheck_Rollover_Class->Enable(g_bRollover);
6295 m_pCheck_Rollover_COG->Enable(g_bRollover);
6296 m_pCheck_Rollover_CPA->Enable(g_bRollover);
6297 pStatic_CallSign->Enable(g_bRollover);
6298
6299 pZoomButtons->SetValue(g_bShowMuiZoomButtons);
6300
6301 // pOverzoomEmphasis->SetValue(!g_fog_overzoom);
6302 // pOZScaleVector->SetValue(!g_oz_vector_scale);
6303 pInlandEcdis->SetValue(g_bInlandEcdis);
6304 pHiconColors->SetValue(g_hicon_colors);
6305
6306#ifdef ocpnUSE_GL
6307 pOpenGL->SetValue(g_bopengl);
6308 if (auto* w = wxWindow::FindWindowById(ID_OPENGLOPTIONS))
6309 w->Enable(pOpenGL->IsChecked());
6310#endif
6311 if (pSmoothPanZoom) pSmoothPanZoom->SetValue(g_bsmoothpanzoom);
6312 pCBTrueShow->SetValue(g_bShowTrue);
6313 pCBMagShow->SetValue(g_bShowMag);
6314
6315 int oldLength = itemStaticTextUserVar->GetLabel().Length();
6316
6317 // disable input for variation if WMM is available
6318 if (b_haveWMM) {
6319 itemStaticTextUserVar->SetLabel(
6320 _("WMM Plugin calculated magnetic variation"));
6321 wxString s;
6322 s.Printf("%4.1f", gVar);
6323 pMagVar->SetValue(s);
6324 } else {
6325 itemStaticTextUserVar->SetLabel(_("User set magnetic variation"));
6326 wxString s;
6327 s.Printf("%4.1f", g_UserVar);
6328 pMagVar->SetValue(s);
6329 }
6330
6331 int newLength = itemStaticTextUserVar->GetLabel().Length();
6332
6333 // size hack to adjust change in static text size
6334 if ((newLength != oldLength) || (b_oldhaveWMM != b_haveWMM)) {
6335 wxSize sz = GetSize();
6336 SetSize(sz.x + 1, sz.y);
6337 SetSize(sz);
6338 }
6339
6340 itemStaticTextUserVar2->Enable(!b_haveWMM);
6341 pMagVar->Enable(!b_haveWMM);
6342
6343 if (pSDisplayGrid) pSDisplayGrid->SetValue(g_bDisplayGrid);
6344
6345 // LIVE ETA OPTION
6346
6347 // Checkbox
6348 if (pSLiveETA) pSLiveETA->SetValue(g_bShowLiveETA);
6349
6350 // Defaut boat speed text input field
6351 // Speed always in knots, and converted to user speed unit
6352 wxString stringDefaultBoatSpeed;
6353 if (!g_defaultBoatSpeed || !g_defaultBoatSpeedUserUnit) {
6354 g_defaultBoatSpeed = 6.0;
6355 g_defaultBoatSpeedUserUnit = toUsrSpeed(g_defaultBoatSpeed, -1);
6356 }
6357 stringDefaultBoatSpeed.Printf("%d", (int)g_defaultBoatSpeedUserUnit);
6358 if (pSDefaultBoatSpeed) pSDefaultBoatSpeed->SetValue(stringDefaultBoatSpeed);
6359
6360 // END LIVE ETA OPTION
6361
6362 if (pCBCourseUp) pCBCourseUp->SetValue(g_bCourseUp);
6363 if (pCBNorthUp) pCBNorthUp->SetValue(!g_bCourseUp);
6364 if (pCBLookAhead) pCBLookAhead->SetValue(g_bLookAhead);
6365
6366 if (fabs(wxRound(g_ownship_predictor_minutes) - g_ownship_predictor_minutes) >
6367 1e-4)
6368 s.Printf("%6.2f", g_ownship_predictor_minutes);
6369 else
6370 s.Printf("%4.0f", g_ownship_predictor_minutes);
6371 m_pText_OSCOG_Predictor->SetValue(s);
6372
6373 if (fabs(wxRound(g_ownship_HDTpredictor_miles) -
6374 g_ownship_HDTpredictor_miles) > 1e-4)
6375 s.Printf("%6.2f", g_ownship_HDTpredictor_miles);
6376 else
6377 s.Printf("%4.0f", g_ownship_HDTpredictor_miles);
6378 m_pText_OSHDT_Predictor->SetValue(s);
6379
6380 if (g_OwnShipmmsi > 0) {
6381 wxString s = wxString::Format("%i", g_OwnShipmmsi);
6382 m_pTxt_OwnMMSI->SetValue(s);
6383 } else
6384 m_pTxt_OwnMMSI->SetValue("");
6385
6386 m_pShipIconType->SetSelection(g_OwnShipIconType);
6387 wxCommandEvent eDummy;
6388 OnShipTypeSelect(eDummy);
6389 m_pOSLength->SetValue(wxString::Format("%.1f", g_n_ownship_length_meters));
6390 m_pOSWidth->SetValue(wxString::Format("%.1f", g_n_ownship_beam_meters));
6391 m_pOSGPSOffsetX->SetValue(wxString::Format("%.1f", g_n_gps_antenna_offset_x));
6392 m_pOSGPSOffsetY->SetValue(wxString::Format("%.1f", g_n_gps_antenna_offset_y));
6393 m_pOSMinSize->SetValue(wxString::Format("%d", g_n_ownship_min_mm));
6394 m_pText_ACRadius->SetValue(
6395 wxString::Format("%.3f", g_n_arrival_circle_radius));
6396
6397 wxString buf;
6398 if (g_iNavAidRadarRingsNumberVisible > 10)
6399 g_iNavAidRadarRingsNumberVisible = 10;
6400 pNavAidRadarRingsNumberVisible->SetSelection(
6401 g_iNavAidRadarRingsNumberVisible);
6402 buf.Printf("%.3f", g_fNavAidRadarRingsStep);
6403 pNavAidRadarRingsStep->SetValue(buf);
6404 m_itemRadarRingsUnits->SetSelection(g_pNavAidRadarRingsStepUnits);
6405 m_colourOwnshipRangeRingColour->SetColour(g_colourOwnshipRangeRingsColour);
6406
6407 pScaMinChckB->SetValue(g_bUseWptScaMin);
6408 m_pText_ScaMin->SetValue(wxString::Format("%i", g_iWpt_ScaMin));
6409 m_pText_ScaMax->SetValue(wxString::Format("%i", g_iWpt_ScaMax));
6410 pScaMinOverruleChckB->SetValue(g_bOverruleScaMin);
6411
6412 OnRadarringSelect(eDummy);
6413
6414 if (g_iWaypointRangeRingsNumber > 10) g_iWaypointRangeRingsNumber = 10;
6415 pWaypointRangeRingsNumber->SetSelection(g_iWaypointRangeRingsNumber);
6416 buf.Printf("%.3f", g_fWaypointRangeRingsStep);
6417 pWaypointRangeRingsStep->SetValue(buf);
6418 m_itemWaypointRangeRingsUnits->SetSelection(g_iWaypointRangeRingsStepUnits);
6419 m_colourWaypointRangeRingsColour->SetColour(g_colourWaypointRangeRingsColour);
6420 OnWaypointRangeRingSelect(eDummy);
6421 pShowshipToActive->SetValue(g_bShowShipToActive);
6422 m_shipToActiveStyle->SetSelection(g_shipToActiveStyle);
6423 m_shipToActiveColor->SetSelection(g_shipToActiveColor);
6424
6425 pWayPointPreventDragging->SetValue(g_bWayPointPreventDragging);
6426 pConfirmObjectDeletion->SetValue(g_bConfirmObjectDelete);
6427
6428 if (pEnableZoomToCursor) pEnableZoomToCursor->SetValue(g_bEnableZoomToCursor);
6429 if (pEnableTenHertz) pEnableTenHertz->SetValue(g_btenhertz);
6430
6431 if (pPreserveScale) pPreserveScale->SetValue(g_bPreserveScaleOnX);
6432 pPlayShipsBells->SetValue(g_bPlayShipsBells);
6433
6434 if (pCmdSoundString) pCmdSoundString->SetValue(g_CmdSoundString);
6435
6436 if (pSoundDeviceIndex) pSoundDeviceIndex->SetSelection(g_iSoundDeviceIndex);
6437 // pFullScreenToolbar->SetValue( g_bFullscreenToolbar );
6438 // pTransparentToolbar->SetValue(g_bTransparentToolbar);
6439 pSDMMFormat->Select(g_iSDMMFormat);
6440 // Map DISTANCE_* enum to dropdown index using the mapping table
6441 {
6442 int distance_ui_index = GetDistanceFormatIndex(g_iDistanceFormat);
6443 pDistanceFormat->SetSelection(distance_ui_index);
6444 }
6445 pSpeedFormat->Select(g_iSpeedFormat);
6446 pWindSpeedFormat->Select(g_iWindSpeedFormat);
6447 pTempFormat->Select(g_iTempFormat);
6448 if (pHeightUnitSelect) pHeightUnitSelect->SetSelection(g_iHeightFormat);
6449
6450 pAdvanceRouteWaypointOnArrivalOnly->SetValue(
6451 g_bAdvanceRouteWaypointOnArrivalOnly);
6452
6453 if (g_datetime_format == "Local Time") {
6454 pTimezoneLocalTime->SetValue(true);
6455 } else if (g_datetime_format == "UTC") {
6456 pTimezoneUTC->SetValue(true);
6457 } else {
6458 // Default to UTC if no saved timezone or if it's not in the list.
6459 pTimezoneUTC->SetValue(true);
6460 }
6461
6462 pTrackDaily->SetValue(g_bTrackDaily);
6463 pTrackRotateLMT->SetValue(g_track_rotate_time_type == TIME_TYPE_LMT);
6464 pTrackRotateUTC->SetValue(g_track_rotate_time_type == TIME_TYPE_UTC);
6465 pTrackRotateComputerTime->SetValue(g_track_rotate_time_type ==
6466 TIME_TYPE_COMPUTER);
6467 pTrackHighlite->SetValue(g_bHighliteTracks);
6468 m_colourTrackLineColour->SetColour(g_colourTrackLineColour);
6469 pTrackPrecision->SetSelection(g_nTrackPrecision);
6470
6471 m_soundPanelAnchor->GetCheckBox()->SetValue(g_bAnchor_Alert_Audio);
6472
6473 // AIS Parameters
6474 // CPA Box
6475 m_pCheck_CPA_Max->SetValue(g_bCPAMax);
6476
6477 s.Printf("%4.1f", g_CPAMax_NM);
6478 m_pText_CPA_Max->SetValue(s);
6479
6480 m_pCheck_CPA_Warn->SetValue(g_bCPAWarn);
6481
6482 s.Printf("%4.1f", g_CPAWarn_NM);
6483 m_pText_CPA_Warn->SetValue(s);
6484
6485 if (m_pCheck_CPA_Warn->GetValue()) {
6486 m_pCheck_CPA_WarnT->Enable();
6487 m_pCheck_CPA_WarnT->SetValue(g_bTCPA_Max);
6488 } else
6489 m_pCheck_CPA_WarnT->Disable();
6490
6491 s.Printf("%4.0f", g_TCPA_Max);
6492 m_pText_CPA_WarnT->SetValue(s);
6493
6494 // Lost Targets
6495 m_pCheck_Mark_Lost->SetValue(g_bMarkLost);
6496
6497 s.Printf("%4.0f", g_MarkLost_Mins);
6498 m_pText_Mark_Lost->SetValue(s);
6499
6500 m_pCheck_Remove_Lost->SetValue(g_bRemoveLost);
6501
6502 s.Printf("%4.0f", g_RemoveLost_Mins);
6503 m_pText_Remove_Lost->SetValue(s);
6504
6505 // Display
6506 m_pCheck_Show_COG->SetValue(g_bShowCOG);
6507
6508 s.Printf("%4.0f", g_ShowCOG_Mins);
6509 m_pText_COG_Predictor->SetValue(s);
6510
6511 m_pCheck_Sync_OCOG_ACOG->SetValue(g_bSyncCogPredictors);
6512 if (g_bSyncCogPredictors) m_pText_COG_Predictor->Disable();
6513
6514 m_pCheck_Show_Tracks->SetValue(g_bAISShowTracks);
6515
6516 s.Printf("%4.0f", g_AISShowTracks_Mins);
6517 m_pText_Track_Length->SetValue(s);
6518
6519 m_pCheck_Hide_Moored->SetValue(g_bHideMoored);
6520
6521 s.Printf("%4.1f", g_ShowMoored_Kts);
6522 m_pText_Moored_Speed->SetValue(s);
6523
6524 m_pCheck_Draw_Realtime_Prediction->SetValue(g_bDrawAISRealtime);
6525
6526 s.Printf("%4.1f", g_AIS_RealtPred_Kts);
6527 m_pText_RealtPred_Speed->SetValue(s);
6528
6529 m_pCheck_Scale_Priority->SetValue(g_bAllowShowScaled);
6530
6531 s.Printf("%i", g_ShowScaled_Num);
6532 m_pText_Scale_Priority->SetValue(s);
6533
6534 m_pCheck_Show_Area_Notices->SetValue(g_bShowAreaNotices);
6535
6536 m_pCheck_Draw_Target_Size->SetValue(g_bDrawAISSize);
6537 m_pCheck_Draw_Realtime_Prediction->SetValue(g_bDrawAISRealtime);
6538
6539 m_pCheck_Show_Target_Name->SetValue(g_bShowAISName);
6540
6541 s.Printf("%d", g_Show_Target_Name_Scale);
6542 m_pText_Show_Target_Name_Scale->SetValue(s);
6543
6544 m_pCheck_use_Wpl->SetValue(g_bWplUsePosition);
6545 m_pWplAction->SetSelection(g_WplAction);
6546
6547 // Alerts
6548 m_pCheck_AlertDialog->SetValue(g_bAIS_CPA_Alert);
6549 if (g_bAIS_CPA_Alert) {
6550 m_pCheck_AlertAudio->Enable();
6551 m_pCheck_AlertAudio->SetValue(g_bAIS_CPA_Alert_Audio);
6552 } else {
6553 m_pCheck_AlertAudio->Disable();
6554 m_pCheck_AlertAudio->SetValue(false);
6555 }
6556
6557 m_pCheck_Alert_Moored->SetValue(g_bAIS_CPA_Alert_Suppress_Moored);
6558
6559 m_pCheck_Ack_Timout->SetValue(g_bAIS_ACK_Timeout);
6560 s.Printf("%4.0f", g_AckTimeout_Mins);
6561 m_pText_ACK_Timeout->SetValue(s);
6562
6563 // Sounds
6564 m_soundPanelAIS->GetCheckBox()->SetValue(g_bAIS_GCPA_Alert_Audio);
6565 m_soundPanelSART->GetCheckBox()->SetValue(g_bAIS_SART_Alert_Audio);
6566 m_soundPanelDSC->GetCheckBox()->SetValue(g_bAIS_DSC_Alert_Audio);
6567
6568 // Rollover
6569 m_pCheck_Rollover_Class->SetValue(g_bAISRolloverShowClass);
6570 m_pCheck_Rollover_COG->SetValue(g_bAISRolloverShowCOG);
6571 m_pCheck_Rollover_CPA->SetValue(g_bAISRolloverShowCPA);
6572
6573 m_pSlider_Zoom_Raster->SetValue(g_chart_zoom_modifier_raster);
6574 m_pSlider_Zoom_Vector->SetValue(g_chart_zoom_modifier_vector);
6575
6576 m_pSlider_GUI_Factor->SetValue(g_GUIScaleFactor);
6577 m_pSlider_Chart_Factor->SetValue(g_ChartScaleFactor);
6578 m_pSlider_Ship_Factor->SetValue(g_ShipScaleFactor);
6579 m_pSlider_Text_Factor->SetValue(g_ENCSoundingScaleFactor);
6580 m_pSlider_ENCText_Factor->SetValue(g_ENCTextScaleFactor);
6581 m_pMouse_Zoom_Slider->SetValue(g_mouse_zoom_sensitivity_ui);
6582#ifndef __ANDROID__
6583 wxString screenmm;
6584 if (!g_config_display_size_manual) {
6585 pRBSizeAuto->SetValue(TRUE);
6586 for (const auto& mm : g_monitor_info) {
6587 screenmm.Append(wxString::Format("%zu,", mm.width_mm));
6588 }
6589 screenmm.RemoveLast(); // Strip last comma
6590 pScreenMM->Disable();
6591 } else {
6592 for (const auto& mm : g_config_display_size_mm) {
6593 screenmm.Append(wxString::Format("%zu,", mm));
6594 }
6595 screenmm.RemoveLast(); // Strip last comma
6596 pRBSizeManual->SetValue(TRUE);
6597 }
6598
6599 pScreenMM->SetValue(screenmm);
6600#endif
6601
6602 pDepthUnitSelect->SetSelection(g_nDepthUnitDisplay);
6603 UpdateOptionsUnits(); // sets depth values using the user's unit preference
6604
6605 SetInitialVectorSettings();
6606
6607 pToolbarAutoHideCB->SetValue(g_bAutoHideToolbar);
6608
6609 s.Printf("%d", g_nAutoHideToolbar);
6610 pToolbarHideSecs->SetValue(s);
6611
6612 // Serial ports
6613
6614 delete m_pSerialArray;
6615 m_pSerialArray = NULL;
6616 m_pSerialArray = EnumerateSerialPorts();
6617 m_bForceNewToolbaronCancel = false;
6618}
6619
6620void options::resetMarStdList(bool bsetConfig, bool bsetStd) {
6621 if (ps57CtlListBox) {
6622 // S52 Primary Filters
6623 ps57CtlListBox->Clear();
6624 marinersStdXref.clear();
6625
6626 ps57CtlListBox->Freeze();
6627
6628 for (unsigned int iPtr = 0; iPtr < ps52plib->pOBJLArray->GetCount();
6629 iPtr++) {
6630 OBJLElement* pOLE = (OBJLElement*)(ps52plib->pOBJLArray->Item(iPtr));
6631
6632 wxString item;
6633 if (iPtr < ps52plib->OBJLDescriptions.size()) {
6634 item = ps52plib->OBJLDescriptions[iPtr];
6635 } else {
6636 item = wxString(pOLE->OBJLName, wxConvUTF8);
6637 }
6638
6639 // Find the most conservative Category, among Point, Area, and Line LUPs
6640 DisCat cat = OTHER;
6641
6642 DisCat catp = ps52plib->findLUPDisCat(pOLE->OBJLName, SIMPLIFIED);
6643 DisCat cata = ps52plib->findLUPDisCat(pOLE->OBJLName, PLAIN_BOUNDARIES);
6644 DisCat catl = ps52plib->findLUPDisCat(pOLE->OBJLName, LINES);
6645
6646 if ((catp == DISPLAYBASE) || (cata == DISPLAYBASE) ||
6647 (catl == DISPLAYBASE))
6648 cat = DISPLAYBASE;
6649 else if ((catp == STANDARD) || (cata == STANDARD) || (catl == STANDARD))
6650 cat = STANDARD;
6651
6652 bool benable = true;
6653 if (cat > 0) benable = cat != DISPLAYBASE;
6654
6655 // The ListBox control will insert entries in sorted order, which means
6656 // we need to
6657 // keep track of already inserted items that gets pushed down the line.
6658 int newpos = ps57CtlListBox->Append(item, benable, false);
6659 marinersStdXref.push_back(newpos);
6660 for (size_t i = 0; i < iPtr; i++) {
6661 if (marinersStdXref[i] >= newpos) marinersStdXref[i]++;
6662 }
6663
6664 bool bviz = 0;
6665 if (bsetConfig) bviz = !(pOLE->nViz == 0);
6666
6667 if (cat == DISPLAYBASE) bviz = true;
6668
6669 if (bsetStd) {
6670 if (cat == STANDARD) {
6671 bviz = true;
6672 }
6673 }
6674
6675 ps57CtlListBox->Check(newpos, bviz);
6676 }
6677 ps57CtlListBox->Thaw();
6678
6679 // Deferred layout instead of after every appended checkbox
6680 ps57CtlListBox->RunLayout();
6681
6682 // Force the wxScrolledWindow to recalculate its scroll bars
6683 wxSize s = ps57CtlListBox->GetSize();
6684 ps57CtlListBox->SetSize(s.x, s.y - 1);
6685 }
6686}
6687
6688void options::SetInitialVectorSettings() {
6689 m_pSlider_CM93_Zoom->SetValue(g_cm93_zoom_factor);
6690
6691 // Diplay Category
6692 if (ps52plib) {
6693 m_bVectorInit = true;
6694 resetMarStdList(true, false);
6695
6696#ifdef __ANDROID__
6697 ps57CtlListBox->GetHandle()->setStyleSheet(getAdjustedDialogStyleSheet());
6698#endif
6699
6700 int nset = 2; // default OTHER
6701 switch (ps52plib->GetDisplayCategory()) {
6702 case (DISPLAYBASE):
6703 nset = 0;
6704 break;
6705 case (STANDARD):
6706 nset = 1;
6707 break;
6708 case (OTHER):
6709 nset = 2;
6710 break;
6711 case (MARINERS_STANDARD):
6712 nset = 3;
6713 break;
6714 default:
6715 nset = 3;
6716 break;
6717 }
6718
6719 if (pDispCat) pDispCat->SetSelection(nset);
6720
6721 // Enable the UserStandard object list if either canvas is in
6722 // MARINERS_STANDARD display category
6723 bool benableMarStd = false;
6724 // .. for each canvas...
6725 for (unsigned int i = 0; i < g_canvasArray.GetCount(); i++) {
6726 ChartCanvas* cc = g_canvasArray.Item(i);
6727 if (cc) {
6728 if (cc->GetENCDisplayCategory() == MARINERS_STANDARD) {
6729 benableMarStd = true;
6730 break;
6731 }
6732 }
6733 }
6734
6735 // if(g_useMUI)
6736 // benableMarStd = true;
6737
6738 if (ps57CtlListBox) ps57CtlListBox->Enable(benableMarStd);
6739 itemButtonClearList->Enable(benableMarStd);
6740 itemButtonSelectList->Enable(benableMarStd);
6741 itemButtonSetStd->Enable(benableMarStd);
6742
6743 // Other Display Filters
6744 if (pCheck_SOUNDG) pCheck_SOUNDG->SetValue(ps52plib->m_bShowSoundg);
6745 if (pCheck_ATONTEXT) pCheck_ATONTEXT->SetValue(ps52plib->m_bShowAtonText);
6746 if (pCheck_LDISTEXT) pCheck_LDISTEXT->SetValue(ps52plib->m_bShowLdisText);
6747 if (pCheck_XLSECTTEXT)
6748 pCheck_XLSECTTEXT->SetValue(ps52plib->m_bExtendLightSectors);
6749
6750 pCheck_META->SetValue(ps52plib->m_bShowMeta);
6751 pCheck_SHOWIMPTEXT->SetValue(ps52plib->m_bShowS57ImportantTextOnly);
6752 pCheck_SCAMIN->SetValue(ps52plib->m_bUseSCAMIN);
6753 pCheck_SuperSCAMIN->SetValue(ps52plib->m_bUseSUPER_SCAMIN);
6754
6755 pCheck_DECLTEXT->SetValue(ps52plib->m_bDeClutterText);
6756 pCheck_NATIONALTEXT->SetValue(ps52plib->m_bShowNationalTexts);
6757
6758 // Chart Display Style
6759 if (ps52plib->m_nSymbolStyle == PAPER_CHART)
6760 pPointStyle->SetSelection(0);
6761 else
6762 pPointStyle->SetSelection(1);
6763
6764 if (ps52plib->m_nBoundaryStyle == PLAIN_BOUNDARIES)
6765 pBoundStyle->SetSelection(0);
6766 else
6767 pBoundStyle->SetSelection(1);
6768
6769 if (S52_getMarinerParam(S52_MAR_TWO_SHADES) == 1.0)
6770 p24Color->SetSelection(0);
6771 else
6772 p24Color->SetSelection(1);
6773
6774 UpdateOptionsUnits(); // sets depth values using the user's unit preference
6775 }
6776}
6777
6778void options::UpdateOptionsUnits() {
6779 int depthUnit = pDepthUnitSelect->GetSelection();
6780
6781 depthUnit = wxMax(depthUnit, 0);
6782 depthUnit = wxMin(depthUnit, 2);
6783
6784 // depth unit conversion factor
6785 float conv = 1;
6786 if (depthUnit == 0) // feet
6787 conv = 0.3048f; // international definiton of 1 foot is 0.3048 metres
6788 else if (depthUnit == 2) // fathoms
6789 conv = 0.3048f * 6; // 1 fathom is 6 feet
6790
6791 // set depth input values
6792
6793 // set depth unit labels
6794 wxString depthUnitStrings[] = {_("feet"), _("meters"), _("fathoms")};
6795 wxString depthUnitString = depthUnitStrings[depthUnit];
6796 m_depthUnitsShal->SetLabel(depthUnitString);
6797 m_depthUnitsSafe->SetLabel(depthUnitString);
6798 m_depthUnitsDeep->SetLabel(depthUnitString);
6799
6800 wxString s;
6801 s.Printf("%6.2f", S52_getMarinerParam(S52_MAR_SHALLOW_CONTOUR) / conv);
6802 s.Trim(FALSE);
6803 m_ShallowCtl->SetValue(s);
6804
6805 s.Printf("%6.2f", S52_getMarinerParam(S52_MAR_SAFETY_CONTOUR) / conv);
6806 s.Trim(FALSE);
6807 m_SafetyCtl->SetValue(s);
6808
6809 s.Printf("%6.2f", S52_getMarinerParam(S52_MAR_DEEP_CONTOUR) / conv);
6810 s.Trim(FALSE);
6811 m_DeepCtl->SetValue(s);
6812 /*
6813 int oldLength = itemStaticTextUserVar->GetLabel().Length();
6814
6815 //disable input for variation if WMM is available
6816 if(b_haveWMM){
6817 itemStaticTextUserVar->SetLabel(_("WMM Plugin calculated magnetic
6818 variation")); wxString s; s.Printf("%4.1f", gVar); pMagVar->SetValue(s);
6819 }
6820 else{
6821 itemStaticTextUserVar->SetLabel(_("User set magnetic variation"));
6822 wxString s;
6823 s.Printf("%4.1f", g_UserVar);
6824 pMagVar->SetValue(s);
6825 }
6826
6827 int newLength = itemStaticTextUserVar->GetLabel().Length();
6828
6829 // size hack to adjust change in static text size
6830 if( (newLength != oldLength) || (b_oldhaveWMM != b_haveWMM) ){
6831 wxSize sz = GetSize();
6832 SetSize(sz.x+1, sz.y);
6833 SetSize(sz);
6834 }
6835
6836 itemStaticTextUserVar2->Enable(!b_haveWMM);
6837 pMagVar->Enable(!b_haveWMM);
6838 */
6839}
6840
6841void options::OnSizeAutoButton(wxCommandEvent& event) {
6842 wxString screenmm;
6843 for (const auto& mm : g_monitor_info) {
6844 screenmm.Append(wxString::Format("%zu,", mm.width_mm));
6845 }
6846 screenmm.RemoveLast(); // Strip last comma
6847 pScreenMM->SetValue(screenmm);
6848 pScreenMM->Disable();
6849 g_config_display_size_manual = FALSE;
6850}
6851
6852void options::OnSizeManualButton(wxCommandEvent& event) {
6853 wxString screenmm;
6854 if (g_config_display_size_mm.size() > 0 && g_config_display_size_mm[0] > 0) {
6855 for (const auto& mm : g_config_display_size_mm) {
6856 screenmm.Append(wxString::Format("%zu,", mm));
6857 }
6858 } else {
6859 for (const auto& mm : g_monitor_info) {
6860 screenmm.Append(wxString::Format("%zu,", mm.width_mm));
6861 }
6862 }
6863 screenmm.RemoveLast(); // Strip last comma
6864 pScreenMM->SetValue(screenmm);
6865 pScreenMM->Enable();
6866 g_config_display_size_manual = TRUE;
6867}
6868
6869void options::OnUnitsChoice(wxCommandEvent& event) { UpdateOptionsUnits(); }
6870
6871void options::OnCPAWarnClick(wxCommandEvent& event) {
6872 if (m_pCheck_CPA_Warn->GetValue()) {
6873 m_pCheck_CPA_WarnT->Enable();
6874 } else {
6875 m_pCheck_CPA_WarnT->SetValue(FALSE);
6876 m_pCheck_CPA_WarnT->Disable();
6877 }
6878}
6879
6880void options::OnSyncCogPredClick(wxCommandEvent& event) {
6881 if (m_pCheck_Sync_OCOG_ACOG->GetValue()) {
6882 m_pText_COG_Predictor->SetValue(m_pText_OSCOG_Predictor->GetValue());
6883 m_pText_COG_Predictor->Disable();
6884 } else {
6885 wxString s;
6886 s.Printf("%4.0f", g_ShowCOG_Mins);
6887 m_pText_COG_Predictor->SetValue(s);
6888 m_pText_COG_Predictor->Enable();
6889 }
6890}
6891
6892void options::OnShipTypeSelect(wxCommandEvent& event) {
6893 realSizes->ShowItems(m_pShipIconType->GetSelection() != 0);
6894 dispOptions->Layout();
6895 ownShip->Layout();
6896 itemPanelShip->Layout();
6897 itemPanelShip->Refresh();
6898 event.Skip();
6899}
6900
6901void options::OnRadarringSelect(wxCommandEvent& event) {
6902 radarGrid->ShowItems(pNavAidRadarRingsNumberVisible->GetSelection() != 0);
6903 dispOptions->Layout();
6904 ownShip->Layout();
6905 itemPanelShip->Layout();
6906 itemPanelShip->Refresh();
6907 event.Skip();
6908}
6909
6910void options::OnWaypointRangeRingSelect(wxCommandEvent& event) {
6911 waypointradarGrid->ShowItems(pWaypointRangeRingsNumber->GetSelection() != 0);
6912 dispOptions->Layout();
6913 Routes->Layout();
6914 itemPanelRoutes->Layout();
6915 itemPanelRoutes->Refresh();
6916 event.Skip();
6917}
6918
6919void options::OnGLClicked(wxCommandEvent& event) {
6920 // if (!g_bTransparentToolbarInOpenGLOK)
6921 // pTransparentToolbar->Enable(!pOpenGL->GetValue());
6922 if (auto* w = wxWindow::FindWindowById(ID_OPENGLOPTIONS))
6923 w->Enable(pOpenGL->IsChecked());
6924}
6925
6926void options::OnOpenGLOptions(wxCommandEvent& event) {
6927#ifdef ocpnUSE_GL
6928 OpenGLOptionsDlg dlg(this);
6929
6930 if (dlg.ShowModal() == wxID_OK) {
6931 if (top_frame::Get()->GetWxGlCanvas()) {
6932 g_GLOptions.m_bUseAcceleratedPanning =
6933 g_bGLexpert ? dlg.GetAcceleratedPanning()
6934 : top_frame::Get()
6935 ->GetAbstractPrimaryCanvas()
6936 ->CanAccelerateGlPanning();
6937 }
6938
6939 g_bSoftwareGL = dlg.GetSoftwareGL();
6940
6941 g_GLOptions.m_GLPolygonSmoothing = dlg.GetPolygonSmoothing();
6942 g_GLOptions.m_GLLineSmoothing = dlg.GetLineSmoothing();
6943
6944 if (g_bGLexpert) {
6945 // user defined
6946 g_GLOptions.m_bTextureCompressionCaching =
6947 dlg.GetTextureCompressionCaching();
6948 g_GLOptions.m_iTextureMemorySize = dlg.GetTextureMemorySize();
6949 } else {
6950 // caching is on if textures are compressed
6951 g_GLOptions.m_bTextureCompressionCaching = dlg.GetTextureCompression();
6952 }
6953
6954 if (g_bopengl && g_glTextureManager &&
6955 g_GLOptions.m_bTextureCompression != dlg.GetTextureCompression()) {
6956 // new g_GLoptions setting is needed in callees
6957 g_GLOptions.m_bTextureCompression = dlg.GetTextureCompression();
6958
6959 if (top_frame::Get()->GetWxGlCanvas()) {
6960 ::wxBeginBusyCursor();
6961 top_frame::Get()->GetAbstractPrimaryCanvas()->SetupGlCompression();
6962 g_glTextureManager->ClearAllRasterTextures();
6963 ::wxEndBusyCursor();
6964 }
6965 } else
6966 g_GLOptions.m_bTextureCompression = dlg.GetTextureCompression();
6967 }
6968
6969 if (dlg.GetRebuildCache()) {
6970 m_returnChanges = REBUILD_RASTER_CACHE;
6971 Finish();
6972 }
6973#endif
6974}
6975
6976void options::OnChartDirListSelect(wxCommandEvent& event) {
6977#if 0
6978 bool selected = (pActiveChartsList->GetSelectedItemCount() > 0);
6979 m_removeBtn->Enable(selected);
6980 if (m_compressBtn) m_compressBtn->Enable(selected);
6981#endif
6982}
6983
6984void options::OnDisplayCategoryRadioButton(wxCommandEvent& event) {
6985 if (!g_useMUI) {
6986 if (pDispCat) {
6987 const bool select = pDispCat->GetSelection() == 3;
6988 ps57CtlListBox->Enable(select);
6989 itemButtonClearList->Enable(select);
6990 itemButtonSelectList->Enable(select);
6991 itemButtonSetStd->Enable(select);
6992 }
6993 }
6994 event.Skip();
6995}
6996
6997void options::OnButtonClearClick(wxCommandEvent& event) {
6998 resetMarStdList(false, false);
6999
7000 // int nOBJL = ps57CtlListBox->GetCount();
7001 // for (int iPtr = 0; iPtr < nOBJL; iPtr++){
7002 // ps57CtlListBox->Check(iPtr, FALSE);
7003 // }
7004 event.Skip();
7005}
7006
7007void options::OnButtonSelectClick(wxCommandEvent& event) {
7008 int nOBJL = ps57CtlListBox->GetCount();
7009 for (int iPtr = 0; iPtr < nOBJL; iPtr++) ps57CtlListBox->Check(iPtr, TRUE);
7010
7011 event.Skip();
7012}
7013
7014void options::OnButtonSetStd(wxCommandEvent& event) {
7015 resetMarStdList(false, true);
7016
7017 event.Skip();
7018}
7019
7020bool options::ShowToolTips() { return TRUE; }
7021
7022void options::OnCharHook(wxKeyEvent& event) {
7023 if (event.GetKeyCode() == WXK_RETURN &&
7024 event.GetModifiers() == wxMOD_CONTROL) {
7025 wxCommandEvent okEvent;
7026 okEvent.SetId(xID_OK);
7027 okEvent.SetEventType(wxEVT_COMMAND_BUTTON_CLICKED);
7028 GetEventHandler()->AddPendingEvent(okEvent);
7029 }
7030 event.Skip();
7031}
7032
7033void options::OnButtonaddClick(wxCommandEvent& event) {
7034 wxString selDir;
7035 int dresult = g_Platform->DoDirSelectorDialog(
7036 this, &selDir, _("Add a directory containing chart files"),
7037 *pInit_Chart_Dir, false); // no add files allowed
7038
7039 if (dresult != wxID_CANCEL) AddChartDir(selDir);
7040
7041 event.Skip();
7042}
7043
7044void options::AddChartDir(const wxString& dir) {
7045 wxFileName dirname = wxFileName(dir);
7046 pInit_Chart_Dir->Empty();
7047
7048 wxString dirAdd;
7049 if (g_bportable) {
7050 wxFileName f(dir);
7051 f.MakeRelativeTo(g_Platform->GetHomeDir());
7052 dirAdd = f.GetFullPath();
7053 } else {
7054 pInit_Chart_Dir->Append(dirname.GetPath());
7055 dirAdd = dir;
7056 }
7057
7058 ChartDirInfo cdi;
7059 cdi.fullpath = dirAdd;
7060 ActiveChartArray.Add(cdi);
7061
7062 UpdateChartDirList();
7063
7064 k_charts |= CHANGE_CHARTS;
7065
7066 pScanCheckBox->Disable();
7067}
7068
7069void options::UpdateDisplayedChartDirList(ArrayOfCDI p) {
7070 // Called by pluginmanager after adding single chart to database
7071
7072 ActiveChartArray.Clear();
7073 for (size_t i = 0; i < p.GetCount(); i++) {
7074 ActiveChartArray.Add(p[i]);
7075 }
7076
7077 UpdateChartDirList();
7078}
7079
7080void options::UpdateWorkArrayFromDisplayPanel() {
7081 wxString dirname;
7082 int n = ActiveChartArray.GetCount();
7083 if (m_pWorkDirList) {
7084 m_pWorkDirList->Clear();
7085 for (int i = 0; i < n; i++) {
7086 dirname = ActiveChartArray[i].fullpath;
7087 if (!dirname.IsEmpty()) {
7088 // This is a fix for OSX, which appends EOL to results of
7089 // GetLineText()
7090 while ((dirname.Last() == wxChar(_T('\n'))) ||
7091 (dirname.Last() == wxChar(_T('\r'))))
7092 dirname.RemoveLast();
7093
7094 // scan the current array to find a match
7095 // if found, add the info to the work list, preserving the magic
7096 // number
7097 // If not found, make a new ChartDirInfo, and add it
7098 bool b_added = FALSE;
7099 // if(m_pCurrentDirList)
7100 {
7101 int nDir = m_CurrentDirList.GetCount();
7102
7103 for (int i = 0; i < nDir; i++) {
7104 if (m_CurrentDirList[i].fullpath == dirname) {
7105 ChartDirInfo cdi = m_CurrentDirList[i];
7106 m_pWorkDirList->Add(cdi);
7107 b_added = TRUE;
7108 break;
7109 }
7110 }
7111 }
7112 if (!b_added) {
7113 ChartDirInfo cdin;
7114 cdin.fullpath = dirname;
7115 m_pWorkDirList->Add(cdin);
7116 }
7117 }
7118 }
7119 }
7120}
7121
7122void options::OnApplyClick(wxCommandEvent& event) {
7123 ApplyChanges(event);
7124
7125 // Complete processing
7126 // Force reload of options dialog to pick up font changes, locale changes,
7127 // or other major layout changes
7128 if ((m_returnChanges & FONT_CHANGED) ||
7129 (m_returnChanges & NEED_NEW_OPTIONS)) {
7130 // This will require an options reload
7131 // Clear the plugin options pages toggle
7132 if (g_pi_manager) g_pi_manager->CloseAllPlugInPanels((int)wxOK);
7133
7134 m_callbacks.prepare_close(this, m_returnChanges);
7135 if (!(m_returnChanges & FONT_CHANGED_SAFE))
7136 top_frame::Get()->ScheduleReconfigAndSettingsReload(true, true);
7137 } else {
7138 // If we had a config change,
7139 // then schedule a re-entry to the settings dialog
7140 if ((m_returnChanges & CONFIG_CHANGED)) {
7141 top_frame::Get()->ScheduleReconfigAndSettingsReload(true, false);
7142 }
7143 }
7144}
7145
7146void options::ApplyChanges(wxCommandEvent& event) {
7147 //::wxBeginBusyCursor();
7148 // FIXME This function is in ConnectionsDialog StopBTScan();
7149
7150 // Start with the stuff that requires intelligent validation.
7151
7152 if (m_pShipIconType->GetSelection() > 0) {
7153 double n_ownship_length_meters;
7154 double n_ownship_beam_meters;
7155 double n_gps_antenna_offset_y;
7156 double n_gps_antenna_offset_x;
7157 long n_ownship_min_mm;
7158 m_pOSLength->GetValue().ToDouble(&n_ownship_length_meters);
7159 m_pOSWidth->GetValue().ToDouble(&n_ownship_beam_meters);
7160 m_pOSGPSOffsetX->GetValue().ToDouble(&n_gps_antenna_offset_x);
7161 m_pOSGPSOffsetY->GetValue().ToDouble(&n_gps_antenna_offset_y);
7162 m_pOSMinSize->GetValue().ToLong(&n_ownship_min_mm);
7163 wxString msg;
7164 if (n_ownship_length_meters <= 0)
7165 msg += _("\n - your ship's length must be > 0");
7166 if (n_ownship_beam_meters <= 0)
7167 msg += _("\n - your ship's beam must be > 0");
7168 if (fabs(n_gps_antenna_offset_x) > n_ownship_beam_meters / 2.0)
7169 msg += _(
7170 "\n - your GPS offset from midship must be within your ship's beam");
7171 if (n_gps_antenna_offset_y < 0 ||
7172 n_gps_antenna_offset_y > n_ownship_length_meters)
7173 msg +=
7174 _("\n - your GPS offset from bow must be within your ship's length");
7175 if (n_ownship_min_mm <= 0 || n_ownship_min_mm > 100)
7176 msg += _("\n - your minimum ship icon size must be between 1 and 100 mm");
7177 if (!msg.IsEmpty()) {
7178 msg.Prepend(_("The settings for own ship real size are not correct:"));
7179 OCPNMessageBox(this, msg, _("OpenCPN info"), wxICON_ERROR | wxOK);
7180 ::wxEndBusyCursor();
7181 event.SetInt(wxID_STOP);
7182 return;
7183 }
7184 g_n_ownship_length_meters = n_ownship_length_meters;
7185 g_n_ownship_beam_meters = n_ownship_beam_meters;
7186 g_n_gps_antenna_offset_y = n_gps_antenna_offset_y;
7187 g_n_gps_antenna_offset_x = n_gps_antenna_offset_x;
7188 g_n_ownship_min_mm = static_cast<int>(n_ownship_min_mm);
7189 }
7190 g_OwnShipIconType = m_pShipIconType->GetSelection();
7191 g_bShowShipToActive = pShowshipToActive->GetValue();
7192 g_shipToActiveStyle = m_shipToActiveStyle->GetSelection();
7193 g_shipToActiveColor = m_shipToActiveColor->GetSelection();
7194
7195 m_pText_ACRadius->GetValue().ToDouble(&g_n_arrival_circle_radius);
7196 g_n_arrival_circle_radius =
7197 wxClip(g_n_arrival_circle_radius, 0.001, 0.6); // Correct abnormally
7198
7199 wxString* icon_name =
7200 pWayPointMan->GetIconKey(pWaypointDefaultIconChoice->GetSelection());
7201 if (icon_name && icon_name->Length()) g_default_wp_icon = *icon_name;
7202
7203 icon_name =
7204 pWayPointMan->GetIconKey(pRoutepointDefaultIconChoice->GetSelection());
7205 if (icon_name && icon_name->Length()) g_default_routepoint_icon = *icon_name;
7206
7207 g_bUseWptScaMin = pScaMinChckB->GetValue();
7208 g_iWpt_ScaMin = wxAtoi(m_pText_ScaMin->GetValue());
7209 g_iWpt_ScaMax = wxAtoi(m_pText_ScaMax->GetValue());
7210 g_bOverruleScaMin = pScaMinOverruleChckB->GetValue();
7211
7212 // Any Font changes?
7213 if (m_bfontChanged) {
7214#ifdef ocpnUSE_GL
7215 if (top_frame::Get()->GetWxGlCanvas()) {
7216 top_frame::Get()->GetAbstractPrimaryCanvas()->ResetGridFont();
7217 }
7218#endif
7219 if (top_frame::Get()->GetAbstractPrimaryCanvas()) {
7220 top_frame::Get()->GetAbstractPrimaryCanvas()->ResetGridFont();
7221 }
7222
7223 m_returnChanges |= FONT_CHANGED;
7224
7225 // If the font element changed was not "Dialog", then we don't need a full
7226 // reload
7227 if (m_font_element_array.Index("Dialog") == wxNOT_FOUND)
7228 m_returnChanges |= FONT_CHANGED_SAFE;
7229 }
7230
7231 // Handle Chart Tab
7232 UpdateWorkArrayFromDisplayPanel();
7233
7234 groupsPanel->SetDBDirs(*m_pWorkDirList); // update the Groups tab
7235 groupsPanel->m_treespopulated = FALSE;
7236
7237 int k_force = FORCE_UPDATE;
7238 if (pUpdateCheckBox) {
7239 if (!pUpdateCheckBox->GetValue()) k_force = 0;
7240 pUpdateCheckBox->Enable();
7241 pUpdateCheckBox->SetValue(FALSE);
7242 } else {
7243 k_force = 0;
7244 }
7245
7246 m_returnChanges |= k_force;
7247
7248 int k_scan = SCAN_UPDATE;
7249 if (pScanCheckBox) {
7250 if (!pScanCheckBox->GetValue()) k_scan = 0;
7251 pScanCheckBox->Enable();
7252 pScanCheckBox->SetValue(FALSE);
7253 } else {
7254 k_scan = 0;
7255 }
7256
7257 m_returnChanges |= k_scan;
7258
7259 pConfig->UpdateChartDirs(*m_pWorkDirList);
7260
7261 // Chart Groups
7262
7263 if (groupsPanel->modified) {
7264 groupsPanel->EmptyChartGroupArray(g_pGroupArray);
7265 delete g_pGroupArray;
7266 g_pGroupArray = groupsPanel->CloneChartGroupArray(m_pGroupArray);
7267 m_returnChanges |= GROUPS_CHANGED;
7268 }
7269
7270 // Handle Settings Tab
7271 if (m_pConfig) {
7272 g_bShowStatusBar = pShowStatusBar->GetValue();
7273
7274#ifndef __WXOSX__
7275 bool bmenu_shown = g_bShowMenuBar;
7276 if (pShowMenuBar->GetValue() != bmenu_shown)
7277 m_returnChanges |= MENU_CHANGED;
7278 g_bShowMenuBar = pShowMenuBar->GetValue();
7279#endif
7280
7281 g_bShowCompassWin = pShowCompassWin->GetValue();
7282 }
7283
7284 g_bShowChartBar = pShowChartBar->GetValue();
7285#ifndef __ANDROID__
7286 wxString screenmm = pScreenMM->GetValue();
7287 wxStringTokenizer tkz(screenmm, ",");
7289 while (tkz.HasMoreTokens()) {
7290 wxString token = tkz.GetNextToken();
7291 long mm = -1;
7292 if (token.ToLong(&mm) && mm > 0) {
7293 g_config_display_size_mm.push_back(mm);
7294 } else {
7295 g_config_display_size_mm.push_back(0);
7296 }
7297 }
7298 g_config_display_size_manual = pRBSizeManual->GetValue();
7299#endif
7300
7301 // Connections page.
7302 comm_dialog->ApplySettings();
7303
7304 if (pCDOOutlines) g_bShowOutlines = pCDOOutlines->GetValue();
7305 if (pSDisplayGrid) g_bDisplayGrid = pSDisplayGrid->GetValue();
7306
7307 if (pCDOQuilting) {
7308 bool temp_bquilting = pCDOQuilting->GetValue();
7309 // if (!g_bQuiltEnable && temp_bquilting)
7310 // cc1->ReloadVP(); /* compose the quilt */
7311 g_bQuiltEnable = temp_bquilting;
7312 }
7313 // g_bFullScreenQuilt = !pFullScreenQuilt->GetValue();
7314
7315 if (pSDepthUnits) g_bShowDepthUnits = pSDepthUnits->GetValue();
7316 g_bskew_comp = pSkewComp->GetValue();
7317 g_btouch = pMobile->GetValue();
7318 g_bresponsive = pResponsive->GetValue();
7319 g_bRollover = pRollover->GetValue();
7320 g_bShowMuiZoomButtons = pZoomButtons->GetValue();
7321
7322 g_bAutoHideToolbar = pToolbarAutoHideCB->GetValue();
7323
7324 long hide_val = 10;
7325 pToolbarHideSecs->GetValue().ToLong(&hide_val);
7326 g_nAutoHideToolbar = wxMin(static_cast<int>(hide_val), 100);
7327 g_nAutoHideToolbar = wxMax(g_nAutoHideToolbar, 2);
7328
7329 // g_fog_overzoom = !pOverzoomEmphasis->GetValue();
7330 // g_oz_vector_scale = !pOZScaleVector->GetValue();
7331
7332 if (pSmoothPanZoom) g_bsmoothpanzoom = pSmoothPanZoom->GetValue();
7333#ifdef __ANDROID__
7334 g_bsmoothpanzoom = false;
7335#endif
7336 if (pSmoothPanZoom) g_bsmoothpanzoom = pSmoothPanZoom->GetValue();
7337#ifdef __ANDROID__
7338 g_bsmoothpanzoom = false;
7339#endif
7340
7341 long update_val = 1;
7342 pCOGUPUpdateSecs->GetValue().ToLong(&update_val);
7343 g_COGAvgSec = wxMin(static_cast<int>(update_val), kMaxCogAverageSeconds);
7344
7345 // TODO if (g_bCourseUp != pCBCourseUp->GetValue()) gFrame->ToggleCourseUp();
7346
7347 if (pCBLookAhead) g_bLookAhead = pCBLookAhead->GetValue();
7348
7349 g_bShowTrue = pCBTrueShow->GetValue();
7350 g_bShowMag = pCBMagShow->GetValue();
7351
7352 auto loader = PluginLoader::GetInstance();
7353 b_haveWMM = loader && loader->IsPlugInAvailable("WMM");
7354 if (!b_haveWMM && !b_oldhaveWMM) {
7355 pMagVar->GetValue().ToDouble(&g_UserVar);
7356 gVar = g_UserVar;
7357 }
7358
7359 g_OwnShipmmsi = wxAtoi(m_pTxt_OwnMMSI->GetValue());
7360 m_pText_OSCOG_Predictor->GetValue().ToDouble(&g_ownship_predictor_minutes);
7361 m_pText_OSHDT_Predictor->GetValue().ToDouble(&g_ownship_HDTpredictor_miles);
7362
7363 double temp_dbl;
7364 g_iNavAidRadarRingsNumberVisible =
7365 pNavAidRadarRingsNumberVisible->GetSelection();
7366 g_bNavAidRadarRingsShown = g_iNavAidRadarRingsNumberVisible > 0;
7367 if (pNavAidRadarRingsStep->GetValue().ToDouble(&temp_dbl))
7368 g_fNavAidRadarRingsStep = temp_dbl;
7369 g_pNavAidRadarRingsStepUnits = m_itemRadarRingsUnits->GetSelection();
7370 g_iWaypointRangeRingsNumber = pWaypointRangeRingsNumber->GetSelection();
7371 if (pWaypointRangeRingsStep->GetValue().ToDouble(&temp_dbl))
7372 g_fWaypointRangeRingsStep = temp_dbl;
7373 g_iWaypointRangeRingsStepUnits =
7374 m_itemWaypointRangeRingsUnits->GetSelection();
7376 m_colourWaypointRangeRingsColour->GetColour();
7378 wxColour(g_colourWaypointRangeRingsColour.Red(),
7381 g_bWayPointPreventDragging = pWayPointPreventDragging->GetValue();
7382
7383 g_bConfirmObjectDelete = pConfirmObjectDeletion->GetValue();
7384
7385 if (pPreserveScale) g_bPreserveScaleOnX = pPreserveScale->GetValue();
7386
7387 if (pCmdSoundString) {
7388 g_CmdSoundString = pCmdSoundString->GetValue();
7389 if (wxIsEmpty(g_CmdSoundString)) {
7390 g_CmdSoundString = wxString(OCPN_SOUND_CMD);
7391 pCmdSoundString->SetValue(g_CmdSoundString);
7392 }
7393 }
7394
7395 g_bPlayShipsBells = pPlayShipsBells->GetValue();
7396 if (pSoundDeviceIndex)
7397 g_iSoundDeviceIndex = pSoundDeviceIndex->GetSelection();
7398 // g_bTransparentToolbar = pTransparentToolbar->GetValue();
7399 g_iSDMMFormat = pSDMMFormat->GetSelection();
7400 // Map dropdown selection index explicitly to DISTANCE_* enum.
7401 {
7402 int sel = pDistanceFormat->GetSelection();
7403 g_iDistanceFormat = GetDistanceFormatEnum(sel);
7404 }
7405 g_iSpeedFormat = pSpeedFormat->GetSelection();
7406 g_iWindSpeedFormat = pWindSpeedFormat->GetSelection();
7407 g_iTempFormat = pTempFormat->GetSelection();
7408 if (pHeightUnitSelect) g_iHeightFormat = pHeightUnitSelect->GetSelection();
7409
7410 // LIVE ETA OPTION
7411 if (pSLiveETA) g_bShowLiveETA = pSLiveETA->GetValue();
7412 if (pSDefaultBoatSpeed)
7413 pSDefaultBoatSpeed->GetValue().ToDouble(&g_defaultBoatSpeedUserUnit);
7414 g_defaultBoatSpeed = fromUsrSpeed(g_defaultBoatSpeedUserUnit);
7415 if (m_Text_def_boat_speed)
7416 m_Text_def_boat_speed->SetLabel(_("Default Boat Speed ") + "(" +
7417 getUsrSpeedUnit() + ")");
7418
7419 g_bAdvanceRouteWaypointOnArrivalOnly =
7420 pAdvanceRouteWaypointOnArrivalOnly->GetValue();
7421
7422 g_colourTrackLineColour = m_colourTrackLineColour->GetColour();
7423 g_colourTrackLineColour =
7424 wxColour(g_colourTrackLineColour.Red(), g_colourTrackLineColour.Green(),
7425 g_colourTrackLineColour.Blue());
7426 g_nTrackPrecision = pTrackPrecision->GetSelection();
7427
7428 g_bTrackDaily = pTrackDaily->GetValue();
7429
7430 g_track_rotate_time = 0;
7431#if wxUSE_TIMEPICKCTRL
7432 int h, m, s;
7433 if (pTrackRotateTime && pTrackRotateTime->GetTime(&h, &m, &s))
7434 g_track_rotate_time = h * 3600 + m * 60 + s;
7435#endif
7436
7437 if (pTrackRotateUTC->GetValue())
7438 g_track_rotate_time_type = TIME_TYPE_UTC;
7439 else if (pTrackRotateLMT->GetValue())
7440 g_track_rotate_time_type = TIME_TYPE_LMT;
7441 else
7442 g_track_rotate_time_type = TIME_TYPE_COMPUTER;
7443
7444 g_bHighliteTracks = pTrackHighlite->GetValue();
7445
7446 if (pTimezoneUTC->GetValue())
7447 g_datetime_format = "UTC";
7448 else if (pTimezoneLocalTime->GetValue())
7449 g_datetime_format = "Local Time";
7450
7451 if (pEnableZoomToCursor)
7452 g_bEnableZoomToCursor = pEnableZoomToCursor->GetValue();
7453
7454 if (pEnableTenHertz) g_btenhertz = pEnableTenHertz->GetValue();
7455
7456#ifdef __ANDROID__
7457 g_bEnableZoomToCursor = false;
7458#endif
7459
7460 g_colourOwnshipRangeRingsColour = m_colourOwnshipRangeRingColour->GetColour();
7461 g_colourOwnshipRangeRingsColour =
7462 wxColour(g_colourOwnshipRangeRingsColour.Red(),
7463 g_colourOwnshipRangeRingsColour.Green(),
7464 g_colourOwnshipRangeRingsColour.Blue());
7465
7466 // Sounds
7467 g_bAIS_GCPA_Alert_Audio = m_soundPanelAIS->GetCheckBox()->GetValue();
7468 g_bAIS_SART_Alert_Audio = m_soundPanelSART->GetCheckBox()->GetValue();
7469 g_bAIS_DSC_Alert_Audio = m_soundPanelDSC->GetCheckBox()->GetValue();
7470 g_bAnchor_Alert_Audio = m_soundPanelAnchor->GetCheckBox()->GetValue();
7471
7472 // AIS Parameters
7473 // CPA Box
7474 g_bCPAMax = m_pCheck_CPA_Max->GetValue();
7475 m_pText_CPA_Max->GetValue().ToDouble(&g_CPAMax_NM);
7476 g_bCPAWarn = m_pCheck_CPA_Warn->GetValue();
7477 m_pText_CPA_Warn->GetValue().ToDouble(&g_CPAWarn_NM);
7478 g_bTCPA_Max = m_pCheck_CPA_WarnT->GetValue();
7479 m_pText_CPA_WarnT->GetValue().ToDouble(&g_TCPA_Max);
7480
7481 // Lost Targets
7482 g_bMarkLost = m_pCheck_Mark_Lost->GetValue();
7483 m_pText_Mark_Lost->GetValue().ToDouble(&g_MarkLost_Mins);
7484 g_bRemoveLost = m_pCheck_Remove_Lost->GetValue();
7485 m_pText_Remove_Lost->GetValue().ToDouble(&g_RemoveLost_Mins);
7486
7487 // Display
7488 g_bShowCOG = m_pCheck_Show_COG->GetValue();
7489 // If synchronized with own ship predictor
7490 g_bSyncCogPredictors = m_pCheck_Sync_OCOG_ACOG->GetValue();
7491 if (g_bSyncCogPredictors) {
7492 m_pText_COG_Predictor->SetValue(m_pText_OSCOG_Predictor->GetValue());
7493 }
7494 m_pText_COG_Predictor->GetValue().ToDouble(&g_ShowCOG_Mins);
7495
7496 g_bAISShowTracks = m_pCheck_Show_Tracks->GetValue();
7497 m_pText_Track_Length->GetValue().ToDouble(&g_AISShowTracks_Mins);
7498
7499 // Update all the current targets
7500 if (g_pAIS) {
7501 for (const auto& it : g_pAIS->GetTargetList()) {
7502 auto pAISTarget = it.second;
7503 if (NULL != pAISTarget) {
7504 pAISTarget->b_show_track = g_bAISShowTracks;
7505 // Check for exceptions in MMSI properties
7506 for (unsigned int i = 0; i < g_MMSI_Props_Array.GetCount(); i++) {
7507 if (pAISTarget->MMSI == g_MMSI_Props_Array[i]->MMSI) {
7508 MmsiProperties* props = g_MMSI_Props_Array[i];
7509 if (TRACKTYPE_NEVER == props->TrackType) {
7510 pAISTarget->b_show_track = false;
7511 break;
7512 } else if (TRACKTYPE_ALWAYS == props->TrackType) {
7513 pAISTarget->b_show_track = true;
7514 break;
7515 } else
7516 break;
7517 }
7518 }
7519 // Check for any persistently tracked target, force b_show_track ON
7520 std::map<int, Track*>::iterator it;
7521 it = g_pAIS->m_persistent_tracks.find(pAISTarget->MMSI);
7522 if (it != g_pAIS->m_persistent_tracks.end())
7523 pAISTarget->b_show_track = true;
7524 pAISTarget->b_show_track_old = g_bAISShowTracks;
7525 }
7526 }
7527 }
7528
7529 g_bHideMoored = m_pCheck_Hide_Moored->GetValue();
7530 m_pText_Moored_Speed->GetValue().ToDouble(&g_ShowMoored_Kts);
7531
7532 g_bDrawAISRealtime = m_pCheck_Draw_Realtime_Prediction->GetValue();
7533 m_pText_RealtPred_Speed->GetValue().ToDouble(&g_AIS_RealtPred_Kts);
7534
7535 g_bAllowShowScaled = m_pCheck_Scale_Priority->GetValue();
7536 long l;
7537 m_pText_Scale_Priority->GetValue().ToLong(&l);
7538 g_ShowScaled_Num = (int)l;
7539
7540 g_bShowAreaNotices = m_pCheck_Show_Area_Notices->GetValue();
7541 g_bDrawAISSize = m_pCheck_Draw_Target_Size->GetValue();
7542 g_bShowAISName = m_pCheck_Show_Target_Name->GetValue();
7543 long ais_name_scale = 5000;
7544 m_pText_Show_Target_Name_Scale->GetValue().ToLong(&ais_name_scale);
7545 g_Show_Target_Name_Scale = (int)wxMax(5000, ais_name_scale);
7546 g_bWplUsePosition = m_pCheck_use_Wpl->GetValue();
7547 g_WplAction = m_pWplAction->GetSelection();
7548
7549 // Alert
7550 g_bAIS_CPA_Alert = m_pCheck_AlertDialog->GetValue();
7551 g_bAIS_CPA_Alert_Audio = m_pCheck_AlertAudio->GetValue();
7552 g_bAIS_CPA_Alert_Suppress_Moored = m_pCheck_Alert_Moored->GetValue();
7553
7554 g_bAIS_ACK_Timeout = m_pCheck_Ack_Timout->GetValue();
7555 m_pText_ACK_Timeout->GetValue().ToDouble(&g_AckTimeout_Mins);
7556
7557 // Rollover
7558 g_bAISRolloverShowClass = m_pCheck_Rollover_Class->GetValue();
7559 g_bAISRolloverShowCOG = m_pCheck_Rollover_COG->GetValue();
7560 g_bAISRolloverShowCPA = m_pCheck_Rollover_CPA->GetValue();
7561
7562 g_chart_zoom_modifier_raster = m_pSlider_Zoom_Raster->GetValue();
7563 g_chart_zoom_modifier_vector = m_pSlider_Zoom_Vector->GetValue();
7564 g_cm93_zoom_factor = m_pSlider_CM93_Zoom->GetValue();
7565 g_GUIScaleFactor = m_pSlider_GUI_Factor->GetValue();
7566
7567 bool bchange_scale = false;
7568 if (g_ChartScaleFactor != m_pSlider_Chart_Factor->GetValue())
7569 bchange_scale = true;
7570 g_ChartScaleFactor = m_pSlider_Chart_Factor->GetValue();
7571
7573 g_Platform->GetChartScaleFactorExp(g_ChartScaleFactor);
7574 g_MarkScaleFactorExp = g_Platform->GetMarkScaleFactorExp(g_ChartScaleFactor);
7575 g_ShipScaleFactor = m_pSlider_Ship_Factor->GetValue();
7576 g_ShipScaleFactorExp = g_Platform->GetChartScaleFactorExp(g_ShipScaleFactor);
7577 g_ENCSoundingScaleFactor = m_pSlider_Text_Factor->GetValue();
7578 g_ENCTextScaleFactor = m_pSlider_ENCText_Factor->GetValue();
7579
7580 g_mouse_zoom_sensitivity_ui = m_pMouse_Zoom_Slider->GetValue();
7581 g_mouse_zoom_sensitivity =
7582 MouseZoom::ui_to_config(g_mouse_zoom_sensitivity_ui);
7583
7584 // Only reload the icons if user has actually visted the UI page
7585 if (m_bVisitLang) {
7586 if (pWayPointMan) WayPointmanGui(*pWayPointMan).ReloadRoutepointIcons();
7587 }
7588
7589 // FIXME Move these two
7590 // g_NMEAAPBPrecision = m_choicePrecision->GetCurrentSelection();
7591 // g_TalkerIdText = m_TalkerIdText->GetValue().MakeUpper();
7592
7593#ifdef ocpnUSE_GL
7594 if (g_bopengl != pOpenGL->GetValue()) m_returnChanges |= GL_CHANGED;
7595 g_bopengl = pOpenGL->GetValue();
7596#endif
7597
7598 g_bChartBarEx = pChartBarEX->GetValue();
7599
7600 // Handle Vector Charts Tab
7601 int depthUnit = pDepthUnitSelect->GetSelection();
7602 g_nDepthUnitDisplay = depthUnit;
7603
7604 // Process the UserStandard display list, noting if any changes were made
7605 bool bUserStdChange = false;
7606
7607 int nOBJL = ps57CtlListBox->GetCount();
7608
7609 for (int iPtr = 0; iPtr < nOBJL; iPtr++) {
7610 int itemIndex = -1;
7611 for (size_t i = 0; i < marinersStdXref.size(); i++) {
7612 if (marinersStdXref[i] == iPtr) {
7613 itemIndex = i;
7614 break;
7615 }
7616 }
7617 assert(itemIndex >= 0);
7618 OBJLElement* pOLE = (OBJLElement*)(ps52plib->pOBJLArray->Item(itemIndex));
7619 if (pOLE->nViz != (int)(ps57CtlListBox->IsChecked(iPtr)))
7620 bUserStdChange = true;
7621 pOLE->nViz = ps57CtlListBox->IsChecked(iPtr);
7622 }
7623
7624 if (ps52plib) {
7625 // Take a snapshot of the S52 config right now,
7626 // for later comparison
7627 ps52plib->GenerateStateHash();
7628 long stateHash = ps52plib->GetStateHash();
7629
7630 if (m_returnChanges & GL_CHANGED) {
7631 // Do this now to handle the screen refresh that is automatically
7632 // generated on Windows at closure of the options dialog...
7633 ps52plib->FlushSymbolCaches(ChartCtxFactory());
7634 // some CNSY depends on renderer (e.g. CARC)
7635 ps52plib->ClearCNSYLUPArray();
7636 ps52plib->GenerateStateHash();
7637 }
7638
7639 if (pDispCat) {
7640 enum _DisCat nset = OTHER;
7641 switch (pDispCat->GetSelection()) {
7642 case 0:
7643 nset = DISPLAYBASE;
7644 break;
7645 case 1:
7646 nset = STANDARD;
7647 break;
7648 case 2:
7649 nset = OTHER;
7650 break;
7651 case 3:
7652 nset = MARINERS_STANDARD;
7653 break;
7654 }
7655 ps52plib->SetDisplayCategory(nset);
7656 }
7657
7658 if (pCheck_SOUNDG) ps52plib->m_bShowSoundg = pCheck_SOUNDG->GetValue();
7659 if (pCheck_ATONTEXT)
7660 ps52plib->m_bShowAtonText = pCheck_ATONTEXT->GetValue();
7661 if (pCheck_LDISTEXT)
7662 ps52plib->m_bShowLdisText = pCheck_LDISTEXT->GetValue();
7663 if (pCheck_XLSECTTEXT)
7664 ps52plib->m_bExtendLightSectors = pCheck_XLSECTTEXT->GetValue();
7665
7666 ps52plib->m_bShowMeta = pCheck_META->GetValue();
7667 ps52plib->m_bDeClutterText = pCheck_DECLTEXT->GetValue();
7668 ps52plib->m_bShowNationalTexts = pCheck_NATIONALTEXT->GetValue();
7669 ps52plib->m_bShowS57ImportantTextOnly = pCheck_SHOWIMPTEXT->GetValue();
7670 ps52plib->m_bUseSCAMIN = pCheck_SCAMIN->GetValue();
7671 ps52plib->m_bUseSUPER_SCAMIN = pCheck_SuperSCAMIN->GetValue();
7672
7673 ps52plib->m_nSymbolStyle =
7674 pPointStyle->GetSelection() == 0 ? PAPER_CHART : SIMPLIFIED;
7675
7676 ps52plib->m_nBoundaryStyle = pBoundStyle->GetSelection() == 0
7677 ? PLAIN_BOUNDARIES
7678 : SYMBOLIZED_BOUNDARIES;
7679 ps52plib->m_nSoundingFactor = m_pSlider_Text_Factor->GetValue();
7680 ps52plib->m_nTextFactor = m_pSlider_ENCText_Factor->GetValue();
7681
7682 S52_setMarinerParam(S52_MAR_TWO_SHADES,
7683 (p24Color->GetSelection() == 0) ? 1.0 : 0.0);
7684
7685 // Depths
7686 double dval;
7687 float conv = 1;
7688
7689 if (depthUnit == 0) // feet
7690 conv = 0.3048f; // international definiton of 1 foot is 0.3048 metres
7691 else if (depthUnit == 2) // fathoms
7692 conv = 0.3048f * 6; // 1 fathom is 6 feet
7693
7694 if (m_SafetyCtl->GetValue().ToDouble(&dval)) {
7695 S52_setMarinerParam(S52_MAR_SAFETY_DEPTH,
7696 dval * conv); // controls sounding display
7697 S52_setMarinerParam(S52_MAR_SAFETY_CONTOUR,
7698 dval * conv); // controls colour
7699 }
7700
7701 if (m_ShallowCtl->GetValue().ToDouble(&dval))
7702 S52_setMarinerParam(S52_MAR_SHALLOW_CONTOUR, dval * conv);
7703
7704 if (m_DeepCtl->GetValue().ToDouble(&dval))
7705 S52_setMarinerParam(S52_MAR_DEEP_CONTOUR, dval * conv);
7706
7707 ps52plib->UpdateMarinerParams();
7708 ps52plib->m_nDepthUnitDisplay = depthUnit;
7709 // Keep s52plib height display in sync with height preference
7710 ps52plib->m_nHeightUnitDisplay = g_iHeightFormat;
7711
7712 ps52plib->GenerateStateHash();
7713
7714 // Detect a change to S52 library config
7715 if ((stateHash != ps52plib->GetStateHash()) || bUserStdChange)
7716 m_returnChanges |= S52_CHANGED;
7717
7718 if (bchange_scale) m_returnChanges |= S52_CHANGED;
7719 }
7720
7721// User Interface Panel
7722#if wxUSE_XLOCALE || !wxCHECK_VERSION(3, 0, 0)
7723 if (m_bVisitLang) {
7724 wxString new_canon = "en_US";
7725 wxString lang_sel = m_itemLangListBox->GetStringSelection();
7726
7727 int nLang = sizeof(lang_list) / sizeof(int);
7728 for (int it = 0; it < nLang; it++) {
7729 const wxLanguageInfo* pli = wxLocale::GetLanguageInfo(lang_list[it]);
7730 if (pli) {
7731 wxString lang_canonical = pli->CanonicalName;
7732 wxString test_string = GetOCPNKnownLanguage(lang_canonical);
7733 if (lang_sel == test_string) {
7734 new_canon = lang_canonical;
7735 break;
7736 }
7737 }
7738 }
7739
7740 wxString locale_old = g_locale;
7741 g_locale = new_canon;
7742
7743 if (g_locale != locale_old) m_returnChanges |= LOCALE_CHANGED;
7744
7745 wxString oldStyle = g_StyleManager->GetCurrentStyle()->name;
7746 // g_StyleManager->SetStyleNextInvocation(
7747 // m_itemStyleListBox->GetStringSelection());
7748 if (g_StyleManager->GetStyleNextInvocation() != oldStyle) {
7749 m_returnChanges |= STYLE_CHANGED;
7750 }
7751 wxSizeEvent nullEvent;
7752 top_frame::Get()->OnSize(nullEvent);
7753 }
7754#endif
7755 if (g_bInlandEcdis != pInlandEcdis->GetValue()) { // InlandEcdis changed
7756 g_bInlandEcdis = pInlandEcdis->GetValue();
7757 SwitchInlandEcdisMode(g_bInlandEcdis);
7758 m_returnChanges |= TOOLBAR_CHANGED;
7759 }
7760
7761 if (pHiconColors) g_hicon_colors = pHiconColors->GetValue();
7762
7763 // PlugIn Manager Panel
7764 // Pick up any changes to selections
7765 if (PluginLoader::GetInstance()->UpdatePlugIns())
7766 m_returnChanges |= TOOLBAR_CHANGED;
7767
7768 // And keep config in sync
7769 // if (m_pPlugInCtrl) m_pPlugInCtrl->UpdatePluginsOrder(); FIXME(leamas)
7770 g_pi_manager->UpdateConfig();
7771
7772 m_returnChanges |= GENERIC_CHANGED | k_vectorcharts | k_charts |
7773 m_groups_changed | k_plugins;
7774
7775 // Pick up all the entries in the Tide/current DataSelected control
7776 // and update the global static array if changed
7777 // Get signature of existing array
7778 wxString string_acc;
7779 for (wxString entry : TideCurrentDataSet) {
7780 string_acc += entry;
7781 }
7782 // Get signature for options control
7783 wxString string_acc_control;
7784 for (int i = 0; i < tcDataSelected->GetItemCount(); i++) {
7785 wxString setName = tcDataSelected->GetItemText(i);
7786 string_acc_control += setName;
7787 }
7788 // Any change?
7789 if (!string_acc.IsSameAs(string_acc_control)) {
7790 TideCurrentDataSet.clear();
7791 int nEntry = tcDataSelected->GetItemCount();
7792 for (int i = 0; i < nEntry; i++) {
7793 wxString setName = tcDataSelected->GetItemText(i);
7794 TideCurrentDataSet.push_back(setName.ToStdString());
7795 }
7796 m_returnChanges |= TIDES_CHANGED;
7797 }
7798
7799 if (g_canvasConfig != m_screenConfig) m_returnChanges |= CONFIG_CHANGED;
7800 g_canvasConfig = m_screenConfig;
7801
7802 UpdateWorkArrayFromDisplayPanel();
7803
7804 // Start a chartdbs update directly, if required
7805 if ((m_returnChanges & VISIT_CHARTS) &&
7806 ((m_returnChanges & CHANGE_CHARTS) || (m_returnChanges & SCAN_UPDATE))) {
7807 DoDBSUpdate((m_returnChanges & FORCE_UPDATE) == FORCE_UPDATE);
7808 } else {
7809 bool b_groupchange = ChartData->ScrubGroupArray();
7810 ChartData->ApplyGroupArray(g_pGroupArray);
7811 if (b_groupchange ||
7812 ((m_returnChanges & GROUPS_CHANGED) == GROUPS_CHANGED)) {
7813 pConfig->DestroyConfigGroups();
7814 pConfig->CreateConfigGroups(g_pGroupArray);
7815 }
7816 if ((m_returnChanges & GROUPS_CHANGED) == GROUPS_CHANGED)
7817 ChartData->ApplyGroupArray(g_pGroupArray);
7818 }
7819
7820 m_callbacks.process_dialog(m_returnChanges, m_pWorkDirList);
7821
7822 // We can clear a few flag bits on "Apply", so they won't be recognised at
7823 // the "Close" click. Their actions have already been accomplished once...
7824 m_returnChanges &= ~(CHANGE_CHARTS | FORCE_UPDATE | SCAN_UPDATE);
7825 k_charts = 0;
7826
7827 top_frame::Get()->RefreshAllCanvas();
7828
7829 // Some layout changes requiring a new options instance?
7830 if (m_bneedNew) m_returnChanges |= NEED_NEW_OPTIONS;
7831
7832 if (m_bVisitPlugins) m_returnChanges |= FORCE_RELOAD;
7833
7834 // Record notice of any changes to last applied template
7835 UpdateTemplateTitleText();
7836
7837 if (::wxIsBusy()) // FIXME: Not sure why this is needed here
7838 ::wxEndBusyCursor();
7839}
7840
7841void options::OnXidOkClick(wxCommandEvent& event) {
7842 // When closing the form with Ctrl-Enter sometimes we get double events, the
7843 // second is empty??
7844 if (event.GetEventObject() == NULL) return;
7845
7846 ApplyChanges(event);
7847
7848 // Complete processing
7849 m_callbacks.prepare_close(this, m_returnChanges);
7850
7851 // If we had a config change, then do it now
7852 if ((m_returnChanges & CONFIG_CHANGED) || (m_returnChanges & GL_CHANGED))
7853 top_frame::Get()->ScheduleReconfigAndSettingsReload(false, false);
7854
7855 // Special case for "Dialog" font edit
7856 if ((m_returnChanges & FONT_CHANGED) &&
7857 !(m_returnChanges & FONT_CHANGED_SAFE))
7858 top_frame::Get()->ScheduleDeleteSettingsDialog();
7859
7860 // And for locale change
7861 if (m_returnChanges & LOCALE_CHANGED)
7862 top_frame::Get()->ScheduleDeleteSettingsDialog();
7863
7864 if ((m_returnChanges & FONT_CHANGED) ||
7865 (m_returnChanges & NEED_NEW_OPTIONS)) {
7866 // This will require an options reload
7867 // Clear the plugin options pages toggle
7868 if (g_pi_manager) g_pi_manager->CloseAllPlugInPanels((int)wxOK);
7869 }
7870
7871 // Also for FORCE_RELOAD
7872 if (m_returnChanges & FORCE_RELOAD) top_frame::Get()->ScheduleReloadCharts();
7873
7874 Finish();
7875 Hide();
7876}
7877
7878void options::Finish() {
7879 // Required to avoid intermittent crash on wxGTK
7880 m_pListbook->ChangeSelection(0);
7881 for (size_t i = 0; i < m_pListbook->GetPageCount(); i++) {
7882 wxNotebookPage* pg = m_pListbook->GetPage(i);
7883 wxNotebook* nb = dynamic_cast<wxNotebook*>(pg);
7884 if (nb) nb->ChangeSelection(0);
7885 }
7886
7887 lastWindowPos = GetPosition();
7888 lastWindowSize = GetSize();
7889
7890 pConfig->SetPath("/Settings");
7891 pConfig->Write("OptionsSizeX", lastWindowSize.x);
7892 pConfig->Write("OptionsSizeY", lastWindowSize.y);
7893}
7894
7895ArrayOfCDI options::GetSelectedChartDirs() {
7896 ArrayOfCDI rv;
7897 for (size_t i = 0; i < panelVector.size(); i++) {
7898 if (panelVector[i]->IsSelected()) {
7899 rv.Add(panelVector[i]->GetCDI());
7900 }
7901 }
7902
7903 return rv;
7904}
7905
7906ArrayOfCDI options::GetUnSelectedChartDirs() {
7907 ArrayOfCDI rv;
7908 for (size_t i = 0; i < panelVector.size(); i++) {
7909 if (!panelVector[i]->IsSelected()) {
7910 rv.Add(panelVector[i]->GetCDI());
7911 }
7912 }
7913
7914 return rv;
7915}
7916
7917void options::SetDirActionButtons() {
7918 ArrayOfCDI selArray = GetSelectedChartDirs();
7919 if (selArray.GetCount())
7920 m_removeBtn->Enable();
7921 else
7922 m_removeBtn->Disable();
7923}
7924
7925void options::OnButtondeleteClick(wxCommandEvent& event) {
7926 ArrayOfCDI unselArray = GetUnSelectedChartDirs();
7927 ActiveChartArray.Clear();
7928 for (size_t i = 0; i < unselArray.GetCount(); i++) {
7929 ActiveChartArray.Add(unselArray[i]);
7930 }
7931
7932 UpdateChartDirList();
7933
7934 UpdateWorkArrayFromDisplayPanel();
7935
7936#if 0
7937 if (m_pWorkDirList) {
7938 pActiveChartsList->DeleteAllItems();
7939 for (size_t id = 0; id < m_pWorkDirList->GetCount(); id++) {
7940 wxString dirname = m_pWorkDirList->Item(id).fullpath;
7941 wxListItem li;
7942 li.SetId(id);
7943 li.SetAlign(wxLIST_FORMAT_LEFT);
7944 li.SetText(dirname);
7945 li.SetColumn(0);
7946 long idx = pActiveChartsList->InsertItem(li);
7947 }
7948 }
7949#endif
7950
7951 k_charts |= CHANGE_CHARTS;
7952
7953 pScanCheckBox->Disable();
7954
7955 event.Skip();
7956}
7957
7958void options::DoDBSUpdate(bool force_full) {
7959 m_OKButton->Disable();
7960 m_CancelButton->Disable();
7961 m_ApplyButton->Disable();
7962
7963 wxString longmsg = _("OpenCPN Chart Update");
7964 longmsg +=
7965 ".................................................................."
7966 "........";
7967
7968 m_pCBDSprog = new wxGenericProgressDialog();
7969
7970 wxFont* qFont = GetOCPNScaledFont(_("Dialog"));
7971 m_pCBDSprog->SetFont(*qFont);
7972
7973 //
7974 m_pCBDSprog->Create(_("OpenCPN Chart Update"), longmsg, 100, nullptr,
7975 wxPD_SMOOTH);
7976
7977 DimeControl(m_pCBDSprog);
7978 m_pCBDSprog->Show();
7979
7980 ChartData->PurgeCache();
7981
7982 // Disable texture compression cacheing
7983 m_bTextureCacheingSave = g_GLOptions.m_bTextureCompressionCaching;
7984 g_GLOptions.m_bTextureCompressionCaching = false;
7985
7986 ChartData->UpdateChartDatabaseInplace(*m_pWorkDirList, force_full,
7987 m_pCBDSprog);
7988}
7989
7990void options::OnButtonRebuildChartDb(wxCommandEvent& event) {
7991 DoDBSUpdate(true); // Force full update
7992}
7993
7994void options::OnButtonParseENC(wxCommandEvent& event) {
7995 top_frame::Get()->GetAbstractPrimaryCanvas()->EnablePaint(false);
7996
7997 extern void ParseAllENC(wxWindow * parent);
7998
7999 ParseAllENC(g_pOptions);
8000
8001 ViewPort vp;
8002 top_frame::Get()->ChartsRefresh();
8003
8004 top_frame::Get()->GetAbstractPrimaryCanvas()->EnablePaint(true);
8005}
8006
8007#ifdef OCPN_USE_LZMA
8008#include <lzma.h>
8009
8010static bool compress(lzma_stream* strm, FILE* infile, FILE* outfile) {
8011 // This will be LZMA_RUN until the end of the input file is reached.
8012 // This tells lzma_code() when there will be no more input.
8013 lzma_action action = LZMA_RUN;
8014
8015 // Buffers to temporarily hold uncompressed input
8016 // and compressed output.
8017 uint8_t inbuf[BUFSIZ];
8018 uint8_t outbuf[BUFSIZ];
8019
8020 // Initialize the input and output pointers. Initializing next_in
8021 // and avail_in isn't really necessary when we are going to encode
8022 // just one file since LZMA_STREAM_INIT takes care of initializing
8023 // those already. But it doesn't hurt much and it will be needed
8024 // if encoding more than one file like we will in 02_decompress.c.
8025 //
8026 // While we don't care about strm->total_in or strm->total_out in this
8027 // example, it is worth noting that initializing the encoder will
8028 // always reset total_in and total_out to zero. But the encoder
8029 // initialization doesn't touch next_in, avail_in, next_out, or
8030 // avail_out.
8031 strm->next_in = NULL;
8032 strm->avail_in = 0;
8033 strm->next_out = outbuf;
8034 strm->avail_out = sizeof(outbuf);
8035
8036 // Loop until the file has been successfully compressed or until
8037 // an error occurs.
8038 while (true) {
8039 // Fill the input buffer if it is empty.
8040 if (strm->avail_in == 0 && !feof(infile)) {
8041 strm->next_in = inbuf;
8042 strm->avail_in = fread(inbuf, 1, sizeof(inbuf), infile);
8043
8044 if (ferror(infile)) {
8045 fprintf(stderr, "Read error: %s\n", strerror(errno));
8046 return false;
8047 }
8048
8049 // Once the end of the input file has been reached,
8050 // we need to tell lzma_code() that no more input
8051 // will be coming and that it should finish the
8052 // encoding.
8053 if (feof(infile)) action = LZMA_FINISH;
8054 }
8055
8056 // Tell liblzma do the actual encoding.
8057 //
8058 // This reads up to strm->avail_in bytes of input starting
8059 // from strm->next_in. avail_in will be decremented and
8060 // next_in incremented by an equal amount to match the
8061 // number of input bytes consumed.
8062 //
8063 // Up to strm->avail_out bytes of compressed output will be
8064 // written starting from strm->next_out. avail_out and next_out
8065 // will be incremented by an equal amount to match the number
8066 // of output bytes written.
8067 //
8068 // The encoder has to do internal buffering, which means that
8069 // it may take quite a bit of input before the same data is
8070 // available in compressed form in the output buffer.
8071 lzma_ret ret = lzma_code(strm, action);
8072
8073 // If the output buffer is full or if the compression finished
8074 // successfully, write the data from the output bufffer to
8075 // the output file.
8076 if (strm->avail_out == 0 || ret == LZMA_STREAM_END) {
8077 // When lzma_code() has returned LZMA_STREAM_END,
8078 // the output buffer is likely to be only partially
8079 // full. Calculate how much new data there is to
8080 // be written to the output file.
8081 size_t write_size = sizeof(outbuf) - strm->avail_out;
8082
8083 if (fwrite(outbuf, 1, write_size, outfile) != write_size) {
8084 fprintf(stderr, "Write error: %s\n", strerror(errno));
8085 return false;
8086 }
8087
8088 // Reset next_out and avail_out.
8089 strm->next_out = outbuf;
8090 strm->avail_out = sizeof(outbuf);
8091 }
8092
8093 // Normally the return value of lzma_code() will be LZMA_OK
8094 // until everything has been encoded.
8095 if (ret != LZMA_OK) {
8096 // Once everything has been encoded successfully, the
8097 // return value of lzma_code() will be LZMA_STREAM_END.
8098 //
8099 // It is important to check for LZMA_STREAM_END. Do not
8100 // assume that getting ret != LZMA_OK would mean that
8101 // everything has gone well.
8102 if (ret == LZMA_STREAM_END) return true;
8103
8104 // It's not LZMA_OK nor LZMA_STREAM_END,
8105 // so it must be an error code. See lzma/base.h
8106 // (src/liblzma/api/lzma/base.h in the source package
8107 // or e.g. /usr/include/lzma/base.h depending on the
8108 // install prefix) for the list and documentation of
8109 // possible values. Most values listen in lzma_ret
8110 // enumeration aren't possible in this example.
8111 const char* msg;
8112 switch (ret) {
8113 case LZMA_MEM_ERROR:
8114 msg = "Memory allocation failed";
8115 break;
8116
8117 case LZMA_DATA_ERROR:
8118 // This error is returned if the compressed
8119 // or uncompressed size get near 8 EiB
8120 // (2^63 bytes) because that's where the .xz
8121 // file format size limits currently are.
8122 // That is, the possibility of this error
8123 // is mostly theoretical unless you are doing
8124 // something very unusual.
8125 //
8126 // Note that strm->total_in and strm->total_out
8127 // have nothing to do with this error. Changing
8128 // those variables won't increase or decrease
8129 // the chance of getting this error.
8130 msg = "File size limits exceeded";
8131 break;
8132
8133 default:
8134 // This is most likely LZMA_PROG_ERROR, but
8135 // if this program is buggy (or liblzma has
8136 // a bug), it may be e.g. LZMA_BUF_ERROR or
8137 // LZMA_OPTIONS_ERROR too.
8138 //
8139 // It is inconvenient to have a separate
8140 // error message for errors that should be
8141 // impossible to occur, but knowing the error
8142 // code is important for debugging. That's why
8143 // it is good to print the error code at least
8144 // when there is no good error message to show.
8145 msg = "Unknown error, possibly a bug";
8146 break;
8147 }
8148
8149 wxLogMessage("LZMA Encoder error: %s (error code %u)\n", msg, ret);
8150 return false;
8151 }
8152 }
8153}
8154#endif
8155
8156static bool CompressChart(wxString in, wxString out) {
8157#ifdef OCPN_USE_LZMA
8158 FILE* infile = fopen(in.mb_str(), "rb");
8159 if (!infile) return false;
8160
8161 FILE* outfile = fopen(out.mb_str(), "wb");
8162 if (!outfile) {
8163 fclose(infile);
8164 return false;
8165 }
8166
8167 lzma_stream strm = LZMA_STREAM_INIT;
8168 bool success = false;
8169 if (lzma_easy_encoder(&strm, LZMA_PRESET_DEFAULT, LZMA_CHECK_CRC64) ==
8170 LZMA_OK)
8171 success = compress(&strm, infile, outfile);
8172
8173 lzma_end(&strm);
8174 fclose(infile);
8175 fclose(outfile);
8176
8177 return success;
8178#endif
8179 return false;
8180}
8181
8182void options::OnButtonmigrateClick(wxCommandEvent& event) {
8183#ifdef __ANDROID__
8184
8185 // Run the chart migration assistant
8186 g_migrateDialog =
8187 // skip Folder scan
8188 new MigrateAssistantDialog(wxTheApp->GetTopWindow(), true);
8189 g_migrateDialog->SetSize(top_frame::Get()->GetSize());
8190 g_migrateDialog->Centre();
8191 g_migrateDialog->Raise();
8192 g_migrateDialog->ShowModal();
8193#endif
8194}
8195
8196void options::OnButtonEcdisHelp(wxCommandEvent& event) {
8197 wxString testFile = "/doc/iECDIS/index.html";
8198
8199 if (!::wxFileExists(testFile)) {
8200 wxString msg = _("The Inland ECDIS Manual is not available locally.");
8201 msg += "\n";
8202 msg +=
8203 _("Would you like to visit the iECDIS Manual website for more "
8204 "information?");
8205
8206 if (wxID_YES == OCPNMessageBox(NULL, msg, _("Inland ECDIS Manual"),
8207 wxYES_NO | wxCENTER, 60)) {
8208 wxLaunchDefaultBrowser("https://opencpn-manuals.github.io/inland-ecdis");
8209 }
8210 } else {
8211#ifdef __WXMSW__
8212 wxLaunchDefaultBrowser("file:///" + *GetpSharedDataLocation() + testFile);
8213#else
8214 wxLaunchDefaultBrowser("file://" + *GetpSharedDataLocation() + testFile);
8215#endif
8216 }
8217}
8218
8219void options::OnButtoncompressClick(wxCommandEvent& event) {
8220#if 0
8221 wxArrayInt pListBoxSelections;
8222 long item = -1;
8223 for (;;) {
8224 item = pActiveChartsList->GetNextItem(item, wxLIST_NEXT_ALL,
8225 wxLIST_STATE_SELECTED);
8226 if (item == -1) break;
8227 //pListBoxSelections.Add((int)item);
8228 item = -1; // Restart
8229 }
8230
8231 if (OCPNMessageBox(this, _("Compression will alter chart files on disk.\n\
8232This may make them incompatible with other programs or older versions of OpenCPN.\n\
8233Compressed charts may take slightly longer to load and display on some systems.\n\
8234They can be decompressed again using unxz or 7 zip programs."),
8235 _("OpenCPN Warning"),
8236 wxYES | wxCANCEL | wxCANCEL_DEFAULT | wxICON_WARNING) !=
8237 wxID_YES)
8238 return;
8239
8240 wxArrayString filespecs;
8241 filespecs.Add("*.kap");
8242 filespecs.Add("*.KAP");
8243 filespecs.Add("*.000");
8244
8245 // should we verify we are in a cm93 directory for these?
8246 filespecs.Add("*.A"), filespecs.Add("*.B"), filespecs.Add("*.C"),
8247 filespecs.Add("*.D");
8248 filespecs.Add("*.E"), filespecs.Add("*.F"), filespecs.Add("*.G"),
8249 filespecs.Add("*.Z");
8250
8251 wxGenericProgressDialog prog1(
8252 _("OpenCPN Compress Charts"), wxEmptyString,
8253 filespecs.GetCount() * pListBoxSelections.GetCount() + 1, this,
8254 wxPD_SMOOTH | wxPD_ELAPSED_TIME | wxPD_ESTIMATED_TIME |
8255 wxPD_REMAINING_TIME | wxPD_CAN_SKIP);
8256
8257 // Make sure the dialog is big enough to be readable
8258 wxSize sz = prog1.GetSize();
8259 sz.x = top_frame::Get()->GetClientSize().x * 8 / 10;
8260 prog1.SetSize(sz);
8261
8262 wxArrayString charts;
8263 for (unsigned int i = 0; i < pListBoxSelections.GetCount(); i++) {
8264 wxString dirname = pActiveChartsList->GetItemText(pListBoxSelections[i]);
8265 if (dirname.IsEmpty()) continue;
8266 // This is a fix for OSX, which appends EOL to results of
8267 // GetLineText()
8268 while ((dirname.Last() == wxChar(_T('\n'))) ||
8269 (dirname.Last() == wxChar(_T('\r'))))
8270 dirname.RemoveLast();
8271
8272 if (!wxDir::Exists(dirname)) continue;
8273
8274 wxDir dir(dirname);
8275 wxArrayString FileList;
8276 for (unsigned int j = 0; j < filespecs.GetCount(); j++) {
8277 dir.GetAllFiles(dirname, &FileList, filespecs[j]);
8278 bool skip = false;
8279 prog1.Update(i * filespecs.GetCount() + j, dirname + filespecs[j], &skip);
8280 if (skip) return;
8281 }
8282
8283 for (unsigned int j = 0; j < FileList.GetCount(); j++)
8284 charts.Add(FileList[j]);
8285 }
8286 prog1.Hide();
8287
8288 if (charts.GetCount() == 0) {
8289 OCPNMessageBox(this, _("No charts found to compress."), _("OpenCPN Info"));
8290 return;
8291 }
8292
8293 // TODO: make this use threads
8294 unsigned long total_size = 0, total_compressed_size = 0, count = 0;
8295 wxGenericProgressDialog prog(
8296 _("OpenCPN Compress Charts"), wxEmptyString, charts.GetCount() + 1, this,
8297 wxPD_SMOOTH | wxPD_ELAPSED_TIME | wxPD_ESTIMATED_TIME |
8298 wxPD_REMAINING_TIME | wxPD_CAN_SKIP);
8299
8300 prog.SetSize(sz);
8301
8302 for (unsigned int i = 0; i < charts.GetCount(); i++) {
8303 bool skip = false;
8304 prog.Update(i, charts[i], &skip);
8305 if (skip) break;
8306
8307 wxString compchart = charts[i] + ".xz";
8308 if (CompressChart(charts[i], compchart)) {
8309 total_size += wxFileName::GetSize(charts[i]).ToULong();
8310 total_compressed_size += wxFileName::GetSize(compchart).ToULong();
8311 wxRemoveFile(charts[i]);
8312 count++;
8313 }
8314 }
8315
8316 // report statistics
8317 double total_size_mb = total_size / 1024.0 / 1024.0;
8318 double total_compressed_size_mb = total_compressed_size / 1024.0 / 1024.0;
8319 OCPNMessageBox(
8320 this,
8321 wxString::Format(_("compressed %ld charts\nfrom %.1fMB to %.1fMB\nsaved "
8322 "%.1fMB (%.1f%%)"),
8323 count, total_size_mb, total_compressed_size_mb,
8324 total_size_mb - total_compressed_size_mb,
8325 (1 - total_compressed_size_mb / total_size_mb) * 100.0),
8326 _("OpenCPN Info"));
8327
8328 UpdateWorkArrayFromTextCtl();
8329
8330 if (m_pWorkDirList) {
8331 pActiveChartsList->DeleteAllItems();
8332 for (size_t id = 0; id < m_pWorkDirList->GetCount(); id++) {
8333 wxString dirname = m_pWorkDirList->Item(id).fullpath;
8334 wxListItem li;
8335 li.SetId(id);
8336 li.SetAlign(wxLIST_FORMAT_LEFT);
8337 li.SetText(dirname);
8338 li.SetColumn(0);
8339 long idx = pActiveChartsList->InsertItem(li);
8340 }
8341 }
8342
8343 k_charts |= CHANGE_CHARTS;
8344
8345 pScanCheckBox->Disable();
8346
8347 event.Skip();
8348#endif
8349}
8350
8351void options::OnDebugcheckbox1Click(wxCommandEvent& event) { event.Skip(); }
8352
8353void options::OnCancelClick(wxCommandEvent& event) {
8354 m_pListbook->ChangeSelection(0);
8355 comm_dialog->CancelSettings();
8356
8357 lastWindowPos = GetPosition();
8358 lastWindowSize = GetSize();
8359
8360 pConfig->SetPath("/Settings");
8361 pConfig->Write("OptionsSizeX", lastWindowSize.x);
8362 pConfig->Write("OptionsSizeY", lastWindowSize.y);
8363
8364#ifdef __ANDROID__
8365 androidEnableBackButton(true);
8366 androidEnableRotation();
8367 androidEnableOptionItems(true);
8368#endif
8369
8370 top_frame::Get()->ThawCharts();
8371 Hide();
8372 top_frame::Get()->EnableSettingsTool(true);
8373}
8374
8375void options::OnClose(wxCloseEvent& event) {
8376 m_pListbook->ChangeSelection(0);
8377
8378 lastWindowPos = GetPosition();
8379 lastWindowSize = GetSize();
8380
8381 pConfig->SetPath("/Settings");
8382 pConfig->Write("OptionsSizeX", lastWindowSize.x);
8383 pConfig->Write("OptionsSizeY", lastWindowSize.y);
8384
8385 m_callbacks.prepare_close(this, m_returnChanges);
8386 Hide();
8387}
8388
8389void options::OnFontChoice(wxCommandEvent& event) {
8390 wxString sel_text_element = m_itemFontElementListBox->GetStringSelection();
8391 m_font_element_array.Add(sel_text_element);
8392
8393 wxFont* pif = FontMgr::Get().GetFont(sel_text_element);
8394 wxColour init_color = FontMgr::Get().GetFontColor(sel_text_element);
8395
8396 m_textSample->SetFont(*pif);
8397 m_textSample->SetForegroundColour(init_color);
8398 m_itemBoxSizerFontPanel->Layout();
8399 event.Skip();
8400}
8401
8402void options::OnChooseFont(wxCommandEvent& event) {
8403#ifdef __ANDROID__
8404 androidDisableRotation();
8405#endif
8406
8407 wxString sel_text_element = m_itemFontElementListBox->GetStringSelection();
8408 m_font_element_array.Add(sel_text_element);
8409 wxFontData font_data;
8410
8411 wxFont* pif = FontMgr::Get().GetFont(sel_text_element);
8412 wxColour init_color = FontMgr::Get().GetFontColor(sel_text_element);
8413
8414 wxFontData init_font_data;
8415 if (pif) init_font_data.SetInitialFont(*pif);
8416 init_font_data.SetColour(init_color);
8417
8418#ifdef __WXGTK__
8419 if (g_Platform->getDisplaySize().y < 800) {
8420 ocpnGenericFontDialog dg(this, init_font_data);
8421 wxFont* qFont = dialogFont;
8422 dg.SetFont(*qFont);
8423
8424 int retval = dg.ShowModal();
8425 if (wxID_CANCEL != retval) {
8426 font_data = dg.GetFontData();
8427 wxFont font = font_data.GetChosenFont();
8428 wxFont* psfont = new wxFont(font);
8429 wxColor color = font_data.GetColour();
8430 FontMgr::Get().SetFont(sel_text_element, psfont, color);
8431 top_frame::Get()->UpdateAllFonts();
8432 m_bfontChanged = true;
8433 OnFontChoice(event);
8434 }
8435 } else
8436#endif
8437 {
8438#ifdef __WXGTK__
8439 wxFontDialog dg(this, init_font_data);
8440#else
8441 wxFontDialog dg(pParent, init_font_data);
8442#endif
8443
8444 wxFont* qFont = dialogFont;
8445 dg.SetFont(*qFont);
8446
8447#ifdef __WXQT__
8448 // Make sure that font dialog will fit on the screen without scrolling
8449 // We do this by setting the dialog font size "small enough" to show "n"
8450 // lines
8451 wxSize proposed_size = GetSize();
8452 float n_lines = 30;
8453 float font_size = dialogFont->GetPointSize();
8454
8455 if ((proposed_size.y / font_size) < n_lines) {
8456 float new_font_size = proposed_size.y / n_lines;
8457 wxFont* smallFont = new wxFont(*dialogFont);
8458 smallFont->SetPointSize(new_font_size);
8459 dg.SetFont(*smallFont);
8460 }
8461#endif
8462
8463 if (g_bresponsive) {
8464 dg.SetSize(GetSize());
8465 dg.Centre();
8466 }
8467
8468 int retval = dg.ShowModal();
8469 if (wxID_CANCEL != retval) {
8470 font_data = dg.GetFontData();
8471 wxFont font = font_data.GetChosenFont();
8472 wxFont* psfont = new wxFont(font);
8473 wxColor color = font_data.GetColour();
8474 FontMgr::Get().SetFont(sel_text_element, psfont, color);
8475 top_frame::Get()->UpdateAllFonts();
8476 m_bfontChanged = true;
8477 OnFontChoice(event);
8478 }
8479 }
8480
8481#ifdef __ANDROID__
8482 androidEnableRotation();
8483#endif
8484
8485 event.Skip();
8486}
8487
8488#if defined(__WXGTK__) || defined(__WXQT__)
8489void options::OnChooseFontColor(wxCommandEvent& event) {
8490 wxString sel_text_element = m_itemFontElementListBox->GetStringSelection();
8491 m_font_element_array.Add(sel_text_element);
8492
8493 wxColourData colour_data;
8494
8495 wxFont* pif = FontMgr::Get().GetFont(sel_text_element);
8496 wxColour init_color = FontMgr::Get().GetFontColor(sel_text_element);
8497
8498#ifdef __ANDROID__
8499 androidDisableRotation();
8500
8501 unsigned int cco = 0;
8502 cco |= 0xff;
8503 cco = cco << 8;
8504 cco |= init_color.Red();
8505 cco = cco << 8;
8506 cco |= init_color.Green();
8507 cco = cco << 8;
8508 cco |= init_color.Blue();
8509 unsigned int cc = androidColorPicker(cco);
8510
8511 wxColor cn;
8512 unsigned char blue = (unsigned char)cc % 256;
8513 unsigned char green = (unsigned char)(cc >> 8) % 256;
8514 ;
8515 unsigned char red = (unsigned char)(cc >> 16) % 256;
8516 cn.Set(red, green, blue);
8517
8518 FontMgr::Get().SetFont(sel_text_element, pif, cn);
8519
8520 top_frame::Get()->UpdateAllFonts();
8521 m_bfontChanged = true;
8522
8523 androidEnableRotation();
8524#else
8525 wxScrolledWindow* sw =
8526 new wxScrolledWindow(this, wxID_ANY, wxDefaultPosition, wxSize(400, 400));
8527
8528 wxColourData init_colour_data;
8529 init_colour_data.SetColour(init_color);
8530
8531 wxColourDialog dg(sw, &init_colour_data);
8532
8533 int retval = dg.ShowModal();
8534 if (wxID_CANCEL != retval) {
8535 colour_data = dg.GetColourData();
8536
8537 wxColor color = colour_data.GetColour();
8538 FontMgr::Get().SetFont(sel_text_element, pif, color);
8539
8540 top_frame::Get()->UpdateAllFonts();
8541 m_bfontChanged = true;
8542 OnFontChoice(event);
8543 }
8544
8545 sw->Destroy();
8546#endif
8547 event.Skip();
8548}
8549#endif
8550
8551void options::OnChartsPageChange(wxListbookEvent& event) {
8552 unsigned int i = event.GetSelection();
8553
8554 UpdateChartDirList();
8555
8556 // User selected Chart Groups Page?
8557 // If so, build the remaining UI elements
8558 if (2 == i) { // 2 is the index of "Chart Groups" page
8559 if (!groupsPanel->m_UIcomplete) groupsPanel->CompletePanel();
8560
8561 // Make sure any recently added chart dirs appear in the
8562 // Groups panel, making them available for addition to groups.
8563 UpdateWorkArrayFromDisplayPanel();
8564 groupsPanel->SetDBDirs(*m_pWorkDirList); // update the Groups tab
8565 groupsPanel->m_treespopulated = FALSE;
8566
8567 if (!groupsPanel->m_settingscomplete) {
8568 ::wxBeginBusyCursor();
8569 groupsPanel->CompleteInitialSettings();
8570 ::wxEndBusyCursor();
8571 } else if (!groupsPanel->m_treespopulated) {
8572 groupsPanel->PopulateTrees();
8573 groupsPanel->m_treespopulated = TRUE;
8574 }
8575 } else if (1 == i) { // Vector charts panel
8576 LoadS57();
8577 if (!m_bVectorInit) {
8578 SetInitialVectorSettings();
8579 UpdateOptionsUnits(); // sets depth values, overriding defaults
8580 }
8581 }
8582
8583 event.Skip(); // Allow continued event processing
8584}
8585
8586void options::OnPageChange(wxListbookEvent& event) {
8587 DoOnPageChange(event.GetSelection());
8588}
8589
8590void options::OnSubNBPageChange(wxNotebookEvent& event) {
8591 // In the case where wxNotebooks are nested, we need to identify the subpage
8592 // But otherwise do nothing
8593 if (event.GetEventObject()) {
8594 if (dynamic_cast<wxWindow*>(event.GetEventObject())) {
8595 wxWindow* win = dynamic_cast<wxWindow*>(event.GetEventObject());
8596 wxWindow* parent = dynamic_cast<wxWindow*>(win->GetParent());
8597 if (dynamic_cast<wxNotebook*>(parent)) {
8598 lastSubPage = event.GetSelection();
8599 return;
8600 }
8601 if (dynamic_cast<wxListbook*>(parent)) {
8602 lastSubPage = event.GetSelection();
8603 return;
8604 }
8605 }
8606 }
8607}
8608
8609void options::OnTopNBPageChange(wxNotebookEvent& event) {
8610 DoOnPageChange(event.GetSelection());
8611}
8612
8613void options::DoOnPageChange(size_t page) {
8614 unsigned int i = page;
8615
8616 // Sometimes there is a (-1) page selected.
8617 if (page > 10) return;
8618
8619 lastSubPage = 0; // Reset sub-page
8620
8621 lastPage = i;
8622
8623#ifndef __ANDROID__
8624 if (0 == i) { // Display
8625 if (m_sconfigSelect_single) m_sconfigSelect_single->Refresh(true);
8626 if (m_sconfigSelect_twovertical) m_sconfigSelect_twovertical->Refresh(true);
8627 }
8628#endif
8629 // User selected Chart Page?
8630 // If so, build the "Charts" page variants
8631 if (1 == i) { // 2 is the index of "Charts" page
8632 k_charts = VISIT_CHARTS;
8633 UpdateChartDirList();
8634 } else if (m_pageUI == i) { // 5 is the index of "User Interface" page
8635 if (!m_itemLangListBox) return;
8636#if wxUSE_XLOCALE
8637
8638 if (!m_bVisitLang) {
8639 ::wxBeginBusyCursor();
8640
8641 int current_language = plocale_def_lang->GetLanguage();
8642 wxString current_sel = wxLocale::GetLanguageName(current_language);
8643
8644 current_sel = GetOCPNKnownLanguage(g_locale);
8645
8646 int nLang = sizeof(lang_list) / sizeof(int);
8647#ifdef __WXMSW__
8648 // always add us english
8649 m_itemLangListBox->Append("English (U.S.)");
8650
8651 wxString lang_dir = g_Platform->GetSharedDataDir() + "share/locale/";
8652 for (int it = 1; it < nLang; it++) {
8653 if (wxLocale::IsAvailable(lang_list[it])) {
8654 wxLocale ltest(lang_list[it], 0);
8655 ltest.AddCatalog("opencpn");
8656 if (!ltest.IsLoaded("opencpn")) continue;
8657
8658 // Defaults
8659 wxString loc_lang_name = wxLocale::GetLanguageName(lang_list[it]);
8660 wxString widgets_lang_name = loc_lang_name;
8661 wxString lang_canonical =
8662 wxLocale::GetLanguageInfo(lang_list[it])->CanonicalName;
8663
8664 // Make opencpn substitutions
8665 wxString lang_suffix;
8666 loc_lang_name = GetOCPNKnownLanguage(lang_canonical, lang_suffix);
8667
8668 // Look explicitely to see if .mo is available
8669 wxString test_dir = lang_dir + lang_suffix;
8670 if (!wxDir::Exists(test_dir)) continue;
8671
8672 m_itemLangListBox->Append(loc_lang_name);
8673 }
8674 }
8675#else
8676 wxArrayString lang_array;
8677
8678 // always add us english
8679 lang_array.Add("en_US");
8680 for (int it = 0; it < nLang; it++) {
8681 {
8682 wxLog::EnableLogging(
8683 FALSE); // avoid "Cannot set locale to..." log message
8684
8685 wxLocale ltest(lang_list[it], 0);
8686#if wxCHECK_VERSION(2, 9, 0)
8687#ifdef __WXGTK__
8688 ltest.AddCatalogLookupPathPrefix(
8689 wxStandardPaths::Get().GetInstallPrefix() + "/share/locale");
8690#endif
8691#endif
8692 ltest.AddCatalog("opencpn");
8693
8694 wxLog::EnableLogging(TRUE);
8695 if (ltest.IsLoaded("opencpn")) {
8696 auto x = wxLocale::GetLanguageInfo(lang_list[it]);
8697 wxString s0;
8698 if (x)
8699 s0 = x->CanonicalName;
8700 else
8701 continue;
8702 wxString sl = wxLocale::GetLanguageName(lang_list[it]);
8703 if (wxNOT_FOUND == lang_array.Index(s0)) {
8704 lang_array.Add(s0);
8705 }
8706 }
8707 }
8708 }
8709
8710 for (unsigned int i = 0; i < lang_array.GetCount(); i++) {
8711 // Make opencpn substitutions
8712 wxString loc_lang_name = GetOCPNKnownLanguage(lang_array[i]);
8713 m_itemLangListBox->Append(loc_lang_name);
8714 }
8715#endif
8716 // BUGBUG
8717 // Remember that wxLocale ctor has the effect of changing the system
8718 // locale, including the "C" libraries.
8719 // It should then also happen that the locale should be switched back to
8720 // ocpn initial load setting
8721 // upon the dtor of the above wxLocale instantiations....
8722 // wxWidgets may do so internally, but there seems to be no effect upon
8723 // the system libraries, so that
8724 // functions like strftime() do not revert to the correct locale setting.
8725 // Also, the catalog for the application is not reloaded by the ctor, so
8726 // we must reload them directly
8727 // So as workaround, we reset the locale explicitely.
8728
8729 delete plocale_def_lang;
8730 plocale_def_lang = new wxLocale(current_language);
8731
8732 setlocale(LC_NUMERIC, "C");
8733 plocale_def_lang->AddCatalog("opencpn");
8734
8735 m_itemLangListBox->SetStringSelection(current_sel);
8736
8737 // Initialize Language tab
8738 const wxLanguageInfo* pli = wxLocale::FindLanguageInfo(g_locale);
8739 if (pli) {
8740 wxString clang = pli->Description;
8741 // m_itemLangListBox->SetValue(clang);
8742 }
8743
8744 m_bVisitLang = TRUE;
8745
8746 ::wxEndBusyCursor();
8747 }
8748#endif
8749 } else if (m_pagePlugins == i) { // 7 is the index of "Plugins" page
8750 m_bVisitPlugins = TRUE;
8751 top_frame::Get()->FreezeCharts();
8752
8753 // load the disabled plugins finally because the user might want to enable
8754 // them
8755 auto loader = PluginLoader::GetInstance();
8756 if (LoadAllPlugIns(false)) {
8757 delete m_pPlugInCtrl;
8758 m_pPlugInCtrl = NULL;
8759 delete m_PluginCatalogMgrPanel;
8760 m_PluginCatalogMgrPanel = NULL;
8761 itemBoxSizerPanelPlugins->Clear();
8762 }
8763
8764 if (!m_pPlugInCtrl) {
8765 // Build the PlugIn Manager Panel
8766 ::wxBeginBusyCursor();
8767
8768 m_pPlugInCtrl = new PluginListPanel(itemPanelPlugins, ID_PANELPIM,
8769 wxDefaultPosition, wxDefaultSize);
8770 m_pPlugInCtrl->SetScrollRate(m_scrollRate, m_scrollRate);
8771 itemBoxSizerPanelPlugins->Add(m_pPlugInCtrl, 01,
8772 wxEXPAND | wxGROW | wxALL, 4);
8773 if (g_pi_manager) g_pi_manager->SetListPanelPtr(m_pPlugInCtrl);
8774
8775 m_PluginCatalogMgrPanel = new CatalogMgrPanel(itemPanelPlugins);
8776 m_PluginCatalogMgrPanel->SetListPanelPtr(m_pPlugInCtrl);
8777
8778 itemBoxSizerPanelPlugins->Add(m_PluginCatalogMgrPanel, 0,
8779 wxEXPAND | wxALL, 4);
8780 itemBoxSizerPanelPlugins->Layout();
8781
8782 // Update the PlugIn page to reflect the state of individual selections
8783 m_pPlugInCtrl->UpdateSelections();
8784
8785 ::wxEndBusyCursor();
8786
8787 wxDEFINE_EVENT(EVT_COMPAT_OS_CHANGE, wxCommandEvent);
8788 obs::GlobalVar<wxString> compat_os(&g_compatOS);
8789 }
8790 k_plugins = TOOLBAR_CHANGED;
8791 // TODO Only if o-charts is touched?
8792 k_plugins |= FORCE_RELOAD;
8793 }
8794}
8795
8796wxString options::SelectSoundFile() {
8797 wxString sound_dir = g_Platform->GetSharedDataDir();
8798 sound_dir.Append("sounds");
8799 wxString sel_file;
8800 int response;
8801
8802#ifndef __ANDROID__
8803 wxFileDialog* popenDialog = new wxFileDialog(
8804 NULL, _("Select Sound File"), sound_dir, wxEmptyString,
8805 "WAV files (*.wav)|*.wav|All files (*.*)|*.*", wxFD_OPEN);
8806 if (g_bresponsive)
8807 popenDialog = g_Platform->AdjustFileDialogFont(this, popenDialog);
8808
8809 response = popenDialog->ShowModal();
8810 sel_file = popenDialog->GetPath();
8811 delete popenDialog;
8812
8813#else
8814 response = g_Platform->DoFileSelectorDialog(
8815 this, &sel_file, _("Select Sound File"), sound_dir, wxEmptyString, "*.*");
8816#endif
8817
8818 if (response == wxID_OK)
8819 return g_Platform->NormalizePath(sel_file);
8820 else
8821 return "";
8822}
8823
8824void options::OnButtonSelectSound(wxCommandEvent& event) {
8825 wxString sel_file = SelectSoundFile();
8826
8827 if (!sel_file.IsEmpty()) {
8828 g_sAIS_Alert_Sound_File = g_Platform->NormalizePath(sel_file);
8829 }
8830}
8831
8832void options::OnButtonTestSound(wxCommandEvent& event) {
8833 auto sound = o_sound::Factory();
8834 auto cmd_sound = dynamic_cast<o_sound::SystemCmdSound*>(sound);
8835 if (cmd_sound) cmd_sound->SetCmd(g_CmdSoundString.mb_str());
8836 sound->SetFinishedCallback([&](void* snd) { m_on_sound_done.Notify(snd); });
8837 sound->Load(m_soundPanelAIS->GetSoundFile(), g_iSoundDeviceIndex);
8838 sound->Play();
8839}
8840
8841wxString GetOCPNKnownLanguage(wxString lang_canonical, wxString& lang_dir) {
8842 wxString return_string;
8843 wxString dir_suffix;
8844
8845#if wxUSE_XLOCALE || !wxCHECK_VERSION(3, 0, 0)
8846
8847 if (lang_canonical == "en_US") {
8848 dir_suffix = "en";
8849 return_string = wxString("English (U.S.)", wxConvUTF8);
8850
8851 } else if ((lang_canonical == "cs_CZ") || (lang_canonical == "cs")) {
8852 dir_suffix = "cs";
8853 return_string = wxString("Čeština", wxConvUTF8);
8854
8855 } else if ((lang_canonical == "da_DK") || (lang_canonical == "da")) {
8856 dir_suffix = "da";
8857 return_string = wxString("Dansk", wxConvUTF8);
8858
8859 } else if ((lang_canonical == "de_DE") || (lang_canonical == "de")) {
8860 dir_suffix = "de";
8861 return_string = wxString("Deutsch", wxConvUTF8);
8862
8863 } else if ((lang_canonical == "et_EE") || (lang_canonical == "et")) {
8864 dir_suffix = "et";
8865 return_string = wxString("Eesti", wxConvUTF8);
8866
8867 } else if ((lang_canonical == "es_ES") || (lang_canonical == "es")) {
8868 dir_suffix = "es";
8869 return_string = wxString("Español", wxConvUTF8);
8870
8871 } else if ((lang_canonical == "fr_FR") || (lang_canonical == "fr")) {
8872 dir_suffix = "fr";
8873 return_string = wxString("Français", wxConvUTF8);
8874
8875 } else if ((lang_canonical == "it_IT") || (lang_canonical == "it")) {
8876 dir_suffix = "it";
8877 return_string = wxString("Italiano", wxConvUTF8);
8878
8879 } else if ((lang_canonical == "nl_NL") || (lang_canonical == "nl")) {
8880 dir_suffix = "nl";
8881 return_string = wxString("Nederlands", wxConvUTF8);
8882
8883 } else if ((lang_canonical == "pl_PL") || (lang_canonical == "pl")) {
8884 dir_suffix = "pl";
8885 return_string = wxString("Polski", wxConvUTF8);
8886
8887 } else if ((lang_canonical == "pt_PT") || (lang_canonical == "pt")) {
8888 dir_suffix = "pt_PT";
8889 return_string = wxString("Português", wxConvUTF8);
8890
8891 } else if ((lang_canonical == "pt_BR") || (lang_canonical == "pt_BR")) {
8892 dir_suffix = "pt_BR";
8893 return_string = wxString("Português Brasileiro", wxConvUTF8);
8894
8895 } else if ((lang_canonical == "ru_RU") || (lang_canonical == "ru")) {
8896 dir_suffix = "ru";
8897 return_string = wxString("Русский", wxConvUTF8);
8898
8899 } else if ((lang_canonical == "sv_SE") || (lang_canonical == "sv")) {
8900 dir_suffix = "sv";
8901 return_string = wxString("Svenska", wxConvUTF8);
8902
8903 } else if ((lang_canonical == "fi_FI") || (lang_canonical == "fi")) {
8904 dir_suffix = "fi_FI";
8905 return_string = wxString("Suomi", wxConvUTF8);
8906
8907 } else if ((lang_canonical == "nb_NO") || (lang_canonical == "nb")) {
8908 dir_suffix = "nb_NO";
8909 return_string = wxString("Norsk", wxConvUTF8);
8910
8911 } else if ((lang_canonical == "tr_TR") || (lang_canonical == "tr")) {
8912 dir_suffix = "tr_TR";
8913 return_string = wxString("Türkçe", wxConvUTF8);
8914
8915 } else if ((lang_canonical == "el_GR") || (lang_canonical == "el")) {
8916 dir_suffix = "el_GR";
8917 return_string = wxString("Ελληνικά", wxConvUTF8);
8918
8919 } else if ((lang_canonical == "hu_HU") || (lang_canonical == "hu")) {
8920 dir_suffix = "hu_HU";
8921 return_string = wxString("Magyar", wxConvUTF8);
8922
8923 } else if ((lang_canonical == "zh_TW") || (lang_canonical == "zh_TW")) {
8924 dir_suffix = "zh_TW";
8925 return_string = wxString("正體字", wxConvUTF8);
8926
8927 } else if ((lang_canonical == "zh_CN") || (lang_canonical == "zh_CN")) {
8928 dir_suffix = "zh_CN";
8929 return_string = wxString("Simplified Chinese", wxConvUTF8);
8930
8931 } else if ((lang_canonical == "ca_ES") || (lang_canonical == "ca")) {
8932 dir_suffix = "ca_ES";
8933 return_string = wxString("Catalan", wxConvUTF8);
8934
8935 } else if ((lang_canonical == "gl_ES") || (lang_canonical == "gl_ES")) {
8936 dir_suffix = "gl_ES";
8937 return_string = wxString("Galician", wxConvUTF8);
8938
8939 } else if ((lang_canonical == "ja_JP") || (lang_canonical == "ja_JP")) {
8940 dir_suffix = "ja_JP";
8941 return_string = wxString("Japanese", wxConvUTF8);
8942
8943 } else if ((lang_canonical == "vi_VN") || (lang_canonical == "vi_VN")) {
8944 dir_suffix = "vi_VN";
8945 return_string = wxString("Vietnamese", wxConvUTF8);
8946
8947 } else {
8948 dir_suffix = lang_canonical;
8949 const wxLanguageInfo* info = wxLocale::FindLanguageInfo(lang_canonical);
8950 if (info)
8951 return_string = info->Description;
8952 else
8953 return_string = lang_canonical;
8954 }
8955
8956 lang_dir = dir_suffix;
8957#endif
8958 return return_string;
8959}
8960
8961wxString GetOCPNKnownLanguage(const wxString lang_canonical) {
8962 wxString lang_dir;
8963 return GetOCPNKnownLanguage(lang_canonical, lang_dir);
8964}
8965
8966ChartGroupArray* ChartGroupsUI::CloneChartGroupArray(ChartGroupArray* s) {
8967 ChartGroupArray* d = new ChartGroupArray;
8968 for (unsigned int i = 0; i < s->GetCount(); i++) {
8969 ChartGroup* psg = s->Item(i);
8970 ChartGroup* pdg = new ChartGroup;
8971 pdg->m_group_name = psg->m_group_name;
8972 pdg->m_element_array.reserve(psg->m_element_array.size());
8973
8974 for (auto& elem : psg->m_element_array)
8975 pdg->m_element_array.push_back(elem);
8976
8977 d->Add(pdg);
8978 }
8979 return d;
8980}
8981
8982void ChartGroupsUI::EmptyChartGroupArray(ChartGroupArray* s) {
8983 if (!s) return;
8984
8985 // ChartGroups don't need anything special for delete, just calling the
8986 // destructor is enough.
8987 WX_CLEAR_ARRAY(*s);
8988}
8989
8990// Chart Groups dialog implementation
8991BEGIN_EVENT_TABLE(ChartGroupsUI, wxEvtHandler)
8992EVT_TREE_ITEM_EXPANDED(wxID_TREECTRL, ChartGroupsUI::OnNodeExpanded)
8993EVT_NOTEBOOK_PAGE_CHANGED(
8994 wxID_ANY,
8995 ChartGroupsUI::OnGroupPageChange) // This should work under Windows :-(
8996END_EVENT_TABLE()
8997
8998ChartGroupsUI::ChartGroupsUI(wxWindow* parent) : wxScrolledWindow(parent) {
8999 m_GroupSelectedPage = -1;
9000 m_pActiveChartsTree = 0;
9001 pParent = parent;
9002 lastSelectedCtl = NULL;
9003 allAvailableCtl = NULL;
9004 defaultAllCtl = NULL;
9005 iFont = NULL;
9006 m_pAddButton = NULL;
9007 m_pRemoveButton = NULL;
9008 m_pDeleteGroupButton = NULL;
9009 m_pNewGroupButton = NULL;
9010 m_pGroupArray = NULL;
9011 m_GroupNB = NULL;
9012 modified = false;
9013 m_UIcomplete = false;
9014 m_treespopulated = false;
9015 dialogFont = GetOCPNScaledFont(_("Dialog"));
9016}
9017
9018ChartGroupsUI::~ChartGroupsUI() {
9019 m_DirCtrlArray.Clear();
9020 m_GroupNB->Disconnect(
9021 wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED,
9022 wxNotebookEventHandler(ChartGroupsUI::OnGroupPageChange), NULL, this);
9023
9024 delete iFont;
9025}
9026
9027void ChartGroupsUI::SetInitialSettings() {
9028 m_settingscomplete = FALSE;
9029 m_treespopulated = FALSE;
9030}
9031
9032void ChartGroupsUI::PopulateTrees() {
9033 // Fill in the "Active chart" tree control
9034 // from the options dialog "Active Chart Directories" list
9035 wxArrayString dir_array;
9036 int nDir = m_db_dirs.GetCount();
9037 for (int i = 0; i < nDir; i++) {
9038 wxString dirname = m_db_dirs[i].fullpath;
9039 if (!dirname.IsEmpty()) dir_array.Add(dirname);
9040 }
9041
9042 PopulateTreeCtrl(allAvailableCtl->GetTreeCtrl(), dir_array,
9043 wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT),
9044 dialogFont);
9045 m_pActiveChartsTree = allAvailableCtl->GetTreeCtrl();
9046
9047 // Fill in the Page 0 tree control
9048 // from the options dialog "Active Chart Directories" list
9049 wxArrayString dir_array0;
9050 int nDir0 = m_db_dirs.GetCount();
9051 for (int i = 0; i < nDir0; i++) {
9052 wxString dirname = m_db_dirs[i].fullpath;
9053 if (!dirname.IsEmpty()) dir_array0.Add(dirname);
9054 }
9055 PopulateTreeCtrl(defaultAllCtl->GetTreeCtrl(), dir_array0,
9056 wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT), iFont);
9057}
9058
9059void ChartGroupsUI::CompleteInitialSettings() {
9060 PopulateTrees();
9061
9062 BuildNotebookPages(m_pGroupArray);
9063
9064 m_panel->GetSizer()->Layout();
9065
9066 m_settingscomplete = TRUE;
9067 m_treespopulated = TRUE;
9068}
9069
9070void ChartGroupsUI::PopulateTreeCtrl(wxTreeCtrl* ptc,
9071 const wxArrayString& dir_array,
9072 const wxColour& col, wxFont* pFont) {
9073 ptc->DeleteAllItems();
9074
9075 wxDirItemData* rootData = new wxDirItemData("Dummy", "Dummy", TRUE);
9076 wxString rootName;
9077 rootName = "Dummy";
9078 wxTreeItemId m_rootId = ptc->AddRoot(rootName, 3, -1, rootData);
9079 ptc->SetItemHasChildren(m_rootId);
9080
9081 wxString dirname;
9082 int nDir = dir_array.GetCount();
9083 for (int i = 0; i < nDir; i++) {
9084 wxString dirname = dir_array[i];
9085 if (!dirname.IsEmpty()) {
9086 wxDirItemData* dir_item = new wxDirItemData(dirname, dirname, TRUE);
9087 wxTreeItemId id = ptc->AppendItem(m_rootId, dirname, 0, -1, dir_item);
9088
9089 // wxWidgets bug workaraound (Ticket #10085)
9090 ptc->SetItemText(id, dirname);
9091 if (pFont) ptc->SetItemFont(id, *pFont);
9092
9093#ifndef __WXOSX__
9094 // On MacOS, use the default system dialog color, to honor Dark mode.
9095 ptc->SetItemTextColour(id, col);
9096#endif
9097 ptc->SetItemHasChildren(id);
9098 }
9099 }
9100}
9101
9102void ChartGroupsUI::OnInsertChartItem(wxCommandEvent& event) {
9103 wxString insert_candidate = allAvailableCtl->GetPath();
9104 if (!insert_candidate.IsEmpty()) {
9105 if (m_DirCtrlArray.GetCount()) {
9106 wxGenericDirCtrl* pDirCtrl = (m_DirCtrlArray[m_GroupSelectedPage]);
9107 ChartGroup* pGroup = m_pGroupArray->Item(m_GroupSelectedPage - 1);
9108 if (pDirCtrl) {
9109 wxTreeCtrl* ptree = pDirCtrl->GetTreeCtrl();
9110 if (ptree) {
9111 if (ptree->IsEmpty()) {
9112 wxDirItemData* rootData =
9113 new wxDirItemData(wxEmptyString, wxEmptyString, TRUE);
9114 wxString rootName = "Dummy";
9115 wxTreeItemId rootId = ptree->AddRoot(rootName, 3, -1, rootData);
9116
9117 ptree->SetItemHasChildren(rootId);
9118 }
9119
9120 wxTreeItemId root_Id = ptree->GetRootItem();
9121 wxDirItemData* dir_item =
9122 new wxDirItemData(insert_candidate, insert_candidate, TRUE);
9123 wxTreeItemId id =
9124 ptree->AppendItem(root_Id, insert_candidate, 0, -1, dir_item);
9125 if (wxDir::Exists(insert_candidate)) ptree->SetItemHasChildren(id);
9126 }
9127
9128 pGroup->m_element_array.push_back({insert_candidate});
9129 }
9130 }
9131 }
9132 modified = TRUE;
9133 allAvailableCtl->GetTreeCtrl()->UnselectAll();
9134 m_pAddButton->Disable();
9135
9136 wxGenericDirCtrl* pDirCtrl = (m_DirCtrlArray[m_GroupSelectedPage]);
9137 if (pDirCtrl) {
9138 wxTreeCtrl* ptree = pDirCtrl->GetTreeCtrl();
9139 if (ptree) ptree->Refresh();
9140 }
9141}
9142
9143void ChartGroupsUI::OnRemoveChartItem(wxCommandEvent& event) {
9144 if (m_DirCtrlArray.GetCount()) {
9145 wxGenericDirCtrl* pDirCtrl = (m_DirCtrlArray[m_GroupSelectedPage]);
9146 ChartGroup* pGroup = m_pGroupArray->Item(m_GroupSelectedPage - 1);
9147
9148 if (pDirCtrl) {
9149 wxString sel_item = pDirCtrl->GetPath();
9150
9151 wxTreeCtrl* ptree = pDirCtrl->GetTreeCtrl();
9152 if (ptree && ptree->GetCount()) {
9153 wxTreeItemId id = ptree->GetSelection();
9154 lastDeletedItem = id;
9155 if (id.IsOk()) {
9156 wxString branch_adder;
9157 int group_item_index =
9158 FindGroupBranch(pGroup, ptree, id, &branch_adder);
9159 if (group_item_index >= 0) {
9160 ChartGroupElement& pelement =
9161 pGroup->m_element_array[group_item_index];
9162 bool b_duplicate = FALSE;
9163 for (unsigned int k = 0; k < pelement.m_missing_name_array.size();
9164 k++) {
9165 if (pelement.m_missing_name_array[k] == sel_item) {
9166 b_duplicate = TRUE;
9167 break;
9168 }
9169 }
9170 if (!b_duplicate) {
9171 pelement.m_missing_name_array.Add(sel_item);
9172 }
9173
9174 // Special case...
9175 // If the selection is a branch itself,
9176 // Then delete from the tree, and delete from the group
9177 if (branch_adder == "") {
9178 ptree->Delete(id);
9179 pGroup->m_element_array.erase(pGroup->m_element_array.begin() +
9180 group_item_index);
9181 } else {
9182 ptree->SetItemTextColour(id, wxColour(128, 128, 128));
9183 // what about toggle back?
9184 }
9185 }
9186 }
9187 modified = TRUE;
9188 lastSelectedCtl->Unselect();
9189 lastSelectedCtl = 0;
9190 m_pRemoveButton->Disable();
9191
9192 wxGenericDirCtrl* pDirCtrl = (m_DirCtrlArray[m_GroupSelectedPage]);
9193 if (pDirCtrl) {
9194 wxTreeCtrl* ptree = pDirCtrl->GetTreeCtrl();
9195 if (ptree) ptree->Refresh();
9196 }
9197 }
9198 }
9199 }
9200 event.Skip();
9201}
9202
9203void ChartGroupsUI::OnGroupPageChange(wxNotebookEvent& event) {
9204 m_GroupSelectedPage = event.GetSelection();
9205 allAvailableCtl->GetTreeCtrl()->UnselectAll();
9206 if (lastSelectedCtl) {
9207 lastSelectedCtl->UnselectAll();
9208 lastSelectedCtl = 0;
9209 }
9210 m_pRemoveButton->Disable();
9211 m_pAddButton->Disable();
9212
9213 // Disable delete option for "All Charts" group
9214 if (m_GroupSelectedPage == 0) {
9215 if (m_pDeleteGroupButton) m_pDeleteGroupButton->Disable();
9216 } else {
9217 if (m_pDeleteGroupButton) m_pDeleteGroupButton->Enable();
9218 }
9219}
9220
9221void ChartGroupsUI::OnAvailableSelection(wxTreeEvent& event) {
9222 wxObject* evtObj = event.GetEventObject();
9223 if (allAvailableCtl && (evtObj == allAvailableCtl->GetTreeCtrl())) {
9224 wxTreeItemId item = allAvailableCtl->GetTreeCtrl()->GetSelection();
9225 if (item && item.IsOk() && m_GroupSelectedPage > 0) {
9226 m_pAddButton->Enable();
9227 } else {
9228 m_pAddButton->Disable();
9229 }
9230 } else {
9231 lastSelectedCtl = dynamic_cast<wxTreeCtrl*>(evtObj);
9232 if (!lastSelectedCtl) goto out;
9233 wxTreeItemId item = lastSelectedCtl->GetSelection();
9234 if (item && item.IsOk() && m_GroupSelectedPage > 0) {
9235 // We need a trick for wxGTK here, since it gives us a Selection
9236 // event with the just deleted element after OnRemoveChartItem()
9237 wxGenericDirCtrl* dirCtrl =
9238 dynamic_cast<wxGenericDirCtrl*>(lastSelectedCtl->GetParent());
9239 if (!dirCtrl) goto out;
9240 wxString itemPath = dirCtrl->GetPath();
9241 if (!itemPath.IsEmpty()) m_pRemoveButton->Enable();
9242 } else {
9243 m_pRemoveButton->Disable();
9244 }
9245 }
9246
9247out:
9248 event.Skip();
9249}
9250
9251void ChartGroupsUI::OnNewGroup(wxCommandEvent& event) {
9252 wxTextEntryDialog* pd = new wxTextEntryDialog();
9253 wxFont* qFont = GetOCPNScaledFont(_("Dialog"));
9254 pd->SetFont(*qFont);
9255
9256 pd->Create(m_panel, _("Enter Group Name"), _("New Chart Group"));
9257
9258#ifdef __ANDROID__
9259 androidDisableRotation();
9260#endif
9261
9262 if (pd->ShowModal() == wxID_OK) {
9263 if (pd->GetValue().Length()) {
9264 AddEmptyGroupPage(pd->GetValue());
9265 ChartGroup* pGroup = new ChartGroup;
9266 pGroup->m_group_name = pd->GetValue();
9267 m_pGroupArray->Add(pGroup);
9268
9269 m_GroupSelectedPage =
9270 m_GroupNB->GetPageCount() - 1; // select the new page
9271 m_GroupNB->ChangeSelection(m_GroupSelectedPage);
9272 m_pDeleteGroupButton->Enable();
9273 modified = TRUE;
9274 }
9275 }
9276 delete pd;
9277
9278#ifdef __ANDROID__
9279 androidEnableRotation();
9280#endif
9281}
9282
9283void ChartGroupsUI::OnDeleteGroup(wxCommandEvent& event) {
9284 if (0 != m_GroupSelectedPage) {
9285 m_DirCtrlArray.RemoveAt(m_GroupSelectedPage);
9286 if (m_pGroupArray) m_pGroupArray->RemoveAt(m_GroupSelectedPage - 1);
9287 m_GroupNB->DeletePage(m_GroupSelectedPage);
9288 modified = TRUE;
9289 }
9290 if (m_GroupSelectedPage <= 0) {
9291 m_pAddButton->Disable();
9292 m_pDeleteGroupButton->Disable();
9293 }
9294}
9295
9296int ChartGroupsUI::FindGroupBranch(ChartGroup* pGroup, wxTreeCtrl* ptree,
9297 wxTreeItemId item, wxString* pbranch_adder) {
9298 wxString branch_name;
9299 wxString branch_adder;
9300
9301 wxTreeItemId current_node = item;
9302 while (current_node.IsOk()) {
9303 wxTreeItemId parent_node = ptree->GetItemParent(current_node);
9304 if (!parent_node) break;
9305
9306 if (parent_node == ptree->GetRootItem()) {
9307 branch_name = ptree->GetItemText(current_node);
9308 break;
9309 }
9310
9311 branch_adder.Prepend(ptree->GetItemText(current_node));
9312 branch_adder.Prepend(wxString(wxFILE_SEP_PATH));
9313
9314 current_node = ptree->GetItemParent(current_node);
9315 }
9316
9317 // Find the index and element pointer of the target branch in the Group
9318 unsigned int target_item_index = -1;
9319
9320 for (unsigned int i = 0; i < pGroup->m_element_array.size(); i++) {
9321 const wxString& target = pGroup->m_element_array[i].m_element_name;
9322 if (branch_name == target) {
9323 target_item_index = i;
9324 break;
9325 }
9326 }
9327
9328 if (pbranch_adder) *pbranch_adder = branch_adder;
9329
9330 return target_item_index;
9331}
9332
9333void ChartGroupsUI::OnNodeExpanded(wxTreeEvent& event) {
9334 wxTreeItemId node = event.GetItem();
9335
9336 if (m_GroupSelectedPage <= 0) return;
9337 wxGenericDirCtrl* pDirCtrl = (m_DirCtrlArray[m_GroupSelectedPage]);
9338 ChartGroup* pGroup = m_pGroupArray->Item(m_GroupSelectedPage - 1);
9339 if (!pDirCtrl) return;
9340
9341 wxTreeCtrl* ptree = pDirCtrl->GetTreeCtrl();
9342 wxString branch_adder;
9343 int target_item_index = FindGroupBranch(pGroup, ptree, node, &branch_adder);
9344 if (target_item_index < 0) return;
9345 const ChartGroupElement& target_element =
9346 pGroup->m_element_array[target_item_index];
9347 const wxString& branch_name = target_element.m_element_name;
9348
9349 // Walk the children of the expanded node, marking any items which appear in
9350 // the "missing" list
9351 if (!target_element.m_missing_name_array.GetCount()) return;
9352 wxString full_root = branch_name;
9353 full_root += branch_adder;
9354 full_root += wxString(wxFILE_SEP_PATH);
9355
9356 wxTreeItemIdValue cookie;
9357 wxTreeItemId child = ptree->GetFirstChild(node, cookie);
9358 while (child.IsOk()) {
9359 wxString target_string = full_root;
9360 target_string += ptree->GetItemText(child);
9361
9362 for (unsigned int k = 0; k < target_element.m_missing_name_array.GetCount();
9363 k++) {
9364 if (target_element.m_missing_name_array[k] == target_string) {
9365 ptree->SetItemTextColour(child, wxColour(128, 128, 128));
9366 break;
9367 }
9368 }
9369 child = ptree->GetNextChild(node, cookie);
9370 }
9371}
9372
9373void ChartGroupsUI::BuildNotebookPages(ChartGroupArray* pGroupArray) {
9374 ClearGroupPages();
9375
9376 for (unsigned int i = 0; i < pGroupArray->GetCount(); i++) {
9377 ChartGroup* pGroup = pGroupArray->Item(i);
9378 wxTreeCtrl* ptc = AddEmptyGroupPage(pGroup->m_group_name);
9379
9380 wxString itemname;
9381 int nItems = pGroup->m_element_array.size();
9382 for (int i = 0; i < nItems; i++) {
9383 const wxString& itemname = pGroup->m_element_array[i].m_element_name;
9384 if (!itemname.IsEmpty()) {
9385 wxDirItemData* dir_item = new wxDirItemData(itemname, itemname, TRUE);
9386 wxTreeItemId id =
9387 ptc->AppendItem(ptc->GetRootItem(), itemname, 0, -1, dir_item);
9388
9389 if (wxDir::Exists(itemname)) ptc->SetItemHasChildren(id);
9390 }
9391 }
9392 }
9393}
9394
9395wxTreeCtrl* ChartGroupsUI::AddEmptyGroupPage(const wxString& label) {
9396 wxGenericDirCtrl* GroupDirCtl =
9397 new wxGenericDirCtrl(m_GroupNB, wxID_ANY, "TESTDIR");
9398 m_GroupNB->AddPage(GroupDirCtl, label);
9399
9400 wxTreeCtrl* ptree = GroupDirCtl->GetTreeCtrl();
9401 ptree->DeleteAllItems();
9402
9403 wxDirItemData* rootData =
9404 new wxDirItemData(wxEmptyString, wxEmptyString, TRUE);
9405 wxString rootName = "Dummy";
9406 wxTreeItemId rootId = ptree->AddRoot(rootName, 3, -1, rootData);
9407 ptree->SetItemHasChildren(rootId);
9408
9409 m_DirCtrlArray.Add(GroupDirCtl);
9410
9411 return ptree;
9412}
9413
9414void ChartGroupsUI::ClearGroupPages() {
9415 if (m_GroupNB->GetPageCount() == 0) return;
9416
9417 for (unsigned int i = m_GroupNB->GetPageCount() - 1; i > 0; i--) {
9418 m_DirCtrlArray.RemoveAt(i);
9419 m_GroupNB->DeletePage(i);
9420 }
9421}
9422
9423void options::OnInsertTideDataLocation(wxCommandEvent& event) {
9424 wxString sel_file;
9425 int response = wxID_CANCEL;
9426
9427#ifndef __ANDROID__
9428 wxFileDialog* popenDialog = new wxFileDialog(
9429 NULL, _("Select Tide/Current Data"), g_TCData_Dir, "",
9430 "Tide/Current Data files (*.IDX; *.TCD)|*.IDX;*.idx;*.TCD;*.tcd|All "
9431 "files (*.*)|*.*",
9432 wxFD_OPEN);
9433 if (g_bresponsive)
9434 popenDialog = g_Platform->AdjustFileDialogFont(this, popenDialog);
9435
9436 response = popenDialog->ShowModal();
9437 sel_file = popenDialog->GetPath();
9438 delete popenDialog;
9439
9440#else
9441 wxString path;
9442 response = g_Platform->DoFileSelectorDialog(
9443 this, &path, _("Select Tide/Current Data"), g_TCData_Dir, "", "*.*");
9444 sel_file = path;
9445#endif
9446
9447 if (response == wxID_OK) {
9448 wxListItem li;
9449 int id = tcDataSelected->GetItemCount(); // next index
9450 li.SetId(id);
9451 long idx = tcDataSelected->InsertItem(li);
9452 tcDataSelected->SetItem(id, 0, g_Platform->NormalizePath(sel_file));
9453
9454 // Record the currently selected directory for later use
9455 wxFileName fn(sel_file);
9456 wxString data_dir = fn.GetPath();
9457 g_TCData_Dir = g_Platform->NormalizePath(data_dir);
9458 }
9459}
9460
9461void options::OnRemoveTideDataLocation(wxCommandEvent& event) {
9462 long item = -1;
9463 for (;;) {
9464 item = tcDataSelected->GetNextItem(item, wxLIST_NEXT_ALL,
9465 wxLIST_STATE_SELECTED);
9466 if (item == -1) break;
9467 tcDataSelected->DeleteItem(item);
9468 item = -1; // Restart
9469 }
9470}
9471
9472// OpenGLOptionsDlg
9473enum { ID_BUTTON_REBUILD, ID_BUTTON_CLEAR };
9474
9475#ifdef ocpnUSE_GL
9476BEGIN_EVENT_TABLE(OpenGLOptionsDlg, wxDialog)
9477EVT_BUTTON(ID_BUTTON_REBUILD, OpenGLOptionsDlg::OnButtonRebuild)
9478EVT_BUTTON(ID_BUTTON_CLEAR, OpenGLOptionsDlg::OnButtonClear)
9479END_EVENT_TABLE()
9480
9481OpenGLOptionsDlg::OpenGLOptionsDlg(wxWindow* parent)
9482 : wxDialog(parent, wxID_ANY, "OpenGL Options", wxDefaultPosition,
9483 wxDefaultSize,
9484 wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER
9485#ifdef __WXOSX__
9486 | wxSTAY_ON_TOP
9487#endif
9488 ),
9489 m_brebuild_cache(FALSE) {
9490
9491 wxFont* dialogFont = GetOCPNScaledFont(_("Dialog"));
9492 SetFont(*dialogFont);
9493
9494 wxBoxSizer* mainSizer = new wxBoxSizer(wxVERTICAL);
9495 wxFlexGridSizer* flexSizer = new wxFlexGridSizer(2);
9496
9497 m_cbTextureCompression =
9498 new wxCheckBox(this, wxID_ANY,
9499 g_bGLexpert ? _("Texture Compression")
9500 : _("Texture Compression with Caching"));
9501 m_cbTextureCompressionCaching =
9502 new wxCheckBox(this, wxID_ANY, _("Texture Compression Caching"));
9503 m_memorySize =
9504 new wxStaticText(this, wxID_ANY, _("Texture Memory Size (MB)"));
9505 m_sTextureMemorySize = new wxSpinCtrl(this);
9506 m_sTextureMemorySize->SetRange(1, 16384);
9507 m_cacheSize =
9508 new wxStaticText(this, wxID_ANY, _("Size: ") + GetTextureCacheSize());
9509 wxButton* btnRebuild =
9510 new wxButton(this, ID_BUTTON_REBUILD, _("Rebuild Texture Cache"));
9511 wxButton* btnClear =
9512 new wxButton(this, ID_BUTTON_CLEAR, _("Clear Texture Cache"));
9513 btnRebuild->Enable(g_GLOptions.m_bTextureCompressionCaching);
9514 if (!g_bopengl || g_raster_format == GL_RGB) btnRebuild->Disable();
9515 btnClear->Enable(g_GLOptions.m_bTextureCompressionCaching);
9516 m_cbPolygonSmoothing = new wxCheckBox(this, wxID_ANY, _("Polygon Smoothing"));
9517 m_cbLineSmoothing = new wxCheckBox(this, wxID_ANY, _("Line Smoothing"));
9518 m_cbSoftwareGL =
9519 new wxCheckBox(this, wxID_ANY, _("Software OpenGL (restart OpenCPN)"));
9520 m_cbUseAcceleratedPanning =
9521 new wxCheckBox(this, wxID_ANY, _("Use Accelerated Panning"));
9522
9523 flexSizer->Add(new wxStaticText(this, wxID_ANY, _("Texture Settings")), 0,
9524 wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL, 5);
9525 flexSizer->Add(m_cbTextureCompression, 0, wxALL | wxEXPAND, 5);
9526 flexSizer->AddSpacer(0);
9527 flexSizer->Add(m_cbTextureCompressionCaching, 0, wxALL | wxEXPAND, 5);
9528 flexSizer->Add(m_memorySize, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL, 5);
9529 flexSizer->Add(m_sTextureMemorySize, 0, wxALL | wxEXPAND, 5);
9530 flexSizer->Add(new wxStaticText(this, wxID_ANY, _("Texture Cache")), 0,
9531 wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL, 5);
9532 flexSizer->Add(m_cacheSize, 0, wxALIGN_CENTER | wxALIGN_CENTER_VERTICAL, 5);
9533 flexSizer->AddSpacer(0);
9534 flexSizer->Add(btnRebuild, 0, wxALL | wxEXPAND, 5);
9535 flexSizer->AddSpacer(0);
9536 flexSizer->Add(btnClear, 0, wxALL | wxEXPAND, 5);
9537 flexSizer->Add(new wxStaticText(this, wxID_ANY, _("Miscellaneous")), 0,
9538 wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL, 5);
9539 flexSizer->Add(m_cbPolygonSmoothing, 0, wxALL | wxEXPAND, 5);
9540 flexSizer->AddSpacer(0);
9541 flexSizer->Add(m_cbLineSmoothing, 0, wxALL | wxEXPAND, 5);
9542 flexSizer->AddSpacer(0);
9543 flexSizer->AddSpacer(0);
9544 flexSizer->Add(m_cbSoftwareGL, 0, wxALL | wxEXPAND, 5);
9545 flexSizer->AddSpacer(0);
9546 flexSizer->Add(m_cbUseAcceleratedPanning, 0, wxALL | wxEXPAND, 5);
9547 flexSizer->AddGrowableCol(1);
9548 mainSizer->Add(flexSizer, 0, wxALL | wxEXPAND, 5);
9549
9550 wxStdDialogButtonSizer* btnSizer = new wxStdDialogButtonSizer();
9551 btnSizer->AddButton(new wxButton(this, wxID_OK));
9552 btnSizer->AddButton(new wxButton(this, wxID_CANCEL, _("Cancel")));
9553 btnSizer->Realize();
9554
9555 mainSizer->AddStretchSpacer();
9556 mainSizer->Add(btnSizer, 0, wxALL | wxEXPAND, 5);
9557
9558 Populate();
9559
9560 SetSizer(mainSizer);
9561 mainSizer->SetSizeHints(this);
9562 Centre();
9563}
9564
9565bool OpenGLOptionsDlg::GetAcceleratedPanning() const {
9566 return m_cbUseAcceleratedPanning->GetValue();
9567}
9568
9569bool OpenGLOptionsDlg::GetTextureCompression() const {
9570 return m_cbTextureCompression->GetValue();
9571}
9572
9573bool OpenGLOptionsDlg::GetPolygonSmoothing() const {
9574 return m_cbPolygonSmoothing->GetValue();
9575}
9576
9577bool OpenGLOptionsDlg::GetLineSmoothing() const {
9578 return m_cbLineSmoothing->GetValue();
9579}
9580
9581bool OpenGLOptionsDlg::GetSoftwareGL() const {
9582 return m_cbSoftwareGL->GetValue();
9583}
9584
9585bool OpenGLOptionsDlg::GetTextureCompressionCaching() const {
9586 return m_cbTextureCompressionCaching->GetValue();
9587}
9588
9589bool OpenGLOptionsDlg::GetRebuildCache() const { return m_brebuild_cache; }
9590
9591int OpenGLOptionsDlg::GetTextureMemorySize() const {
9592 return m_sTextureMemorySize->GetValue();
9593}
9594
9595void OpenGLOptionsDlg::Populate() {
9596 m_cbTextureCompression->SetValue(g_GLOptions.m_bTextureCompression);
9597 /* disable caching if unsupported */
9598 // if (b_glEntryPointsSet && !s_glCompressedTexImage2D) {
9599 // g_GLOptions.m_bTextureCompressionCaching = FALSE;
9600 // m_cbTextureCompression->Disable();
9601 // m_cbTextureCompression->SetValue(FALSE);
9602 // }
9603
9604 m_cbTextureCompressionCaching->Show(g_bGLexpert);
9605 m_memorySize->Show(g_bGLexpert);
9606 m_sTextureMemorySize->Show(g_bGLexpert);
9607 if (g_bGLexpert) {
9608 m_cbTextureCompressionCaching->SetValue(
9609 g_GLOptions.m_bTextureCompressionCaching);
9610 m_sTextureMemorySize->SetValue(g_GLOptions.m_iTextureMemorySize);
9611 }
9612 m_cbPolygonSmoothing->SetValue(g_GLOptions.m_GLPolygonSmoothing);
9613 m_cbLineSmoothing->SetValue(g_GLOptions.m_GLLineSmoothing);
9614
9615#if defined(__UNIX__) && !defined(__ANDROID__) && !defined(__WXOSX__)
9616 if (top_frame::Get()->GetWxGlCanvas()) {
9617 if (top_frame::Get()->GetGlVersionString().Upper().Find("MESA") !=
9618 wxNOT_FOUND)
9619 m_cbSoftwareGL->SetValue(g_bSoftwareGL);
9620 }
9621#else
9622 m_cbSoftwareGL->Hide();
9623#endif
9624
9625 wxFont* dialogFont = GetOCPNScaledFont(_("Dialog"));
9626 SetFont(*dialogFont);
9627
9628 if (g_bGLexpert) {
9629 if (top_frame::Get()->GetWxGlCanvas()) {
9630 if (top_frame::Get()
9631 ->GetAbstractPrimaryCanvas()
9632 ->CanAccelerateGlPanning()) {
9633 m_cbUseAcceleratedPanning->Enable();
9634 m_cbUseAcceleratedPanning->SetValue(
9635 g_GLOptions.m_bUseAcceleratedPanning);
9636 } else {
9637 m_cbUseAcceleratedPanning->SetValue(FALSE);
9638 m_cbUseAcceleratedPanning->Disable();
9639 }
9640 } else {
9641 m_cbUseAcceleratedPanning->SetValue(g_GLOptions.m_bUseAcceleratedPanning);
9642 }
9643 } else {
9644 m_cbUseAcceleratedPanning->SetValue(g_GLOptions.m_bUseAcceleratedPanning);
9645 m_cbUseAcceleratedPanning->Disable();
9646 }
9647}
9648
9649void OpenGLOptionsDlg::OnButtonRebuild(wxCommandEvent& event) {
9650 if (g_GLOptions.m_bTextureCompressionCaching) {
9651 m_brebuild_cache = TRUE;
9652 EndModal(wxID_CANCEL);
9653 }
9654}
9655
9656void OpenGLOptionsDlg::OnButtonClear(wxCommandEvent& event) {
9657 if (g_bopengl && g_glTextureManager) {
9658 ::wxBeginBusyCursor();
9659 g_glTextureManager->ClearAllRasterTextures();
9660
9661 wxString path = g_Platform->GetPrivateDataDir();
9662 appendOSDirSlash(&path);
9663 path.append("raster_texture_cache");
9664
9665 if (::wxDirExists(path)) {
9666 wxArrayString files;
9667 size_t nfiles = wxDir::GetAllFiles(path, &files);
9668 for (unsigned int i = 0; i < files.GetCount(); i++)
9669 ::wxRemoveFile(files[i]);
9670 }
9671
9672 m_cacheSize->SetLabel(_("Size: ") + GetTextureCacheSize());
9673 ::wxEndBusyCursor();
9674 }
9675}
9676
9677wxString OpenGLOptionsDlg::GetTextureCacheSize() {
9678 wxString path = g_Platform->GetPrivateDataDir();
9679 appendOSDirSlash(&path);
9680 path.append("raster_texture_cache");
9681 long long total = 0;
9682
9683 if (::wxDirExists(path)) {
9684 wxArrayString files;
9685 size_t nfiles = wxDir::GetAllFiles(path, &files);
9686 for (unsigned int i = 0; i < files.GetCount(); i++)
9687 total += wxFile(files[i]).Length();
9688 }
9689 double mb = total / (1024.0 * 1024.0);
9690 if (mb < 10000.0) return wxString::Format("%.1f MB", mb);
9691 mb = mb / 1024.0;
9692 return wxString::Format("%.1f GB", mb);
9693}
9694#endif
9695//-------------------------------------------------------------------------------------------------
9696// CanvasConfig selection panel
9697//-------------------------------------------------------------------------------------------------
9698
9699BEGIN_EVENT_TABLE(CanvasConfigSelect, wxPanel)
9700EVT_PAINT(CanvasConfigSelect::OnPaint)
9701END_EVENT_TABLE()
9702
9703CanvasConfigSelect::CanvasConfigSelect(wxWindow* parent, options* parentOptions,
9704 wxWindowID id, wxBitmap& bmp,
9705 const wxPoint& pos, const wxSize& size)
9706 : wxPanel(parent, id, pos, size, wxBORDER_NONE) {
9707 m_parentOptions = parentOptions;
9708 m_bmpNormal = bmp;
9709 m_borderWidth = 5;
9710 SetSelected(false);
9711
9712 int refHeight = GetCharHeight();
9713 // SetMinSize(wxSize(-1, 5 * refHeight));
9714 SetMinSize(wxSize(bmp.GetSize().x + m_borderWidth * 2,
9715 bmp.GetSize().y + m_borderWidth * 2));
9716
9717 Connect(wxEVT_LEFT_DOWN,
9718 wxMouseEventHandler(CanvasConfigSelect::OnMouseSelected), NULL, this);
9719}
9720
9721CanvasConfigSelect::~CanvasConfigSelect() {}
9722
9723void CanvasConfigSelect::OnMouseSelected(wxMouseEvent& event) {
9724 if (!m_bSelected) {
9725 SetSelected(true);
9726 } else {
9727 SetSelected(false);
9728 }
9729 if (m_parentOptions)
9730 m_parentOptions->OnCanvasConfigSelectClick(GetId(), GetSelected());
9731}
9732
9733void CanvasConfigSelect::SetSelected(bool selected) {
9734 m_bSelected = selected;
9735
9736 if (selected) {
9737 m_boxColour =
9738 wxSystemSettings::GetColour(wxSystemColour::wxSYS_COLOUR_HIGHLIGHT);
9739 } else {
9740 m_boxColour =
9741 wxSystemSettings::GetColour(wxSystemColour::wxSYS_COLOUR_WINDOW);
9742 }
9743
9744 Refresh(true);
9745}
9746
9747void CanvasConfigSelect::OnPaint(wxPaintEvent& event) {
9748 int width, height;
9749 GetSize(&width, &height);
9750 wxPaintDC dc(this);
9751
9752 dc.SetBackground(*wxLIGHT_GREY);
9753
9754 dc.SetPen(*wxTRANSPARENT_PEN);
9755 dc.SetBrush(wxBrush(GetBackgroundColour()));
9756 dc.DrawRectangle(GetVirtualSize());
9757
9758 if (m_bSelected) {
9759 dc.SetBrush(wxBrush(m_boxColour));
9760 dc.SetPen(wxPen(
9761 wxSystemSettings::GetColour(wxSystemColour::wxSYS_COLOUR_HIGHLIGHT),
9762 3));
9763 dc.DrawRoundedRectangle(0, 0, width - 1, height - 1, height / 10);
9764 } else {
9765 dc.SetBrush(wxBrush(m_boxColour));
9766 dc.SetPen(wxPen(
9767 wxSystemSettings::GetColour(wxSystemColour::wxSYS_COLOUR_HIGHLIGHT),
9768 3));
9769 dc.DrawRoundedRectangle(0, 0, width - 1, height - 1, height / 10);
9770 }
9771
9772 dc.DrawBitmap(m_bmpNormal, m_borderWidth, m_borderWidth, false);
9773}
ArrayOfMmsiProperties g_MMSI_Props_Array
Global instance.
unsigned g_OwnShipmmsi
Global instance.
AisDecoder * g_pAIS
Global instance.
Class AisDecoder and helpers.
Global state for AIS decoder.
AIS target definitions.
Wrapper for creating a ChartCtx based on global vars.
ChartDB * ChartData
Global instance.
Definition chartdb.cpp:71
ChartGroupArray * g_pGroupArray
Global instance.
Definition chartdbs.cpp:61
Basic chart info storage.
arrayofCanvasPtr g_canvasArray
Global instance.
Definition chcanv.cpp:173
Generic Chart canvas base.
double GetDisplayDIPMult(wxWindow *win)
Get the display scaling factor for DPI-aware rendering.
Represents a user-defined collection of logically related charts.
Definition chartdbs.h:499
ConfigCreateDialog(wxWindow *parent, wxWindowID id=wxID_ANY, const wxString &caption=wxEmptyString, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=0)
Class ConfigCreateDialog.
Definition options.cpp:676
wxColour GetFontColor(const wxString &TextElement) const
Gets the text color for a UI element.
Definition font_mgr.cpp:110
bool SetFont(const wxString &TextElement, wxFont *pFont, wxColour color)
Sets the default font properties for a UI element.
Definition font_mgr.cpp:302
wxFont * GetFont(const wxString &TextElement, int requested_font_size=0)
Get a font object for a UI element.
Definition font_mgr.cpp:193
MMSIEditDialog(MmsiProperties *props, wxWindow *parent, wxWindowID id=wxID_ANY, const wxString &caption=wxEmptyString, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=0)
Class MMSIEditDialog.
Definition options.cpp:755
Process incoming AIS messages.
Definition ais_decoder.h:76
static double ui_to_config(int slider_pos)
Convert a slider scale 1-100 value to configuration value 1.02..3.0.
Definition navutil.h:157
wxSize getDisplaySize()
Get the display size in logical pixels.
double GetDisplaySizeMM()
Get the width of the screen in millimeters.
obs::EventVar m_on_sp_sound_done
Notified with a OCPN_Sound* pointer when sound has completed.
Definition options.cpp:4824
Custom event class for OpenCPN's notification system.
Generic event handling between for example MVC Model and Controller based on a shared EventVar variab...
Definition evtvar.h:78
Wrapper for global variable, supports notification events when value changes.
Definition global_var.h:69
Define an action to be performed when a KeyProvider is notified.
Definition observable.h:293
obs::EventVar m_on_sound_done
Notified with a OCPN_Sound* pointer when sound has completed.
Definition options.h:641
wxRadioButton * pTimezoneUTC
Specify date/time should be formatted in UTC.
Definition options.h:443
wxRadioButton * pTimezoneLocalTime
Specify date/time should be formatted in timezone as configured in the operating system.
Definition options.h:441
Class cm93chart and helpers – CM93 chart state.
Global variables reflecting command line options and arguments.
Communication drivers factory and support.
Misc driver utilities.
Config file user configuration interface.
int g_iTempFormat
User-selected temperature unit format for display and input.
bool g_bsmoothpanzoom
Controls how the chart panning and zooming smoothing is done during user interactions.
int g_iHeightFormat
User-selected height (vertical, above reference datum) unit format for display and input.
int g_nDepthUnitDisplay
User-selected depth (below surface) unit format for display and input.
bool g_bRollover
enable/disable mouse rollover GUI effects
int g_iSpeedFormat
User-selected speed unit format for display and input.
int g_COGAvgSec
COG average period for Course Up Mode (sec).
int g_iDistanceFormat
User-selected distance (horizontal) unit format for display and input.
wxString g_datetime_format
Date/time format to use when formatting date/time strings.
std::vector< size_t > g_config_display_size_mm
Size of pysical screen in millimeters.
bool g_bDisplayGrid
Should lat/lon grid be displayed ?
Global variables stored in configuration file.
std::vector< ConnectionParams * > & TheConnectionParams()
Return global list of connections.
Panel for editing a connection.
Options | Connections GUI tab managing connections
std::vector< OCPN_MonitorInfo > g_monitor_info
Information about the monitors connected to the system.
Definition displays.cpp:45
Display utilities.
A common variable shared between producer and consumer which supports Listen() and Notify().
Font list manager.
GLuint g_raster_format
Global instance.
OpenGL chart rendering canvas.
Platform independent GL includes.
glTextureManager * g_glTextureManager
Global instance.
Global variables Listen()/Notify() wrapper.
Misc GUI event vars, a singleton.
wxFont * GetOCPNScaledFont(wxString item, int default_size)
Retrieves a font from FontMgr, optionally scaled for physical readability.
Definition gui_lib.cpp:61
wxFont GetOCPNGUIScaledFont(wxString item)
Retrieves a font optimized for touch and high-resolution interfaces.
Definition gui_lib.cpp:90
size_t g_current_monitor
Current monitor displaying main application frame.
Definition gui_vars.cpp:75
Miscellaneous globals primarely used by gui layer, not persisted in configuration file.
GUI constant definitions.
Waypoint properties maintenance dialog.
Multiplexer class and helpers.
MyConfig * pConfig
Global instance.
Definition navutil.cpp:118
Utility functions.
Navigation Utility Functions without GUI dependencies.
Generic font dialog for OpenCPN.
OCPNPlatform * g_Platform
Global instance.
OpenCPN Platform specific support utilities.
wxWindow * GetOCPNCanvasWindow()
Gets OpenCPN's main canvas window.
wxString * GetpSharedDataLocation()
Gets shared application data location.
double OCPN_GetWinDIPScaleFactor()
Gets Windows-specific DPI scaling factor.
options * g_options
Global instance.
Definition options.cpp:181
Options dialog.
options * g_options
Global instance.
Definition options.cpp:181
double gVar
Magnetic variation in degrees.
Definition own_ship.cpp:32
Position, course, speed, etc.
PlugInManager * g_pi_manager
Global instance.
wxColour g_colourWaypointRangeRingsColour
Global instance.
float g_ChartScaleFactorExp
Global instance.
Definition routeman.cpp:68
Route Manager.
Serial ports support, notably enumeration.
wxArrayString * EnumerateSerialPorts(void)
Enumerate all serial ports.
ocpnStyle::StyleManager * g_StyleManager
Global instance.
Definition styles.cpp:54
Chart Symbols.
wxBitmap LoadSVG(const wxString filename, const unsigned int width, const unsigned int height, wxBitmap *default_bitmap, bool use_cache)
Load SVG file and return it's bitmap representation of requested size In case file can't be loaded an...
Definition svg_utils.cpp:59
SVG utilities.
Abstract gFrame/MyFrame interface.
Access checks for comm devices and dongle.
Low-level USB device management.
WaypointMan drawing stuff.