29 #include <wx/wxprec.h>
35 #include <wx/artprov.h>
36 #include <wx/statline.h>
41 #include "CanvasOptions.h"
45 #ifdef __OCPN__ANDROID__
46 #include "androidUTIL.h"
52 extern s52plib *ps52plib;
63 EVT_CLOSE(CanvasOptions::OnClose)
73 wxFont* qFont = GetOCPNScaledFont(_(
"Dialog"));
76 long mstyle = wxNO_BORDER | wxFRAME_NO_TASKBAR;
78 mstyle |= wxSTAY_ON_TOP;
81 wxDialog::Create(parent, wxID_ANY, _T(
""), wxDefaultPosition, wxDefaultSize,
84 wxBoxSizer* topsizer =
new wxBoxSizer(wxVERTICAL);
87 m_sWindow =
new wxScrolledWindow(
this, wxID_ANY, wxDefaultPosition,
88 wxDefaultSize, wxVSCROLL | wxSUNKEN_BORDER);
89 topsizer->Add(m_sWindow, 1, wxEXPAND);
91 m_sWindow->SetScrollRate(0, 5);
94 int group_item_spacing = 0;
95 int interGroupSpace = border_size * 2;
97 wxSizerFlags verticalInputFlags = wxSizerFlags(0)
100 .Border(wxALL, group_item_spacing);
101 wxSizerFlags inputFlags =
102 wxSizerFlags(0).Align(wxALIGN_LEFT).Border(wxALL, group_item_spacing);
104 wxScrolledWindow* pDisplayPanel = m_sWindow;
106 wxBoxSizer* generalSizer =
new wxBoxSizer(wxVERTICAL);
107 pDisplayPanel->SetSizer(generalSizer);
110 wxStaticText* optionsLabelBox =
111 new wxStaticText(pDisplayPanel, wxID_ANY, _(
"Chart Panel Options"));
112 generalSizer->Add(optionsLabelBox, 0, wxALL | wxEXPAND, border_size);
113 wxStaticLine* m_staticLine121 =
114 new wxStaticLine(pDisplayPanel, wxID_ANY, wxDefaultPosition,
115 wxDefaultSize, wxLI_HORIZONTAL);
116 generalSizer->Add(m_staticLine121, 0, wxALL | wxEXPAND, border_size);
119 generalSizer->Add(0, interGroupSpace);
135 wxStaticBoxSizer* boxNavMode =
new wxStaticBoxSizer(
136 new wxStaticBox(pDisplayPanel, wxID_ANY, _(
"Navigation Mode")),
138 generalSizer->Add(boxNavMode, 0, wxALL | wxEXPAND, border_size);
140 wxBoxSizer* rowOrientation =
new wxBoxSizer(wxVERTICAL);
141 boxNavMode->Add(rowOrientation);
143 pCBNorthUp =
new wxRadioButton(pDisplayPanel, wxID_ANY, _(
"North Up"),
144 wxDefaultPosition, wxDefaultSize, wxRB_GROUP);
145 rowOrientation->Add(pCBNorthUp, inputFlags);
146 pCBNorthUp->Connect(wxEVT_COMMAND_RADIOBUTTON_SELECTED,
147 wxCommandEventHandler(CanvasOptions::OnOptionChange),
151 new wxRadioButton(pDisplayPanel, IDCO_COURSEUPCHECKBOX, _(
"Course Up"));
152 rowOrientation->Add(pCBCourseUp, wxSizerFlags(0)
154 .Border(wxLEFT, group_item_spacing * 2));
155 pCBCourseUp->Connect(wxEVT_COMMAND_RADIOBUTTON_SELECTED,
156 wxCommandEventHandler(CanvasOptions::OnOptionChange),
160 new wxRadioButton(pDisplayPanel, IDCO_HEADUPCHECKBOX, _(
"Heading Up"));
161 rowOrientation->Add(pCBHeadUp, wxSizerFlags(0)
163 .Border(wxLEFT, group_item_spacing * 2));
164 pCBHeadUp->Connect(wxEVT_COMMAND_RADIOBUTTON_SELECTED,
165 wxCommandEventHandler(CanvasOptions::OnOptionChange), NULL,
169 new wxCheckBox(pDisplayPanel, IDCO_CHECK_LOOKAHEAD, _(
"Look Ahead Mode"));
170 boxNavMode->Add(pCBLookAhead, verticalInputFlags);
171 pCBLookAhead->Connect(wxEVT_COMMAND_CHECKBOX_CLICKED,
172 wxCommandEventHandler(CanvasOptions::OnOptionChange),
176 generalSizer->Add(0, interGroupSpace);
179 wxStaticBoxSizer* boxDisp =
new wxStaticBoxSizer(
180 new wxStaticBox(pDisplayPanel, wxID_ANY, _(
"Display Options")),
182 generalSizer->Add(boxDisp, 0, wxALL | wxEXPAND, border_size);
184 pCDOQuilting =
new wxCheckBox(pDisplayPanel, IDCO_QUILTCHECKBOX1,
185 _(
"Enable Chart Quilting"));
186 boxDisp->Add(pCDOQuilting, verticalInputFlags);
187 pCDOQuilting->Connect(wxEVT_COMMAND_CHECKBOX_CLICKED,
188 wxCommandEventHandler(CanvasOptions::OnOptionChange),
192 new wxCheckBox(pDisplayPanel, IDCO_CHECK_DISPLAYGRID, _(
"Show Grid"));
193 boxDisp->Add(pSDisplayGrid, verticalInputFlags);
194 pSDisplayGrid->Connect(wxEVT_COMMAND_CHECKBOX_CLICKED,
195 wxCommandEventHandler(CanvasOptions::OnOptionChange),
198 pCDOOutlines =
new wxCheckBox(pDisplayPanel, IDCO_OUTLINECHECKBOX1,
199 _(
"Show Chart Outlines"));
200 boxDisp->Add(pCDOOutlines, verticalInputFlags);
201 pCDOOutlines->Connect(wxEVT_COMMAND_CHECKBOX_CLICKED,
202 wxCommandEventHandler(CanvasOptions::OnOptionChange),
205 pSDepthUnits =
new wxCheckBox(pDisplayPanel, IDCO_SHOWDEPTHUNITSBOX1,
206 _(
"Show Depth Units"));
207 boxDisp->Add(pSDepthUnits, verticalInputFlags);
208 pSDepthUnits->Connect(wxEVT_COMMAND_CHECKBOX_CLICKED,
209 wxCommandEventHandler(CanvasOptions::OnOptionChange),
213 wxStaticBoxSizer* boxAIS =
new wxStaticBoxSizer(
214 new wxStaticBox(pDisplayPanel, wxID_ANY, _(
"AIS")), wxVERTICAL);
215 generalSizer->Add(boxAIS, 0, wxALL | wxEXPAND, border_size);
217 pCBShowAIS =
new wxCheckBox(pDisplayPanel, IDCO_SHOW_AIS_CHECKBOX,
218 _(
"Show AIS targets"));
219 boxAIS->Add(pCBShowAIS, verticalInputFlags);
220 pCBShowAIS->Connect(wxEVT_COMMAND_CHECKBOX_CLICKED,
221 wxCommandEventHandler(CanvasOptions::OnOptionChange),
224 pCBAttenAIS =
new wxCheckBox(pDisplayPanel, IDCO_ATTEN_AIS_CHECKBOX,
225 _(
"Minimize less critical targets"));
226 boxAIS->Add(pCBAttenAIS, verticalInputFlags);
227 pCBAttenAIS->Connect(wxEVT_COMMAND_CHECKBOX_CLICKED,
228 wxCommandEventHandler(CanvasOptions::OnOptionChange),
232 generalSizer->Add(0, interGroupSpace);
235 wxStaticBoxSizer* boxTC =
new wxStaticBoxSizer(
236 new wxStaticBox(pDisplayPanel, wxID_ANY, _(
"Tides and Currents")),
238 generalSizer->Add(boxTC, 0, wxALL | wxEXPAND, border_size);
240 pCDOTides =
new wxCheckBox(pDisplayPanel, IDCO_TIDES_CHECKBOX,
241 _(
"Show Tide stations"));
242 boxTC->Add(pCDOTides, verticalInputFlags);
243 pCDOTides->Connect(wxEVT_COMMAND_CHECKBOX_CLICKED,
244 wxCommandEventHandler(CanvasOptions::OnOptionChange), NULL,
248 new wxCheckBox(pDisplayPanel, IDCO_CURRENTS_CHECKBOX, _(
"Show Currents"));
249 boxTC->Add(pCDOCurrents, verticalInputFlags);
250 pCDOCurrents->Connect(wxEVT_COMMAND_CHECKBOX_CLICKED,
251 wxCommandEventHandler(CanvasOptions::OnOptionChange),
255 generalSizer->Add(0, interGroupSpace);
258 wxStaticBoxSizer* boxENC =
new wxStaticBoxSizer(
259 new wxStaticBox(pDisplayPanel, wxID_ANY, _(
"Vector Charts")), wxVERTICAL);
260 generalSizer->Add(boxENC, 0, wxALL | wxEXPAND, border_size);
263 new wxCheckBox(pDisplayPanel, IDCO_ENCTEXT_CHECKBOX1, _(
"Show text"));
264 boxENC->Add(pCDOENCText, verticalInputFlags);
265 pCDOENCText->Connect(wxEVT_COMMAND_CHECKBOX_CLICKED,
266 wxCommandEventHandler(CanvasOptions::OnOptionChange),
270 new wxCheckBox(pDisplayPanel, IDCO_ENCDEPTH_CHECKBOX1, _(
"Show depths"));
271 boxENC->Add(pCBENCDepth, verticalInputFlags);
272 pCBENCDepth->Connect(wxEVT_COMMAND_CHECKBOX_CLICKED,
273 wxCommandEventHandler(CanvasOptions::OnOptionChange),
276 pCBENCBuoyLabels =
new wxCheckBox(pDisplayPanel, IDCO_ENCBUOYLABEL_CHECKBOX1,
277 _(
"Buoy/Light Labels"));
278 boxENC->Add(pCBENCBuoyLabels, verticalInputFlags);
279 pCBENCBuoyLabels->Connect(
280 wxEVT_COMMAND_CHECKBOX_CLICKED,
281 wxCommandEventHandler(CanvasOptions::OnOptionChange), NULL,
this);
284 new wxCheckBox(pDisplayPanel, IDCO_ENCBUOYLABEL_CHECKBOX1, _(
"Lights"));
285 boxENC->Add(pCBENCLights, verticalInputFlags);
286 pCBENCLights->Connect(wxEVT_COMMAND_CHECKBOX_CLICKED,
287 wxCommandEventHandler(CanvasOptions::OnOptionChange),
290 pCBENCLightDesc =
new wxCheckBox(pDisplayPanel, IDCO_ENCBUOY_CHECKBOX1,
291 _(
"Light Descriptions"));
292 boxENC->Add(pCBENCLightDesc, verticalInputFlags);
293 pCBENCLightDesc->Connect(wxEVT_COMMAND_CHECKBOX_CLICKED,
294 wxCommandEventHandler(CanvasOptions::OnOptionChange),
297 pCBENCAnchorDetails =
new wxCheckBox(pDisplayPanel, IDCO_ENCANCHOR_CHECKBOX1,
298 _(
"Anchoring Info"));
299 boxENC->Add(pCBENCAnchorDetails, verticalInputFlags);
300 pCBENCAnchorDetails->Connect(
301 wxEVT_COMMAND_CHECKBOX_CLICKED,
302 wxCommandEventHandler(CanvasOptions::OnOptionChange), NULL,
this);
304 pCBENCVisibleSectors =
305 new wxCheckBox(pDisplayPanel, IDCO_ENCVISIBLESECTORS_CHECKBOX1,
306 _(
"Show visible sector lights"));
307 boxENC->Add(pCBENCVisibleSectors, verticalInputFlags);
308 pCBENCVisibleSectors->Connect(
309 wxEVT_COMMAND_CHECKBOX_CLICKED,
310 wxCommandEventHandler(CanvasOptions::OnOptionChange), NULL,
this);
313 new wxCheckBox(pDisplayPanel, IDCO_ENCDATAQUALITY_CHECKBOX,
314 _(
"Show chart data quality"));
315 boxENC->Add(pCBENCDataQuality, verticalInputFlags);
316 pCBENCDataQuality->Connect(
317 wxEVT_COMMAND_CHECKBOX_CLICKED,
318 wxCommandEventHandler(CanvasOptions::OnOptionChange), NULL,
this);
321 boxENC->Add(0, interGroupSpace);
324 boxENC->Add(
new wxStaticText(pDisplayPanel, wxID_ANY, _(
"Display Category")),
326 wxString pDispCatStrings[] = {_(
"Base"), _(
"Standard"), _(
"All"),
328 m_pDispCat =
new wxChoice(pDisplayPanel, ID_CODISPCAT, wxDefaultPosition,
329 wxDefaultSize, 4, pDispCatStrings);
330 boxENC->Add(m_pDispCat, 0, wxALIGN_CENTER_HORIZONTAL, 0);
331 m_pDispCat->Connect(wxEVT_COMMAND_CHOICE_SELECTED,
332 wxCommandEventHandler(CanvasOptions::OnOptionChange),
335 #ifdef __OCPN__ANDROID__
336 GetHandle()->setStyleSheet(getAdjustedDialogStyleSheet());
339 RefreshControlValues();
346 void CanvasOptions::OnEraseBackground(wxEraseEvent& event) {}
348 void CanvasOptions::OnClose(wxCloseEvent& event) {
353 void CanvasOptions::OnOptionChange(wxCommandEvent& event) {
354 UpdateCanvasOptions();
357 void CanvasOptions::RefreshControlValues(
void) {
359 if (!parentCanvas)
return;
365 int mode = parentCanvas->GetUpMode();
366 if (mode == NORTH_UP_MODE)
367 pCBNorthUp->SetValue(
true);
368 else if (mode == COURSE_UP_MODE)
369 pCBCourseUp->SetValue(
true);
371 pCBHeadUp->SetValue(
true);
373 pCBLookAhead->SetValue(parentCanvas->GetLookahead());
376 pCDOQuilting->SetValue(parentCanvas->GetQuiltMode());
377 pSDisplayGrid->SetValue(parentCanvas->GetShowGrid());
378 pCDOOutlines->SetValue(parentCanvas->GetShowOutlines());
379 pSDepthUnits->SetValue(parentCanvas->GetShowDepthUnits());
382 pCBShowAIS->SetValue(parentCanvas->GetShowAIS());
383 pCBAttenAIS->SetValue(parentCanvas->GetAttenAIS());
386 pCDOTides->SetValue(parentCanvas->GetbShowTide());
387 pCDOCurrents->SetValue(parentCanvas->GetbShowCurrent());
391 pCDOENCText->SetValue(parentCanvas->GetShowENCText());
392 pCBENCDepth->SetValue(parentCanvas->GetShowENCDepth());
393 pCBENCLightDesc->SetValue(parentCanvas->GetShowENCLightDesc());
394 pCBENCBuoyLabels->SetValue(parentCanvas->GetShowENCBuoyLabels());
395 pCBENCLights->SetValue(parentCanvas->GetShowENCLights());
396 pCBENCAnchorDetails->SetValue(parentCanvas->GetShowENCAnchor());
397 pCBENCVisibleSectors->SetValue(parentCanvas->GetShowVisibleSectors());
398 pCBENCDataQuality->SetValue(parentCanvas->GetShowENCDataQual());
404 switch (parentCanvas->GetENCDisplayCategory()) {
414 case (MARINERS_STANDARD):
421 m_pDispCat->SetSelection(nset);
425 pCDOENCText->Enable(m_ENCAvail);
426 pCBENCDepth->Enable(m_ENCAvail);
427 pCBENCLightDesc->Enable(m_ENCAvail && parentCanvas->GetShowENCLights());
428 pCBENCBuoyLabels->Enable(m_ENCAvail);
429 pCBENCLights->Enable(m_ENCAvail);
430 pCBENCVisibleSectors->Enable(m_ENCAvail);
434 pCBENCDataQuality->Enable(m_ENCAvail && (nset > 1));
435 pCBENCAnchorDetails->Enable(m_ENCAvail && (nset > 1));
439 pCDOENCText->Disable();
440 pCBENCDepth->Disable();
441 pCBENCLightDesc->Disable();
442 pCBENCBuoyLabels->Disable();
443 pCBENCLights->Disable();
444 pCBENCVisibleSectors->Disable();
445 pCBENCDataQuality->Disable();
448 m_pDispCat->Enable(m_ENCAvail);
451 pCBENCLightDesc->Enable(pCDOENCText->GetValue());
452 pCBENCBuoyLabels->Enable(pCDOENCText->GetValue());
456 void CanvasOptions::SetENCAvailable(
bool avail) {
458 RefreshControlValues();
461 void CanvasOptions::UpdateCanvasOptions(
void) {
463 if (!parentCanvas)
return;
465 bool b_needRefresh =
false;
466 bool b_needReLoad =
false;
473 if (pCDOQuilting->GetValue() != parentCanvas->GetQuiltMode()) {
474 parentCanvas->ToggleCanvasQuiltMode();
477 if (pSDisplayGrid->GetValue() != parentCanvas->GetShowGrid()) {
478 parentCanvas->SetShowGrid(pSDisplayGrid->GetValue());
479 b_needRefresh =
true;
482 if (pCDOOutlines->GetValue() != parentCanvas->GetShowOutlines()) {
483 parentCanvas->SetShowOutlines(pCDOOutlines->GetValue());
484 b_needRefresh =
true;
486 if (pSDepthUnits->GetValue() != parentCanvas->GetShowDepthUnits()) {
487 parentCanvas->SetShowDepthUnits(pSDepthUnits->GetValue());
488 b_needRefresh =
true;
491 if (pCBShowAIS->GetValue() != parentCanvas->GetShowAIS()) {
492 parentCanvas->SetShowAIS(pCBShowAIS->GetValue());
493 b_needRefresh =
true;
496 if (pCBAttenAIS->GetValue() != parentCanvas->GetAttenAIS()) {
497 parentCanvas->SetAttenAIS(pCBAttenAIS->GetValue());
498 b_needRefresh =
true;
501 if (pCDOTides->GetValue() != parentCanvas->GetbShowTide()) {
502 parentCanvas->ShowTides(pCDOTides->GetValue());
503 b_needRefresh =
true;
505 if (pCDOCurrents->GetValue() != parentCanvas->GetbShowCurrent()) {
506 parentCanvas->ShowCurrents(pCDOCurrents->GetValue());
507 b_needRefresh =
true;
511 if (pCDOENCText->GetValue() != parentCanvas->GetShowENCText()) {
512 parentCanvas->SetShowENCText(pCDOENCText->GetValue());
516 if (pCBENCDepth->GetValue() != parentCanvas->GetShowENCDepth()) {
517 parentCanvas->SetShowENCDepth(pCBENCDepth->GetValue());
521 if (pCBENCLightDesc->GetValue() != parentCanvas->GetShowENCLightDesc()) {
522 parentCanvas->SetShowENCLightDesc(pCBENCLightDesc->GetValue());
526 if (pCBENCBuoyLabels->GetValue() != parentCanvas->GetShowENCBuoyLabels()) {
527 parentCanvas->SetShowENCBuoyLabels(pCBENCBuoyLabels->GetValue());
531 if (pCBENCLights->GetValue() != parentCanvas->GetShowENCLights()) {
532 parentCanvas->SetShowENCLights(pCBENCLights->GetValue());
536 if (pCBENCAnchorDetails->GetValue() != parentCanvas->GetShowENCAnchor()) {
537 parentCanvas->SetShowENCAnchor(pCBENCAnchorDetails->GetValue());
541 if (pCBENCVisibleSectors->GetValue() !=
542 parentCanvas->GetShowVisibleSectors()) {
543 parentCanvas->SetShowVisibleSectors(pCBENCVisibleSectors->GetValue());
547 if (pCBENCDataQuality->GetValue() !=
548 parentCanvas->GetShowENCDataQual()) {
549 parentCanvas->SetShowENCDataQual(pCBENCDataQuality->GetValue());
554 if (pCBENCDataQuality->GetValue()){
556 ps52plib->m_bShowMeta =
true;
557 parentCanvas->UpdateCanvasS52PLIBConfig();
560 int newMode = NORTH_UP_MODE;
561 if (pCBCourseUp->GetValue())
562 newMode = COURSE_UP_MODE;
563 else if (pCBHeadUp->GetValue())
564 newMode = HEAD_UP_MODE;
566 if (newMode != parentCanvas->GetUpMode()) {
567 parentCanvas->SetUpMode(newMode);
571 if (pCBLookAhead->GetValue() != parentCanvas->GetLookahead()) {
572 parentCanvas->ToggleLookahead();
573 parentCanvas->UpdateFollowButtonState();
578 switch (parentCanvas->GetENCDisplayCategory()) {
588 case (MARINERS_STANDARD):
596 if (m_pDispCat->GetSelection() != nset) {
597 int valSet = STANDARD;
598 int newSet = m_pDispCat->GetSelection();
601 valSet = DISPLAYBASE;
610 valSet = MARINERS_STANDARD;
616 parentCanvas->SetENCDisplayCategory(valSet);
621 pCBENCAnchorDetails->Enable(newSet > 1);
625 parentCanvas->ReloadVP();
626 }
else if (b_needRefresh) {
627 parentCanvas->Refresh(
true);
628 parentCanvas->InvalidateGL();
631 RefreshControlValues();
General purpose GUI support.