28 #include <wx/wxprec.h>
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"
55 #include "pluginmanager.h"
56 #include "routemanagerdialog.h"
57 #include "routeprintout.h"
58 #include "RoutePropDlgImpl.h"
60 #include "svg_utils.h"
64 #include "androidUTIL.h"
65 #include <QtWidgets/QScroller>
77 extern wxString g_default_wp_icon;
83 extern float g_MarkScaleFactorExp;
87 WX_DECLARE_LIST(wxBitmap, BitmapList);
88 #include <wx/listimpl.cpp>
89 WX_DEFINE_LIST(BitmapList);
91 #include <wx/arrimpl.cpp>
92 WX_DEFINE_OBJARRAY(ArrayOfBitmaps);
94 #define EXTENDED_PROP_PAGE 2
96 OCPNIconCombo::OCPNIconCombo(wxWindow* parent, wxWindowID
id,
97 const wxString& value,
const wxPoint& pos,
98 const wxSize& size,
int n,
99 const wxString choices[],
long style,
100 const wxValidator& validator,
const wxString& name)
101 : wxOwnerDrawnComboBox(parent, id, value, pos, size, n, choices, style,
104 GetFont().GetPointSize() / g_Platform->getFontPointsperPixel();
105 itemHeight = (int)wxRound(fontHeight);
108 OCPNIconCombo::~OCPNIconCombo() {}
110 void OCPNIconCombo::OnDrawItem(wxDC& dc,
const wxRect& rect,
int item,
112 int offset_x = bmpArray[item].GetWidth();
113 int bmpHeight = bmpArray[item].GetHeight();
114 dc.DrawBitmap(bmpArray[item], rect.x, rect.y + (rect.height - bmpHeight) / 2,
117 if (flags & wxODCB_PAINTING_CONTROL) {
118 wxString text = GetValue();
121 #if wxCHECK_VERSION(2, 9, 0)
122 if (ShouldUseHintText()) {
124 wxColour col = wxSystemSettings::GetColour(wxSYS_COLOUR_GRAYTEXT);
125 dc.SetTextForeground(col);
128 margin_x = GetMargins().x;
131 dc.DrawText(text, rect.x + margin_x + offset_x,
132 (rect.height - dc.GetCharHeight()) / 2 + rect.y);
134 dc.DrawText(GetVListBoxComboPopup()->GetString(item), rect.x + 2 + offset_x,
135 (rect.height - dc.GetCharHeight()) / 2 + rect.y);
139 wxCoord OCPNIconCombo::OnMeasureItem(
size_t item)
const {
140 int bmpHeight = bmpArray[item].GetHeight();
142 return wxMax(itemHeight, bmpHeight);
145 wxCoord OCPNIconCombo::OnMeasureItemWidth(
size_t item)
const {
return -1; }
147 int OCPNIconCombo::Append(
const wxString& item, wxBitmap bmp) {
149 int idx = wxOwnerDrawnComboBox::Append(item);
154 void OCPNIconCombo::Clear(
void) {
155 wxOwnerDrawnComboBox::Clear();
169 const wxEventType EVT_LLCHANGE = wxNewEventType();
178 const wxString& value, const wxPoint& pos,
179 const wxSize& size,
long style,
180 const wxValidator& validator,
181 const wxString& name)
182 : wxTextCtrl(parent,
id, value, pos, size, style, validator, name) {
183 m_pParentEventHandler = parent->GetEventHandler();
186 void LatLonTextCtrl::OnKillFocus(wxFocusEvent& event) {
188 wxCommandEvent up_event(EVT_LLCHANGE, GetId());
189 up_event.SetEventObject((wxObject*)
this);
190 m_pParentEventHandler->AddPendingEvent(up_event);
199 EVT_BUTTON(wxID_OK, MarkInfoDlg::OnMarkInfoOKClick)
200 EVT_BUTTON(wxID_CANCEL, MarkInfoDlg::OnMarkInfoCancelClick)
201 EVT_BUTTON(ID_BTN_DESC_BASIC, MarkInfoDlg::OnExtDescriptionClick)
202 EVT_BUTTON(ID_DEFAULT, MarkInfoDlg::DefautlBtnClicked)
203 EVT_BUTTON(ID_BTN_SHOW_TIDES, MarkInfoDlg::ShowTidesBtnClicked)
204 EVT_COMBOBOX(ID_BITMAPCOMBOCTRL, MarkInfoDlg::OnBitmapCombClick)
205 EVT_CHECKBOX(ID_SHOWNAMECHECKBOXBASIC,
206 MarkInfoDlg::OnShowWaypointNameSelectBasic)
207 EVT_CHECKBOX(ID_SHOWNAMECHECKBOX_EXT, MarkInfoDlg::OnShowWaypointNameSelectExt)
208 EVT_CHECKBOX(ID_CHECKBOX_SCAMIN_VIS, MarkInfoDlg::OnSelectScaMinExt)
209 EVT_TEXT(ID_DESCR_CTR_DESC, MarkInfoDlg::OnDescChangedExt)
210 EVT_TEXT(ID_DESCR_CTR_BASIC, MarkInfoDlg::OnDescChangedBasic)
211 EVT_TEXT(ID_LATCTRL, MarkInfoDlg::OnPositionCtlUpdated)
212 EVT_TEXT(ID_LONCTRL, MarkInfoDlg::OnPositionCtlUpdated)
213 EVT_CHOICE(ID_WPT_RANGERINGS_NO, MarkInfoDlg::OnWptRangeRingsNoChange)
215 EVT_HTML_LINK_CLICKED(wxID_ANY, MarkInfoDlg::OnHtmlLinkClicked)
216 EVT_CLOSE(MarkInfoDlg::OnClose)
222 const wxPoint& pos, const wxSize& size,
long style) {
223 DIALOG_PARENT::Create(parent,
id, title, pos, size, style);
225 wxFont* qFont = GetOCPNScaledFont(_(
"Dialog"));
227 int metric = GetCharHeight();
231 wxString wqs = getFontQtStylesheet(qFont);
232 wxCharBuffer sbuf = wqs.ToUTF8();
233 QString qsb = QString(sbuf.data());
234 QString qsbq = getQtStyleSheet();
235 this->GetHandle()->setStyleSheet(qsb + qsbq);
237 if (sdc.IsOk()) sdc.GetTextExtent(_T(
"W"), NULL, &metric, NULL, NULL, qFont);
240 m_pMyLinkList = NULL;
241 SetColorScheme((ColorScheme)0);
242 m_pRoutePoint = NULL;
243 m_SaveDefaultDlg = NULL;
247 Connect(wxEVT_ACTIVATE, wxActivateEventHandler(MarkInfoDlg::OnActivate), NULL,
252 void MarkInfoDlg::OnActivate(wxActivateEvent& event) {
253 DIALOG_PARENT* pWin = wxDynamicCast(event.GetEventObject(), DIALOG_PARENT);
254 long int style = pWin->GetWindowStyle();
255 if (event.GetActive())
256 pWin->SetWindowStyle(style | wxSTAY_ON_TOP);
258 pWin->SetWindowStyle(style ^ wxSTAY_ON_TOP);
261 void MarkInfoDlg::initialize_images(
void) {
262 wxString iconDir = g_Platform->GetSharedDataDir() + _T(
"uidata/MUI_flat/");
263 _img_MUI_settings_svg = LoadSVG(iconDir + _T(
"MUI_settings.svg"),
264 2 * GetCharHeight(), 2 * GetCharHeight());
267 wxBitmap tide = style->GetIcon(_T(
"tidesml"));
268 wxImage tide1 = tide.ConvertToImage();
269 wxImage tide1s = tide1.Scale(m_sizeMetric * 3 / 2, m_sizeMetric * 3 / 2,
270 wxIMAGE_QUALITY_HIGH);
271 m_bmTide = wxBitmap(tide1s);
276 void MarkInfoDlg::Create() {
277 wxFont* qFont = GetOCPNScaledFont(_(
"Dialog"));
279 m_sizeMetric = GetCharHeight();
284 wxString wqs = getFontQtStylesheet(qFont);
285 wxCharBuffer sbuf = wqs.ToUTF8();
286 QString qsb = QString(sbuf.data());
288 QString qsbq = getAdjustedDialogStyleSheet();
290 this->GetHandle()->setStyleSheet(qsb + qsbq);
294 sdc.GetTextExtent(_T(
"W"), NULL, &m_sizeMetric, NULL, NULL, qFont);
301 bSizer1 =
new wxBoxSizer(wxVERTICAL);
303 bSizer1->SetSizeHints(
this);
305 m_notebookProperties =
306 new wxNotebook(
this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0);
308 m_panelBasicProperties =
new wxScrolledWindow(
309 m_notebookProperties, wxID_ANY, wxDefaultPosition, wxDefaultSize,
310 wxHSCROLL | wxVSCROLL | wxTAB_TRAVERSAL);
312 m_panelBasicProperties->GetHandle()->setStyleSheet(
313 getAdjustedDialogStyleSheet());
316 m_panelBasicProperties->SetScrollRate(0, 2);
318 m_notebookProperties->AddPage(m_panelBasicProperties, _(
"Basic"),
true);
320 bSizerBasicProperties =
new wxBoxSizer(wxVERTICAL);
321 m_panelBasicProperties->SetSizer(bSizerBasicProperties);
323 wxStaticBoxSizer* sbSizerProperties;
324 sbSizerProperties =
new wxStaticBoxSizer(
325 new wxStaticBox(m_panelBasicProperties, wxID_ANY, _(
"Properties")),
328 wxBoxSizer* bSizerInnerProperties =
new wxBoxSizer(wxHORIZONTAL);
336 wxBoxSizer* bSizerTextProperties;
337 bSizerTextProperties =
new wxBoxSizer(wxVERTICAL);
339 m_staticTextLayer =
new wxStaticText(
340 m_panelBasicProperties, wxID_ANY,
341 _(
"This waypoint is part of a layer and can't be edited"),
342 wxDefaultPosition, wxDefaultSize, 0);
343 m_staticTextLayer->Enable(
false);
345 bSizerTextProperties->Add(m_staticTextLayer, 0, wxALL, 5);
347 wxBoxSizer* bSizerName;
348 bSizerName =
new wxBoxSizer(wxHORIZONTAL);
351 new wxStaticText(m_panelBasicProperties, wxID_ANY, _(
"Name"),
352 wxDefaultPosition, wxDefaultSize, 0);
354 bSizerName->Add(m_staticTextName, 0, wxALL | wxALIGN_CENTER_VERTICAL, 5);
356 wxBoxSizer* bSizerNameValue =
new wxBoxSizer(wxVERTICAL);
358 m_checkBoxShowName =
new wxCheckBox(
359 m_panelBasicProperties, wxID_ANY, wxEmptyString, wxDefaultPosition,
361 wxALIGN_CENTER_VERTICAL);
362 bSizerName->Add(m_checkBoxShowName, 0, wxALL | wxALIGN_CENTER_VERTICAL, 5);
364 m_textName =
new wxTextCtrl(m_panelBasicProperties, wxID_ANY, wxEmptyString,
365 wxDefaultPosition, wxDefaultSize, 0);
366 bSizerNameValue->Add(m_textName, 0, wxALL | wxEXPAND, 5);
367 bSizerName->Add(bSizerNameValue, 1, wxEXPAND, 5);
368 bSizerTextProperties->Add(bSizerName, 0, wxEXPAND, 5);
371 wxBoxSizer* bSizer8 =
new wxBoxSizer(wxHORIZONTAL);
372 bSizerTextProperties->Add(bSizer8, 0, wxEXPAND, 5);
375 new wxStaticText(m_panelBasicProperties, wxID_ANY, _(
"Icon"),
376 wxDefaultPosition, wxDefaultSize, 0);
377 bSizer8->Add(m_staticTextIcon, 0, wxALL | wxALIGN_CENTER_VERTICAL, 5);
379 m_bcomboBoxIcon =
new OCPNIconCombo(m_panelBasicProperties, wxID_ANY,
380 _(
"Combo!"), wxDefaultPosition,
381 wxDefaultSize, 0, NULL, wxCB_READONLY);
383 m_bcomboBoxIcon->SetPopupMaxHeight(::wxGetDisplaySize().y / 2);
386 int min_size = m_sizeMetric * 2;
387 min_size = wxMax(min_size, (32 * g_MarkScaleFactorExp) + 4);
388 m_bcomboBoxIcon->SetMinSize(wxSize(-1, min_size));
390 bSizer8->Add(m_bcomboBoxIcon, 1, wxALL, 5);
392 bSizerTextProperties->AddSpacer(5);
394 wxFlexGridSizer* LLGrid =
new wxFlexGridSizer(0, 2, 1, 1);
395 LLGrid->AddGrowableCol(1);
396 bSizerTextProperties->Add(LLGrid, 0, wxEXPAND, 0);
399 GetTextExtent(_T(
"179 59.9999 W"), &w, &h);
401 wxGridBagSizer* gridBagSizer =
new wxGridBagSizer(5, 5);
403 m_staticTextLatitude =
404 new wxStaticText(m_panelBasicProperties, wxID_ANY, _(
"Latitude"));
405 gridBagSizer->Add(m_staticTextLatitude, wxGBPosition(0, 0), wxDefaultSpan,
406 wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL, 5);
409 new wxTextCtrl(m_panelBasicProperties, wxID_ANY, wxEmptyString,
410 wxDefaultPosition, wxSize(w + 20, -1), 0);
411 gridBagSizer->Add(m_textLatitude, wxGBPosition(0, 1), wxDefaultSpan,
412 wxALIGN_LEFT | wxEXPAND, 5);
414 m_staticTextLongitude =
415 new wxStaticText(m_panelBasicProperties, wxID_ANY, _(
"Longitude"));
416 gridBagSizer->Add(m_staticTextLongitude, wxGBPosition(0, 2), wxDefaultSpan,
417 wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL, 5);
420 new wxTextCtrl(m_panelBasicProperties, wxID_ANY, wxEmptyString,
421 wxDefaultPosition, wxSize(w + 20, -1), 0);
422 gridBagSizer->Add(m_textLongitude, wxGBPosition(0, 3), wxDefaultSpan,
423 wxALIGN_LEFT | wxEXPAND, 5);
425 bSizerTextProperties->Add(gridBagSizer, 0, wxEXPAND | wxALL, 5);
427 m_staticTextDescription =
428 new wxStaticText(m_panelBasicProperties, wxID_ANY, _(
"Description"),
429 wxDefaultPosition, wxDefaultSize, 0);
430 bSizerTextProperties->Add(m_staticTextDescription, 0, wxALL, 5);
432 wxBoxSizer* bSizer14;
433 bSizer14 =
new wxBoxSizer(wxHORIZONTAL);
435 m_textDescription =
new wxTextCtrl(
436 m_panelBasicProperties, ID_DESCR_CTR_BASIC, wxEmptyString,
437 wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE | wxTE_READONLY);
438 m_textDescription->SetMinSize(wxSize(-1, 80));
439 bSizer14->Add(m_textDescription, 1, wxALL | wxEXPAND, 5);
441 m_buttonExtDescription =
442 new wxButton(m_panelBasicProperties, ID_BTN_DESC_BASIC, _T(
"..."),
443 wxDefaultPosition, wxSize(GetCharHeight() * 15 / 10, -1), 0);
444 bSizer14->Add(m_buttonExtDescription, 0, wxALL | wxEXPAND, 5);
446 bSizerTextProperties->Add(bSizer14, 1, wxEXPAND, 5);
448 bSizerInnerProperties->Add(bSizerTextProperties, 1, wxEXPAND, 5);
450 sbSizerProperties->Add(bSizerInnerProperties, 1, wxEXPAND, 5);
452 bSizerBasicProperties->Add(sbSizerProperties, 2, wxALL | wxEXPAND, 5);
455 wxStaticText* staticTextLinks =
456 new wxStaticText(m_panelBasicProperties, wxID_ANY, _(
"Links"),
457 wxDefaultPosition, wxDefaultSize, 0);
458 bSizerTextProperties->Add(staticTextLinks, 0, wxALL, 5);
460 wxBoxSizer* bSizer19 =
new wxBoxSizer(wxHORIZONTAL);
461 bSizerTextProperties->Add(bSizer19, 1, wxEXPAND, 5);
463 m_htmlList =
new wxSimpleHtmlListBox(m_panelBasicProperties, wxID_ANY,
464 wxDefaultPosition, wxDefaultSize, 0);
465 bSizer19->Add(m_htmlList, 1, wxALL | wxEXPAND, 5);
468 sbSizerLinks =
new wxStaticBoxSizer(
469 new wxStaticBox(m_panelBasicProperties, wxID_ANY, _(
"Links")),
471 bSizerBasicProperties->Add(sbSizerLinks, 1, wxALL | wxEXPAND, 5);
473 m_scrolledWindowLinks =
474 new wxScrolledWindow(m_panelBasicProperties, wxID_ANY, wxDefaultPosition,
475 wxSize(-1, 100), wxHSCROLL | wxVSCROLL);
476 m_scrolledWindowLinks->SetMinSize(wxSize(-1, 80));
477 m_scrolledWindowLinks->SetScrollRate(2, 2);
478 sbSizerLinks->Add(m_scrolledWindowLinks, 1, wxEXPAND | wxALL, 5);
480 bSizerLinks =
new wxBoxSizer(wxVERTICAL);
481 m_scrolledWindowLinks->SetSizer(bSizerLinks);
483 m_menuLink =
new wxMenu();
484 wxMenuItem* m_menuItemDelete;
485 m_menuItemDelete =
new wxMenuItem(m_menuLink, wxID_ANY, wxString(_(
"Delete")),
486 wxEmptyString, wxITEM_NORMAL);
487 m_menuLink->Append(m_menuItemDelete);
489 wxMenuItem* m_menuItemEdit;
490 m_menuItemEdit =
new wxMenuItem(m_menuLink, wxID_ANY, wxString(_(
"Edit")),
491 wxEmptyString, wxITEM_NORMAL);
492 m_menuLink->Append(m_menuItemEdit);
494 wxMenuItem* m_menuItemAdd;
495 m_menuItemAdd =
new wxMenuItem(m_menuLink, wxID_ANY, wxString(_(
"Add new")),
496 wxEmptyString, wxITEM_NORMAL);
497 m_menuLink->Append(m_menuItemAdd);
499 wxBoxSizer* bSizer9 =
new wxBoxSizer(wxHORIZONTAL);
502 new wxButton(m_panelBasicProperties, wxID_ANY, _(
"Add new"),
503 wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT);
504 bSizer9->Add(m_buttonAddLink, 0, wxALL, 5);
506 m_buttonAddLink->Connect(wxEVT_COMMAND_BUTTON_CLICKED,
507 wxCommandEventHandler(MarkInfoDlg::OnAddLink), NULL,
510 sbSizerLinks->Add(bSizer9, 0, wxEXPAND, 5);
515 new wxPanel(m_notebookProperties, wxID_ANY, wxDefaultPosition,
516 wxDefaultSize, wxTAB_TRAVERSAL);
517 wxBoxSizer* bSizer15;
518 bSizer15 =
new wxBoxSizer(wxVERTICAL);
520 m_textCtrlExtDescription =
521 new wxTextCtrl(m_panelDescription, ID_DESCR_CTR_DESC, wxEmptyString,
522 wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE);
523 bSizer15->Add(m_textCtrlExtDescription, 1, wxALL | wxEXPAND, 5);
525 m_panelDescription->SetSizer(bSizer15);
526 m_notebookProperties->AddPage(m_panelDescription, _(
"Description"),
false);
531 m_panelExtendedProperties =
new wxScrolledWindow(
532 m_notebookProperties, wxID_ANY, wxDefaultPosition, wxDefaultSize,
533 wxHSCROLL | wxVSCROLL | wxTAB_TRAVERSAL);
535 m_panelExtendedProperties->GetHandle()->setStyleSheet(
536 getAdjustedDialogStyleSheet());
539 m_panelExtendedProperties->SetScrollRate(0, 2);
541 wxBoxSizer* fSizerExtProperties =
new wxBoxSizer(wxVERTICAL);
542 m_panelExtendedProperties->SetSizer(fSizerExtProperties);
543 m_notebookProperties->AddPage(m_panelExtendedProperties, _(
"Extended"),
546 sbSizerExtProperties =
new wxStaticBoxSizer(
547 wxVERTICAL, m_panelExtendedProperties, _(
"Extended Properties"));
548 wxFlexGridSizer* gbSizerInnerExtProperties =
new wxFlexGridSizer(3, 0, 0);
549 gbSizerInnerExtProperties->AddGrowableCol(2);
550 gbSizerInnerExtProperties->SetFlexibleDirection(wxBOTH);
551 gbSizerInnerExtProperties->SetNonFlexibleGrowMode(wxFLEX_GROWMODE_SPECIFIED);
553 m_checkBoxVisible =
new wxCheckBox(sbSizerExtProperties->GetStaticBox(),
554 ID_CHECKBOX_VIS_EXT, wxEmptyString);
555 gbSizerInnerExtProperties->Add(m_checkBoxVisible);
556 wxStaticText* m_staticTextVisible =
new wxStaticText(
557 sbSizerExtProperties->GetStaticBox(), wxID_ANY, _(
"Show on chart"));
558 gbSizerInnerExtProperties->Add(m_staticTextVisible);
559 gbSizerInnerExtProperties->Add(0, 0, 1, wxEXPAND, 0);
561 m_checkBoxScaMin =
new wxCheckBox(sbSizerExtProperties->GetStaticBox(),
562 ID_CHECKBOX_SCAMIN_VIS, wxEmptyString);
563 gbSizerInnerExtProperties->Add(m_checkBoxScaMin, 0, wxALIGN_CENTRE_VERTICAL,
565 m_staticTextScaMin =
new wxStaticText(sbSizerExtProperties->GetStaticBox(),
566 wxID_ANY, _(
"Show at scale > 1 :"));
567 gbSizerInnerExtProperties->Add(m_staticTextScaMin, 0, wxALIGN_CENTRE_VERTICAL,
569 m_textScaMin =
new wxTextCtrl(sbSizerExtProperties->GetStaticBox(), wxID_ANY);
570 gbSizerInnerExtProperties->Add(m_textScaMin, 0, wxALL | wxEXPAND, 5);
572 m_checkBoxShowNameExt =
573 new wxCheckBox(sbSizerExtProperties->GetStaticBox(),
574 ID_SHOWNAMECHECKBOX_EXT, wxEmptyString);
575 gbSizerInnerExtProperties->Add(m_checkBoxShowNameExt);
576 m_staticTextShowNameExt =
new wxStaticText(
577 sbSizerExtProperties->GetStaticBox(), wxID_ANY, _(
"Show waypoint name"));
578 gbSizerInnerExtProperties->Add(m_staticTextShowNameExt);
579 gbSizerInnerExtProperties->Add(0, 0, 1, wxEXPAND, 0);
581 sbRangeRingsExtProperties =
new wxStaticBoxSizer(
582 wxVERTICAL, sbSizerExtProperties->GetStaticBox(), _(
"Range rings"));
583 wxFlexGridSizer* gbRRExtProperties =
new wxFlexGridSizer(4, 0, 0);
584 gbRRExtProperties->AddGrowableCol(0);
585 gbRRExtProperties->AddGrowableCol(1);
586 gbRRExtProperties->AddGrowableCol(3);
587 m_staticTextRR1 =
new wxStaticText(sbSizerExtProperties->GetStaticBox(),
588 wxID_ANY, _(
"Number"));
589 gbRRExtProperties->Add(m_staticTextRR1, 0, wxLEFT, 5);
590 m_staticTextRR2 =
new wxStaticText(sbSizerExtProperties->GetStaticBox(),
591 wxID_ANY, _(
"Distance"));
592 gbRRExtProperties->Add(m_staticTextRR2, 0, wxLEFT, 5);
593 gbRRExtProperties->Add(0, 0, 1, wxEXPAND, 5);
594 m_staticTextRR4 =
new wxStaticText(sbSizerExtProperties->GetStaticBox(),
595 wxID_ANY, _(
"Color"));
596 gbRRExtProperties->Add(m_staticTextRR4, 0, wxLEFT, 5);
598 wxString rrAlt[] = {_(
"None"), _T(
"1" ), _T(
"2" ), _T(
"3" ),
599 _T(
"4" ), _T(
"5" ), _T(
"6" ), _T(
"7" ),
600 _T(
"8" ), _T(
"9" ), _T(
"10" )};
601 m_ChoiceWaypointRangeRingsNumber =
602 new wxChoice(sbSizerExtProperties->GetStaticBox(), ID_WPT_RANGERINGS_NO,
603 wxDefaultPosition, wxDefaultSize, 11, rrAlt);
605 gbRRExtProperties->Add(m_ChoiceWaypointRangeRingsNumber, 0, wxALL | wxEXPAND,
607 m_textWaypointRangeRingsStep =
608 new wxTextCtrl(sbSizerExtProperties->GetStaticBox(), wxID_ANY, _(
"0.05"),
609 wxDefaultPosition, wxDefaultSize, 0);
610 gbRRExtProperties->Add(m_textWaypointRangeRingsStep, 0, wxALL | wxEXPAND, 5);
612 wxString pDistUnitsStrings[] = {_(
"NMi"), _(
"km")};
614 new wxChoice(sbSizerExtProperties->GetStaticBox(), wxID_ANY,
615 wxDefaultPosition, wxDefaultSize, 2, pDistUnitsStrings);
616 gbRRExtProperties->Add(m_RangeRingUnits, 0, wxALIGN_CENTRE_VERTICAL, 0);
618 m_PickColor =
new wxColourPickerCtrl(sbSizerExtProperties->GetStaticBox(),
619 wxID_ANY, wxColour(0, 0, 0),
620 wxDefaultPosition, wxDefaultSize, 0);
621 gbRRExtProperties->Add(m_PickColor, 0, wxALL | wxEXPAND, 5);
622 sbRangeRingsExtProperties->Add(
623 gbRRExtProperties, 1,
624 wxLEFT | wxTOP | wxEXPAND | wxALIGN_LEFT | wxALIGN_TOP, 5);
626 sbSizerExtProperties->GetStaticBox()->Layout();
628 wxFlexGridSizer* gbSizerInnerExtProperties2 =
new wxFlexGridSizer(2, 0, 0);
629 gbSizerInnerExtProperties2->AddGrowableCol(1);
632 new wxStaticText(sbSizerExtProperties->GetStaticBox(), wxID_ANY,
633 _(
"GUID"), wxDefaultPosition, wxDefaultSize, 0);
634 gbSizerInnerExtProperties2->Add(m_staticTextGuid, 0, wxALIGN_CENTRE_VERTICAL,
636 m_textCtrlGuid =
new wxTextCtrl(sbSizerExtProperties->GetStaticBox(),
637 wxID_ANY, wxEmptyString, wxDefaultPosition,
638 wxDefaultSize, wxTE_READONLY);
639 m_textCtrlGuid->SetEditable(
false);
640 gbSizerInnerExtProperties2->Add(m_textCtrlGuid, 0, wxALL | wxEXPAND, 5);
642 wxFlexGridSizer* gbSizerInnerExtProperties1 =
new wxFlexGridSizer(3, 0, 0);
643 gbSizerInnerExtProperties1->AddGrowableCol(1);
645 m_staticTextTideStation =
646 new wxStaticText(sbSizerExtProperties->GetStaticBox(), wxID_ANY,
647 _(
"Tide Station"), wxDefaultPosition, wxDefaultSize, 0);
648 gbSizerInnerExtProperties1->Add(m_staticTextTideStation, 0,
649 wxALIGN_CENTRE_VERTICAL, 5);
652 m_choiceTideChoices.Add(_T(
" "));
653 m_comboBoxTideStation =
654 new wxChoice(sbSizerExtProperties->GetStaticBox(), wxID_ANY,
655 wxDefaultPosition, wxDefaultSize, m_choiceTideChoices);
657 gbSizerInnerExtProperties1->Add(
658 m_comboBoxTideStation, 0, wxALL | wxEXPAND | wxALIGN_CENTRE_VERTICAL, 5);
661 m_comboBoxTideStation =
new wxComboBox(
662 sbSizerExtProperties->GetStaticBox(), wxID_ANY, wxEmptyString,
663 wxDefaultPosition, wxDefaultSize, 0, NULL, wxCB_READONLY);
664 gbSizerInnerExtProperties1->Add(
665 m_comboBoxTideStation, 0, wxALL | wxEXPAND | wxALIGN_CENTRE_VERTICAL, 5);
668 m_buttonShowTides =
new wxBitmapButton(
669 sbSizerExtProperties->GetStaticBox(), ID_BTN_SHOW_TIDES, m_bmTide,
670 wxDefaultPosition, m_bmTide.GetSize(), 0);
671 gbSizerInnerExtProperties1->Add(m_buttonShowTides, 0,
672 wxALL | wxALIGN_CENTRE_VERTICAL, 5);
674 m_staticTextArrivalRadius =
new wxStaticText(
675 sbSizerExtProperties->GetStaticBox(), wxID_ANY, _(
"Arrival Radius"));
676 gbSizerInnerExtProperties1->Add(m_staticTextArrivalRadius, 0,
677 wxALIGN_CENTRE_VERTICAL, 0);
678 m_textArrivalRadius =
679 new wxTextCtrl(sbSizerExtProperties->GetStaticBox(), wxID_ANY,
680 wxEmptyString, wxDefaultPosition, wxDefaultSize, 0);
681 gbSizerInnerExtProperties1->Add(m_textArrivalRadius, 0, wxALL | wxEXPAND, 5);
682 m_staticTextArrivalUnits =
683 new wxStaticText(sbSizerExtProperties->GetStaticBox(), wxID_ANY,
684 wxEmptyString, wxDefaultPosition, wxDefaultSize, 0);
685 gbSizerInnerExtProperties1->Add(m_staticTextArrivalUnits, 0,
686 wxALIGN_CENTRE_VERTICAL, 0);
688 m_staticTextPlSpeed =
689 new wxStaticText(sbSizerExtProperties->GetStaticBox(), wxID_ANY,
690 _(
"Planned Speed"), wxDefaultPosition, wxDefaultSize, 0);
691 gbSizerInnerExtProperties1->Add(m_staticTextPlSpeed, 0,
692 wxALIGN_CENTRE_VERTICAL, 0);
694 new wxTextCtrl(sbSizerExtProperties->GetStaticBox(), wxID_ANY,
695 wxEmptyString, wxDefaultPosition, wxDefaultSize, 0);
696 gbSizerInnerExtProperties1->Add(m_textCtrlPlSpeed, 0, wxALL | wxEXPAND, 5);
697 m_staticTextPlSpeedUnits =
698 new wxStaticText(sbSizerExtProperties->GetStaticBox(), wxID_ANY,
699 getUsrSpeedUnit(), wxDefaultPosition, wxDefaultSize, 0);
700 gbSizerInnerExtProperties1->Add(m_staticTextPlSpeedUnits, 0,
701 wxALIGN_CENTRE_VERTICAL, 0);
703 m_staticTextEta =
new wxStaticText(sbSizerExtProperties->GetStaticBox(),
704 wxID_ANY, _(
"ETD (UTC)"));
705 gbSizerInnerExtProperties1->Add(m_staticTextEta, 0, wxALIGN_CENTRE_VERTICAL,
707 wxBoxSizer* bsTimestamp =
new wxBoxSizer(wxHORIZONTAL);
708 m_cbEtaPresent =
new wxCheckBox(sbSizerExtProperties->GetStaticBox(),
709 wxID_ANY, wxEmptyString);
710 bsTimestamp->Add(m_cbEtaPresent, 0, wxALL | wxEXPAND, 5);
711 m_EtaDatePickerCtrl =
new wxDatePickerCtrl(
712 sbSizerExtProperties->GetStaticBox(), ID_ETA_DATEPICKERCTRL,
713 wxDefaultDateTime, wxDefaultPosition, wxDefaultSize, wxDP_DEFAULT,
715 bsTimestamp->Add(m_EtaDatePickerCtrl, 0, wxALL | wxEXPAND, 5);
718 m_EtaTimePickerCtrl =
719 new TimeCtrl(sbSizerExtProperties->GetStaticBox(), ID_ETA_TIMEPICKERCTRL,
720 wxDefaultDateTime, wxDefaultPosition, wxDefaultSize);
722 m_EtaTimePickerCtrl =
new wxTimePickerCtrl(
723 sbSizerExtProperties->GetStaticBox(), ID_ETA_TIMEPICKERCTRL,
724 wxDefaultDateTime, wxDefaultPosition, wxDefaultSize, wxDP_DEFAULT,
728 bsTimestamp->Add(m_EtaTimePickerCtrl, 0, wxALL | wxEXPAND, 5);
729 gbSizerInnerExtProperties1->Add(bsTimestamp, 0, wxEXPAND, 0);
730 sbSizerExtProperties->Add(gbSizerInnerExtProperties, 0, wxALL | wxEXPAND, 5);
731 sbSizerExtProperties->Add(sbRangeRingsExtProperties, 0, wxALL | wxEXPAND, 5);
732 sbSizerExtProperties->Add(gbSizerInnerExtProperties2, 0, wxALL | wxEXPAND, 5);
733 sbSizerExtProperties->Add(gbSizerInnerExtProperties1, 0, wxALL | wxEXPAND, 5);
735 fSizerExtProperties->Add(sbSizerExtProperties, 1, wxALL | wxEXPAND);
738 bSizer1->Add(m_notebookProperties, 1, wxEXPAND | wxALL, 5);
740 wxBoxSizer* btnSizer =
new wxBoxSizer(wxHORIZONTAL);
741 bSizer1->Add(btnSizer, 0, wxEXPAND, 0);
744 new wxBitmapButton(
this, ID_DEFAULT, _img_MUI_settings_svg,
745 wxDefaultPosition, _img_MUI_settings_svg.GetSize(), 0);
746 btnSizer->Add(DefaultsBtn, 0, wxALL | wxALIGN_LEFT | wxALIGN_BOTTOM, 5);
747 btnSizer->Add(0, 0, 1, wxEXPAND);
749 m_sdbSizerButtons =
new wxStdDialogButtonSizer();
750 m_sdbSizerButtons->AddButton(
new wxButton(
this, wxID_OK));
751 m_sdbSizerButtons->AddButton(
new wxButton(
this, wxID_CANCEL, _(
"Cancel")));
752 m_sdbSizerButtons->Realize();
753 btnSizer->Add(m_sdbSizerButtons, 0, wxALL, 5);
758 m_textLatitude->Connect(
760 wxCommandEventHandler(MarkInfoDlg::OnRightClickLatLon), NULL,
this);
761 m_textLongitude->Connect(
763 wxCommandEventHandler(MarkInfoDlg::OnRightClickLatLon), NULL,
this);
765 m_htmlList->Connect(wxEVT_RIGHT_DOWN,
766 wxMouseEventHandler(MarkInfoDlg::m_htmlListContextMenu),
770 m_notebookProperties->Connect(
771 wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED,
772 wxNotebookEventHandler(MarkInfoDlg::OnNotebookPageChanged), NULL,
this);
777 m_comboBoxTideStation->Connect(
778 wxEVT_COMMAND_COMBOBOX_SELECTED,
779 wxCommandEventHandler(MarkInfoDlg::OnTideStationCombobox), NULL,
this);
782 void MarkInfoDlg::OnClose(wxCloseEvent& event) {
785 if (m_pRoutePoint) m_pRoutePoint->m_bRPIsBeingEdited =
false;
788 #define TIDESTATION_BATCH_SIZE 10
790 void MarkInfoDlg::OnTideStationCombobox(wxCommandEvent& event) {
791 int count = m_comboBoxTideStation->GetCount();
792 int sel = m_comboBoxTideStation->GetSelection();
793 if (sel == count - 1) {
796 for (
auto ts : m_tss) {
797 if (i == count + TIDESTATION_BATCH_SIZE) {
801 n = wxString::FromUTF8(ts.second->IDX_station_name);
802 m_comboBoxTideStation->Append(n);
809 void MarkInfoDlg::OnNotebookPageChanged(wxNotebookEvent& event) {
810 if (event.GetSelection() == EXTENDED_PROP_PAGE) {
811 if (m_lasttspos.IsSameAs(m_textLatitude->GetValue() +
812 m_textLongitude->GetValue())) {
815 m_lasttspos = m_textLatitude->GetValue() + m_textLongitude->GetValue();
816 double lat = fromDMM(m_textLatitude->GetValue());
817 double lon = fromDMM(m_textLongitude->GetValue());
818 m_tss = ptcmgr->GetStationsForLL(lat, lon);
819 wxString s = m_comboBoxTideStation->GetStringSelection();
822 m_comboBoxTideStation->Clear();
823 m_comboBoxTideStation->Append(wxEmptyString);
824 for (
auto ts : m_tss) {
825 if (i == TIDESTATION_BATCH_SIZE) {
829 n = wxString::FromUTF8(ts.second->IDX_station_name);
830 m_comboBoxTideStation->Append(n);
832 m_comboBoxTideStation->SetSelection(i);
835 if (m_comboBoxTideStation->GetStringSelection() != s) {
836 m_comboBoxTideStation->Insert(s, 1);
837 m_comboBoxTideStation->SetSelection(1);
842 void MarkInfoDlg::RecalculateSize(
void) {
847 wxSize dsize = GetParent()->GetClientSize();
851 esize.x = GetCharHeight() * 20;
852 esize.y = GetCharHeight() * 40;
855 esize.y = wxMin(esize.y, dsize.y - (2 * GetCharHeight()));
856 esize.x = wxMin(esize.x, dsize.x - (1 * GetCharHeight()));
857 SetSize(wxSize(esize.x, esize.y));
860 wxSize fsize = GetSize();
861 fsize.y = wxMin(fsize.y, dsize.y - (2 * GetCharHeight()));
862 fsize.x = wxMin(fsize.x, dsize.x - (1 * GetCharHeight()));
866 fsize.y = wxMin(fsize.y, (25 * GetCharHeight()));
868 SetSize(wxSize(-1, fsize.y));
870 m_defaultClientSize = GetClientSize();
873 wxSize dsize = GetParent()->GetClientSize();
874 SetSize(-1, wxMax(GetSize().y, dsize.y / 1.5));
878 MarkInfoDlg::~MarkInfoDlg() {
880 m_textLatitude->Disconnect(
882 wxCommandEventHandler(MarkInfoDlg::OnRightClickLatLon), NULL,
this);
883 m_textLongitude->Disconnect(
885 wxCommandEventHandler(MarkInfoDlg::OnRightClickLatLon), NULL,
this);
887 m_htmlList->Disconnect(
888 wxEVT_RIGHT_DOWN, wxMouseEventHandler(MarkInfoDlg::m_htmlListContextMenu),
893 m_notebookProperties->Disconnect(
894 wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED,
895 wxNotebookEventHandler(MarkInfoDlg::OnNotebookPageChanged), NULL,
this);
896 m_EtaTimePickerCtrl->Disconnect(
897 wxEVT_TIME_CHANGED, wxDateEventHandler(MarkInfoDlg::OnTimeChanged), NULL,
899 m_EtaDatePickerCtrl->Disconnect(
900 wxEVT_DATE_CHANGED, wxDateEventHandler(MarkInfoDlg::OnTimeChanged), NULL,
904 androidEnableBackButton(
true);
908 void MarkInfoDlg::InitialFocus(
void) {
909 m_textName->SetFocus();
910 m_textName->SetInsertionPointEnd();
913 void MarkInfoDlg::SetColorScheme(ColorScheme cs) { DimeControl(
this); }
915 void MarkInfoDlg::SetBulkEdit(
bool bBulkEdit) {
916 m_textName->Enable(!bBulkEdit);
917 m_textLatitude->Enable(!bBulkEdit);
918 m_textLongitude->Enable(!bBulkEdit);
919 m_textDescription->Enable(!bBulkEdit);
920 m_textCtrlExtDescription->Enable(!bBulkEdit);
923 void MarkInfoDlg::SetRoutePoints(
const std::vector<RoutePoint*> &points) {
924 m_pRoutePoints = points;
925 SetRoutePoint(m_pRoutePoints[0]);
926 SetBulkEdit(points.size() > 1);
929 void MarkInfoDlg::ClearData() {
930 m_pRoutePoint = NULL;
931 m_pRoutePoints.clear();
935 void MarkInfoDlg::SetRoutePoint(
RoutePoint* pRP) {
938 m_lat_save = m_pRoutePoint->m_lat;
939 m_lon_save = m_pRoutePoint->m_lon;
940 m_IconName_save = m_pRoutePoint->GetIconName();
941 m_bShowName_save = m_pRoutePoint->m_bShowName;
942 m_bIsVisible_save = m_pRoutePoint->m_bIsVisible;
943 m_Name_save = m_pRoutePoint->GetName();
944 m_Description_save = m_pRoutePoint->m_MarkDescription;
945 m_bUseScaMin_save = m_pRoutePoint->GetUseSca();
946 m_iScaminVal_save = m_pRoutePoint->GetScaMin();
948 if (m_pMyLinkList)
delete m_pMyLinkList;
949 m_pMyLinkList =
new HyperlinkList();
950 int NbrOfLinks = m_pRoutePoint->m_HyperlinkList->GetCount();
951 if (NbrOfLinks > 0) {
952 wxHyperlinkListNode* linknode =
953 m_pRoutePoint->m_HyperlinkList->GetFirst();
958 h->DescrText = link->DescrText;
959 h->Link = link->Link;
960 h->LType = link->LType;
962 m_pMyLinkList->Append(h);
964 linknode = linknode->GetNext();
968 SetBulkEdit(m_pRoutePoints.size() > 1);
971 void MarkInfoDlg::UpdateHtmlList() {
973 GetSimpleBox()->Clear();
974 int NbrOfLinks = m_pRoutePoint->m_HyperlinkList->GetCount();
976 if (NbrOfLinks > 0) {
977 wxHyperlinkListNode* linknode = m_pRoutePoint->m_HyperlinkList->GetFirst();
980 wxString s = wxString::Format(wxT(
"<a href='%s'>%s</a>"), link->Link,
982 GetSimpleBox()->AppendString(s);
983 linknode = linknode->GetNext();
988 wxWindowList kids = m_scrolledWindowLinks->GetChildren();
989 for (
unsigned int i = 0; i < kids.GetCount(); i++) {
990 wxWindowListNode* node = kids.Item(i);
991 wxWindow* win = node->GetData();
993 if (win->IsKindOf(CLASSINFO(wxHyperlinkCtrl))) {
994 ((wxHyperlinkCtrl*)win)
995 ->Disconnect(wxEVT_COMMAND_HYPERLINK,
996 wxHyperlinkEventHandler(MarkInfoDlg::OnHyperLinkClick));
997 ((wxHyperlinkCtrl*)win)
998 ->Disconnect(wxEVT_RIGHT_DOWN,
999 wxMouseEventHandler(MarkInfoDlg::m_htmlListContextMenu));
1004 int NbrOfLinks = m_pRoutePoint->m_HyperlinkList->GetCount();
1005 HyperlinkList* hyperlinklist = m_pRoutePoint->m_HyperlinkList;
1006 if (NbrOfLinks > 0) {
1007 wxHyperlinkListNode* linknode = hyperlinklist->GetFirst();
1010 wxString Link = link->Link;
1011 wxString Descr = link->DescrText;
1013 wxHyperlinkCtrl* ctrl =
new wxHyperlinkCtrl(
1014 m_scrolledWindowLinks, wxID_ANY, Descr, Link, wxDefaultPosition,
1015 wxDefaultSize, wxNO_BORDER | wxHL_CONTEXTMENU | wxHL_ALIGN_LEFT);
1016 ctrl->Connect(wxEVT_COMMAND_HYPERLINK,
1017 wxHyperlinkEventHandler(MarkInfoDlg::OnHyperLinkClick),
1019 if (!m_pRoutePoint->m_bIsInLayer)
1020 ctrl->Connect(wxEVT_RIGHT_DOWN,
1021 wxMouseEventHandler(MarkInfoDlg::m_htmlListContextMenu),
1024 bSizerLinks->Add(ctrl, 1, wxALL | wxEXPAND, 5);
1026 linknode = linknode->GetNext();
1031 m_scrolledWindowLinks->Layout();
1035 void MarkInfoDlg::OnHyperLinkClick(wxHyperlinkEvent& event) {
1036 wxString url =
event.GetURL();
1037 url.Replace(_T(
" "), _T(
"%20"));
1038 if (g_Platform) g_Platform->platformLaunchDefaultBrowser(url);
1041 void MarkInfoDlg::OnHtmlLinkClicked(wxHtmlLinkEvent& event) {
1051 wxString cc =
event.GetLinkInfo().GetHref().c_str();
1052 if (cc.Find(_T(
"#")) != wxNOT_FOUND) {
1054 wxString(_T(
"HKEY_CLASSES_ROOT\\HTTP\\shell\\open\\command")));
1055 if (RegKey.Exists()) {
1056 wxString command_line;
1057 RegKey.QueryValue(wxString(_T(
"")), command_line);
1060 command_line.Replace(wxString(_T(
"\"")), wxString(_T(
"")));
1063 int l = command_line.Find(_T(
".exe"));
1064 if (wxNOT_FOUND == l) l = command_line.Find(_T(
".EXE"));
1066 if (wxNOT_FOUND != l) {
1067 wxString cl = command_line.Mid(0, l + 4);
1069 cc.Prepend(_T(
"\""));
1070 cc.Append(_T(
"\""));
1076 wxString url =
event.GetLinkInfo().GetHref().c_str();
1077 url.Replace(_T(
" "), _T(
"%20"));
1078 ::wxLaunchDefaultBrowser(url);
1082 wxString url =
event.GetLinkInfo().GetHref().c_str();
1083 url.Replace(_T(
" "), _T(
"%20"));
1084 if (g_Platform) g_Platform->platformLaunchDefaultBrowser(url);
1090 void MarkInfoDlg::OnDescChangedExt(wxCommandEvent& event) {
1091 if (m_panelDescription->IsShownOnScreen()) {
1092 m_textDescription->ChangeValue(m_textCtrlExtDescription->GetValue());
1096 void MarkInfoDlg::OnDescChangedBasic(wxCommandEvent& event) {
1097 if (m_panelBasicProperties->IsShownOnScreen()) {
1098 m_textCtrlExtDescription->ChangeValue(m_textDescription->GetValue());
1103 void MarkInfoDlg::OnExtDescriptionClick(wxCommandEvent& event) {
1104 long pos = m_textDescription->GetInsertionPoint();
1105 m_notebookProperties->SetSelection(1);
1106 m_textCtrlExtDescription->SetInsertionPoint(pos);
1110 void MarkInfoDlg::OnShowWaypointNameSelectBasic(wxCommandEvent& event) {
1111 if (m_panelBasicProperties->IsShownOnScreen())
1112 m_checkBoxShowNameExt->SetValue(m_checkBoxShowName->GetValue());
1115 void MarkInfoDlg::OnShowWaypointNameSelectExt(wxCommandEvent& event) {
1116 if (m_panelExtendedProperties->IsShownOnScreen())
1117 m_checkBoxShowName->SetValue(m_checkBoxShowNameExt->GetValue());
1121 void MarkInfoDlg::OnWptRangeRingsNoChange(wxCommandEvent& event) {
1122 if (!m_pRoutePoint->m_bIsInLayer) {
1123 m_textWaypointRangeRingsStep->Enable(
1124 (
bool)(m_ChoiceWaypointRangeRingsNumber->GetSelection() != 0));
1125 m_PickColor->Enable(
1126 (
bool)(m_ChoiceWaypointRangeRingsNumber->GetSelection() != 0));
1130 void MarkInfoDlg::OnSelectScaMinExt(wxCommandEvent& event) {
1131 if (!m_pRoutePoint->m_bIsInLayer) {
1132 m_textScaMin->Enable(m_checkBoxScaMin->GetValue());
1136 void MarkInfoDlg::OnPositionCtlUpdated(wxCommandEvent& event) {
1138 double lat = fromDMM(m_textLatitude->GetValue());
1139 double lon = fromDMM(m_textLongitude->GetValue());
1140 if (!m_pRoutePoint->m_bIsInLayer) {
1141 m_pRoutePoint->SetPosition(lat, lon);
1142 pSelect->ModifySelectablePoint(lat, lon, (
void*)m_pRoutePoint,
1143 SELTYPE_ROUTEPOINT);
1146 gFrame->RefreshAllCanvas();
1149 void MarkInfoDlg::m_htmlListContextMenu(wxMouseEvent& event) {
1150 if (m_pRoutePoints.size() > 1)
return;
1154 wxPoint pos =
event.GetPosition();
1155 i_htmlList_item = -1;
1156 for (
int i = 0; i < (int)GetSimpleBox()->GetCount(); i++) {
1157 wxRect rect = GetSimpleBox()->GetItemRect(i);
1158 if (rect.Contains(pos)) {
1159 i_htmlList_item = i;
1164 wxMenu* popup =
new wxMenu();
1165 if ((GetSimpleBox()->GetCount()) > 0 && (i_htmlList_item > -1) &&
1166 (i_htmlList_item < (
int)GetSimpleBox()->GetCount())) {
1167 popup->Append(ID_RCLK_MENU_DELETE_LINK, _(
"Delete"));
1168 popup->Append(ID_RCLK_MENU_EDIT_LINK, _(
"Edit"));
1170 popup->Append(ID_RCLK_MENU_ADD_LINK, _(
"Add New"));
1172 m_contextObject =
event.GetEventObject();
1174 wxEVT_COMMAND_MENU_SELECTED,
1175 wxCommandEventHandler(MarkInfoDlg::On_html_link_popupmenu_Click), NULL,
1181 m_pEditedLink = wxDynamicCast(event.GetEventObject(), wxHyperlinkCtrl);
1183 if (m_pEditedLink) {
1184 wxString url = m_pEditedLink->GetURL();
1185 wxString label = m_pEditedLink->GetLabel();
1186 i_htmlList_item = -1;
1187 HyperlinkList* hyperlinklist = m_pRoutePoint->m_HyperlinkList;
1188 if (hyperlinklist->GetCount() > 0) {
1190 wxHyperlinkListNode* linknode = hyperlinklist->GetFirst();
1193 if (link->DescrText == label) {
1194 i_htmlList_item = i;
1198 linknode = linknode->GetNext();
1203 wxFont sFont = GetOCPNGUIScaledFont(_T(
"Menu"));
1205 wxMenu* popup =
new wxMenu();
1207 wxMenuItem* menuItemDelete =
1208 new wxMenuItem(popup, ID_RCLK_MENU_DELETE_LINK, wxString(_(
"Delete")),
1209 wxEmptyString, wxITEM_NORMAL);
1211 menuItemDelete->SetFont(sFont);
1213 popup->Append(menuItemDelete);
1215 wxMenuItem* menuItemEdit =
1216 new wxMenuItem(popup, ID_RCLK_MENU_EDIT_LINK, wxString(_(
"Edit")),
1217 wxEmptyString, wxITEM_NORMAL);
1219 menuItemEdit->SetFont(sFont);
1221 popup->Append(menuItemEdit);
1224 wxMenuItem* menuItemAdd =
1225 new wxMenuItem(popup, ID_RCLK_MENU_ADD_LINK, wxString(_(
"Add New")),
1226 wxEmptyString, wxITEM_NORMAL);
1228 menuItemAdd->SetFont(sFont);
1230 popup->Append(menuItemAdd);
1232 m_contextObject =
event.GetEventObject();
1234 wxEVT_COMMAND_MENU_SELECTED,
1235 wxCommandEventHandler(MarkInfoDlg::On_html_link_popupmenu_Click), NULL,
1237 wxPoint p = m_scrolledWindowLinks->GetPosition();
1238 p.x += m_scrolledWindowLinks->GetSize().x / 2;
1239 PopupMenu(popup, p);
1262 void MarkInfoDlg::OnAddLink(wxCommandEvent& event) {
1263 wxCommandEvent evt(wxEVT_COMMAND_MENU_SELECTED);
1264 evt.SetId(ID_RCLK_MENU_ADD_LINK);
1266 On_html_link_popupmenu_Click(evt);
1269 void MarkInfoDlg::On_html_link_popupmenu_Click(wxCommandEvent& event) {
1270 switch (event.GetId()) {
1271 case ID_RCLK_MENU_DELETE_LINK: {
1272 wxHyperlinkListNode* node =
1273 m_pRoutePoint->m_HyperlinkList->Item(i_htmlList_item);
1274 m_pRoutePoint->m_HyperlinkList->DeleteNode(node);
1278 case ID_RCLK_MENU_EDIT_LINK: {
1280 m_pRoutePoint->m_HyperlinkList->Item(i_htmlList_item)->GetData();
1282 LinkPropDlg->m_textCtrlLinkDescription->SetValue(link->DescrText);
1283 LinkPropDlg->m_textCtrlLinkUrl->SetValue(link->Link);
1284 DimeControl(LinkPropDlg);
1285 LinkPropDlg->ShowWindowModalThenDo([
this, LinkPropDlg,
1286 link](
int retcode) {
1287 if (retcode == wxID_OK) {
1288 link->DescrText = LinkPropDlg->m_textCtrlLinkDescription->GetValue();
1289 link->Link = LinkPropDlg->m_textCtrlLinkUrl->GetValue();
1290 m_pRoutePoint->m_HyperlinkList->Item(i_htmlList_item)->SetData(link);
1296 case ID_RCLK_MENU_ADD_LINK: {
1298 LinkPropDlg->m_textCtrlLinkDescription->SetValue(wxEmptyString);
1299 LinkPropDlg->m_textCtrlLinkUrl->SetValue(wxEmptyString);
1300 DimeControl(LinkPropDlg);
1301 LinkPropDlg->ShowWindowModalThenDo([
this, LinkPropDlg](
int retcode) {
1302 if (retcode == wxID_OK) {
1304 link->DescrText = LinkPropDlg->m_textCtrlLinkDescription->GetValue();
1305 link->Link = LinkPropDlg->m_textCtrlLinkUrl->GetValue();
1307 if (link->DescrText == wxEmptyString) {
1308 link->DescrText = link->Link;
1310 if (link->Link == wxEmptyString) {
1313 m_pRoutePoint->m_HyperlinkList->Append(link);
1324 void MarkInfoDlg::OnRightClickLatLon(wxCommandEvent& event) {
1325 wxMenu* popup =
new wxMenu();
1326 popup->Append(ID_RCLK_MENU_COPY, _(
"Copy"));
1327 popup->Append(ID_RCLK_MENU_COPY_LL, _(
"Copy lat/long"));
1328 popup->Append(ID_RCLK_MENU_PASTE, _(
"Paste"));
1329 popup->Append(ID_RCLK_MENU_PASTE_LL, _(
"Paste lat/long"));
1330 m_contextObject =
event.GetEventObject();
1331 popup->Connect(wxEVT_COMMAND_MENU_SELECTED,
1332 wxCommandEventHandler(MarkInfoDlg::OnCopyPasteLatLon), NULL,
1339 void MarkInfoDlg::OnCopyPasteLatLon(wxCommandEvent& event) {
1341 double lat = fromDMM(m_textLatitude->GetValue());
1342 double lon = fromDMM(m_textLongitude->GetValue());
1346 switch (event.GetId()) {
1347 case ID_RCLK_MENU_PASTE: {
1348 if (wxTheClipboard->Open()) {
1349 wxTextDataObject data;
1350 wxTheClipboard->GetData(data);
1351 result = data.GetText();
1352 ((wxTextCtrl*)m_contextObject)->SetValue(result);
1353 wxTheClipboard->Close();
1357 case ID_RCLK_MENU_PASTE_LL: {
1358 if (wxTheClipboard->Open()) {
1359 wxTextDataObject data;
1360 wxTheClipboard->GetData(data);
1361 result = data.GetText();
1365 if (pparse.IsOk()) {
1366 m_textLatitude->SetValue(pparse.GetLatitudeString());
1367 m_textLongitude->SetValue(pparse.GetLongitudeString());
1369 wxTheClipboard->Close();
1373 case ID_RCLK_MENU_COPY: {
1374 result = ((wxTextCtrl*)m_contextObject)->GetValue();
1377 case ID_RCLK_MENU_COPY_LL: {
1378 result << toSDMM(1, lat,
true) << _T(
'\t');
1379 result << toSDMM(2, lon,
true);
1384 if (wxTheClipboard->Open()) {
1385 wxTextDataObject* data =
new wxTextDataObject;
1386 data->SetText(result);
1387 wxTheClipboard->SetData(data);
1388 wxTheClipboard->Close();
1392 void MarkInfoDlg::DefautlBtnClicked(wxCommandEvent& event) {
1394 m_SaveDefaultDlg->Center();
1395 DimeControl(m_SaveDefaultDlg);
1396 int retcode = m_SaveDefaultDlg->ShowModal();
1399 if (retcode == wxID_OK) {
1401 if (m_SaveDefaultDlg->IconCB->GetValue()) {
1403 *pWayPointMan->GetIconKey(m_bcomboBoxIcon->GetSelection());
1405 if (m_SaveDefaultDlg->RangRingsCB->GetValue()) {
1406 g_iWaypointRangeRingsNumber =
1407 m_ChoiceWaypointRangeRingsNumber->GetSelection();
1408 if (m_textWaypointRangeRingsStep->GetValue().ToDouble(&value))
1409 g_fWaypointRangeRingsStep = fromUsrDistance(value, -1);
1410 g_colourWaypointRangeRingsColour = m_PickColor->GetColour();
1412 if (m_SaveDefaultDlg->ArrivalRCB->GetValue())
1413 if (m_textArrivalRadius->GetValue().ToDouble(&value))
1414 g_n_arrival_circle_radius = fromUsrDistance(value, -1);
1415 if (m_SaveDefaultDlg->ScaleCB->GetValue()) {
1416 g_iWpt_ScaMin = wxAtoi(m_textScaMin->GetValue());
1417 g_bUseWptScaMin = m_checkBoxScaMin->GetValue();
1419 if (m_SaveDefaultDlg->NameCB->GetValue()) {
1420 g_bShowWptName = m_checkBoxShowName->GetValue();
1423 m_SaveDefaultDlg = NULL;
1427 void MarkInfoDlg::OnMarkInfoCancelClick(wxCommandEvent& event) {
1428 if (m_pRoutePoint) {
1429 m_pRoutePoint->SetVisible(m_bIsVisible_save);
1430 m_pRoutePoint->SetNameShown(m_bShowName_save);
1431 m_pRoutePoint->SetPosition(m_lat_save, m_lon_save);
1432 m_pRoutePoint->SetIconName(m_IconName_save);
1433 m_pRoutePoint->ReLoadIcon();
1434 m_pRoutePoint->SetName(m_Name_save);
1435 m_pRoutePoint->m_MarkDescription = m_Description_save;
1436 m_pRoutePoint->SetUseSca(m_bUseScaMin_save);
1437 m_pRoutePoint->SetScaMin(m_iScaminVal_save);
1439 m_pRoutePoint->m_HyperlinkList->Clear();
1441 int NbrOfLinks = m_pMyLinkList->GetCount();
1442 if (NbrOfLinks > 0) {
1443 wxHyperlinkListNode* linknode = m_pMyLinkList->GetFirst();
1447 h->DescrText = link->DescrText;
1448 h->Link = link->Link;
1449 h->LType = link->LType;
1451 m_pRoutePoint->m_HyperlinkList->Append(h);
1453 linknode = linknode->GetNext();
1458 m_pRoutePoints.clear();
1460 m_lasttspos.Clear();
1467 delete m_pMyLinkList;
1468 m_pMyLinkList = NULL;
1469 SetClientSize(m_defaultClientSize);
1472 androidEnableBackButton(
true);
1478 void MarkInfoDlg::OnMarkInfoOKClick(wxCommandEvent& event) {
1479 if (m_pRoutePoint) {
1480 m_pRoutePoint->m_wxcWaypointRangeRingsColour = m_PickColor->GetColour();
1482 OnPositionCtlUpdated(event);
1485 m_pRoutePoints.clear();
1493 if (pRouteManagerDialog && pRouteManagerDialog->IsShown())
1494 pRouteManagerDialog->UpdateWptListCtrl();
1496 if (pRoutePropDialog && pRoutePropDialog->IsShown())
1497 pRoutePropDialog->UpdatePoints();
1499 SetClientSize(m_defaultClientSize);
1502 androidEnableBackButton(
true);
1508 bool MarkInfoDlg::UpdateProperties(
bool positionOnly) {
1509 if (m_pRoutePoint) {
1510 m_textLatitude->SetValue(::toSDMM(1, m_pRoutePoint->m_lat));
1511 m_textLongitude->SetValue(::toSDMM(2, m_pRoutePoint->m_lon));
1512 m_lat_save = m_pRoutePoint->m_lat;
1513 m_lon_save = m_pRoutePoint->m_lon;
1514 m_textName->SetValue(m_pRoutePoint->GetName());
1515 m_textDescription->ChangeValue(m_pRoutePoint->m_MarkDescription);
1516 m_textCtrlExtDescription->ChangeValue(m_pRoutePoint->m_MarkDescription);
1517 m_checkBoxShowName->SetValue(m_pRoutePoint->m_bShowName);
1518 m_checkBoxShowNameExt->SetValue(m_pRoutePoint->m_bShowName);
1519 m_checkBoxVisible->SetValue(m_pRoutePoint->m_bIsVisible);
1520 m_checkBoxScaMin->SetValue(m_pRoutePoint->GetUseSca());
1521 m_textScaMin->SetValue(
1522 wxString::Format(wxT(
"%i"), (
int)m_pRoutePoint->GetScaMin()));
1523 m_textCtrlGuid->SetValue(m_pRoutePoint->m_GUID);
1524 m_ChoiceWaypointRangeRingsNumber->SetSelection(
1525 m_pRoutePoint->GetWaypointRangeRingsNumber());
1527 buf.Printf(_T(
"%.3f"),
1528 toUsrDistance(m_pRoutePoint->GetWaypointRangeRingsStep(), -1));
1529 m_textWaypointRangeRingsStep->SetValue(buf);
1530 m_staticTextArrivalUnits->SetLabel(getUsrDistanceUnit());
1531 buf.Printf(_T(
"%.3f"),
1532 toUsrDistance(m_pRoutePoint->GetWaypointArrivalRadius(), -1));
1533 m_textArrivalRadius->SetValue(buf);
1535 int nUnits = m_pRoutePoint->GetWaypointRangeRingsStepUnits();
1536 m_RangeRingUnits->SetSelection(nUnits);
1538 wxColour col = m_pRoutePoint->m_wxcWaypointRangeRingsColour;
1539 m_PickColor->SetColour(col);
1541 if (m_comboBoxTideStation->GetStringSelection() !=
1542 m_pRoutePoint->m_TideStation) {
1543 m_comboBoxTideStation->Clear();
1544 m_comboBoxTideStation->Append(wxEmptyString);
1545 if (!m_pRoutePoint->m_TideStation.IsEmpty()) {
1546 m_comboBoxTideStation->Append(m_pRoutePoint->m_TideStation);
1547 m_comboBoxTideStation->SetSelection(1);
1551 if (m_pRoutePoint->GetPlannedSpeed() > .01) {
1552 m_textCtrlPlSpeed->SetValue(wxString::Format(
1553 "%.1f", toUsrSpeed(m_pRoutePoint->GetPlannedSpeed())));
1555 m_textCtrlPlSpeed->SetValue(wxEmptyString);
1559 etd = m_pRoutePoint->GetManualETD();
1560 if (etd.IsValid()) {
1561 m_cbEtaPresent->SetValue(
true);
1562 m_EtaDatePickerCtrl->SetValue(etd.GetDateOnly());
1563 m_EtaTimePickerCtrl->SetValue(etd);
1565 m_cbEtaPresent->SetValue(
false);
1568 m_staticTextPlSpeed->Show(m_pRoutePoint->m_bIsInRoute);
1569 m_textCtrlPlSpeed->Show(m_pRoutePoint->m_bIsInRoute);
1570 m_staticTextEta->Show(m_pRoutePoint->m_bIsInRoute);
1571 m_EtaDatePickerCtrl->Show(m_pRoutePoint->m_bIsInRoute);
1572 m_EtaTimePickerCtrl->Show(m_pRoutePoint->m_bIsInRoute);
1573 m_cbEtaPresent->Show(m_pRoutePoint->m_bIsInRoute);
1574 m_staticTextPlSpeedUnits->Show(m_pRoutePoint->m_bIsInRoute);
1575 m_staticTextArrivalRadius->Show(m_pRoutePoint->m_bIsInRoute);
1576 m_staticTextArrivalUnits->Show(m_pRoutePoint->m_bIsInRoute);
1577 m_textArrivalRadius->Show(m_pRoutePoint->m_bIsInRoute);
1579 if (positionOnly)
return true;
1582 if (m_pRoutePoint->m_bIsInLayer) {
1583 m_staticTextLayer->Enable();
1584 m_staticTextLayer->Show(
true);
1585 m_textName->SetEditable(
false);
1586 m_textDescription->SetEditable(
false);
1587 m_textCtrlExtDescription->SetEditable(
false);
1588 m_textLatitude->SetEditable(
false);
1589 m_textLongitude->SetEditable(
false);
1590 m_bcomboBoxIcon->Enable(
false);
1591 m_checkBoxShowName->Enable(
false);
1592 m_checkBoxVisible->Enable(
false);
1593 m_textArrivalRadius->SetEditable(
false);
1594 m_checkBoxScaMin->Enable(
false);
1595 m_textScaMin->SetEditable(
false);
1596 m_checkBoxShowNameExt->Enable(
false);
1597 m_ChoiceWaypointRangeRingsNumber->Enable(
false);
1598 m_textWaypointRangeRingsStep->SetEditable(
false);
1599 m_PickColor->Enable(
false);
1600 DefaultsBtn->Enable(
false);
1601 m_EtaDatePickerCtrl->Enable(
false);
1602 m_EtaTimePickerCtrl->Enable(
false);
1603 m_cbEtaPresent->Enable(
false);
1604 m_notebookProperties->SetSelection(0);
1605 m_comboBoxTideStation->Enable(
false);
1607 m_staticTextLayer->Enable(
false);
1608 m_staticTextLayer->Show(
false);
1609 m_textName->SetEditable(
true);
1610 m_textDescription->SetEditable(
true);
1611 m_textCtrlExtDescription->SetEditable(
true);
1612 m_textLatitude->SetEditable(
true);
1613 m_textLongitude->SetEditable(
true);
1614 m_bcomboBoxIcon->Enable(
true);
1615 m_checkBoxShowName->Enable(
true);
1616 m_checkBoxVisible->Enable(
true);
1617 m_textArrivalRadius->SetEditable(
true);
1618 m_checkBoxScaMin->Enable(
true);
1619 m_textScaMin->SetEditable(
true);
1620 m_checkBoxShowNameExt->Enable(
true);
1621 m_ChoiceWaypointRangeRingsNumber->Enable(
true);
1622 m_textWaypointRangeRingsStep->SetEditable(
true);
1623 m_PickColor->Enable(
true);
1624 DefaultsBtn->Enable(
true);
1625 m_EtaDatePickerCtrl->Enable(
true);
1626 m_EtaTimePickerCtrl->Enable(
true);
1627 m_cbEtaPresent->Enable(
true);
1628 m_notebookProperties->SetSelection(0);
1629 m_comboBoxTideStation->Enable(
true);
1633 m_bcomboBoxIcon->Clear();
1635 bool fillCombo = m_bcomboBoxIcon->GetCount() == 0;
1638 for (
int i = 0; i < pWayPointMan->GetNumIcons(); i++) {
1639 wxString* ps = pWayPointMan->GetIconDescription(i);
1641 pWayPointMan->GetIconBitmapForList(i, 2 * GetCharHeight());
1643 m_bcomboBoxIcon->Append(*ps, bmp);
1647 int iconToSelect = -1;
1648 for (
int i = 0; i < pWayPointMan->GetNumIcons(); i++) {
1649 if (*pWayPointMan->GetIconKey(i) == m_pRoutePoint->GetIconName()) {
1651 m_bcomboBoxIcon->Select(iconToSelect);
1656 OnShowWaypointNameSelectBasic(ev);
1657 OnWptRangeRingsNoChange(ev);
1658 OnSelectScaMinExt(ev);
1663 androidEnableBackButton(
false);
1673 void MarkInfoDlg::OnBitmapCombClick(wxCommandEvent& event) {
1674 wxString* icon_name =
1675 pWayPointMan->GetIconKey(m_bcomboBoxIcon->GetSelection());
1676 if (icon_name && icon_name->Length()) m_pRoutePoint->SetIconName(*icon_name);
1677 m_pRoutePoint->ReLoadIcon();
1682 void MarkInfoDlg::ValidateMark(
void) {
1685 wxRoutePointListNode* node = pWayPointMan->GetWaypointList()->GetFirst();
1687 bool b_found =
false;
1690 if (m_pRoutePoint == rp) {
1694 node = node->GetNext();
1696 if (!b_found) m_pRoutePoint = NULL;
1699 bool MarkInfoDlg::SaveChanges() {
1700 if (m_pRoutePoint) {
1701 if (m_pRoutePoints.size() <= 1) {
1702 if (m_pRoutePoint->m_bIsInLayer)
return true;
1705 m_pRoutePoint->SetName(m_textName->GetValue());
1706 m_pRoutePoint->SetWaypointArrivalRadius(m_textArrivalRadius->GetValue());
1707 m_pRoutePoint->SetScaMin(m_textScaMin->GetValue());
1708 m_pRoutePoint->SetUseSca(m_checkBoxScaMin->GetValue());
1709 m_pRoutePoint->m_MarkDescription = m_textDescription->GetValue();
1710 m_pRoutePoint->SetVisible(m_checkBoxVisible->GetValue());
1711 m_pRoutePoint->m_bShowName = m_checkBoxShowName->GetValue();
1712 m_pRoutePoint->SetPosition(fromDMM(m_textLatitude->GetValue()),
1713 fromDMM(m_textLongitude->GetValue()));
1714 wxString* icon_name =
1715 pWayPointMan->GetIconKey(m_bcomboBoxIcon->GetSelection());
1716 if (icon_name && icon_name->Length())
1717 m_pRoutePoint->SetIconName(*icon_name);
1718 m_pRoutePoint->ReLoadIcon();
1719 m_pRoutePoint->SetShowWaypointRangeRings(
1720 (
bool)(m_ChoiceWaypointRangeRingsNumber->GetSelection() != 0));
1721 m_pRoutePoint->SetWaypointRangeRingsNumber(
1722 m_ChoiceWaypointRangeRingsNumber->GetSelection());
1724 if (m_textWaypointRangeRingsStep->GetValue().ToDouble(&value))
1725 m_pRoutePoint->SetWaypointRangeRingsStep(fromUsrDistance(value, -1));
1726 if (m_textArrivalRadius->GetValue().ToDouble(&value))
1727 m_pRoutePoint->SetWaypointArrivalRadius(fromUsrDistance(value, -1));
1729 if (m_RangeRingUnits->GetSelection() != wxNOT_FOUND)
1730 m_pRoutePoint->SetWaypointRangeRingsStepUnits(
1731 m_RangeRingUnits->GetSelection());
1733 m_pRoutePoint->m_TideStation =
1734 m_comboBoxTideStation->GetStringSelection();
1735 if (m_textCtrlPlSpeed->GetValue() == wxEmptyString) {
1736 m_pRoutePoint->SetPlannedSpeed(0.0);
1739 if (m_textCtrlPlSpeed->GetValue().ToDouble(&spd)) {
1740 m_pRoutePoint->SetPlannedSpeed(fromUsrSpeed(spd));
1744 if (m_cbEtaPresent->GetValue()) {
1745 wxDateTime dt = m_EtaDatePickerCtrl->GetValue();
1746 dt.SetHour(m_EtaTimePickerCtrl->GetValue().GetHour());
1747 dt.SetMinute(m_EtaTimePickerCtrl->GetValue().GetMinute());
1748 dt.SetSecond(m_EtaTimePickerCtrl->GetValue().GetSecond());
1750 m_pRoutePoint->SetETD(dt.FormatISOCombined());
1753 m_pRoutePoint->SetETD(wxEmptyString);
1761 if (m_pRoutePoint->m_bIsInRoute) {
1762 bool b_name_is_numeric =
true;
1763 for (
unsigned int i = 0; i < m_pRoutePoint->GetName().Len(); i++) {
1764 if (i < 2 && wxChar(
'N') == m_pRoutePoint->GetName()[0] &&
1765 wxChar(
'M') == m_pRoutePoint->GetName()[1] &&
1766 m_pRoutePoint->GetName().Len() > 2)
1768 if (wxChar(
'0') > m_pRoutePoint->GetName()[i])
1769 b_name_is_numeric =
false;
1770 if (wxChar(
'9') < m_pRoutePoint->GetName()[i])
1771 b_name_is_numeric =
false;
1774 m_pRoutePoint->m_bDynamicName = b_name_is_numeric;
1776 m_pRoutePoint->m_bDynamicName =
false;
1778 if (m_pRoutePoint->m_bIsInRoute) {
1780 pSelect->UpdateSelectableRouteSegments(m_pRoutePoint);
1783 wxArrayPtrVoid* pEditRouteArray =
1784 g_pRouteMan->GetRouteArrayContaining(m_pRoutePoint);
1786 if (pEditRouteArray) {
1787 for (
unsigned int ir = 0; ir < pEditRouteArray->GetCount(); ir++) {
1788 Route* pr = (
Route*)pEditRouteArray->Item(ir);
1789 pr->FinalizeForRendering();
1790 pr->UpdateSegmentDistances();
1792 pConfig->UpdateRoute(pr);
1794 delete pEditRouteArray;
1797 pConfig->UpdateWayPoint(m_pRoutePoint);
1803 for (std::vector<RoutePoint*>::reverse_iterator rit = m_pRoutePoints.rbegin(); rit != m_pRoutePoints.rend(); ++rit) {
1805 if (rp->m_bIsInLayer)
continue;
1806 if (m_pRoutePoint->m_WaypointArrivalRadius != wxAtof(m_textArrivalRadius->GetValue()))
1807 rp->SetWaypointArrivalRadius(m_textArrivalRadius->GetValue());
1808 if (m_pRoutePoint->GetScaMin() != wxAtoi(m_textScaMin->GetValue()))
1809 rp->SetScaMin(m_textScaMin->GetValue());
1810 if (m_pRoutePoint-> GetUseSca() != m_checkBoxScaMin->GetValue())
1811 rp->SetUseSca(m_checkBoxScaMin->GetValue());
1812 if (m_pRoutePoint->GetNameShown() != m_checkBoxShowName->GetValue())
1813 rp->SetNameShown(m_checkBoxShowName->GetValue());
1814 if (m_pRoutePoint->IsVisible() != m_checkBoxVisible->GetValue())
1815 rp->SetVisible(m_checkBoxVisible->GetValue());
1816 wxString* icon_name =
1817 pWayPointMan->GetIconKey(m_bcomboBoxIcon->GetSelection());
1818 if (m_pRoutePoint->GetIconName() != *icon_name) {
1819 if (icon_name && icon_name->Length()) rp->SetIconName(*icon_name);
1822 if (m_pRoutePoint->GetShowWaypointRangeRings() !=
1823 (bool)(m_ChoiceWaypointRangeRingsNumber->GetSelection() != 0)) {
1824 rp->SetShowWaypointRangeRings(
1825 (
bool)(m_ChoiceWaypointRangeRingsNumber->GetSelection() != 0));
1826 rp->SetWaypointRangeRingsNumber(
1827 m_ChoiceWaypointRangeRingsNumber->GetSelection());
1831 if (m_pRoutePoint->GetWaypointRangeRingsStep() !=
1832 fromUsrDistance(wxAtof(m_textWaypointRangeRingsStep->GetValue())))
1833 if (m_textWaypointRangeRingsStep->GetValue().ToDouble(&value))
1834 rp->SetWaypointRangeRingsStep(fromUsrDistance(value, -1));
1836 if (m_pRoutePoint->GetWaypointRangeRingsStep() !=
1837 fromUsrDistance(wxAtof(m_textArrivalRadius->GetValue())))
1838 if (m_textArrivalRadius->GetValue().ToDouble(&value))
1839 rp->SetWaypointArrivalRadius(fromUsrDistance(value, -1));
1841 if (m_RangeRingUnits->GetSelection() != wxNOT_FOUND && m_pRoutePoint->GetWaypointRangeRingsStepUnits() != m_RangeRingUnits->GetSelection())
1842 rp->SetWaypointRangeRingsStepUnits(m_RangeRingUnits->GetSelection());
1844 if (m_pRoutePoint->m_TideStation != m_comboBoxTideStation->GetStringSelection())
1845 rp->m_TideStation = m_comboBoxTideStation->GetStringSelection();
1846 pConfig->UpdateWayPoint(rp);
1854 SaveDefaultsDialog::SaveDefaultsDialog(
MarkInfoDlg* parent)
1855 : wxDialog(parent, wxID_ANY, _(
"Save some defaults")) {
1857 this->SetSizeHints(wxDefaultSize, wxDefaultSize);
1859 wxBoxSizer* bSizer1 =
new wxBoxSizer(wxVERTICAL);
1860 wxStdDialogButtonSizer* StdDialogButtonSizer1;
1863 new wxStaticText(
this, wxID_ANY,
1864 _(
"Check which properties of current waypoint\n should "
1865 "be set as default for NEW waypoints."));
1866 bSizer1->Add(StaticText1, 0, wxALL | wxALIGN_CENTER_HORIZONTAL, 5);
1868 wxFlexGridSizer* fgSizer1 =
new wxFlexGridSizer(2);
1871 (g_pMarkInfoDialog->m_checkBoxShowName->GetValue() ? _(
"Do use")
1874 new wxCheckBox(
this, wxID_ANY, _(
"Show Waypoint Name"), wxDefaultPosition,
1875 wxDefaultSize, 0, wxDefaultValidator);
1876 fgSizer1->Add(NameCB, 0, wxALL, 5);
1877 stName =
new wxStaticText(
this, wxID_ANY, _T(
"[") + s + _T(
"]"),
1878 wxDefaultPosition, wxDefaultSize, 0);
1880 fgSizer1->Add(stName, 0, wxALL | wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL, 5);
1882 s = g_pMarkInfoDialog->m_pRoutePoint->GetIconName();
1883 IconCB =
new wxCheckBox(
this, wxID_ANY, _(
"Icon"));
1884 fgSizer1->Add(IconCB, 0, wxALL, 5);
1885 stIcon =
new wxStaticText(
this, wxID_ANY, _T(
"[") + s + _T(
"]"),
1886 wxDefaultPosition, wxDefaultSize, 0);
1888 fgSizer1->Add(stIcon, 0, wxALL | wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL, 5);
1890 s = (g_pMarkInfoDialog->m_ChoiceWaypointRangeRingsNumber->GetSelection()
1894 g_pMarkInfoDialog->m_ChoiceWaypointRangeRingsNumber
1897 RangRingsCB =
new wxCheckBox(
this, wxID_ANY, _(
"Range rings"));
1898 fgSizer1->Add(RangRingsCB, 0, wxALL, 5);
1899 stRR =
new wxStaticText(
this, wxID_ANY, _T(
"[") + s + _T(
"]"),
1900 wxDefaultPosition, wxDefaultSize, 0);
1902 fgSizer1->Add(stRR, 0, wxALL | wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL, 5);
1904 s = (g_pMarkInfoDialog->m_textArrivalRadius->GetValue());
1905 ArrivalRCB =
new wxCheckBox(
this, wxID_ANY, _(
"Arrival radius"));
1906 fgSizer1->Add(ArrivalRCB, 0, wxALL, 5);
1907 stArrivalR =
new wxStaticText(
1909 wxString::Format(_T(
"[%s %s]"), s.c_str(), getUsrDistanceUnit().c_str()),
1910 wxDefaultPosition, wxDefaultSize, 0);
1911 stArrivalR->Wrap(-1);
1912 fgSizer1->Add(stArrivalR, 0, wxALL | wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL,
1915 s = (g_pMarkInfoDialog->m_checkBoxScaMin->GetValue()
1916 ? _(
"Show only if") + _T(
" < ") +
1917 g_pMarkInfoDialog->m_textScaMin->GetValue()
1918 : _(
"Show always"));
1919 ScaleCB =
new wxCheckBox(
this, wxID_ANY, _(
"Show only at scale"));
1920 fgSizer1->Add(ScaleCB, 0, wxALL, 5);
1921 stScale =
new wxStaticText(
this, wxID_ANY, _T(
"[") + s + _T(
"]"),
1922 wxDefaultPosition, wxDefaultSize, 0);
1924 fgSizer1->Add(stScale, 0, wxALL | wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL, 5);
1926 bSizer1->Add(fgSizer1, 0, wxALL | wxEXPAND, 5);
1928 StdDialogButtonSizer1 =
new wxStdDialogButtonSizer();
1929 StdDialogButtonSizer1->AddButton(
new wxButton(
this, wxID_OK));
1930 StdDialogButtonSizer1->AddButton(
1931 new wxButton(
this, wxID_CANCEL, _(
"Cancel")));
1932 StdDialogButtonSizer1->Realize();
1933 bSizer1->Add(StdDialogButtonSizer1, 0, wxALL | wxEXPAND, 5);
1940 SetSize(parent->GetSize());
1946 void MarkInfoDlg::ShowTidesBtnClicked(wxCommandEvent& event) {
1947 if (m_comboBoxTideStation->GetSelection() < 1) {
1951 ptcmgr->GetStationIDXbyName(m_comboBoxTideStation->GetStringSelection(),
1952 fromDMM(m_textLatitude->GetValue()),
1953 fromDMM(m_textLongitude->GetValue())));
1955 TCWin* pCwin =
new TCWin(gFrame->GetPrimaryCanvas(), 0, 0, pIDX);
1958 wxString msg(_(
"Tide Station not found"));
1960 msg += m_comboBoxTideStation->GetStringSelection();
1961 OCPNMessageBox(NULL, msg, _(
"OpenCPN Info"), wxOK | wxCENTER, 10);
Class SaveDefaultsDialog.
General purpose GUI support.