34#include <wx/datetime.h>
35#include <wx/clipbrd.h>
37#include <wx/printdlg.h>
38#include <wx/stattext.h>
39#include <wx/clrpicker.h>
40#include <wx/bmpbuttn.h>
45#include "model/georef.h"
46#include "model/navutil_base.h"
47#include "model/own_ship.h"
48#include "model/position_parser.h"
49#include "model/route.h"
50#include "model/routeman.h"
51#include "model/select.h"
53#include "ocpn_frame.h"
54#include "OCPNPlatform.h"
56#include "routemanagerdialog.h"
57#include "RoutePropDlgImpl.h"
65#include "androidUTIL.h"
66#include <QtWidgets/QScroller>
80extern wxString g_default_wp_icon;
86extern float g_MarkScaleFactorExp;
90#include <wx/arrimpl.cpp>
91WX_DEFINE_OBJARRAY(ArrayOfBitmaps);
93#define EXTENDED_PROP_PAGE 2
95OCPNIconCombo::OCPNIconCombo(wxWindow* parent, wxWindowID
id,
96 const wxString& value,
const wxPoint& pos,
97 const wxSize& size,
int n,
98 const wxString choices[],
long style,
99 const wxValidator& validator,
const wxString& name)
100 : wxOwnerDrawnComboBox(parent, id, value, pos, size, n, choices, style,
103 GetFont().GetPointSize() / g_Platform->getFontPointsperPixel();
104 itemHeight = (int)wxRound(fontHeight);
107OCPNIconCombo::~OCPNIconCombo() {}
109void OCPNIconCombo::OnDrawItem(wxDC& dc,
const wxRect& rect,
int item,
111 int offset_x = bmpArray[item].GetWidth();
112 int bmpHeight = bmpArray[item].GetHeight();
113 dc.DrawBitmap(bmpArray[item], rect.x, rect.y + (rect.height - bmpHeight) / 2,
116 if (flags & wxODCB_PAINTING_CONTROL) {
117 wxString text = GetValue();
120#if wxCHECK_VERSION(2, 9, 0)
121 if (ShouldUseHintText()) {
123 wxColour col = wxSystemSettings::GetColour(wxSYS_COLOUR_GRAYTEXT);
124 dc.SetTextForeground(col);
127 margin_x = GetMargins().x;
130 dc.DrawText(text, rect.x + margin_x + offset_x,
131 (rect.height - dc.GetCharHeight()) / 2 + rect.y);
133 dc.DrawText(GetVListBoxComboPopup()->GetString(item), rect.x + 2 + offset_x,
134 (rect.height - dc.GetCharHeight()) / 2 + rect.y);
138wxCoord OCPNIconCombo::OnMeasureItem(
size_t item)
const {
139 int bmpHeight = bmpArray[item].GetHeight();
141 return wxMax(itemHeight, bmpHeight);
144wxCoord OCPNIconCombo::OnMeasureItemWidth(
size_t item)
const {
return -1; }
146int OCPNIconCombo::Append(
const wxString& item, wxBitmap bmp) {
148 int idx = wxOwnerDrawnComboBox::Append(item);
153void OCPNIconCombo::Clear(
void) {
154 wxOwnerDrawnComboBox::Clear();
168const wxEventType EVT_LLCHANGE = wxNewEventType();
177 const wxString& value, const wxPoint& pos,
178 const wxSize& size,
long style,
179 const wxValidator& validator,
180 const wxString& name)
181 : wxTextCtrl(parent,
id, value, pos, size, style, validator, name) {
182 m_pParentEventHandler = parent->GetEventHandler();
185void LatLonTextCtrl::OnKillFocus(wxFocusEvent& event) {
187 wxCommandEvent up_event(EVT_LLCHANGE, GetId());
188 up_event.SetEventObject((wxObject*)
this);
189 m_pParentEventHandler->AddPendingEvent(up_event);
198EVT_BUTTON(wxID_OK, MarkInfoDlg::OnMarkInfoOKClick)
199EVT_BUTTON(wxID_CANCEL, MarkInfoDlg::OnMarkInfoCancelClick)
200EVT_BUTTON(ID_BTN_DESC_BASIC, MarkInfoDlg::OnExtDescriptionClick)
201EVT_BUTTON(ID_DEFAULT, MarkInfoDlg::DefautlBtnClicked)
202EVT_BUTTON(ID_BTN_SHOW_TIDES, MarkInfoDlg::ShowTidesBtnClicked)
203EVT_COMBOBOX(ID_BITMAPCOMBOCTRL, MarkInfoDlg::OnBitmapCombClick)
204EVT_CHECKBOX(ID_CHECKBOX_SCAMIN_VIS, MarkInfoDlg::OnSelectScaMinExt)
205EVT_TEXT(ID_DESCR_CTR_DESC, MarkInfoDlg::OnDescChangedExt)
206EVT_TEXT(ID_DESCR_CTR_BASIC, MarkInfoDlg::OnDescChangedBasic)
207EVT_TEXT(ID_LATCTRL, MarkInfoDlg::OnPositionCtlUpdated)
208EVT_TEXT(ID_LONCTRL, MarkInfoDlg::OnPositionCtlUpdated)
209EVT_CHOICE(ID_WPT_RANGERINGS_NO, MarkInfoDlg::OnWptRangeRingsNoChange)
211EVT_HTML_LINK_CLICKED(wxID_ANY, MarkInfoDlg::OnHtmlLinkClicked)
212EVT_COMMAND(wxID_ANY, EVT_LAYOUT_RESIZE, MarkInfoDlg::OnLayoutResize)
213EVT_CLOSE(MarkInfoDlg::OnClose)
219 const wxPoint& pos, const wxSize& size,
long style) {
220 DIALOG_PARENT::Create(parent,
id, title, pos, size, style);
224 int metric = GetCharHeight();
228 wxString wqs = getFontQtStylesheet(qFont);
229 wxCharBuffer sbuf = wqs.ToUTF8();
230 QString qsb = QString(sbuf.data());
231 QString qsbq = getQtStyleSheet();
232 this->GetHandle()->setStyleSheet(qsb + qsbq);
234 if (sdc.IsOk()) sdc.GetTextExtent(
"W", NULL, &metric, NULL, NULL, qFont);
237 m_pMyLinkList = NULL;
238 SetColorScheme((ColorScheme)0);
239 m_pRoutePoint = NULL;
240 m_SaveDefaultDlg = NULL;
244 Connect(wxEVT_ACTIVATE, wxActivateEventHandler(MarkInfoDlg::OnActivate), NULL,
249void MarkInfoDlg::OnActivate(wxActivateEvent& event) {
250 auto pWin =
dynamic_cast<DIALOG_PARENT*
>(
event.GetEventObject());
251 long int style = pWin->GetWindowStyle();
252 if (event.GetActive())
253 pWin->SetWindowStyle(style | wxSTAY_ON_TOP);
255 pWin->SetWindowStyle(style ^ wxSTAY_ON_TOP);
258void MarkInfoDlg::initialize_images(
void) {
259 wxString iconDir = g_Platform->GetSharedDataDir() +
"uidata/MUI_flat/";
260 _img_MUI_settings_svg = LoadSVG(iconDir +
"MUI_settings.svg",
261 2 * GetCharHeight(), 2 * GetCharHeight());
264 wxBitmap tide = style->GetIcon(
"tidesml");
265 wxImage tide1 = tide.ConvertToImage();
266 wxImage tide1s = tide1.Scale(m_sizeMetric * 3 / 2, m_sizeMetric * 3 / 2,
267 wxIMAGE_QUALITY_HIGH);
268 m_bmTide = wxBitmap(tide1s);
273void MarkInfoDlg::Create() {
276 m_sizeMetric = GetCharHeight();
281 wxString wqs = getFontQtStylesheet(qFont);
282 wxCharBuffer sbuf = wqs.ToUTF8();
283 QString qsb = QString(sbuf.data());
285 QString qsbq = getAdjustedDialogStyleSheet();
287 this->GetHandle()->setStyleSheet(qsb + qsbq);
291 sdc.GetTextExtent(
"W", NULL, &m_sizeMetric, NULL, NULL, qFont);
298 bSizer1 =
new wxBoxSizer(wxVERTICAL);
300 bSizer1->SetSizeHints(
this);
303 m_notebookProperties =
new wxNotebook(
this, wxID_ANY, wxDefaultPosition,
304 wxDefaultSize, wxNB_FIXEDWIDTH);
306 m_panelBasicProperties =
new wxScrolledWindow(
307 m_notebookProperties, wxID_ANY, wxDefaultPosition, wxDefaultSize,
308 wxHSCROLL | wxVSCROLL | wxTAB_TRAVERSAL);
310 m_panelBasicProperties->GetHandle()->setStyleSheet(
311 getAdjustedDialogStyleSheet());
315 m_panelBasicProperties->SetScrollRate(0, 2);
316 m_notebookProperties->AddPage(m_panelBasicProperties, _(
"Basic"),
true);
317 bSizerBasicProperties =
new wxBoxSizer(wxVERTICAL);
318 m_panelBasicProperties->SetSizer(bSizerBasicProperties);
321 m_staticTextLayer =
new wxStaticText(
322 m_panelBasicProperties, wxID_ANY,
323 _(
"This waypoint is part of a layer and can't be edited"),
324 wxDefaultPosition, wxDefaultSize, 0);
325 m_staticTextLayer->Enable(
false);
326 bSizerBasicProperties->Add(m_staticTextLayer, 0, wxALL, 5);
329 wxPanel* props_panel =
new wxPanel(m_panelBasicProperties);
331 props_panel->SetSizer(props_sizer);
332 bSizerBasicProperties->Add(props_panel, 0, wxALL | wxEXPAND, 16);
333 int label_size = m_sizeMetric * 4;
336 m_textName =
new TextField(props_panel, _(
"Name"));
339 wxStaticText* name_cb_label =
340 new wxStaticText(props_panel, wxID_ANY, _(
"Show waypoint name"));
342 new wxCheckBox(props_panel, wxID_ANY, wxEmptyString, wxDefaultPosition,
343 wxDefaultSize, wxALIGN_CENTER_VERTICAL);
344 m_checkBoxShowName->Bind(wxEVT_CHECKBOX,
345 &MarkInfoDlg::OnShowWaypointNameSelectBasic,
this);
346 props_sizer->Add(name_cb_label, 0, wxALIGN_TOP);
347 props_sizer->Add(m_checkBoxShowName, 0, wxEXPAND);
350 int icon_size = m_sizeMetric * 2;
351 icon_size = wxMax(icon_size, (32 * g_MarkScaleFactorExp) + 4);
353 new OCPNIconCombo(props_panel, wxID_ANY, _(
"Combo!"), wxDefaultPosition,
354 wxDefaultSize, 0, NULL, wxCB_READONLY);
355 m_bcomboBoxIcon->SetPopupMaxHeight(::wxGetDisplaySize().y / 2);
356 m_bcomboBoxIcon->SetMinSize(wxSize(-1, icon_size));
358 wxStaticText* icon_label =
new wxStaticText(props_panel, wxID_ANY, _(
"Icon"));
359 icon_label->SetMinSize(wxSize(label_size, -1));
360 props_sizer->Add(icon_label, 0, wxALIGN_CENTER_VERTICAL);
361 props_sizer->Add(m_bcomboBoxIcon, 0, wxEXPAND);
364 m_textLatitude =
new TextField(props_panel, _(
"Latitude"));
365 m_textLongitude =
new TextField(props_panel, _(
"Longitude"));
366 props_sizer->Fit(props_panel);
369 wxStaticBox* desc_box =
370 new wxStaticBox(m_panelBasicProperties, wxID_ANY, _(
"Description"));
371 wxStaticBoxSizer* desc_sizer =
new wxStaticBoxSizer(desc_box, wxHORIZONTAL);
372 bSizerBasicProperties->Add(desc_sizer, 1, wxALL | wxEXPAND, 8);
373 m_textDescription =
new wxTextCtrl(
374 m_panelBasicProperties, ID_DESCR_CTR_BASIC, wxEmptyString,
375 wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE | wxTE_READONLY);
376 m_textDescription->SetMinSize(wxSize(-1, 80));
377 desc_sizer->Add(m_textDescription, 1, wxEXPAND);
380 m_buttonExtDescription =
381 new wxButton(m_panelBasicProperties, ID_BTN_DESC_BASIC,
"...",
382 wxDefaultPosition, wxSize(GetCharHeight() * 15 / 10, -1), 0);
383 desc_sizer->Add(m_buttonExtDescription, 0, wxEXPAND);
386 wxStaticBox* links_box =
387 new wxStaticBox(m_panelBasicProperties, wxID_ANY, _(
"Links"));
388 wxStaticBoxSizer* links_sizer =
new wxStaticBoxSizer(links_box, wxHORIZONTAL);
389 bSizerBasicProperties->Add(links_sizer, 1, wxALL | wxEXPAND, 8);
392 m_htmlList =
new wxSimpleHtmlListBox(m_panelBasicProperties, wxID_ANY,
393 wxDefaultPosition, wxDefaultSize, 0);
394 links_sizer->Add(m_htmlList, 1, wxEXPAND);
397 m_scrolledWindowLinks =
398 new wxScrolledWindow(m_panelBasicProperties, wxID_ANY, wxDefaultPosition,
399 wxSize(-1, 100), wxHSCROLL | wxVSCROLL);
400 m_scrolledWindowLinks->SetMinSize(wxSize(-1, 80));
401 m_scrolledWindowLinks->SetScrollRate(2, 2);
402 links_sizer->Add(m_scrolledWindowLinks, 1, wxEXPAND);
404 bSizerLinks =
new wxBoxSizer(wxVERTICAL);
405 m_scrolledWindowLinks->SetSizer(bSizerLinks);
407 m_menuLink =
new wxMenu();
408 wxMenuItem* m_menuItemDelete;
409 m_menuItemDelete =
new wxMenuItem(m_menuLink, wxID_ANY, wxString(_(
"Delete")),
410 wxEmptyString, wxITEM_NORMAL);
411 m_menuLink->Append(m_menuItemDelete);
413 wxMenuItem* m_menuItemEdit;
414 m_menuItemEdit =
new wxMenuItem(m_menuLink, wxID_ANY, wxString(_(
"Edit")),
415 wxEmptyString, wxITEM_NORMAL);
416 m_menuLink->Append(m_menuItemEdit);
418 wxMenuItem* m_menuItemAdd;
419 m_menuItemAdd =
new wxMenuItem(m_menuLink, wxID_ANY, wxString(_(
"Add new")),
420 wxEmptyString, wxITEM_NORMAL);
421 m_menuLink->Append(m_menuItemAdd);
423 wxBoxSizer* bSizer9 =
new wxBoxSizer(wxHORIZONTAL);
426 new wxButton(m_panelBasicProperties, wxID_ANY, _(
"Add new"),
427 wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT);
428 bSizer9->Add(m_buttonAddLink, 0, wxALL, 5);
430 m_buttonAddLink->Connect(wxEVT_COMMAND_BUTTON_CLICKED,
431 wxCommandEventHandler(MarkInfoDlg::OnAddLink), NULL,
434 links_sizer->Add(bSizer9, 0, wxEXPAND, 5);
439 new wxPanel(m_notebookProperties, wxID_ANY, wxDefaultPosition,
440 wxDefaultSize, wxTAB_TRAVERSAL);
441 wxBoxSizer* bSizer15;
442 bSizer15 =
new wxBoxSizer(wxVERTICAL);
444 m_textCtrlExtDescription =
445 new wxTextCtrl(m_panelDescription, ID_DESCR_CTR_DESC, wxEmptyString,
446 wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE);
447 bSizer15->Add(m_textCtrlExtDescription, 1, wxALL | wxEXPAND, 5);
449 m_panelDescription->SetSizer(bSizer15);
450 m_notebookProperties->AddPage(m_panelDescription, _(
"Description"),
false);
455 m_panelExtendedProperties =
new wxScrolledWindow(
456 m_notebookProperties, wxID_ANY, wxDefaultPosition, wxDefaultSize,
457 wxHSCROLL | wxVSCROLL | wxTAB_TRAVERSAL);
459 m_panelExtendedProperties->GetHandle()->setStyleSheet(
460 getAdjustedDialogStyleSheet());
463 m_panelExtendedProperties->SetScrollRate(0, 2);
465 wxBoxSizer* fSizerExtProperties =
new wxBoxSizer(wxVERTICAL);
466 m_panelExtendedProperties->SetSizer(fSizerExtProperties);
467 m_notebookProperties->AddPage(m_panelExtendedProperties, _(
"Extended"),
470 sbSizerExtProperties =
new wxStaticBoxSizer(
471 wxVERTICAL, m_panelExtendedProperties, _(
"Extended Properties"));
472 wxFlexGridSizer* gbSizerInnerExtProperties =
new wxFlexGridSizer(3, 0, 0);
473 gbSizerInnerExtProperties->AddGrowableCol(2);
474 gbSizerInnerExtProperties->SetFlexibleDirection(wxBOTH);
475 gbSizerInnerExtProperties->SetNonFlexibleGrowMode(wxFLEX_GROWMODE_SPECIFIED);
477 m_checkBoxVisible =
new wxCheckBox(sbSizerExtProperties->GetStaticBox(),
478 ID_CHECKBOX_VIS_EXT, wxEmptyString);
479 gbSizerInnerExtProperties->Add(m_checkBoxVisible);
480 wxStaticText* m_staticTextVisible =
new wxStaticText(
481 sbSizerExtProperties->GetStaticBox(), wxID_ANY, _(
"Show on chart"));
482 gbSizerInnerExtProperties->Add(m_staticTextVisible);
483 gbSizerInnerExtProperties->Add(0, 0, 1, wxEXPAND, 0);
485 m_checkBoxScaMin =
new wxCheckBox(sbSizerExtProperties->GetStaticBox(),
486 ID_CHECKBOX_SCAMIN_VIS, wxEmptyString);
487 gbSizerInnerExtProperties->Add(m_checkBoxScaMin, 0, wxALIGN_CENTRE_VERTICAL,
489 m_staticTextScaMin =
new wxStaticText(sbSizerExtProperties->GetStaticBox(),
490 wxID_ANY, _(
"Show at scale > 1 :"));
491 gbSizerInnerExtProperties->Add(m_staticTextScaMin, 0, wxALIGN_CENTRE_VERTICAL,
493 m_textScaMin =
new wxTextCtrl(sbSizerExtProperties->GetStaticBox(), wxID_ANY);
494 gbSizerInnerExtProperties->Add(m_textScaMin, 0, wxALL | wxEXPAND, 5);
496 m_checkBoxShowNameExt =
new wxCheckBox(sbSizerExtProperties->GetStaticBox(),
497 wxID_ANY, wxEmptyString);
498 m_checkBoxShowNameExt->Bind(wxEVT_CHECKBOX,
499 &MarkInfoDlg::OnShowWaypointNameSelectExt,
this);
500 gbSizerInnerExtProperties->Add(m_checkBoxShowNameExt);
501 m_staticTextShowNameExt =
new wxStaticText(
502 sbSizerExtProperties->GetStaticBox(), wxID_ANY, _(
"Show waypoint name"));
504 gbSizerInnerExtProperties->Add(m_staticTextShowNameExt);
505 gbSizerInnerExtProperties->Add(0, 0, 1, wxEXPAND, 0);
507 sbRangeRingsExtProperties =
new wxStaticBoxSizer(
508 wxVERTICAL, sbSizerExtProperties->GetStaticBox(), _(
"Range rings"));
509 wxFlexGridSizer* gbRRExtProperties =
new wxFlexGridSizer(4, 0, 0);
510 gbRRExtProperties->AddGrowableCol(0);
511 gbRRExtProperties->AddGrowableCol(1);
512 gbRRExtProperties->AddGrowableCol(3);
513 m_staticTextRR1 =
new wxStaticText(sbSizerExtProperties->GetStaticBox(),
514 wxID_ANY, _(
"Number"));
515 gbRRExtProperties->Add(m_staticTextRR1, 0, wxLEFT, 5);
516 m_staticTextRR2 =
new wxStaticText(sbSizerExtProperties->GetStaticBox(),
517 wxID_ANY, _(
"Distance"));
518 gbRRExtProperties->Add(m_staticTextRR2, 0, wxLEFT, 5);
519 gbRRExtProperties->Add(0, 0, 1, wxEXPAND, 5);
520 m_staticTextRR4 =
new wxStaticText(sbSizerExtProperties->GetStaticBox(),
521 wxID_ANY, _(
"Color"));
522 gbRRExtProperties->Add(m_staticTextRR4, 0, wxLEFT, 5);
524 wxString rrAlt[] = {_(
"None"), _T(
"1" ), _T(
"2" ), _T(
"3" ),
525 _T(
"4" ), _T(
"5" ), _T(
"6" ), _T(
"7" ),
526 _T(
"8" ), _T(
"9" ), _T(
"10" )};
527 m_ChoiceWaypointRangeRingsNumber =
528 new wxChoice(sbSizerExtProperties->GetStaticBox(), ID_WPT_RANGERINGS_NO,
529 wxDefaultPosition, wxDefaultSize, 11, rrAlt);
531 gbRRExtProperties->Add(m_ChoiceWaypointRangeRingsNumber, 0, wxALL | wxEXPAND,
533 m_textWaypointRangeRingsStep =
534 new wxTextCtrl(sbSizerExtProperties->GetStaticBox(), wxID_ANY, _(
"0.05"),
535 wxDefaultPosition, wxDefaultSize, 0);
536 gbRRExtProperties->Add(m_textWaypointRangeRingsStep, 0, wxALL | wxEXPAND, 5);
538 wxString pDistUnitsStrings[] = {_(
"NMi"), _(
"km")};
540 new wxChoice(sbSizerExtProperties->GetStaticBox(), wxID_ANY,
541 wxDefaultPosition, wxDefaultSize, 2, pDistUnitsStrings);
542 gbRRExtProperties->Add(m_RangeRingUnits, 0, wxALIGN_CENTRE_VERTICAL, 0);
544 m_PickColor =
new wxColourPickerCtrl(sbSizerExtProperties->GetStaticBox(),
545 wxID_ANY, wxColour(0, 0, 0),
546 wxDefaultPosition, wxDefaultSize, 0);
547 gbRRExtProperties->Add(m_PickColor, 0, wxALL | wxEXPAND, 5);
548 sbRangeRingsExtProperties->Add(
549 gbRRExtProperties, 1,
550 wxLEFT | wxTOP | wxEXPAND | wxALIGN_LEFT | wxALIGN_TOP, 5);
552 sbSizerExtProperties->GetStaticBox()->Layout();
554 wxFlexGridSizer* gbSizerInnerExtProperties2 =
new wxFlexGridSizer(2, 0, 0);
555 gbSizerInnerExtProperties2->AddGrowableCol(1);
558 new wxStaticText(sbSizerExtProperties->GetStaticBox(), wxID_ANY,
559 _(
"GUID"), wxDefaultPosition, wxDefaultSize, 0);
560 gbSizerInnerExtProperties2->Add(m_staticTextGuid, 0, wxALIGN_CENTRE_VERTICAL,
562 m_textCtrlGuid =
new wxTextCtrl(sbSizerExtProperties->GetStaticBox(),
563 wxID_ANY, wxEmptyString, wxDefaultPosition,
564 wxDefaultSize, wxTE_READONLY);
565 m_textCtrlGuid->SetEditable(
false);
566 gbSizerInnerExtProperties2->Add(m_textCtrlGuid, 0, wxALL | wxEXPAND, 5);
568 wxFlexGridSizer* gbSizerInnerExtProperties1 =
new wxFlexGridSizer(3, 0, 0);
569 gbSizerInnerExtProperties1->AddGrowableCol(1);
571 m_staticTextTideStation =
572 new wxStaticText(sbSizerExtProperties->GetStaticBox(), wxID_ANY,
573 _(
"Tide Station"), wxDefaultPosition, wxDefaultSize, 0);
574 gbSizerInnerExtProperties1->Add(m_staticTextTideStation, 0,
575 wxALIGN_CENTRE_VERTICAL, 5);
578 m_choiceTideChoices.Add(
" ");
579 m_comboBoxTideStation =
580 new wxChoice(sbSizerExtProperties->GetStaticBox(), wxID_ANY,
581 wxDefaultPosition, wxDefaultSize, m_choiceTideChoices);
583 gbSizerInnerExtProperties1->Add(
584 m_comboBoxTideStation, 0, wxALL | wxEXPAND | wxALIGN_CENTRE_VERTICAL, 5);
587 m_comboBoxTideStation =
new wxComboBox(
588 sbSizerExtProperties->GetStaticBox(), wxID_ANY, wxEmptyString,
589 wxDefaultPosition, wxDefaultSize, 0, NULL, wxCB_READONLY);
590 gbSizerInnerExtProperties1->Add(
591 m_comboBoxTideStation, 0, wxALL | wxEXPAND | wxALIGN_CENTRE_VERTICAL, 5);
593 m_comboBoxTideStation->SetToolTip(
594 _(
"Associate this waypoint with a tide station to quickly access tide "
595 "predictions. Select from nearby stations or leave empty for no "
598 m_buttonShowTides =
new wxBitmapButton(
599 sbSizerExtProperties->GetStaticBox(), ID_BTN_SHOW_TIDES, m_bmTide,
600 wxDefaultPosition, m_bmTide.GetSize(), 0);
601 gbSizerInnerExtProperties1->Add(m_buttonShowTides, 0,
602 wxALL | wxALIGN_CENTRE_VERTICAL, 5);
604 m_staticTextArrivalRadius =
new wxStaticText(
605 sbSizerExtProperties->GetStaticBox(), wxID_ANY, _(
"Arrival Radius"));
606 gbSizerInnerExtProperties1->Add(m_staticTextArrivalRadius, 0,
607 wxALIGN_CENTRE_VERTICAL, 0);
608 m_textArrivalRadius =
609 new wxTextCtrl(sbSizerExtProperties->GetStaticBox(), wxID_ANY,
610 wxEmptyString, wxDefaultPosition, wxDefaultSize, 0);
611 m_textArrivalRadius->SetToolTip(
612 _(
"Distance from the waypoint at which OpenCPN will consider the "
613 "waypoint reached. Used for automatic waypoint advancement during "
614 "active navigation."));
615 gbSizerInnerExtProperties1->Add(m_textArrivalRadius, 0, wxALL | wxEXPAND, 5);
616 m_staticTextArrivalUnits =
617 new wxStaticText(sbSizerExtProperties->GetStaticBox(), wxID_ANY,
618 wxEmptyString, wxDefaultPosition, wxDefaultSize, 0);
619 gbSizerInnerExtProperties1->Add(m_staticTextArrivalUnits, 0,
620 wxALIGN_CENTRE_VERTICAL, 0);
622 m_staticTextPlSpeed =
623 new wxStaticText(sbSizerExtProperties->GetStaticBox(), wxID_ANY,
624 _(
"Planned Speed"), wxDefaultPosition, wxDefaultSize, 0);
625 gbSizerInnerExtProperties1->Add(m_staticTextPlSpeed, 0,
626 wxALIGN_CENTRE_VERTICAL, 0);
628 new wxTextCtrl(sbSizerExtProperties->GetStaticBox(), wxID_ANY,
629 wxEmptyString, wxDefaultPosition, wxDefaultSize, 0);
631 "Enter the planned vessel speed for the leg FOLLOWING this waypoint. "
632 "This speed is used when traveling FROM this waypoint TO the next "
633 "waypoint in the route. The value is used to calculate estimated time "
634 "of arrival at the next waypoint based on the ETD from this waypoint.\n\n"
635 "If left blank, the route's default speed will be used for this leg. "
636 "Individual waypoint speeds override the route-level speed setting."));
638 m_staticTextPlSpeedUnits =
639 new wxStaticText(sbSizerExtProperties->GetStaticBox(), wxID_ANY,
640 getUsrSpeedUnit(), wxDefaultPosition, wxDefaultSize, 0);
641 gbSizerInnerExtProperties1->Add(m_staticTextPlSpeedUnits, 0,
642 wxALIGN_CENTRE_VERTICAL, 0);
646 m_staticTextEtd =
new wxStaticText(sbSizerExtProperties->GetStaticBox(),
648 gbSizerInnerExtProperties1->Add(
m_staticTextEtd, 0, wxALIGN_CENTRE_VERTICAL,
650 wxBoxSizer* bsTimestamp =
new wxBoxSizer(wxHORIZONTAL);
651 m_cbEtdPresent =
new wxCheckBox(sbSizerExtProperties->GetStaticBox(),
652 wxID_ANY, wxEmptyString);
654 _(
"Enable to manually set a planned departure time (ETD) for this "
656 "When checked, the specified date and time will be used instead of the "
657 "automatically calculated ETD. This affects ETA calculations for "
658 "subsequent waypoints in the route."));
661 sbSizerExtProperties->GetStaticBox(), ID_ETA_DATEPICKERCTRL,
662 wxDefaultDateTime, wxDefaultPosition, wxDefaultSize, wxDP_DEFAULT,
665 "Select the planned departure date (ETD) for this waypoint.\nUsed "
666 "together with the time control to calculate arrival times at subsequent "
667 "waypoints.\nETD information is only used for route planning "
668 "and does not affect navigation."));
673 new TimeCtrl(sbSizerExtProperties->GetStaticBox(), ID_ETA_TIMEPICKERCTRL,
674 wxDefaultDateTime, wxDefaultPosition, wxDefaultSize);
677 sbSizerExtProperties->GetStaticBox(), ID_ETA_TIMEPICKERCTRL,
678 wxDefaultDateTime, wxDefaultPosition, wxDefaultSize, wxDP_DEFAULT,
683 gbSizerInnerExtProperties1->Add(bsTimestamp, 0, wxEXPAND, 0);
684 sbSizerExtProperties->Add(gbSizerInnerExtProperties, 0, wxALL | wxEXPAND, 5);
685 sbSizerExtProperties->Add(sbRangeRingsExtProperties, 0, wxALL | wxEXPAND, 5);
686 sbSizerExtProperties->Add(gbSizerInnerExtProperties2, 0, wxALL | wxEXPAND, 5);
687 sbSizerExtProperties->Add(gbSizerInnerExtProperties1, 0, wxALL | wxEXPAND, 5);
689 fSizerExtProperties->Add(sbSizerExtProperties, 1, wxALL | wxEXPAND);
692 bSizer1->Add(m_notebookProperties, 1, wxEXPAND);
694 wxBoxSizer* btnSizer =
new wxBoxSizer(wxHORIZONTAL);
695 bSizer1->Add(btnSizer, 0, wxEXPAND, 0);
698 new wxBitmapButton(
this, ID_DEFAULT, _img_MUI_settings_svg,
699 wxDefaultPosition, _img_MUI_settings_svg.GetSize(), 0);
700 btnSizer->Add(DefaultsBtn, 0, wxALL | wxALIGN_LEFT | wxALIGN_BOTTOM, 5);
701 btnSizer->Add(0, 0, 1, wxEXPAND);
703 m_sdbSizerButtons =
new wxStdDialogButtonSizer();
704 m_buttonOkay =
new wxButton(
this, wxID_OK);
705 m_sdbSizerButtons->AddButton(m_buttonOkay);
706 m_sdbSizerButtons->AddButton(
new wxButton(
this, wxID_CANCEL, _(
"Cancel")));
707 m_sdbSizerButtons->Realize();
708 btnSizer->Add(m_sdbSizerButtons, 0, wxALL, 5);
713 m_textLatitude->Connect(
715 wxCommandEventHandler(MarkInfoDlg::OnRightClickLatLon), NULL,
this);
716 m_textLongitude->Connect(
718 wxCommandEventHandler(MarkInfoDlg::OnRightClickLatLon), NULL,
this);
720 m_htmlList->Connect(wxEVT_RIGHT_DOWN,
721 wxMouseEventHandler(MarkInfoDlg::m_htmlListContextMenu),
725 m_notebookProperties->Connect(
726 wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED,
727 wxNotebookEventHandler(MarkInfoDlg::OnNotebookPageChanged), NULL,
this);
732 m_comboBoxTideStation->Connect(
733 wxEVT_COMMAND_COMBOBOX_SELECTED,
734 wxCommandEventHandler(MarkInfoDlg::OnTideStationCombobox), NULL,
this);
737void MarkInfoDlg::OnClose(wxCloseEvent& event) {
743#define TIDESTATION_BATCH_SIZE 10
745void MarkInfoDlg::OnTideStationCombobox(wxCommandEvent& event) {
746 int count = m_comboBoxTideStation->GetCount();
747 int sel = m_comboBoxTideStation->GetSelection();
748 if (sel == count - 1) {
751 for (
auto ts : m_tss) {
752 if (i == count + TIDESTATION_BATCH_SIZE) {
756 n = wxString::FromUTF8(ts.second->IDX_station_name);
757 m_comboBoxTideStation->Append(n);
764void MarkInfoDlg::OnNotebookPageChanged(wxNotebookEvent& event) {
765 if (event.GetSelection() == EXTENDED_PROP_PAGE) {
766 if (m_lasttspos.IsSameAs(m_textLatitude->GetValue() +
767 m_textLongitude->GetValue())) {
770 m_lasttspos = m_textLatitude->GetValue() + m_textLongitude->GetValue();
771 double lat = fromDMM(m_textLatitude->GetValue());
772 double lon = fromDMM(m_textLongitude->GetValue());
773 m_tss = ptcmgr->GetStationsForLL(lat, lon);
774 wxString s = m_comboBoxTideStation->GetStringSelection();
777 m_comboBoxTideStation->Clear();
778 m_comboBoxTideStation->Append(wxEmptyString);
779 for (
auto ts : m_tss) {
780 if (i == TIDESTATION_BATCH_SIZE) {
784 n = wxString::FromUTF8(ts.second->IDX_station_name);
785 m_comboBoxTideStation->Append(n);
787 m_comboBoxTideStation->SetSelection(i);
790 if (m_comboBoxTideStation->GetStringSelection() != s) {
791 m_comboBoxTideStation->Insert(s, 1);
792 m_comboBoxTideStation->SetSelection(1);
797void MarkInfoDlg::RecalculateSize(
void) {
802 wxSize dsize = GetParent()->GetClientSize();
806 esize.x = GetCharHeight() * 20;
807 esize.y = GetCharHeight() * 40;
810 esize.y = wxMin(esize.y, dsize.y - (2 * GetCharHeight()));
811 esize.x = wxMin(esize.x, dsize.x - (1 * GetCharHeight()));
812 SetSize(wxSize(esize.x, esize.y));
815 wxSize fsize = GetSize();
816 fsize.y = wxMin(fsize.y, dsize.y - (2 * GetCharHeight()));
817 fsize.x = wxMin(fsize.x, dsize.x - (1 * GetCharHeight()));
821 fsize.y = wxMin(fsize.y, (25 * GetCharHeight()));
823 SetSize(wxSize(-1, fsize.y));
825 m_defaultClientSize = GetClientSize();
828 wxSize dsize = GetParent()->GetClientSize();
829 SetSize(-1, wxMax(GetSize().y, dsize.y / 1.5));
833MarkInfoDlg::~MarkInfoDlg() {
835 m_textLatitude->Disconnect(
837 wxCommandEventHandler(MarkInfoDlg::OnRightClickLatLon), NULL,
this);
838 m_textLongitude->Disconnect(
840 wxCommandEventHandler(MarkInfoDlg::OnRightClickLatLon), NULL,
this);
842 m_htmlList->Disconnect(
843 wxEVT_RIGHT_DOWN, wxMouseEventHandler(MarkInfoDlg::m_htmlListContextMenu),
848 m_notebookProperties->Disconnect(
849 wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED,
850 wxNotebookEventHandler(MarkInfoDlg::OnNotebookPageChanged), NULL,
this);
852 wxEVT_TIME_CHANGED, wxDateEventHandler(MarkInfoDlg::OnTimeChanged), NULL,
855 wxEVT_DATE_CHANGED, wxDateEventHandler(MarkInfoDlg::OnTimeChanged), NULL,
859 androidEnableBackButton(
true);
863void MarkInfoDlg::InitialFocus(
void) {
864 m_textName->SetFocus();
865 m_textName->SetInsertionPointEnd();
868void MarkInfoDlg::SetColorScheme(ColorScheme cs) { DimeControl(
this); }
870void MarkInfoDlg::ClearData() {
871 m_pRoutePoint = NULL;
875void MarkInfoDlg::SetRoutePoint(
RoutePoint* pRP) {
878 m_lat_save = m_pRoutePoint->m_lat;
879 m_lon_save = m_pRoutePoint->m_lon;
880 m_IconName_save = m_pRoutePoint->GetIconName();
883 m_Name_save = m_pRoutePoint->GetName();
885 m_bUseScaMin_save = m_pRoutePoint->GetUseSca();
886 m_iScaminVal_save = m_pRoutePoint->GetScaMin();
888 if (m_pMyLinkList)
delete m_pMyLinkList;
889 m_pMyLinkList =
new HyperlinkList();
891 if (NbrOfLinks > 0) {
892 wxHyperlinkListNode* linknode =
898 h->DescrText = link->DescrText;
899 h->Link = link->Link;
900 h->LType = link->LType;
902 m_pMyLinkList->Append(h);
904 linknode = linknode->GetNext();
910void MarkInfoDlg::UpdateHtmlList() {
912 GetSimpleBox()->Clear();
915 if (NbrOfLinks > 0) {
916 wxHyperlinkListNode* linknode = m_pRoutePoint->
m_HyperlinkList->GetFirst();
920 wxString::Format(
"<a href='%s'>%s</a>", link->Link, link->DescrText);
921 GetSimpleBox()->AppendString(s);
922 linknode = linknode->GetNext();
927 wxWindowList kids = m_scrolledWindowLinks->GetChildren();
928 for (
unsigned int i = 0; i < kids.GetCount(); i++) {
929 wxWindowListNode* node = kids.Item(i);
930 wxWindow* win = node->GetData();
932 auto link_win =
dynamic_cast<wxHyperlinkCtrl*
>(win);
934 link_win->Disconnect(
935 wxEVT_COMMAND_HYPERLINK,
936 wxHyperlinkEventHandler(MarkInfoDlg::OnHyperLinkClick));
937 link_win->Disconnect(
939 wxMouseEventHandler(MarkInfoDlg::m_htmlListContextMenu));
946 if (NbrOfLinks > 0) {
947 wxHyperlinkListNode* linknode = hyperlinklist->GetFirst();
950 wxString Link = link->Link;
951 wxString Descr = link->DescrText;
953 wxHyperlinkCtrl* ctrl =
new wxHyperlinkCtrl(
954 m_scrolledWindowLinks, wxID_ANY, Descr, Link, wxDefaultPosition,
955 wxDefaultSize, wxNO_BORDER | wxHL_CONTEXTMENU | wxHL_ALIGN_LEFT);
956 ctrl->Connect(wxEVT_COMMAND_HYPERLINK,
957 wxHyperlinkEventHandler(MarkInfoDlg::OnHyperLinkClick),
960 ctrl->Connect(wxEVT_RIGHT_DOWN,
961 wxMouseEventHandler(MarkInfoDlg::m_htmlListContextMenu),
964 bSizerLinks->Add(ctrl, 1, wxALL | wxEXPAND, 5);
966 linknode = linknode->GetNext();
971 m_scrolledWindowLinks->Layout();
975void MarkInfoDlg::OnHyperLinkClick(wxHyperlinkEvent& event) {
976 wxString url =
event.GetURL();
977 url.Replace(
" ",
"%20");
978 if (g_Platform) g_Platform->platformLaunchDefaultBrowser(url);
981void MarkInfoDlg::OnHtmlLinkClicked(wxHtmlLinkEvent& event) {
991 wxString cc =
event.GetLinkInfo().GetHref().c_str();
992 if (cc.Find(
"#") != wxNOT_FOUND) {
993 wxRegKey RegKey(wxString(
"HKEY_CLASSES_ROOT\\HTTP\\shell\\open\\command"));
994 if (RegKey.Exists()) {
995 wxString command_line;
996 RegKey.QueryValue(wxString(
""), command_line);
999 command_line.Replace(wxString(
"\""), wxString(
""));
1002 int l = command_line.Find(
".exe");
1003 if (wxNOT_FOUND == l) l = command_line.Find(
".EXE");
1005 if (wxNOT_FOUND != l) {
1006 wxString cl = command_line.Mid(0, l + 4);
1015 wxString url =
event.GetLinkInfo().GetHref().c_str();
1016 url.Replace(
" ",
"%20");
1017 ::wxLaunchDefaultBrowser(url);
1021 wxString url =
event.GetLinkInfo().GetHref().c_str();
1022 url.Replace(
" ",
"%20");
1023 if (g_Platform) g_Platform->platformLaunchDefaultBrowser(url);
1029void MarkInfoDlg::OnLayoutResize(wxCommandEvent& event) {
1030 m_panelBasicProperties->Layout();
1034void MarkInfoDlg::OnDescChangedExt(wxCommandEvent& event) {
1035 if (m_panelDescription->IsShownOnScreen()) {
1036 m_textDescription->ChangeValue(m_textCtrlExtDescription->GetValue());
1040void MarkInfoDlg::OnDescChangedBasic(wxCommandEvent& event) {
1041 if (m_panelBasicProperties->IsShownOnScreen()) {
1042 m_textCtrlExtDescription->ChangeValue(m_textDescription->GetValue());
1047void MarkInfoDlg::OnExtDescriptionClick(wxCommandEvent& event) {
1048 long pos = m_textDescription->GetInsertionPoint();
1049 m_notebookProperties->SetSelection(1);
1050 m_textCtrlExtDescription->SetInsertionPoint(pos);
1054void MarkInfoDlg::OnShowWaypointNameSelectBasic(wxCommandEvent& event) {
1055 m_checkBoxShowNameExt->SetValue(m_checkBoxShowName->GetValue());
1058void MarkInfoDlg::OnShowWaypointNameSelectExt(wxCommandEvent& event) {
1059 m_checkBoxShowName->SetValue(m_checkBoxShowNameExt->GetValue());
1063void MarkInfoDlg::OnWptRangeRingsNoChange(wxCommandEvent& event) {
1065 m_textWaypointRangeRingsStep->Enable(
1066 (
bool)(m_ChoiceWaypointRangeRingsNumber->GetSelection() != 0));
1067 m_PickColor->Enable(
1068 (
bool)(m_ChoiceWaypointRangeRingsNumber->GetSelection() != 0));
1072void MarkInfoDlg::OnSelectScaMinExt(wxCommandEvent& event) {
1074 m_textScaMin->Enable(m_checkBoxScaMin->GetValue());
1078void MarkInfoDlg::OnPositionCtlUpdated(wxCommandEvent& event) {
1080 double lat = fromDMM(m_textLatitude->GetValue());
1081 double lon = fromDMM(m_textLongitude->GetValue());
1083 m_pRoutePoint->SetPosition(lat, lon);
1084 pSelect->ModifySelectablePoint(lat, lon, (
void*)m_pRoutePoint,
1085 SELTYPE_ROUTEPOINT);
1088 gFrame->RefreshAllCanvas();
1091void MarkInfoDlg::m_htmlListContextMenu(wxMouseEvent& event) {
1095 wxPoint pos =
event.GetPosition();
1096 i_htmlList_item = -1;
1097 for (
int i = 0; i < (int)GetSimpleBox()->GetCount(); i++) {
1098 wxRect rect = GetSimpleBox()->GetItemRect(i);
1099 if (rect.Contains(pos)) {
1100 i_htmlList_item = i;
1105 wxMenu* popup =
new wxMenu();
1106 if ((GetSimpleBox()->GetCount()) > 0 && (i_htmlList_item > -1) &&
1107 (i_htmlList_item < (
int)GetSimpleBox()->GetCount())) {
1108 popup->Append(ID_RCLK_MENU_DELETE_LINK, _(
"Delete"));
1109 popup->Append(ID_RCLK_MENU_EDIT_LINK, _(
"Edit"));
1111 popup->Append(ID_RCLK_MENU_ADD_LINK, _(
"Add New"));
1113 m_contextObject =
event.GetEventObject();
1115 wxEVT_COMMAND_MENU_SELECTED,
1116 wxCommandEventHandler(MarkInfoDlg::On_html_link_popupmenu_Click), NULL,
1122 m_pEditedLink =
dynamic_cast<wxHyperlinkCtrl*
>(
event.GetEventObject());
1124 if (m_pEditedLink) {
1125 wxString url = m_pEditedLink->GetURL();
1126 wxString label = m_pEditedLink->GetLabel();
1127 i_htmlList_item = -1;
1129 if (hyperlinklist->GetCount() > 0) {
1131 wxHyperlinkListNode* linknode = hyperlinklist->GetFirst();
1134 if (link->DescrText == label) {
1135 i_htmlList_item = i;
1139 linknode = linknode->GetNext();
1146 wxMenu* popup =
new wxMenu();
1148 wxMenuItem* menuItemDelete =
1149 new wxMenuItem(popup, ID_RCLK_MENU_DELETE_LINK, wxString(_(
"Delete")),
1150 wxEmptyString, wxITEM_NORMAL);
1152 menuItemDelete->SetFont(sFont);
1154 popup->Append(menuItemDelete);
1156 wxMenuItem* menuItemEdit =
1157 new wxMenuItem(popup, ID_RCLK_MENU_EDIT_LINK, wxString(_(
"Edit")),
1158 wxEmptyString, wxITEM_NORMAL);
1160 menuItemEdit->SetFont(sFont);
1162 popup->Append(menuItemEdit);
1165 wxMenuItem* menuItemAdd =
1166 new wxMenuItem(popup, ID_RCLK_MENU_ADD_LINK, wxString(_(
"Add New")),
1167 wxEmptyString, wxITEM_NORMAL);
1169 menuItemAdd->SetFont(sFont);
1171 popup->Append(menuItemAdd);
1173 m_contextObject =
event.GetEventObject();
1175 wxEVT_COMMAND_MENU_SELECTED,
1176 wxCommandEventHandler(MarkInfoDlg::On_html_link_popupmenu_Click), NULL,
1178 wxPoint p = m_scrolledWindowLinks->GetPosition();
1179 p.x += m_scrolledWindowLinks->GetSize().x / 2;
1180 PopupMenu(popup, p);
1203void MarkInfoDlg::OnAddLink(wxCommandEvent& event) {
1204 wxCommandEvent evt(wxEVT_COMMAND_MENU_SELECTED);
1205 evt.SetId(ID_RCLK_MENU_ADD_LINK);
1207 On_html_link_popupmenu_Click(evt);
1210void MarkInfoDlg::On_html_link_popupmenu_Click(wxCommandEvent& event) {
1211 switch (event.GetId()) {
1212 case ID_RCLK_MENU_DELETE_LINK: {
1213 wxHyperlinkListNode* node =
1219 case ID_RCLK_MENU_EDIT_LINK: {
1223 LinkPropDlg->m_textCtrlLinkDescription->SetValue(link->DescrText);
1224 LinkPropDlg->m_textCtrlLinkUrl->SetValue(link->Link);
1225 DimeControl(LinkPropDlg);
1226 LinkPropDlg->ShowWindowModalThenDo([
this, LinkPropDlg,
1227 link](
int retcode) {
1228 if (retcode == wxID_OK) {
1229 link->DescrText = LinkPropDlg->m_textCtrlLinkDescription->GetValue();
1230 link->Link = LinkPropDlg->m_textCtrlLinkUrl->GetValue();
1237 case ID_RCLK_MENU_ADD_LINK: {
1239 LinkPropDlg->m_textCtrlLinkDescription->SetValue(wxEmptyString);
1240 LinkPropDlg->m_textCtrlLinkUrl->SetValue(wxEmptyString);
1241 DimeControl(LinkPropDlg);
1242 LinkPropDlg->ShowWindowModalThenDo([
this, LinkPropDlg](
int retcode) {
1243 if (retcode == wxID_OK) {
1245 link->DescrText = LinkPropDlg->m_textCtrlLinkDescription->GetValue();
1246 link->Link = LinkPropDlg->m_textCtrlLinkUrl->GetValue();
1248 if (link->DescrText == wxEmptyString) {
1249 link->DescrText = link->Link;
1251 if (link->Link == wxEmptyString) {
1254 m_pRoutePoint->m_HyperlinkList->Append(link);
1265void MarkInfoDlg::OnRightClickLatLon(wxCommandEvent& event) {
1266 wxMenu* popup =
new wxMenu();
1267 popup->Append(ID_RCLK_MENU_COPY, _(
"Copy"));
1268 popup->Append(ID_RCLK_MENU_COPY_LL, _(
"Copy lat/long"));
1269 popup->Append(ID_RCLK_MENU_PASTE, _(
"Paste"));
1270 popup->Append(ID_RCLK_MENU_PASTE_LL, _(
"Paste lat/long"));
1271 m_contextObject =
event.GetEventObject();
1272 popup->Connect(wxEVT_COMMAND_MENU_SELECTED,
1273 wxCommandEventHandler(MarkInfoDlg::OnCopyPasteLatLon), NULL,
1280void MarkInfoDlg::OnCopyPasteLatLon(wxCommandEvent& event) {
1282 double lat = fromDMM(m_textLatitude->GetValue());
1283 double lon = fromDMM(m_textLongitude->GetValue());
1287 switch (event.GetId()) {
1288 case ID_RCLK_MENU_PASTE: {
1289 if (wxTheClipboard->Open()) {
1290 wxTextDataObject data;
1291 wxTheClipboard->GetData(data);
1292 result = data.GetText();
1293 ((wxTextCtrl*)m_contextObject)->SetValue(result);
1294 wxTheClipboard->Close();
1298 case ID_RCLK_MENU_PASTE_LL: {
1299 if (wxTheClipboard->Open()) {
1300 wxTextDataObject data;
1301 wxTheClipboard->GetData(data);
1302 result = data.GetText();
1306 if (pparse.IsOk()) {
1307 m_textLatitude->SetValue(pparse.GetLatitudeString());
1308 m_textLongitude->SetValue(pparse.GetLongitudeString());
1310 wxTheClipboard->Close();
1314 case ID_RCLK_MENU_COPY: {
1315 result = ((wxTextCtrl*)m_contextObject)->GetValue();
1318 case ID_RCLK_MENU_COPY_LL: {
1319 result << toSDMM(1, lat,
true) << _T(
'\t');
1320 result << toSDMM(2, lon,
true);
1325 if (wxTheClipboard->Open()) {
1326 wxTextDataObject* data =
new wxTextDataObject;
1327 data->SetText(result);
1328 wxTheClipboard->SetData(data);
1329 wxTheClipboard->Close();
1333void MarkInfoDlg::DefautlBtnClicked(wxCommandEvent& event) {
1335 m_SaveDefaultDlg->Center();
1336 DimeControl(m_SaveDefaultDlg);
1337 int retcode = m_SaveDefaultDlg->ShowModal();
1340 if (retcode == wxID_OK) {
1342 if (m_SaveDefaultDlg->IconCB->GetValue()) {
1344 *pWayPointMan->GetIconKey(m_bcomboBoxIcon->GetSelection());
1346 if (m_SaveDefaultDlg->RangRingsCB->GetValue()) {
1347 g_iWaypointRangeRingsNumber =
1348 m_ChoiceWaypointRangeRingsNumber->GetSelection();
1349 if (m_textWaypointRangeRingsStep->GetValue().ToDouble(&value))
1350 g_fWaypointRangeRingsStep = fromUsrDistance(value, -1);
1351 g_colourWaypointRangeRingsColour = m_PickColor->GetColour();
1353 if (m_SaveDefaultDlg->ArrivalRCB->GetValue())
1354 if (m_textArrivalRadius->GetValue().ToDouble(&value))
1355 g_n_arrival_circle_radius = fromUsrDistance(value, -1);
1356 if (m_SaveDefaultDlg->ScaleCB->GetValue()) {
1357 g_iWpt_ScaMin = wxAtoi(m_textScaMin->GetValue());
1358 g_bUseWptScaMin = m_checkBoxScaMin->GetValue();
1360 if (m_SaveDefaultDlg->NameCB->GetValue()) {
1361 g_bShowWptName = m_checkBoxShowName->GetValue();
1364 m_SaveDefaultDlg = NULL;
1368void MarkInfoDlg::OnMarkInfoCancelClick(wxCommandEvent& event) {
1369 if (m_pRoutePoint) {
1370 m_pRoutePoint->SetVisible(m_bIsVisible_save);
1371 m_pRoutePoint->SetNameShown(m_bShowName_save);
1372 m_pRoutePoint->SetPosition(m_lat_save, m_lon_save);
1373 m_pRoutePoint->SetIconName(m_IconName_save);
1374 m_pRoutePoint->ReLoadIcon();
1375 m_pRoutePoint->SetName(m_Name_save);
1377 m_pRoutePoint->SetUseSca(m_bUseScaMin_save);
1378 m_pRoutePoint->SetScaMin(m_iScaminVal_save);
1382 int NbrOfLinks = m_pMyLinkList->GetCount();
1383 if (NbrOfLinks > 0) {
1384 wxHyperlinkListNode* linknode = m_pMyLinkList->GetFirst();
1388 h->DescrText = link->DescrText;
1389 h->Link = link->Link;
1390 h->LType = link->LType;
1394 linknode = linknode->GetNext();
1399 m_lasttspos.Clear();
1406 delete m_pMyLinkList;
1407 m_pMyLinkList = NULL;
1408 SetClientSize(m_defaultClientSize);
1411 androidEnableBackButton(
true);
1417void MarkInfoDlg::OnMarkInfoOKClick(wxCommandEvent& event) {
1418 if (m_pRoutePoint) {
1421 OnPositionCtlUpdated(event);
1431 if (pRouteManagerDialog && pRouteManagerDialog->IsShown())
1432 pRouteManagerDialog->UpdateWptListCtrl();
1434 if (pRoutePropDialog && pRoutePropDialog->IsShown())
1435 pRoutePropDialog->UpdatePoints();
1437 SetClientSize(m_defaultClientSize);
1440 androidEnableBackButton(
true);
1446bool MarkInfoDlg::UpdateProperties(
bool positionOnly) {
1447 if (m_pRoutePoint) {
1448 m_textLatitude->SetValue(::toSDMM(1, m_pRoutePoint->m_lat));
1449 m_textLongitude->SetValue(::toSDMM(2, m_pRoutePoint->m_lon));
1450 m_lat_save = m_pRoutePoint->m_lat;
1451 m_lon_save = m_pRoutePoint->m_lon;
1452 m_textName->SetValue(m_pRoutePoint->GetName());
1455 m_checkBoxShowName->SetValue(m_pRoutePoint->
m_bShowName);
1456 m_checkBoxShowNameExt->SetValue(m_pRoutePoint->
m_bShowName);
1457 m_checkBoxVisible->SetValue(m_pRoutePoint->
m_bIsVisible);
1458 m_checkBoxScaMin->SetValue(m_pRoutePoint->GetUseSca());
1459 m_textScaMin->SetValue(
1460 wxString::Format(
"%i", (
int)m_pRoutePoint->GetScaMin()));
1461 m_textCtrlGuid->SetValue(m_pRoutePoint->
m_GUID);
1462 m_ChoiceWaypointRangeRingsNumber->SetSelection(
1463 m_pRoutePoint->GetWaypointRangeRingsNumber());
1466 toUsrDistance(m_pRoutePoint->GetWaypointRangeRingsStep(), -1));
1467 m_textWaypointRangeRingsStep->SetValue(buf);
1468 m_staticTextArrivalUnits->SetLabel(getUsrDistanceUnit());
1470 toUsrDistance(m_pRoutePoint->GetWaypointArrivalRadius(), -1));
1471 m_textArrivalRadius->SetValue(buf);
1473 int nUnits = m_pRoutePoint->GetWaypointRangeRingsStepUnits();
1474 m_RangeRingUnits->SetSelection(nUnits);
1477 m_PickColor->SetColour(col);
1480 if (m_name_validator) m_name_validator.reset();
1482 std::make_unique<RoutePointNameValidator>(m_pRoutePoint);
1483 m_textName->SetValidator(*m_name_validator);
1485 m_textName->Bind(wxEVT_KILL_FOCUS, &MarkInfoDlg::OnFocusEvent,
this);
1487 m_textName->SetValidator();
1489 m_textName->Unbind(wxEVT_KILL_FOCUS, &MarkInfoDlg::OnFocusEvent,
this);
1492 if (m_comboBoxTideStation->GetStringSelection() !=
1494 m_comboBoxTideStation->Clear();
1495 m_comboBoxTideStation->Append(wxEmptyString);
1497 m_comboBoxTideStation->Append(m_pRoutePoint->
m_TideStation);
1498 m_comboBoxTideStation->SetSelection(1);
1502 m_staticTextPlSpeedUnits->SetLabel(getUsrSpeedUnit());
1510 bool isLastWaypoint =
false;
1513 wxArrayPtrVoid* pRouteArray =
1516 isLastWaypoint =
true;
1518 for (
unsigned int i = 0; i < pRouteArray->GetCount(); i++) {
1520 if (route->GetLastPoint()->
m_GUID != m_pRoutePoint->
m_GUID) {
1521 isLastWaypoint =
false;
1530 if (isLastWaypoint) {
1535 if (etd.IsValid()) {
1538 if (dtFormat ==
"Local Time") {
1542 }
else if (dtFormat ==
"UTC") {
1549 "MarkInfoDlg::UpdateProperties. Unexpected date/time format: %s",
1551 etd = wxInvalidDateTime;
1562 m_staticTextPlSpeed->Show(m_pRoutePoint->
m_bIsInRoute);
1568 m_staticTextPlSpeedUnits->Show(m_pRoutePoint->
m_bIsInRoute);
1569 m_staticTextArrivalRadius->Show(m_pRoutePoint->
m_bIsInRoute);
1570 m_staticTextArrivalUnits->Show(m_pRoutePoint->
m_bIsInRoute);
1571 m_textArrivalRadius->Show(m_pRoutePoint->
m_bIsInRoute);
1573 if (positionOnly)
return true;
1577 m_staticTextLayer->Enable();
1578 m_staticTextLayer->Show(
true);
1579 m_textName->SetEditable(
false);
1580 m_textDescription->SetEditable(
false);
1581 m_textCtrlExtDescription->SetEditable(
false);
1582 m_textLatitude->SetEditable(
false);
1583 m_textLongitude->SetEditable(
false);
1584 m_bcomboBoxIcon->Enable(
false);
1585 m_checkBoxShowName->Enable(
false);
1586 m_checkBoxVisible->Enable(
false);
1587 m_textArrivalRadius->SetEditable(
false);
1588 m_checkBoxScaMin->Enable(
false);
1589 m_textScaMin->SetEditable(
false);
1590 m_checkBoxShowNameExt->Enable(
false);
1591 m_ChoiceWaypointRangeRingsNumber->Enable(
false);
1592 m_textWaypointRangeRingsStep->SetEditable(
false);
1593 m_PickColor->Enable(
false);
1594 DefaultsBtn->Enable(
false);
1598 m_notebookProperties->SetSelection(0);
1599 m_comboBoxTideStation->Enable(
false);
1601 m_staticTextLayer->Enable(
false);
1602 m_staticTextLayer->Show(
false);
1603 m_textName->SetEditable(
true);
1604 m_textDescription->SetEditable(
true);
1605 m_textCtrlExtDescription->SetEditable(
true);
1606 m_textLatitude->SetEditable(
true);
1607 m_textLongitude->SetEditable(
true);
1608 m_bcomboBoxIcon->Enable(
true);
1609 m_checkBoxShowName->Enable(
true);
1610 m_checkBoxVisible->Enable(
true);
1611 m_textArrivalRadius->SetEditable(
true);
1612 m_checkBoxScaMin->Enable(
true);
1613 m_textScaMin->SetEditable(
true);
1614 m_checkBoxShowNameExt->Enable(
true);
1615 m_ChoiceWaypointRangeRingsNumber->Enable(
true);
1616 m_textWaypointRangeRingsStep->SetEditable(
true);
1617 m_PickColor->Enable(
true);
1618 DefaultsBtn->Enable(
true);
1619 m_notebookProperties->SetSelection(0);
1620 m_comboBoxTideStation->Enable(
true);
1630 m_bcomboBoxIcon->Clear();
1632 bool fillCombo = m_bcomboBoxIcon->GetCount() == 0;
1635 for (
int i = 0; i < pWayPointMan->GetNumIcons(); i++) {
1636 wxString* ps = pWayPointMan->GetIconDescription(i);
1638 pWayPointMan->GetIconBitmapForList(i, 2 * GetCharHeight());
1640 m_bcomboBoxIcon->Append(*ps, bmp);
1644 int iconToSelect = -1;
1645 for (
int i = 0; i < pWayPointMan->GetNumIcons(); i++) {
1646 if (*pWayPointMan->GetIconKey(i) == m_pRoutePoint->GetIconName()) {
1648 m_bcomboBoxIcon->Select(iconToSelect);
1653 OnShowWaypointNameSelectBasic(ev);
1654 OnWptRangeRingsNoChange(ev);
1655 OnSelectScaMinExt(ev);
1660 androidEnableBackButton(
false);
1671void MarkInfoDlg::OnFocusEvent(wxFocusEvent& event) {
1672 bool is_valid = Validate();
1673 m_buttonOkay->Enable(is_valid);
1677void MarkInfoDlg::OnBitmapCombClick(wxCommandEvent& event) {
1678 wxString* icon_name =
1679 pWayPointMan->GetIconKey(m_bcomboBoxIcon->GetSelection());
1680 if (icon_name && icon_name->Length()) m_pRoutePoint->SetIconName(*icon_name);
1681 m_pRoutePoint->ReLoadIcon();
1686void MarkInfoDlg::ValidateMark(
void) {
1689 wxRoutePointListNode* node = pWayPointMan->GetWaypointList()->GetFirst();
1691 bool b_found =
false;
1694 if (m_pRoutePoint == rp) {
1698 node = node->GetNext();
1700 if (!b_found) m_pRoutePoint = NULL;
1703bool MarkInfoDlg::SaveChanges() {
1704 if (m_pRoutePoint) {
1706 if (!this->Validate())
return false;
1709 m_pRoutePoint->SetName(m_textName->GetValue());
1710 m_pRoutePoint->SetWaypointArrivalRadius(m_textArrivalRadius->GetValue());
1711 m_pRoutePoint->SetScaMin(m_textScaMin->GetValue());
1712 m_pRoutePoint->SetUseSca(m_checkBoxScaMin->GetValue());
1714 m_pRoutePoint->SetVisible(m_checkBoxVisible->GetValue());
1715 m_pRoutePoint->
m_bShowName = m_checkBoxShowName->GetValue();
1716 m_pRoutePoint->SetPosition(fromDMM(m_textLatitude->GetValue()),
1717 fromDMM(m_textLongitude->GetValue()));
1718 wxString* icon_name =
1719 pWayPointMan->GetIconKey(m_bcomboBoxIcon->GetSelection());
1720 if (icon_name && icon_name->Length())
1721 m_pRoutePoint->SetIconName(*icon_name);
1722 m_pRoutePoint->ReLoadIcon();
1723 m_pRoutePoint->SetShowWaypointRangeRings(
1724 (
bool)(m_ChoiceWaypointRangeRingsNumber->GetSelection() != 0));
1725 m_pRoutePoint->SetWaypointRangeRingsNumber(
1726 m_ChoiceWaypointRangeRingsNumber->GetSelection());
1728 if (m_textWaypointRangeRingsStep->GetValue().ToDouble(&value))
1729 m_pRoutePoint->SetWaypointRangeRingsStep(fromUsrDistance(value, -1));
1730 if (m_textArrivalRadius->GetValue().ToDouble(&value))
1731 m_pRoutePoint->SetWaypointArrivalRadius(fromUsrDistance(value, -1));
1733 if (m_RangeRingUnits->GetSelection() != wxNOT_FOUND)
1734 m_pRoutePoint->SetWaypointRangeRingsStepUnits(
1735 m_RangeRingUnits->GetSelection());
1737 m_pRoutePoint->
m_TideStation = m_comboBoxTideStation->GetStringSelection();
1739 m_pRoutePoint->SetPlannedSpeed(0.0);
1743 m_pRoutePoint->SetPlannedSpeed(fromUsrSpeed(spd));
1750 int hour = t.GetHour();
1760 if (dtFormat ==
"Local Time") {
1761 m_pRoutePoint->
SetETD(dt.MakeUTC());
1762 }
else if (dtFormat ==
"UTC") {
1763 m_pRoutePoint->
SetETD(dt);
1772 "Failed to configured ETD. Unsupported date/time format: %s",
1774 m_pRoutePoint->
SetETD(wxInvalidDateTime);
1778 m_pRoutePoint->
SetETD(wxInvalidDateTime);
1783 pSelect->UpdateSelectableRouteSegments(m_pRoutePoint);
1786 wxArrayPtrVoid* pEditRouteArray =
1789 if (pEditRouteArray) {
1790 for (
unsigned int ir = 0; ir < pEditRouteArray->GetCount(); ir++) {
1791 Route* pr = (
Route*)pEditRouteArray->Item(ir);
1792 pr->FinalizeForRendering();
1793 pr->UpdateSegmentDistances();
1796 NavObj_dB::GetInstance().UpdateRoute(pr);
1798 delete pEditRouteArray;
1802 NavObj_dB::GetInstance().UpdateRoutePoint(m_pRoutePoint);
1808SaveDefaultsDialog::SaveDefaultsDialog(
MarkInfoDlg* parent)
1809 : wxDialog(parent, wxID_ANY, _(
"Save some defaults")) {
1811 this->SetSizeHints(wxDefaultSize, wxDefaultSize);
1813 wxBoxSizer* bSizer1 =
new wxBoxSizer(wxVERTICAL);
1814 wxStdDialogButtonSizer* StdDialogButtonSizer1;
1817 new wxStaticText(
this, wxID_ANY,
1818 _(
"Check which properties of current waypoint\n should "
1819 "be set as default for NEW waypoints."));
1820 bSizer1->Add(StaticText1, 0, wxALL | wxALIGN_CENTER_HORIZONTAL, 5);
1822 wxFlexGridSizer* fgSizer1 =
new wxFlexGridSizer(2);
1825 (g_pMarkInfoDialog->m_checkBoxShowName->GetValue() ? _(
"Do use")
1828 new wxCheckBox(
this, wxID_ANY, _(
"Show Waypoint Name"), wxDefaultPosition,
1829 wxDefaultSize, 0, wxDefaultValidator);
1830 fgSizer1->Add(NameCB, 0, wxALL, 5);
1831 stName =
new wxStaticText(
this, wxID_ANY,
"[" + s +
"]", wxDefaultPosition,
1834 fgSizer1->Add(stName, 0, wxALL | wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL, 5);
1836 s = g_pMarkInfoDialog->m_pRoutePoint->GetIconName();
1837 IconCB =
new wxCheckBox(
this, wxID_ANY, _(
"Icon"));
1838 fgSizer1->Add(IconCB, 0, wxALL, 5);
1839 stIcon =
new wxStaticText(
this, wxID_ANY,
"[" + s +
"]", wxDefaultPosition,
1842 fgSizer1->Add(stIcon, 0, wxALL | wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL, 5);
1844 s = (g_pMarkInfoDialog->m_ChoiceWaypointRangeRingsNumber->GetSelection()
1848 g_pMarkInfoDialog->m_ChoiceWaypointRangeRingsNumber
1851 RangRingsCB =
new wxCheckBox(
this, wxID_ANY, _(
"Range rings"));
1852 fgSizer1->Add(RangRingsCB, 0, wxALL, 5);
1853 stRR =
new wxStaticText(
this, wxID_ANY,
"[" + s +
"]", wxDefaultPosition,
1856 fgSizer1->Add(stRR, 0, wxALL | wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL, 5);
1858 s = (g_pMarkInfoDialog->m_textArrivalRadius->GetValue());
1859 ArrivalRCB =
new wxCheckBox(
this, wxID_ANY, _(
"Arrival radius"));
1860 fgSizer1->Add(ArrivalRCB, 0, wxALL, 5);
1861 stArrivalR =
new wxStaticText(
1863 wxString::Format(
"[%s %s]", s.c_str(), getUsrDistanceUnit().c_str()),
1864 wxDefaultPosition, wxDefaultSize, 0);
1865 stArrivalR->Wrap(-1);
1866 fgSizer1->Add(stArrivalR, 0, wxALL | wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL,
1869 s = (g_pMarkInfoDialog->m_checkBoxScaMin->GetValue()
1870 ? _(
"Show only if") +
" < " +
1871 g_pMarkInfoDialog->m_textScaMin->GetValue()
1872 : _(
"Show always"));
1873 ScaleCB =
new wxCheckBox(
this, wxID_ANY, _(
"Show only at scale"));
1874 fgSizer1->Add(ScaleCB, 0, wxALL, 5);
1875 stScale =
new wxStaticText(
this, wxID_ANY,
"[" + s +
"]", wxDefaultPosition,
1878 fgSizer1->Add(stScale, 0, wxALL | wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL, 5);
1880 bSizer1->Add(fgSizer1, 0, wxALL | wxEXPAND, 5);
1882 StdDialogButtonSizer1 =
new wxStdDialogButtonSizer();
1883 StdDialogButtonSizer1->AddButton(
new wxButton(
this, wxID_OK));
1884 StdDialogButtonSizer1->AddButton(
1885 new wxButton(
this, wxID_CANCEL, _(
"Cancel")));
1886 StdDialogButtonSizer1->Realize();
1887 bSizer1->Add(StdDialogButtonSizer1, 0, wxALL | wxEXPAND, 5);
1894 SetSize(parent->GetSize());
1900void MarkInfoDlg::ShowTidesBtnClicked(wxCommandEvent& event) {
1901 if (m_comboBoxTideStation->GetSelection() < 1) {
1905 ptcmgr->GetStationIDXbyName(m_comboBoxTideStation->GetStringSelection(),
1906 fromDMM(m_textLatitude->GetValue()),
1907 fromDMM(m_textLongitude->GetValue())));
1909 TCWin* pCwin =
new TCWin(gFrame->GetPrimaryCanvas(), 0, 0, pIDX);
1912 wxString msg(_(
"Tide Station not found"));
1914 msg += m_comboBoxTideStation->GetStringSelection();
1915 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.
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.
wxString getUsrDateTimeFormat()
Return the date/time format to use when formatting date/time strings.
PlugInManager and helper classes – Mostly gui parts (dialogs) and plugin API stuff.
GUI library utils and events.