28#include "navutil_base.h"
32#include "routeman_gui.h"
33#include "routemanagerdialog.h"
34#include "trackprintout.h"
35#include "pluginmanager.h"
36#include "OCPNPlatform.h"
37#include "TrackPropDlg.h"
42#include "ocpn_frame.h"
44#ifdef __OCPN__ANDROID__
45#include "androidUTIL.h"
48extern std::vector<Track*> g_TrackList;
61#define DISPLAY_FORMAT 2
62#define TIMESTAMP_FORMAT 3
64wxString timestamp2s(wxDateTime ts,
int tz_selection,
long LMT_offset,
68 if (format == INPUT_FORMAT)
70 else if (format == TIMESTAMP_FORMAT)
71 f = _T(
"%x %H:%M:%S");
74 switch (tz_selection) {
76 s.Append(ts.Format(f));
77 if (format != INPUT_FORMAT) s.Append(_T(
" UT"));
80 s.Append(ts.FromUTC().Format(f));
83 wxTimeSpan lmt(0, 0, (
int)LMT_offset, 0);
84 s.Append(ts.Add(lmt).Format(f));
85 if (format != INPUT_FORMAT) s.Append(_T(
" LMT"));
91bool TrackPropDlg::instanceFlag =
false;
93TrackPropDlg* TrackPropDlg::getInstance(wxWindow* parent, wxWindowID
id,
94 const wxString& title,
95 const wxPoint& pos,
const wxSize& size,
98 single =
new TrackPropDlg(parent,
id, title, pos, size, style);
106TrackPropDlg::TrackPropDlg(wxWindow* parent, wxWindowID
id,
107 const wxString& title,
const wxPoint& pos,
108 const wxSize& size,
long style)
109 : wxFrame(parent, id, title, pos, size, style) {
110 wxFont* qFont = GetOCPNScaledFont(_(
"Dialog"));
113 SetWindowStyleFlag(style);
115 m_scrolledWindowLinks = NULL;
116 m_tDescription = NULL;
120#ifdef __OCPN__ANDROID__
122 CreateControlsCompact();
132 m_sdbBtmBtnsSizerCancel->Connect(
133 wxEVT_COMMAND_BUTTON_CLICKED,
134 wxCommandEventHandler(TrackPropDlg::OnCancelBtnClick), NULL,
this);
135 m_sdbBtmBtnsSizerOK->Connect(
136 wxEVT_COMMAND_BUTTON_CLICKED,
137 wxCommandEventHandler(TrackPropDlg::OnOKBtnClick), NULL,
this);
138 if (m_sdbBtmBtnsSizerPrint)
139 m_sdbBtmBtnsSizerPrint->Connect(
140 wxEVT_COMMAND_BUTTON_CLICKED,
141 wxCommandEventHandler(TrackPropDlg::OnPrintBtnClick), NULL,
this);
142 m_sdbBtmBtnsSizerSplit->Connect(
143 wxEVT_COMMAND_BUTTON_CLICKED,
144 wxCommandEventHandler(TrackPropDlg::OnSplitBtnClick), NULL,
this);
145 m_sdbBtmBtnsSizerExtend->Connect(
146 wxEVT_COMMAND_BUTTON_CLICKED,
147 wxCommandEventHandler(TrackPropDlg::OnExtendBtnClick), NULL,
this);
148 m_sdbBtmBtnsSizerToRoute->Connect(
149 wxEVT_COMMAND_BUTTON_CLICKED,
150 wxCommandEventHandler(TrackPropDlg::OnToRouteBtnClick), NULL,
this);
151 if (m_sdbBtmBtnsSizerExport)
152 m_sdbBtmBtnsSizerExport->Connect(
153 wxEVT_COMMAND_BUTTON_CLICKED,
154 wxCommandEventHandler(TrackPropDlg::OnExportBtnClick), NULL,
this);
155 m_lcPoints->Connect(wxEVT_COMMAND_LIST_ITEM_SELECTED,
156 wxListEventHandler(TrackPropDlg::OnTrackPropListClick),
158 Connect(wxEVT_COMMAND_LIST_ITEM_RIGHT_CLICK,
159 wxListEventHandler(TrackPropDlg::OnTrackPropRightClick), NULL,
this);
160 Connect(wxEVT_COMMAND_MENU_SELECTED,
161 wxCommandEventHandler(TrackPropDlg::OnTrackPropMenuSelected), NULL,
165 Connect(wxEVT_ACTIVATE,
166 wxActivateEventHandler(TrackPropDlg::OnActivate),
171 m_buttonAddLink->Connect(wxEVT_COMMAND_BUTTON_CLICKED,
172 wxCommandEventHandler(TrackPropDlg::OnAddLink),
174 m_toggleBtnEdit->Connect(
175 wxEVT_COMMAND_TOGGLEBUTTON_CLICKED,
176 wxCommandEventHandler(TrackPropDlg::OnEditLinkToggle), NULL,
this);
180 m_rbShowTimeUTC->Connect(wxEVT_COMMAND_RADIOBUTTON_SELECTED,
181 wxCommandEventHandler(TrackPropDlg::OnShowTimeTZ),
184 m_rbShowTimePC->Connect(wxEVT_COMMAND_RADIOBUTTON_SELECTED,
185 wxCommandEventHandler(TrackPropDlg::OnShowTimeTZ),
187 if (m_rbShowTimeLocal)
188 m_rbShowTimeLocal->Connect(
189 wxEVT_COMMAND_RADIOBUTTON_SELECTED,
190 wxCommandEventHandler(TrackPropDlg::OnShowTimeTZ), NULL,
this);
192 m_pMyLinkList = NULL;
195TrackPropDlg::~TrackPropDlg() {
197 m_sdbBtmBtnsSizerCancel->Disconnect(
198 wxEVT_COMMAND_BUTTON_CLICKED,
199 wxCommandEventHandler(TrackPropDlg::OnCancelBtnClick), NULL,
this);
200 m_sdbBtmBtnsSizerOK->Disconnect(
201 wxEVT_COMMAND_BUTTON_CLICKED,
202 wxCommandEventHandler(TrackPropDlg::OnOKBtnClick), NULL,
this);
203 if (m_sdbBtmBtnsSizerPrint)
204 m_sdbBtmBtnsSizerPrint->Disconnect(
205 wxEVT_COMMAND_BUTTON_CLICKED,
206 wxCommandEventHandler(TrackPropDlg::OnPrintBtnClick), NULL,
this);
207 m_sdbBtmBtnsSizerSplit->Disconnect(
208 wxEVT_COMMAND_BUTTON_CLICKED,
209 wxCommandEventHandler(TrackPropDlg::OnSplitBtnClick), NULL,
this);
210 m_sdbBtmBtnsSizerExtend->Disconnect(
211 wxEVT_COMMAND_BUTTON_CLICKED,
212 wxCommandEventHandler(TrackPropDlg::OnExtendBtnClick), NULL,
this);
213 m_sdbBtmBtnsSizerToRoute->Disconnect(
214 wxEVT_COMMAND_BUTTON_CLICKED,
215 wxCommandEventHandler(TrackPropDlg::OnToRouteBtnClick), NULL,
this);
216 if (m_sdbBtmBtnsSizerExport)
217 m_sdbBtmBtnsSizerExport->Disconnect(
218 wxEVT_COMMAND_BUTTON_CLICKED,
219 wxCommandEventHandler(TrackPropDlg::OnExportBtnClick), NULL,
this);
220 m_lcPoints->Disconnect(wxEVT_COMMAND_LIST_ITEM_SELECTED,
221 wxListEventHandler(TrackPropDlg::OnTrackPropListClick),
223 Disconnect(wxEVT_COMMAND_LIST_ITEM_RIGHT_CLICK,
224 wxListEventHandler(TrackPropDlg::OnTrackPropRightClick), NULL,
226 Disconnect(wxEVT_COMMAND_MENU_SELECTED,
227 wxCommandEventHandler(TrackPropDlg::OnTrackPropMenuSelected), NULL,
230 Disconnect(wxID_ANY, wxEVT_COMMAND_MENU_SELECTED,
232 Disconnect(wxID_ANY, wxEVT_COMMAND_MENU_SELECTED,
233 wxCommandEventHandler(TrackPropDlg::OnEditLink));
234 Disconnect(wxID_ANY, wxEVT_COMMAND_MENU_SELECTED,
235 wxCommandEventHandler(TrackPropDlg::OnAddLink));
238 m_buttonAddLink->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED,
239 wxCommandEventHandler(TrackPropDlg::OnAddLink),
241 m_toggleBtnEdit->Disconnect(
242 wxEVT_COMMAND_TOGGLEBUTTON_CLICKED,
243 wxCommandEventHandler(TrackPropDlg::OnEditLinkToggle), NULL,
this);
247 m_rbShowTimeUTC->Disconnect(
248 wxEVT_COMMAND_RADIOBUTTON_SELECTED,
249 wxCommandEventHandler(TrackPropDlg::OnShowTimeTZ), NULL,
this);
251 m_rbShowTimePC->Disconnect(
252 wxEVT_COMMAND_RADIOBUTTON_SELECTED,
253 wxCommandEventHandler(TrackPropDlg::OnShowTimeTZ), NULL,
this);
254 if (m_rbShowTimeLocal)
255 m_rbShowTimeLocal->Disconnect(
256 wxEVT_COMMAND_RADIOBUTTON_SELECTED,
257 wxCommandEventHandler(TrackPropDlg::OnShowTimeTZ), NULL,
this);
259 instanceFlag =
false;
262void TrackPropDlg::OnActivate(wxActivateEvent& event){
263 wxFrame* pWin = wxDynamicCast(event.GetEventObject(), wxFrame);
264 long int style = pWin->GetWindowStyle();
265 if (event.GetActive())
266 pWin->SetWindowStyle(style | wxSTAY_ON_TOP);
268 pWin->SetWindowStyle(style ^ wxSTAY_ON_TOP);
272void TrackPropDlg::RecalculateSize(
void) {
276 esize.x = GetCharWidth() * 110;
277 esize.y = GetCharHeight() * 40;
279 wxSize dsize = GetParent()->GetClientSize();
280 esize.y = wxMin(esize.y, dsize.y - (2 * GetCharHeight()));
281 esize.x = wxMin(esize.x, dsize.x - (2 * GetCharHeight()));
282 SetClientSize(esize);
284 wxSize fsize = GetSize();
285 fsize.y = wxMin(fsize.y, dsize.y - (2 * GetCharHeight()));
286 fsize.x = wxMin(fsize.x, dsize.x - (2 * GetCharHeight()));
290 int sy = GetCharHeight() * m_lcPoints->GetItemCount();
293 m_lcPoints->SetSize(wxSize(GetClientSize().x - 40, sy));
295 if (m_lcPoints->GetItemCount()) Layout();
301static void addColumns(wxListCtrl* lctrl,
int dx) {
302 lctrl->InsertColumn(0, _(
"Leg"), wxLIST_FORMAT_LEFT, dx * 6);
303 lctrl->InsertColumn(1, _(
"Distance"), wxLIST_FORMAT_LEFT, dx * 10);
304 lctrl->InsertColumn(2, _(
"Bearing"), wxLIST_FORMAT_LEFT, dx * 8);
305 lctrl->InsertColumn(3, _(
"Latitude"), wxLIST_FORMAT_LEFT, dx * 11);
306 lctrl->InsertColumn(4, _(
"Longitude"), wxLIST_FORMAT_LEFT, dx * 11);
308 lctrl->InsertColumn(5, _(
"Timestamp"), wxLIST_FORMAT_LEFT, dx * 19);
309 lctrl->InsertColumn(6, _(
"Speed"), wxLIST_FORMAT_CENTER, dx * 8);
311 lctrl->SetMinSize(wxSize(-1, 50));
314void TrackPropDlg::CreateControlsCompact() {
315 wxBoxSizer* itemBoxSizer1 =
new wxBoxSizer(wxVERTICAL);
316 SetSizer(itemBoxSizer1);
318 itemDialog1 =
new wxScrolledWindow(
this, wxID_ANY, wxDefaultPosition,
319 wxSize(-1, -1), wxVSCROLL);
320 itemDialog1->SetScrollRate(0, 1);
322#ifdef __OCPN__ANDROID__
324 wxFont* qFont = GetOCPNScaledFont(_(
"Dialog"));
326 wxString wqs = getFontQtStylesheet(qFont);
327 wxCharBuffer sbuf = wqs.ToUTF8();
328 QString qsb = QString(sbuf.data());
330 QString qsbq = getQtStyleSheet();
332 itemDialog1->GetHandle()->setStyleSheet(qsb +
336 itemBoxSizer1->Add(itemDialog1, 1, wxEXPAND | wxALL, 0);
338 wxBoxSizer* itemBoxSizer2 =
new wxBoxSizer(wxVERTICAL);
339 itemDialog1->SetSizer(itemBoxSizer2);
341 wxStaticText* itemStaticText4 =
new wxStaticText(
342 itemDialog1, wxID_STATIC, _(
"Name"), wxDefaultPosition, wxDefaultSize, 0);
343 itemBoxSizer2->Add(itemStaticText4, 0,
344 wxALIGN_LEFT | wxLEFT | wxRIGHT | wxTOP, 5);
346 m_tName =
new wxTextCtrl(itemDialog1, wxID_ANY, _T(
""), wxDefaultPosition,
348 itemBoxSizer2->Add(m_tName, 0, wxALIGN_LEFT | wxLEFT | wxRIGHT | wxBOTTOM, 5);
350 wxStaticText* itemStaticText7 =
351 new wxStaticText(itemDialog1, wxID_STATIC, _(
"Depart From"),
352 wxDefaultPosition, wxDefaultSize, 0);
353 itemBoxSizer2->Add(itemStaticText7, 0,
354 wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxLEFT | wxRIGHT,
357 m_tFrom =
new wxTextCtrl(itemDialog1, wxID_ANY, _T(
""), wxDefaultPosition,
359 itemBoxSizer2->Add(m_tFrom, 0,
360 wxEXPAND | wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL |
361 wxLEFT | wxRIGHT | wxBOTTOM,
364 wxStaticText* itemStaticText8 =
365 new wxStaticText(itemDialog1, wxID_STATIC, _(
"Destination"),
366 wxDefaultPosition, wxDefaultSize, 0);
367 itemBoxSizer2->Add(itemStaticText8, 0,
368 wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxLEFT | wxRIGHT,
371 m_tTo =
new wxTextCtrl(itemDialog1, wxID_ANY, _T(
""), wxDefaultPosition,
373 itemBoxSizer2->Add(m_tTo, 0,
374 wxEXPAND | wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL |
375 wxLEFT | wxRIGHT | wxBOTTOM,
378 m_cbShow =
new wxCheckBox(itemDialog1, wxID_ANY, _(
"Show on chart"),
379 wxDefaultPosition, wxDefaultSize, 0);
380 itemBoxSizer2->Add(m_cbShow, 0, wxALL, 5);
382 wxFlexGridSizer* itemFlexGridSizer6a =
new wxFlexGridSizer(4, 2, 0, 0);
383 itemFlexGridSizer6a->AddGrowableCol(1, 0);
385 itemBoxSizer2->Add(itemFlexGridSizer6a, 0, wxEXPAND | wxALIGN_LEFT | wxALL,
388 wxStaticText* itemStaticText11 =
389 new wxStaticText(itemDialog1, wxID_STATIC, _(
"Total distance"),
390 wxDefaultPosition, wxDefaultSize, 0);
391 itemFlexGridSizer6a->Add(
393 wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxLEFT | wxRIGHT | wxTOP, 5);
396 new wxTextCtrl(itemDialog1, wxID_ANY, _T(
""), wxDefaultPosition,
397 wxSize(-1, -1), wxTE_READONLY);
398 itemFlexGridSizer6a->Add(m_tTotDistance, 0,
399 wxEXPAND | wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL |
400 wxLEFT | wxRIGHT | wxBOTTOM,
403 m_stAvgSpeed =
new wxStaticText(itemDialog1, wxID_STATIC, _(
"Avg. speed"),
404 wxDefaultPosition, wxDefaultSize, 0);
405 itemFlexGridSizer6a->Add(
407 wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxLEFT | wxRIGHT | wxTOP, 5);
409 m_tAvgSpeed =
new wxTextCtrl(itemDialog1, wxID_ANY, _T(
""), wxDefaultPosition,
410 wxSize(150, -1), wxTE_PROCESS_ENTER);
411 itemFlexGridSizer6a->Add(
413 wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxLEFT | wxRIGHT | wxBOTTOM, 5);
416 new wxStaticText(itemDialog1, wxID_STATIC, _(
"Time Enroute"),
417 wxDefaultPosition, wxDefaultSize, 0);
418 itemFlexGridSizer6a->Add(
420 wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxLEFT | wxRIGHT | wxTOP, 5);
423 new wxTextCtrl(itemDialog1, wxID_ANY, _T(
""), wxDefaultPosition,
424 wxSize(-1, -1), wxTE_READONLY);
425 itemFlexGridSizer6a->Add(m_tTimeEnroute, 0,
426 wxEXPAND | wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL |
427 wxLEFT | wxRIGHT | wxBOTTOM,
444 wxString pDispTimeZone[] = {_(
"UTC"), _(
"Local @ PC"), _(
"LMT @ Location")};
446 wxStaticText* itemStaticText12b =
447 new wxStaticText(itemDialog1, wxID_STATIC, _(
"Time shown as"),
448 wxDefaultPosition, wxDefaultSize, 0);
449 itemBoxSizer2->Add(itemStaticText12b, 0, wxEXPAND | wxALL, 5);
452 new wxRadioButton(itemDialog1, wxID_ANY, _(
"UTC"), wxDefaultPosition,
453 wxDefaultSize, wxRB_GROUP);
456 wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxLEFT | wxRIGHT | wxBOTTOM, 5);
458 m_rbShowTimePC =
new wxRadioButton(itemDialog1, wxID_ANY, _(
"Local @ PC"));
461 wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxLEFT | wxRIGHT | wxBOTTOM, 5);
464 new wxRadioButton(itemDialog1, wxID_ANY, _(
"LMT @ Location"));
466 m_rbShowTimeLocal, 0,
467 wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxLEFT | wxRIGHT | wxBOTTOM, 5);
469 wxFlexGridSizer* itemFlexGridSizer6b =
new wxFlexGridSizer(3, 2, 0, 0);
470 itemBoxSizer2->Add(itemFlexGridSizer6b, 0, wxEXPAND | wxALIGN_LEFT | wxALL,
473 wxStaticText* m_staticText1 =
474 new wxStaticText(itemDialog1, wxID_ANY, _(
"Color") + _T(
":"),
475 wxDefaultPosition, wxDefaultSize, 0);
476 itemFlexGridSizer6b->Add(m_staticText1, 0, wxALIGN_CENTER_VERTICAL | wxALL,
479 wxString m_chColorChoices[] = {
480 _(
"Default color"), _(
"Black"), _(
"Dark Red"), _(
"Dark Green"),
481 _(
"Dark Yellow"), _(
"Dark Blue"), _(
"Dark Magenta"), _(
"Dark Cyan"),
482 _(
"Light Gray"), _(
"Dark Gray"), _(
"Red"), _(
"Green"),
483 _(
"Yellow"), _(
"Blue"), _(
"Magenta"), _(
"Cyan"),
485 int m_chColorNChoices =
sizeof(m_chColorChoices) /
sizeof(wxString);
487 new wxChoice(itemDialog1, wxID_ANY, wxDefaultPosition, wxSize(250, -1),
488 m_chColorNChoices, m_chColorChoices, 0);
489 m_cColor->SetSelection(0);
490 itemFlexGridSizer6b->Add(m_cColor, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
492 wxStaticText* staticTextStyle =
493 new wxStaticText(itemDialog1, wxID_ANY, _(
"Style") + _T(
":"),
494 wxDefaultPosition, wxDefaultSize, 0);
495 itemFlexGridSizer6b->Add(staticTextStyle, 0, wxALIGN_CENTER_VERTICAL | wxALL,
498 wxString m_chStyleChoices[] = {_(
"Default"), _(
"Solid"),
499 _(
"Dot"), _(
"Long dash"),
500 _(
"Short dash"), _(
"Dot dash")};
501 int m_chStyleNChoices =
sizeof(m_chStyleChoices) /
sizeof(wxString);
503 new wxChoice(itemDialog1, wxID_ANY, wxDefaultPosition, wxDefaultSize,
504 m_chStyleNChoices, m_chStyleChoices, 0);
505 m_cStyle->SetSelection(0);
506 itemFlexGridSizer6b->Add(m_cStyle, 0,
507 wxEXPAND | wxALIGN_CENTER_VERTICAL | wxALL, 5);
510 staticTextStyle->Hide();
514 m_stWidth =
new wxStaticText(itemDialog1, wxID_ANY, _(
"Width") + _T(
":"),
515 wxDefaultPosition, wxDefaultSize, 0);
516 itemFlexGridSizer6b->Add(m_stWidth, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
518 wxString m_chWidthChoices[] = {_(
"Default"), _(
"1 pixel"), _(
"2 pixels"),
519 _(
"3 pixels"), _(
"4 pixels"), _(
"5 pixels"),
520 _(
"6 pixels"), _(
"7 pixels"), _(
"8 pixels"),
521 _(
"9 pixels"), _(
"10 pixels")};
522 int m_chWidthNChoices =
sizeof(m_chWidthChoices) /
sizeof(wxString);
524 new wxChoice(itemDialog1, wxID_ANY, wxDefaultPosition, wxSize(150, -1),
525 m_chWidthNChoices, m_chWidthChoices, 0);
526 m_cWidth->SetSelection(0);
527 itemFlexGridSizer6b->Add(m_cWidth, 0,
528 wxEXPAND | wxALIGN_CENTER_VERTICAL | wxALL, 5);
530 wxStaticBox* itemStaticBoxSizer14Static =
531 new wxStaticBox(itemDialog1, wxID_ANY, _(
"Waypoints"));
532 wxStaticBoxSizer* m_pListSizer =
533 new wxStaticBoxSizer(itemStaticBoxSizer14Static, wxVERTICAL);
534 itemBoxSizer2->Add(m_pListSizer, 1, wxEXPAND | wxALL, 1);
536 wxScrolledWindow* itemlistWin =
537 new wxScrolledWindow(itemDialog1, wxID_ANY, wxDefaultPosition,
538 wxDefaultSize, wxHSCROLL | wxVSCROLL);
539 itemlistWin->SetScrollRate(2, 2);
541 m_pListSizer->Add(itemlistWin, 0, wxEXPAND | wxALL, 6);
543 long flags = wxLC_REPORT | wxLC_HRULES | wxLC_VRULES | wxLC_EDIT_LABELS;
545 flags |= wxLC_VIRTUAL;
549 wxSize(100, 500), flags);
550 addColumns(m_lcPoints, GetCharWidth());
554#ifdef __OCPN__ANDROID__
555 m_lcPoints->GetHandle()->setStyleSheet(getQtStyleSheet());
560 wxBoxSizer* itemBoxSizerBottom =
new wxBoxSizer(wxVERTICAL);
561 itemBoxSizer1->Add(itemBoxSizerBottom, 0, wxALIGN_LEFT | wxALL | wxEXPAND, 5);
565 wxFlexGridSizer* itemBoxSizerAux =
new wxFlexGridSizer(0, n_col, 0, 0);
566 itemBoxSizerAux->SetFlexibleDirection(wxBOTH);
567 itemBoxSizerAux->SetNonFlexibleGrowMode(wxFLEX_GROWMODE_SPECIFIED);
569 itemBoxSizerBottom->Add(itemBoxSizerAux, 1, wxALIGN_LEFT | wxALL, 5);
571#ifndef __OCPN__ANDROID__
573 m_sdbBtmBtnsSizerPrint =
new wxButton(
this, wxID_ANY, _(
"Print"),
574 wxDefaultPosition, wxDefaultSize, 0);
575 itemBoxSizerAux->Add(m_sdbBtmBtnsSizerPrint, 0,
576 wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxALL, 5);
577 m_sdbBtmBtnsSizerPrint->Enable(
true);
579 m_sdbBtmBtnsSizerPrint = NULL;
582 m_sdbBtmBtnsSizerSplit =
new wxButton(
this, wxID_ANY, _(
"Split"),
583 wxDefaultPosition, wxDefaultSize, 0);
584 itemBoxSizerAux->Add(m_sdbBtmBtnsSizerSplit, 0,
585 wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxALL, 5);
586 m_sdbBtmBtnsSizerSplit->Enable(
false);
588 m_sdbBtmBtnsSizerExtend =
new wxButton(
this, wxID_ANY, _(
"Extend"),
589 wxDefaultPosition, wxDefaultSize, 0);
590 itemBoxSizerAux->Add(m_sdbBtmBtnsSizerExtend, 0,
591 wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxALL, 5);
593 m_sdbBtmBtnsSizerToRoute =
new wxButton(
this, wxID_ANY, _(
"To route"),
594 wxDefaultPosition, wxDefaultSize, 0);
595 itemBoxSizerAux->Add(m_sdbBtmBtnsSizerToRoute, 0,
596 wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxALL, 5);
598 m_sdbBtmBtnsSizerExport = NULL;
604 wxBoxSizer* itemBoxSizer16 =
new wxBoxSizer(wxHORIZONTAL);
605 itemBoxSizerBottom->Add(itemBoxSizer16, 0, wxALIGN_RIGHT | wxALL, 5);
607 m_sdbBtmBtnsSizerCancel =
new wxButton(
this, wxID_CANCEL, _(
"Cancel"),
608 wxDefaultPosition, wxDefaultSize, 0);
609 itemBoxSizer16->Add(m_sdbBtmBtnsSizerCancel, 0,
610 wxALIGN_RIGHT | wxALIGN_BOTTOM | wxALL, 5);
612 m_sdbBtmBtnsSizerOK =
613 new wxButton(
this, wxID_OK, _(
"OK"), wxDefaultPosition, wxDefaultSize, 0);
614 itemBoxSizer16->Add(m_sdbBtmBtnsSizerOK, 0,
615 wxALIGN_RIGHT | wxALIGN_BOTTOM | wxALL, 5);
616 m_sdbBtmBtnsSizerOK->SetDefault();
618 int char_size = GetCharWidth();
621 ::wxDisplaySize(&width, &height);
622 SetSizeHints(-1, -1, width - 100, height - 100);
625void TrackPropDlg::CreateControls(
void) {
626 wxBoxSizer* bSizerMain;
627 bSizerMain =
new wxBoxSizer(wxVERTICAL);
628 SetSizer(bSizerMain);
631 new wxNotebook(
this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0);
633 bSizerMain->Add(m_notebook1, 1, wxEXPAND | wxALL, 5);
636 new wxPanel(m_notebook1, wxID_ANY, wxDefaultPosition, wxDefaultSize);
637 m_notebook1->AddPage(m_panel0, _(
"Basic"),
true);
639 wxBoxSizer* bSizer0 =
new wxBoxSizer(wxVERTICAL);
640 m_panel0->SetSizer(bSizer0);
642 wxBoxSizer* bSizer1 =
new wxBoxSizer(wxVERTICAL);
643 bSizer0->Add(bSizer1, 1, wxEXPAND | wxALL, 5);
645 m_panelBasic =
new wxScrolledWindow(m_panel0, wxID_ANY, wxDefaultPosition,
647 wxHSCROLL | wxVSCROLL | wxTAB_TRAVERSAL);
649#ifdef __OCPN__ANDROID__
651 wxFont* qFont = GetOCPNScaledFont(_(
"Dialog"));
653 wxString wqs = getFontQtStylesheet(qFont);
654 wxCharBuffer sbuf = wqs.ToUTF8();
655 QString qsb = QString(sbuf.data());
657 QString qsbq = getQtStyleSheet();
659 m_panelBasic->GetHandle()->setStyleSheet(qsb +
668 wxBoxSizer* bSizerBasic =
new wxBoxSizer(wxVERTICAL);
669 m_panelBasic->SetSizer(bSizerBasic);
671 bSizer1->Add(m_panelBasic, 1, wxEXPAND | wxALL, 5);
673 wxBoxSizer* bSizerName;
674 bSizerName =
new wxBoxSizer(wxHORIZONTAL);
675 bSizerBasic->Add(bSizerName, 0, wxALL | wxEXPAND, 5);
677 m_stName =
new wxStaticText(m_panelBasic, wxID_ANY, _(
"Name"),
678 wxDefaultPosition, wxDefaultSize, 0);
680 bSizerName->Add(m_stName, 0, wxALL, 5);
682 m_tName =
new wxTextCtrl(m_panelBasic, wxID_ANY, wxEmptyString,
683 wxDefaultPosition, wxDefaultSize, 0);
684 bSizerName->Add(m_tName, 1, 0, 5);
686 wxBoxSizer* bSizerFromTo;
687 bSizerFromTo =
new wxBoxSizer(wxHORIZONTAL);
688 bSizerBasic->Add(bSizerFromTo, 0, wxALL | wxEXPAND, 5);
690 m_stFrom =
new wxStaticText(m_panelBasic, wxID_ANY, _(
"From"),
691 wxDefaultPosition, wxDefaultSize, 0);
693 bSizerFromTo->Add(m_stFrom, 0, wxALL, 5);
695 m_tFrom =
new wxTextCtrl(m_panelBasic, wxID_ANY, wxEmptyString,
696 wxDefaultPosition, wxDefaultSize, 0);
697 bSizerFromTo->Add(m_tFrom, 1, 0, 5);
699 m_stTo =
new wxStaticText(m_panelBasic, wxID_ANY, _(
"To"), wxDefaultPosition,
702 bSizerFromTo->Add(m_stTo, 0, wxALL, 5);
704 m_tTo =
new wxTextCtrl(m_panelBasic, wxID_ANY, wxEmptyString,
705 wxDefaultPosition, wxDefaultSize, 0);
706 bSizerFromTo->Add(m_tTo, 1, 0, 5);
708 wxStaticBoxSizer* sbSizerParams;
709 sbSizerParams =
new wxStaticBoxSizer(
710 new wxStaticBox(m_panelBasic, wxID_ANY, _(
"Display parameters")),
712 bSizerBasic->Add(sbSizerParams, 0, wxALL | wxEXPAND, 5);
714 m_cbShow =
new wxCheckBox(m_panelBasic, wxID_ANY, _(
"Show on chart"),
715 wxDefaultPosition, wxDefaultSize, 0);
716 sbSizerParams->Add(m_cbShow, 0, wxALL, 5);
718 m_stColor =
new wxStaticText(m_panelBasic, wxID_ANY, _(
"Color"),
719 wxDefaultPosition, wxDefaultSize, 0);
721 sbSizerParams->Add(m_stColor, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
723 wxString m_cColorChoices[] = {
724 _(
"Default color"), _(
"Black"), _(
"Dark Red"), _(
"Dark Green"),
725 _(
"Dark Yellow"), _(
"Dark Blue"), _(
"Dark Magenta"), _(
"Dark Cyan"),
726 _(
"Light Gray"), _(
"Dark Gray"), _(
"Red"), _(
"Green"),
727 _(
"Yellow"), _(
"Blue"), _(
"Magenta"), _(
"Cyan"),
729 int m_cColorNChoices =
sizeof(m_cColorChoices) /
sizeof(wxString);
730 m_cColor =
new wxChoice(m_panelBasic, wxID_ANY, wxDefaultPosition,
731 wxDefaultSize, m_cColorNChoices, m_cColorChoices, 0);
732 m_cColor->SetSelection(0);
733 sbSizerParams->Add(m_cColor, 1, 0, 5);
735 m_stStyle =
new wxStaticText(m_panelBasic, wxID_ANY, _(
"Style"),
736 wxDefaultPosition, wxDefaultSize, 0);
738 sbSizerParams->Add(m_stStyle, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
740 wxString m_cStyleChoices[] = {_(
"Default"), _(
"Solid"), _(
"Dot"),
741 _(
"Long dash"), _(
"Short dash"), _(
"Dot dash")};
742 int m_cStyleNChoices =
sizeof(m_cStyleChoices) /
sizeof(wxString);
743 m_cStyle =
new wxChoice(m_panelBasic, wxID_ANY, wxDefaultPosition,
744 wxDefaultSize, m_cStyleNChoices, m_cStyleChoices, 0);
745 m_cStyle->SetSelection(0);
746 sbSizerParams->Add(m_cStyle, 1, 0, 5);
748 m_stWidth =
new wxStaticText(m_panelBasic, wxID_ANY, _(
"Width"),
749 wxDefaultPosition, wxDefaultSize, 0);
751 sbSizerParams->Add(m_stWidth, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
753 wxString m_cWidthChoices[] = {_(
"Default"), _(
"1 pixel"), _(
"2 pixels"),
754 _(
"3 pixels"), _(
"4 pixels"), _(
"5 pixels"),
755 _(
"6 pixels"), _(
"7 pixels"), _(
"8 pixels"),
756 _(
"9 pixels"), _(
"10 pixels")};
757 int m_cWidthNChoices =
sizeof(m_cWidthChoices) /
sizeof(wxString);
758 m_cWidth =
new wxChoice(m_panelBasic, wxID_ANY, wxDefaultPosition,
759 wxDefaultSize, m_cWidthNChoices, m_cWidthChoices, 0);
760 m_cWidth->SetSelection(0);
761 sbSizerParams->Add(m_cWidth, 1, 0, 5);
763 wxStaticBoxSizer* sbSizerStats;
764 sbSizerStats =
new wxStaticBoxSizer(
765 new wxStaticBox(m_panelBasic, wxID_ANY, _(
"Statistics")), wxVERTICAL);
766 bSizerBasic->Add(sbSizerStats, 0, wxALL | wxEXPAND, 5);
768 wxBoxSizer* bSizerStats;
769 bSizerStats =
new wxBoxSizer(wxHORIZONTAL);
772 new wxStaticText(m_panelBasic, wxID_ANY, _(
"Total distance"),
773 wxDefaultPosition, wxDefaultSize, 0);
775 bSizerStats->Add(m_stTotDistance, 0, wxALL, 5);
778 new wxTextCtrl(m_panelBasic, wxID_ANY, wxEmptyString, wxDefaultPosition,
779 wxDefaultSize, wxTE_READONLY);
780 bSizerStats->Add(m_tTotDistance, 1, 0, 5);
782 m_stAvgSpeed =
new wxStaticText(m_panelBasic, wxID_ANY, _(
"Avg. speed"),
783 wxDefaultPosition, wxDefaultSize, 0);
785 bSizerStats->Add(m_stAvgSpeed, 0, wxALL, 5);
787 m_tAvgSpeed =
new wxTextCtrl(m_panelBasic, wxID_ANY, wxEmptyString,
788 wxDefaultPosition, wxDefaultSize, wxTE_READONLY);
789 bSizerStats->Add(m_tAvgSpeed, 1, 0, 5);
791 m_stTimeEnroute =
new wxStaticText(m_panelBasic, wxID_ANY, _(
"Time enroute"),
792 wxDefaultPosition, wxDefaultSize, 0);
794 bSizerStats->Add(m_stTimeEnroute, 0, wxALL, 5);
797 new wxTextCtrl(m_panelBasic, wxID_ANY, wxEmptyString, wxDefaultPosition,
798 wxDefaultSize, wxTE_READONLY);
799 bSizerStats->Add(m_tTimeEnroute, 2, 0, 5);
801 sbSizerStats->Add(bSizerStats, 0, wxEXPAND, 5);
803 wxStaticBoxSizer* sbSizerPoints;
804 sbSizerPoints =
new wxStaticBoxSizer(
805 new wxStaticBox(m_panel0, wxID_ANY, _(
"Recorded points")), wxVERTICAL);
806 bSizer1->Add(sbSizerPoints, 1, wxALL | wxEXPAND, 5);
808 wxBoxSizer* bSizerShowTime;
809 bSizerShowTime =
new wxBoxSizer(wxHORIZONTAL);
811 m_stShowTime =
new wxStaticText(m_panel0, wxID_ANY, _(
"Time shown as"),
812 wxDefaultPosition, wxDefaultSize, 0);
814 bSizerShowTime->Add(m_stShowTime, 0, wxALL, 5);
816 m_rbShowTimeUTC =
new wxRadioButton(m_panel0, wxID_ANY, _(
"UTC"),
817 wxDefaultPosition, wxDefaultSize, 0);
818 bSizerShowTime->Add(m_rbShowTimeUTC, 0, 0, 5);
820 m_rbShowTimePC =
new wxRadioButton(m_panel0, wxID_ANY, _(
"Local @ PC"),
821 wxDefaultPosition, wxDefaultSize, 0);
822 bSizerShowTime->Add(m_rbShowTimePC, 0, 0, 5);
825 new wxRadioButton(m_panel0, wxID_ANY, _(
"LMT @ Track Start"),
826 wxDefaultPosition, wxDefaultSize, 0);
827 bSizerShowTime->Add(m_rbShowTimeLocal, 0, 0, 5);
829 m_rbShowTimePC->SetValue(
true);
831 sbSizerPoints->Add(bSizerShowTime, 0, wxEXPAND, 5);
833 long flags = wxLC_REPORT | wxLC_HRULES | wxLC_VRULES | wxLC_EDIT_LABELS;
835 flags |= wxLC_VIRTUAL;
839 wxDefaultSize, flags);
840 addColumns(m_lcPoints, GetCharWidth());
842 sbSizerPoints->Add(m_lcPoints, 1, wxALL | wxEXPAND, 5);
844#ifdef __OCPN__ANDROID__
845 m_lcPoints->GetHandle()->setStyleSheet(getQtStyleSheet());
859 m_panelAdvanced =
new wxScrolledWindow(
860 m_notebook1, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL);
862 wxBoxSizer* bSizerAdvanced;
863 bSizerAdvanced =
new wxBoxSizer(wxVERTICAL);
866 new wxStaticText(m_panelAdvanced, wxID_ANY, _(
"Description"),
867 wxDefaultPosition, wxDefaultSize, 0);
869 bSizerAdvanced->Add(m_stDescription, 0, wxALL, 5);
872 new wxTextCtrl(m_panelAdvanced, wxID_ANY, wxEmptyString,
873 wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE);
874 bSizerAdvanced->Add(m_tDescription, 1, wxALL | wxEXPAND, 5);
876 sbSizerLinks =
new wxStaticBoxSizer(
877 new wxStaticBox(m_panelAdvanced, wxID_ANY, _(
"Links")), wxVERTICAL);
879 m_scrolledWindowLinks =
880 new wxScrolledWindow(m_panelAdvanced, wxID_ANY, wxDefaultPosition,
881 wxDefaultSize, wxHSCROLL | wxVSCROLL);
882 m_scrolledWindowLinks->SetScrollRate(5, 5);
883 bSizerLinks =
new wxBoxSizer(wxVERTICAL);
886 new wxHyperlinkCtrl(m_scrolledWindowLinks, wxID_ANY, _(
"wxFB Website"),
887 wxT(
"http://www.wxformbuilder.org"),
888 wxDefaultPosition, wxDefaultSize, wxHL_DEFAULT_STYLE);
889 m_menuLink =
new wxMenu();
891 new wxMenuItem(m_menuLink, ID_TRK_MENU_EDIT, wxString(_(
"Edit")),
892 wxEmptyString, wxITEM_NORMAL);
893 m_menuLink->Append(m_menuItemEdit);
896 new wxMenuItem(m_menuLink, ID_TRK_MENU_ADD, wxString(_(
"Add new")),
897 wxEmptyString, wxITEM_NORMAL);
898 m_menuLink->Append(m_menuItemAdd);
901 new wxMenuItem(m_menuLink, ID_TRK_MENU_DELETE, wxString(_(
"Delete")),
902 wxEmptyString, wxITEM_NORMAL);
903 m_menuLink->Append(m_menuItemDelete);
905 m_hyperlink1->Connect(
907 wxMouseEventHandler(TrackPropDlg::m_hyperlink1OnContextMenu), NULL,
this);
909 bSizerLinks->Add(m_hyperlink1, 0, wxALL, 5);
911 m_scrolledWindowLinks->SetSizer(bSizerLinks);
912 m_scrolledWindowLinks->Layout();
913 bSizerLinks->Fit(m_scrolledWindowLinks);
914 sbSizerLinks->Add(m_scrolledWindowLinks, 1, wxEXPAND | wxALL, 5);
916 wxBoxSizer* bSizerLinkBtns;
917 bSizerLinkBtns =
new wxBoxSizer(wxHORIZONTAL);
920 new wxButton(m_panelAdvanced, wxID_ANY, _(
"Add"), wxDefaultPosition,
921 wxDefaultSize, wxBU_EXACTFIT);
922 bSizerLinkBtns->Add(m_buttonAddLink, 0, wxALL, 5);
924 m_toggleBtnEdit =
new wxToggleButton(m_panelAdvanced, wxID_ANY, _(
"Edit"),
925 wxDefaultPosition, wxDefaultSize, 0);
926 bSizerLinkBtns->Add(m_toggleBtnEdit, 0, wxALL, 5);
928 m_staticTextEditEnabled =
new wxStaticText(
929 m_panelAdvanced, wxID_ANY, _(
"Links are opened in the default browser."),
930 wxDefaultPosition, wxDefaultSize, 0);
932 bSizerLinkBtns->Add(m_staticTextEditEnabled, 0,
933 wxALIGN_CENTER_VERTICAL | wxALL, 5);
935 sbSizerLinks->Add(bSizerLinkBtns, 0, wxEXPAND, 5);
937 bSizerAdvanced->Add(sbSizerLinks, 1, wxEXPAND, 5);
939 m_panelAdvanced->SetSizer(bSizerAdvanced);
940 m_notebook1->AddPage(m_panelAdvanced, _(
"Advanced"),
false);
944 wxBoxSizer* itemBoxSizerBottom =
new wxBoxSizer(wxVERTICAL);
945 bSizerMain->Add(itemBoxSizerBottom, 0, wxALIGN_LEFT | wxALL | wxEXPAND, 5);
951 wxFlexGridSizer* itemBoxSizerAux =
new wxFlexGridSizer(0, n_col, 0, 0);
952 itemBoxSizerAux->SetFlexibleDirection(wxBOTH);
953 itemBoxSizerAux->SetNonFlexibleGrowMode(wxFLEX_GROWMODE_SPECIFIED);
955 itemBoxSizerBottom->Add(itemBoxSizerAux, 1, wxALIGN_LEFT | wxALL, 5);
957#ifndef __OCPN__ANDROID__
959 m_sdbBtmBtnsSizerPrint =
new wxButton(
this, wxID_ANY, _(
"Print"),
960 wxDefaultPosition, wxDefaultSize, 0);
961 itemBoxSizerAux->Add(m_sdbBtmBtnsSizerPrint, 0,
962 wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxALL, 5);
963 m_sdbBtmBtnsSizerPrint->Enable(
true);
965 m_sdbBtmBtnsSizerPrint = NULL;
968 m_sdbBtmBtnsSizerSplit =
new wxButton(
this, wxID_ANY, _(
"Split"),
969 wxDefaultPosition, wxDefaultSize, 0);
970 itemBoxSizerAux->Add(m_sdbBtmBtnsSizerSplit, 0,
971 wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxALL, 5);
972 m_sdbBtmBtnsSizerSplit->Enable(
false);
974 m_sdbBtmBtnsSizerExtend =
new wxButton(
this, wxID_ANY, _(
"Extend track"),
975 wxDefaultPosition, wxDefaultSize, 0);
976 itemBoxSizerAux->Add(m_sdbBtmBtnsSizerExtend, 0,
977 wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxALL, 5);
979 m_sdbBtmBtnsSizerToRoute =
new wxButton(
this, wxID_ANY, _(
"To route"),
980 wxDefaultPosition, wxDefaultSize, 0);
981 itemBoxSizerAux->Add(m_sdbBtmBtnsSizerToRoute, 0,
982 wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxALL, 5);
984 m_sdbBtmBtnsSizerExport =
new wxButton(
this, wxID_ANY, _(
"Export"),
985 wxDefaultPosition, wxDefaultSize, 0);
986 itemBoxSizerAux->Add(m_sdbBtmBtnsSizerExport, 0,
987 wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxALL, 5);
989 wxBoxSizer* itemBoxSizer16 =
new wxBoxSizer(wxHORIZONTAL);
990 itemBoxSizerBottom->Add(itemBoxSizer16, 0, wxALIGN_RIGHT | wxALL, 5);
992 m_sdbBtmBtnsSizerCancel =
new wxButton(
this, wxID_CANCEL, _(
"Cancel"),
993 wxDefaultPosition, wxDefaultSize, 0);
994 itemBoxSizer16->Add(m_sdbBtmBtnsSizerCancel, 0, wxALIGN_BOTTOM | wxALL, 5);
996 m_sdbBtmBtnsSizerOK =
997 new wxButton(
this, wxID_OK, _(
"OK"), wxDefaultPosition, wxDefaultSize, 0);
998 itemBoxSizer16->Add(m_sdbBtmBtnsSizerOK, 0, wxALIGN_BOTTOM | wxALL, 5);
999 m_sdbBtmBtnsSizerOK->SetDefault();
1003 ((wxWindowBase*)m_stName)->GetSize(&w1, &h);
1004 ((wxWindowBase*)m_stFrom)->GetSize(&w2, &h);
1005 ((wxWindowBase*)m_stName)->SetMinSize(wxSize(wxMax(w1, w2), h));
1006 ((wxWindowBase*)m_stFrom)->SetMinSize(wxSize(wxMax(w1, w2), h));
1008 m_panelBasic->SetScrollRate(5, 5);
1009 m_panelAdvanced->SetScrollRate(5, 5);
1012void TrackPropDlg::SetTrackAndUpdate(
Track* pt) {
1015 m_lcPoints->DeleteAllItems();
1017 if (m_pMyLinkList)
delete m_pMyLinkList;
1018 m_pMyLinkList =
new HyperlinkList();
1020 int NbrOfLinks = m_pTrack->m_HyperlinkList->GetCount();
1021 if (NbrOfLinks > 0) {
1022 wxHyperlinkListNode* linknode = m_pTrack->m_HyperlinkList->GetFirst();
1027 h->DescrText = link->DescrText;
1028 h->Link = link->Link;
1029 h->LType = link->LType;
1031 m_pMyLinkList->Append(h);
1033 linknode = linknode->GetNext();
1043void TrackPropDlg::InitializeList() {
1044 if (NULL == m_pTrack)
return;
1046 m_lcPoints->m_pTrack = m_pTrack;
1048 if (m_pTrack->GetnPoints()) {
1051 m_lcPoints->m_LMT_Offset = long((prp->m_lon) * 3600. / 15.);
1053 m_lcPoints->m_LMT_Offset = 0;
1056 if (m_lcPoints->IsVirtual())
1057 m_lcPoints->SetItemCount(m_pTrack->GetnPoints());
1060 for (
int in = 0; in < m_pTrack->GetnPoints(); in++) {
1064 m_lcPoints->InsertItem(item);
1065 for (
int j = 0; j < 7; j++) {
1067 item.SetText(m_lcPoints->OnGetItemText(in, j));
1068 m_lcPoints->SetItem(item);
1075 if (NULL == m_pTrack)
return false;
1077 ::wxBeginBusyCursor();
1079 if (m_scrolledWindowLinks) {
1080 wxWindowList kids = m_scrolledWindowLinks->GetChildren();
1081 for (
unsigned int i = 0; i < kids.GetCount(); i++) {
1082 wxWindowListNode* node = kids.Item(i);
1083 wxWindow* win = node->GetData();
1085 if (win->IsKindOf(CLASSINFO(wxHyperlinkCtrl))) {
1086 ((wxHyperlinkCtrl*)win)
1088 wxEVT_COMMAND_HYPERLINK,
1089 wxHyperlinkEventHandler(TrackPropDlg::OnHyperLinkClick));
1090 ((wxHyperlinkCtrl*)win)
1093 wxMouseEventHandler(TrackPropDlg::m_hyperlinkContextMenu));
1098 int NbrOfLinks = m_pTrack->m_HyperlinkList->GetCount();
1099 HyperlinkList* hyperlinklist = m_pTrack->m_HyperlinkList;
1101 if (NbrOfLinks > 0) {
1102 wxHyperlinkListNode* linknode = hyperlinklist->GetFirst();
1105 wxString Link = link->Link;
1106 wxString Descr = link->DescrText;
1108 wxHyperlinkCtrl* ctrl =
new wxHyperlinkCtrl(
1109 m_scrolledWindowLinks, wxID_ANY, Descr, Link, wxDefaultPosition,
1110 wxDefaultSize, wxHL_DEFAULT_STYLE);
1111 ctrl->Connect(wxEVT_COMMAND_HYPERLINK,
1112 wxHyperlinkEventHandler(TrackPropDlg::OnHyperLinkClick),
1114 if (!m_pTrack->m_bIsInLayer)
1117 wxMouseEventHandler(TrackPropDlg::m_hyperlinkContextMenu), NULL,
1120 bSizerLinks->Add(ctrl, 0, wxALL, 5);
1122 linknode = linknode->GetNext();
1125 bSizerLinks->Fit(m_scrolledWindowLinks);
1128 m_tName->SetValue(m_pTrack->GetName());
1129 m_tFrom->SetValue(m_pTrack->m_TrackStartString);
1130 m_tTo->SetValue(m_pTrack->m_TrackEndString);
1131 if (m_tDescription) m_tDescription->SetValue(m_pTrack->m_TrackDescription);
1133 m_tTotDistance->SetValue(_T(
""));
1134 m_tTimeEnroute->SetValue(_T(
""));
1136 m_sdbBtmBtnsSizerSplit->Enable(
false);
1137 m_sdbBtmBtnsSizerExtend->Enable(
false);
1140 TrackPoint* last_point = m_pTrack->GetLastPoint();
1141 TrackPoint* first_point = m_pTrack->GetPoint(0);
1142 double trackLength = m_pTrack->Length();
1143 double total_seconds = 0.;
1145 wxString speed(_T(
"--"));
1147 if (last_point && first_point) {
1148 if (last_point->GetCreateTime().IsValid() &&
1149 first_point->GetCreateTime().IsValid()) {
1150 total_seconds = last_point->GetCreateTime()
1151 .Subtract(first_point->GetCreateTime())
1154 if (total_seconds != 0.) {
1155 m_avgspeed = trackLength / total_seconds * 3600;
1159 speed.Printf(_T(
"%5.2f"), toUsrSpeed(m_avgspeed));
1163 m_tAvgSpeed->SetValue(speed);
1167 slen.Printf(wxT(
"%5.2f ") + getUsrDistanceUnit(), toUsrDistance(trackLength));
1169 m_tTotDistance->SetValue(slen);
1173 wxTimeSpan time(0, 0, (
int)total_seconds, 0);
1175 if (total_seconds > 3600. * 24.)
1176 time_form = time.Format(
"%H:%M");
1177 else if (total_seconds > 0.)
1178 time_form = time.Format(
"%H:%M");
1180 time_form = _T(
"--");
1181 m_tTimeEnroute->SetValue(time_form);
1183 m_cbShow->SetValue(m_pTrack->IsVisible());
1185 if (m_pTrack->m_Colour == wxEmptyString)
1186 m_cColor->Select(0);
1188 for (
unsigned int i = 0; i <
sizeof(::GpxxColorNames) /
sizeof(wxString);
1190 if (m_pTrack->m_Colour == ::GpxxColorNames[i]) {
1191 m_cColor->Select(i + 1);
1197 for (
unsigned int i = 0; i <
sizeof(::StyleValues) /
sizeof(
int); i++) {
1198 if (m_pTrack->m_style == ::StyleValues[i]) {
1199 m_cStyle->Select(i);
1204 for (
unsigned int i = 0; i <
sizeof(::WidthValues) /
sizeof(
int); i++) {
1205 if (m_pTrack->m_width == ::WidthValues[i]) {
1206 m_cWidth->Select(i);
1211 if (m_pTrack->m_bIsInLayer) {
1212 m_tName->SetEditable(
false);
1213 m_tFrom->SetEditable(
false);
1214 m_tTo->SetEditable(
false);
1215 if (m_tDescription) m_tDescription->SetEditable(
false);
1216 m_cbShow->Enable(
false);
1217 m_cColor->Enable(
false);
1218 m_cStyle->Enable(
false);
1219 m_cWidth->Enable(
false);
1220 m_sdbBtmBtnsSizerExtend->Enable(
false);
1221 m_sdbBtmBtnsSizerSplit->Enable(
false);
1222 SetTitle(wxString::Format(_T(
"%s, %s: %d"), _(
"Track properties"),
1223 _T(
"Layer"), m_pTrack->m_LayerID));
1225 m_tName->SetEditable(
true);
1226 m_tFrom->SetEditable(
true);
1227 m_tTo->SetEditable(
true);
1228 if (m_tDescription) m_tDescription->SetEditable(
true);
1229 m_cbShow->Enable(
true);
1230 m_cColor->Enable(
true);
1231 m_cStyle->Enable(
true);
1232 m_cWidth->Enable(
true);
1234 m_sdbBtmBtnsSizerExtend->Enable(IsThisTrackExtendable());
1236 SetTitle(_(
"Track properties"));
1239 ::wxEndBusyCursor();
1244bool TrackPropDlg::IsThisTrackExtendable() {
1245 m_pExtendTrack = NULL;
1246 m_pExtendPoint = NULL;
1247 if (m_pTrack == g_pActiveTrack || m_pTrack->m_bIsInLayer) {
1251 TrackPoint* pLastPoint = m_pTrack->GetPoint(0);
1252 if (!pLastPoint->GetCreateTime().IsValid()) {
1256 for (
Track* ptrack : g_TrackList) {
1257 if (ptrack->IsVisible() && (ptrack->m_GUID != m_pTrack->m_GUID)) {
1258 TrackPoint* track_node = ptrack->GetLastPoint();
1260 if (track_node->GetCreateTime().IsValid()) {
1261 if (track_node->GetCreateTime() <= pLastPoint->GetCreateTime()) {
1262 if (!m_pExtendPoint ||
1263 track_node->GetCreateTime() > m_pExtendPoint->GetCreateTime()) {
1264 m_pExtendPoint = track_node;
1265 m_pExtendTrack = ptrack;
1272 if (m_pExtendTrack) {
1273 return (!m_pExtendTrack->m_bIsInLayer);
1279void TrackPropDlg::OnExtendBtnClick(wxCommandEvent& event) {
1280 TrackPoint* pFirstPoint = m_pTrack->GetPoint(0);
1282 if (IsThisTrackExtendable()) {
1284 if (pFirstPoint->GetCreateTime() == m_pExtendPoint->GetCreateTime()) {
1287 pSelect->DeleteAllSelectableTrackSegments(m_pExtendTrack);
1288 m_pExtendTrack->Clone(m_pTrack, begin, m_pTrack->GetnPoints(), _(
"_plus"));
1289 pSelect->AddAllSelectableTrackSegments(m_pExtendTrack);
1290 pSelect->DeleteAllSelectableTrackSegments(m_pTrack);
1293 SetTrackAndUpdate(m_pExtendTrack);
1296 if (pRouteManagerDialog && pRouteManagerDialog->IsShown()) {
1297 pRouteManagerDialog->UpdateTrkListCtrl();
1302void TrackPropDlg::OnSplitBtnClick(wxCommandEvent& event) {
1303 m_sdbBtmBtnsSizerSplit->Enable(
false);
1305 if (m_pTrack->m_bIsInLayer) {
1309 if ((m_nSelected > 1) && (m_nSelected < m_pTrack->GetnPoints())) {
1312 pHead->Clone(m_pTrack, 0, m_nSelected - 1, _(
"_A"));
1313 pTail->Clone(m_pTrack, m_nSelected - 1, m_pTrack->GetnPoints(), _(
"_B"));
1314 g_TrackList.push_back(pHead);
1315 pConfig->AddNewTrack(pHead);
1317 g_TrackList.push_back(pTail);
1318 pConfig->AddNewTrack(pTail);
1320 pConfig->DeleteConfigTrack(m_pTrack);
1322 pSelect->DeleteAllSelectableTrackSegments(m_pTrack);
1324 pSelect->AddAllSelectableTrackSegments(pTail);
1325 pSelect->AddAllSelectableTrackSegments(pHead);
1327 SetTrackAndUpdate(pTail);
1330 if (pRouteManagerDialog && pRouteManagerDialog->IsShown()) {
1331 pRouteManagerDialog->UpdateTrkListCtrl();
1336void TrackPropDlg::OnTrackPropCopyTxtClick(wxCommandEvent& event) {
1337 wxString tab(
"\t", wxConvUTF8);
1338 wxString eol(
"\n", wxConvUTF8);
1341 csvString << this->GetTitle() << eol << _(
"Name") << tab
1342 << m_pTrack->GetName() << eol << _(
"Depart From") << tab
1343 << m_pTrack->m_TrackStartString << eol << _(
"Destination") << tab
1344 << m_pTrack->m_TrackEndString << eol << _(
"Total distance") << tab
1345 << m_tTotDistance->GetValue() << eol << _(
"Speed") << tab
1346 << m_tAvgSpeed->GetValue() << eol
1347 << _(
"Departure Time") + _T(
" ") + _(
"(m/d/y h:m)") << tab
1348 << m_pTrack->GetPoint(1)->GetCreateTime().Format() << eol
1349 << _(
"Time enroute") << tab << m_tTimeEnroute->GetValue() << eol
1354 noCols = m_lcPoints->GetColumnCount();
1355 noRows = m_lcPoints->GetItemCount();
1357 item.SetMask(wxLIST_MASK_TEXT);
1359 for (
int i = 0; i < noCols; i++) {
1360 m_lcPoints->GetColumn(i, item);
1361 csvString << item.GetText() << tab;
1365 for (
int j = 0; j < noRows; j++) {
1367 for (
int i = 0; i < noCols; i++) {
1369 m_lcPoints->GetItem(item);
1370 csvString << item.GetText() << tab;
1375 if (wxTheClipboard->Open()) {
1376 wxTextDataObject* data =
new wxTextDataObject;
1377 data->SetText(csvString);
1378 wxTheClipboard->SetData(data);
1379 wxTheClipboard->Close();
1383void TrackPropDlg::OnPrintBtnClick(wxCommandEvent& event) {
1387 dlg->ShowWindowModalThenDo([
this, dlg](
int retcode) {
1388 if (retcode == wxID_OK) {
1393void TrackPropDlg::OnTrackPropRightClick(wxListEvent& event) {
1396 wxMenuItem* copyItem =
1397 menu.Append(ID_RCLK_MENU_COPY_TEXT, _(
"&Copy all as text"));
1402void TrackPropDlg::OnTrackPropListClick(wxListEvent& event) {
1408 m_lcPoints->GetNextItem(itemno, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
1412 selected_no = itemno;
1414 m_pTrack->m_HighlightedTrackPoint = -1;
1417 TrackPoint* prp = m_pTrack->GetPoint(itemno);
1419 m_pTrack->m_HighlightedTrackPoint = itemno;
1421 if (!(m_pTrack->m_bIsInLayer) && !(m_pTrack == g_pActiveTrack)) {
1422 m_nSelected = selected_no + 1;
1423 m_sdbBtmBtnsSizerSplit->Enable(
true);
1425 gFrame->JumpToPosition(gFrame->GetPrimaryCanvas(), prp->m_lat, prp->m_lon,
1426 gFrame->GetPrimaryCanvas()->GetVPScale());
1428 if (m_lcPoints) m_lcPoints->SetFocus();
1432 if (selected_no == 0 || selected_no == m_pTrack->GetnPoints() - 1)
1433 m_sdbBtmBtnsSizerSplit->Enable(
false);
1436void TrackPropDlg::OnTrackPropMenuSelected(wxCommandEvent& event) {
1437 switch (event.GetId()) {
1438 case ID_RCLK_MENU_COPY_TEXT:
1439 OnTrackPropCopyTxtClick(event);
1444void TrackPropDlg::OnToRouteBtnClick(wxCommandEvent& event) {
1445 pRouteManagerDialog->TrackToRoute(m_pTrack);
1446 if (NULL != pRouteManagerDialog && pRouteManagerDialog->IsVisible())
1447 pRouteManagerDialog->UpdateRouteListCtrl();
1450void TrackPropDlg::OnExportBtnClick(wxCommandEvent& event) {
1451 wxString suggested_name = _(
"track");
1452 std::vector<Track*> list = { m_pTrack };
1453 if (m_pTrack->GetName() != wxEmptyString)
1454 suggested_name = m_pTrack->GetName();
1455 ExportGPXTracks(
this, &list, suggested_name);
1458void TrackPropDlg::m_hyperlinkContextMenu(wxMouseEvent& event) {
1459 m_pEditedLink = (wxHyperlinkCtrl*)event.GetEventObject();
1461 wxEVT_COMMAND_MENU_SELECTED,
1462 (wxObjectEventFunction)(wxEventFunction)&TrackPropDlg::PopupMenuHandler);
1463 m_scrolledWindowLinks->PopupMenu(
1464 m_menuLink, m_pEditedLink->GetPosition().x + event.GetPosition().x,
1465 m_pEditedLink->GetPosition().y + event.GetPosition().y);
1468void TrackPropDlg::PopupMenuHandler(wxCommandEvent& event) {
1469 switch (event.GetId()) {
1470 case ID_TRK_MENU_ADD:
1473 case ID_TRK_MENU_EDIT:
1476 case ID_TRK_MENU_DELETE:
1485 wxHyperlinkListNode* nodeToDelete = NULL;
1486 wxString findurl = m_pEditedLink->GetURL();
1487 wxString findlabel = m_pEditedLink->GetLabel();
1489 wxWindowList kids = m_scrolledWindowLinks->GetChildren();
1490 for (
unsigned int i = 0; i < kids.GetCount(); i++) {
1491 wxWindowListNode* node = kids.Item(i);
1492 wxWindow* win = node->GetData();
1494 if (win->IsKindOf(CLASSINFO(wxHyperlinkCtrl))) {
1495 ((wxHyperlinkCtrl*)win)
1496 ->Disconnect(wxEVT_COMMAND_HYPERLINK,
1497 wxHyperlinkEventHandler(TrackPropDlg::OnHyperLinkClick));
1498 ((wxHyperlinkCtrl*)win)
1501 wxMouseEventHandler(TrackPropDlg::m_hyperlinkContextMenu));
1507 int NbrOfLinks = m_pTrack->m_HyperlinkList->GetCount();
1508 HyperlinkList* hyperlinklist = m_pTrack->m_HyperlinkList;
1510 if (NbrOfLinks > 0) {
1511 wxHyperlinkListNode* linknode = hyperlinklist->GetFirst();
1514 wxString Link = link->Link;
1515 wxString Descr = link->DescrText;
1516 if (Link == findurl &&
1517 (Descr == findlabel || (Link == findlabel && Descr == wxEmptyString)))
1518 nodeToDelete = linknode;
1520 wxHyperlinkCtrl* ctrl =
new wxHyperlinkCtrl(
1521 m_scrolledWindowLinks, wxID_ANY, Descr, Link, wxDefaultPosition,
1522 wxDefaultSize, wxHL_DEFAULT_STYLE);
1523 ctrl->Connect(wxEVT_COMMAND_HYPERLINK,
1524 wxHyperlinkEventHandler(TrackPropDlg::OnHyperLinkClick),
1526 ctrl->Connect(wxEVT_RIGHT_DOWN,
1527 wxMouseEventHandler(TrackPropDlg::m_hyperlinkContextMenu),
1530 bSizerLinks->Add(ctrl, 0, wxALL, 5);
1532 linknode = linknode->GetNext();
1535 if (nodeToDelete) hyperlinklist->DeleteNode(nodeToDelete);
1536 m_scrolledWindowLinks->InvalidateBestSize();
1537 m_scrolledWindowLinks->Layout();
1538 sbSizerLinks->Layout();
1542void TrackPropDlg::OnEditLink(wxCommandEvent& event) {
1543 wxString findurl = m_pEditedLink->GetURL();
1544 wxString findlabel = m_pEditedLink->GetLabel();
1547 LinkPropDlg->m_textCtrlLinkDescription->SetValue(findlabel);
1548 LinkPropDlg->m_textCtrlLinkUrl->SetValue(findurl);
1549 DimeControl(LinkPropDlg);
1550 LinkPropDlg->ShowWindowModalThenDo([
this, LinkPropDlg, findurl,
1551 findlabel](
int retcode) {
1552 if (retcode == wxID_OK) {
1553 int NbrOfLinks = m_pTrack->m_HyperlinkList->GetCount();
1554 HyperlinkList* hyperlinklist = m_pTrack->m_HyperlinkList;
1556 if (NbrOfLinks > 0) {
1557 wxHyperlinkListNode* linknode = hyperlinklist->GetFirst();
1560 wxString Link = link->Link;
1561 wxString Descr = link->DescrText;
1562 if (Link == findurl &&
1563 (Descr == findlabel ||
1564 (Link == findlabel && Descr == wxEmptyString))) {
1565 link->Link = LinkPropDlg->m_textCtrlLinkUrl->GetValue();
1567 LinkPropDlg->m_textCtrlLinkDescription->GetValue();
1568 wxHyperlinkCtrl* h =
1569 (wxHyperlinkCtrl*)m_scrolledWindowLinks->FindWindowByLabel(
1572 h->SetLabel(LinkPropDlg->m_textCtrlLinkDescription->GetValue());
1573 h->SetURL(LinkPropDlg->m_textCtrlLinkUrl->GetValue());
1576 linknode = linknode->GetNext();
1580 m_scrolledWindowLinks->InvalidateBestSize();
1581 m_scrolledWindowLinks->Layout();
1582 sbSizerLinks->Layout();
1588void TrackPropDlg::OnAddLink(wxCommandEvent& event) {
1590 LinkPropDlg->m_textCtrlLinkDescription->SetValue(wxEmptyString);
1591 LinkPropDlg->m_textCtrlLinkUrl->SetValue(wxEmptyString);
1592 DimeControl(LinkPropDlg);
1593 LinkPropDlg->ShowWindowModalThenDo([
this, LinkPropDlg](
int retcode) {
1594 if (retcode == wxID_OK) {
1595 wxString desc = LinkPropDlg->m_textCtrlLinkDescription->GetValue();
1596 if (desc == wxEmptyString)
1597 desc = LinkPropDlg->m_textCtrlLinkUrl->GetValue();
1598 wxHyperlinkCtrl* ctrl =
new wxHyperlinkCtrl(
1599 m_scrolledWindowLinks, wxID_ANY, desc,
1600 LinkPropDlg->m_textCtrlLinkUrl->GetValue(), wxDefaultPosition,
1601 wxDefaultSize, wxHL_DEFAULT_STYLE);
1602 ctrl->Connect(wxEVT_COMMAND_HYPERLINK,
1603 wxHyperlinkEventHandler(TrackPropDlg::OnHyperLinkClick),
1605 ctrl->Connect(wxEVT_RIGHT_DOWN,
1606 wxMouseEventHandler(TrackPropDlg::m_hyperlinkContextMenu),
1609 bSizerLinks->Add(ctrl, 0, wxALL, 5);
1610 bSizerLinks->Fit(m_scrolledWindowLinks);
1614 h->DescrText = LinkPropDlg->m_textCtrlLinkDescription->GetValue();
1615 h->Link = LinkPropDlg->m_textCtrlLinkUrl->GetValue();
1616 h->LType = wxEmptyString;
1617 m_pTrack->m_HyperlinkList->Append(h);
1622 m_scrolledWindowLinks->InvalidateBestSize();
1623 m_scrolledWindowLinks->Layout();
1624 sbSizerLinks->Layout();
1629void TrackPropDlg::OnEditLinkToggle(wxCommandEvent& event) {
1630 if (m_toggleBtnEdit->GetValue())
1631 m_staticTextEditEnabled->SetLabel(_(
"Links are opened for editing."));
1633 m_staticTextEditEnabled->SetLabel(
1634 _(
"Links are opened in the default browser."));
1638void TrackPropDlg::OnHyperLinkClick(wxHyperlinkEvent& event) {
1639 if (m_toggleBtnEdit->GetValue()) {
1640 m_pEditedLink = (wxHyperlinkCtrl*)event.GetEventObject();
1655 wxString cc =
event.GetURL();
1656 if (cc.Find(_T(
"#")) != wxNOT_FOUND) {
1658 wxString(_T(
"HKEY_CLASSES_ROOT\\HTTP\\shell\\open\\command")));
1659 if (RegKey.Exists()) {
1660 wxString command_line;
1661 RegKey.QueryValue(wxString(_T(
"")), command_line);
1664 command_line.Replace(wxString(_T(
"\"")), wxString(_T(
"")));
1667 int l = command_line.Find(_T(
".exe"));
1668 if (wxNOT_FOUND == l) l = command_line.Find(_T(
".EXE"));
1670 if (wxNOT_FOUND != l) {
1671 wxString cl = command_line.Mid(0, l + 4);
1673 cc.Prepend(_T(
"\""));
1674 cc.Append(_T(
"\""));
1682 wxString url =
event.GetURL();
1683 url.Replace(_T(
" "), _T(
"%20"));
1684 ::wxLaunchDefaultBrowser(url);
1689void TrackPropDlg::OnShowTimeTZ(wxCommandEvent& event) {
1690 if (m_rbShowTimeUTC && m_rbShowTimeUTC->GetValue())
1691 m_lcPoints->m_tz_selection = UTCINPUT;
1692 else if (m_rbShowTimePC && m_rbShowTimePC->GetValue())
1693 m_lcPoints->m_tz_selection = LTINPUT;
1695 m_lcPoints->m_tz_selection = LMTINPUT;
1696 m_lcPoints->DeleteAllItems();
1700bool TrackPropDlg::SaveChanges(
void) {
1701 if (m_pTrack && !m_pTrack->m_bIsInLayer) {
1703 m_pTrack->SetName(m_tName->GetValue());
1704 m_pTrack->m_TrackStartString = m_tFrom->GetValue();
1705 m_pTrack->m_TrackEndString = m_tTo->GetValue();
1707 m_pTrack->m_TrackDescription = m_tDescription->GetValue();
1708 m_pTrack->SetVisible(m_cbShow->GetValue());
1709 if (m_cColor->GetSelection() == 0)
1710 m_pTrack->m_Colour = wxEmptyString;
1712 m_pTrack->m_Colour = ::GpxxColorNames[m_cColor->GetSelection() - 1];
1713 m_pTrack->m_style = (wxPenStyle)::StyleValues[m_cStyle->GetSelection()];
1714 m_pTrack->m_width = ::WidthValues[m_cWidth->GetSelection()];
1716 pConfig->UpdateTrack(m_pTrack);
1717 pConfig->UpdateSettings();
1720 if (m_pTrack && m_pTrack->IsRunning()) {
1722 v[_T(
"Changed")] =
true;
1723 v[_T(
"Name")] = m_pTrack->GetName();
1724 v[_T(
"GUID")] = m_pTrack->m_GUID;
1725 wxString msg_id(_T(
"OCPN_TRK_ACTIVATED"));
1726 g_pi_manager->SendJSONMessageToAllPlugins(msg_id, v);
1732void TrackPropDlg::OnOKBtnClick(wxCommandEvent& event) {
1736 bool b_found_track =
1737 std::find(g_TrackList.begin(), g_TrackList.end(), m_pTrack) !=
1740 if (b_found_track) {
1742 m_pTrack->ClearHighlights();
1745 m_bStartNow =
false;
1747 if (pRouteManagerDialog && pRouteManagerDialog->IsShown())
1748 pRouteManagerDialog->UpdateTrkListCtrl();
1751 gFrame->InvalidateAllGL();
1752 gFrame->RefreshAllCanvas(
false);
1757void TrackPropDlg::OnCancelBtnClick(wxCommandEvent& event) {
1758 bool b_found_track =
1759 std::find(g_TrackList.begin(), g_TrackList.end(), m_pTrack) !=
1762 if (b_found_track) m_pTrack->ClearHighlights();
1765 gFrame->InvalidateAllGL();
1766 gFrame->RefreshAllCanvas(
false);
1775OCPNTrackListCtrl::OCPNTrackListCtrl(wxWindow* parent, wxWindowID
id,
1776 const wxPoint& pos,
const wxSize& size,
1778 : wxListCtrl(parent, id, pos, size, style) {
1780 m_tz_selection = LTINPUT;
1784OCPNTrackListCtrl::~OCPNTrackListCtrl() {}
1786wxString OCPNTrackListCtrl::OnGetItemText(
long item,
long column)
const {
1789 if (item < 0 || item >= m_pTrack->GetnPoints())
return wxEmptyString;
1791 TrackPoint* this_point = m_pTrack->GetPoint(item);
1792 TrackPoint* prev_point = item > 0 ? m_pTrack->GetPoint(item - 1) : NULL;
1794 if (!this_point)
return wxEmptyString;
1796 double gt_brg, gt_leg_dist;
1802 slat = prev_point->m_lat;
1803 slon = prev_point->m_lon;
1811 ret.Printf(_T(
"%ld"), item);
1815 DistanceBearingMercator(this_point->m_lat, this_point->m_lon, slat, slon,
1816 >_brg, >_leg_dist);
1818 ret.Printf(_T(
"%6.2f ") + getUsrDistanceUnit(),
1819 toUsrDistance(gt_leg_dist));
1823 DistanceBearingMercator(this_point->m_lat, this_point->m_lon, slat, slon,
1824 >_brg, >_leg_dist);
1825 ret.Printf(
"%03.0f %cT", gt_brg, 0x00B0);
1829 ret = toSDMM(1, this_point->m_lat, 1);
1833 ret = toSDMM(2, this_point->m_lon, 1);
1837 wxDateTime timestamp = this_point->GetCreateTime();
1838 if (timestamp.IsValid())
1839 ret = timestamp2s(timestamp, m_tz_selection, m_LMT_Offset,
1846 if ((item > 0) && this_point->GetCreateTime().IsValid() &&
1847 prev_point->GetCreateTime().IsValid()) {
1848 DistanceBearingMercator(this_point->m_lat, this_point->m_lon, slat,
1849 slon, >_brg, >_leg_dist);
1851 double seconds = this_point->GetCreateTime()
1852 .Subtract(prev_point->GetCreateTime())
1856 if (seconds > 0.) speed = gt_leg_dist / seconds * 3600;
1858 ret.Printf(_T(
"%5.2f"), toUsrSpeed(speed));
1870int OCPNTrackListCtrl::OnGetItemColumnImage(
long item,
long column)
const {
void OnDeleteLink(wxCommandEvent &event)