34#include <wx/arrimpl.cpp>
35#include <wx/datetime.h>
36#include <wx/clipbrd.h>
38#include <wx/printdlg.h>
39#include <wx/stattext.h>
40#include <wx/clrpicker.h>
41#include <wx/bmpbuttn.h>
69#include "androidUTIL.h"
70#include <QtWidgets/QScroller>
73#define EXTENDED_PROP_PAGE 2
75WX_DEFINE_OBJARRAY(ArrayOfBitmaps);
79OCPNIconCombo::OCPNIconCombo(wxWindow* parent, wxWindowID
id,
80 const wxString& value,
const wxPoint& pos,
81 const wxSize& size,
int n,
82 const wxString choices[],
long style,
83 const wxValidator& validator,
const wxString& name)
84 : wxOwnerDrawnComboBox(parent, id, value, pos, size, n, choices, style,
87 GetFont().GetPointSize() / g_Platform->getFontPointsperPixel();
88 itemHeight = (int)wxRound(fontHeight);
91OCPNIconCombo::~OCPNIconCombo() {}
93void OCPNIconCombo::OnDrawItem(wxDC& dc,
const wxRect& rect,
int item,
95 int offset_x = bmpArray[item].GetWidth();
96 int bmpHeight = bmpArray[item].GetHeight();
97 dc.DrawBitmap(bmpArray[item], rect.x, rect.y + (rect.height - bmpHeight) / 2,
100 if (flags & wxODCB_PAINTING_CONTROL) {
101 wxString text = GetValue();
104#if wxCHECK_VERSION(2, 9, 0)
105 if (ShouldUseHintText()) {
107 wxColour col = wxSystemSettings::GetColour(wxSYS_COLOUR_GRAYTEXT);
108 dc.SetTextForeground(col);
111 margin_x = GetMargins().x;
114 dc.DrawText(text, rect.x + margin_x + offset_x,
115 (rect.height - dc.GetCharHeight()) / 2 + rect.y);
117 dc.DrawText(GetVListBoxComboPopup()->GetString(item), rect.x + 2 + offset_x,
118 (rect.height - dc.GetCharHeight()) / 2 + rect.y);
122wxCoord OCPNIconCombo::OnMeasureItem(
size_t item)
const {
123 int bmpHeight = bmpArray[item].GetHeight();
125 return wxMax(itemHeight, bmpHeight);
128wxCoord OCPNIconCombo::OnMeasureItemWidth(
size_t item)
const {
return -1; }
130int OCPNIconCombo::Append(
const wxString& item, wxBitmap bmp) {
132 int idx = wxOwnerDrawnComboBox::Append(item);
137void OCPNIconCombo::Clear() {
138 wxOwnerDrawnComboBox::Clear();
161 const wxString& value, const wxPoint& pos,
162 const wxSize& size,
long style,
163 const wxValidator& validator,
164 const wxString& name)
165 : wxTextCtrl(parent,
id, value, pos, size, style, validator, name) {
166 m_pParentEventHandler = parent->GetEventHandler();
169void LatLonTextCtrl::OnKillFocus(wxFocusEvent& event) {
172 up_event.SetEventObject((wxObject*)
this);
173 m_pParentEventHandler->AddPendingEvent(up_event);
182EVT_BUTTON(wxID_OK, MarkInfoDlg::OnMarkInfoOKClick)
183EVT_BUTTON(wxID_CANCEL, MarkInfoDlg::OnMarkInfoCancelClick)
184EVT_BUTTON(ID_BTN_DESC_BASIC, MarkInfoDlg::OnExtDescriptionClick)
185EVT_BUTTON(ID_DEFAULT, MarkInfoDlg::DefautlBtnClicked)
186EVT_BUTTON(ID_BTN_SHOW_TIDES, MarkInfoDlg::ShowTidesBtnClicked)
187EVT_COMBOBOX(ID_BITMAPCOMBOCTRL, MarkInfoDlg::OnBitmapCombClick)
188EVT_CHECKBOX(ID_CHECKBOX_SCAMIN_VIS, MarkInfoDlg::OnSelectScaMinExt)
189EVT_TEXT(ID_DESCR_CTR_DESC, MarkInfoDlg::OnDescChangedExt)
190EVT_TEXT(ID_DESCR_CTR_BASIC, MarkInfoDlg::OnDescChangedBasic)
191EVT_TEXT(ID_LATCTRL, MarkInfoDlg::OnPositionCtlUpdated)
192EVT_TEXT(ID_LONCTRL, MarkInfoDlg::OnPositionCtlUpdated)
193EVT_CHOICE(ID_WPT_RANGERINGS_NO, MarkInfoDlg::OnWptRangeRingsNoChange)
195EVT_HTML_LINK_CLICKED(wxID_ANY, MarkInfoDlg::OnHtmlLinkClicked)
196EVT_COMMAND(wxID_ANY, EVT_LAYOUT_RESIZE, MarkInfoDlg::OnLayoutResize)
197EVT_CLOSE(MarkInfoDlg::OnClose)
203 const wxPoint& pos, const wxSize& size,
long style) {
204 DIALOG_PARENT::Create(parent,
id, title, pos, size, style);
208 int metric = GetCharHeight();
212 wxString wqs = getFontQtStylesheet(qFont);
213 wxCharBuffer sbuf = wqs.ToUTF8();
214 QString qsb = QString(sbuf.data());
215 QString qsbq = getQtStyleSheet();
216 this->GetHandle()->setStyleSheet(qsb + qsbq);
218 if (sdc.IsOk()) sdc.GetTextExtent(
"W", NULL, &metric, NULL, NULL, qFont);
221 m_pMyLinkList = NULL;
222 SetColorScheme((ColorScheme)0);
223 m_pRoutePoint = NULL;
224 m_SaveDefaultDlg = NULL;
228 Connect(wxEVT_ACTIVATE, wxActivateEventHandler(MarkInfoDlg::OnActivate), NULL,
233void MarkInfoDlg::OnActivate(wxActivateEvent& event) {
234 auto pWin =
dynamic_cast<DIALOG_PARENT*
>(
event.GetEventObject());
235 long int style = pWin->GetWindowStyle();
236 if (event.GetActive())
237 pWin->SetWindowStyle(style | wxSTAY_ON_TOP);
239 pWin->SetWindowStyle(style ^ wxSTAY_ON_TOP);
242void MarkInfoDlg::initialize_images() {
243 wxString iconDir = g_Platform->GetSharedDataDir() +
"uidata/MUI_flat/";
244 _img_MUI_settings_svg =
LoadSVG(iconDir +
"MUI_settings.svg",
245 2 * GetCharHeight(), 2 * GetCharHeight());
248 wxBitmap tide = style->GetIcon(
"tidesml");
249 wxImage tide1 = tide.ConvertToImage();
250 wxImage tide1s = tide1.Scale(m_sizeMetric * 3 / 2, m_sizeMetric * 3 / 2,
251 wxIMAGE_QUALITY_HIGH);
252 m_bmTide = wxBitmap(tide1s);
257void MarkInfoDlg::Create() {
260 m_sizeMetric = GetCharHeight();
265 wxString wqs = getFontQtStylesheet(qFont);
266 wxCharBuffer sbuf = wqs.ToUTF8();
267 QString qsb = QString(sbuf.data());
269 QString qsbq = getAdjustedDialogStyleSheet();
271 this->GetHandle()->setStyleSheet(qsb + qsbq);
275 sdc.GetTextExtent(
"W", NULL, &m_sizeMetric, NULL, NULL, qFont);
282 bSizer1 =
new wxBoxSizer(wxVERTICAL);
284 bSizer1->SetSizeHints(
this);
287 m_notebookProperties =
new wxNotebook(
this, wxID_ANY, wxDefaultPosition,
288 wxDefaultSize, wxNB_FIXEDWIDTH);
290 m_panelBasicProperties =
new wxScrolledWindow(
291 m_notebookProperties, wxID_ANY, wxDefaultPosition, wxDefaultSize,
292 wxHSCROLL | wxVSCROLL | wxTAB_TRAVERSAL);
294 m_panelBasicProperties->GetHandle()->setStyleSheet(
295 getAdjustedDialogStyleSheet());
299 m_panelBasicProperties->SetScrollRate(0, 2);
300 m_notebookProperties->AddPage(m_panelBasicProperties, _(
"Basic"),
true);
301 bSizerBasicProperties =
new wxBoxSizer(wxVERTICAL);
302 m_panelBasicProperties->SetSizer(bSizerBasicProperties);
305 m_staticTextLayer =
new wxStaticText(
306 m_panelBasicProperties, wxID_ANY,
307 _(
"This waypoint is part of a layer and can't be edited"),
308 wxDefaultPosition, wxDefaultSize, 0);
309 m_staticTextLayer->Enable(
false);
310 bSizerBasicProperties->Add(m_staticTextLayer, 0, wxALL, 5);
313 wxPanel* props_panel =
new wxPanel(m_panelBasicProperties);
315 props_panel->SetSizer(props_sizer);
316 bSizerBasicProperties->Add(props_panel, 0, wxALL | wxEXPAND, 16);
317 int label_size = m_sizeMetric * 4;
320 m_textName =
new TextField(props_panel, _(
"Name"));
323 wxStaticText* name_cb_label =
324 new wxStaticText(props_panel, wxID_ANY, _(
"Show waypoint name"));
326 new wxCheckBox(props_panel, wxID_ANY,
"", wxDefaultPosition,
327 wxDefaultSize, wxALIGN_CENTER_VERTICAL);
328 m_checkBoxShowName->Bind(wxEVT_CHECKBOX,
329 &MarkInfoDlg::OnShowWaypointNameSelectBasic,
this);
330 props_sizer->Add(name_cb_label, 0, wxALIGN_TOP);
331 props_sizer->Add(m_checkBoxShowName, 0, wxEXPAND);
334 int icon_size = m_sizeMetric * 2;
335 icon_size = wxMax(icon_size, (32 * g_MarkScaleFactorExp) + 4);
337 new OCPNIconCombo(props_panel, wxID_ANY, _(
"Combo!"), wxDefaultPosition,
338 wxDefaultSize, 0, NULL, wxCB_READONLY);
339 m_bcomboBoxIcon->SetPopupMaxHeight(::wxGetDisplaySize().y / 2);
340 m_bcomboBoxIcon->SetMinSize(wxSize(-1, icon_size));
342 wxStaticText* icon_label =
new wxStaticText(props_panel, wxID_ANY, _(
"Icon"));
343 icon_label->SetMinSize(wxSize(label_size, -1));
344 props_sizer->Add(icon_label, 0, wxALIGN_CENTER_VERTICAL);
345 props_sizer->Add(m_bcomboBoxIcon, 0, wxEXPAND);
348 m_textLatitude =
new TextField(props_panel, _(
"Latitude"));
349 m_textLongitude =
new TextField(props_panel, _(
"Longitude"));
350 props_sizer->Fit(props_panel);
353 wxStaticBox* desc_box =
354 new wxStaticBox(m_panelBasicProperties, wxID_ANY, _(
"Description"));
355 wxStaticBoxSizer* desc_sizer =
new wxStaticBoxSizer(desc_box, wxHORIZONTAL);
356 bSizerBasicProperties->Add(desc_sizer, 1, wxALL | wxEXPAND, 8);
357 m_textDescription =
new wxTextCtrl(m_panelBasicProperties, ID_DESCR_CTR_BASIC,
358 "", wxDefaultPosition, wxDefaultSize,
359 wxTE_MULTILINE | wxTE_READONLY);
360 m_textDescription->SetMinSize(wxSize(-1, 80));
361 desc_sizer->Add(m_textDescription, 1, wxEXPAND);
364 m_buttonExtDescription =
365 new wxButton(m_panelBasicProperties, ID_BTN_DESC_BASIC,
"...",
366 wxDefaultPosition, wxSize(GetCharHeight() * 15 / 10, -1), 0);
367 desc_sizer->Add(m_buttonExtDescription, 0, wxEXPAND);
370 wxStaticBox* links_box =
371 new wxStaticBox(m_panelBasicProperties, wxID_ANY, _(
"Links"));
372 wxStaticBoxSizer* links_sizer =
new wxStaticBoxSizer(links_box, wxHORIZONTAL);
373 bSizerBasicProperties->Add(links_sizer, 1, wxALL | wxEXPAND, 8);
376 m_htmlList =
new wxSimpleHtmlListBox(m_panelBasicProperties, wxID_ANY,
377 wxDefaultPosition, wxDefaultSize, 0);
378 links_sizer->Add(m_htmlList, 1, wxEXPAND);
381 m_scrolledWindowLinks =
382 new wxScrolledWindow(m_panelBasicProperties, wxID_ANY, wxDefaultPosition,
383 wxSize(-1, 100), wxHSCROLL | wxVSCROLL);
384 m_scrolledWindowLinks->SetMinSize(wxSize(-1, 80));
385 m_scrolledWindowLinks->SetScrollRate(2, 2);
386 links_sizer->Add(m_scrolledWindowLinks, 1, wxEXPAND);
388 bSizerLinks =
new wxBoxSizer(wxVERTICAL);
389 m_scrolledWindowLinks->SetSizer(bSizerLinks);
391 m_menuLink =
new wxMenu();
392 wxMenuItem* m_menuItemDelete;
393 m_menuItemDelete =
new wxMenuItem(m_menuLink, wxID_ANY, wxString(_(
"Delete")),
395 m_menuLink->Append(m_menuItemDelete);
397 wxMenuItem* m_menuItemEdit;
398 m_menuItemEdit =
new wxMenuItem(m_menuLink, wxID_ANY, wxString(_(
"Edit")),
"",
400 m_menuLink->Append(m_menuItemEdit);
402 wxMenuItem* m_menuItemAdd;
403 m_menuItemAdd =
new wxMenuItem(m_menuLink, wxID_ANY, wxString(_(
"Add new")),
405 m_menuLink->Append(m_menuItemAdd);
407 wxBoxSizer* bSizer9 =
new wxBoxSizer(wxHORIZONTAL);
410 new wxButton(m_panelBasicProperties, wxID_ANY, _(
"Add new"),
411 wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT);
412 bSizer9->Add(m_buttonAddLink, 0, wxALL, 5);
414 m_buttonAddLink->Connect(wxEVT_COMMAND_BUTTON_CLICKED,
415 wxCommandEventHandler(MarkInfoDlg::OnAddLink), NULL,
418 links_sizer->Add(bSizer9, 0, wxEXPAND, 5);
423 new wxPanel(m_notebookProperties, wxID_ANY, wxDefaultPosition,
424 wxDefaultSize, wxTAB_TRAVERSAL);
425 wxBoxSizer* bSizer15;
426 bSizer15 =
new wxBoxSizer(wxVERTICAL);
428 m_textCtrlExtDescription =
429 new wxTextCtrl(m_panelDescription, ID_DESCR_CTR_DESC,
"",
430 wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE);
431 bSizer15->Add(m_textCtrlExtDescription, 1, wxALL | wxEXPAND, 5);
433 m_panelDescription->SetSizer(bSizer15);
434 m_notebookProperties->AddPage(m_panelDescription, _(
"Description"),
false);
439 m_panelExtendedProperties =
new wxScrolledWindow(
440 m_notebookProperties, wxID_ANY, wxDefaultPosition, wxDefaultSize,
441 wxHSCROLL | wxVSCROLL | wxTAB_TRAVERSAL);
443 m_panelExtendedProperties->GetHandle()->setStyleSheet(
444 getAdjustedDialogStyleSheet());
447 m_panelExtendedProperties->SetScrollRate(0, 2);
449 wxBoxSizer* fSizerExtProperties =
new wxBoxSizer(wxVERTICAL);
450 m_panelExtendedProperties->SetSizer(fSizerExtProperties);
451 m_notebookProperties->AddPage(m_panelExtendedProperties, _(
"Extended"),
454 sbSizerExtProperties =
new wxStaticBoxSizer(
455 wxVERTICAL, m_panelExtendedProperties, _(
"Extended Properties"));
456 wxFlexGridSizer* gbSizerInnerExtProperties =
new wxFlexGridSizer(3, 0, 0);
457 gbSizerInnerExtProperties->AddGrowableCol(2);
458 gbSizerInnerExtProperties->SetFlexibleDirection(wxBOTH);
459 gbSizerInnerExtProperties->SetNonFlexibleGrowMode(wxFLEX_GROWMODE_SPECIFIED);
461 m_checkBoxVisible =
new wxCheckBox(sbSizerExtProperties->GetStaticBox(),
462 ID_CHECKBOX_VIS_EXT,
"");
463 gbSizerInnerExtProperties->Add(m_checkBoxVisible);
464 wxStaticText* m_staticTextVisible =
new wxStaticText(
465 sbSizerExtProperties->GetStaticBox(), wxID_ANY, _(
"Show on chart"));
466 gbSizerInnerExtProperties->Add(m_staticTextVisible);
467 gbSizerInnerExtProperties->Add(0, 0, 1, wxEXPAND, 0);
469 m_checkBoxScaMin =
new wxCheckBox(sbSizerExtProperties->GetStaticBox(),
470 ID_CHECKBOX_SCAMIN_VIS,
"");
471 gbSizerInnerExtProperties->Add(m_checkBoxScaMin, 0, wxALIGN_CENTRE_VERTICAL,
473 m_staticTextScaMin =
new wxStaticText(sbSizerExtProperties->GetStaticBox(),
474 wxID_ANY, _(
"Show at scale > 1 :"));
475 gbSizerInnerExtProperties->Add(m_staticTextScaMin, 0, wxALIGN_CENTRE_VERTICAL,
477 m_textScaMin =
new wxTextCtrl(sbSizerExtProperties->GetStaticBox(), wxID_ANY);
478 gbSizerInnerExtProperties->Add(m_textScaMin, 0, wxALL | wxEXPAND, 5);
480 m_checkBoxShowNameExt =
481 new wxCheckBox(sbSizerExtProperties->GetStaticBox(), wxID_ANY,
"");
482 m_checkBoxShowNameExt->Bind(wxEVT_CHECKBOX,
483 &MarkInfoDlg::OnShowWaypointNameSelectExt,
this);
484 gbSizerInnerExtProperties->Add(m_checkBoxShowNameExt);
485 m_staticTextShowNameExt =
new wxStaticText(
486 sbSizerExtProperties->GetStaticBox(), wxID_ANY, _(
"Show waypoint name"));
488 gbSizerInnerExtProperties->Add(m_staticTextShowNameExt);
489 gbSizerInnerExtProperties->Add(0, 0, 1, wxEXPAND, 0);
491 sbRangeRingsExtProperties =
new wxStaticBoxSizer(
492 wxVERTICAL, sbSizerExtProperties->GetStaticBox(), _(
"Range rings"));
493 wxFlexGridSizer* gbRRExtProperties =
new wxFlexGridSizer(4, 0, 0);
494 gbRRExtProperties->AddGrowableCol(0);
495 gbRRExtProperties->AddGrowableCol(1);
496 gbRRExtProperties->AddGrowableCol(3);
497 m_staticTextRR1 =
new wxStaticText(sbSizerExtProperties->GetStaticBox(),
498 wxID_ANY, _(
"Number"));
499 gbRRExtProperties->Add(m_staticTextRR1, 0, wxLEFT, 5);
500 m_staticTextRR2 =
new wxStaticText(sbSizerExtProperties->GetStaticBox(),
501 wxID_ANY, _(
"Distance"));
502 gbRRExtProperties->Add(m_staticTextRR2, 0, wxLEFT, 5);
503 gbRRExtProperties->Add(0, 0, 1, wxEXPAND, 5);
504 m_staticTextRR4 =
new wxStaticText(sbSizerExtProperties->GetStaticBox(),
505 wxID_ANY, _(
"Color"));
506 gbRRExtProperties->Add(m_staticTextRR4, 0, wxLEFT, 5);
508 wxString rrAlt[] = {_(
"None"),
"1",
"2",
"3",
"4",
"5",
509 "6",
"7",
"8",
"9",
"10"};
510 m_ChoiceWaypointRangeRingsNumber =
511 new wxChoice(sbSizerExtProperties->GetStaticBox(), ID_WPT_RANGERINGS_NO,
512 wxDefaultPosition, wxDefaultSize, 11, rrAlt);
514 gbRRExtProperties->Add(m_ChoiceWaypointRangeRingsNumber, 0, wxALL | wxEXPAND,
516 m_textWaypointRangeRingsStep =
517 new wxTextCtrl(sbSizerExtProperties->GetStaticBox(), wxID_ANY, _(
"0.05"),
518 wxDefaultPosition, wxDefaultSize, 0);
519 gbRRExtProperties->Add(m_textWaypointRangeRingsStep, 0, wxALL | wxEXPAND, 5);
521 wxString pDistUnitsStrings[] = {_(
"NMi"), _(
"km")};
523 new wxChoice(sbSizerExtProperties->GetStaticBox(), wxID_ANY,
524 wxDefaultPosition, wxDefaultSize, 2, pDistUnitsStrings);
525 gbRRExtProperties->Add(m_RangeRingUnits, 0, wxALIGN_CENTRE_VERTICAL, 0);
527 m_PickColor =
new wxColourPickerCtrl(sbSizerExtProperties->GetStaticBox(),
528 wxID_ANY, wxColour(0, 0, 0),
529 wxDefaultPosition, wxDefaultSize, 0);
530 gbRRExtProperties->Add(m_PickColor, 0, wxALL | wxEXPAND, 5);
531 sbRangeRingsExtProperties->Add(
532 gbRRExtProperties, 1,
533 wxLEFT | wxTOP | wxEXPAND | wxALIGN_LEFT | wxALIGN_TOP, 5);
535 sbSizerExtProperties->GetStaticBox()->Layout();
537 wxFlexGridSizer* gbSizerInnerExtProperties2 =
new wxFlexGridSizer(2, 0, 0);
538 gbSizerInnerExtProperties2->AddGrowableCol(1);
541 new wxStaticText(sbSizerExtProperties->GetStaticBox(), wxID_ANY,
542 _(
"GUID"), wxDefaultPosition, wxDefaultSize, 0);
543 gbSizerInnerExtProperties2->Add(m_staticTextGuid, 0, wxALIGN_CENTRE_VERTICAL,
546 new wxTextCtrl(sbSizerExtProperties->GetStaticBox(), wxID_ANY,
"",
547 wxDefaultPosition, wxDefaultSize, wxTE_READONLY);
548 m_textCtrlGuid->SetEditable(
false);
549 gbSizerInnerExtProperties2->Add(m_textCtrlGuid, 0, wxALL | wxEXPAND, 5);
551 wxFlexGridSizer* gbSizerInnerExtProperties1 =
new wxFlexGridSizer(3, 0, 0);
552 gbSizerInnerExtProperties1->AddGrowableCol(1);
554 m_staticTextTideStation =
555 new wxStaticText(sbSizerExtProperties->GetStaticBox(), wxID_ANY,
556 _(
"Tide Station"), wxDefaultPosition, wxDefaultSize, 0);
557 gbSizerInnerExtProperties1->Add(m_staticTextTideStation, 0,
558 wxALIGN_CENTRE_VERTICAL, 5);
561 m_choiceTideChoices.Add(
" ");
562 m_comboBoxTideStation =
563 new wxChoice(sbSizerExtProperties->GetStaticBox(), wxID_ANY,
564 wxDefaultPosition, wxDefaultSize, m_choiceTideChoices);
566 gbSizerInnerExtProperties1->Add(
567 m_comboBoxTideStation, 0, wxALL | wxEXPAND | wxALIGN_CENTRE_VERTICAL, 5);
570 m_comboBoxTideStation =
571 new wxComboBox(sbSizerExtProperties->GetStaticBox(), wxID_ANY,
"",
572 wxDefaultPosition, wxDefaultSize, 0, NULL, wxCB_READONLY);
573 gbSizerInnerExtProperties1->Add(
574 m_comboBoxTideStation, 0, wxALL | wxEXPAND | wxALIGN_CENTRE_VERTICAL, 5);
576 m_comboBoxTideStation->SetToolTip(
577 _(
"Associate this waypoint with a tide station to quickly access tide "
578 "predictions. Select from nearby stations or leave empty for no "
581 m_buttonShowTides =
new wxBitmapButton(
582 sbSizerExtProperties->GetStaticBox(), ID_BTN_SHOW_TIDES, m_bmTide,
583 wxDefaultPosition, m_bmTide.GetSize(), 0);
584 gbSizerInnerExtProperties1->Add(m_buttonShowTides, 0,
585 wxALL | wxALIGN_CENTRE_VERTICAL, 5);
587 m_staticTextArrivalRadius =
new wxStaticText(
588 sbSizerExtProperties->GetStaticBox(), wxID_ANY, _(
"Arrival Radius"));
589 gbSizerInnerExtProperties1->Add(m_staticTextArrivalRadius, 0,
590 wxALIGN_CENTRE_VERTICAL, 0);
591 m_textArrivalRadius =
592 new wxTextCtrl(sbSizerExtProperties->GetStaticBox(), wxID_ANY,
"",
593 wxDefaultPosition, wxDefaultSize, 0);
594 m_textArrivalRadius->SetToolTip(
595 _(
"Distance from the waypoint at which OpenCPN will consider the "
596 "waypoint reached. Used for automatic waypoint advancement during "
597 "active navigation."));
598 gbSizerInnerExtProperties1->Add(m_textArrivalRadius, 0, wxALL | wxEXPAND, 5);
599 m_staticTextArrivalUnits =
600 new wxStaticText(sbSizerExtProperties->GetStaticBox(), wxID_ANY,
"",
601 wxDefaultPosition, wxDefaultSize, 0);
602 gbSizerInnerExtProperties1->Add(m_staticTextArrivalUnits, 0,
603 wxALIGN_CENTRE_VERTICAL, 0);
605 m_staticTextPlSpeed =
606 new wxStaticText(sbSizerExtProperties->GetStaticBox(), wxID_ANY,
607 _(
"Planned Speed"), wxDefaultPosition, wxDefaultSize, 0);
608 gbSizerInnerExtProperties1->Add(m_staticTextPlSpeed, 0,
609 wxALIGN_CENTRE_VERTICAL, 0);
611 new wxTextCtrl(sbSizerExtProperties->GetStaticBox(), wxID_ANY,
"",
612 wxDefaultPosition, wxDefaultSize, 0);
614 "Enter the planned vessel speed for the leg FOLLOWING this waypoint. "
615 "This speed is used when traveling FROM this waypoint TO the next "
616 "waypoint in the route. The value is used to calculate estimated time "
617 "of arrival at the next waypoint based on the ETD from this waypoint.\n\n"
618 "If left blank, the route's default speed will be used for this leg. "
619 "Individual waypoint speeds override the route-level speed setting."));
621 m_staticTextPlSpeedUnits =
622 new wxStaticText(sbSizerExtProperties->GetStaticBox(), wxID_ANY,
623 getUsrSpeedUnit(), wxDefaultPosition, wxDefaultSize, 0);
624 gbSizerInnerExtProperties1->Add(m_staticTextPlSpeedUnits, 0,
625 wxALIGN_CENTRE_VERTICAL, 0);
629 m_staticTextEtd =
new wxStaticText(sbSizerExtProperties->GetStaticBox(),
631 gbSizerInnerExtProperties1->Add(
m_staticTextEtd, 0, wxALIGN_CENTRE_VERTICAL,
633 wxBoxSizer* bsTimestamp =
new wxBoxSizer(wxHORIZONTAL);
635 new wxCheckBox(sbSizerExtProperties->GetStaticBox(), wxID_ANY,
"");
637 _(
"Enable to manually set a planned departure time (ETD) for this "
639 "When checked, the specified date and time will be used instead of the "
640 "automatically calculated ETD. This affects ETA calculations for "
641 "subsequent waypoints in the route."));
644 sbSizerExtProperties->GetStaticBox(), ID_ETA_DATEPICKERCTRL,
645 wxDefaultDateTime, wxDefaultPosition, wxDefaultSize, wxDP_DEFAULT,
648 "Select the planned departure date (ETD) for this waypoint.\nUsed "
649 "together with the time control to calculate arrival times at subsequent "
650 "waypoints.\nETD information is only used for route planning "
651 "and does not affect navigation."));
656 new TimeCtrl(sbSizerExtProperties->GetStaticBox(), ID_ETA_TIMEPICKERCTRL,
657 wxDefaultDateTime, wxDefaultPosition, wxDefaultSize);
660 sbSizerExtProperties->GetStaticBox(), ID_ETA_TIMEPICKERCTRL,
661 wxDefaultDateTime, wxDefaultPosition, wxDefaultSize, wxDP_DEFAULT,
666 gbSizerInnerExtProperties1->Add(bsTimestamp, 0, wxEXPAND, 0);
667 sbSizerExtProperties->Add(gbSizerInnerExtProperties, 0, wxALL | wxEXPAND, 5);
668 sbSizerExtProperties->Add(sbRangeRingsExtProperties, 0, wxALL | wxEXPAND, 5);
669 sbSizerExtProperties->Add(gbSizerInnerExtProperties2, 0, wxALL | wxEXPAND, 5);
670 sbSizerExtProperties->Add(gbSizerInnerExtProperties1, 0, wxALL | wxEXPAND, 5);
672 fSizerExtProperties->Add(sbSizerExtProperties, 1, wxALL | wxEXPAND);
675 bSizer1->Add(m_notebookProperties, 1, wxEXPAND);
677 wxBoxSizer* btnSizer =
new wxBoxSizer(wxHORIZONTAL);
678 bSizer1->Add(btnSizer, 0, wxEXPAND, 0);
681 new wxBitmapButton(
this, ID_DEFAULT, _img_MUI_settings_svg,
682 wxDefaultPosition, _img_MUI_settings_svg.GetSize(), 0);
683 btnSizer->Add(DefaultsBtn, 0, wxALL | wxALIGN_LEFT | wxALIGN_BOTTOM, 5);
684 btnSizer->Add(0, 0, 1, wxEXPAND);
686 m_sdbSizerButtons =
new wxStdDialogButtonSizer();
687 m_buttonOkay =
new wxButton(
this, wxID_OK);
688 m_sdbSizerButtons->AddButton(m_buttonOkay);
689 m_sdbSizerButtons->AddButton(
new wxButton(
this, wxID_CANCEL, _(
"Cancel")));
690 m_sdbSizerButtons->Realize();
691 btnSizer->Add(m_sdbSizerButtons, 0, wxALL, 5);
696 m_textLatitude->Connect(
698 wxCommandEventHandler(MarkInfoDlg::OnRightClickLatLon), NULL,
this);
699 m_textLongitude->Connect(
701 wxCommandEventHandler(MarkInfoDlg::OnRightClickLatLon), NULL,
this);
703 m_htmlList->Connect(wxEVT_RIGHT_DOWN,
704 wxMouseEventHandler(MarkInfoDlg::m_htmlListContextMenu),
708 m_notebookProperties->Connect(
709 wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED,
710 wxNotebookEventHandler(MarkInfoDlg::OnNotebookPageChanged), NULL,
this);
715 m_comboBoxTideStation->Connect(
716 wxEVT_COMMAND_COMBOBOX_SELECTED,
717 wxCommandEventHandler(MarkInfoDlg::OnTideStationCombobox), NULL,
this);
720void MarkInfoDlg::OnClose(wxCloseEvent& event) {
726#define TIDESTATION_BATCH_SIZE 10
728void MarkInfoDlg::OnTideStationCombobox(wxCommandEvent& event) {
729 int count = m_comboBoxTideStation->GetCount();
730 int sel = m_comboBoxTideStation->GetSelection();
731 if (sel == count - 1) {
734 for (
auto ts : m_tss) {
735 if (i == count + TIDESTATION_BATCH_SIZE) {
739 n = wxString::FromUTF8(ts.second->IDX_station_name);
740 m_comboBoxTideStation->Append(n);
747void MarkInfoDlg::OnNotebookPageChanged(wxNotebookEvent& event) {
748 if (event.GetSelection() == EXTENDED_PROP_PAGE) {
749 if (m_lasttspos.IsSameAs(m_textLatitude->GetValue() +
750 m_textLongitude->GetValue())) {
753 m_lasttspos = m_textLatitude->GetValue() + m_textLongitude->GetValue();
754 double lat = fromDMM(m_textLatitude->GetValue());
755 double lon = fromDMM(m_textLongitude->GetValue());
756 m_tss =
ptcmgr->GetStationsForLL(lat, lon);
757 wxString s = m_comboBoxTideStation->GetStringSelection();
760 m_comboBoxTideStation->Clear();
761 m_comboBoxTideStation->Append(
"");
762 for (
auto ts : m_tss) {
763 if (i == TIDESTATION_BATCH_SIZE) {
767 n = wxString::FromUTF8(ts.second->IDX_station_name);
768 m_comboBoxTideStation->Append(n);
770 m_comboBoxTideStation->SetSelection(i);
773 if (m_comboBoxTideStation->GetStringSelection() != s) {
774 m_comboBoxTideStation->Insert(s, 1);
775 m_comboBoxTideStation->SetSelection(1);
780void MarkInfoDlg::RecalculateSize() {
785 wxSize dsize = GetParent()->GetClientSize();
789 esize.x = GetCharHeight() * 20;
790 esize.y = GetCharHeight() * 40;
793 esize.y = wxMin(esize.y, dsize.y - (2 * GetCharHeight()));
794 esize.x = wxMin(esize.x, dsize.x - (1 * GetCharHeight()));
795 SetSize(wxSize(esize.x, esize.y));
798 wxSize fsize = GetSize();
799 fsize.y = wxMin(fsize.y, dsize.y - (2 * GetCharHeight()));
800 fsize.x = wxMin(fsize.x, dsize.x - (1 * GetCharHeight()));
804 fsize.y = wxMin(fsize.y, (25 * GetCharHeight()));
806 SetSize(wxSize(-1, fsize.y));
808 m_defaultClientSize = GetClientSize();
811 wxSize dsize = GetParent()->GetClientSize();
812 SetSize(-1, wxMax(GetSize().y, dsize.y / 1.5));
816MarkInfoDlg::~MarkInfoDlg() {
818 m_textLatitude->Disconnect(
820 wxCommandEventHandler(MarkInfoDlg::OnRightClickLatLon), NULL,
this);
821 m_textLongitude->Disconnect(
823 wxCommandEventHandler(MarkInfoDlg::OnRightClickLatLon), NULL,
this);
825 m_htmlList->Disconnect(
826 wxEVT_RIGHT_DOWN, wxMouseEventHandler(MarkInfoDlg::m_htmlListContextMenu),
831 m_notebookProperties->Disconnect(
832 wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED,
833 wxNotebookEventHandler(MarkInfoDlg::OnNotebookPageChanged), NULL,
this);
835 wxEVT_TIME_CHANGED, wxDateEventHandler(MarkInfoDlg::OnTimeChanged), NULL,
838 wxEVT_DATE_CHANGED, wxDateEventHandler(MarkInfoDlg::OnTimeChanged), NULL,
842 androidEnableBackButton(
true);
846void MarkInfoDlg::InitialFocus() {
847 m_textName->SetFocus();
848 m_textName->SetInsertionPointEnd();
851void MarkInfoDlg::SetColorScheme(ColorScheme cs) { DimeControl(
this); }
853void MarkInfoDlg::ClearData() {
854 m_pRoutePoint = NULL;
858void MarkInfoDlg::SetRoutePoint(
RoutePoint* pRP) {
861 m_lat_save = m_pRoutePoint->m_lat;
862 m_lon_save = m_pRoutePoint->m_lon;
863 m_IconName_save = m_pRoutePoint->GetIconName();
866 m_Name_save = m_pRoutePoint->GetName();
868 m_bUseScaMin_save = m_pRoutePoint->GetUseSca();
869 m_iScaminVal_save = m_pRoutePoint->GetScaMin();
871 if (m_pMyLinkList)
delete m_pMyLinkList;
872 m_pMyLinkList =
new HyperlinkList();
873 for (
Hyperlink* link : *m_pRoutePoint->m_HyperlinkList) {
875 h->DescrText = link->DescrText;
876 h->Link = link->Link;
877 h->LType = link->LType;
879 m_pMyLinkList->push_back(h);
884void MarkInfoDlg::UpdateHtmlList() {
886 GetSimpleBox()->Clear();
889 if (NbrOfLinks > 0) {
891 for (
auto it = list->begin(); it != list->end(); ++it) {
894 wxString::Format(
"<a href='%s'>%s</a>", link->Link, link->DescrText);
895 GetSimpleBox()->AppendString(s);
900 wxWindowList kids = m_scrolledWindowLinks->GetChildren();
901 for (
unsigned int i = 0; i < kids.GetCount(); i++) {
902 wxWindowListNode* node = kids.Item(i);
903 wxWindow* win = node->GetData();
905 auto link_win =
dynamic_cast<wxHyperlinkCtrl*
>(win);
907 link_win->Disconnect(
908 wxEVT_COMMAND_HYPERLINK,
909 wxHyperlinkEventHandler(MarkInfoDlg::OnHyperLinkClick));
910 link_win->Disconnect(
912 wxMouseEventHandler(MarkInfoDlg::m_htmlListContextMenu));
917 for (
Hyperlink* link : *m_pRoutePoint->m_HyperlinkList) {
918 wxString Link = link->Link;
919 wxString Descr = link->DescrText;
921 wxHyperlinkCtrl* ctrl =
new wxHyperlinkCtrl(
922 m_scrolledWindowLinks, wxID_ANY, Descr, Link, wxDefaultPosition,
923 wxDefaultSize, wxNO_BORDER | wxHL_CONTEXTMENU | wxHL_ALIGN_LEFT);
924 ctrl->Connect(wxEVT_COMMAND_HYPERLINK,
925 wxHyperlinkEventHandler(MarkInfoDlg::OnHyperLinkClick), NULL,
928 ctrl->Connect(wxEVT_RIGHT_DOWN,
929 wxMouseEventHandler(MarkInfoDlg::m_htmlListContextMenu),
932 bSizerLinks->Add(ctrl, 1, wxALL | wxEXPAND, 5);
936 m_scrolledWindowLinks->Layout();
940void MarkInfoDlg::OnHyperLinkClick(wxHyperlinkEvent& event) {
941 wxString url =
event.GetURL();
942 url.Replace(
" ",
"%20");
943 if (g_Platform) g_Platform->platformLaunchDefaultBrowser(url);
946void MarkInfoDlg::OnHtmlLinkClicked(wxHtmlLinkEvent& event) {
956 wxString cc =
event.GetLinkInfo().GetHref().c_str();
957 if (cc.Find(
"#") != wxNOT_FOUND) {
958 wxRegKey RegKey(wxString(
"HKEY_CLASSES_ROOT\\HTTP\\shell\\open\\command"));
959 if (RegKey.Exists()) {
960 wxString command_line;
961 RegKey.QueryValue(wxString(
""), command_line);
964 command_line.Replace(wxString(
"\""), wxString(
""));
967 int l = command_line.Find(
".exe");
968 if (wxNOT_FOUND == l) l = command_line.Find(
".EXE");
970 if (wxNOT_FOUND != l) {
971 wxString cl = command_line.Mid(0, l + 4);
980 wxString url =
event.GetLinkInfo().GetHref().c_str();
981 url.Replace(
" ",
"%20");
982 ::wxLaunchDefaultBrowser(url);
986 wxString url =
event.GetLinkInfo().GetHref().c_str();
987 url.Replace(
" ",
"%20");
988 if (g_Platform) g_Platform->platformLaunchDefaultBrowser(url);
994void MarkInfoDlg::OnLayoutResize(wxCommandEvent& event) {
995 m_panelBasicProperties->Layout();
999void MarkInfoDlg::OnDescChangedExt(wxCommandEvent& event) {
1000 if (m_panelDescription->IsShownOnScreen()) {
1001 m_textDescription->ChangeValue(m_textCtrlExtDescription->GetValue());
1005void MarkInfoDlg::OnDescChangedBasic(wxCommandEvent& event) {
1006 if (m_panelBasicProperties->IsShownOnScreen()) {
1007 m_textCtrlExtDescription->ChangeValue(m_textDescription->GetValue());
1012void MarkInfoDlg::OnExtDescriptionClick(wxCommandEvent& event) {
1013 long pos = m_textDescription->GetInsertionPoint();
1014 m_notebookProperties->SetSelection(1);
1015 m_textCtrlExtDescription->SetInsertionPoint(pos);
1019void MarkInfoDlg::OnShowWaypointNameSelectBasic(wxCommandEvent& event) {
1020 m_checkBoxShowNameExt->SetValue(m_checkBoxShowName->GetValue());
1023void MarkInfoDlg::OnShowWaypointNameSelectExt(wxCommandEvent& event) {
1024 m_checkBoxShowName->SetValue(m_checkBoxShowNameExt->GetValue());
1028void MarkInfoDlg::OnWptRangeRingsNoChange(wxCommandEvent& event) {
1030 m_textWaypointRangeRingsStep->Enable(
1031 (
bool)(m_ChoiceWaypointRangeRingsNumber->GetSelection() != 0));
1032 m_PickColor->Enable(
1033 (
bool)(m_ChoiceWaypointRangeRingsNumber->GetSelection() != 0));
1037void MarkInfoDlg::OnSelectScaMinExt(wxCommandEvent& event) {
1039 m_textScaMin->Enable(m_checkBoxScaMin->GetValue());
1043void MarkInfoDlg::OnPositionCtlUpdated(wxCommandEvent& event) {
1045 double lat = fromDMM(m_textLatitude->GetValue());
1046 double lon = fromDMM(m_textLongitude->GetValue());
1048 m_pRoutePoint->SetPosition(lat, lon);
1049 pSelect->ModifySelectablePoint(lat, lon, (
void*)m_pRoutePoint,
1050 SELTYPE_ROUTEPOINT);
1053 gFrame->RefreshAllCanvas();
1056void MarkInfoDlg::m_htmlListContextMenu(wxMouseEvent& event) {
1060 wxPoint pos =
event.GetPosition();
1061 i_htmlList_item = -1;
1062 for (
int i = 0; i < (int)GetSimpleBox()->GetCount(); i++) {
1063 wxRect rect = GetSimpleBox()->GetItemRect(i);
1064 if (rect.Contains(pos)) {
1065 i_htmlList_item = i;
1070 wxMenu* popup =
new wxMenu();
1071 if ((GetSimpleBox()->GetCount()) > 0 && (i_htmlList_item > -1) &&
1072 (i_htmlList_item < (
int)GetSimpleBox()->GetCount())) {
1073 popup->Append(ID_RCLK_MENU_DELETE_LINK, _(
"Delete"));
1074 popup->Append(ID_RCLK_MENU_EDIT_LINK, _(
"Edit"));
1076 popup->Append(ID_RCLK_MENU_ADD_LINK, _(
"Add New"));
1078 m_contextObject =
event.GetEventObject();
1080 wxEVT_COMMAND_MENU_SELECTED,
1081 wxCommandEventHandler(MarkInfoDlg::On_html_link_popupmenu_Click), NULL,
1087 m_pEditedLink =
dynamic_cast<wxHyperlinkCtrl*
>(
event.GetEventObject());
1089 if (m_pEditedLink) {
1090 wxString url = m_pEditedLink->GetURL();
1091 wxString label = m_pEditedLink->GetLabel();
1092 i_htmlList_item = -1;
1095 for (
Hyperlink* link : *hyperlinklist) {
1096 if (link->DescrText == label) {
1097 i_htmlList_item = i;
1105 wxMenu* popup =
new wxMenu();
1107 wxMenuItem* menuItemDelete =
1108 new wxMenuItem(popup, ID_RCLK_MENU_DELETE_LINK, wxString(_(
"Delete")),
1111 menuItemDelete->SetFont(sFont);
1113 popup->Append(menuItemDelete);
1115 wxMenuItem* menuItemEdit =
1116 new wxMenuItem(popup, ID_RCLK_MENU_EDIT_LINK, wxString(_(
"Edit")),
"",
1119 menuItemEdit->SetFont(sFont);
1121 popup->Append(menuItemEdit);
1124 wxMenuItem* menuItemAdd =
1125 new wxMenuItem(popup, ID_RCLK_MENU_ADD_LINK, wxString(_(
"Add New")),
"",
1128 menuItemAdd->SetFont(sFont);
1130 popup->Append(menuItemAdd);
1132 m_contextObject =
event.GetEventObject();
1134 wxEVT_COMMAND_MENU_SELECTED,
1135 wxCommandEventHandler(MarkInfoDlg::On_html_link_popupmenu_Click), NULL,
1137 wxPoint p = m_scrolledWindowLinks->GetPosition();
1138 p.x += m_scrolledWindowLinks->GetSize().x / 2;
1139 PopupMenu(popup, p);
1162void MarkInfoDlg::OnAddLink(wxCommandEvent& event) {
1163 wxCommandEvent evt(wxEVT_COMMAND_MENU_SELECTED);
1164 evt.SetId(ID_RCLK_MENU_ADD_LINK);
1166 On_html_link_popupmenu_Click(evt);
1169void MarkInfoDlg::On_html_link_popupmenu_Click(wxCommandEvent& event) {
1170 switch (event.GetId()) {
1171 case ID_RCLK_MENU_DELETE_LINK: {
1177 case ID_RCLK_MENU_EDIT_LINK: {
1181 LinkPropDlg->m_textCtrlLinkDescription->SetValue(link->DescrText);
1182 LinkPropDlg->m_textCtrlLinkUrl->SetValue(link->Link);
1183 DimeControl(LinkPropDlg);
1184 LinkPropDlg->ShowWindowModalThenDo([
this, LinkPropDlg,
1185 link](
int retcode) {
1186 if (retcode == wxID_OK) {
1187 link->DescrText = LinkPropDlg->m_textCtrlLinkDescription->GetValue();
1189 link->Link = LinkPropDlg->m_textCtrlLinkUrl->GetValue();
1196 case ID_RCLK_MENU_ADD_LINK: {
1198 LinkPropDlg->m_textCtrlLinkDescription->SetValue(
"");
1199 LinkPropDlg->m_textCtrlLinkUrl->SetValue(
"");
1200 DimeControl(LinkPropDlg);
1201 LinkPropDlg->ShowWindowModalThenDo([
this, LinkPropDlg](
int retcode) {
1202 if (retcode == wxID_OK) {
1204 link->DescrText = LinkPropDlg->m_textCtrlLinkDescription->GetValue();
1205 link->Link = LinkPropDlg->m_textCtrlLinkUrl->GetValue();
1207 if (link->DescrText ==
"") {
1208 link->DescrText = link->Link;
1210 if (link->Link ==
"") {
1213 m_pRoutePoint->m_HyperlinkList->push_back(link);
1224void MarkInfoDlg::OnRightClickLatLon(wxCommandEvent& event) {
1225 wxMenu* popup =
new wxMenu();
1226 popup->Append(ID_RCLK_MENU_COPY, _(
"Copy"));
1227 popup->Append(ID_RCLK_MENU_COPY_LL, _(
"Copy lat/long"));
1228 popup->Append(ID_RCLK_MENU_PASTE, _(
"Paste"));
1229 popup->Append(ID_RCLK_MENU_PASTE_LL, _(
"Paste lat/long"));
1230 m_contextObject =
event.GetEventObject();
1231 popup->Connect(wxEVT_COMMAND_MENU_SELECTED,
1232 wxCommandEventHandler(MarkInfoDlg::OnCopyPasteLatLon), NULL,
1239void MarkInfoDlg::OnCopyPasteLatLon(wxCommandEvent& event) {
1241 double lat = fromDMM(m_textLatitude->GetValue());
1242 double lon = fromDMM(m_textLongitude->GetValue());
1246 switch (event.GetId()) {
1247 case ID_RCLK_MENU_PASTE: {
1248 if (wxTheClipboard->Open()) {
1249 wxTextDataObject data;
1250 wxTheClipboard->GetData(data);
1251 result = data.GetText();
1252 ((wxTextCtrl*)m_contextObject)->SetValue(result);
1253 wxTheClipboard->Close();
1257 case ID_RCLK_MENU_PASTE_LL: {
1258 if (wxTheClipboard->Open()) {
1259 wxTextDataObject data;
1260 wxTheClipboard->GetData(data);
1261 result = data.GetText();
1265 if (pparse.IsOk()) {
1266 m_textLatitude->SetValue(pparse.GetLatitudeString());
1267 m_textLongitude->SetValue(pparse.GetLongitudeString());
1269 wxTheClipboard->Close();
1273 case ID_RCLK_MENU_COPY: {
1274 result = ((wxTextCtrl*)m_contextObject)->GetValue();
1277 case ID_RCLK_MENU_COPY_LL: {
1278 result << toSDMM(1, lat,
true) <<
'\t';
1279 result << toSDMM(2, lon,
true);
1284 if (wxTheClipboard->Open()) {
1285 wxTextDataObject* data =
new wxTextDataObject;
1286 data->SetText(result);
1287 wxTheClipboard->SetData(data);
1288 wxTheClipboard->Close();
1292void MarkInfoDlg::DefautlBtnClicked(wxCommandEvent& event) {
1294 m_SaveDefaultDlg->Center();
1295 DimeControl(m_SaveDefaultDlg);
1296 int retcode = m_SaveDefaultDlg->ShowModal();
1299 if (retcode == wxID_OK) {
1301 if (m_SaveDefaultDlg->IconCB->GetValue()) {
1303 *pWayPointMan->GetIconKey(m_bcomboBoxIcon->GetSelection());
1305 if (m_SaveDefaultDlg->RangRingsCB->GetValue()) {
1306 g_iWaypointRangeRingsNumber =
1307 m_ChoiceWaypointRangeRingsNumber->GetSelection();
1308 if (m_textWaypointRangeRingsStep->GetValue().ToDouble(&value))
1312 if (m_SaveDefaultDlg->ArrivalRCB->GetValue())
1313 if (m_textArrivalRadius->GetValue().ToDouble(&value))
1315 if (m_SaveDefaultDlg->ScaleCB->GetValue()) {
1316 g_iWpt_ScaMin = wxAtoi(m_textScaMin->GetValue());
1317 g_bUseWptScaMin = m_checkBoxScaMin->GetValue();
1319 if (m_SaveDefaultDlg->NameCB->GetValue()) {
1320 g_bShowWptName = m_checkBoxShowName->GetValue();
1323 m_SaveDefaultDlg = NULL;
1327void MarkInfoDlg::OnMarkInfoCancelClick(wxCommandEvent& event) {
1328 if (m_pRoutePoint) {
1329 m_pRoutePoint->SetVisible(m_bIsVisible_save);
1330 m_pRoutePoint->SetNameShown(m_bShowName_save);
1331 m_pRoutePoint->SetPosition(m_lat_save, m_lon_save);
1332 m_pRoutePoint->SetIconName(m_IconName_save);
1333 m_pRoutePoint->ReLoadIcon();
1334 m_pRoutePoint->SetName(m_Name_save);
1336 m_pRoutePoint->SetUseSca(m_bUseScaMin_save);
1337 m_pRoutePoint->SetScaMin(m_iScaminVal_save);
1341 int NbrOfLinks = m_pMyLinkList->size();
1342 if (NbrOfLinks > 0) {
1343 for (
Hyperlink* link : *m_pMyLinkList) {
1345 h->DescrText = link->DescrText;
1346 h->Link = link->Link;
1347 h->LType = link->LType;
1354 m_lasttspos.Clear();
1361 delete m_pMyLinkList;
1362 m_pMyLinkList = NULL;
1363 SetClientSize(m_defaultClientSize);
1366 androidEnableBackButton(
true);
1372void MarkInfoDlg::OnMarkInfoOKClick(wxCommandEvent& event) {
1373 if (m_pRoutePoint) {
1376 OnPositionCtlUpdated(event);
1386 if (pRouteManagerDialog && pRouteManagerDialog->IsShown())
1387 pRouteManagerDialog->UpdateWptListCtrl();
1392 SetClientSize(m_defaultClientSize);
1395 androidEnableBackButton(
true);
1401bool MarkInfoDlg::UpdateProperties(
bool positionOnly) {
1402 if (m_pRoutePoint) {
1403 m_textLatitude->SetValue(::toSDMM(1, m_pRoutePoint->m_lat));
1404 m_textLongitude->SetValue(::toSDMM(2, m_pRoutePoint->m_lon));
1405 m_lat_save = m_pRoutePoint->m_lat;
1406 m_lon_save = m_pRoutePoint->m_lon;
1407 m_textName->SetValue(m_pRoutePoint->GetName());
1410 m_checkBoxShowName->SetValue(m_pRoutePoint->
m_bShowName);
1411 m_checkBoxShowNameExt->SetValue(m_pRoutePoint->
m_bShowName);
1412 m_checkBoxVisible->SetValue(m_pRoutePoint->
m_bIsVisible);
1413 m_checkBoxScaMin->SetValue(m_pRoutePoint->GetUseSca());
1414 m_textScaMin->SetValue(
1415 wxString::Format(
"%i", (
int)m_pRoutePoint->GetScaMin()));
1416 m_textCtrlGuid->SetValue(m_pRoutePoint->
m_GUID);
1417 m_ChoiceWaypointRangeRingsNumber->SetSelection(
1418 m_pRoutePoint->GetWaypointRangeRingsNumber());
1421 toUsrDistance(m_pRoutePoint->GetWaypointRangeRingsStep(), -1));
1422 m_textWaypointRangeRingsStep->SetValue(buf);
1423 m_staticTextArrivalUnits->SetLabel(getUsrDistanceUnit());
1425 toUsrDistance(m_pRoutePoint->GetWaypointArrivalRadius(), -1));
1426 m_textArrivalRadius->SetValue(buf);
1428 int nUnits = m_pRoutePoint->GetWaypointRangeRingsStepUnits();
1429 m_RangeRingUnits->SetSelection(nUnits);
1432 m_PickColor->SetColour(col);
1435 if (m_name_validator) m_name_validator.reset();
1437 std::make_unique<RoutePointNameValidator>(m_pRoutePoint);
1438 m_textName->SetValidator(*m_name_validator);
1440 m_textName->Bind(wxEVT_KILL_FOCUS, &MarkInfoDlg::OnFocusEvent,
this);
1442 m_textName->SetValidator();
1444 m_textName->Unbind(wxEVT_KILL_FOCUS, &MarkInfoDlg::OnFocusEvent,
this);
1447 if (m_comboBoxTideStation->GetStringSelection() !=
1449 m_comboBoxTideStation->Clear();
1450 m_comboBoxTideStation->Append(
"");
1452 m_comboBoxTideStation->Append(m_pRoutePoint->
m_TideStation);
1453 m_comboBoxTideStation->SetSelection(1);
1457 m_staticTextPlSpeedUnits->SetLabel(getUsrSpeedUnit());
1465 bool isLastWaypoint =
false;
1468 wxArrayPtrVoid* pRouteArray =
1471 isLastWaypoint =
true;
1473 for (
unsigned int i = 0; i < pRouteArray->GetCount(); i++) {
1475 if (route->GetLastPoint()->
m_GUID != m_pRoutePoint->
m_GUID) {
1476 isLastWaypoint =
false;
1485 if (isLastWaypoint) {
1490 if (etd.IsValid()) {
1493 if (dtFormat ==
"Local Time") {
1497 }
else if (dtFormat ==
"UTC") {
1504 "MarkInfoDlg::UpdateProperties. Unexpected date/time format: %s",
1506 etd = wxInvalidDateTime;
1517 m_staticTextPlSpeed->Show(m_pRoutePoint->
m_bIsInRoute);
1523 m_staticTextPlSpeedUnits->Show(m_pRoutePoint->
m_bIsInRoute);
1524 m_staticTextArrivalRadius->Show(m_pRoutePoint->
m_bIsInRoute);
1525 m_staticTextArrivalUnits->Show(m_pRoutePoint->
m_bIsInRoute);
1526 m_textArrivalRadius->Show(m_pRoutePoint->
m_bIsInRoute);
1528 if (positionOnly)
return true;
1532 m_staticTextLayer->Enable();
1533 m_staticTextLayer->Show(
true);
1534 m_textName->SetEditable(
false);
1535 m_textDescription->SetEditable(
false);
1536 m_textCtrlExtDescription->SetEditable(
false);
1537 m_textLatitude->SetEditable(
false);
1538 m_textLongitude->SetEditable(
false);
1539 m_bcomboBoxIcon->Enable(
false);
1540 m_checkBoxShowName->Enable(
false);
1541 m_checkBoxVisible->Enable(
false);
1542 m_textArrivalRadius->SetEditable(
false);
1543 m_checkBoxScaMin->Enable(
false);
1544 m_textScaMin->SetEditable(
false);
1545 m_checkBoxShowNameExt->Enable(
false);
1546 m_ChoiceWaypointRangeRingsNumber->Enable(
false);
1547 m_textWaypointRangeRingsStep->SetEditable(
false);
1548 m_PickColor->Enable(
false);
1549 DefaultsBtn->Enable(
false);
1553 m_notebookProperties->SetSelection(0);
1554 m_comboBoxTideStation->Enable(
false);
1556 m_staticTextLayer->Enable(
false);
1557 m_staticTextLayer->Show(
false);
1558 m_textName->SetEditable(
true);
1559 m_textDescription->SetEditable(
true);
1560 m_textCtrlExtDescription->SetEditable(
true);
1561 m_textLatitude->SetEditable(
true);
1562 m_textLongitude->SetEditable(
true);
1563 m_bcomboBoxIcon->Enable(
true);
1564 m_checkBoxShowName->Enable(
true);
1565 m_checkBoxVisible->Enable(
true);
1566 m_textArrivalRadius->SetEditable(
true);
1567 m_checkBoxScaMin->Enable(
true);
1568 m_textScaMin->SetEditable(
true);
1569 m_checkBoxShowNameExt->Enable(
true);
1570 m_ChoiceWaypointRangeRingsNumber->Enable(
true);
1571 m_textWaypointRangeRingsStep->SetEditable(
true);
1572 m_PickColor->Enable(
true);
1573 DefaultsBtn->Enable(
true);
1574 m_notebookProperties->SetSelection(0);
1575 m_comboBoxTideStation->Enable(
true);
1585 m_bcomboBoxIcon->Clear();
1587 bool fillCombo = m_bcomboBoxIcon->GetCount() == 0;
1590 for (
int i = 0; i < pWayPointMan->GetNumIcons(); i++) {
1591 wxString* ps = pWayPointMan->GetIconDescription(i);
1593 pWayPointMan->GetIconBitmapForList(i, 2 * GetCharHeight());
1595 m_bcomboBoxIcon->Append(*ps, bmp);
1599 int iconToSelect = -1;
1600 for (
int i = 0; i < pWayPointMan->GetNumIcons(); i++) {
1601 if (*pWayPointMan->GetIconKey(i) == m_pRoutePoint->GetIconName()) {
1603 m_bcomboBoxIcon->Select(iconToSelect);
1608 OnShowWaypointNameSelectBasic(ev);
1609 OnWptRangeRingsNoChange(ev);
1610 OnSelectScaMinExt(ev);
1615 androidEnableBackButton(
false);
1626void MarkInfoDlg::OnFocusEvent(wxFocusEvent& event) {
1627 bool is_valid = Validate();
1628 m_buttonOkay->Enable(is_valid);
1632void MarkInfoDlg::OnBitmapCombClick(wxCommandEvent& event) {
1633 wxString* icon_name =
1634 pWayPointMan->GetIconKey(m_bcomboBoxIcon->GetSelection());
1635 if (icon_name && icon_name->Length()) m_pRoutePoint->SetIconName(*icon_name);
1636 m_pRoutePoint->ReLoadIcon();
1641void MarkInfoDlg::ValidateMark() {
1644 bool b_found =
false;
1645 for (
RoutePoint* rp : *pWayPointMan->GetWaypointList()) {
1646 if (m_pRoutePoint == rp) {
1651 if (!b_found) m_pRoutePoint = NULL;
1654bool MarkInfoDlg::SaveChanges() {
1655 if (m_pRoutePoint) {
1657 if (!this->Validate())
return false;
1660 m_pRoutePoint->SetName(m_textName->GetValue());
1661 m_pRoutePoint->SetWaypointArrivalRadius(m_textArrivalRadius->GetValue());
1662 m_pRoutePoint->SetScaMin(m_textScaMin->GetValue());
1663 m_pRoutePoint->SetUseSca(m_checkBoxScaMin->GetValue());
1665 m_pRoutePoint->SetVisible(m_checkBoxVisible->GetValue());
1666 m_pRoutePoint->
m_bShowName = m_checkBoxShowName->GetValue();
1667 m_pRoutePoint->SetPosition(fromDMM(m_textLatitude->GetValue()),
1668 fromDMM(m_textLongitude->GetValue()));
1669 wxString* icon_name =
1670 pWayPointMan->GetIconKey(m_bcomboBoxIcon->GetSelection());
1671 if (icon_name && icon_name->Length())
1672 m_pRoutePoint->SetIconName(*icon_name);
1673 m_pRoutePoint->ReLoadIcon();
1674 m_pRoutePoint->SetShowWaypointRangeRings(
1675 (
bool)(m_ChoiceWaypointRangeRingsNumber->GetSelection() != 0));
1676 m_pRoutePoint->SetWaypointRangeRingsNumber(
1677 m_ChoiceWaypointRangeRingsNumber->GetSelection());
1679 if (m_textWaypointRangeRingsStep->GetValue().ToDouble(&value))
1681 if (m_textArrivalRadius->GetValue().ToDouble(&value))
1684 if (m_RangeRingUnits->GetSelection() != wxNOT_FOUND)
1685 m_pRoutePoint->SetWaypointRangeRingsStepUnits(
1686 m_RangeRingUnits->GetSelection());
1688 m_pRoutePoint->
m_TideStation = m_comboBoxTideStation->GetStringSelection();
1690 m_pRoutePoint->SetPlannedSpeed(0.0);
1694 m_pRoutePoint->SetPlannedSpeed(fromUsrSpeed(spd));
1701 int hour = t.GetHour();
1711 if (dtFormat ==
"Local Time") {
1712 m_pRoutePoint->
SetETD(dt.MakeUTC());
1713 }
else if (dtFormat ==
"UTC") {
1714 m_pRoutePoint->
SetETD(dt);
1723 "Failed to configured ETD. Unsupported date/time format: %s",
1725 m_pRoutePoint->
SetETD(wxInvalidDateTime);
1729 m_pRoutePoint->
SetETD(wxInvalidDateTime);
1734 pSelect->UpdateSelectableRouteSegments(m_pRoutePoint);
1737 wxArrayPtrVoid* pEditRouteArray =
1740 if (pEditRouteArray) {
1741 for (
unsigned int ir = 0; ir < pEditRouteArray->GetCount(); ir++) {
1742 Route* pr = (
Route*)pEditRouteArray->Item(ir);
1743 pr->FinalizeForRendering();
1744 pr->UpdateSegmentDistances();
1747 NavObj_dB::GetInstance().UpdateRoute(pr);
1749 delete pEditRouteArray;
1753 NavObj_dB::GetInstance().UpdateRoutePoint(m_pRoutePoint);
1759SaveDefaultsDialog::SaveDefaultsDialog(
MarkInfoDlg* parent)
1760 : wxDialog(parent, wxID_ANY, _(
"Save some defaults")) {
1762 this->SetSizeHints(wxDefaultSize, wxDefaultSize);
1764 wxBoxSizer* bSizer1 =
new wxBoxSizer(wxVERTICAL);
1765 wxStdDialogButtonSizer* StdDialogButtonSizer1;
1768 new wxStaticText(
this, wxID_ANY,
1769 _(
"Check which properties of current waypoint\n should "
1770 "be set as default for NEW waypoints."));
1771 bSizer1->Add(StaticText1, 0, wxALL | wxALIGN_CENTER_HORIZONTAL, 5);
1773 wxFlexGridSizer* fgSizer1 =
new wxFlexGridSizer(2);
1779 new wxCheckBox(
this, wxID_ANY, _(
"Show Waypoint Name"), wxDefaultPosition,
1780 wxDefaultSize, 0, wxDefaultValidator);
1781 fgSizer1->Add(NameCB, 0, wxALL, 5);
1782 stName =
new wxStaticText(
this, wxID_ANY,
"[" + s +
"]", wxDefaultPosition,
1785 fgSizer1->Add(stName, 0, wxALL | wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL, 5);
1788 IconCB =
new wxCheckBox(
this, wxID_ANY, _(
"Icon"));
1789 fgSizer1->Add(IconCB, 0, wxALL, 5);
1790 stIcon =
new wxStaticText(
this, wxID_ANY,
"[" + s +
"]", wxDefaultPosition,
1793 fgSizer1->Add(stIcon, 0, wxALL | wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL, 5);
1802 RangRingsCB =
new wxCheckBox(
this, wxID_ANY, _(
"Range rings"));
1803 fgSizer1->Add(RangRingsCB, 0, wxALL, 5);
1804 stRR =
new wxStaticText(
this, wxID_ANY,
"[" + s +
"]", wxDefaultPosition,
1807 fgSizer1->Add(stRR, 0, wxALL | wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL, 5);
1810 ArrivalRCB =
new wxCheckBox(
this, wxID_ANY, _(
"Arrival radius"));
1811 fgSizer1->Add(ArrivalRCB, 0, wxALL, 5);
1812 stArrivalR =
new wxStaticText(
1814 wxString::Format(
"[%s %s]", s.c_str(), getUsrDistanceUnit().c_str()),
1815 wxDefaultPosition, wxDefaultSize, 0);
1816 stArrivalR->Wrap(-1);
1817 fgSizer1->Add(stArrivalR, 0, wxALL | wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL,
1821 ? _(
"Show only if") +
" < " +
1823 : _(
"Show always"));
1824 ScaleCB =
new wxCheckBox(
this, wxID_ANY, _(
"Show only at scale"));
1825 fgSizer1->Add(ScaleCB, 0, wxALL, 5);
1826 stScale =
new wxStaticText(
this, wxID_ANY,
"[" + s +
"]", wxDefaultPosition,
1829 fgSizer1->Add(stScale, 0, wxALL | wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL, 5);
1831 bSizer1->Add(fgSizer1, 0, wxALL | wxEXPAND, 5);
1833 StdDialogButtonSizer1 =
new wxStdDialogButtonSizer();
1834 StdDialogButtonSizer1->AddButton(
new wxButton(
this, wxID_OK));
1835 StdDialogButtonSizer1->AddButton(
1836 new wxButton(
this, wxID_CANCEL, _(
"Cancel")));
1837 StdDialogButtonSizer1->Realize();
1838 bSizer1->Add(StdDialogButtonSizer1, 0, wxALL | wxEXPAND, 5);
1845 SetSize(parent->GetSize());
1851void MarkInfoDlg::ShowTidesBtnClicked(wxCommandEvent& event) {
1852 if (m_comboBoxTideStation->GetSelection() < 1) {
1856 ptcmgr->GetStationIDXbyName(m_comboBoxTideStation->GetStringSelection(),
1857 fromDMM(m_textLatitude->GetValue()),
1858 fromDMM(m_textLongitude->GetValue())));
1860 TCWin* pCwin =
new TCWin(gFrame->GetPrimaryCanvas(), 0, 0, pIDX);
1863 wxString msg(_(
"Tide Station not found"));
1865 msg += m_comboBoxTideStation->GetStringSelection();
1866 OCPNMessageBox(NULL, msg, _(
"OpenCPN Info"), wxOK | wxCENTER, 10);
Generic Chart canvas base.
Represents an index entry for tidal and current data.
Dialog for displaying and editing waypoint properties.
wxDatePickerCtrl * m_EtdDatePickerCtrl
Date picker control for setting the Estimated Time of Departure (ETD).
wxStaticText * m_staticTextEtd
Label for the Estimated Time of Departure field.
wxCheckBox * m_cbEtdPresent
Checkbox control that enables/disables manual ETD setting for a waypoint.
wxTextCtrl * m_textCtrlPlSpeed
Text control for waypoint planned speed.
wxTimePickerCtrl * m_EtdTimePickerCtrl
Time picker control for setting the Estimated Time of Departure (ETD).
Custom combobox for selecting waypoint icons.
Represents a waypoint or mark within the navigation system.
HyperlinkList * m_HyperlinkList
List of hyperlinks associated with this waypoint.
wxColour m_wxcWaypointRangeRingsColour
Color for the range rings display.
wxString m_MarkDescription
Description text for the waypoint.
bool m_bRPIsBeingEdited
Flag indicating if this waypoint is currently being edited.
wxString m_GUID
Globally Unique Identifier for the waypoint.
wxDateTime GetManualETD()
Retrieves the manually set Estimated Time of Departure for this waypoint, in UTC.
bool m_bIsInRoute
Flag indicating if this waypoint is part of a route.
bool m_bShowName
Flag indicating if the waypoint name should be shown.
double GetPlannedSpeed()
Return the planned speed associated with this waypoint.
bool m_bIsVisible
Flag indicating if the waypoint should be drawn on the chart.
bool m_bIsInLayer
Flag indicating if the waypoint belongs to a layer.
wxString m_TideStation
Associated tide station identifier.
void SetETD(const wxDateTime &etd)
Sets the Estimated Time of Departure for this waypoint, in UTC.
Represents a navigational route in the navigation system.
wxArrayPtrVoid * GetRouteArrayContaining(RoutePoint *pWP)
Find all routes that contain the given waypoint.
Dialog for saving default waypoint properties.
Text field with validator and error handler.
void OnTextChanged(wxCommandEvent &event)
Text changed event handler.
Global variables stored in configuration file.
wxFont * GetOCPNScaledFont(wxString item, int default_size)
Retrieves a font from FontMgr, optionally scaled for physical readability.
wxFont GetOCPNGUIScaledFont(wxString item)
Retrieves a font optimized for touch and high-resolution interfaces.
General purpose GUI support.
MarkInfoDlg * g_pMarkInfoDialog
global instance
const wxEventType EVT_LLCHANGE
Waypoint properties maintenance dialog.
const wxEventType EVT_LLCHANGE
wxString getUsrDateTimeFormat()
Return the date/time format to use when formatting date/time strings.
MySQL based storage for routes, tracks, etc.
double fromUsrDistance(double usr_distance, int unit, int default_val)
Convert distance from user units to nautical miles.
double toUsrDistance(double nm_distance, int unit)
Convert a distance from nautical miles (NMi) to user display units.
Navigation Utility Functions without GUI dependencies.
Position, course, speed, etc.
PlugInManager and helper classes – Mostly gui parts (dialogs) and plugin API stuff.
String positions parsing.
wxColour g_colourWaypointRangeRingsColour
Global instance.
RoutePropDlgImpl * pRoutePropDialog
Global instance.
Routeman * g_pRouteMan
Global instance.
Select * pSelect
Global instance.
Selected route, segment, waypoint, etc.
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...
Tide and currents window.
TCMgr * ptcmgr
Global instance.
Tide and Current Manager @TODO Add original author copyright.
GUI library utils and events.