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);
479 gbSizerInnerExtProperties->Add(0, 0, 1, wxEXPAND, 0);
480 m_staticTextScaMax =
new wxStaticText(sbSizerExtProperties->GetStaticBox(),
481 wxID_ANY, _(
"Show at scale < 1 :"));
482 gbSizerInnerExtProperties->Add(m_staticTextScaMax, 0, wxALIGN_CENTRE_VERTICAL,
484 m_textScaMax =
new wxTextCtrl(sbSizerExtProperties->GetStaticBox(), wxID_ANY);
485 gbSizerInnerExtProperties->Add(m_textScaMax, 0, wxALL | wxEXPAND, 5);
487 m_checkBoxShowNameExt =
488 new wxCheckBox(sbSizerExtProperties->GetStaticBox(), wxID_ANY,
"");
489 m_checkBoxShowNameExt->Bind(wxEVT_CHECKBOX,
490 &MarkInfoDlg::OnShowWaypointNameSelectExt,
this);
491 gbSizerInnerExtProperties->Add(m_checkBoxShowNameExt);
492 m_staticTextShowNameExt =
new wxStaticText(
493 sbSizerExtProperties->GetStaticBox(), wxID_ANY, _(
"Show waypoint name"));
495 gbSizerInnerExtProperties->Add(m_staticTextShowNameExt);
496 gbSizerInnerExtProperties->Add(0, 0, 1, wxEXPAND, 0);
498 sbRangeRingsExtProperties =
new wxStaticBoxSizer(
499 wxVERTICAL, sbSizerExtProperties->GetStaticBox(), _(
"Range rings"));
500 wxFlexGridSizer* gbRRExtProperties =
new wxFlexGridSizer(4, 0, 0);
501 gbRRExtProperties->AddGrowableCol(0);
502 gbRRExtProperties->AddGrowableCol(1);
503 gbRRExtProperties->AddGrowableCol(3);
504 m_staticTextRR1 =
new wxStaticText(sbSizerExtProperties->GetStaticBox(),
505 wxID_ANY, _(
"Number"));
506 gbRRExtProperties->Add(m_staticTextRR1, 0, wxLEFT, 5);
507 m_staticTextRR2 =
new wxStaticText(sbSizerExtProperties->GetStaticBox(),
508 wxID_ANY, _(
"Distance"));
509 gbRRExtProperties->Add(m_staticTextRR2, 0, wxLEFT, 5);
510 gbRRExtProperties->Add(0, 0, 1, wxEXPAND, 5);
511 m_staticTextRR4 =
new wxStaticText(sbSizerExtProperties->GetStaticBox(),
512 wxID_ANY, _(
"Color"));
513 gbRRExtProperties->Add(m_staticTextRR4, 0, wxLEFT, 5);
515 wxString rrAlt[] = {_(
"None"),
"1",
"2",
"3",
"4",
"5",
516 "6",
"7",
"8",
"9",
"10"};
517 m_ChoiceWaypointRangeRingsNumber =
518 new wxChoice(sbSizerExtProperties->GetStaticBox(), ID_WPT_RANGERINGS_NO,
519 wxDefaultPosition, wxDefaultSize, 11, rrAlt);
521 gbRRExtProperties->Add(m_ChoiceWaypointRangeRingsNumber, 0, wxALL | wxEXPAND,
523 m_textWaypointRangeRingsStep =
524 new wxTextCtrl(sbSizerExtProperties->GetStaticBox(), wxID_ANY, _(
"0.05"),
525 wxDefaultPosition, wxDefaultSize, 0);
526 gbRRExtProperties->Add(m_textWaypointRangeRingsStep, 0, wxALL | wxEXPAND, 5);
528 wxString pDistUnitsStrings[] = {_(
"NMi"), _(
"km")};
530 new wxChoice(sbSizerExtProperties->GetStaticBox(), wxID_ANY,
531 wxDefaultPosition, wxDefaultSize, 2, pDistUnitsStrings);
532 gbRRExtProperties->Add(m_RangeRingUnits, 0, wxALIGN_CENTRE_VERTICAL, 0);
534 m_PickColor =
new wxColourPickerCtrl(sbSizerExtProperties->GetStaticBox(),
535 wxID_ANY, wxColour(0, 0, 0),
536 wxDefaultPosition, wxDefaultSize, 0);
537 gbRRExtProperties->Add(m_PickColor, 0, wxALL | wxEXPAND, 5);
538 sbRangeRingsExtProperties->Add(
539 gbRRExtProperties, 1,
540 wxLEFT | wxTOP | wxEXPAND | wxALIGN_LEFT | wxALIGN_TOP, 5);
542 sbSizerExtProperties->GetStaticBox()->Layout();
544 wxFlexGridSizer* gbSizerInnerExtProperties2 =
new wxFlexGridSizer(2, 0, 0);
545 gbSizerInnerExtProperties2->AddGrowableCol(1);
548 new wxStaticText(sbSizerExtProperties->GetStaticBox(), wxID_ANY,
549 _(
"GUID"), wxDefaultPosition, wxDefaultSize, 0);
550 gbSizerInnerExtProperties2->Add(m_staticTextGuid, 0, wxALIGN_CENTRE_VERTICAL,
553 new wxTextCtrl(sbSizerExtProperties->GetStaticBox(), wxID_ANY,
"",
554 wxDefaultPosition, wxDefaultSize, wxTE_READONLY);
555 m_textCtrlGuid->SetEditable(
false);
556 gbSizerInnerExtProperties2->Add(m_textCtrlGuid, 0, wxALL | wxEXPAND, 5);
558 wxFlexGridSizer* gbSizerInnerExtProperties1 =
new wxFlexGridSizer(3, 0, 0);
559 gbSizerInnerExtProperties1->AddGrowableCol(1);
561 m_staticTextTideStation =
562 new wxStaticText(sbSizerExtProperties->GetStaticBox(), wxID_ANY,
563 _(
"Tide Station"), wxDefaultPosition, wxDefaultSize, 0);
564 gbSizerInnerExtProperties1->Add(m_staticTextTideStation, 0,
565 wxALIGN_CENTRE_VERTICAL, 5);
568 m_choiceTideChoices.Add(
" ");
569 m_comboBoxTideStation =
570 new wxChoice(sbSizerExtProperties->GetStaticBox(), wxID_ANY,
571 wxDefaultPosition, wxDefaultSize, m_choiceTideChoices);
573 gbSizerInnerExtProperties1->Add(
574 m_comboBoxTideStation, 0, wxALL | wxEXPAND | wxALIGN_CENTRE_VERTICAL, 5);
577 m_comboBoxTideStation =
578 new wxComboBox(sbSizerExtProperties->GetStaticBox(), wxID_ANY,
"",
579 wxDefaultPosition, wxDefaultSize, 0, NULL, wxCB_READONLY);
580 gbSizerInnerExtProperties1->Add(
581 m_comboBoxTideStation, 0, wxALL | wxEXPAND | wxALIGN_CENTRE_VERTICAL, 5);
583 m_comboBoxTideStation->SetToolTip(
584 _(
"Associate this waypoint with a tide station to quickly access tide "
585 "predictions. Select from nearby stations or leave empty for no "
588 m_buttonShowTides =
new wxBitmapButton(
589 sbSizerExtProperties->GetStaticBox(), ID_BTN_SHOW_TIDES, m_bmTide,
590 wxDefaultPosition, m_bmTide.GetSize(), 0);
591 gbSizerInnerExtProperties1->Add(m_buttonShowTides, 0,
592 wxALL | wxALIGN_CENTRE_VERTICAL, 5);
594 m_staticTextArrivalRadius =
new wxStaticText(
595 sbSizerExtProperties->GetStaticBox(), wxID_ANY, _(
"Arrival Radius"));
596 gbSizerInnerExtProperties1->Add(m_staticTextArrivalRadius, 0,
597 wxALIGN_CENTRE_VERTICAL, 0);
598 m_textArrivalRadius =
599 new wxTextCtrl(sbSizerExtProperties->GetStaticBox(), wxID_ANY,
"",
600 wxDefaultPosition, wxDefaultSize, 0);
601 m_textArrivalRadius->SetToolTip(
602 _(
"Distance from the waypoint at which OpenCPN will consider the "
603 "waypoint reached. Used for automatic waypoint advancement during "
604 "active navigation."));
605 gbSizerInnerExtProperties1->Add(m_textArrivalRadius, 0, wxALL | wxEXPAND, 5);
606 m_staticTextArrivalUnits =
607 new wxStaticText(sbSizerExtProperties->GetStaticBox(), wxID_ANY,
"",
608 wxDefaultPosition, wxDefaultSize, 0);
609 gbSizerInnerExtProperties1->Add(m_staticTextArrivalUnits, 0,
610 wxALIGN_CENTRE_VERTICAL, 0);
612 m_staticTextPlSpeed =
613 new wxStaticText(sbSizerExtProperties->GetStaticBox(), wxID_ANY,
614 _(
"Planned Speed"), wxDefaultPosition, wxDefaultSize, 0);
615 gbSizerInnerExtProperties1->Add(m_staticTextPlSpeed, 0,
616 wxALIGN_CENTRE_VERTICAL, 0);
618 new wxTextCtrl(sbSizerExtProperties->GetStaticBox(), wxID_ANY,
"",
619 wxDefaultPosition, wxDefaultSize, 0);
621 "Enter the planned vessel speed for the leg FOLLOWING this waypoint. "
622 "This speed is used when traveling FROM this waypoint TO the next "
623 "waypoint in the route. The value is used to calculate estimated time "
624 "of arrival at the next waypoint based on the ETD from this waypoint.\n\n"
625 "If left blank, the route's default speed will be used for this leg. "
626 "Individual waypoint speeds override the route-level speed setting."));
628 m_staticTextPlSpeedUnits =
629 new wxStaticText(sbSizerExtProperties->GetStaticBox(), wxID_ANY,
630 getUsrSpeedUnit(), wxDefaultPosition, wxDefaultSize, 0);
631 gbSizerInnerExtProperties1->Add(m_staticTextPlSpeedUnits, 0,
632 wxALIGN_CENTRE_VERTICAL, 0);
636 m_staticTextEtd =
new wxStaticText(sbSizerExtProperties->GetStaticBox(),
638 gbSizerInnerExtProperties1->Add(
m_staticTextEtd, 0, wxALIGN_CENTRE_VERTICAL,
640 wxBoxSizer* bsTimestamp =
new wxBoxSizer(wxHORIZONTAL);
642 new wxCheckBox(sbSizerExtProperties->GetStaticBox(), wxID_ANY,
"");
644 _(
"Enable to manually set a planned departure time (ETD) for this "
646 "When checked, the specified date and time will be used instead of the "
647 "automatically calculated ETD. This affects ETA calculations for "
648 "subsequent waypoints in the route."));
651 sbSizerExtProperties->GetStaticBox(), ID_ETA_DATEPICKERCTRL,
652 wxDefaultDateTime, wxDefaultPosition, wxDefaultSize, wxDP_DEFAULT,
655 "Select the planned departure date (ETD) for this waypoint.\nUsed "
656 "together with the time control to calculate arrival times at subsequent "
657 "waypoints.\nETD information is only used for route planning "
658 "and does not affect navigation."));
663 new TimeCtrl(sbSizerExtProperties->GetStaticBox(), ID_ETA_TIMEPICKERCTRL,
664 wxDefaultDateTime, wxDefaultPosition, wxDefaultSize);
667 sbSizerExtProperties->GetStaticBox(), ID_ETA_TIMEPICKERCTRL,
668 wxDefaultDateTime, wxDefaultPosition, wxDefaultSize, wxDP_DEFAULT,
673 gbSizerInnerExtProperties1->Add(bsTimestamp, 0, wxEXPAND, 0);
674 sbSizerExtProperties->Add(gbSizerInnerExtProperties, 0, wxALL | wxEXPAND, 5);
675 sbSizerExtProperties->Add(sbRangeRingsExtProperties, 0, wxALL | wxEXPAND, 5);
676 sbSizerExtProperties->Add(gbSizerInnerExtProperties2, 0, wxALL | wxEXPAND, 5);
677 sbSizerExtProperties->Add(gbSizerInnerExtProperties1, 0, wxALL | wxEXPAND, 5);
679 fSizerExtProperties->Add(sbSizerExtProperties, 1, wxALL | wxEXPAND);
682 bSizer1->Add(m_notebookProperties, 1, wxEXPAND);
684 wxBoxSizer* btnSizer =
new wxBoxSizer(wxHORIZONTAL);
685 bSizer1->Add(btnSizer, 0, wxEXPAND, 0);
688 new wxBitmapButton(
this, ID_DEFAULT, _img_MUI_settings_svg,
689 wxDefaultPosition, _img_MUI_settings_svg.GetSize(), 0);
690 btnSizer->Add(DefaultsBtn, 0, wxALL | wxALIGN_LEFT | wxALIGN_BOTTOM, 5);
691 btnSizer->Add(0, 0, 1, wxEXPAND);
693 m_sdbSizerButtons =
new wxStdDialogButtonSizer();
694 m_buttonOkay =
new wxButton(
this, wxID_OK);
695 m_sdbSizerButtons->AddButton(m_buttonOkay);
696 m_sdbSizerButtons->AddButton(
new wxButton(
this, wxID_CANCEL, _(
"Cancel")));
697 m_sdbSizerButtons->Realize();
698 btnSizer->Add(m_sdbSizerButtons, 0, wxALL, 5);
703 m_textLatitude->Connect(
705 wxCommandEventHandler(MarkInfoDlg::OnRightClickLatLon), NULL,
this);
706 m_textLongitude->Connect(
708 wxCommandEventHandler(MarkInfoDlg::OnRightClickLatLon), NULL,
this);
710 m_htmlList->Connect(wxEVT_RIGHT_DOWN,
711 wxMouseEventHandler(MarkInfoDlg::m_htmlListContextMenu),
715 m_notebookProperties->Connect(
716 wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED,
717 wxNotebookEventHandler(MarkInfoDlg::OnNotebookPageChanged), NULL,
this);
722 m_comboBoxTideStation->Connect(
723 wxEVT_COMMAND_COMBOBOX_SELECTED,
724 wxCommandEventHandler(MarkInfoDlg::OnTideStationCombobox), NULL,
this);
727void MarkInfoDlg::OnClose(wxCloseEvent& event) {
733#define TIDESTATION_BATCH_SIZE 10
735void MarkInfoDlg::OnTideStationCombobox(wxCommandEvent& event) {
736 int count = m_comboBoxTideStation->GetCount();
737 int sel = m_comboBoxTideStation->GetSelection();
738 if (sel == count - 1) {
741 for (
auto ts : m_tss) {
742 if (i == count + TIDESTATION_BATCH_SIZE) {
746 n = wxString::FromUTF8(ts.second->IDX_station_name);
747 m_comboBoxTideStation->Append(n);
754void MarkInfoDlg::OnNotebookPageChanged(wxNotebookEvent& event) {
755 if (event.GetSelection() == EXTENDED_PROP_PAGE) {
756 if (m_lasttspos.IsSameAs(m_textLatitude->GetValue() +
757 m_textLongitude->GetValue())) {
760 m_lasttspos = m_textLatitude->GetValue() + m_textLongitude->GetValue();
761 double lat = fromDMM(m_textLatitude->GetValue());
762 double lon = fromDMM(m_textLongitude->GetValue());
763 m_tss =
ptcmgr->GetStationsForLL(lat, lon);
764 wxString s = m_comboBoxTideStation->GetStringSelection();
767 m_comboBoxTideStation->Clear();
768 m_comboBoxTideStation->Append(
"");
769 for (
auto ts : m_tss) {
770 if (i == TIDESTATION_BATCH_SIZE) {
774 n = wxString::FromUTF8(ts.second->IDX_station_name);
775 m_comboBoxTideStation->Append(n);
777 m_comboBoxTideStation->SetSelection(i);
780 if (m_comboBoxTideStation->GetStringSelection() != s) {
781 m_comboBoxTideStation->Insert(s, 1);
782 m_comboBoxTideStation->SetSelection(1);
787void MarkInfoDlg::RecalculateSize() {
792 wxSize dsize = GetParent()->GetClientSize();
796 esize.x = GetCharHeight() * 20;
797 esize.y = GetCharHeight() * 40;
800 esize.y = wxMin(esize.y, dsize.y - (2 * GetCharHeight()));
801 esize.x = wxMin(esize.x, dsize.x - (1 * GetCharHeight()));
802 SetSize(wxSize(esize.x, esize.y));
805 wxSize fsize = GetSize();
806 fsize.y = wxMin(fsize.y, dsize.y - (2 * GetCharHeight()));
807 fsize.x = wxMin(fsize.x, dsize.x - (1 * GetCharHeight()));
811 fsize.y = wxMin(fsize.y, (25 * GetCharHeight()));
813 SetSize(wxSize(-1, fsize.y));
815 m_defaultClientSize = GetClientSize();
818 wxSize dsize = GetParent()->GetClientSize();
819 SetSize(-1, wxMax(GetSize().y, dsize.y / 1.5));
823MarkInfoDlg::~MarkInfoDlg() {
825 m_textLatitude->Disconnect(
827 wxCommandEventHandler(MarkInfoDlg::OnRightClickLatLon), NULL,
this);
828 m_textLongitude->Disconnect(
830 wxCommandEventHandler(MarkInfoDlg::OnRightClickLatLon), NULL,
this);
832 m_htmlList->Disconnect(
833 wxEVT_RIGHT_DOWN, wxMouseEventHandler(MarkInfoDlg::m_htmlListContextMenu),
838 m_notebookProperties->Disconnect(
839 wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED,
840 wxNotebookEventHandler(MarkInfoDlg::OnNotebookPageChanged), NULL,
this);
842 wxEVT_TIME_CHANGED, wxDateEventHandler(MarkInfoDlg::OnTimeChanged), NULL,
845 wxEVT_DATE_CHANGED, wxDateEventHandler(MarkInfoDlg::OnTimeChanged), NULL,
849 androidEnableBackButton(
true);
853void MarkInfoDlg::InitialFocus() {
854 m_textName->SetFocus();
855 m_textName->SetInsertionPointEnd();
858void MarkInfoDlg::SetColorScheme(ColorScheme cs) { DimeControl(
this); }
860void MarkInfoDlg::ClearData() {
861 m_pRoutePoint = NULL;
865void MarkInfoDlg::SetRoutePoint(
RoutePoint* pRP) {
868 m_lat_save = m_pRoutePoint->m_lat;
869 m_lon_save = m_pRoutePoint->m_lon;
870 m_IconName_save = m_pRoutePoint->GetIconName();
873 m_Name_save = m_pRoutePoint->GetName();
875 m_bUseScaMin_save = m_pRoutePoint->GetUseSca();
876 m_iScaminVal_save = m_pRoutePoint->GetScaMin();
877 m_iScamaxVal_save = m_pRoutePoint->GetScaMax();
879 if (m_pMyLinkList)
delete m_pMyLinkList;
880 m_pMyLinkList =
new HyperlinkList();
881 for (
Hyperlink* link : *m_pRoutePoint->m_HyperlinkList) {
883 h->DescrText = link->DescrText;
884 h->Link = link->Link;
885 h->LType = link->LType;
887 m_pMyLinkList->push_back(h);
892void MarkInfoDlg::UpdateHtmlList() {
894 GetSimpleBox()->Clear();
897 if (NbrOfLinks > 0) {
899 for (
auto it = list->begin(); it != list->end(); ++it) {
902 wxString::Format(
"<a href='%s'>%s</a>", link->Link, link->DescrText);
903 GetSimpleBox()->AppendString(s);
908 wxWindowList kids = m_scrolledWindowLinks->GetChildren();
909 for (
unsigned int i = 0; i < kids.GetCount(); i++) {
910 wxWindowListNode* node = kids.Item(i);
911 wxWindow* win = node->GetData();
913 auto link_win =
dynamic_cast<wxHyperlinkCtrl*
>(win);
915 link_win->Disconnect(
916 wxEVT_COMMAND_HYPERLINK,
917 wxHyperlinkEventHandler(MarkInfoDlg::OnHyperLinkClick));
918 link_win->Disconnect(
920 wxMouseEventHandler(MarkInfoDlg::m_htmlListContextMenu));
925 for (
Hyperlink* link : *m_pRoutePoint->m_HyperlinkList) {
926 wxString Link = link->Link;
927 wxString Descr = link->DescrText;
929 wxHyperlinkCtrl* ctrl =
new wxHyperlinkCtrl(
930 m_scrolledWindowLinks, wxID_ANY, Descr, Link, wxDefaultPosition,
931 wxDefaultSize, wxNO_BORDER | wxHL_CONTEXTMENU | wxHL_ALIGN_LEFT);
932 ctrl->Connect(wxEVT_COMMAND_HYPERLINK,
933 wxHyperlinkEventHandler(MarkInfoDlg::OnHyperLinkClick), NULL,
936 ctrl->Connect(wxEVT_RIGHT_DOWN,
937 wxMouseEventHandler(MarkInfoDlg::m_htmlListContextMenu),
940 bSizerLinks->Add(ctrl, 1, wxALL | wxEXPAND, 5);
944 m_scrolledWindowLinks->Layout();
948void MarkInfoDlg::OnHyperLinkClick(wxHyperlinkEvent& event) {
949 wxString url =
event.GetURL();
950 url.Replace(
" ",
"%20");
951 if (g_Platform) g_Platform->platformLaunchDefaultBrowser(url);
954void MarkInfoDlg::OnHtmlLinkClicked(wxHtmlLinkEvent& event) {
964 wxString cc =
event.GetLinkInfo().GetHref().c_str();
965 if (cc.Find(
"#") != wxNOT_FOUND) {
966 wxRegKey RegKey(wxString(
"HKEY_CLASSES_ROOT\\HTTP\\shell\\open\\command"));
967 if (RegKey.Exists()) {
968 wxString command_line;
969 RegKey.QueryValue(wxString(
""), command_line);
972 command_line.Replace(wxString(
"\""), wxString(
""));
975 int l = command_line.Find(
".exe");
976 if (wxNOT_FOUND == l) l = command_line.Find(
".EXE");
978 if (wxNOT_FOUND != l) {
979 wxString cl = command_line.Mid(0, l + 4);
988 wxString url =
event.GetLinkInfo().GetHref().c_str();
989 url.Replace(
" ",
"%20");
990 ::wxLaunchDefaultBrowser(url);
994 wxString url =
event.GetLinkInfo().GetHref().c_str();
995 url.Replace(
" ",
"%20");
996 if (g_Platform) g_Platform->platformLaunchDefaultBrowser(url);
1002void MarkInfoDlg::OnLayoutResize(wxCommandEvent& event) {
1003 m_panelBasicProperties->Layout();
1007void MarkInfoDlg::OnDescChangedExt(wxCommandEvent& event) {
1008 if (m_panelDescription->IsShownOnScreen()) {
1009 m_textDescription->ChangeValue(m_textCtrlExtDescription->GetValue());
1013void MarkInfoDlg::OnDescChangedBasic(wxCommandEvent& event) {
1014 if (m_panelBasicProperties->IsShownOnScreen()) {
1015 m_textCtrlExtDescription->ChangeValue(m_textDescription->GetValue());
1020void MarkInfoDlg::OnExtDescriptionClick(wxCommandEvent& event) {
1021 long pos = m_textDescription->GetInsertionPoint();
1022 m_notebookProperties->SetSelection(1);
1023 m_textCtrlExtDescription->SetInsertionPoint(pos);
1027void MarkInfoDlg::OnShowWaypointNameSelectBasic(wxCommandEvent& event) {
1028 m_checkBoxShowNameExt->SetValue(m_checkBoxShowName->GetValue());
1031void MarkInfoDlg::OnShowWaypointNameSelectExt(wxCommandEvent& event) {
1032 m_checkBoxShowName->SetValue(m_checkBoxShowNameExt->GetValue());
1036void MarkInfoDlg::OnWptRangeRingsNoChange(wxCommandEvent& event) {
1038 m_textWaypointRangeRingsStep->Enable(
1039 (
bool)(m_ChoiceWaypointRangeRingsNumber->GetSelection() != 0));
1040 m_PickColor->Enable(
1041 (
bool)(m_ChoiceWaypointRangeRingsNumber->GetSelection() != 0));
1045void MarkInfoDlg::OnSelectScaMinExt(wxCommandEvent& event) {
1047 m_textScaMin->Enable(m_checkBoxScaMin->GetValue());
1048 m_textScaMax->Enable(m_checkBoxScaMin->GetValue());
1052void MarkInfoDlg::OnPositionCtlUpdated(wxCommandEvent& event) {
1054 double lat = fromDMM(m_textLatitude->GetValue());
1055 double lon = fromDMM(m_textLongitude->GetValue());
1057 m_pRoutePoint->SetPosition(lat, lon);
1058 pSelect->ModifySelectablePoint(lat, lon, (
void*)m_pRoutePoint,
1059 SELTYPE_ROUTEPOINT);
1062 gFrame->RefreshAllCanvas();
1065void MarkInfoDlg::m_htmlListContextMenu(wxMouseEvent& event) {
1069 wxPoint pos =
event.GetPosition();
1070 i_htmlList_item = -1;
1071 for (
int i = 0; i < (int)GetSimpleBox()->GetCount(); i++) {
1072 wxRect rect = GetSimpleBox()->GetItemRect(i);
1073 if (rect.Contains(pos)) {
1074 i_htmlList_item = i;
1079 wxMenu* popup =
new wxMenu();
1080 if ((GetSimpleBox()->GetCount()) > 0 && (i_htmlList_item > -1) &&
1081 (i_htmlList_item < (
int)GetSimpleBox()->GetCount())) {
1082 popup->Append(ID_RCLK_MENU_DELETE_LINK, _(
"Delete"));
1083 popup->Append(ID_RCLK_MENU_EDIT_LINK, _(
"Edit"));
1085 popup->Append(ID_RCLK_MENU_ADD_LINK, _(
"Add New"));
1087 m_contextObject =
event.GetEventObject();
1089 wxEVT_COMMAND_MENU_SELECTED,
1090 wxCommandEventHandler(MarkInfoDlg::On_html_link_popupmenu_Click), NULL,
1096 m_pEditedLink =
dynamic_cast<wxHyperlinkCtrl*
>(
event.GetEventObject());
1098 if (m_pEditedLink) {
1099 wxString url = m_pEditedLink->GetURL();
1100 wxString label = m_pEditedLink->GetLabel();
1101 i_htmlList_item = -1;
1104 for (
Hyperlink* link : *hyperlinklist) {
1105 if (link->DescrText == label) {
1106 i_htmlList_item = i;
1114 wxMenu* popup =
new wxMenu();
1116 wxMenuItem* menuItemDelete =
1117 new wxMenuItem(popup, ID_RCLK_MENU_DELETE_LINK, wxString(_(
"Delete")),
1120 menuItemDelete->SetFont(sFont);
1122 popup->Append(menuItemDelete);
1124 wxMenuItem* menuItemEdit =
1125 new wxMenuItem(popup, ID_RCLK_MENU_EDIT_LINK, wxString(_(
"Edit")),
"",
1128 menuItemEdit->SetFont(sFont);
1130 popup->Append(menuItemEdit);
1133 wxMenuItem* menuItemAdd =
1134 new wxMenuItem(popup, ID_RCLK_MENU_ADD_LINK, wxString(_(
"Add New")),
"",
1137 menuItemAdd->SetFont(sFont);
1139 popup->Append(menuItemAdd);
1141 m_contextObject =
event.GetEventObject();
1143 wxEVT_COMMAND_MENU_SELECTED,
1144 wxCommandEventHandler(MarkInfoDlg::On_html_link_popupmenu_Click), NULL,
1146 wxPoint p = m_scrolledWindowLinks->GetPosition();
1147 p.x += m_scrolledWindowLinks->GetSize().x / 2;
1148 PopupMenu(popup, p);
1171void MarkInfoDlg::OnAddLink(wxCommandEvent& event) {
1172 wxCommandEvent evt(wxEVT_COMMAND_MENU_SELECTED);
1173 evt.SetId(ID_RCLK_MENU_ADD_LINK);
1175 On_html_link_popupmenu_Click(evt);
1178void MarkInfoDlg::On_html_link_popupmenu_Click(wxCommandEvent& event) {
1179 switch (event.GetId()) {
1180 case ID_RCLK_MENU_DELETE_LINK: {
1186 case ID_RCLK_MENU_EDIT_LINK: {
1190 LinkPropDlg->m_textCtrlLinkDescription->SetValue(link->DescrText);
1191 LinkPropDlg->m_textCtrlLinkUrl->SetValue(link->Link);
1192 DimeControl(LinkPropDlg);
1193 LinkPropDlg->ShowWindowModalThenDo([
this, LinkPropDlg,
1194 link](
int retcode) {
1195 if (retcode == wxID_OK) {
1196 link->DescrText = LinkPropDlg->m_textCtrlLinkDescription->GetValue();
1198 link->Link = LinkPropDlg->m_textCtrlLinkUrl->GetValue();
1205 case ID_RCLK_MENU_ADD_LINK: {
1207 LinkPropDlg->m_textCtrlLinkDescription->SetValue(
"");
1208 LinkPropDlg->m_textCtrlLinkUrl->SetValue(
"");
1209 DimeControl(LinkPropDlg);
1210 LinkPropDlg->ShowWindowModalThenDo([
this, LinkPropDlg](
int retcode) {
1211 if (retcode == wxID_OK) {
1213 link->DescrText = LinkPropDlg->m_textCtrlLinkDescription->GetValue();
1214 link->Link = LinkPropDlg->m_textCtrlLinkUrl->GetValue();
1216 if (link->DescrText ==
"") {
1217 link->DescrText = link->Link;
1219 if (link->Link ==
"") {
1222 m_pRoutePoint->m_HyperlinkList->push_back(link);
1233void MarkInfoDlg::OnRightClickLatLon(wxCommandEvent& event) {
1234 wxMenu* popup =
new wxMenu();
1235 popup->Append(ID_RCLK_MENU_COPY, _(
"Copy"));
1236 popup->Append(ID_RCLK_MENU_COPY_LL, _(
"Copy lat/long"));
1237 popup->Append(ID_RCLK_MENU_PASTE, _(
"Paste"));
1238 popup->Append(ID_RCLK_MENU_PASTE_LL, _(
"Paste lat/long"));
1239 m_contextObject =
event.GetEventObject();
1240 popup->Connect(wxEVT_COMMAND_MENU_SELECTED,
1241 wxCommandEventHandler(MarkInfoDlg::OnCopyPasteLatLon), NULL,
1248void MarkInfoDlg::OnCopyPasteLatLon(wxCommandEvent& event) {
1250 double lat = fromDMM(m_textLatitude->GetValue());
1251 double lon = fromDMM(m_textLongitude->GetValue());
1255 switch (event.GetId()) {
1256 case ID_RCLK_MENU_PASTE: {
1257 if (wxTheClipboard->Open()) {
1258 wxTextDataObject data;
1259 wxTheClipboard->GetData(data);
1260 result = data.GetText();
1261 ((wxTextCtrl*)m_contextObject)->SetValue(result);
1262 wxTheClipboard->Close();
1266 case ID_RCLK_MENU_PASTE_LL: {
1267 if (wxTheClipboard->Open()) {
1268 wxTextDataObject data;
1269 wxTheClipboard->GetData(data);
1270 result = data.GetText();
1274 if (pparse.IsOk()) {
1275 m_textLatitude->SetValue(pparse.GetLatitudeString());
1276 m_textLongitude->SetValue(pparse.GetLongitudeString());
1278 wxTheClipboard->Close();
1282 case ID_RCLK_MENU_COPY: {
1283 result = ((wxTextCtrl*)m_contextObject)->GetValue();
1286 case ID_RCLK_MENU_COPY_LL: {
1287 result << toSDMM(1, lat,
true) <<
'\t';
1288 result << toSDMM(2, lon,
true);
1293 if (wxTheClipboard->Open()) {
1294 wxTextDataObject* data =
new wxTextDataObject;
1295 data->SetText(result);
1296 wxTheClipboard->SetData(data);
1297 wxTheClipboard->Close();
1301void MarkInfoDlg::DefautlBtnClicked(wxCommandEvent& event) {
1303 m_SaveDefaultDlg->Center();
1304 DimeControl(m_SaveDefaultDlg);
1305 int retcode = m_SaveDefaultDlg->ShowModal();
1308 if (retcode == wxID_OK) {
1310 if (m_SaveDefaultDlg->IconCB->GetValue()) {
1312 *pWayPointMan->GetIconKey(m_bcomboBoxIcon->GetSelection());
1314 if (m_SaveDefaultDlg->RangRingsCB->GetValue()) {
1315 g_iWaypointRangeRingsNumber =
1316 m_ChoiceWaypointRangeRingsNumber->GetSelection();
1317 if (m_textWaypointRangeRingsStep->GetValue().ToDouble(&value))
1321 if (m_SaveDefaultDlg->ArrivalRCB->GetValue())
1322 if (m_textArrivalRadius->GetValue().ToDouble(&value))
1324 if (m_SaveDefaultDlg->ScaleCB->GetValue()) {
1325 g_iWpt_ScaMin = wxAtoi(m_textScaMin->GetValue());
1326 g_iWpt_ScaMax = wxAtoi(m_textScaMax->GetValue());
1327 g_bUseWptScaMin = m_checkBoxScaMin->GetValue();
1329 if (m_SaveDefaultDlg->NameCB->GetValue()) {
1330 g_bShowWptName = m_checkBoxShowName->GetValue();
1333 m_SaveDefaultDlg = NULL;
1337void MarkInfoDlg::OnMarkInfoCancelClick(wxCommandEvent& event) {
1338 if (m_pRoutePoint) {
1339 m_pRoutePoint->SetVisible(m_bIsVisible_save);
1340 m_pRoutePoint->SetNameShown(m_bShowName_save);
1341 m_pRoutePoint->SetPosition(m_lat_save, m_lon_save);
1342 m_pRoutePoint->SetIconName(m_IconName_save);
1343 m_pRoutePoint->ReLoadIcon();
1344 m_pRoutePoint->SetName(m_Name_save);
1346 m_pRoutePoint->SetUseSca(m_bUseScaMin_save);
1347 m_pRoutePoint->SetScaMin(m_iScaminVal_save);
1348 m_pRoutePoint->SetScaMax(m_iScamaxVal_save);
1352 int NbrOfLinks = m_pMyLinkList->size();
1353 if (NbrOfLinks > 0) {
1354 for (
Hyperlink* link : *m_pMyLinkList) {
1356 h->DescrText = link->DescrText;
1357 h->Link = link->Link;
1358 h->LType = link->LType;
1365 m_lasttspos.Clear();
1372 delete m_pMyLinkList;
1373 m_pMyLinkList = NULL;
1374 SetClientSize(m_defaultClientSize);
1377 androidEnableBackButton(
true);
1383void MarkInfoDlg::OnMarkInfoOKClick(wxCommandEvent& event) {
1384 if (m_pRoutePoint) {
1387 OnPositionCtlUpdated(event);
1397 if (pRouteManagerDialog && pRouteManagerDialog->IsShown())
1398 pRouteManagerDialog->UpdateWptListCtrl();
1403 SetClientSize(m_defaultClientSize);
1406 androidEnableBackButton(
true);
1412bool MarkInfoDlg::UpdateProperties(
bool positionOnly) {
1413 if (m_pRoutePoint) {
1414 m_textLatitude->SetValue(::toSDMM(1, m_pRoutePoint->m_lat));
1415 m_textLongitude->SetValue(::toSDMM(2, m_pRoutePoint->m_lon));
1416 m_lat_save = m_pRoutePoint->m_lat;
1417 m_lon_save = m_pRoutePoint->m_lon;
1418 m_textName->SetValue(m_pRoutePoint->GetName());
1421 m_checkBoxShowName->SetValue(m_pRoutePoint->
m_bShowName);
1422 m_checkBoxShowNameExt->SetValue(m_pRoutePoint->
m_bShowName);
1423 m_checkBoxVisible->SetValue(m_pRoutePoint->
m_bIsVisible);
1424 m_checkBoxScaMin->SetValue(m_pRoutePoint->GetUseSca());
1425 m_textScaMin->SetValue(
1426 wxString::Format(
"%i", (
int)m_pRoutePoint->GetScaMin()));
1427 m_textScaMax->SetValue(
1428 wxString::Format(
"%i", (
int)m_pRoutePoint->GetScaMax()));
1429 m_textCtrlGuid->SetValue(m_pRoutePoint->
m_GUID);
1430 m_ChoiceWaypointRangeRingsNumber->SetSelection(
1431 m_pRoutePoint->GetWaypointRangeRingsNumber());
1434 toUsrDistance(m_pRoutePoint->GetWaypointRangeRingsStep(), -1));
1435 m_textWaypointRangeRingsStep->SetValue(buf);
1436 m_staticTextArrivalUnits->SetLabel(getUsrDistanceUnit());
1438 toUsrDistance(m_pRoutePoint->GetWaypointArrivalRadius(), -1));
1439 m_textArrivalRadius->SetValue(buf);
1441 int nUnits = m_pRoutePoint->GetWaypointRangeRingsStepUnits();
1442 m_RangeRingUnits->SetSelection(nUnits);
1445 m_PickColor->SetColour(col);
1448 if (m_name_validator) m_name_validator.reset();
1450 std::make_unique<RoutePointNameValidator>(m_pRoutePoint);
1451 m_textName->SetValidator(*m_name_validator);
1453 m_textName->Bind(wxEVT_KILL_FOCUS, &MarkInfoDlg::OnFocusEvent,
this);
1455 m_textName->SetValidator();
1457 m_textName->Unbind(wxEVT_KILL_FOCUS, &MarkInfoDlg::OnFocusEvent,
this);
1460 if (m_comboBoxTideStation->GetStringSelection() !=
1462 m_comboBoxTideStation->Clear();
1463 m_comboBoxTideStation->Append(
"");
1465 m_comboBoxTideStation->Append(m_pRoutePoint->
m_TideStation);
1466 m_comboBoxTideStation->SetSelection(1);
1470 m_staticTextPlSpeedUnits->SetLabel(getUsrSpeedUnit());
1478 bool isLastWaypoint =
false;
1481 wxArrayPtrVoid* pRouteArray =
1484 isLastWaypoint =
true;
1486 for (
unsigned int i = 0; i < pRouteArray->GetCount(); i++) {
1488 if (route->GetLastPoint()->
m_GUID != m_pRoutePoint->
m_GUID) {
1489 isLastWaypoint =
false;
1498 if (isLastWaypoint) {
1503 if (etd.IsValid()) {
1506 if (dtFormat ==
"Local Time") {
1510 }
else if (dtFormat ==
"UTC") {
1517 "MarkInfoDlg::UpdateProperties. Unexpected date/time format: %s",
1519 etd = wxInvalidDateTime;
1530 m_staticTextPlSpeed->Show(m_pRoutePoint->
m_bIsInRoute);
1536 m_staticTextPlSpeedUnits->Show(m_pRoutePoint->
m_bIsInRoute);
1537 m_staticTextArrivalRadius->Show(m_pRoutePoint->
m_bIsInRoute);
1538 m_staticTextArrivalUnits->Show(m_pRoutePoint->
m_bIsInRoute);
1539 m_textArrivalRadius->Show(m_pRoutePoint->
m_bIsInRoute);
1541 if (positionOnly)
return true;
1545 m_staticTextLayer->Enable();
1546 m_staticTextLayer->Show(
true);
1547 m_textName->SetEditable(
false);
1548 m_textDescription->SetEditable(
false);
1549 m_textCtrlExtDescription->SetEditable(
false);
1550 m_textLatitude->SetEditable(
false);
1551 m_textLongitude->SetEditable(
false);
1552 m_bcomboBoxIcon->Enable(
false);
1553 m_checkBoxShowName->Enable(
false);
1554 m_checkBoxVisible->Enable(
false);
1555 m_textArrivalRadius->SetEditable(
false);
1556 m_checkBoxScaMin->Enable(
false);
1557 m_textScaMin->SetEditable(
false);
1558 m_textScaMax->SetEditable(
false);
1559 m_checkBoxShowNameExt->Enable(
false);
1560 m_ChoiceWaypointRangeRingsNumber->Enable(
false);
1561 m_textWaypointRangeRingsStep->SetEditable(
false);
1562 m_PickColor->Enable(
false);
1563 DefaultsBtn->Enable(
false);
1567 m_notebookProperties->SetSelection(0);
1568 m_comboBoxTideStation->Enable(
false);
1570 m_staticTextLayer->Enable(
false);
1571 m_staticTextLayer->Show(
false);
1572 m_textName->SetEditable(
true);
1573 m_textDescription->SetEditable(
true);
1574 m_textCtrlExtDescription->SetEditable(
true);
1575 m_textLatitude->SetEditable(
true);
1576 m_textLongitude->SetEditable(
true);
1577 m_bcomboBoxIcon->Enable(
true);
1578 m_checkBoxShowName->Enable(
true);
1579 m_checkBoxVisible->Enable(
true);
1580 m_textArrivalRadius->SetEditable(
true);
1581 m_checkBoxScaMin->Enable(
true);
1582 m_textScaMin->SetEditable(
true);
1583 m_textScaMax->SetEditable(
true);
1584 m_checkBoxShowNameExt->Enable(
true);
1585 m_ChoiceWaypointRangeRingsNumber->Enable(
true);
1586 m_textWaypointRangeRingsStep->SetEditable(
true);
1587 m_PickColor->Enable(
true);
1588 DefaultsBtn->Enable(
true);
1589 m_notebookProperties->SetSelection(0);
1590 m_comboBoxTideStation->Enable(
true);
1600 m_bcomboBoxIcon->Clear();
1602 bool fillCombo = m_bcomboBoxIcon->GetCount() == 0;
1605 for (
int i = 0; i < pWayPointMan->GetNumIcons(); i++) {
1606 wxString* ps = pWayPointMan->GetIconDescription(i);
1608 pWayPointMan->GetIconBitmapForList(i, 2 * GetCharHeight());
1610 m_bcomboBoxIcon->Append(*ps, bmp);
1614 int iconToSelect = -1;
1615 for (
int i = 0; i < pWayPointMan->GetNumIcons(); i++) {
1616 if (*pWayPointMan->GetIconKey(i) == m_pRoutePoint->GetIconName()) {
1618 m_bcomboBoxIcon->Select(iconToSelect);
1623 OnShowWaypointNameSelectBasic(ev);
1624 OnWptRangeRingsNoChange(ev);
1625 OnSelectScaMinExt(ev);
1630 androidEnableBackButton(
false);
1641void MarkInfoDlg::OnFocusEvent(wxFocusEvent& event) {
1642 bool is_valid = Validate();
1643 m_buttonOkay->Enable(is_valid);
1647void MarkInfoDlg::OnBitmapCombClick(wxCommandEvent& event) {
1648 wxString* icon_name =
1649 pWayPointMan->GetIconKey(m_bcomboBoxIcon->GetSelection());
1650 if (icon_name && icon_name->Length()) m_pRoutePoint->SetIconName(*icon_name);
1651 m_pRoutePoint->ReLoadIcon();
1656void MarkInfoDlg::ValidateMark() {
1659 bool b_found =
false;
1660 for (
RoutePoint* rp : *pWayPointMan->GetWaypointList()) {
1661 if (m_pRoutePoint == rp) {
1666 if (!b_found) m_pRoutePoint = NULL;
1669bool MarkInfoDlg::SaveChanges() {
1670 if (m_pRoutePoint) {
1672 if (!this->Validate())
return false;
1675 m_pRoutePoint->SetName(m_textName->GetValue());
1676 m_pRoutePoint->SetWaypointArrivalRadius(m_textArrivalRadius->GetValue());
1677 m_pRoutePoint->SetScaMin(m_textScaMin->GetValue());
1678 m_pRoutePoint->SetScaMax(m_textScaMax->GetValue());
1679 m_pRoutePoint->SetUseSca(m_checkBoxScaMin->GetValue());
1681 m_pRoutePoint->SetVisible(m_checkBoxVisible->GetValue());
1682 m_pRoutePoint->
m_bShowName = m_checkBoxShowName->GetValue();
1683 m_pRoutePoint->SetPosition(fromDMM(m_textLatitude->GetValue()),
1684 fromDMM(m_textLongitude->GetValue()));
1685 wxString* icon_name =
1686 pWayPointMan->GetIconKey(m_bcomboBoxIcon->GetSelection());
1687 if (icon_name && icon_name->Length())
1688 m_pRoutePoint->SetIconName(*icon_name);
1689 m_pRoutePoint->ReLoadIcon();
1690 m_pRoutePoint->SetShowWaypointRangeRings(
1691 (
bool)(m_ChoiceWaypointRangeRingsNumber->GetSelection() != 0));
1692 m_pRoutePoint->SetWaypointRangeRingsNumber(
1693 m_ChoiceWaypointRangeRingsNumber->GetSelection());
1695 if (m_textWaypointRangeRingsStep->GetValue().ToDouble(&value))
1697 if (m_textArrivalRadius->GetValue().ToDouble(&value))
1700 if (m_RangeRingUnits->GetSelection() != wxNOT_FOUND)
1701 m_pRoutePoint->SetWaypointRangeRingsStepUnits(
1702 m_RangeRingUnits->GetSelection());
1704 m_pRoutePoint->
m_TideStation = m_comboBoxTideStation->GetStringSelection();
1706 m_pRoutePoint->SetPlannedSpeed(0.0);
1710 m_pRoutePoint->SetPlannedSpeed(fromUsrSpeed(spd));
1717 int hour = t.GetHour();
1727 if (dtFormat ==
"Local Time") {
1728 m_pRoutePoint->
SetETD(dt.MakeUTC());
1729 }
else if (dtFormat ==
"UTC") {
1730 m_pRoutePoint->
SetETD(dt);
1739 "Failed to configured ETD. Unsupported date/time format: %s",
1741 m_pRoutePoint->
SetETD(wxInvalidDateTime);
1745 m_pRoutePoint->
SetETD(wxInvalidDateTime);
1750 pSelect->UpdateSelectableRouteSegments(m_pRoutePoint);
1753 wxArrayPtrVoid* pEditRouteArray =
1756 if (pEditRouteArray) {
1757 for (
unsigned int ir = 0; ir < pEditRouteArray->GetCount(); ir++) {
1758 Route* pr = (
Route*)pEditRouteArray->Item(ir);
1759 pr->FinalizeForRendering();
1760 pr->UpdateSegmentDistances();
1763 NavObj_dB::GetInstance().UpdateRoute(pr);
1765 delete pEditRouteArray;
1769 NavObj_dB::GetInstance().UpdateRoutePoint(m_pRoutePoint);
1775SaveDefaultsDialog::SaveDefaultsDialog(
MarkInfoDlg* parent)
1776 : wxDialog(parent, wxID_ANY, _(
"Save some defaults")) {
1778 this->SetSizeHints(wxDefaultSize, wxDefaultSize);
1780 wxBoxSizer* bSizer1 =
new wxBoxSizer(wxVERTICAL);
1781 wxStdDialogButtonSizer* StdDialogButtonSizer1;
1784 new wxStaticText(
this, wxID_ANY,
1785 _(
"Check which properties of current waypoint\n should "
1786 "be set as default for NEW waypoints."));
1787 bSizer1->Add(StaticText1, 0, wxALL | wxALIGN_CENTER_HORIZONTAL, 5);
1789 wxFlexGridSizer* fgSizer1 =
new wxFlexGridSizer(2);
1795 new wxCheckBox(
this, wxID_ANY, _(
"Show Waypoint Name"), wxDefaultPosition,
1796 wxDefaultSize, 0, wxDefaultValidator);
1797 fgSizer1->Add(NameCB, 0, wxALL, 5);
1798 stName =
new wxStaticText(
this, wxID_ANY,
"[" + s +
"]", wxDefaultPosition,
1801 fgSizer1->Add(stName, 0, wxALL | wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL, 5);
1804 IconCB =
new wxCheckBox(
this, wxID_ANY, _(
"Icon"));
1805 fgSizer1->Add(IconCB, 0, wxALL, 5);
1806 stIcon =
new wxStaticText(
this, wxID_ANY,
"[" + s +
"]", wxDefaultPosition,
1809 fgSizer1->Add(stIcon, 0, wxALL | wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL, 5);
1818 RangRingsCB =
new wxCheckBox(
this, wxID_ANY, _(
"Range rings"));
1819 fgSizer1->Add(RangRingsCB, 0, wxALL, 5);
1820 stRR =
new wxStaticText(
this, wxID_ANY,
"[" + s +
"]", wxDefaultPosition,
1823 fgSizer1->Add(stRR, 0, wxALL | wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL, 5);
1826 ArrivalRCB =
new wxCheckBox(
this, wxID_ANY, _(
"Arrival radius"));
1827 fgSizer1->Add(ArrivalRCB, 0, wxALL, 5);
1828 stArrivalR =
new wxStaticText(
1830 wxString::Format(
"[%s %s]", s.c_str(), getUsrDistanceUnit().c_str()),
1831 wxDefaultPosition, wxDefaultSize, 0);
1832 stArrivalR->Wrap(-1);
1833 fgSizer1->Add(stArrivalR, 0, wxALL | wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL,
1837 s = _(
"Show only at scales between ");
1842 s = _(
"Show always");
1844 ScaleCB =
new wxCheckBox(
this, wxID_ANY, _(
"Show only at scale"));
1845 fgSizer1->Add(ScaleCB, 0, wxALL, 5);
1846 stScale =
new wxStaticText(
this, wxID_ANY,
"[" + s +
"]", wxDefaultPosition,
1849 fgSizer1->Add(stScale, 0, wxALL | wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL, 5);
1851 bSizer1->Add(fgSizer1, 0, wxALL | wxEXPAND, 5);
1853 StdDialogButtonSizer1 =
new wxStdDialogButtonSizer();
1854 StdDialogButtonSizer1->AddButton(
new wxButton(
this, wxID_OK));
1855 StdDialogButtonSizer1->AddButton(
1856 new wxButton(
this, wxID_CANCEL, _(
"Cancel")));
1857 StdDialogButtonSizer1->Realize();
1858 bSizer1->Add(StdDialogButtonSizer1, 0, wxALL | wxEXPAND, 5);
1865 SetSize(parent->GetSize());
1871void MarkInfoDlg::ShowTidesBtnClicked(wxCommandEvent& event) {
1872 if (m_comboBoxTideStation->GetSelection() < 1) {
1876 ptcmgr->GetStationIDXbyName(m_comboBoxTideStation->GetStringSelection(),
1877 fromDMM(m_textLatitude->GetValue()),
1878 fromDMM(m_textLongitude->GetValue())));
1880 TCWin* pCwin =
new TCWin(gFrame->GetPrimaryCanvas(), 0, 0, pIDX);
1883 wxString msg(_(
"Tide Station not found"));
1885 msg += m_comboBoxTideStation->GetStringSelection();
1886 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.