35#include <wx/artprov.h>
36#include <wx/statline.h>
41#include "CanvasOptions.h"
42#include "OCPNPlatform.h"
46#ifdef __OCPN__ANDROID__
47#include "androidUTIL.h"
63EVT_CLOSE(CanvasOptions::OnClose)
73 wxFont* qFont = GetOCPNScaledFont(_(
"Dialog"));
77 long mstyle = wxNO_BORDER | wxFRAME_NO_TASKBAR | wxFRAME_SHAPED;
78 wxDialog::Create(parent, wxID_ANY, _T(
""), wxDefaultPosition, wxDefaultSize,
81 wxBoxSizer* topsizer =
new wxBoxSizer(wxVERTICAL);
84 m_sWindow =
new wxScrolledWindow(
this, wxID_ANY, wxDefaultPosition,
85 wxDefaultSize, wxVSCROLL | wxSUNKEN_BORDER);
86 topsizer->Add(m_sWindow, 1, wxEXPAND);
88 m_sWindow->SetScrollRate(0, 5);
91 int group_item_spacing = 0;
92 int interGroupSpace = border_size * 2;
94 wxSizerFlags verticalInputFlags = wxSizerFlags(0)
97 .Border(wxALL, group_item_spacing);
98 wxSizerFlags inputFlags =
99 wxSizerFlags(0).Align(wxALIGN_LEFT).Border(wxALL, group_item_spacing);
101 wxScrolledWindow* pDisplayPanel = m_sWindow;
103 wxBoxSizer* generalSizer =
new wxBoxSizer(wxVERTICAL);
104 pDisplayPanel->SetSizer(generalSizer);
107 wxStaticText* optionsLabelBox =
108 new wxStaticText(pDisplayPanel, wxID_ANY, _(
"Chart Panel Options"));
109 generalSizer->Add(optionsLabelBox, 0, wxALL | wxEXPAND, border_size);
110 wxStaticLine* m_staticLine121 =
111 new wxStaticLine(pDisplayPanel, wxID_ANY, wxDefaultPosition,
112 wxDefaultSize, wxLI_HORIZONTAL);
113 generalSizer->Add(m_staticLine121, 0, wxALL | wxEXPAND, border_size);
116 generalSizer->Add(0, interGroupSpace);
132 wxStaticBoxSizer* boxNavMode =
new wxStaticBoxSizer(
133 new wxStaticBox(pDisplayPanel, wxID_ANY, _(
"Navigation Mode")),
135 generalSizer->Add(boxNavMode, 0, wxALL | wxEXPAND, border_size);
137 wxBoxSizer* rowOrientation =
new wxBoxSizer(wxVERTICAL);
138 boxNavMode->Add(rowOrientation);
140 pCBNorthUp =
new wxRadioButton(pDisplayPanel, wxID_ANY, _(
"North Up"),
141 wxDefaultPosition, wxDefaultSize, wxRB_GROUP);
142 rowOrientation->Add(pCBNorthUp, inputFlags);
143 pCBNorthUp->Connect(wxEVT_COMMAND_RADIOBUTTON_SELECTED,
144 wxCommandEventHandler(CanvasOptions::OnOptionChange),
148 new wxRadioButton(pDisplayPanel, IDCO_COURSEUPCHECKBOX, _(
"Course Up"));
149 rowOrientation->Add(pCBCourseUp, wxSizerFlags(0)
151 .Border(wxLEFT, group_item_spacing * 2));
152 pCBCourseUp->Connect(wxEVT_COMMAND_RADIOBUTTON_SELECTED,
153 wxCommandEventHandler(CanvasOptions::OnOptionChange),
157 new wxRadioButton(pDisplayPanel, IDCO_HEADUPCHECKBOX, _(
"Heading Up"));
158 rowOrientation->Add(pCBHeadUp, wxSizerFlags(0)
160 .Border(wxLEFT, group_item_spacing * 2));
161 pCBHeadUp->Connect(wxEVT_COMMAND_RADIOBUTTON_SELECTED,
162 wxCommandEventHandler(CanvasOptions::OnOptionChange), NULL,
166 new wxCheckBox(pDisplayPanel, IDCO_CHECK_LOOKAHEAD, _(
"Look Ahead Mode"));
167 boxNavMode->Add(pCBLookAhead, verticalInputFlags);
168 pCBLookAhead->Connect(wxEVT_COMMAND_CHECKBOX_CLICKED,
169 wxCommandEventHandler(CanvasOptions::OnOptionChange),
173 generalSizer->Add(0, interGroupSpace);
176 wxStaticBoxSizer* boxDisp =
new wxStaticBoxSizer(
177 new wxStaticBox(pDisplayPanel, wxID_ANY, _(
"Display Options")),
179 generalSizer->Add(boxDisp, 0, wxALL | wxEXPAND, border_size);
181 pCDOQuilting =
new wxCheckBox(pDisplayPanel, IDCO_QUILTCHECKBOX1,
182 _(
"Enable Chart Quilting"));
183 boxDisp->Add(pCDOQuilting, verticalInputFlags);
184 pCDOQuilting->Connect(wxEVT_COMMAND_CHECKBOX_CLICKED,
185 wxCommandEventHandler(CanvasOptions::OnOptionChange),
189 new wxCheckBox(pDisplayPanel, IDCO_CHECK_DISPLAYGRID, _(
"Show Grid"));
190 boxDisp->Add(pSDisplayGrid, verticalInputFlags);
191 pSDisplayGrid->Connect(wxEVT_COMMAND_CHECKBOX_CLICKED,
192 wxCommandEventHandler(CanvasOptions::OnOptionChange),
195 pCDOOutlines =
new wxCheckBox(pDisplayPanel, IDCO_OUTLINECHECKBOX1,
196 _(
"Show Chart Outlines"));
197 boxDisp->Add(pCDOOutlines, verticalInputFlags);
198 pCDOOutlines->Connect(wxEVT_COMMAND_CHECKBOX_CLICKED,
199 wxCommandEventHandler(CanvasOptions::OnOptionChange),
202 pSDepthUnits =
new wxCheckBox(pDisplayPanel, IDCO_SHOWDEPTHUNITSBOX1,
203 _(
"Show Depth Units"));
204 boxDisp->Add(pSDepthUnits, verticalInputFlags);
205 pSDepthUnits->Connect(wxEVT_COMMAND_CHECKBOX_CLICKED,
206 wxCommandEventHandler(CanvasOptions::OnOptionChange),
210 wxStaticBoxSizer* boxAIS =
new wxStaticBoxSizer(
211 new wxStaticBox(pDisplayPanel, wxID_ANY, _(
"AIS")), wxVERTICAL);
212 generalSizer->Add(boxAIS, 0, wxALL | wxEXPAND, border_size);
214 pCBShowAIS =
new wxCheckBox(pDisplayPanel, IDCO_SHOW_AIS_CHECKBOX,
215 _(
"Show AIS targets"));
216 boxAIS->Add(pCBShowAIS, verticalInputFlags);
217 pCBShowAIS->Connect(wxEVT_COMMAND_CHECKBOX_CLICKED,
218 wxCommandEventHandler(CanvasOptions::OnOptionChange),
221 pCBAttenAIS =
new wxCheckBox(pDisplayPanel, IDCO_ATTEN_AIS_CHECKBOX,
222 _(
"Minimize less critical targets"));
223 boxAIS->Add(pCBAttenAIS, verticalInputFlags);
224 pCBAttenAIS->Connect(wxEVT_COMMAND_CHECKBOX_CLICKED,
225 wxCommandEventHandler(CanvasOptions::OnOptionChange),
229 generalSizer->Add(0, interGroupSpace);
232 wxStaticBoxSizer* boxTC =
new wxStaticBoxSizer(
233 new wxStaticBox(pDisplayPanel, wxID_ANY, _(
"Tides and Currents")),
235 generalSizer->Add(boxTC, 0, wxALL | wxEXPAND, border_size);
237 pCDOTides =
new wxCheckBox(pDisplayPanel, IDCO_TIDES_CHECKBOX,
238 _(
"Show Tide stations"));
239 boxTC->Add(pCDOTides, verticalInputFlags);
240 pCDOTides->Connect(wxEVT_COMMAND_CHECKBOX_CLICKED,
241 wxCommandEventHandler(CanvasOptions::OnOptionChange), NULL,
245 new wxCheckBox(pDisplayPanel, IDCO_CURRENTS_CHECKBOX, _(
"Show Currents"));
246 boxTC->Add(pCDOCurrents, verticalInputFlags);
247 pCDOCurrents->Connect(wxEVT_COMMAND_CHECKBOX_CLICKED,
248 wxCommandEventHandler(CanvasOptions::OnOptionChange),
252 generalSizer->Add(0, interGroupSpace);
255 wxStaticBoxSizer* boxENC =
new wxStaticBoxSizer(
256 new wxStaticBox(pDisplayPanel, wxID_ANY, _(
"Vector Charts")), wxVERTICAL);
257 generalSizer->Add(boxENC, 0, wxALL | wxEXPAND, border_size);
260 new wxCheckBox(pDisplayPanel, IDCO_ENCTEXT_CHECKBOX1, _(
"Show text"));
261 boxENC->Add(pCDOENCText, verticalInputFlags);
262 pCDOENCText->Connect(wxEVT_COMMAND_CHECKBOX_CLICKED,
263 wxCommandEventHandler(CanvasOptions::OnOptionChange),
267 new wxCheckBox(pDisplayPanel, IDCO_ENCDEPTH_CHECKBOX1, _(
"Show depths"));
268 boxENC->Add(pCBENCDepth, verticalInputFlags);
269 pCBENCDepth->Connect(wxEVT_COMMAND_CHECKBOX_CLICKED,
270 wxCommandEventHandler(CanvasOptions::OnOptionChange),
273 pCBENCBuoyLabels =
new wxCheckBox(pDisplayPanel, IDCO_ENCBUOYLABEL_CHECKBOX1,
274 _(
"Buoy/Light Labels"));
275 boxENC->Add(pCBENCBuoyLabels, verticalInputFlags);
276 pCBENCBuoyLabels->Connect(
277 wxEVT_COMMAND_CHECKBOX_CLICKED,
278 wxCommandEventHandler(CanvasOptions::OnOptionChange), NULL,
this);
281 new wxCheckBox(pDisplayPanel, IDCO_ENCBUOYLABEL_CHECKBOX1, _(
"Lights"));
282 boxENC->Add(pCBENCLights, verticalInputFlags);
283 pCBENCLights->Connect(wxEVT_COMMAND_CHECKBOX_CLICKED,
284 wxCommandEventHandler(CanvasOptions::OnOptionChange),
287 pCBENCLightDesc =
new wxCheckBox(pDisplayPanel, IDCO_ENCBUOY_CHECKBOX1,
288 _(
"Light Descriptions"));
289 boxENC->Add(pCBENCLightDesc, verticalInputFlags);
290 pCBENCLightDesc->Connect(wxEVT_COMMAND_CHECKBOX_CLICKED,
291 wxCommandEventHandler(CanvasOptions::OnOptionChange),
294 pCBENCAnchorDetails =
new wxCheckBox(pDisplayPanel, IDCO_ENCANCHOR_CHECKBOX1,
295 _(
"Anchoring Info"));
296 boxENC->Add(pCBENCAnchorDetails, verticalInputFlags);
297 pCBENCAnchorDetails->Connect(
298 wxEVT_COMMAND_CHECKBOX_CLICKED,
299 wxCommandEventHandler(CanvasOptions::OnOptionChange), NULL,
this);
301 pCBENCVisibleSectors =
302 new wxCheckBox(pDisplayPanel, IDCO_ENCVISIBLESECTORS_CHECKBOX1,
303 _(
"Show visible sector lights"));
304 boxENC->Add(pCBENCVisibleSectors, verticalInputFlags);
305 pCBENCVisibleSectors->Connect(
306 wxEVT_COMMAND_CHECKBOX_CLICKED,
307 wxCommandEventHandler(CanvasOptions::OnOptionChange), NULL,
this);
310 boxENC->Add(0, interGroupSpace);
313 boxENC->Add(
new wxStaticText(pDisplayPanel, wxID_ANY, _(
"Display Category")),
315 wxString pDispCatStrings[] = {_(
"Base"), _(
"Standard"), _(
"All"),
317 m_pDispCat =
new wxChoice(pDisplayPanel, ID_CODISPCAT, wxDefaultPosition,
318 wxDefaultSize, 4, pDispCatStrings);
319 boxENC->Add(m_pDispCat, 0, wxALIGN_CENTER_HORIZONTAL, 0);
320 m_pDispCat->Connect(wxEVT_COMMAND_CHOICE_SELECTED,
321 wxCommandEventHandler(CanvasOptions::OnOptionChange),
324#ifdef __OCPN__ANDROID__
325 GetHandle()->setStyleSheet(getAdjustedDialogStyleSheet());
328 RefreshControlValues();
335void CanvasOptions::OnEraseBackground(wxEraseEvent& event) {}
337void CanvasOptions::OnClose(wxCloseEvent& event) {
342void CanvasOptions::OnOptionChange(wxCommandEvent& event) {
343 UpdateCanvasOptions();
346void CanvasOptions::RefreshControlValues(
void) {
348 if (!parentCanvas)
return;
354 int mode = parentCanvas->GetUpMode();
355 if (mode == NORTH_UP_MODE)
356 pCBNorthUp->SetValue(
true);
357 else if (mode == COURSE_UP_MODE)
358 pCBCourseUp->SetValue(
true);
360 pCBHeadUp->SetValue(
true);
362 pCBLookAhead->SetValue(parentCanvas->GetLookahead());
365 pCDOQuilting->SetValue(parentCanvas->GetQuiltMode());
366 pSDisplayGrid->SetValue(parentCanvas->GetShowGrid());
367 pCDOOutlines->SetValue(parentCanvas->GetShowOutlines());
368 pSDepthUnits->SetValue(parentCanvas->GetShowDepthUnits());
371 pCBShowAIS->SetValue(parentCanvas->GetShowAIS());
372 pCBAttenAIS->SetValue(parentCanvas->GetAttenAIS());
375 pCDOTides->SetValue(parentCanvas->GetbShowTide());
376 pCDOCurrents->SetValue(parentCanvas->GetbShowCurrent());
380 pCDOENCText->SetValue(parentCanvas->GetShowENCText());
381 pCBENCDepth->SetValue(parentCanvas->GetShowENCDepth());
382 pCBENCLightDesc->SetValue(parentCanvas->GetShowENCLightDesc());
383 pCBENCBuoyLabels->SetValue(parentCanvas->GetShowENCBuoyLabels());
384 pCBENCLights->SetValue(parentCanvas->GetShowENCLights());
385 pCBENCAnchorDetails->SetValue(parentCanvas->GetShowENCAnchor());
386 pCBENCVisibleSectors->SetValue(parentCanvas->GetShowVisibleSectors());
392 switch (parentCanvas->GetENCDisplayCategory()) {
402 case (MARINERS_STANDARD):
409 m_pDispCat->SetSelection(nset);
413 pCDOENCText->Enable(m_ENCAvail);
414 pCBENCDepth->Enable(m_ENCAvail);
415 pCBENCLightDesc->Enable(m_ENCAvail && parentCanvas->GetShowENCLights());
416 pCBENCBuoyLabels->Enable(m_ENCAvail);
417 pCBENCLights->Enable(m_ENCAvail);
418 pCBENCVisibleSectors->Enable(m_ENCAvail);
422 pCBENCAnchorDetails->Enable(m_ENCAvail && (nset > 1));
426 pCDOENCText->Disable();
427 pCBENCDepth->Disable();
428 pCBENCLightDesc->Disable();
429 pCBENCBuoyLabels->Disable();
430 pCBENCLights->Disable();
431 pCBENCVisibleSectors->Disable();
434 m_pDispCat->Enable(m_ENCAvail);
437void CanvasOptions::SetENCAvailable(
bool avail) {
439 RefreshControlValues();
442void CanvasOptions::UpdateCanvasOptions(
void) {
444 if (!parentCanvas)
return;
446 bool b_needRefresh =
false;
447 bool b_needReLoad =
false;
454 if (pCDOQuilting->GetValue() != parentCanvas->GetQuiltMode()) {
455 parentCanvas->ToggleCanvasQuiltMode();
458 if (pSDisplayGrid->GetValue() != parentCanvas->GetShowGrid()) {
459 parentCanvas->SetShowGrid(pSDisplayGrid->GetValue());
460 b_needRefresh =
true;
463 if (pCDOOutlines->GetValue() != parentCanvas->GetShowOutlines()) {
464 parentCanvas->SetShowOutlines(pCDOOutlines->GetValue());
465 b_needRefresh =
true;
467 if (pSDepthUnits->GetValue() != parentCanvas->GetShowDepthUnits()) {
468 parentCanvas->SetShowDepthUnits(pSDepthUnits->GetValue());
469 b_needRefresh =
true;
472 if (pCBShowAIS->GetValue() != parentCanvas->GetShowAIS()) {
473 parentCanvas->SetShowAIS(pCBShowAIS->GetValue());
474 b_needRefresh =
true;
477 if (pCBAttenAIS->GetValue() != parentCanvas->GetAttenAIS()) {
478 parentCanvas->SetAttenAIS(pCBAttenAIS->GetValue());
479 b_needRefresh =
true;
482 if (pCDOTides->GetValue() != parentCanvas->GetbShowTide()) {
483 parentCanvas->ShowTides(pCDOTides->GetValue());
484 b_needRefresh =
true;
486 if (pCDOCurrents->GetValue() != parentCanvas->GetbShowCurrent()) {
487 parentCanvas->ShowCurrents(pCDOCurrents->GetValue());
488 b_needRefresh =
true;
492 if (pCDOENCText->GetValue() != parentCanvas->GetShowENCText()) {
493 parentCanvas->SetShowENCText(pCDOENCText->GetValue());
497 if (pCBENCDepth->GetValue() != parentCanvas->GetShowENCDepth()) {
498 parentCanvas->SetShowENCDepth(pCBENCDepth->GetValue());
502 if (pCBENCLightDesc->GetValue() != parentCanvas->GetShowENCLightDesc()) {
503 parentCanvas->SetShowENCLightDesc(pCBENCLightDesc->GetValue());
507 if (pCBENCBuoyLabels->GetValue() != parentCanvas->GetShowENCBuoyLabels()) {
508 parentCanvas->SetShowENCBuoyLabels(pCBENCBuoyLabels->GetValue());
512 if (pCBENCLights->GetValue() != parentCanvas->GetShowENCLights()) {
513 parentCanvas->SetShowENCLights(pCBENCLights->GetValue());
517 if (pCBENCAnchorDetails->GetValue() != parentCanvas->GetShowENCAnchor()) {
518 parentCanvas->SetShowENCAnchor(pCBENCAnchorDetails->GetValue());
522 if (pCBENCVisibleSectors->GetValue() !=
523 parentCanvas->GetShowVisibleSectors()) {
524 parentCanvas->SetShowVisibleSectors(pCBENCVisibleSectors->GetValue());
528 int newMode = NORTH_UP_MODE;
529 if (pCBCourseUp->GetValue())
530 newMode = COURSE_UP_MODE;
531 else if (pCBHeadUp->GetValue())
532 newMode = HEAD_UP_MODE;
534 if (newMode != parentCanvas->GetUpMode()) {
535 parentCanvas->SetUpMode(newMode);
539 if (pCBLookAhead->GetValue() != parentCanvas->GetLookahead()) {
540 parentCanvas->ToggleLookahead();
541 parentCanvas->UpdateFollowButtonState();
546 switch (parentCanvas->GetENCDisplayCategory()) {
556 case (MARINERS_STANDARD):
564 if (m_pDispCat->GetSelection() != nset) {
565 int valSet = STANDARD;
566 int newSet = m_pDispCat->GetSelection();
569 valSet = DISPLAYBASE;
578 valSet = MARINERS_STANDARD;
584 parentCanvas->SetENCDisplayCategory(valSet);
589 pCBENCAnchorDetails->Enable(newSet > 1);
593 parentCanvas->ReloadVP();
594 }
else if (b_needRefresh) {
595 parentCanvas->Refresh(
true);
596 parentCanvas->InvalidateGL();
599 RefreshControlValues();