10 #include <wx/dataview.h>
11 #include <wx/datectrl.h>
12 #include <wx/datetime.h>
14 #include <wx/gdicmn.h>
15 #include <wx/menuitem.h>
16 #include <wx/notebook.h>
17 #include <wx/scrolwin.h>
19 #include <wx/stattext.h>
20 #include <wx/string.h>
21 #include <wx/textctrl.h>
22 #include <wx/timectrl.h>
23 #include <wx/window.h>
26 #include "model/nav_object_database.h"
27 #include "model/ocpn_types.h"
28 #include "routeman_gui.h"
29 #include "model/routeman.h"
30 #include "routemanagerdialog.h"
31 #include "RoutePropDlg.h"
32 #include "RoutePropDlgImpl.h"
35 #if wxCHECK_VERSION(3, 1, 2)
36 #define CELL_EDITABLE wxDATAVIEW_CELL_EDITABLE
38 #define CELL_EDITABLE wxDATAVIEW_CELL_INERT
43 #ifdef __OCPN__ANDROID__
44 EVT_CHAR(RoutePropDlg::OnKeyChar)
55 ctx.set_route_and_update = [&](
Route* r) {
56 if (pRoutePropDialog && (pRoutePropDialog->IsShown())) {
57 pRoutePropDialog->SetRouteAndUpdate(r,
true);
61 if (pRoutePropDialog && pRoutePropDialog->IsShown()) {
62 if (pRoutePropDialog->GetRoute() == r) {
63 pRoutePropDialog->SetEnroutePoint(rt);
67 ctx.hide = [&](
Route* r) {
68 if (pRoutePropDialog && (pRoutePropDialog->IsShown()) &&
69 (r == pRoutePropDialog->GetRoute())) {
70 pRoutePropDialog->Hide();
73 auto RouteMgrDlgUpdateListCtrl = [&]() {
74 if (pRouteManagerDialog && pRouteManagerDialog->IsShown())
75 pRouteManagerDialog->UpdateRouteListCtrl();
80 RoutePropDlg::RoutePropDlg(wxWindow* parent, wxWindowID
id,
81 const wxString& title,
const wxPoint& pos,
82 const wxSize& size,
long style)
83 : DIALOG_PARENT(parent, id, title, pos, size, style) {
84 wxFont* qFont = GetOCPNScaledFont(_(
"Dialog"));
87 this->SetSizeHints(wxSize(300, 300), wxDefaultSize);
89 wxBoxSizer* bSizerMain;
90 bSizerMain =
new wxBoxSizer(wxVERTICAL);
93 new wxNotebook(
this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0);
94 m_pnlBasic =
new wxPanel(m_ntbRteProp, wxID_ANY, wxDefaultPosition,
95 wxDefaultSize, wxTAB_TRAVERSAL);
96 wxBoxSizer* bSizerData;
97 bSizerData =
new wxBoxSizer(wxVERTICAL);
99 wxBoxSizer* bSizerName;
100 bSizerName =
new wxBoxSizer(wxHORIZONTAL);
102 m_stName =
new wxStaticText(m_pnlBasic, wxID_ANY, _(
"Name"),
103 wxDefaultPosition, wxDefaultSize, 0);
105 bSizerName->Add(m_stName, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
107 m_tcName =
new wxTextCtrl(m_pnlBasic, wxID_ANY, wxEmptyString,
108 wxDefaultPosition, wxDefaultSize, 0);
109 bSizerName->Add(m_tcName, 1, wxALL, 5);
111 bSizerData->Add(bSizerName, 0, wxEXPAND, 5);
113 wxBoxSizer* bSizerFromTo;
114 bSizerFromTo =
new wxBoxSizer(wxHORIZONTAL);
116 m_stFrom =
new wxStaticText(m_pnlBasic, wxID_ANY, _(
"From"),
117 wxDefaultPosition, wxDefaultSize, 0);
119 bSizerFromTo->Add(m_stFrom, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
121 m_tcFrom =
new wxTextCtrl(m_pnlBasic, wxID_ANY, wxEmptyString,
122 wxDefaultPosition, wxDefaultSize, 0);
123 bSizerFromTo->Add(m_tcFrom, 1, wxALL, 5);
125 m_stTo =
new wxStaticText(m_pnlBasic, wxID_ANY, _(
"To"), wxDefaultPosition,
128 bSizerFromTo->Add(m_stTo, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
130 m_tcTo =
new wxTextCtrl(m_pnlBasic, wxID_ANY, wxEmptyString,
131 wxDefaultPosition, wxDefaultSize, 0);
132 bSizerFromTo->Add(m_tcTo, 1, wxALL, 5);
134 bSizerData->Add(bSizerFromTo, 0, wxEXPAND, 5);
136 wxWrapSizer* wSizerParams;
137 wSizerParams =
new wxWrapSizer(wxHORIZONTAL, wxEXTEND_LAST_ON_EACH_LINE |
138 wxREMOVE_LEADING_SPACES |
139 wxWRAPSIZER_DEFAULT_FLAGS);
141 int maxFieldSize = GetCharWidth() * 10;
143 wxBoxSizer* bSizerDistance;
144 bSizerDistance =
new wxBoxSizer(wxVERTICAL);
146 m_stDistTotal =
new wxStaticText(m_pnlBasic, wxID_ANY, _(
"Distance"),
147 wxDefaultPosition, wxDefaultSize, 0);
148 m_stDistTotal->Wrap(-1);
149 bSizerDistance->Add(m_stDistTotal, 0, wxALL, 5);
152 new wxTextCtrl(m_pnlBasic, wxID_ANY, wxEmptyString, wxDefaultPosition,
153 wxDefaultSize, wxTE_READONLY);
154 m_tcDistance->SetMaxSize(wxSize(maxFieldSize, -1));
155 m_tcDistance->SetMinSize(wxSize(maxFieldSize, -1));
157 bSizerDistance->Add(m_tcDistance, 0, wxALL | wxEXPAND, 5);
159 wSizerParams->Add(bSizerDistance, 1, wxEXPAND, 0);
161 wxBoxSizer* bSizerSpeed;
162 bSizerSpeed =
new wxBoxSizer(wxVERTICAL);
164 m_stPlanSpeed =
new wxStaticText(m_pnlBasic, wxID_ANY, _(
"Plan speed"),
165 wxDefaultPosition, wxDefaultSize, 0);
166 m_stPlanSpeed->Wrap(-1);
167 bSizerSpeed->Add(m_stPlanSpeed, 0, wxALL, 5);
170 new wxTextCtrl(m_pnlBasic, wxID_ANY, wxEmptyString, wxDefaultPosition,
171 wxDefaultSize, wxTE_PROCESS_ENTER);
172 m_tcPlanSpeed->SetMaxSize(wxSize(maxFieldSize, -1));
173 m_tcPlanSpeed->SetMinSize(wxSize(maxFieldSize, -1));
175 bSizerSpeed->Add(m_tcPlanSpeed, 0, wxALL, 5);
177 wSizerParams->Add(bSizerSpeed, 1, wxEXPAND, 0);
180 wxBoxSizer* bSizerEnroute;
181 bSizerEnroute =
new wxBoxSizer(wxVERTICAL);
183 m_stEnroute =
new wxStaticText(m_pnlBasic, wxID_ANY, _(
"Enroute"),
184 wxDefaultPosition, wxDefaultSize, 0);
185 m_stEnroute->Wrap(-1);
186 bSizerEnroute->Add(m_stEnroute, 0, wxALL, 5);
188 m_tcEnroute =
new wxTextCtrl(m_pnlBasic, wxID_ANY, wxEmptyString,
189 wxDefaultPosition, wxDefaultSize, wxTE_READONLY);
190 m_tcEnroute->SetMaxSize(wxSize(maxFieldSize, -1));
191 m_tcEnroute->SetMinSize(wxSize(maxFieldSize, -1));
193 bSizerEnroute->Add(m_tcEnroute, 0, wxALL, 5);
195 wSizerParams->Add(bSizerEnroute, 1, wxEXPAND, 0);
198 wxBoxSizer* bSizerDeparture;
199 bSizerDeparture =
new wxBoxSizer(wxVERTICAL);
201 m_stDeparture =
new wxStaticText(m_pnlBasic, wxID_ANY, _(
"Departure"),
202 wxDefaultPosition, wxDefaultSize, 0);
203 m_stDeparture->Wrap(-1);
204 bSizerDeparture->Add(m_stDeparture, 0, wxALL, 5);
206 wxBoxSizer* bSizerDepartureTS;
207 bSizerDepartureTS =
new wxBoxSizer(wxHORIZONTAL);
208 bSizerDeparture->Add(bSizerDepartureTS, 0, 0, 5);
211 new wxDatePickerCtrl(m_pnlBasic, wxID_ANY, wxDefaultDateTime,
212 wxDefaultPosition, wxDefaultSize, wxDP_DEFAULT);
213 bSizerDepartureTS->Add(m_dpDepartureDate, 0, wxALIGN_CENTER_VERTICAL | wxALL,
216 int ys = GetCharHeight();
217 m_dpDepartureDate->SetMinSize(wxSize(-1, ys * 15/10));
222 m_tpDepartureTime =
new TimeCtrl(m_pnlBasic, wxID_ANY, wxDefaultDateTime,
223 wxDefaultPosition, wxDefaultSize);
226 new wxTimePickerCtrl(m_pnlBasic, wxID_ANY, wxDefaultDateTime,
227 wxDefaultPosition, wxDefaultSize, wxDP_DEFAULT);
229 bSizerDepartureTS->Add(m_tpDepartureTime, 0, wxALIGN_CENTER_VERTICAL | wxALL,
232 wSizerParams->Add(bSizerDeparture, 1, wxEXPAND, 0);
234 wxBoxSizer* bSizerTime;
235 bSizerTime =
new wxBoxSizer(wxVERTICAL);
237 m_stTimeZone =
new wxStaticText(m_pnlBasic, wxID_ANY, _(
"Time"),
238 wxDefaultPosition, wxDefaultSize, 0);
239 m_stTimeZone->Wrap(-1);
240 bSizerTime->Add(m_stTimeZone, 0, wxALL, 5);
242 wxString m_choiceTimezoneChoices[] = {_(
"UTC"), _(
"Local@PC"),
244 int m_choiceTimezoneNChoices =
245 sizeof(m_choiceTimezoneChoices) /
sizeof(wxString);
247 new wxChoice(m_pnlBasic, wxID_ANY, wxDefaultPosition, wxDefaultSize,
248 m_choiceTimezoneNChoices, m_choiceTimezoneChoices, 0);
249 m_choiceTimezone->SetSelection(0);
250 m_choiceTimezone->SetMaxSize(wxSize(GetCharWidth() * 12, -1));
252 bSizerTime->Add(m_choiceTimezone, 0, wxALL, 5);
254 wSizerParams->Add(bSizerTime, 1, wxEXPAND, 0);
256 wxBoxSizer* bSizerColor;
257 bSizerColor =
new wxBoxSizer(wxVERTICAL);
259 m_staticTextColor =
new wxStaticText(m_pnlBasic, wxID_ANY, _(
"Color"),
260 wxDefaultPosition, wxDefaultSize, 0);
261 m_staticTextColor->Wrap(-1);
262 bSizerColor->Add(m_staticTextColor, 0, wxALL, 5);
264 wxString m_choiceColorChoices[] = {
265 _(
"Default color"), _(
"Black"), _(
"Dark Red"), _(
"Dark Green"),
266 _(
"Dark Yellow"), _(
"Dark Blue"), _(
"Dark Magenta"), _(
"Dark Cyan"),
267 _(
"Light Gray"), _(
"Dark Gray"), _(
"Red"), _(
"Green"),
268 _(
"Yellow"), _(
"Blue"), _(
"Magenta"), _(
"Cyan"),
270 int m_choiceColorNChoices =
sizeof(m_choiceColorChoices) /
sizeof(wxString);
272 new wxChoice(m_pnlBasic, wxID_ANY, wxDefaultPosition, wxDefaultSize,
273 m_choiceColorNChoices, m_choiceColorChoices, 0);
274 m_choiceColor->SetSelection(0);
275 bSizerColor->Add(m_choiceColor, 0, wxALL, 5);
277 wSizerParams->Add(bSizerColor, 1, wxEXPAND, 5);
279 wxBoxSizer* bSizerStyle;
280 bSizerStyle =
new wxBoxSizer(wxVERTICAL);
282 m_stStyle =
new wxStaticText(m_pnlBasic, wxID_ANY, _(
"Style"),
283 wxDefaultPosition, wxDefaultSize, 0);
285 bSizerStyle->Add(m_stStyle, 0, wxALL, 5);
287 wxString m_choiceStyleChoices[] = {_(
"Default"), _(
"Solid"),
288 _(
"Dot"), _(
"Long dash"),
290 int m_choiceStyleNChoices =
sizeof(m_choiceStyleChoices) /
sizeof(wxString);
292 new wxChoice(m_pnlBasic, wxID_ANY, wxDefaultPosition, wxDefaultSize,
293 m_choiceStyleNChoices, m_choiceStyleChoices, 0);
294 m_choiceStyle->SetSelection(0);
295 bSizerStyle->Add(m_choiceStyle, 0, wxALL, 5);
297 wSizerParams->Add(bSizerStyle, 1, wxEXPAND, 5);
299 wxBoxSizer* bSizerWidth;
300 bSizerWidth =
new wxBoxSizer(wxVERTICAL);
302 m_stWidth =
new wxStaticText(m_pnlBasic, wxID_ANY, _(
"Width"),
303 wxDefaultPosition, wxDefaultSize, 0);
305 bSizerWidth->Add(m_stWidth, 0, wxALL, 5);
307 wxString m_choiceWidthChoices[] = {
308 _(
"Default"), _(
"1 px"), _(
"2px"), _(
"3 px"), _(
"4 px"), _(
"5 px"),
309 _(
"6 px"), _(
"7 px"), _(
"8 px"), _(
"9 px"), _(
"10 px")};
310 int m_choiceWidthNChoices =
sizeof(m_choiceWidthChoices) /
sizeof(wxString);
312 new wxChoice(m_pnlBasic, wxID_ANY, wxDefaultPosition, wxDefaultSize,
313 m_choiceWidthNChoices, m_choiceWidthChoices, 0);
314 m_choiceWidth->SetSelection(0);
315 bSizerWidth->Add(m_choiceWidth, 0, wxALL, 5);
317 wSizerParams->Add(bSizerWidth, 1, wxEXPAND, 5);
322 wxString toLabel = _(
"To waypoint");
325 int columWidths[] = {
326 wxCOL_WIDTH_AUTOSIZE, wxCOL_WIDTH_AUTOSIZE, wxCOL_WIDTH_AUTOSIZE,
327 wxCOL_WIDTH_AUTOSIZE, wxCOL_WIDTH_AUTOSIZE, wxCOL_WIDTH_AUTOSIZE,
328 wxCOL_WIDTH_AUTOSIZE, wxCOL_WIDTH_AUTOSIZE, wxCOL_WIDTH_AUTOSIZE,
329 wxCOL_WIDTH_AUTOSIZE, wxCOL_WIDTH_AUTOSIZE, wxCOL_WIDTH_AUTOSIZE,
330 wxCOL_WIDTH_AUTOSIZE, wxCOL_WIDTH_AUTOSIZE, wxCOL_WIDTH_AUTOSIZE};
332 toLabel = _(
"To WP");
335 int columWidths[] = {30, 80, 70,
342 int colFlags = wxDATAVIEW_COL_RESIZABLE;
346 bSizerData->Add(wSizerParams, 0, wxEXPAND, 0);
349 new wxDataViewListCtrl(m_pnlBasic, wxID_ANY, wxDefaultPosition,
350 wxDefaultSize, wxDV_VERT_RULES | wxDV_HORIZ_RULES);
351 m_dataViewListColumnLeg = m_dvlcWaypoints->AppendTextColumn(
352 _(
"Leg"), wxDATAVIEW_CELL_INERT, columWidths[0],
353 static_cast<wxAlignment
>(wxALIGN_LEFT), colFlags);
354 m_dataViewListColumnLeg->GetRenderer()->EnableEllipsize(wxELLIPSIZE_NONE);
355 m_dataViewListColumnToWpt = m_dvlcWaypoints->AppendTextColumn(
356 toLabel, wxDATAVIEW_CELL_INERT, columWidths[1],
357 static_cast<wxAlignment
>(wxALIGN_LEFT), colFlags);
358 m_dataViewListColumnToWpt->GetRenderer()->EnableEllipsize(wxELLIPSIZE_END);
359 m_dataViewListColumnDistance = m_dvlcWaypoints->AppendTextColumn(
360 _(
"Distance"), wxDATAVIEW_CELL_INERT, columWidths[2],
361 static_cast<wxAlignment
>(wxALIGN_LEFT), colFlags);
362 m_dataViewListColumnDistance->GetRenderer()->EnableEllipsize(wxELLIPSIZE_END);
363 m_dataViewListColumnBearing = m_dvlcWaypoints->AppendTextColumn(
364 _(
"Bearing"), wxDATAVIEW_CELL_INERT, columWidths[3],
365 static_cast<wxAlignment
>(wxALIGN_LEFT), colFlags);
366 m_dataViewListColumnBearing->GetRenderer()->EnableEllipsize(wxELLIPSIZE_END);
367 m_dataViewListColumnTotalDistance = m_dvlcWaypoints->AppendTextColumn(
368 _(
"Total Distance"), wxDATAVIEW_CELL_INERT, columWidths[4],
369 static_cast<wxAlignment
>(wxALIGN_LEFT), colFlags);
370 m_dataViewListColumnTotalDistance->GetRenderer()->EnableEllipsize(
372 m_dataViewListColumnLat = m_dvlcWaypoints->AppendTextColumn(
373 _(
"Latitude"), wxDATAVIEW_CELL_INERT, columWidths[5],
374 static_cast<wxAlignment
>(wxALIGN_LEFT), colFlags);
375 m_dataViewListColumnLat->GetRenderer()->EnableEllipsize(wxELLIPSIZE_END);
376 m_dataViewListColumnLon = m_dvlcWaypoints->AppendTextColumn(
377 _(
"Longitude"), wxDATAVIEW_CELL_INERT, columWidths[6],
378 static_cast<wxAlignment
>(wxALIGN_LEFT), colFlags);
379 m_dataViewListColumnLon->GetRenderer()->EnableEllipsize(wxELLIPSIZE_END);
380 m_dataViewListColumnETE = m_dvlcWaypoints->AppendTextColumn(
381 _(
"ETE"), wxDATAVIEW_CELL_INERT, columWidths[7],
382 static_cast<wxAlignment
>(wxALIGN_LEFT), colFlags);
383 m_dataViewListColumnETE->GetRenderer()->EnableEllipsize(wxELLIPSIZE_END);
384 m_dataViewListColumnETA = m_dvlcWaypoints->AppendTextColumn(
385 _(
"ETA"), wxDATAVIEW_CELL_INERT, columWidths[8],
386 static_cast<wxAlignment
>(wxALIGN_LEFT), colFlags);
387 m_dataViewListColumnETA->GetRenderer()->EnableEllipsize(wxELLIPSIZE_END);
388 m_dataViewListColumnSpeed = m_dvlcWaypoints->AppendTextColumn(
389 _(
"Speed"), CELL_EDITABLE, columWidths[9],
390 static_cast<wxAlignment
>(wxALIGN_LEFT), colFlags);
391 m_dataViewListColumnSpeed->GetRenderer()->EnableEllipsize(wxELLIPSIZE_END);
392 m_dataViewListColumnNTE = m_dvlcWaypoints->AppendTextColumn(
393 _(
"Next tide event"), wxDATAVIEW_CELL_INERT, columWidths[10],
394 static_cast<wxAlignment
>(wxALIGN_LEFT), colFlags);
395 m_dataViewListColumnNTE->GetRenderer()->EnableEllipsize(wxELLIPSIZE_END);
396 m_dataViewListColumnDesc = m_dvlcWaypoints->AppendTextColumn(
397 _(
"Description"), wxDATAVIEW_CELL_INERT, columWidths[11],
398 static_cast<wxAlignment
>(wxALIGN_LEFT), colFlags);
399 m_dataViewListColumnDesc->GetRenderer()->EnableEllipsize(wxELLIPSIZE_END);
400 m_dataViewListColumnCourse = m_dvlcWaypoints->AppendTextColumn(
401 _(
"Course"), wxDATAVIEW_CELL_INERT, columWidths[12],
402 static_cast<wxAlignment
>(wxALIGN_LEFT), colFlags);
403 m_dataViewListColumnCourse->GetRenderer()->EnableEllipsize(wxELLIPSIZE_END);
404 m_dataViewListColumnETD = m_dvlcWaypoints->AppendTextColumn(
405 _(
"ETD"), CELL_EDITABLE, columWidths[13],
406 static_cast<wxAlignment
>(wxALIGN_LEFT), colFlags);
407 m_dataViewListColumnETD->GetRenderer()->EnableEllipsize(wxELLIPSIZE_END);
408 m_dataViewListColumnEmpty = m_dvlcWaypoints->AppendTextColumn(
409 wxEmptyString, wxDATAVIEW_CELL_INERT, columWidths[14],
410 static_cast<wxAlignment
>(wxALIGN_LEFT), colFlags);
411 bSizerData->Add(m_dvlcWaypoints, 1, wxALL | wxEXPAND, 5);
413 m_pnlBasic->SetSizer(bSizerData);
414 m_pnlBasic->Layout();
415 bSizerData->Fit(m_pnlBasic);
416 m_ntbRteProp->AddPage(m_pnlBasic, _(
"Basic"),
false);
417 m_pnlAdvanced =
new wxPanel(m_ntbRteProp, wxID_ANY, wxDefaultPosition,
418 wxDefaultSize, wxTAB_TRAVERSAL);
419 wxBoxSizer* bSizerAdvanced;
420 bSizerAdvanced =
new wxBoxSizer(wxVERTICAL);
422 m_stDescription =
new wxStaticText(m_pnlAdvanced, wxID_ANY, _(
"Description"),
423 wxDefaultPosition, wxDefaultSize, 0);
424 m_stDescription->Wrap(-1);
425 bSizerAdvanced->Add(m_stDescription, 0, wxALL, 5);
428 new wxTextCtrl(m_pnlAdvanced, wxID_ANY, wxEmptyString, wxDefaultPosition,
429 wxDefaultSize, wxTE_MULTILINE);
430 bSizerAdvanced->Add(m_tcDescription, 0, wxALL | wxEXPAND, 5);
432 wxStaticBoxSizer* sbSizerLinks;
433 sbSizerLinks =
new wxStaticBoxSizer(
434 new wxStaticBox(m_pnlAdvanced, wxID_ANY, _(
"Links")), wxVERTICAL);
436 m_scrolledWindowLinks =
new wxScrolledWindow(
437 sbSizerLinks->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize,
438 wxHSCROLL | wxVSCROLL);
439 m_scrolledWindowLinks->SetScrollRate(5, 5);
440 wxBoxSizer* bSizerLinksWnd;
441 bSizerLinksWnd =
new wxBoxSizer(wxVERTICAL);
443 bSizerLinks =
new wxBoxSizer(wxVERTICAL);
446 new wxHyperlinkCtrl(m_scrolledWindowLinks, wxID_ANY, _(
"wxFB Website"),
447 wxT(
"http://www.wxformbuilder.org"),
448 wxDefaultPosition, wxDefaultSize, wxHL_DEFAULT_STYLE);
449 m_hyperlink1->Enable(
false);
450 m_hyperlink1->Hide();
452 m_menuLink =
new wxMenu();
453 wxMenuItem* m_menuItemEdit;
454 m_menuItemEdit =
new wxMenuItem(m_menuLink, wxID_ANY, wxString(_(
"Edit")),
455 wxEmptyString, wxITEM_NORMAL);
456 m_menuLink->Append(m_menuItemEdit);
458 wxMenuItem* m_menuItemAdd;
459 m_menuItemAdd =
new wxMenuItem(m_menuLink, wxID_ANY, wxString(_(
"Add new")),
460 wxEmptyString, wxITEM_NORMAL);
461 m_menuLink->Append(m_menuItemAdd);
463 wxMenuItem* m_menuItemDelete;
464 m_menuItemDelete =
new wxMenuItem(m_menuLink, wxID_ANY, wxString(_(
"Delete")),
465 wxEmptyString, wxITEM_NORMAL);
466 m_menuLink->Append(m_menuItemDelete);
468 m_hyperlink1->Connect(
470 wxMouseEventHandler(RoutePropDlg::m_hyperlink1OnContextMenu), NULL,
this);
472 bSizerLinks->Add(m_hyperlink1, 0, wxALL, 5);
474 bSizerLinksWnd->Add(bSizerLinks, 1, wxEXPAND, 5);
476 wxBoxSizer* bSizerLinkBtns;
477 bSizerLinkBtns =
new wxBoxSizer(wxHORIZONTAL);
479 m_btnAddLink =
new wxButton(m_scrolledWindowLinks, wxID_ANY, _(
"Add"),
480 wxDefaultPosition, wxDefaultSize, 0);
481 bSizerLinkBtns->Add(m_btnAddLink, 0, wxALL, 5);
484 new wxToggleButton(m_scrolledWindowLinks, wxID_ANY, _(
"Edit"),
485 wxDefaultPosition, wxDefaultSize, 0);
486 bSizerLinkBtns->Add(m_toggleBtnEdit, 0, wxALL, 5);
489 new wxStaticText(m_scrolledWindowLinks, wxID_ANY,
490 _(
"Links are opened in the default browser."),
491 wxDefaultPosition, wxDefaultSize, 0);
492 m_stEditEnabled->Wrap(-1);
493 bSizerLinkBtns->Add(m_stEditEnabled, 0, wxALL, 5);
495 bSizerLinksWnd->Add(bSizerLinkBtns, 0, wxEXPAND, 5);
497 m_scrolledWindowLinks->SetSizer(bSizerLinksWnd);
498 m_scrolledWindowLinks->Layout();
499 bSizerLinksWnd->Fit(m_scrolledWindowLinks);
500 m_menuLinks =
new wxMenu();
501 wxMenuItem* m_menuItemAddLink;
503 new wxMenuItem(m_menuLinks, wxID_ANY, wxString(_(
"Add new")),
504 wxEmptyString, wxITEM_NORMAL);
505 m_menuLinks->Append(m_menuItemAddLink);
507 m_scrolledWindowLinks->Connect(
509 wxMouseEventHandler(RoutePropDlg::m_scrolledWindowLinksOnContextMenu),
512 sbSizerLinks->Add(m_scrolledWindowLinks, 1, wxEXPAND | wxALL, 5);
514 bSizerAdvanced->Add(sbSizerLinks, 1, wxEXPAND, 5);
516 m_pnlAdvanced->SetSizer(bSizerAdvanced);
517 m_pnlAdvanced->Layout();
518 bSizerAdvanced->Fit(m_pnlAdvanced);
519 m_ntbRteProp->AddPage(m_pnlAdvanced, _(
"Advanced"),
false);
521 bSizerMain->Add(m_ntbRteProp, 1, wxEXPAND | wxALL, 5);
523 wxWrapSizer* wSizerCustomBtns;
524 wSizerCustomBtns =
new wxWrapSizer(wxHORIZONTAL, wxWRAPSIZER_DEFAULT_FLAGS);
526 m_btnPrint =
new wxButton(
this, wxID_ANY, _(
"Print"), wxDefaultPosition,
528 wSizerCustomBtns->Add(m_btnPrint, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
530 #ifdef __OCPN__ANDROID__
534 m_btnExtend =
new wxButton(
this, wxID_ANY, _(
"Extend"), wxDefaultPosition,
536 wSizerCustomBtns->Add(m_btnExtend, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
538 m_btnSplit =
new wxButton(
this, wxID_ANY, _(
"Split"), wxDefaultPosition,
540 wSizerCustomBtns->Add(m_btnSplit, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
542 wSizerCustomBtns->Add(0, 0, 1, wxEXPAND, 5);
544 m_sdbSizerBtns =
new wxStdDialogButtonSizer();
545 m_sdbSizerBtnsOK =
new wxButton(
this, wxID_OK);
546 m_sdbSizerBtns->AddButton(m_sdbSizerBtnsOK);
547 m_sdbSizerBtnsCancel =
new wxButton(
this, wxID_CANCEL, _(
"Cancel"));
548 m_sdbSizerBtns->AddButton(m_sdbSizerBtnsCancel);
549 m_sdbSizerBtns->Realize();
551 wSizerCustomBtns->Add(m_sdbSizerBtns, 1, wxEXPAND, 5);
553 bSizerMain->Add(wSizerCustomBtns, 0, wxEXPAND, 0);
555 this->SetSizer(bSizerMain);
558 this->Centre(wxBOTH);
561 this->Connect(wxEVT_CLOSE_WINDOW,
562 wxCloseEventHandler(RoutePropDlg::RoutePropDlgOnClose));
563 this->Connect(wxEVT_SIZE,
564 wxSizeEventHandler(RoutePropDlg::RoutePropDlgOnSize));
565 m_ntbRteProp->Connect(
566 wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED,
567 wxNotebookEventHandler(RoutePropDlg::RoutePropDlgOnNotebookPageChanged),
569 m_tcPlanSpeed->Connect(
570 wxEVT_KILL_FOCUS, wxFocusEventHandler(RoutePropDlg::PlanSpeedOnKillFocus),
572 m_tcPlanSpeed->Connect(
573 wxEVT_COMMAND_TEXT_ENTER,
574 wxCommandEventHandler(RoutePropDlg::PlanSpeedOnTextEnter), NULL,
this);
575 m_tcPlanSpeed->Connect(
576 wxEVT_COMMAND_TEXT_UPDATED,
577 wxCommandEventHandler(RoutePropDlg::PlanSpeedOnTextEnter), NULL,
this);
578 m_dpDepartureDate->Connect(
580 wxDateEventHandler(RoutePropDlg::DepartureDateOnDateChanged), NULL,
this);
581 m_tpDepartureTime->Connect(
583 wxDateEventHandler(RoutePropDlg::DepartureTimeOnTimeChanged), NULL,
this);
584 m_choiceTimezone->Connect(
585 wxEVT_COMMAND_CHOICE_SELECTED,
586 wxCommandEventHandler(RoutePropDlg::TimezoneOnChoice), NULL,
this);
587 m_dvlcWaypoints->Connect(
588 wxEVT_COMMAND_DATAVIEW_ITEM_CONTEXT_MENU,
589 wxDataViewEventHandler(
590 RoutePropDlg::WaypointsOnDataViewListCtrlItemContextMenu),
592 m_dvlcWaypoints->Connect(
593 wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_DONE,
594 wxDataViewEventHandler(
595 RoutePropDlg::WaypointsOnDataViewListCtrlItemEditingDone),
597 m_dvlcWaypoints->Connect(
598 wxEVT_COMMAND_DATAVIEW_ITEM_VALUE_CHANGED,
599 wxDataViewEventHandler(
600 RoutePropDlg::WaypointsOnDataViewListCtrlItemValueChanged),
602 m_dvlcWaypoints->Connect(
603 wxEVT_COMMAND_DATAVIEW_SELECTION_CHANGED,
604 wxDataViewEventHandler(
605 RoutePropDlg::WaypointsOnDataViewListCtrlSelectionChanged),
607 m_menuLink->Bind(wxEVT_COMMAND_MENU_SELECTED,
608 wxCommandEventHandler(RoutePropDlg::ItemEditOnMenuSelection),
609 this, m_menuItemEdit->GetId());
610 m_menuLink->Bind(wxEVT_COMMAND_MENU_SELECTED,
611 wxCommandEventHandler(RoutePropDlg::ItemAddOnMenuSelection),
612 this, m_menuItemAdd->GetId());
614 wxEVT_COMMAND_MENU_SELECTED,
615 wxCommandEventHandler(RoutePropDlg::ItemDeleteOnMenuSelection),
this,
616 m_menuItemDelete->GetId());
617 m_btnAddLink->Connect(
618 wxEVT_COMMAND_BUTTON_CLICKED,
619 wxCommandEventHandler(RoutePropDlg::AddLinkOnButtonClick), NULL,
this);
620 m_toggleBtnEdit->Connect(
621 wxEVT_COMMAND_TOGGLEBUTTON_CLICKED,
622 wxCommandEventHandler(RoutePropDlg::BtnEditOnToggleButton), NULL,
this);
623 m_menuLinks->Bind(wxEVT_COMMAND_MENU_SELECTED,
624 wxCommandEventHandler(RoutePropDlg::ItemAddOnMenuSelection),
625 this, m_menuItemAddLink->GetId());
626 m_btnPrint->Connect(wxEVT_COMMAND_BUTTON_CLICKED,
627 wxCommandEventHandler(RoutePropDlg::PrintOnButtonClick),
629 m_btnExtend->Connect(wxEVT_COMMAND_BUTTON_CLICKED,
630 wxCommandEventHandler(RoutePropDlg::ExtendOnButtonClick),
632 m_btnSplit->Connect(wxEVT_COMMAND_BUTTON_CLICKED,
633 wxCommandEventHandler(RoutePropDlg::SplitOnButtonClick),
635 m_sdbSizerBtnsCancel->Connect(
636 wxEVT_COMMAND_BUTTON_CLICKED,
637 wxCommandEventHandler(RoutePropDlg::BtnsOnCancelButtonClick), NULL,
this);
638 m_sdbSizerBtnsOK->Connect(
639 wxEVT_COMMAND_BUTTON_CLICKED,
640 wxCommandEventHandler(RoutePropDlg::BtnsOnOKButtonClick), NULL,
this);
642 auto navobj = NavObjectChanges::getInstance();
644 navobj_del_track_listener.Listen(navobj->evt_delete_track,
this,
645 EVT_ROUTEMAN_DEL_TRK);
647 auto t = std::const_pointer_cast<Track>(UnpackEvtPointer<Track>(ev));
648 RoutemanGui(*g_pRouteMan).DeleteTrack(t.get()); });
651 navobj_del_route_listener.Listen(navobj->evt_delete_route,
this,
652 EVT_ROUTEMAN_DEL_ROUTE);
653 Bind(EVT_ROUTEMAN_DEL_ROUTE, [&](
ObservedEvt& ev) {
654 auto r = std::const_pointer_cast<Route>(UnpackEvtPointer<Route>(ev));
658 RoutePropDlg::~RoutePropDlg() {
660 this->Disconnect(wxEVT_CLOSE_WINDOW,
661 wxCloseEventHandler(RoutePropDlg::RoutePropDlgOnClose));
662 this->Disconnect(wxEVT_SIZE,
663 wxSizeEventHandler(RoutePropDlg::RoutePropDlgOnSize));
664 m_ntbRteProp->Disconnect(
665 wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED,
666 wxNotebookEventHandler(RoutePropDlg::RoutePropDlgOnNotebookPageChanged),
668 m_tcPlanSpeed->Disconnect(
669 wxEVT_KILL_FOCUS, wxFocusEventHandler(RoutePropDlg::PlanSpeedOnKillFocus),
671 m_tcPlanSpeed->Disconnect(
672 wxEVT_COMMAND_TEXT_ENTER,
673 wxCommandEventHandler(RoutePropDlg::PlanSpeedOnTextEnter), NULL,
this);
674 m_tcPlanSpeed->Disconnect(
675 wxEVT_COMMAND_TEXT_UPDATED,
676 wxCommandEventHandler(RoutePropDlg::PlanSpeedOnTextEnter), NULL,
this);
677 m_dpDepartureDate->Disconnect(
679 wxDateEventHandler(RoutePropDlg::DepartureDateOnDateChanged), NULL,
this);
680 m_tpDepartureTime->Disconnect(
682 wxDateEventHandler(RoutePropDlg::DepartureTimeOnTimeChanged), NULL,
this);
683 m_choiceTimezone->Disconnect(
684 wxEVT_COMMAND_CHOICE_SELECTED,
685 wxCommandEventHandler(RoutePropDlg::TimezoneOnChoice), NULL,
this);
686 m_dvlcWaypoints->Disconnect(
687 wxEVT_COMMAND_DATAVIEW_ITEM_CONTEXT_MENU,
688 wxDataViewEventHandler(
689 RoutePropDlg::WaypointsOnDataViewListCtrlItemContextMenu),
691 m_dvlcWaypoints->Disconnect(
692 wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_DONE,
693 wxDataViewEventHandler(
694 RoutePropDlg::WaypointsOnDataViewListCtrlItemEditingDone),
696 m_dvlcWaypoints->Disconnect(
697 wxEVT_COMMAND_DATAVIEW_ITEM_VALUE_CHANGED,
698 wxDataViewEventHandler(
699 RoutePropDlg::WaypointsOnDataViewListCtrlItemValueChanged),
701 m_dvlcWaypoints->Disconnect(
702 wxEVT_COMMAND_DATAVIEW_SELECTION_CHANGED,
703 wxDataViewEventHandler(
704 RoutePropDlg::WaypointsOnDataViewListCtrlSelectionChanged),
706 m_btnAddLink->Disconnect(
707 wxEVT_COMMAND_BUTTON_CLICKED,
708 wxCommandEventHandler(RoutePropDlg::AddLinkOnButtonClick), NULL,
this);
709 m_toggleBtnEdit->Disconnect(
710 wxEVT_COMMAND_TOGGLEBUTTON_CLICKED,
711 wxCommandEventHandler(RoutePropDlg::BtnEditOnToggleButton), NULL,
this);
712 m_btnPrint->Disconnect(
713 wxEVT_COMMAND_BUTTON_CLICKED,
714 wxCommandEventHandler(RoutePropDlg::PrintOnButtonClick), NULL,
this);
715 m_btnExtend->Disconnect(
716 wxEVT_COMMAND_BUTTON_CLICKED,
717 wxCommandEventHandler(RoutePropDlg::ExtendOnButtonClick), NULL,
this);
718 m_btnSplit->Disconnect(
719 wxEVT_COMMAND_BUTTON_CLICKED,
720 wxCommandEventHandler(RoutePropDlg::SplitOnButtonClick), NULL,
this);
721 m_sdbSizerBtnsCancel->Disconnect(
722 wxEVT_COMMAND_BUTTON_CLICKED,
723 wxCommandEventHandler(RoutePropDlg::BtnsOnCancelButtonClick), NULL,
this);
724 m_sdbSizerBtnsOK->Disconnect(
725 wxEVT_COMMAND_BUTTON_CLICKED,
726 wxCommandEventHandler(RoutePropDlg::BtnsOnOKButtonClick), NULL,
this);
732 void RoutePropDlg::OnKeyChar(wxKeyEvent& event) {
733 int key_char =
event.GetKeyCode();
Adds a std::shared<void> element to wxCommandEvent.
bool DeleteRoute(Route *pRoute, NavObjectChanges *nav_obj_changes)
General purpose GUI support.
wxDEFINE_EVENT(REST_IO_EVT, ObservedEvt)
Event from IO thread to main.
Callbacks for RoutePropDlg.