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>
68#include "androidUTIL.h"
69#include <QtWidgets/QScroller>
72#define EXTENDED_PROP_PAGE 2
74WX_DEFINE_OBJARRAY(ArrayOfBitmaps);
78OCPNIconCombo::OCPNIconCombo(wxWindow* parent, wxWindowID
id,
79 const wxString& value,
const wxPoint& pos,
80 const wxSize& size,
int n,
81 const wxString choices[],
long style,
82 const wxValidator& validator,
const wxString& name)
83 : wxOwnerDrawnComboBox(parent, id, value, pos, size, n, choices, style,
86 GetFont().GetPointSize() / g_Platform->getFontPointsperPixel();
87 itemHeight = (int)wxRound(fontHeight);
90OCPNIconCombo::~OCPNIconCombo() {}
92void OCPNIconCombo::OnDrawItem(wxDC& dc,
const wxRect& rect,
int item,
94 int offset_x = bmpArray[item].GetWidth();
95 int bmpHeight = bmpArray[item].GetHeight();
96 dc.DrawBitmap(bmpArray[item], rect.x, rect.y + (rect.height - bmpHeight) / 2,
99 if (flags & wxODCB_PAINTING_CONTROL) {
100 wxString text = GetValue();
103#if wxCHECK_VERSION(2, 9, 0)
104 if (ShouldUseHintText()) {
106 wxColour col = wxSystemSettings::GetColour(wxSYS_COLOUR_GRAYTEXT);
107 dc.SetTextForeground(col);
110 margin_x = GetMargins().x;
113 dc.DrawText(text, rect.x + margin_x + offset_x,
114 (rect.height - dc.GetCharHeight()) / 2 + rect.y);
116 dc.DrawText(GetVListBoxComboPopup()->GetString(item), rect.x + 2 + offset_x,
117 (rect.height - dc.GetCharHeight()) / 2 + rect.y);
121wxCoord OCPNIconCombo::OnMeasureItem(
size_t item)
const {
122 int bmpHeight = bmpArray[item].GetHeight();
124 return wxMax(itemHeight, bmpHeight);
127wxCoord OCPNIconCombo::OnMeasureItemWidth(
size_t item)
const {
return -1; }
129int OCPNIconCombo::Append(
const wxString& item, wxBitmap bmp) {
131 int idx = wxOwnerDrawnComboBox::Append(item);
136void OCPNIconCombo::Clear() {
137 wxOwnerDrawnComboBox::Clear();
160 const wxString& value, const wxPoint& pos,
161 const wxSize& size,
long style,
162 const wxValidator& validator,
163 const wxString& name)
164 : wxTextCtrl(parent,
id, value, pos, size, style, validator, name) {
165 m_pParentEventHandler = parent->GetEventHandler();
168void LatLonTextCtrl::OnKillFocus(wxFocusEvent& event) {
171 up_event.SetEventObject((wxObject*)
this);
172 m_pParentEventHandler->AddPendingEvent(up_event);
181EVT_BUTTON(wxID_OK, MarkInfoDlg::OnMarkInfoOKClick)
182EVT_BUTTON(wxID_CANCEL, MarkInfoDlg::OnMarkInfoCancelClick)
183EVT_BUTTON(ID_BTN_DESC_BASIC, MarkInfoDlg::OnExtDescriptionClick)
184EVT_BUTTON(ID_DEFAULT, MarkInfoDlg::DefautlBtnClicked)
185EVT_BUTTON(ID_BTN_SHOW_TIDES, MarkInfoDlg::ShowTidesBtnClicked)
186EVT_COMBOBOX(ID_BITMAPCOMBOCTRL, MarkInfoDlg::OnBitmapCombClick)
187EVT_CHECKBOX(ID_CHECKBOX_SCAMIN_VIS, MarkInfoDlg::OnSelectScaMinExt)
188EVT_TEXT(ID_DESCR_CTR_DESC, MarkInfoDlg::OnDescChangedExt)
189EVT_TEXT(ID_DESCR_CTR_BASIC, MarkInfoDlg::OnDescChangedBasic)
190EVT_TEXT(ID_LATCTRL, MarkInfoDlg::OnPositionCtlUpdated)
191EVT_TEXT(ID_LONCTRL, MarkInfoDlg::OnPositionCtlUpdated)
192EVT_CHOICE(ID_WPT_RANGERINGS_NO, MarkInfoDlg::OnWptRangeRingsNoChange)
194EVT_HTML_LINK_CLICKED(wxID_ANY, MarkInfoDlg::OnHtmlLinkClicked)
195EVT_COMMAND(wxID_ANY, EVT_LAYOUT_RESIZE, MarkInfoDlg::OnLayoutResize)
196EVT_CLOSE(MarkInfoDlg::OnClose)
202 const wxPoint& pos, const wxSize& size,
long style) {
203 DIALOG_PARENT::Create(parent,
id, title, pos, size, style);
207 int metric = GetCharHeight();
211 wxString wqs = getFontQtStylesheet(qFont);
212 wxCharBuffer sbuf = wqs.ToUTF8();
213 QString qsb = QString(sbuf.data());
214 QString qsbq = getQtStyleSheet();
215 this->GetHandle()->setStyleSheet(qsb + qsbq);
217 if (sdc.IsOk()) sdc.GetTextExtent(
"W", NULL, &metric, NULL, NULL, qFont);
220 m_pMyLinkList = NULL;
221 SetColorScheme((ColorScheme)0);
222 m_pRoutePoint = NULL;
223 m_SaveDefaultDlg = NULL;
227 Connect(wxEVT_ACTIVATE, wxActivateEventHandler(MarkInfoDlg::OnActivate), NULL,
232void MarkInfoDlg::OnActivate(wxActivateEvent& event) {
233 auto pWin =
dynamic_cast<DIALOG_PARENT*
>(
event.GetEventObject());
234 long int style = pWin->GetWindowStyle();
235 if (event.GetActive())
236 pWin->SetWindowStyle(style | wxSTAY_ON_TOP);
238 pWin->SetWindowStyle(style ^ wxSTAY_ON_TOP);
241void MarkInfoDlg::initialize_images() {
242 wxString iconDir = g_Platform->GetSharedDataDir() +
"uidata/MUI_flat/";
243 _img_MUI_settings_svg =
LoadSVG(iconDir +
"MUI_settings.svg",
244 2 * GetCharHeight(), 2 * GetCharHeight());
247 wxBitmap tide = style->GetIcon(
"tidesml");
248 wxImage tide1 = tide.ConvertToImage();
249 wxImage tide1s = tide1.Scale(m_sizeMetric * 3 / 2, m_sizeMetric * 3 / 2,
250 wxIMAGE_QUALITY_HIGH);
251 m_bmTide = wxBitmap(tide1s);
256void MarkInfoDlg::Create() {
259 m_sizeMetric = GetCharHeight();
264 wxString wqs = getFontQtStylesheet(qFont);
265 wxCharBuffer sbuf = wqs.ToUTF8();
266 QString qsb = QString(sbuf.data());
268 QString qsbq = getAdjustedDialogStyleSheet();
270 this->GetHandle()->setStyleSheet(qsb + qsbq);
274 sdc.GetTextExtent(
"W", NULL, &m_sizeMetric, NULL, NULL, qFont);
281 bSizer1 =
new wxBoxSizer(wxVERTICAL);
283 bSizer1->SetSizeHints(
this);
286 m_notebookProperties =
new wxNotebook(
this, wxID_ANY, wxDefaultPosition,
287 wxDefaultSize, wxNB_FIXEDWIDTH);
289 m_panelBasicProperties =
new wxScrolledWindow(
290 m_notebookProperties, wxID_ANY, wxDefaultPosition, wxDefaultSize,
291 wxHSCROLL | wxVSCROLL | wxTAB_TRAVERSAL);
293 m_panelBasicProperties->GetHandle()->setStyleSheet(
294 getAdjustedDialogStyleSheet());
298 m_panelBasicProperties->SetScrollRate(0, 2);
299 m_notebookProperties->AddPage(m_panelBasicProperties, _(
"Basic"),
true);
300 bSizerBasicProperties =
new wxBoxSizer(wxVERTICAL);
301 m_panelBasicProperties->SetSizer(bSizerBasicProperties);
304 m_staticTextLayer =
new wxStaticText(
305 m_panelBasicProperties, wxID_ANY,
306 _(
"This waypoint is part of a layer and can't be edited"),
307 wxDefaultPosition, wxDefaultSize, 0);
308 m_staticTextLayer->Enable(
false);
309 bSizerBasicProperties->Add(m_staticTextLayer, 0, wxALL, 5);
312 wxPanel* props_panel =
new wxPanel(m_panelBasicProperties);
314 props_panel->SetSizer(props_sizer);
315 bSizerBasicProperties->Add(props_panel, 0, wxALL | wxEXPAND, 16);
316 int label_size = m_sizeMetric * 4;
319 m_textName =
new TextField(props_panel, _(
"Name"));
322 wxStaticText* name_cb_label =
323 new wxStaticText(props_panel, wxID_ANY, _(
"Show waypoint name"));
325 new wxCheckBox(props_panel, wxID_ANY,
"", wxDefaultPosition,
326 wxDefaultSize, wxALIGN_CENTER_VERTICAL);
327 m_checkBoxShowName->Bind(wxEVT_CHECKBOX,
328 &MarkInfoDlg::OnShowWaypointNameSelectBasic,
this);
329 props_sizer->Add(name_cb_label, 0, wxALIGN_TOP);
330 props_sizer->Add(m_checkBoxShowName, 0, wxEXPAND);
333 int icon_size = m_sizeMetric * 2;
334 icon_size = wxMax(icon_size, (32 * g_MarkScaleFactorExp) + 4);
336 new OCPNIconCombo(props_panel, wxID_ANY, _(
"Combo!"), wxDefaultPosition,
337 wxDefaultSize, 0, NULL, wxCB_READONLY);
338 m_bcomboBoxIcon->SetPopupMaxHeight(::wxGetDisplaySize().y / 2);
339 m_bcomboBoxIcon->SetMinSize(wxSize(-1, icon_size));
341 wxStaticText* icon_label =
new wxStaticText(props_panel, wxID_ANY, _(
"Icon"));
342 icon_label->SetMinSize(wxSize(label_size, -1));
343 props_sizer->Add(icon_label, 0, wxALIGN_CENTER_VERTICAL);
344 props_sizer->Add(m_bcomboBoxIcon, 0, wxEXPAND);
347 m_textLatitude =
new TextField(props_panel, _(
"Latitude"));
348 m_textLongitude =
new TextField(props_panel, _(
"Longitude"));
349 props_sizer->Fit(props_panel);
352 wxStaticBox* desc_box =
353 new wxStaticBox(m_panelBasicProperties, wxID_ANY, _(
"Description"));
354 wxStaticBoxSizer* desc_sizer =
new wxStaticBoxSizer(desc_box, wxHORIZONTAL);
355 bSizerBasicProperties->Add(desc_sizer, 1, wxALL | wxEXPAND, 8);
356 m_textDescription =
new wxTextCtrl(m_panelBasicProperties, ID_DESCR_CTR_BASIC,
357 "", wxDefaultPosition, wxDefaultSize,
358 wxTE_MULTILINE | wxTE_READONLY);
359 m_textDescription->SetMinSize(wxSize(-1, 80));
360 desc_sizer->Add(m_textDescription, 1, wxEXPAND);
363 m_buttonExtDescription =
364 new wxButton(m_panelBasicProperties, ID_BTN_DESC_BASIC,
"...",
365 wxDefaultPosition, wxSize(GetCharHeight() * 15 / 10, -1), 0);
366 desc_sizer->Add(m_buttonExtDescription, 0, wxEXPAND);
369 wxStaticBox* links_box =
370 new wxStaticBox(m_panelBasicProperties, wxID_ANY, _(
"Links"));
371 wxStaticBoxSizer* links_sizer =
new wxStaticBoxSizer(links_box, wxHORIZONTAL);
372 bSizerBasicProperties->Add(links_sizer, 1, wxALL | wxEXPAND, 8);
375 m_htmlList =
new wxSimpleHtmlListBox(m_panelBasicProperties, wxID_ANY,
376 wxDefaultPosition, wxDefaultSize, 0);
377 links_sizer->Add(m_htmlList, 1, wxEXPAND);
380 m_scrolledWindowLinks =
381 new wxScrolledWindow(m_panelBasicProperties, wxID_ANY, wxDefaultPosition,
382 wxSize(-1, 100), wxHSCROLL | wxVSCROLL);
383 m_scrolledWindowLinks->SetMinSize(wxSize(-1, 80));
384 m_scrolledWindowLinks->SetScrollRate(2, 2);
385 links_sizer->Add(m_scrolledWindowLinks, 1, wxEXPAND);
387 bSizerLinks =
new wxBoxSizer(wxVERTICAL);
388 m_scrolledWindowLinks->SetSizer(bSizerLinks);
390 m_menuLink =
new wxMenu();
391 wxMenuItem* m_menuItemDelete;
392 m_menuItemDelete =
new wxMenuItem(m_menuLink, wxID_ANY, wxString(_(
"Delete")),
394 m_menuLink->Append(m_menuItemDelete);
396 wxMenuItem* m_menuItemEdit;
397 m_menuItemEdit =
new wxMenuItem(m_menuLink, wxID_ANY, wxString(_(
"Edit")),
"",
399 m_menuLink->Append(m_menuItemEdit);
401 wxMenuItem* m_menuItemAdd;
402 m_menuItemAdd =
new wxMenuItem(m_menuLink, wxID_ANY, wxString(_(
"Add new")),
404 m_menuLink->Append(m_menuItemAdd);
406 wxBoxSizer* bSizer9 =
new wxBoxSizer(wxHORIZONTAL);
409 new wxButton(m_panelBasicProperties, wxID_ANY, _(
"Add new"),
410 wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT);
411 bSizer9->Add(m_buttonAddLink, 0, wxALL, 5);
413 m_buttonAddLink->Connect(wxEVT_COMMAND_BUTTON_CLICKED,
414 wxCommandEventHandler(MarkInfoDlg::OnAddLink), NULL,
417 links_sizer->Add(bSizer9, 0, wxEXPAND, 5);
422 new wxPanel(m_notebookProperties, wxID_ANY, wxDefaultPosition,
423 wxDefaultSize, wxTAB_TRAVERSAL);
424 wxBoxSizer* bSizer15;
425 bSizer15 =
new wxBoxSizer(wxVERTICAL);
427 m_textCtrlExtDescription =
428 new wxTextCtrl(m_panelDescription, ID_DESCR_CTR_DESC,
"",
429 wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE);
430 bSizer15->Add(m_textCtrlExtDescription, 1, wxALL | wxEXPAND, 5);
432 m_panelDescription->SetSizer(bSizer15);
433 m_notebookProperties->AddPage(m_panelDescription, _(
"Description"),
false);
438 m_panelExtendedProperties =
new wxScrolledWindow(
439 m_notebookProperties, wxID_ANY, wxDefaultPosition, wxDefaultSize,
440 wxHSCROLL | wxVSCROLL | wxTAB_TRAVERSAL);
442 m_panelExtendedProperties->GetHandle()->setStyleSheet(
443 getAdjustedDialogStyleSheet());
446 m_panelExtendedProperties->SetScrollRate(0, 2);
448 wxBoxSizer* fSizerExtProperties =
new wxBoxSizer(wxVERTICAL);
449 m_panelExtendedProperties->SetSizer(fSizerExtProperties);
450 m_notebookProperties->AddPage(m_panelExtendedProperties, _(
"Extended"),
453 sbSizerExtProperties =
new wxStaticBoxSizer(
454 wxVERTICAL, m_panelExtendedProperties, _(
"Extended Properties"));
455 wxFlexGridSizer* gbSizerInnerExtProperties =
new wxFlexGridSizer(3, 0, 0);
456 gbSizerInnerExtProperties->AddGrowableCol(2);
457 gbSizerInnerExtProperties->SetFlexibleDirection(wxBOTH);
458 gbSizerInnerExtProperties->SetNonFlexibleGrowMode(wxFLEX_GROWMODE_SPECIFIED);
460 m_checkBoxVisible =
new wxCheckBox(sbSizerExtProperties->GetStaticBox(),
461 ID_CHECKBOX_VIS_EXT,
"");
462 gbSizerInnerExtProperties->Add(m_checkBoxVisible);
463 wxStaticText* m_staticTextVisible =
new wxStaticText(
464 sbSizerExtProperties->GetStaticBox(), wxID_ANY, _(
"Show on chart"));
465 gbSizerInnerExtProperties->Add(m_staticTextVisible);
466 gbSizerInnerExtProperties->Add(0, 0, 1, wxEXPAND, 0);
468 m_checkBoxScaMin =
new wxCheckBox(sbSizerExtProperties->GetStaticBox(),
469 ID_CHECKBOX_SCAMIN_VIS,
"");
470 gbSizerInnerExtProperties->Add(m_checkBoxScaMin, 0, wxALIGN_CENTRE_VERTICAL,
472 m_staticTextScaMin =
new wxStaticText(sbSizerExtProperties->GetStaticBox(),
473 wxID_ANY, _(
"Show at scale > 1 :"));
474 gbSizerInnerExtProperties->Add(m_staticTextScaMin, 0, wxALIGN_CENTRE_VERTICAL,
476 m_textScaMin =
new wxTextCtrl(sbSizerExtProperties->GetStaticBox(), wxID_ANY);
477 gbSizerInnerExtProperties->Add(m_textScaMin, 0, wxALL | wxEXPAND, 5);
478 gbSizerInnerExtProperties->Add(0, 0, 1, wxEXPAND, 0);
479 m_staticTextScaMax =
new wxStaticText(sbSizerExtProperties->GetStaticBox(),
480 wxID_ANY, _(
"Show at scale < 1 :"));
481 gbSizerInnerExtProperties->Add(m_staticTextScaMax, 0, wxALIGN_CENTRE_VERTICAL,
483 m_textScaMax =
new wxTextCtrl(sbSizerExtProperties->GetStaticBox(), wxID_ANY);
484 gbSizerInnerExtProperties->Add(m_textScaMax, 0, wxALL | wxEXPAND, 5);
486 m_checkBoxShowNameExt =
487 new wxCheckBox(sbSizerExtProperties->GetStaticBox(), wxID_ANY,
"");
488 m_checkBoxShowNameExt->Bind(wxEVT_CHECKBOX,
489 &MarkInfoDlg::OnShowWaypointNameSelectExt,
this);
490 gbSizerInnerExtProperties->Add(m_checkBoxShowNameExt);
491 m_staticTextShowNameExt =
new wxStaticText(
492 sbSizerExtProperties->GetStaticBox(), wxID_ANY, _(
"Show waypoint name"));
494 gbSizerInnerExtProperties->Add(m_staticTextShowNameExt);
495 gbSizerInnerExtProperties->Add(0, 0, 1, wxEXPAND, 0);
497 sbRangeRingsExtProperties =
new wxStaticBoxSizer(
498 wxVERTICAL, sbSizerExtProperties->GetStaticBox(), _(
"Range rings"));
499 wxFlexGridSizer* gbRRExtProperties =
new wxFlexGridSizer(4, 0, 0);
500 gbRRExtProperties->AddGrowableCol(0);
501 gbRRExtProperties->AddGrowableCol(1);
502 gbRRExtProperties->AddGrowableCol(3);
503 m_staticTextRR1 =
new wxStaticText(sbSizerExtProperties->GetStaticBox(),
504 wxID_ANY, _(
"Number"));
505 gbRRExtProperties->Add(m_staticTextRR1, 0, wxLEFT, 5);
506 m_staticTextRR2 =
new wxStaticText(sbSizerExtProperties->GetStaticBox(),
507 wxID_ANY, _(
"Distance"));
508 gbRRExtProperties->Add(m_staticTextRR2, 0, wxLEFT, 5);
509 gbRRExtProperties->Add(0, 0, 1, wxEXPAND, 5);
510 m_staticTextRR4 =
new wxStaticText(sbSizerExtProperties->GetStaticBox(),
511 wxID_ANY, _(
"Color"));
512 gbRRExtProperties->Add(m_staticTextRR4, 0, wxLEFT, 5);
514 wxString rrAlt[] = {_(
"None"),
"1",
"2",
"3",
"4",
"5",
515 "6",
"7",
"8",
"9",
"10"};
516 m_ChoiceWaypointRangeRingsNumber =
517 new wxChoice(sbSizerExtProperties->GetStaticBox(), ID_WPT_RANGERINGS_NO,
518 wxDefaultPosition, wxDefaultSize, 11, rrAlt);
520 gbRRExtProperties->Add(m_ChoiceWaypointRangeRingsNumber, 0, wxALL | wxEXPAND,
522 m_textWaypointRangeRingsStep =
523 new wxTextCtrl(sbSizerExtProperties->GetStaticBox(), wxID_ANY, _(
"0.05"),
524 wxDefaultPosition, wxDefaultSize, 0);
525 gbRRExtProperties->Add(m_textWaypointRangeRingsStep, 0, wxALL | wxEXPAND, 5);
527 wxString pDistUnitsStrings[] = {_(
"NMi"), _(
"km")};
529 new wxChoice(sbSizerExtProperties->GetStaticBox(), wxID_ANY,
530 wxDefaultPosition, wxDefaultSize, 2, pDistUnitsStrings);
531 gbRRExtProperties->Add(m_RangeRingUnits, 0, wxALIGN_CENTRE_VERTICAL, 0);
533 m_PickColor =
new wxColourPickerCtrl(sbSizerExtProperties->GetStaticBox(),
534 wxID_ANY, wxColour(0, 0, 0),
535 wxDefaultPosition, wxDefaultSize, 0);
536 gbRRExtProperties->Add(m_PickColor, 0, wxALL | wxEXPAND, 5);
537 sbRangeRingsExtProperties->Add(
538 gbRRExtProperties, 1,
539 wxLEFT | wxTOP | wxEXPAND | wxALIGN_LEFT | wxALIGN_TOP, 5);
541 sbSizerExtProperties->GetStaticBox()->Layout();
543 wxFlexGridSizer* gbSizerInnerExtProperties2 =
new wxFlexGridSizer(2, 0, 0);
544 gbSizerInnerExtProperties2->AddGrowableCol(1);
547 new wxStaticText(sbSizerExtProperties->GetStaticBox(), wxID_ANY,
548 _(
"GUID"), wxDefaultPosition, wxDefaultSize, 0);
549 gbSizerInnerExtProperties2->Add(m_staticTextGuid, 0, wxALIGN_CENTRE_VERTICAL,
552 new wxTextCtrl(sbSizerExtProperties->GetStaticBox(), wxID_ANY,
"",
553 wxDefaultPosition, wxDefaultSize, wxTE_READONLY);
554 m_textCtrlGuid->SetEditable(
false);
555 gbSizerInnerExtProperties2->Add(m_textCtrlGuid, 0, wxALL | wxEXPAND, 5);
557 wxFlexGridSizer* gbSizerInnerExtProperties1 =
new wxFlexGridSizer(3, 0, 0);
558 gbSizerInnerExtProperties1->AddGrowableCol(1);
560 m_staticTextTideStation =
561 new wxStaticText(sbSizerExtProperties->GetStaticBox(), wxID_ANY,
562 _(
"Tide Station"), wxDefaultPosition, wxDefaultSize, 0);
563 gbSizerInnerExtProperties1->Add(m_staticTextTideStation, 0,
564 wxALIGN_CENTRE_VERTICAL, 5);
567 m_choiceTideChoices.Add(
" ");
568 m_comboBoxTideStation =
569 new wxChoice(sbSizerExtProperties->GetStaticBox(), wxID_ANY,
570 wxDefaultPosition, wxDefaultSize, m_choiceTideChoices);
572 gbSizerInnerExtProperties1->Add(
573 m_comboBoxTideStation, 0, wxALL | wxEXPAND | wxALIGN_CENTRE_VERTICAL, 5);
576 m_comboBoxTideStation =
577 new wxComboBox(sbSizerExtProperties->GetStaticBox(), wxID_ANY,
"",
578 wxDefaultPosition, wxDefaultSize, 0, NULL, wxCB_READONLY);
579 gbSizerInnerExtProperties1->Add(
580 m_comboBoxTideStation, 0, wxALL | wxEXPAND | wxALIGN_CENTRE_VERTICAL, 5);
582 m_comboBoxTideStation->SetToolTip(
583 _(
"Associate this waypoint with a tide station to quickly access tide "
584 "predictions. Select from nearby stations or leave empty for no "
587 m_buttonShowTides =
new wxBitmapButton(
588 sbSizerExtProperties->GetStaticBox(), ID_BTN_SHOW_TIDES, m_bmTide,
589 wxDefaultPosition, m_bmTide.GetSize(), 0);
590 gbSizerInnerExtProperties1->Add(m_buttonShowTides, 0,
591 wxALL | wxALIGN_CENTRE_VERTICAL, 5);
593 m_staticTextArrivalRadius =
new wxStaticText(
594 sbSizerExtProperties->GetStaticBox(), wxID_ANY, _(
"Arrival Radius"));
595 gbSizerInnerExtProperties1->Add(m_staticTextArrivalRadius, 0,
596 wxALIGN_CENTRE_VERTICAL, 0);
597 m_textArrivalRadius =
598 new wxTextCtrl(sbSizerExtProperties->GetStaticBox(), wxID_ANY,
"",
599 wxDefaultPosition, wxDefaultSize, 0);
600 m_textArrivalRadius->SetToolTip(
601 _(
"Distance from the waypoint at which OpenCPN will consider the "
602 "waypoint reached. Used for automatic waypoint advancement during "
603 "active navigation."));
604 gbSizerInnerExtProperties1->Add(m_textArrivalRadius, 0, wxALL | wxEXPAND, 5);
605 m_staticTextArrivalUnits =
606 new wxStaticText(sbSizerExtProperties->GetStaticBox(), wxID_ANY,
"",
607 wxDefaultPosition, wxDefaultSize, 0);
608 gbSizerInnerExtProperties1->Add(m_staticTextArrivalUnits, 0,
609 wxALIGN_CENTRE_VERTICAL, 0);
611 m_staticTextPlSpeed =
612 new wxStaticText(sbSizerExtProperties->GetStaticBox(), wxID_ANY,
613 _(
"Planned Speed"), wxDefaultPosition, wxDefaultSize, 0);
614 gbSizerInnerExtProperties1->Add(m_staticTextPlSpeed, 0,
615 wxALIGN_CENTRE_VERTICAL, 0);
617 new wxTextCtrl(sbSizerExtProperties->GetStaticBox(), wxID_ANY,
"",
618 wxDefaultPosition, wxDefaultSize, 0);
620 "Enter the planned vessel speed for the leg FOLLOWING this waypoint. "
621 "This speed is used when traveling FROM this waypoint TO the next "
622 "waypoint in the route. The value is used to calculate estimated time "
623 "of arrival at the next waypoint based on the ETD from this waypoint.\n\n"
624 "If left blank, the route's default speed will be used for this leg. "
625 "Individual waypoint speeds override the route-level speed setting."));
627 m_staticTextPlSpeedUnits =
628 new wxStaticText(sbSizerExtProperties->GetStaticBox(), wxID_ANY,
629 getUsrSpeedUnit(), wxDefaultPosition, wxDefaultSize, 0);
630 gbSizerInnerExtProperties1->Add(m_staticTextPlSpeedUnits, 0,
631 wxALIGN_CENTRE_VERTICAL, 0);
635 m_staticTextEtd =
new wxStaticText(sbSizerExtProperties->GetStaticBox(),
637 gbSizerInnerExtProperties1->Add(
m_staticTextEtd, 0, wxALIGN_CENTRE_VERTICAL,
639 wxBoxSizer* bsTimestamp =
new wxBoxSizer(wxHORIZONTAL);
641 new wxCheckBox(sbSizerExtProperties->GetStaticBox(), wxID_ANY,
"");
643 _(
"Enable to manually set a planned departure time (ETD) for this "
645 "When checked, the specified date and time will be used instead of the "
646 "automatically calculated ETD. This affects ETA calculations for "
647 "subsequent waypoints in the route."));
650 sbSizerExtProperties->GetStaticBox(), ID_ETA_DATEPICKERCTRL,
651 wxDefaultDateTime, wxDefaultPosition, wxDefaultSize, wxDP_DEFAULT,
654 "Select the planned departure date (ETD) for this waypoint.\nUsed "
655 "together with the time control to calculate arrival times at subsequent "
656 "waypoints.\nETD information is only used for route planning "
657 "and does not affect navigation."));
662 new TimeCtrl(sbSizerExtProperties->GetStaticBox(), ID_ETA_TIMEPICKERCTRL,
663 wxDefaultDateTime, wxDefaultPosition, wxDefaultSize);
666 sbSizerExtProperties->GetStaticBox(), ID_ETA_TIMEPICKERCTRL,
667 wxDefaultDateTime, wxDefaultPosition, wxDefaultSize, wxDP_DEFAULT,
672 gbSizerInnerExtProperties1->Add(bsTimestamp, 0, wxEXPAND, 0);
673 sbSizerExtProperties->Add(gbSizerInnerExtProperties, 0, wxALL | wxEXPAND, 5);
674 sbSizerExtProperties->Add(sbRangeRingsExtProperties, 0, wxALL | wxEXPAND, 5);
675 sbSizerExtProperties->Add(gbSizerInnerExtProperties2, 0, wxALL | wxEXPAND, 5);
676 sbSizerExtProperties->Add(gbSizerInnerExtProperties1, 0, wxALL | wxEXPAND, 5);
678 fSizerExtProperties->Add(sbSizerExtProperties, 1, wxALL | wxEXPAND);
681 bSizer1->Add(m_notebookProperties, 1, wxEXPAND);
683 wxBoxSizer* btnSizer =
new wxBoxSizer(wxHORIZONTAL);
684 bSizer1->Add(btnSizer, 0, wxEXPAND, 0);
687 new wxBitmapButton(
this, ID_DEFAULT, _img_MUI_settings_svg,
688 wxDefaultPosition, _img_MUI_settings_svg.GetSize(), 0);
689 btnSizer->Add(DefaultsBtn, 0, wxALL | wxALIGN_LEFT | wxALIGN_BOTTOM, 5);
690 btnSizer->Add(0, 0, 1, wxEXPAND);
692 m_sdbSizerButtons =
new wxStdDialogButtonSizer();
693 m_buttonOkay =
new wxButton(
this, wxID_OK);
694 m_sdbSizerButtons->AddButton(m_buttonOkay);
695 m_sdbSizerButtons->AddButton(
new wxButton(
this, wxID_CANCEL, _(
"Cancel")));
696 m_sdbSizerButtons->Realize();
697 btnSizer->Add(m_sdbSizerButtons, 0, wxALL, 5);
702 m_textLatitude->Connect(
704 wxCommandEventHandler(MarkInfoDlg::OnRightClickLatLon), NULL,
this);
705 m_textLongitude->Connect(
707 wxCommandEventHandler(MarkInfoDlg::OnRightClickLatLon), NULL,
this);
709 m_htmlList->Connect(wxEVT_RIGHT_DOWN,
710 wxMouseEventHandler(MarkInfoDlg::m_htmlListContextMenu),
714 m_notebookProperties->Connect(
715 wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED,
716 wxNotebookEventHandler(MarkInfoDlg::OnNotebookPageChanged), NULL,
this);
721 m_comboBoxTideStation->Connect(
722 wxEVT_COMMAND_COMBOBOX_SELECTED,
723 wxCommandEventHandler(MarkInfoDlg::OnTideStationCombobox), NULL,
this);
726void MarkInfoDlg::OnClose(wxCloseEvent& event) {
732#define TIDESTATION_BATCH_SIZE 10
734void MarkInfoDlg::OnTideStationCombobox(wxCommandEvent& event) {
735 int count = m_comboBoxTideStation->GetCount();
736 int sel = m_comboBoxTideStation->GetSelection();
737 if (sel == count - 1) {
740 for (
auto ts : m_tss) {
741 if (i == count + TIDESTATION_BATCH_SIZE) {
745 n = wxString::FromUTF8(ts.second->IDX_station_name);
746 m_comboBoxTideStation->Append(n);
753void MarkInfoDlg::OnNotebookPageChanged(wxNotebookEvent& event) {
754 if (event.GetSelection() == EXTENDED_PROP_PAGE) {
755 if (m_lasttspos.IsSameAs(m_textLatitude->GetValue() +
756 m_textLongitude->GetValue())) {
759 m_lasttspos = m_textLatitude->GetValue() + m_textLongitude->GetValue();
760 double lat = fromDMM(m_textLatitude->GetValue());
761 double lon = fromDMM(m_textLongitude->GetValue());
762 m_tss =
ptcmgr->GetStationsForLL(lat, lon);
763 wxString s = m_comboBoxTideStation->GetStringSelection();
766 m_comboBoxTideStation->Clear();
767 m_comboBoxTideStation->Append(
"");
768 for (
auto ts : m_tss) {
769 if (i == TIDESTATION_BATCH_SIZE) {
773 n = wxString::FromUTF8(ts.second->IDX_station_name);
774 m_comboBoxTideStation->Append(n);
776 m_comboBoxTideStation->SetSelection(i);
779 if (m_comboBoxTideStation->GetStringSelection() != s) {
780 m_comboBoxTideStation->Insert(s, 1);
781 m_comboBoxTideStation->SetSelection(1);
786void MarkInfoDlg::RecalculateSize() {
791 wxSize dsize = GetParent()->GetClientSize();
795 esize.x = GetCharHeight() * 20;
796 esize.y = GetCharHeight() * 40;
799 esize.y = wxMin(esize.y, dsize.y - (2 * GetCharHeight()));
800 esize.x = wxMin(esize.x, dsize.x - (1 * GetCharHeight()));
801 SetSize(wxSize(esize.x, esize.y));
804 wxSize fsize = GetSize();
805 fsize.y = wxMin(fsize.y, dsize.y - (2 * GetCharHeight()));
806 fsize.x = wxMin(fsize.x, dsize.x - (1 * GetCharHeight()));
810 fsize.y = wxMin(fsize.y, (25 * GetCharHeight()));
812 SetSize(wxSize(-1, fsize.y));
814 m_defaultClientSize = GetClientSize();
817 wxSize dsize = GetParent()->GetClientSize();
818 SetSize(-1, wxMax(GetSize().y, dsize.y / 1.5));
822MarkInfoDlg::~MarkInfoDlg() {
824 m_textLatitude->Disconnect(
826 wxCommandEventHandler(MarkInfoDlg::OnRightClickLatLon), NULL,
this);
827 m_textLongitude->Disconnect(
829 wxCommandEventHandler(MarkInfoDlg::OnRightClickLatLon), NULL,
this);
831 m_htmlList->Disconnect(
832 wxEVT_RIGHT_DOWN, wxMouseEventHandler(MarkInfoDlg::m_htmlListContextMenu),
837 m_notebookProperties->Disconnect(
838 wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED,
839 wxNotebookEventHandler(MarkInfoDlg::OnNotebookPageChanged), NULL,
this);
841 wxEVT_TIME_CHANGED, wxDateEventHandler(MarkInfoDlg::OnTimeChanged), NULL,
844 wxEVT_DATE_CHANGED, wxDateEventHandler(MarkInfoDlg::OnTimeChanged), NULL,
848 androidEnableBackButton(
true);
852void MarkInfoDlg::InitialFocus() {
853 m_textName->SetFocus();
854 m_textName->SetInsertionPointEnd();
857void MarkInfoDlg::SetColorScheme(ColorScheme cs) { DimeControl(
this); }
859void MarkInfoDlg::ClearData() {
860 m_pRoutePoint = NULL;
864void MarkInfoDlg::SetRoutePoint(
RoutePoint* pRP) {
867 m_lat_save = m_pRoutePoint->m_lat;
868 m_lon_save = m_pRoutePoint->m_lon;
869 m_IconName_save = m_pRoutePoint->GetIconName();
872 m_Name_save = m_pRoutePoint->GetName();
874 m_bUseScaMin_save = m_pRoutePoint->GetUseSca();
875 m_iScaminVal_save = m_pRoutePoint->GetScaMin();
876 m_iScamaxVal_save = m_pRoutePoint->GetScaMax();
878 if (m_pMyLinkList)
delete m_pMyLinkList;
879 m_pMyLinkList =
new HyperlinkList();
880 for (
Hyperlink* link : *m_pRoutePoint->m_HyperlinkList) {
882 h->DescrText = link->DescrText;
883 h->Link = link->Link;
884 h->LType = link->LType;
886 m_pMyLinkList->push_back(h);
891void MarkInfoDlg::UpdateHtmlList() {
893 GetSimpleBox()->Clear();
896 if (NbrOfLinks > 0) {
898 for (
auto it = list->begin(); it != list->end(); ++it) {
901 wxString::Format(
"<a href='%s'>%s</a>", link->Link, link->DescrText);
902 GetSimpleBox()->AppendString(s);
907 wxWindowList kids = m_scrolledWindowLinks->GetChildren();
908 for (
unsigned int i = 0; i < kids.GetCount(); i++) {
909 wxWindowListNode* node = kids.Item(i);
910 wxWindow* win = node->GetData();
912 auto link_win =
dynamic_cast<wxHyperlinkCtrl*
>(win);
914 link_win->Disconnect(
915 wxEVT_COMMAND_HYPERLINK,
916 wxHyperlinkEventHandler(MarkInfoDlg::OnHyperLinkClick));
917 link_win->Disconnect(
919 wxMouseEventHandler(MarkInfoDlg::m_htmlListContextMenu));
924 for (
Hyperlink* link : *m_pRoutePoint->m_HyperlinkList) {
925 wxString Link = link->Link;
926 wxString Descr = link->DescrText;
928 wxHyperlinkCtrl* ctrl =
new wxHyperlinkCtrl(
929 m_scrolledWindowLinks, wxID_ANY, Descr, Link, wxDefaultPosition,
930 wxDefaultSize, wxNO_BORDER | wxHL_CONTEXTMENU | wxHL_ALIGN_LEFT);
931 ctrl->Connect(wxEVT_COMMAND_HYPERLINK,
932 wxHyperlinkEventHandler(MarkInfoDlg::OnHyperLinkClick), NULL,
935 ctrl->Connect(wxEVT_RIGHT_DOWN,
936 wxMouseEventHandler(MarkInfoDlg::m_htmlListContextMenu),
939 bSizerLinks->Add(ctrl, 1, wxALL | wxEXPAND, 5);
943 m_scrolledWindowLinks->Layout();
947void MarkInfoDlg::OnHyperLinkClick(wxHyperlinkEvent& event) {
948 wxString url =
event.GetURL();
949 url.Replace(
" ",
"%20");
950 if (g_Platform) g_Platform->platformLaunchDefaultBrowser(url);
953void MarkInfoDlg::OnHtmlLinkClicked(wxHtmlLinkEvent& event) {
963 wxString cc =
event.GetLinkInfo().GetHref().c_str();
964 if (cc.Find(
"#") != wxNOT_FOUND) {
965 wxRegKey RegKey(wxString(
"HKEY_CLASSES_ROOT\\HTTP\\shell\\open\\command"));
966 if (RegKey.Exists()) {
967 wxString command_line;
968 RegKey.QueryValue(wxString(
""), command_line);
971 command_line.Replace(wxString(
"\""), wxString(
""));
974 int l = command_line.Find(
".exe");
975 if (wxNOT_FOUND == l) l = command_line.Find(
".EXE");
977 if (wxNOT_FOUND != l) {
978 wxString cl = command_line.Mid(0, l + 4);
987 wxString url =
event.GetLinkInfo().GetHref().c_str();
988 url.Replace(
" ",
"%20");
989 ::wxLaunchDefaultBrowser(url);
993 wxString url =
event.GetLinkInfo().GetHref().c_str();
994 url.Replace(
" ",
"%20");
995 if (g_Platform) g_Platform->platformLaunchDefaultBrowser(url);
1001void MarkInfoDlg::OnLayoutResize(wxCommandEvent& event) {
1002 m_panelBasicProperties->Layout();
1006void MarkInfoDlg::OnDescChangedExt(wxCommandEvent& event) {
1007 if (m_panelDescription->IsShownOnScreen()) {
1008 m_textDescription->ChangeValue(m_textCtrlExtDescription->GetValue());
1012void MarkInfoDlg::OnDescChangedBasic(wxCommandEvent& event) {
1013 if (m_panelBasicProperties->IsShownOnScreen()) {
1014 m_textCtrlExtDescription->ChangeValue(m_textDescription->GetValue());
1019void MarkInfoDlg::OnExtDescriptionClick(wxCommandEvent& event) {
1020 long pos = m_textDescription->GetInsertionPoint();
1021 m_notebookProperties->SetSelection(1);
1022 m_textCtrlExtDescription->SetInsertionPoint(pos);
1026void MarkInfoDlg::OnShowWaypointNameSelectBasic(wxCommandEvent& event) {
1027 m_checkBoxShowNameExt->SetValue(m_checkBoxShowName->GetValue());
1030void MarkInfoDlg::OnShowWaypointNameSelectExt(wxCommandEvent& event) {
1031 m_checkBoxShowName->SetValue(m_checkBoxShowNameExt->GetValue());
1035void MarkInfoDlg::OnWptRangeRingsNoChange(wxCommandEvent& event) {
1037 m_textWaypointRangeRingsStep->Enable(
1038 (
bool)(m_ChoiceWaypointRangeRingsNumber->GetSelection() != 0));
1039 m_PickColor->Enable(
1040 (
bool)(m_ChoiceWaypointRangeRingsNumber->GetSelection() != 0));
1044void MarkInfoDlg::OnSelectScaMinExt(wxCommandEvent& event) {
1046 m_textScaMin->Enable(m_checkBoxScaMin->GetValue());
1047 m_textScaMax->Enable(m_checkBoxScaMin->GetValue());
1051void MarkInfoDlg::OnPositionCtlUpdated(wxCommandEvent& event) {
1053 double lat = fromDMM(m_textLatitude->GetValue());
1054 double lon = fromDMM(m_textLongitude->GetValue());
1056 m_pRoutePoint->SetPosition(lat, lon);
1057 pSelect->ModifySelectablePoint(lat, lon, (
void*)m_pRoutePoint,
1058 SELTYPE_ROUTEPOINT);
1061 top_frame::Get()->RefreshAllCanvas();
1064void MarkInfoDlg::m_htmlListContextMenu(wxMouseEvent& event) {
1068 wxPoint pos =
event.GetPosition();
1069 i_htmlList_item = -1;
1070 for (
int i = 0; i < (int)GetSimpleBox()->GetCount(); i++) {
1071 wxRect rect = GetSimpleBox()->GetItemRect(i);
1072 if (rect.Contains(pos)) {
1073 i_htmlList_item = i;
1078 wxMenu* popup =
new wxMenu();
1079 if ((GetSimpleBox()->GetCount()) > 0 && (i_htmlList_item > -1) &&
1080 (i_htmlList_item < (
int)GetSimpleBox()->GetCount())) {
1081 popup->Append(ID_RCLK_MENU_DELETE_LINK, _(
"Delete"));
1082 popup->Append(ID_RCLK_MENU_EDIT_LINK, _(
"Edit"));
1084 popup->Append(ID_RCLK_MENU_ADD_LINK, _(
"Add New"));
1086 m_contextObject =
event.GetEventObject();
1088 wxEVT_COMMAND_MENU_SELECTED,
1089 wxCommandEventHandler(MarkInfoDlg::On_html_link_popupmenu_Click), NULL,
1095 m_pEditedLink =
dynamic_cast<wxHyperlinkCtrl*
>(
event.GetEventObject());
1097 if (m_pEditedLink) {
1098 wxString url = m_pEditedLink->GetURL();
1099 wxString label = m_pEditedLink->GetLabel();
1100 i_htmlList_item = -1;
1103 for (
Hyperlink* link : *hyperlinklist) {
1104 if (link->DescrText == label) {
1105 i_htmlList_item = i;
1113 wxMenu* popup =
new wxMenu();
1115 wxMenuItem* menuItemDelete =
1116 new wxMenuItem(popup, ID_RCLK_MENU_DELETE_LINK, wxString(_(
"Delete")),
1119 menuItemDelete->SetFont(sFont);
1121 popup->Append(menuItemDelete);
1123 wxMenuItem* menuItemEdit =
1124 new wxMenuItem(popup, ID_RCLK_MENU_EDIT_LINK, wxString(_(
"Edit")),
"",
1127 menuItemEdit->SetFont(sFont);
1129 popup->Append(menuItemEdit);
1132 wxMenuItem* menuItemAdd =
1133 new wxMenuItem(popup, ID_RCLK_MENU_ADD_LINK, wxString(_(
"Add New")),
"",
1136 menuItemAdd->SetFont(sFont);
1138 popup->Append(menuItemAdd);
1140 m_contextObject =
event.GetEventObject();
1142 wxEVT_COMMAND_MENU_SELECTED,
1143 wxCommandEventHandler(MarkInfoDlg::On_html_link_popupmenu_Click), NULL,
1145 wxPoint p = m_scrolledWindowLinks->GetPosition();
1146 p.x += m_scrolledWindowLinks->GetSize().x / 2;
1147 PopupMenu(popup, p);
1170void MarkInfoDlg::OnAddLink(wxCommandEvent& event) {
1171 wxCommandEvent evt(wxEVT_COMMAND_MENU_SELECTED);
1172 evt.SetId(ID_RCLK_MENU_ADD_LINK);
1174 On_html_link_popupmenu_Click(evt);
1177void MarkInfoDlg::On_html_link_popupmenu_Click(wxCommandEvent& event) {
1178 switch (event.GetId()) {
1179 case ID_RCLK_MENU_DELETE_LINK: {
1185 case ID_RCLK_MENU_EDIT_LINK: {
1189 LinkPropDlg->m_textCtrlLinkDescription->SetValue(link->DescrText);
1190 LinkPropDlg->m_textCtrlLinkUrl->SetValue(link->Link);
1191 DimeControl(LinkPropDlg);
1192 LinkPropDlg->ShowWindowModalThenDo([
this, LinkPropDlg,
1193 link](
int retcode) {
1194 if (retcode == wxID_OK) {
1195 link->DescrText = LinkPropDlg->m_textCtrlLinkDescription->GetValue();
1197 link->Link = LinkPropDlg->m_textCtrlLinkUrl->GetValue();
1204 case ID_RCLK_MENU_ADD_LINK: {
1206 LinkPropDlg->m_textCtrlLinkDescription->SetValue(
"");
1207 LinkPropDlg->m_textCtrlLinkUrl->SetValue(
"");
1208 DimeControl(LinkPropDlg);
1209 LinkPropDlg->ShowWindowModalThenDo([
this, LinkPropDlg](
int retcode) {
1210 if (retcode == wxID_OK) {
1212 link->DescrText = LinkPropDlg->m_textCtrlLinkDescription->GetValue();
1213 link->Link = LinkPropDlg->m_textCtrlLinkUrl->GetValue();
1215 if (link->DescrText ==
"") {
1216 link->DescrText = link->Link;
1218 if (link->Link ==
"") {
1221 m_pRoutePoint->m_HyperlinkList->push_back(link);
1232void MarkInfoDlg::OnRightClickLatLon(wxCommandEvent& event) {
1233 wxMenu* popup =
new wxMenu();
1234 popup->Append(ID_RCLK_MENU_COPY, _(
"Copy"));
1235 popup->Append(ID_RCLK_MENU_COPY_LL, _(
"Copy lat/long"));
1236 popup->Append(ID_RCLK_MENU_PASTE, _(
"Paste"));
1237 popup->Append(ID_RCLK_MENU_PASTE_LL, _(
"Paste lat/long"));
1238 m_contextObject =
event.GetEventObject();
1239 popup->Connect(wxEVT_COMMAND_MENU_SELECTED,
1240 wxCommandEventHandler(MarkInfoDlg::OnCopyPasteLatLon), NULL,
1247void MarkInfoDlg::OnCopyPasteLatLon(wxCommandEvent& event) {
1249 double lat = fromDMM(m_textLatitude->GetValue());
1250 double lon = fromDMM(m_textLongitude->GetValue());
1254 switch (event.GetId()) {
1255 case ID_RCLK_MENU_PASTE: {
1256 if (wxTheClipboard->Open()) {
1257 wxTextDataObject data;
1258 wxTheClipboard->GetData(data);
1259 result = data.GetText();
1260 ((wxTextCtrl*)m_contextObject)->SetValue(result);
1261 wxTheClipboard->Close();
1265 case ID_RCLK_MENU_PASTE_LL: {
1266 if (wxTheClipboard->Open()) {
1267 wxTextDataObject data;
1268 wxTheClipboard->GetData(data);
1269 result = data.GetText();
1273 if (pparse.IsOk()) {
1274 m_textLatitude->SetValue(pparse.GetLatitudeString());
1275 m_textLongitude->SetValue(pparse.GetLongitudeString());
1277 wxTheClipboard->Close();
1281 case ID_RCLK_MENU_COPY: {
1282 result = ((wxTextCtrl*)m_contextObject)->GetValue();
1285 case ID_RCLK_MENU_COPY_LL: {
1286 result << toSDMM(1, lat,
true) <<
'\t';
1287 result << toSDMM(2, lon,
true);
1292 if (wxTheClipboard->Open()) {
1293 wxTextDataObject* data =
new wxTextDataObject;
1294 data->SetText(result);
1295 wxTheClipboard->SetData(data);
1296 wxTheClipboard->Close();
1300void MarkInfoDlg::DefautlBtnClicked(wxCommandEvent& event) {
1302 m_SaveDefaultDlg->Center();
1303 DimeControl(m_SaveDefaultDlg);
1304 int retcode = m_SaveDefaultDlg->ShowModal();
1307 if (retcode == wxID_OK) {
1309 if (m_SaveDefaultDlg->IconCB->GetValue()) {
1311 *pWayPointMan->GetIconKey(m_bcomboBoxIcon->GetSelection());
1313 if (m_SaveDefaultDlg->RangRingsCB->GetValue()) {
1314 g_iWaypointRangeRingsNumber =
1315 m_ChoiceWaypointRangeRingsNumber->GetSelection();
1316 if (m_textWaypointRangeRingsStep->GetValue().ToDouble(&value))
1320 if (m_SaveDefaultDlg->ArrivalRCB->GetValue())
1321 if (m_textArrivalRadius->GetValue().ToDouble(&value))
1323 if (m_SaveDefaultDlg->ScaleCB->GetValue()) {
1324 g_iWpt_ScaMin = wxAtoi(m_textScaMin->GetValue());
1325 g_iWpt_ScaMax = wxAtoi(m_textScaMax->GetValue());
1326 g_bUseWptScaMin = m_checkBoxScaMin->GetValue();
1328 if (m_SaveDefaultDlg->NameCB->GetValue()) {
1329 g_bShowWptName = m_checkBoxShowName->GetValue();
1332 m_SaveDefaultDlg = NULL;
1336void MarkInfoDlg::OnMarkInfoCancelClick(wxCommandEvent& event) {
1337 if (m_pRoutePoint) {
1338 m_pRoutePoint->SetVisible(m_bIsVisible_save);
1339 m_pRoutePoint->SetNameShown(m_bShowName_save);
1340 m_pRoutePoint->SetPosition(m_lat_save, m_lon_save);
1341 m_pRoutePoint->SetIconName(m_IconName_save);
1342 m_pRoutePoint->ReLoadIcon();
1343 m_pRoutePoint->SetName(m_Name_save);
1345 m_pRoutePoint->SetUseSca(m_bUseScaMin_save);
1346 m_pRoutePoint->SetScaMin(m_iScaminVal_save);
1347 m_pRoutePoint->SetScaMax(m_iScamaxVal_save);
1351 int NbrOfLinks = m_pMyLinkList->size();
1352 if (NbrOfLinks > 0) {
1353 for (
Hyperlink* link : *m_pMyLinkList) {
1355 h->DescrText = link->DescrText;
1356 h->Link = link->Link;
1357 h->LType = link->LType;
1364 m_lasttspos.Clear();
1367 top_frame::Get()->Raise();
1371 delete m_pMyLinkList;
1372 m_pMyLinkList = NULL;
1373 SetClientSize(m_defaultClientSize);
1376 androidEnableBackButton(
true);
1382void MarkInfoDlg::OnMarkInfoOKClick(wxCommandEvent& event) {
1383 if (m_pRoutePoint) {
1386 OnPositionCtlUpdated(event);
1391 top_frame::Get()->Raise();
1402 SetClientSize(m_defaultClientSize);
1405 androidEnableBackButton(
true);
1411bool MarkInfoDlg::UpdateProperties(
bool positionOnly) {
1412 if (m_pRoutePoint) {
1413 m_textLatitude->SetValue(::toSDMM(1, m_pRoutePoint->m_lat));
1414 m_textLongitude->SetValue(::toSDMM(2, m_pRoutePoint->m_lon));
1415 m_lat_save = m_pRoutePoint->m_lat;
1416 m_lon_save = m_pRoutePoint->m_lon;
1417 m_textName->SetValue(m_pRoutePoint->GetName());
1420 m_checkBoxShowName->SetValue(m_pRoutePoint->
m_bShowName);
1421 m_checkBoxShowNameExt->SetValue(m_pRoutePoint->
m_bShowName);
1422 m_checkBoxVisible->SetValue(m_pRoutePoint->
m_bIsVisible);
1423 m_checkBoxScaMin->SetValue(m_pRoutePoint->GetUseSca());
1424 m_textScaMin->SetValue(
1425 wxString::Format(
"%i", (
int)m_pRoutePoint->GetScaMin()));
1426 m_textScaMax->SetValue(
1427 wxString::Format(
"%i", (
int)m_pRoutePoint->GetScaMax()));
1428 m_textCtrlGuid->SetValue(m_pRoutePoint->
m_GUID);
1429 m_ChoiceWaypointRangeRingsNumber->SetSelection(
1430 m_pRoutePoint->GetWaypointRangeRingsNumber());
1433 toUsrDistance(m_pRoutePoint->GetWaypointRangeRingsStep(), -1));
1434 m_textWaypointRangeRingsStep->SetValue(buf);
1435 m_staticTextArrivalUnits->SetLabel(getUsrDistanceUnit());
1437 toUsrDistance(m_pRoutePoint->GetWaypointArrivalRadius(), -1));
1438 m_textArrivalRadius->SetValue(buf);
1440 int nUnits = m_pRoutePoint->GetWaypointRangeRingsStepUnits();
1441 m_RangeRingUnits->SetSelection(nUnits);
1444 m_PickColor->SetColour(col);
1447 if (m_name_validator) m_name_validator.reset();
1449 std::make_unique<RoutePointNameValidator>(m_pRoutePoint);
1450 m_textName->SetValidator(*m_name_validator);
1452 m_textName->Bind(wxEVT_KILL_FOCUS, &MarkInfoDlg::OnFocusEvent,
this);
1454 m_textName->SetValidator();
1456 m_textName->Unbind(wxEVT_KILL_FOCUS, &MarkInfoDlg::OnFocusEvent,
this);
1459 if (m_comboBoxTideStation->GetStringSelection() !=
1461 m_comboBoxTideStation->Clear();
1462 m_comboBoxTideStation->Append(
"");
1464 m_comboBoxTideStation->Append(m_pRoutePoint->
m_TideStation);
1465 m_comboBoxTideStation->SetSelection(1);
1469 m_staticTextPlSpeedUnits->SetLabel(getUsrSpeedUnit());
1477 bool isLastWaypoint =
false;
1480 wxArrayPtrVoid* pRouteArray =
1483 isLastWaypoint =
true;
1485 for (
unsigned int i = 0; i < pRouteArray->GetCount(); i++) {
1487 if (route->GetLastPoint()->
m_GUID != m_pRoutePoint->
m_GUID) {
1488 isLastWaypoint =
false;
1497 if (isLastWaypoint) {
1502 if (etd.IsValid()) {
1505 if (dtFormat ==
"Local Time") {
1509 }
else if (dtFormat ==
"UTC") {
1516 "MarkInfoDlg::UpdateProperties. Unexpected date/time format: %s",
1518 etd = wxInvalidDateTime;
1529 m_staticTextPlSpeed->Show(m_pRoutePoint->
m_bIsInRoute);
1535 m_staticTextPlSpeedUnits->Show(m_pRoutePoint->
m_bIsInRoute);
1536 m_staticTextArrivalRadius->Show(m_pRoutePoint->
m_bIsInRoute);
1537 m_staticTextArrivalUnits->Show(m_pRoutePoint->
m_bIsInRoute);
1538 m_textArrivalRadius->Show(m_pRoutePoint->
m_bIsInRoute);
1540 if (positionOnly)
return true;
1544 m_staticTextLayer->Enable();
1545 m_staticTextLayer->Show(
true);
1546 m_textName->SetEditable(
false);
1547 m_textDescription->SetEditable(
false);
1548 m_textCtrlExtDescription->SetEditable(
false);
1549 m_textLatitude->SetEditable(
false);
1550 m_textLongitude->SetEditable(
false);
1551 m_bcomboBoxIcon->Enable(
false);
1552 m_checkBoxShowName->Enable(
false);
1553 m_checkBoxVisible->Enable(
false);
1554 m_textArrivalRadius->SetEditable(
false);
1555 m_checkBoxScaMin->Enable(
false);
1556 m_textScaMin->SetEditable(
false);
1557 m_textScaMax->SetEditable(
false);
1558 m_checkBoxShowNameExt->Enable(
false);
1559 m_ChoiceWaypointRangeRingsNumber->Enable(
false);
1560 m_textWaypointRangeRingsStep->SetEditable(
false);
1561 m_PickColor->Enable(
false);
1562 DefaultsBtn->Enable(
false);
1566 m_notebookProperties->SetSelection(0);
1567 m_comboBoxTideStation->Enable(
false);
1569 m_staticTextLayer->Enable(
false);
1570 m_staticTextLayer->Show(
false);
1571 m_textName->SetEditable(
true);
1572 m_textDescription->SetEditable(
true);
1573 m_textCtrlExtDescription->SetEditable(
true);
1574 m_textLatitude->SetEditable(
true);
1575 m_textLongitude->SetEditable(
true);
1576 m_bcomboBoxIcon->Enable(
true);
1577 m_checkBoxShowName->Enable(
true);
1578 m_checkBoxVisible->Enable(
true);
1579 m_textArrivalRadius->SetEditable(
true);
1580 m_checkBoxScaMin->Enable(
true);
1581 m_textScaMin->SetEditable(
true);
1582 m_textScaMax->SetEditable(
true);
1583 m_checkBoxShowNameExt->Enable(
true);
1584 m_ChoiceWaypointRangeRingsNumber->Enable(
true);
1585 m_textWaypointRangeRingsStep->SetEditable(
true);
1586 m_PickColor->Enable(
true);
1587 DefaultsBtn->Enable(
true);
1588 m_notebookProperties->SetSelection(0);
1589 m_comboBoxTideStation->Enable(
true);
1599 m_bcomboBoxIcon->Clear();
1601 bool fillCombo = m_bcomboBoxIcon->GetCount() == 0;
1604 for (
int i = 0; i < pWayPointMan->GetNumIcons(); i++) {
1605 wxString* ps = pWayPointMan->GetIconDescription(i);
1607 pWayPointMan->GetIconBitmapForList(i, 2 * GetCharHeight());
1609 m_bcomboBoxIcon->Append(*ps, bmp);
1613 int iconToSelect = -1;
1614 for (
int i = 0; i < pWayPointMan->GetNumIcons(); i++) {
1615 if (*pWayPointMan->GetIconKey(i) == m_pRoutePoint->GetIconName()) {
1617 m_bcomboBoxIcon->Select(iconToSelect);
1622 OnShowWaypointNameSelectBasic(ev);
1623 OnWptRangeRingsNoChange(ev);
1624 OnSelectScaMinExt(ev);
1629 androidEnableBackButton(
false);
1640void MarkInfoDlg::OnFocusEvent(wxFocusEvent& event) {
1641 bool is_valid = Validate();
1642 m_buttonOkay->Enable(is_valid);
1646void MarkInfoDlg::OnBitmapCombClick(wxCommandEvent& event) {
1647 wxString* icon_name =
1648 pWayPointMan->GetIconKey(m_bcomboBoxIcon->GetSelection());
1649 if (icon_name && icon_name->Length()) m_pRoutePoint->SetIconName(*icon_name);
1650 m_pRoutePoint->ReLoadIcon();
1655void MarkInfoDlg::ValidateMark() {
1658 bool b_found =
false;
1659 for (
RoutePoint* rp : *pWayPointMan->GetWaypointList()) {
1660 if (m_pRoutePoint == rp) {
1665 if (!b_found) m_pRoutePoint = NULL;
1668bool MarkInfoDlg::SaveChanges() {
1669 if (m_pRoutePoint) {
1671 if (!this->Validate())
return false;
1674 m_pRoutePoint->SetName(m_textName->GetValue());
1675 m_pRoutePoint->SetWaypointArrivalRadius(m_textArrivalRadius->GetValue());
1676 m_pRoutePoint->SetScaMin(m_textScaMin->GetValue());
1677 m_pRoutePoint->SetScaMax(m_textScaMax->GetValue());
1678 m_pRoutePoint->SetUseSca(m_checkBoxScaMin->GetValue());
1680 m_pRoutePoint->SetVisible(m_checkBoxVisible->GetValue());
1681 m_pRoutePoint->
m_bShowName = m_checkBoxShowName->GetValue();
1682 m_pRoutePoint->SetPosition(fromDMM(m_textLatitude->GetValue()),
1683 fromDMM(m_textLongitude->GetValue()));
1684 wxString* icon_name =
1685 pWayPointMan->GetIconKey(m_bcomboBoxIcon->GetSelection());
1686 if (icon_name && icon_name->Length())
1687 m_pRoutePoint->SetIconName(*icon_name);
1688 m_pRoutePoint->ReLoadIcon();
1689 m_pRoutePoint->SetShowWaypointRangeRings(
1690 (
bool)(m_ChoiceWaypointRangeRingsNumber->GetSelection() != 0));
1691 m_pRoutePoint->SetWaypointRangeRingsNumber(
1692 m_ChoiceWaypointRangeRingsNumber->GetSelection());
1694 if (m_textWaypointRangeRingsStep->GetValue().ToDouble(&value))
1696 if (m_textArrivalRadius->GetValue().ToDouble(&value))
1699 if (m_RangeRingUnits->GetSelection() != wxNOT_FOUND)
1700 m_pRoutePoint->SetWaypointRangeRingsStepUnits(
1701 m_RangeRingUnits->GetSelection());
1703 m_pRoutePoint->
m_TideStation = m_comboBoxTideStation->GetStringSelection();
1705 m_pRoutePoint->SetPlannedSpeed(0.0);
1709 m_pRoutePoint->SetPlannedSpeed(fromUsrSpeed(spd));
1716 int hour = t.GetHour();
1726 if (dtFormat ==
"Local Time") {
1727 m_pRoutePoint->
SetETD(dt.MakeUTC());
1728 }
else if (dtFormat ==
"UTC") {
1729 m_pRoutePoint->
SetETD(dt);
1738 "Failed to configured ETD. Unsupported date/time format: %s",
1740 m_pRoutePoint->
SetETD(wxInvalidDateTime);
1744 m_pRoutePoint->
SetETD(wxInvalidDateTime);
1749 pSelect->UpdateSelectableRouteSegments(m_pRoutePoint);
1752 wxArrayPtrVoid* pEditRouteArray =
1755 if (pEditRouteArray) {
1756 for (
unsigned int ir = 0; ir < pEditRouteArray->GetCount(); ir++) {
1757 Route* pr = (
Route*)pEditRouteArray->Item(ir);
1758 pr->FinalizeForRendering();
1759 pr->UpdateSegmentDistances();
1762 NavObj_dB::GetInstance().UpdateRoute(pr);
1764 delete pEditRouteArray;
1768 NavObj_dB::GetInstance().UpdateRoutePoint(m_pRoutePoint);
1774SaveDefaultsDialog::SaveDefaultsDialog(
MarkInfoDlg* parent)
1775 : wxDialog(parent, wxID_ANY, _(
"Save some defaults")) {
1777 this->SetSizeHints(wxDefaultSize, wxDefaultSize);
1779 wxBoxSizer* bSizer1 =
new wxBoxSizer(wxVERTICAL);
1780 wxStdDialogButtonSizer* StdDialogButtonSizer1;
1783 new wxStaticText(
this, wxID_ANY,
1784 _(
"Check which properties of current waypoint\n should "
1785 "be set as default for NEW waypoints."));
1786 bSizer1->Add(StaticText1, 0, wxALL | wxALIGN_CENTER_HORIZONTAL, 5);
1788 wxFlexGridSizer* fgSizer1 =
new wxFlexGridSizer(2);
1794 new wxCheckBox(
this, wxID_ANY, _(
"Show Waypoint Name"), wxDefaultPosition,
1795 wxDefaultSize, 0, wxDefaultValidator);
1796 fgSizer1->Add(NameCB, 0, wxALL, 5);
1797 stName =
new wxStaticText(
this, wxID_ANY,
"[" + s +
"]", wxDefaultPosition,
1800 fgSizer1->Add(stName, 0, wxALL | wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL, 5);
1803 IconCB =
new wxCheckBox(
this, wxID_ANY, _(
"Icon"));
1804 fgSizer1->Add(IconCB, 0, wxALL, 5);
1805 stIcon =
new wxStaticText(
this, wxID_ANY,
"[" + s +
"]", wxDefaultPosition,
1808 fgSizer1->Add(stIcon, 0, wxALL | wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL, 5);
1817 RangRingsCB =
new wxCheckBox(
this, wxID_ANY, _(
"Range rings"));
1818 fgSizer1->Add(RangRingsCB, 0, wxALL, 5);
1819 stRR =
new wxStaticText(
this, wxID_ANY,
"[" + s +
"]", wxDefaultPosition,
1822 fgSizer1->Add(stRR, 0, wxALL | wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL, 5);
1825 ArrivalRCB =
new wxCheckBox(
this, wxID_ANY, _(
"Arrival radius"));
1826 fgSizer1->Add(ArrivalRCB, 0, wxALL, 5);
1827 stArrivalR =
new wxStaticText(
1829 wxString::Format(
"[%s %s]", s.c_str(), getUsrDistanceUnit().c_str()),
1830 wxDefaultPosition, wxDefaultSize, 0);
1831 stArrivalR->Wrap(-1);
1832 fgSizer1->Add(stArrivalR, 0, wxALL | wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL,
1836 s = _(
"Show only at scales between ");
1841 s = _(
"Show always");
1843 ScaleCB =
new wxCheckBox(
this, wxID_ANY, _(
"Show only at scale"));
1844 fgSizer1->Add(ScaleCB, 0, wxALL, 5);
1845 stScale =
new wxStaticText(
this, wxID_ANY,
"[" + s +
"]", wxDefaultPosition,
1848 fgSizer1->Add(stScale, 0, wxALL | wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL, 5);
1850 bSizer1->Add(fgSizer1, 0, wxALL | wxEXPAND, 5);
1852 StdDialogButtonSizer1 =
new wxStdDialogButtonSizer();
1853 StdDialogButtonSizer1->AddButton(
new wxButton(
this, wxID_OK));
1854 StdDialogButtonSizer1->AddButton(
1855 new wxButton(
this, wxID_CANCEL, _(
"Cancel")));
1856 StdDialogButtonSizer1->Realize();
1857 bSizer1->Add(StdDialogButtonSizer1, 0, wxALL | wxEXPAND, 5);
1864 SetSize(parent->GetSize());
1870void MarkInfoDlg::ShowTidesBtnClicked(wxCommandEvent& event) {
1871 if (m_comboBoxTideStation->GetSelection() < 1) {
1875 ptcmgr->GetStationIDXbyName(m_comboBoxTideStation->GetStringSelection(),
1876 fromDMM(m_textLatitude->GetValue()),
1877 fromDMM(m_textLongitude->GetValue())));
1880 new TCWin(top_frame::Get()->GetAbstractPrimaryCanvas(), 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.
RouteManagerDialog * pRouteManagerDialog
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.