27 #include "model/georef.h"
28 #include "model/navutil_base.h"
29 #include "model/own_ship.h"
30 #include "model/route.h"
31 #include "model/routeman.h"
32 #include "model/select.h"
33 #include "model/track.h"
39 #include "ocpn_frame.h"
40 #include "OCPNPlatform.h"
41 #include "pluginmanager.h"
42 #include "routemanagerdialog.h"
43 #include "routeman_gui.h"
44 #include "trackprintout.h"
45 #include "TrackPropDlg.h"
48 #include "androidUTIL.h"
54 #define INPUT_FORMAT 1
55 #define DISPLAY_FORMAT 2
56 #define TIMESTAMP_FORMAT 3
58 extern std::vector<Track*> g_TrackList;
66 wxString timestamp2s(wxDateTime ts,
int tz_selection,
long LMT_offset,
70 if (format == INPUT_FORMAT)
72 else if (format == TIMESTAMP_FORMAT)
73 f = _T(
"%x %H:%M:%S");
76 switch (tz_selection) {
78 s.Append(ts.Format(f));
79 if (format != INPUT_FORMAT) s.Append(_T(
" UT"));
82 s.Append(ts.FromUTC().Format(f));
85 wxTimeSpan lmt(0, 0, (
int)LMT_offset, 0);
86 s.Append(ts.Add(lmt).Format(f));
87 if (format != INPUT_FORMAT) s.Append(_T(
" LMT"));
93 bool TrackPropDlg::instanceFlag =
false;
95 TrackPropDlg* TrackPropDlg::getInstance(wxWindow* parent, wxWindowID
id,
96 const wxString& title,
97 const wxPoint& pos,
const wxSize& size,
100 single =
new TrackPropDlg(parent,
id, title, pos, size, style);
108 TrackPropDlg::TrackPropDlg(wxWindow* parent, wxWindowID
id,
109 const wxString& title,
const wxPoint& pos,
110 const wxSize& size,
long style)
111 : DIALOG_PARENT(parent, id, title, pos, size, style) {
112 wxFont* qFont = GetOCPNScaledFont(_(
"Dialog"));
115 SetWindowStyleFlag(style);
117 m_scrolledWindowLinks = NULL;
118 m_tDescription = NULL;
124 CreateControlsCompact();
134 m_sdbBtmBtnsSizerCancel->Connect(
135 wxEVT_COMMAND_BUTTON_CLICKED,
136 wxCommandEventHandler(TrackPropDlg::OnCancelBtnClick), NULL,
this);
137 m_sdbBtmBtnsSizerOK->Connect(
138 wxEVT_COMMAND_BUTTON_CLICKED,
139 wxCommandEventHandler(TrackPropDlg::OnOKBtnClick), NULL,
this);
140 if (m_sdbBtmBtnsSizerPrint)
141 m_sdbBtmBtnsSizerPrint->Connect(
142 wxEVT_COMMAND_BUTTON_CLICKED,
143 wxCommandEventHandler(TrackPropDlg::OnPrintBtnClick), NULL,
this);
144 m_sdbBtmBtnsSizerSplit->Connect(
145 wxEVT_COMMAND_BUTTON_CLICKED,
146 wxCommandEventHandler(TrackPropDlg::OnSplitBtnClick), NULL,
this);
147 m_sdbBtmBtnsSizerExtend->Connect(
148 wxEVT_COMMAND_BUTTON_CLICKED,
149 wxCommandEventHandler(TrackPropDlg::OnExtendBtnClick), NULL,
this);
150 m_sdbBtmBtnsSizerToRoute->Connect(
151 wxEVT_COMMAND_BUTTON_CLICKED,
152 wxCommandEventHandler(TrackPropDlg::OnToRouteBtnClick), NULL,
this);
153 if (m_sdbBtmBtnsSizerExport)
154 m_sdbBtmBtnsSizerExport->Connect(
155 wxEVT_COMMAND_BUTTON_CLICKED,
156 wxCommandEventHandler(TrackPropDlg::OnExportBtnClick), NULL,
this);
157 m_lcPoints->Connect(wxEVT_COMMAND_LIST_ITEM_SELECTED,
158 wxListEventHandler(TrackPropDlg::OnTrackPropListClick),
160 Connect(wxEVT_COMMAND_LIST_ITEM_RIGHT_CLICK,
161 wxListEventHandler(TrackPropDlg::OnTrackPropRightClick), NULL,
this);
162 Connect(wxEVT_COMMAND_MENU_SELECTED,
163 wxCommandEventHandler(TrackPropDlg::OnTrackPropMenuSelected), NULL,
167 Connect(wxEVT_ACTIVATE,
168 wxActivateEventHandler(TrackPropDlg::OnActivate),
173 m_buttonAddLink->Connect(wxEVT_COMMAND_BUTTON_CLICKED,
174 wxCommandEventHandler(TrackPropDlg::OnAddLink),
176 m_toggleBtnEdit->Connect(
177 wxEVT_COMMAND_TOGGLEBUTTON_CLICKED,
178 wxCommandEventHandler(TrackPropDlg::OnEditLinkToggle), NULL,
this);
182 m_rbShowTimeUTC->Connect(wxEVT_COMMAND_RADIOBUTTON_SELECTED,
183 wxCommandEventHandler(TrackPropDlg::OnShowTimeTZ),
186 m_rbShowTimePC->Connect(wxEVT_COMMAND_RADIOBUTTON_SELECTED,
187 wxCommandEventHandler(TrackPropDlg::OnShowTimeTZ),
189 if (m_rbShowTimeLocal)
190 m_rbShowTimeLocal->Connect(
191 wxEVT_COMMAND_RADIOBUTTON_SELECTED,
192 wxCommandEventHandler(TrackPropDlg::OnShowTimeTZ), NULL,
this);
194 m_pMyLinkList = NULL;
197 TrackPropDlg::~TrackPropDlg() {
199 m_sdbBtmBtnsSizerCancel->Disconnect(
200 wxEVT_COMMAND_BUTTON_CLICKED,
201 wxCommandEventHandler(TrackPropDlg::OnCancelBtnClick), NULL,
this);
202 m_sdbBtmBtnsSizerOK->Disconnect(
203 wxEVT_COMMAND_BUTTON_CLICKED,
204 wxCommandEventHandler(TrackPropDlg::OnOKBtnClick), NULL,
this);
205 if (m_sdbBtmBtnsSizerPrint)
206 m_sdbBtmBtnsSizerPrint->Disconnect(
207 wxEVT_COMMAND_BUTTON_CLICKED,
208 wxCommandEventHandler(TrackPropDlg::OnPrintBtnClick), NULL,
this);
209 m_sdbBtmBtnsSizerSplit->Disconnect(
210 wxEVT_COMMAND_BUTTON_CLICKED,
211 wxCommandEventHandler(TrackPropDlg::OnSplitBtnClick), NULL,
this);
212 m_sdbBtmBtnsSizerExtend->Disconnect(
213 wxEVT_COMMAND_BUTTON_CLICKED,
214 wxCommandEventHandler(TrackPropDlg::OnExtendBtnClick), NULL,
this);
215 m_sdbBtmBtnsSizerToRoute->Disconnect(
216 wxEVT_COMMAND_BUTTON_CLICKED,
217 wxCommandEventHandler(TrackPropDlg::OnToRouteBtnClick), NULL,
this);
218 if (m_sdbBtmBtnsSizerExport)
219 m_sdbBtmBtnsSizerExport->Disconnect(
220 wxEVT_COMMAND_BUTTON_CLICKED,
221 wxCommandEventHandler(TrackPropDlg::OnExportBtnClick), NULL,
this);
222 m_lcPoints->Disconnect(wxEVT_COMMAND_LIST_ITEM_SELECTED,
223 wxListEventHandler(TrackPropDlg::OnTrackPropListClick),
225 Disconnect(wxEVT_COMMAND_LIST_ITEM_RIGHT_CLICK,
226 wxListEventHandler(TrackPropDlg::OnTrackPropRightClick), NULL,
228 Disconnect(wxEVT_COMMAND_MENU_SELECTED,
229 wxCommandEventHandler(TrackPropDlg::OnTrackPropMenuSelected), NULL,
232 Disconnect(wxID_ANY, wxEVT_COMMAND_MENU_SELECTED,
234 Disconnect(wxID_ANY, wxEVT_COMMAND_MENU_SELECTED,
235 wxCommandEventHandler(TrackPropDlg::OnEditLink));
236 Disconnect(wxID_ANY, wxEVT_COMMAND_MENU_SELECTED,
237 wxCommandEventHandler(TrackPropDlg::OnAddLink));
240 m_buttonAddLink->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED,
241 wxCommandEventHandler(TrackPropDlg::OnAddLink),
243 m_toggleBtnEdit->Disconnect(
244 wxEVT_COMMAND_TOGGLEBUTTON_CLICKED,
245 wxCommandEventHandler(TrackPropDlg::OnEditLinkToggle), NULL,
this);
249 m_rbShowTimeUTC->Disconnect(
250 wxEVT_COMMAND_RADIOBUTTON_SELECTED,
251 wxCommandEventHandler(TrackPropDlg::OnShowTimeTZ), NULL,
this);
253 m_rbShowTimePC->Disconnect(
254 wxEVT_COMMAND_RADIOBUTTON_SELECTED,
255 wxCommandEventHandler(TrackPropDlg::OnShowTimeTZ), NULL,
this);
256 if (m_rbShowTimeLocal)
257 m_rbShowTimeLocal->Disconnect(
258 wxEVT_COMMAND_RADIOBUTTON_SELECTED,
259 wxCommandEventHandler(TrackPropDlg::OnShowTimeTZ), NULL,
this);
261 instanceFlag =
false;
264 void TrackPropDlg::OnActivate(wxActivateEvent& event){
265 DIALOG_PARENT* pWin = wxDynamicCast(event.GetEventObject(), DIALOG_PARENT);
266 long int style = pWin->GetWindowStyle();
267 if (event.GetActive())
268 pWin->SetWindowStyle(style | wxSTAY_ON_TOP);
270 pWin->SetWindowStyle(style ^ wxSTAY_ON_TOP);
274 void TrackPropDlg::RecalculateSize(
void) {
278 esize.x = GetCharWidth() * 110;
279 esize.y = GetCharHeight() * 40;
281 wxSize dsize = GetParent()->GetClientSize();
282 esize.y = wxMin(esize.y, dsize.y - (2 * GetCharHeight()));
283 esize.x = wxMin(esize.x, dsize.x - (2 * GetCharHeight()));
284 SetClientSize(esize);
286 wxSize fsize = GetSize();
287 fsize.y = wxMin(fsize.y, dsize.y - (2 * GetCharHeight()));
288 fsize.x = wxMin(fsize.x, dsize.x - (2 * GetCharHeight()));
292 int sy = GetCharHeight() * m_lcPoints->GetItemCount();
295 m_lcPoints->SetSize(wxSize(GetClientSize().x - 40, sy));
297 if (m_lcPoints->GetItemCount()) Layout();
303 static void addColumns(wxListCtrl* lctrl,
int dx) {
304 lctrl->InsertColumn(0, _(
"Leg"), wxLIST_FORMAT_LEFT, dx * 6);
305 lctrl->InsertColumn(1, _(
"Distance"), wxLIST_FORMAT_LEFT, dx * 10);
306 lctrl->InsertColumn(2, _(
"Bearing"), wxLIST_FORMAT_LEFT, dx * 8);
307 lctrl->InsertColumn(3, _(
"Latitude"), wxLIST_FORMAT_LEFT, dx * 11);
308 lctrl->InsertColumn(4, _(
"Longitude"), wxLIST_FORMAT_LEFT, dx * 11);
310 lctrl->InsertColumn(5, _(
"Timestamp"), wxLIST_FORMAT_LEFT, dx * 19);
311 lctrl->InsertColumn(6, _(
"Speed"), wxLIST_FORMAT_CENTER, dx * 8);
313 lctrl->SetMinSize(wxSize(-1, 50));
316 void TrackPropDlg::CreateControlsCompact() {
317 wxBoxSizer* itemBoxSizer1 =
new wxBoxSizer(wxVERTICAL);
318 SetSizer(itemBoxSizer1);
320 itemDialog1 =
new wxScrolledWindow(
this, wxID_ANY, wxDefaultPosition,
321 wxSize(-1, -1), wxVSCROLL);
322 itemDialog1->SetScrollRate(0, 1);
326 wxFont* qFont = GetOCPNScaledFont(_(
"Dialog"));
328 wxString wqs = getFontQtStylesheet(qFont);
329 wxCharBuffer sbuf = wqs.ToUTF8();
330 QString qsb = QString(sbuf.data());
332 QString qsbq = getQtStyleSheet();
334 itemDialog1->GetHandle()->setStyleSheet(qsb +
338 itemBoxSizer1->Add(itemDialog1, 1, wxEXPAND | wxALL, 0);
340 wxBoxSizer* itemBoxSizer2 =
new wxBoxSizer(wxVERTICAL);
341 itemDialog1->SetSizer(itemBoxSizer2);
343 wxStaticText* itemStaticText4 =
new wxStaticText(
344 itemDialog1, wxID_STATIC, _(
"Name"), wxDefaultPosition, wxDefaultSize, 0);
345 itemBoxSizer2->Add(itemStaticText4, 0,
346 wxALIGN_LEFT | wxLEFT | wxRIGHT | wxTOP, 5);
348 m_tName =
new wxTextCtrl(itemDialog1, wxID_ANY, _T(
""), wxDefaultPosition,
350 itemBoxSizer2->Add(m_tName, 0, wxALIGN_LEFT | wxLEFT | wxRIGHT | wxBOTTOM, 5);
352 wxStaticText* itemStaticText7 =
353 new wxStaticText(itemDialog1, wxID_STATIC, _(
"Depart From"),
354 wxDefaultPosition, wxDefaultSize, 0);
355 itemBoxSizer2->Add(itemStaticText7, 0,
356 wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxLEFT | wxRIGHT,
359 m_tFrom =
new wxTextCtrl(itemDialog1, wxID_ANY, _T(
""), wxDefaultPosition,
361 itemBoxSizer2->Add(m_tFrom, 0,
362 wxEXPAND | wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL |
363 wxLEFT | wxRIGHT | wxBOTTOM,
366 wxStaticText* itemStaticText8 =
367 new wxStaticText(itemDialog1, wxID_STATIC, _(
"Destination"),
368 wxDefaultPosition, wxDefaultSize, 0);
369 itemBoxSizer2->Add(itemStaticText8, 0,
370 wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxLEFT | wxRIGHT,
373 m_tTo =
new wxTextCtrl(itemDialog1, wxID_ANY, _T(
""), wxDefaultPosition,
375 itemBoxSizer2->Add(m_tTo, 0,
376 wxEXPAND | wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL |
377 wxLEFT | wxRIGHT | wxBOTTOM,
380 m_cbShow =
new wxCheckBox(itemDialog1, wxID_ANY, _(
"Show on chart"),
381 wxDefaultPosition, wxDefaultSize, 0);
382 itemBoxSizer2->Add(m_cbShow, 0, wxALL, 5);
384 wxFlexGridSizer* itemFlexGridSizer6a =
new wxFlexGridSizer(4, 2, 0, 0);
385 itemFlexGridSizer6a->AddGrowableCol(1, 0);
387 itemBoxSizer2->Add(itemFlexGridSizer6a, 0, wxEXPAND | wxALIGN_LEFT | wxALL,
390 wxStaticText* itemStaticText11 =
391 new wxStaticText(itemDialog1, wxID_STATIC, _(
"Total distance"),
392 wxDefaultPosition, wxDefaultSize, 0);
393 itemFlexGridSizer6a->Add(
395 wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxLEFT | wxRIGHT | wxTOP, 5);
398 new wxTextCtrl(itemDialog1, wxID_ANY, _T(
""), wxDefaultPosition,
399 wxSize(-1, -1), wxTE_READONLY);
400 itemFlexGridSizer6a->Add(m_tTotDistance, 0,
401 wxEXPAND | wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL |
402 wxLEFT | wxRIGHT | wxBOTTOM,
405 m_stAvgSpeed =
new wxStaticText(itemDialog1, wxID_STATIC, _(
"Avg. speed"),
406 wxDefaultPosition, wxDefaultSize, 0);
407 itemFlexGridSizer6a->Add(
409 wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxLEFT | wxRIGHT | wxTOP, 5);
411 m_tAvgSpeed =
new wxTextCtrl(itemDialog1, wxID_ANY, _T(
""), wxDefaultPosition,
412 wxSize(150, -1), wxTE_PROCESS_ENTER);
413 itemFlexGridSizer6a->Add(
415 wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxLEFT | wxRIGHT | wxBOTTOM, 5);
418 new wxStaticText(itemDialog1, wxID_STATIC, _(
"Time Enroute"),
419 wxDefaultPosition, wxDefaultSize, 0);
420 itemFlexGridSizer6a->Add(
422 wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxLEFT | wxRIGHT | wxTOP, 5);
425 new wxTextCtrl(itemDialog1, wxID_ANY, _T(
""), wxDefaultPosition,
426 wxSize(-1, -1), wxTE_READONLY);
427 itemFlexGridSizer6a->Add(m_tTimeEnroute, 0,
428 wxEXPAND | wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL |
429 wxLEFT | wxRIGHT | wxBOTTOM,
446 wxString pDispTimeZone[] = {_(
"UTC"), _(
"Local @ PC"), _(
"LMT @ Location")};
448 wxStaticText* itemStaticText12b =
449 new wxStaticText(itemDialog1, wxID_STATIC, _(
"Time shown as"),
450 wxDefaultPosition, wxDefaultSize, 0);
451 itemBoxSizer2->Add(itemStaticText12b, 0, wxEXPAND | wxALL, 5);
454 new wxRadioButton(itemDialog1, wxID_ANY, _(
"UTC"), wxDefaultPosition,
455 wxDefaultSize, wxRB_GROUP);
458 wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxLEFT | wxRIGHT | wxBOTTOM, 5);
460 m_rbShowTimePC =
new wxRadioButton(itemDialog1, wxID_ANY, _(
"Local @ PC"));
463 wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxLEFT | wxRIGHT | wxBOTTOM, 5);
466 new wxRadioButton(itemDialog1, wxID_ANY, _(
"LMT @ Location"));
468 m_rbShowTimeLocal, 0,
469 wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxLEFT | wxRIGHT | wxBOTTOM, 5);
471 wxFlexGridSizer* itemFlexGridSizer6b =
new wxFlexGridSizer(3, 2, 0, 0);
472 itemBoxSizer2->Add(itemFlexGridSizer6b, 0, wxEXPAND | wxALIGN_LEFT | wxALL,
475 wxStaticText* m_staticText1 =
476 new wxStaticText(itemDialog1, wxID_ANY, _(
"Color") + _T(
":"),
477 wxDefaultPosition, wxDefaultSize, 0);
478 itemFlexGridSizer6b->Add(m_staticText1, 0, wxALIGN_CENTER_VERTICAL | wxALL,
481 wxString m_chColorChoices[] = {
482 _(
"Default color"), _(
"Black"), _(
"Dark Red"), _(
"Dark Green"),
483 _(
"Dark Yellow"), _(
"Dark Blue"), _(
"Dark Magenta"), _(
"Dark Cyan"),
484 _(
"Light Gray"), _(
"Dark Gray"), _(
"Red"), _(
"Green"),
485 _(
"Yellow"), _(
"Blue"), _(
"Magenta"), _(
"Cyan"),
487 int m_chColorNChoices =
sizeof(m_chColorChoices) /
sizeof(wxString);
489 new wxChoice(itemDialog1, wxID_ANY, wxDefaultPosition, wxSize(250, -1),
490 m_chColorNChoices, m_chColorChoices, 0);
491 m_cColor->SetSelection(0);
492 itemFlexGridSizer6b->Add(m_cColor, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
494 wxStaticText* staticTextStyle =
495 new wxStaticText(itemDialog1, wxID_ANY, _(
"Style") + _T(
":"),
496 wxDefaultPosition, wxDefaultSize, 0);
497 itemFlexGridSizer6b->Add(staticTextStyle, 0, wxALIGN_CENTER_VERTICAL | wxALL,
500 wxString m_chStyleChoices[] = {_(
"Default"), _(
"Solid"),
501 _(
"Dot"), _(
"Long dash"),
503 int m_chStyleNChoices =
sizeof(m_chStyleChoices) /
sizeof(wxString);
505 new wxChoice(itemDialog1, wxID_ANY, wxDefaultPosition, wxDefaultSize,
506 m_chStyleNChoices, m_chStyleChoices, 0);
507 m_cStyle->SetSelection(0);
508 itemFlexGridSizer6b->Add(m_cStyle, 0,
509 wxEXPAND | wxALIGN_CENTER_VERTICAL | wxALL, 5);
512 staticTextStyle->Hide();
516 m_stWidth =
new wxStaticText(itemDialog1, wxID_ANY, _(
"Width") + _T(
":"),
517 wxDefaultPosition, wxDefaultSize, 0);
518 itemFlexGridSizer6b->Add(m_stWidth, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
520 wxString m_chWidthChoices[] = {_(
"Default"), _(
"1 pixel"), _(
"2 pixels"),
521 _(
"3 pixels"), _(
"4 pixels"), _(
"5 pixels"),
522 _(
"6 pixels"), _(
"7 pixels"), _(
"8 pixels"),
523 _(
"9 pixels"), _(
"10 pixels")};
524 int m_chWidthNChoices =
sizeof(m_chWidthChoices) /
sizeof(wxString);
526 new wxChoice(itemDialog1, wxID_ANY, wxDefaultPosition, wxSize(150, -1),
527 m_chWidthNChoices, m_chWidthChoices, 0);
528 m_cWidth->SetSelection(0);
529 itemFlexGridSizer6b->Add(m_cWidth, 0,
530 wxEXPAND | wxALIGN_CENTER_VERTICAL | wxALL, 5);
532 wxStaticBox* itemStaticBoxSizer14Static =
533 new wxStaticBox(itemDialog1, wxID_ANY, _(
"Waypoints"));
534 wxStaticBoxSizer* m_pListSizer =
535 new wxStaticBoxSizer(itemStaticBoxSizer14Static, wxVERTICAL);
536 itemBoxSizer2->Add(m_pListSizer, 1, wxEXPAND | wxALL, 1);
538 wxScrolledWindow* itemlistWin =
539 new wxScrolledWindow(itemDialog1, wxID_ANY, wxDefaultPosition,
540 wxDefaultSize, wxHSCROLL | wxVSCROLL);
541 itemlistWin->SetScrollRate(2, 2);
543 m_pListSizer->Add(itemlistWin, 0, wxEXPAND | wxALL, 6);
545 long flags = wxLC_REPORT | wxLC_HRULES | wxLC_VRULES | wxLC_EDIT_LABELS;
547 flags |= wxLC_VIRTUAL;
551 wxSize(100, 500), flags);
552 addColumns(m_lcPoints, GetCharWidth());
557 m_lcPoints->GetHandle()->setStyleSheet(getQtStyleSheet());
562 wxBoxSizer* itemBoxSizerBottom =
new wxBoxSizer(wxVERTICAL);
563 itemBoxSizer1->Add(itemBoxSizerBottom, 0, wxALIGN_LEFT | wxALL | wxEXPAND, 5);
567 wxFlexGridSizer* itemBoxSizerAux =
new wxFlexGridSizer(0, n_col, 0, 0);
568 itemBoxSizerAux->SetFlexibleDirection(wxBOTH);
569 itemBoxSizerAux->SetNonFlexibleGrowMode(wxFLEX_GROWMODE_SPECIFIED);
571 itemBoxSizerBottom->Add(itemBoxSizerAux, 1, wxALIGN_LEFT | wxALL, 5);
575 m_sdbBtmBtnsSizerPrint =
new wxButton(
this, wxID_ANY, _(
"Print"),
576 wxDefaultPosition, wxDefaultSize, 0);
577 itemBoxSizerAux->Add(m_sdbBtmBtnsSizerPrint, 0,
578 wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxALL, 5);
579 m_sdbBtmBtnsSizerPrint->Enable(
true);
581 m_sdbBtmBtnsSizerPrint = NULL;
584 m_sdbBtmBtnsSizerSplit =
new wxButton(
this, wxID_ANY, _(
"Split"),
585 wxDefaultPosition, wxDefaultSize, 0);
586 itemBoxSizerAux->Add(m_sdbBtmBtnsSizerSplit, 0,
587 wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxALL, 5);
588 m_sdbBtmBtnsSizerSplit->Enable(
false);
590 m_sdbBtmBtnsSizerExtend =
new wxButton(
this, wxID_ANY, _(
"Extend"),
591 wxDefaultPosition, wxDefaultSize, 0);
592 itemBoxSizerAux->Add(m_sdbBtmBtnsSizerExtend, 0,
593 wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxALL, 5);
595 m_sdbBtmBtnsSizerToRoute =
new wxButton(
this, wxID_ANY, _(
"To route"),
596 wxDefaultPosition, wxDefaultSize, 0);
597 itemBoxSizerAux->Add(m_sdbBtmBtnsSizerToRoute, 0,
598 wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxALL, 5);
600 m_sdbBtmBtnsSizerExport = NULL;
606 wxBoxSizer* itemBoxSizer16 =
new wxBoxSizer(wxHORIZONTAL);
607 itemBoxSizerBottom->Add(itemBoxSizer16, 0, wxALIGN_RIGHT | wxALL, 5);
609 m_sdbBtmBtnsSizerCancel =
new wxButton(
this, wxID_CANCEL, _(
"Cancel"),
610 wxDefaultPosition, wxDefaultSize, 0);
611 itemBoxSizer16->Add(m_sdbBtmBtnsSizerCancel, 0,
612 wxALIGN_RIGHT | wxALIGN_BOTTOM | wxALL, 5);
614 m_sdbBtmBtnsSizerOK =
615 new wxButton(
this, wxID_OK, _(
"OK"), wxDefaultPosition, wxDefaultSize, 0);
616 itemBoxSizer16->Add(m_sdbBtmBtnsSizerOK, 0,
617 wxALIGN_RIGHT | wxALIGN_BOTTOM | wxALL, 5);
618 m_sdbBtmBtnsSizerOK->SetDefault();
620 int char_size = GetCharWidth();
623 width = g_monitor_info[g_current_monitor].width;
624 height = g_monitor_info[g_current_monitor].height;
625 SetSizeHints(-1, -1, width - 100, height - 100);
628 void TrackPropDlg::CreateControls(
void) {
629 wxBoxSizer* bSizerMain;
630 bSizerMain =
new wxBoxSizer(wxVERTICAL);
631 SetSizer(bSizerMain);
634 new wxNotebook(
this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0);
636 bSizerMain->Add(m_notebook1, 1, wxEXPAND | wxALL, 5);
639 new wxPanel(m_notebook1, wxID_ANY, wxDefaultPosition, wxDefaultSize);
640 m_notebook1->AddPage(m_panel0, _(
"Basic"),
true);
642 wxBoxSizer* bSizer0 =
new wxBoxSizer(wxVERTICAL);
643 m_panel0->SetSizer(bSizer0);
645 wxBoxSizer* bSizer1 =
new wxBoxSizer(wxVERTICAL);
646 bSizer0->Add(bSizer1, 1, wxEXPAND | wxALL, 5);
648 m_panelBasic =
new wxScrolledWindow(m_panel0, wxID_ANY, wxDefaultPosition,
650 wxHSCROLL | wxVSCROLL | wxTAB_TRAVERSAL);
654 wxFont* qFont = GetOCPNScaledFont(_(
"Dialog"));
656 wxString wqs = getFontQtStylesheet(qFont);
657 wxCharBuffer sbuf = wqs.ToUTF8();
658 QString qsb = QString(sbuf.data());
660 QString qsbq = getQtStyleSheet();
662 m_panelBasic->GetHandle()->setStyleSheet(qsb +
671 wxBoxSizer* bSizerBasic =
new wxBoxSizer(wxVERTICAL);
672 m_panelBasic->SetSizer(bSizerBasic);
674 bSizer1->Add(m_panelBasic, 1, wxEXPAND | wxALL, 5);
676 wxBoxSizer* bSizerName;
677 bSizerName =
new wxBoxSizer(wxHORIZONTAL);
678 bSizerBasic->Add(bSizerName, 0, wxALL | wxEXPAND, 5);
680 m_stName =
new wxStaticText(m_panelBasic, wxID_ANY, _(
"Name"),
681 wxDefaultPosition, wxDefaultSize, 0);
683 bSizerName->Add(m_stName, 0, wxALL, 5);
685 m_tName =
new wxTextCtrl(m_panelBasic, wxID_ANY, wxEmptyString,
686 wxDefaultPosition, wxDefaultSize, 0);
687 bSizerName->Add(m_tName, 1, 0, 5);
689 wxBoxSizer* bSizerFromTo;
690 bSizerFromTo =
new wxBoxSizer(wxHORIZONTAL);
691 bSizerBasic->Add(bSizerFromTo, 0, wxALL | wxEXPAND, 5);
693 m_stFrom =
new wxStaticText(m_panelBasic, wxID_ANY, _(
"From"),
694 wxDefaultPosition, wxDefaultSize, 0);
696 bSizerFromTo->Add(m_stFrom, 0, wxALL, 5);
698 m_tFrom =
new wxTextCtrl(m_panelBasic, wxID_ANY, wxEmptyString,
699 wxDefaultPosition, wxDefaultSize, 0);
700 bSizerFromTo->Add(m_tFrom, 1, 0, 5);
702 m_stTo =
new wxStaticText(m_panelBasic, wxID_ANY, _(
"To"), wxDefaultPosition,
705 bSizerFromTo->Add(m_stTo, 0, wxALL, 5);
707 m_tTo =
new wxTextCtrl(m_panelBasic, wxID_ANY, wxEmptyString,
708 wxDefaultPosition, wxDefaultSize, 0);
709 bSizerFromTo->Add(m_tTo, 1, 0, 5);
711 wxStaticBoxSizer* sbSizerParams;
712 sbSizerParams =
new wxStaticBoxSizer(
713 new wxStaticBox(m_panelBasic, wxID_ANY, _(
"Display parameters")),
715 bSizerBasic->Add(sbSizerParams, 0, wxALL | wxEXPAND, 5);
717 m_cbShow =
new wxCheckBox(m_panelBasic, wxID_ANY, _(
"Show on chart"),
718 wxDefaultPosition, wxDefaultSize, 0);
719 sbSizerParams->Add(m_cbShow, 0, wxALL, 5);
721 m_stColor =
new wxStaticText(m_panelBasic, wxID_ANY, _(
"Color"),
722 wxDefaultPosition, wxDefaultSize, 0);
724 sbSizerParams->Add(m_stColor, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
726 wxString m_cColorChoices[] = {
727 _(
"Default color"), _(
"Black"), _(
"Dark Red"), _(
"Dark Green"),
728 _(
"Dark Yellow"), _(
"Dark Blue"), _(
"Dark Magenta"), _(
"Dark Cyan"),
729 _(
"Light Gray"), _(
"Dark Gray"), _(
"Red"), _(
"Green"),
730 _(
"Yellow"), _(
"Blue"), _(
"Magenta"), _(
"Cyan"),
732 int m_cColorNChoices =
sizeof(m_cColorChoices) /
sizeof(wxString);
733 m_cColor =
new wxChoice(m_panelBasic, wxID_ANY, wxDefaultPosition,
734 wxDefaultSize, m_cColorNChoices, m_cColorChoices, 0);
735 m_cColor->SetSelection(0);
736 sbSizerParams->Add(m_cColor, 1, 0, 5);
738 m_stStyle =
new wxStaticText(m_panelBasic, wxID_ANY, _(
"Style"),
739 wxDefaultPosition, wxDefaultSize, 0);
741 sbSizerParams->Add(m_stStyle, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
743 wxString m_cStyleChoices[] = {_(
"Default"), _(
"Solid"), _(
"Dot"),
744 _(
"Long dash"), _(
"Short dash")};
745 int m_cStyleNChoices =
sizeof(m_cStyleChoices) /
sizeof(wxString);
746 m_cStyle =
new wxChoice(m_panelBasic, wxID_ANY, wxDefaultPosition,
747 wxDefaultSize, m_cStyleNChoices, m_cStyleChoices, 0);
748 m_cStyle->SetSelection(0);
749 sbSizerParams->Add(m_cStyle, 1, 0, 5);
751 m_stWidth =
new wxStaticText(m_panelBasic, wxID_ANY, _(
"Width"),
752 wxDefaultPosition, wxDefaultSize, 0);
754 sbSizerParams->Add(m_stWidth, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
756 wxString m_cWidthChoices[] = {_(
"Default"), _(
"1 pixel"), _(
"2 pixels"),
757 _(
"3 pixels"), _(
"4 pixels"), _(
"5 pixels"),
758 _(
"6 pixels"), _(
"7 pixels"), _(
"8 pixels"),
759 _(
"9 pixels"), _(
"10 pixels")};
760 int m_cWidthNChoices =
sizeof(m_cWidthChoices) /
sizeof(wxString);
761 m_cWidth =
new wxChoice(m_panelBasic, wxID_ANY, wxDefaultPosition,
762 wxDefaultSize, m_cWidthNChoices, m_cWidthChoices, 0);
763 m_cWidth->SetSelection(0);
764 sbSizerParams->Add(m_cWidth, 1, 0, 5);
766 wxStaticBoxSizer* sbSizerStats;
767 sbSizerStats =
new wxStaticBoxSizer(
768 new wxStaticBox(m_panelBasic, wxID_ANY, _(
"Statistics")), wxVERTICAL);
769 bSizerBasic->Add(sbSizerStats, 0, wxALL | wxEXPAND, 5);
771 wxBoxSizer* bSizerStats;
772 bSizerStats =
new wxBoxSizer(wxHORIZONTAL);
775 new wxStaticText(m_panelBasic, wxID_ANY, _(
"Total distance"),
776 wxDefaultPosition, wxDefaultSize, 0);
778 bSizerStats->Add(m_stTotDistance, 0, wxALL, 5);
781 new wxTextCtrl(m_panelBasic, wxID_ANY, wxEmptyString, wxDefaultPosition,
782 wxDefaultSize, wxTE_READONLY);
783 bSizerStats->Add(m_tTotDistance, 1, 0, 5);
785 m_stAvgSpeed =
new wxStaticText(m_panelBasic, wxID_ANY, _(
"Avg. speed"),
786 wxDefaultPosition, wxDefaultSize, 0);
788 bSizerStats->Add(m_stAvgSpeed, 0, wxALL, 5);
790 m_tAvgSpeed =
new wxTextCtrl(m_panelBasic, wxID_ANY, wxEmptyString,
791 wxDefaultPosition, wxDefaultSize, wxTE_READONLY);
792 bSizerStats->Add(m_tAvgSpeed, 1, 0, 5);
794 m_stTimeEnroute =
new wxStaticText(m_panelBasic, wxID_ANY, _(
"Time enroute"),
795 wxDefaultPosition, wxDefaultSize, 0);
797 bSizerStats->Add(m_stTimeEnroute, 0, wxALL, 5);
800 new wxTextCtrl(m_panelBasic, wxID_ANY, wxEmptyString, wxDefaultPosition,
801 wxDefaultSize, wxTE_READONLY);
802 bSizerStats->Add(m_tTimeEnroute, 2, 0, 5);
804 sbSizerStats->Add(bSizerStats, 0, wxEXPAND, 5);
806 wxStaticBoxSizer* sbSizerPoints;
807 sbSizerPoints =
new wxStaticBoxSizer(
808 new wxStaticBox(m_panel0, wxID_ANY, _(
"Recorded points")), wxVERTICAL);
809 bSizer1->Add(sbSizerPoints, 1, wxALL | wxEXPAND, 5);
811 wxBoxSizer* bSizerShowTime;
812 bSizerShowTime =
new wxBoxSizer(wxHORIZONTAL);
814 m_stShowTime =
new wxStaticText(m_panel0, wxID_ANY, _(
"Time shown as"),
815 wxDefaultPosition, wxDefaultSize, 0);
817 bSizerShowTime->Add(m_stShowTime, 0, wxALL, 5);
819 m_rbShowTimeUTC =
new wxRadioButton(m_panel0, wxID_ANY, _(
"UTC"),
820 wxDefaultPosition, wxDefaultSize, 0);
821 bSizerShowTime->Add(m_rbShowTimeUTC, 0,
822 wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxLEFT | wxRIGHT, 5);
824 m_rbShowTimePC =
new wxRadioButton(m_panel0, wxID_ANY, _(
"Local @ PC"),
825 wxDefaultPosition, wxDefaultSize, 0);
826 bSizerShowTime->Add(m_rbShowTimePC, 0,
827 wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxLEFT | wxRIGHT, 5);
830 new wxRadioButton(m_panel0, wxID_ANY, _(
"LMT @ Track Start"),
831 wxDefaultPosition, wxDefaultSize, 0);
832 bSizerShowTime->Add(m_rbShowTimeLocal, 0,
833 wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxLEFT | wxRIGHT, 5);
835 m_rbShowTimePC->SetValue(
true);
837 sbSizerPoints->Add(bSizerShowTime, 0, wxEXPAND, 5);
839 long flags = wxLC_REPORT | wxLC_HRULES | wxLC_VRULES | wxLC_EDIT_LABELS;
841 flags |= wxLC_VIRTUAL;
845 wxDefaultSize, flags);
846 addColumns(m_lcPoints, GetCharWidth());
848 sbSizerPoints->Add(m_lcPoints, 1, wxALL | wxEXPAND, 5);
851 m_lcPoints->GetHandle()->setStyleSheet(getQtStyleSheet());
865 m_panelAdvanced =
new wxScrolledWindow(
866 m_notebook1, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL);
868 wxBoxSizer* bSizerAdvanced;
869 bSizerAdvanced =
new wxBoxSizer(wxVERTICAL);
872 new wxStaticText(m_panelAdvanced, wxID_ANY, _(
"Description"),
873 wxDefaultPosition, wxDefaultSize, 0);
875 bSizerAdvanced->Add(m_stDescription, 0, wxALL, 5);
878 new wxTextCtrl(m_panelAdvanced, wxID_ANY, wxEmptyString,
879 wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE);
880 bSizerAdvanced->Add(m_tDescription, 1, wxALL | wxEXPAND, 5);
882 sbSizerLinks =
new wxStaticBoxSizer(
883 new wxStaticBox(m_panelAdvanced, wxID_ANY, _(
"Links")), wxVERTICAL);
885 m_scrolledWindowLinks =
886 new wxScrolledWindow(m_panelAdvanced, wxID_ANY, wxDefaultPosition,
887 wxDefaultSize, wxHSCROLL | wxVSCROLL);
888 m_scrolledWindowLinks->SetScrollRate(5, 5);
889 bSizerLinks =
new wxBoxSizer(wxVERTICAL);
892 new wxHyperlinkCtrl(m_scrolledWindowLinks, wxID_ANY, _(
"wxFB Website"),
893 wxT(
"http://www.wxformbuilder.org"),
894 wxDefaultPosition, wxDefaultSize, wxHL_DEFAULT_STYLE);
895 m_menuLink =
new wxMenu();
897 new wxMenuItem(m_menuLink, ID_TRK_MENU_EDIT, wxString(_(
"Edit")),
898 wxEmptyString, wxITEM_NORMAL);
899 m_menuLink->Append(m_menuItemEdit);
902 new wxMenuItem(m_menuLink, ID_TRK_MENU_ADD, wxString(_(
"Add new")),
903 wxEmptyString, wxITEM_NORMAL);
904 m_menuLink->Append(m_menuItemAdd);
907 new wxMenuItem(m_menuLink, ID_TRK_MENU_DELETE, wxString(_(
"Delete")),
908 wxEmptyString, wxITEM_NORMAL);
909 m_menuLink->Append(m_menuItemDelete);
911 m_hyperlink1->Connect(
913 wxMouseEventHandler(TrackPropDlg::m_hyperlink1OnContextMenu), NULL,
this);
915 bSizerLinks->Add(m_hyperlink1, 0, wxALL, 5);
917 m_scrolledWindowLinks->SetSizer(bSizerLinks);
918 m_scrolledWindowLinks->Layout();
919 bSizerLinks->Fit(m_scrolledWindowLinks);
920 sbSizerLinks->Add(m_scrolledWindowLinks, 1, wxEXPAND | wxALL, 5);
922 wxBoxSizer* bSizerLinkBtns;
923 bSizerLinkBtns =
new wxBoxSizer(wxHORIZONTAL);
926 new wxButton(m_panelAdvanced, wxID_ANY, _(
"Add"), wxDefaultPosition,
927 wxDefaultSize, wxBU_EXACTFIT);
928 bSizerLinkBtns->Add(m_buttonAddLink, 0, wxALL, 5);
930 m_toggleBtnEdit =
new wxToggleButton(m_panelAdvanced, wxID_ANY, _(
"Edit"),
931 wxDefaultPosition, wxDefaultSize, 0);
932 bSizerLinkBtns->Add(m_toggleBtnEdit, 0, wxALL, 5);
934 m_staticTextEditEnabled =
new wxStaticText(
935 m_panelAdvanced, wxID_ANY, _(
"Links are opened in the default browser."),
936 wxDefaultPosition, wxDefaultSize, 0);
938 bSizerLinkBtns->Add(m_staticTextEditEnabled, 0,
939 wxALIGN_CENTER_VERTICAL | wxALL, 5);
941 sbSizerLinks->Add(bSizerLinkBtns, 0, wxEXPAND, 5);
943 bSizerAdvanced->Add(sbSizerLinks, 1, wxEXPAND, 5);
945 m_panelAdvanced->SetSizer(bSizerAdvanced);
946 m_notebook1->AddPage(m_panelAdvanced, _(
"Advanced"),
false);
950 wxBoxSizer* itemBoxSizerBottom =
new wxBoxSizer(wxVERTICAL);
951 bSizerMain->Add(itemBoxSizerBottom, 0, wxALIGN_LEFT | wxALL | wxEXPAND, 5);
957 wxFlexGridSizer* itemBoxSizerAux =
new wxFlexGridSizer(0, n_col, 0, 0);
958 itemBoxSizerAux->SetFlexibleDirection(wxBOTH);
959 itemBoxSizerAux->SetNonFlexibleGrowMode(wxFLEX_GROWMODE_SPECIFIED);
961 itemBoxSizerBottom->Add(itemBoxSizerAux, 1, wxALIGN_LEFT | wxALL, 5);
965 m_sdbBtmBtnsSizerPrint =
new wxButton(
this, wxID_ANY, _(
"Print"),
966 wxDefaultPosition, wxDefaultSize, 0);
967 itemBoxSizerAux->Add(m_sdbBtmBtnsSizerPrint, 0,
968 wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxALL, 5);
969 m_sdbBtmBtnsSizerPrint->Enable(
true);
971 m_sdbBtmBtnsSizerPrint = NULL;
974 m_sdbBtmBtnsSizerSplit =
new wxButton(
this, wxID_ANY, _(
"Split"),
975 wxDefaultPosition, wxDefaultSize, 0);
976 itemBoxSizerAux->Add(m_sdbBtmBtnsSizerSplit, 0,
977 wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxALL, 5);
978 m_sdbBtmBtnsSizerSplit->Enable(
false);
980 m_sdbBtmBtnsSizerExtend =
new wxButton(
this, wxID_ANY, _(
"Extend track"),
981 wxDefaultPosition, wxDefaultSize, 0);
982 itemBoxSizerAux->Add(m_sdbBtmBtnsSizerExtend, 0,
983 wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxALL, 5);
985 m_sdbBtmBtnsSizerToRoute =
new wxButton(
this, wxID_ANY, _(
"To route"),
986 wxDefaultPosition, wxDefaultSize, 0);
987 itemBoxSizerAux->Add(m_sdbBtmBtnsSizerToRoute, 0,
988 wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxALL, 5);
990 m_sdbBtmBtnsSizerExport =
new wxButton(
this, wxID_ANY, _(
"Export"),
991 wxDefaultPosition, wxDefaultSize, 0);
992 itemBoxSizerAux->Add(m_sdbBtmBtnsSizerExport, 0,
993 wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxALL, 5);
995 wxBoxSizer* itemBoxSizer16 =
new wxBoxSizer(wxHORIZONTAL);
996 itemBoxSizerBottom->Add(itemBoxSizer16, 0, wxALIGN_RIGHT | wxALL, 5);
998 m_sdbBtmBtnsSizerCancel =
new wxButton(
this, wxID_CANCEL, _(
"Cancel"),
999 wxDefaultPosition, wxDefaultSize, 0);
1000 itemBoxSizer16->Add(m_sdbBtmBtnsSizerCancel, 0, wxALIGN_BOTTOM | wxALL, 5);
1002 m_sdbBtmBtnsSizerOK =
1003 new wxButton(
this, wxID_OK, _(
"OK"), wxDefaultPosition, wxDefaultSize, 0);
1004 itemBoxSizer16->Add(m_sdbBtmBtnsSizerOK, 0, wxALIGN_BOTTOM | wxALL, 5);
1005 m_sdbBtmBtnsSizerOK->SetDefault();
1009 ((wxWindowBase*)m_stName)->GetSize(&w1, &h);
1010 ((wxWindowBase*)m_stFrom)->GetSize(&w2, &h);
1011 ((wxWindowBase*)m_stName)->SetMinSize(wxSize(wxMax(w1, w2), h));
1012 ((wxWindowBase*)m_stFrom)->SetMinSize(wxSize(wxMax(w1, w2), h));
1014 m_panelBasic->SetScrollRate(5, 5);
1015 m_panelAdvanced->SetScrollRate(5, 5);
1018 void TrackPropDlg::SetTrackAndUpdate(
Track* pt) {
1021 m_lcPoints->DeleteAllItems();
1023 if (m_pMyLinkList)
delete m_pMyLinkList;
1024 m_pMyLinkList =
new HyperlinkList();
1026 int NbrOfLinks = m_pTrack->m_HyperlinkList->GetCount();
1027 if (NbrOfLinks > 0) {
1028 wxHyperlinkListNode* linknode = m_pTrack->m_HyperlinkList->GetFirst();
1033 h->DescrText = link->DescrText;
1034 h->Link = link->Link;
1035 h->LType = link->LType;
1037 m_pMyLinkList->Append(h);
1039 linknode = linknode->GetNext();
1049 void TrackPropDlg::InitializeList() {
1050 if (NULL == m_pTrack)
return;
1052 m_lcPoints->m_pTrack = m_pTrack;
1054 if (m_pTrack->GetnPoints()) {
1057 m_lcPoints->m_LMT_Offset = long((prp->m_lon) * 3600. / 15.);
1059 m_lcPoints->m_LMT_Offset = 0;
1062 if (m_lcPoints->IsVirtual())
1063 m_lcPoints->SetItemCount(m_pTrack->GetnPoints());
1066 for (
int in = 0; in < m_pTrack->GetnPoints(); in++) {
1070 m_lcPoints->InsertItem(item);
1071 for (
int j = 0; j < 7; j++) {
1073 item.SetText(m_lcPoints->OnGetItemText(in, j));
1074 m_lcPoints->SetItem(item);
1081 if (NULL == m_pTrack)
return false;
1083 ::wxBeginBusyCursor();
1085 if (m_scrolledWindowLinks) {
1086 wxWindowList kids = m_scrolledWindowLinks->GetChildren();
1087 for (
unsigned int i = 0; i < kids.GetCount(); i++) {
1088 wxWindowListNode* node = kids.Item(i);
1089 wxWindow* win = node->GetData();
1091 if (win->IsKindOf(CLASSINFO(wxHyperlinkCtrl))) {
1092 ((wxHyperlinkCtrl*)win)
1094 wxEVT_COMMAND_HYPERLINK,
1095 wxHyperlinkEventHandler(TrackPropDlg::OnHyperLinkClick));
1096 ((wxHyperlinkCtrl*)win)
1099 wxMouseEventHandler(TrackPropDlg::m_hyperlinkContextMenu));
1104 int NbrOfLinks = m_pTrack->m_HyperlinkList->GetCount();
1105 HyperlinkList* hyperlinklist = m_pTrack->m_HyperlinkList;
1107 if (NbrOfLinks > 0) {
1108 wxHyperlinkListNode* linknode = hyperlinklist->GetFirst();
1111 wxString Link = link->Link;
1112 wxString Descr = link->DescrText;
1114 wxHyperlinkCtrl* ctrl =
new wxHyperlinkCtrl(
1115 m_scrolledWindowLinks, wxID_ANY, Descr, Link, wxDefaultPosition,
1116 wxDefaultSize, wxHL_DEFAULT_STYLE);
1117 ctrl->Connect(wxEVT_COMMAND_HYPERLINK,
1118 wxHyperlinkEventHandler(TrackPropDlg::OnHyperLinkClick),
1120 if (!m_pTrack->m_bIsInLayer)
1123 wxMouseEventHandler(TrackPropDlg::m_hyperlinkContextMenu), NULL,
1126 bSizerLinks->Add(ctrl, 0, wxALL, 5);
1128 linknode = linknode->GetNext();
1131 bSizerLinks->Fit(m_scrolledWindowLinks);
1134 m_tName->SetValue(m_pTrack->GetName());
1135 m_tFrom->SetValue(m_pTrack->m_TrackStartString);
1136 m_tTo->SetValue(m_pTrack->m_TrackEndString);
1137 if (m_tDescription) m_tDescription->SetValue(m_pTrack->m_TrackDescription);
1139 m_tTotDistance->SetValue(_T(
""));
1140 m_tTimeEnroute->SetValue(_T(
""));
1142 m_sdbBtmBtnsSizerSplit->Enable(
false);
1143 m_sdbBtmBtnsSizerExtend->Enable(
false);
1146 TrackPoint* last_point = m_pTrack->GetLastPoint();
1147 TrackPoint* first_point = m_pTrack->GetPoint(0);
1148 double trackLength = m_pTrack->Length();
1149 double total_seconds = 0.;
1151 wxString speed(_T(
"--"));
1153 if (last_point && first_point) {
1154 if (last_point->GetCreateTime().IsValid() &&
1155 first_point->GetCreateTime().IsValid()) {
1156 total_seconds = last_point->GetCreateTime()
1157 .Subtract(first_point->GetCreateTime())
1160 if (total_seconds != 0.) {
1161 m_avgspeed = trackLength / total_seconds * 3600;
1165 speed.Printf(_T(
"%5.2f"), toUsrSpeed(m_avgspeed));
1169 m_tAvgSpeed->SetValue(speed);
1173 slen.Printf(wxT(
"%5.2f ") + getUsrDistanceUnit(), toUsrDistance(trackLength));
1175 m_tTotDistance->SetValue(slen);
1179 wxTimeSpan time(0, 0, (
int)total_seconds, 0);
1181 if (total_seconds > 3600. * 24.)
1182 time_form = time.Format(
"%H:%M");
1183 else if (total_seconds > 0.)
1184 time_form = time.Format(
"%H:%M");
1186 time_form = _T(
"--");
1187 m_tTimeEnroute->SetValue(time_form);
1189 m_cbShow->SetValue(m_pTrack->IsVisible());
1191 if (m_pTrack->m_Colour == wxEmptyString)
1192 m_cColor->Select(0);
1194 for (
unsigned int i = 0; i <
sizeof(::GpxxColorNames) /
sizeof(wxString);
1196 if (m_pTrack->m_Colour == ::GpxxColorNames[i]) {
1197 m_cColor->Select(i + 1);
1203 for (
unsigned int i = 0; i <
sizeof(::StyleValues) /
sizeof(
int); i++) {
1204 if (m_pTrack->m_style == ::StyleValues[i]) {
1205 m_cStyle->Select(i);
1210 for (
unsigned int i = 0; i <
sizeof(::WidthValues) /
sizeof(
int); i++) {
1211 if (m_pTrack->m_width == ::WidthValues[i]) {
1212 m_cWidth->Select(i);
1217 if (m_pTrack->m_bIsInLayer) {
1218 m_tName->SetEditable(
false);
1219 m_tFrom->SetEditable(
false);
1220 m_tTo->SetEditable(
false);
1221 if (m_tDescription) m_tDescription->SetEditable(
false);
1222 m_cbShow->Enable(
false);
1223 m_cColor->Enable(
false);
1224 m_cStyle->Enable(
false);
1225 m_cWidth->Enable(
false);
1226 m_sdbBtmBtnsSizerExtend->Enable(
false);
1227 m_sdbBtmBtnsSizerSplit->Enable(
false);
1228 SetTitle(wxString::Format(_T(
"%s, %s: %d"), _(
"Track properties"),
1229 _T(
"Layer"), m_pTrack->m_LayerID));
1231 m_tName->SetEditable(
true);
1232 m_tFrom->SetEditable(
true);
1233 m_tTo->SetEditable(
true);
1234 if (m_tDescription) m_tDescription->SetEditable(
true);
1235 m_cbShow->Enable(
true);
1236 m_cColor->Enable(
true);
1237 m_cStyle->Enable(
true);
1238 m_cWidth->Enable(
true);
1240 m_sdbBtmBtnsSizerExtend->Enable(IsThisTrackExtendable());
1242 SetTitle(_(
"Track properties"));
1245 ::wxEndBusyCursor();
1250 bool TrackPropDlg::IsThisTrackExtendable() {
1251 m_pExtendTrack = NULL;
1252 m_pExtendPoint = NULL;
1253 if (m_pTrack == g_pActiveTrack || m_pTrack->m_bIsInLayer) {
1257 TrackPoint* pLastPoint = m_pTrack->GetPoint(0);
1258 if (!pLastPoint->GetCreateTime().IsValid()) {
1262 for (
Track* ptrack : g_TrackList) {
1263 if (ptrack->IsVisible() && (ptrack->m_GUID != m_pTrack->m_GUID)) {
1264 TrackPoint* track_node = ptrack->GetLastPoint();
1266 if (track_node->GetCreateTime().IsValid()) {
1267 if (track_node->GetCreateTime() <= pLastPoint->GetCreateTime()) {
1268 if (!m_pExtendPoint ||
1269 track_node->GetCreateTime() > m_pExtendPoint->GetCreateTime()) {
1270 m_pExtendPoint = track_node;
1271 m_pExtendTrack = ptrack;
1278 if (m_pExtendTrack) {
1279 return (!m_pExtendTrack->m_bIsInLayer);
1285 void TrackPropDlg::OnExtendBtnClick(wxCommandEvent& event) {
1286 TrackPoint* pFirstPoint = m_pTrack->GetPoint(0);
1288 if (IsThisTrackExtendable()) {
1290 if (pFirstPoint->GetCreateTime() == m_pExtendPoint->GetCreateTime()) {
1293 pSelect->DeleteAllSelectableTrackSegments(m_pExtendTrack);
1294 m_pExtendTrack->Clone(m_pTrack, begin, m_pTrack->GetnPoints(), _(
"_plus"));
1295 pSelect->AddAllSelectableTrackSegments(m_pExtendTrack);
1296 pSelect->DeleteAllSelectableTrackSegments(m_pTrack);
1299 SetTrackAndUpdate(m_pExtendTrack);
1302 if (pRouteManagerDialog && pRouteManagerDialog->IsShown()) {
1303 pRouteManagerDialog->UpdateTrkListCtrl();
1308 void TrackPropDlg::OnSplitBtnClick(wxCommandEvent& event) {
1309 m_sdbBtmBtnsSizerSplit->Enable(
false);
1311 if (m_pTrack->m_bIsInLayer) {
1315 if ((m_nSelected > 1) && (m_nSelected < m_pTrack->GetnPoints())) {
1318 pHead->Clone(m_pTrack, 0, m_nSelected - 1, _(
"_A"));
1319 pTail->Clone(m_pTrack, m_nSelected - 1, m_pTrack->GetnPoints(), _(
"_B"));
1320 g_TrackList.push_back(pHead);
1321 pConfig->AddNewTrack(pHead);
1323 g_TrackList.push_back(pTail);
1324 pConfig->AddNewTrack(pTail);
1326 pConfig->DeleteConfigTrack(m_pTrack);
1328 pSelect->DeleteAllSelectableTrackSegments(m_pTrack);
1330 pSelect->AddAllSelectableTrackSegments(pTail);
1331 pSelect->AddAllSelectableTrackSegments(pHead);
1333 SetTrackAndUpdate(pTail);
1336 if (pRouteManagerDialog && pRouteManagerDialog->IsShown()) {
1337 pRouteManagerDialog->UpdateTrkListCtrl();
1342 void TrackPropDlg::OnTrackPropCopyTxtClick(wxCommandEvent& event) {
1343 wxString tab(
"\t", wxConvUTF8);
1344 wxString eol(
"\n", wxConvUTF8);
1347 csvString << this->GetTitle() << eol << _(
"Name") << tab
1348 << m_pTrack->GetName() << eol << _(
"Depart From") << tab
1349 << m_pTrack->m_TrackStartString << eol << _(
"Destination") << tab
1350 << m_pTrack->m_TrackEndString << eol << _(
"Total distance") << tab
1351 << m_tTotDistance->GetValue() << eol << _(
"Speed") << tab
1352 << m_tAvgSpeed->GetValue() << eol
1353 << _(
"Departure Time") + _T(
" ") + _(
"(m/d/y h:m)") << tab
1354 << m_pTrack->GetPoint(1)->GetCreateTime().Format() << eol
1355 << _(
"Time enroute") << tab << m_tTimeEnroute->GetValue() << eol
1360 noCols = m_lcPoints->GetColumnCount();
1361 noRows = m_lcPoints->GetItemCount();
1363 item.SetMask(wxLIST_MASK_TEXT);
1365 for (
int i = 0; i < noCols; i++) {
1366 m_lcPoints->GetColumn(i, item);
1367 csvString << item.GetText() << tab;
1371 for (
int j = 0; j < noRows; j++) {
1373 for (
int i = 0; i < noCols; i++) {
1375 m_lcPoints->GetItem(item);
1376 csvString << item.GetText() << tab;
1381 if (wxTheClipboard->Open()) {
1382 wxTextDataObject* data =
new wxTextDataObject;
1383 data->SetText(csvString);
1384 wxTheClipboard->SetData(data);
1385 wxTheClipboard->Close();
1389 void TrackPropDlg::OnPrintBtnClick(wxCommandEvent& event) {
1393 dlg->ShowWindowModalThenDo([
this, dlg](
int retcode) {
1394 if (retcode == wxID_OK) {
1399 void TrackPropDlg::OnTrackPropRightClick(wxListEvent& event) {
1402 wxMenuItem* copyItem =
1403 menu.Append(ID_RCLK_MENU_COPY_TEXT, _(
"&Copy all as text"));
1408 void TrackPropDlg::OnTrackPropListClick(wxListEvent& event) {
1414 m_lcPoints->GetNextItem(itemno, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
1418 selected_no = itemno;
1420 m_pTrack->m_HighlightedTrackPoint = -1;
1423 TrackPoint* prp = m_pTrack->GetPoint(itemno);
1425 m_pTrack->m_HighlightedTrackPoint = itemno;
1427 if (!(m_pTrack->m_bIsInLayer) && !(m_pTrack == g_pActiveTrack)) {
1428 m_nSelected = selected_no + 1;
1429 m_sdbBtmBtnsSizerSplit->Enable(
true);
1431 if (gFrame->GetFocusCanvas()) {
1432 gFrame->JumpToPosition(gFrame->GetFocusCanvas(), prp->m_lat,
1434 gFrame->GetFocusCanvas()->GetVPScale());
1437 if (m_lcPoints) m_lcPoints->SetFocus();
1441 if (selected_no == 0 || selected_no == m_pTrack->GetnPoints() - 1)
1442 m_sdbBtmBtnsSizerSplit->Enable(
false);
1445 void TrackPropDlg::OnTrackPropMenuSelected(wxCommandEvent& event) {
1446 switch (event.GetId()) {
1447 case ID_RCLK_MENU_COPY_TEXT:
1448 OnTrackPropCopyTxtClick(event);
1453 void TrackPropDlg::OnToRouteBtnClick(wxCommandEvent& event) {
1454 pRouteManagerDialog->TrackToRoute(m_pTrack);
1455 if (NULL != pRouteManagerDialog && pRouteManagerDialog->IsVisible())
1456 pRouteManagerDialog->UpdateRouteListCtrl();
1459 void TrackPropDlg::OnExportBtnClick(wxCommandEvent& event) {
1460 wxString suggested_name = _(
"track");
1461 std::vector<Track*> list = { m_pTrack };
1462 if (m_pTrack->GetName() != wxEmptyString)
1463 suggested_name = m_pTrack->GetName();
1464 ExportGPXTracks(
this, &list, suggested_name);
1467 void TrackPropDlg::m_hyperlinkContextMenu(wxMouseEvent& event) {
1468 m_pEditedLink = (wxHyperlinkCtrl*)event.GetEventObject();
1470 wxEVT_COMMAND_MENU_SELECTED,
1471 (wxObjectEventFunction)(wxEventFunction)&TrackPropDlg::PopupMenuHandler);
1472 m_scrolledWindowLinks->PopupMenu(
1473 m_menuLink, m_pEditedLink->GetPosition().x + event.GetPosition().x,
1474 m_pEditedLink->GetPosition().y + event.GetPosition().y);
1477 void TrackPropDlg::PopupMenuHandler(wxCommandEvent& event) {
1478 switch (event.GetId()) {
1479 case ID_TRK_MENU_ADD:
1482 case ID_TRK_MENU_EDIT:
1485 case ID_TRK_MENU_DELETE:
1494 wxHyperlinkListNode* nodeToDelete = NULL;
1495 wxString findurl = m_pEditedLink->GetURL();
1496 wxString findlabel = m_pEditedLink->GetLabel();
1498 wxWindowList kids = m_scrolledWindowLinks->GetChildren();
1499 for (
unsigned int i = 0; i < kids.GetCount(); i++) {
1500 wxWindowListNode* node = kids.Item(i);
1501 wxWindow* win = node->GetData();
1503 if (win->IsKindOf(CLASSINFO(wxHyperlinkCtrl))) {
1504 ((wxHyperlinkCtrl*)win)
1505 ->Disconnect(wxEVT_COMMAND_HYPERLINK,
1506 wxHyperlinkEventHandler(TrackPropDlg::OnHyperLinkClick));
1507 ((wxHyperlinkCtrl*)win)
1510 wxMouseEventHandler(TrackPropDlg::m_hyperlinkContextMenu));
1516 int NbrOfLinks = m_pTrack->m_HyperlinkList->GetCount();
1517 HyperlinkList* hyperlinklist = m_pTrack->m_HyperlinkList;
1519 if (NbrOfLinks > 0) {
1520 wxHyperlinkListNode* linknode = hyperlinklist->GetFirst();
1523 wxString Link = link->Link;
1524 wxString Descr = link->DescrText;
1525 if (Link == findurl &&
1526 (Descr == findlabel || (Link == findlabel && Descr == wxEmptyString)))
1527 nodeToDelete = linknode;
1529 wxHyperlinkCtrl* ctrl =
new wxHyperlinkCtrl(
1530 m_scrolledWindowLinks, wxID_ANY, Descr, Link, wxDefaultPosition,
1531 wxDefaultSize, wxHL_DEFAULT_STYLE);
1532 ctrl->Connect(wxEVT_COMMAND_HYPERLINK,
1533 wxHyperlinkEventHandler(TrackPropDlg::OnHyperLinkClick),
1535 ctrl->Connect(wxEVT_RIGHT_DOWN,
1536 wxMouseEventHandler(TrackPropDlg::m_hyperlinkContextMenu),
1539 bSizerLinks->Add(ctrl, 0, wxALL, 5);
1541 linknode = linknode->GetNext();
1544 if (nodeToDelete) hyperlinklist->DeleteNode(nodeToDelete);
1545 m_scrolledWindowLinks->InvalidateBestSize();
1546 m_scrolledWindowLinks->Layout();
1547 sbSizerLinks->Layout();
1551 void TrackPropDlg::OnEditLink(wxCommandEvent& event) {
1552 wxString findurl = m_pEditedLink->GetURL();
1553 wxString findlabel = m_pEditedLink->GetLabel();
1556 LinkPropDlg->m_textCtrlLinkDescription->SetValue(findlabel);
1557 LinkPropDlg->m_textCtrlLinkUrl->SetValue(findurl);
1558 DimeControl(LinkPropDlg);
1559 LinkPropDlg->ShowWindowModalThenDo([
this, LinkPropDlg, findurl,
1560 findlabel](
int retcode) {
1561 if (retcode == wxID_OK) {
1562 int NbrOfLinks = m_pTrack->m_HyperlinkList->GetCount();
1563 HyperlinkList* hyperlinklist = m_pTrack->m_HyperlinkList;
1565 if (NbrOfLinks > 0) {
1566 wxHyperlinkListNode* linknode = hyperlinklist->GetFirst();
1569 wxString Link = link->Link;
1570 wxString Descr = link->DescrText;
1571 if (Link == findurl &&
1572 (Descr == findlabel ||
1573 (Link == findlabel && Descr == wxEmptyString))) {
1574 link->Link = LinkPropDlg->m_textCtrlLinkUrl->GetValue();
1576 LinkPropDlg->m_textCtrlLinkDescription->GetValue();
1577 wxHyperlinkCtrl* h =
1578 (wxHyperlinkCtrl*)m_scrolledWindowLinks->FindWindowByLabel(
1581 h->SetLabel(LinkPropDlg->m_textCtrlLinkDescription->GetValue());
1582 h->SetURL(LinkPropDlg->m_textCtrlLinkUrl->GetValue());
1585 linknode = linknode->GetNext();
1589 m_scrolledWindowLinks->InvalidateBestSize();
1590 m_scrolledWindowLinks->Layout();
1591 sbSizerLinks->Layout();
1597 void TrackPropDlg::OnAddLink(wxCommandEvent& event) {
1599 LinkPropDlg->m_textCtrlLinkDescription->SetValue(wxEmptyString);
1600 LinkPropDlg->m_textCtrlLinkUrl->SetValue(wxEmptyString);
1601 DimeControl(LinkPropDlg);
1602 LinkPropDlg->ShowWindowModalThenDo([
this, LinkPropDlg](
int retcode) {
1603 if (retcode == wxID_OK) {
1604 wxString desc = LinkPropDlg->m_textCtrlLinkDescription->GetValue();
1605 if (desc == wxEmptyString)
1606 desc = LinkPropDlg->m_textCtrlLinkUrl->GetValue();
1607 wxHyperlinkCtrl* ctrl =
new wxHyperlinkCtrl(
1608 m_scrolledWindowLinks, wxID_ANY, desc,
1609 LinkPropDlg->m_textCtrlLinkUrl->GetValue(), wxDefaultPosition,
1610 wxDefaultSize, wxHL_DEFAULT_STYLE);
1611 ctrl->Connect(wxEVT_COMMAND_HYPERLINK,
1612 wxHyperlinkEventHandler(TrackPropDlg::OnHyperLinkClick),
1614 ctrl->Connect(wxEVT_RIGHT_DOWN,
1615 wxMouseEventHandler(TrackPropDlg::m_hyperlinkContextMenu),
1618 bSizerLinks->Add(ctrl, 0, wxALL, 5);
1619 bSizerLinks->Fit(m_scrolledWindowLinks);
1623 h->DescrText = LinkPropDlg->m_textCtrlLinkDescription->GetValue();
1624 h->Link = LinkPropDlg->m_textCtrlLinkUrl->GetValue();
1625 h->LType = wxEmptyString;
1626 m_pTrack->m_HyperlinkList->Append(h);
1631 m_scrolledWindowLinks->InvalidateBestSize();
1632 m_scrolledWindowLinks->Layout();
1633 sbSizerLinks->Layout();
1638 void TrackPropDlg::OnEditLinkToggle(wxCommandEvent& event) {
1639 if (m_toggleBtnEdit->GetValue())
1640 m_staticTextEditEnabled->SetLabel(_(
"Links are opened for editing."));
1642 m_staticTextEditEnabled->SetLabel(
1643 _(
"Links are opened in the default browser."));
1647 void TrackPropDlg::OnHyperLinkClick(wxHyperlinkEvent& event) {
1648 if (m_toggleBtnEdit->GetValue()) {
1649 m_pEditedLink = (wxHyperlinkCtrl*)event.GetEventObject();
1664 wxString cc =
event.GetURL();
1665 if (cc.Find(_T(
"#")) != wxNOT_FOUND) {
1667 wxString(_T(
"HKEY_CLASSES_ROOT\\HTTP\\shell\\open\\command")));
1668 if (RegKey.Exists()) {
1669 wxString command_line;
1670 RegKey.QueryValue(wxString(_T(
"")), command_line);
1673 command_line.Replace(wxString(_T(
"\"")), wxString(_T(
"")));
1676 int l = command_line.Find(_T(
".exe"));
1677 if (wxNOT_FOUND == l) l = command_line.Find(_T(
".EXE"));
1679 if (wxNOT_FOUND != l) {
1680 wxString cl = command_line.Mid(0, l + 4);
1682 cc.Prepend(_T(
"\""));
1683 cc.Append(_T(
"\""));
1691 wxString url =
event.GetURL();
1692 url.Replace(_T(
" "), _T(
"%20"));
1693 ::wxLaunchDefaultBrowser(url);
1698 void TrackPropDlg::OnShowTimeTZ(wxCommandEvent& event) {
1699 if (m_rbShowTimeUTC && m_rbShowTimeUTC->GetValue())
1700 m_lcPoints->m_tz_selection = UTCINPUT;
1701 else if (m_rbShowTimePC && m_rbShowTimePC->GetValue())
1702 m_lcPoints->m_tz_selection = LTINPUT;
1704 m_lcPoints->m_tz_selection = LMTINPUT;
1705 m_lcPoints->DeleteAllItems();
1709 bool TrackPropDlg::SaveChanges(
void) {
1710 if (m_pTrack && !m_pTrack->m_bIsInLayer) {
1712 m_pTrack->SetName(m_tName->GetValue());
1713 m_pTrack->m_TrackStartString = m_tFrom->GetValue();
1714 m_pTrack->m_TrackEndString = m_tTo->GetValue();
1716 m_pTrack->m_TrackDescription = m_tDescription->GetValue();
1717 m_pTrack->SetVisible(m_cbShow->GetValue());
1718 if (m_cColor->GetSelection() == 0)
1719 m_pTrack->m_Colour = wxEmptyString;
1721 m_pTrack->m_Colour = ::GpxxColorNames[m_cColor->GetSelection() - 1];
1722 m_pTrack->m_style = (wxPenStyle)::StyleValues[m_cStyle->GetSelection()];
1723 m_pTrack->m_width = ::WidthValues[m_cWidth->GetSelection()];
1725 pConfig->UpdateTrack(m_pTrack);
1726 pConfig->UpdateSettings();
1729 if (m_pTrack && m_pTrack->IsRunning()) {
1731 v[_T(
"Changed")] =
true;
1732 v[_T(
"Name")] = m_pTrack->GetName();
1733 v[_T(
"GUID")] = m_pTrack->m_GUID;
1734 wxString msg_id(_T(
"OCPN_TRK_ACTIVATED"));
1735 g_pi_manager->SendJSONMessageToAllPlugins(msg_id, v);
1741 void TrackPropDlg::OnOKBtnClick(wxCommandEvent& event) {
1745 bool b_found_track =
1746 std::find(g_TrackList.begin(), g_TrackList.end(), m_pTrack) !=
1749 if (b_found_track) {
1751 m_pTrack->ClearHighlights();
1754 m_bStartNow =
false;
1756 if (pRouteManagerDialog && pRouteManagerDialog->IsShown())
1757 pRouteManagerDialog->UpdateTrkListCtrl();
1760 gFrame->InvalidateAllGL();
1761 gFrame->RefreshAllCanvas(
false);
1766 void TrackPropDlg::OnCancelBtnClick(wxCommandEvent& event) {
1767 bool b_found_track =
1768 std::find(g_TrackList.begin(), g_TrackList.end(), m_pTrack) !=
1771 if (b_found_track) m_pTrack->ClearHighlights();
1774 gFrame->InvalidateAllGL();
1775 gFrame->RefreshAllCanvas(
false);
1784 OCPNTrackListCtrl::OCPNTrackListCtrl(wxWindow* parent, wxWindowID
id,
1785 const wxPoint& pos,
const wxSize& size,
1787 : wxListCtrl(parent, id, pos, size, style) {
1789 m_tz_selection = LTINPUT;
1793 OCPNTrackListCtrl::~OCPNTrackListCtrl() {}
1795 wxString OCPNTrackListCtrl::OnGetItemText(
long item,
long column)
const {
1798 if (item < 0 || item >= m_pTrack->GetnPoints())
return wxEmptyString;
1800 TrackPoint* this_point = m_pTrack->GetPoint(item);
1801 TrackPoint* prev_point = item > 0 ? m_pTrack->GetPoint(item - 1) : NULL;
1803 if (!this_point)
return wxEmptyString;
1805 double gt_brg, gt_leg_dist;
1811 slat = prev_point->m_lat;
1812 slon = prev_point->m_lon;
1820 ret.Printf(_T(
"%ld"), item);
1824 DistanceBearingMercator(this_point->m_lat, this_point->m_lon, slat, slon,
1825 >_brg, >_leg_dist);
1827 ret.Printf(_T(
"%6.2f ") + getUsrDistanceUnit(),
1828 toUsrDistance(gt_leg_dist));
1832 DistanceBearingMercator(this_point->m_lat, this_point->m_lon, slat, slon,
1833 >_brg, >_leg_dist);
1834 ret.Printf(
"%03.0f %cT", gt_brg, 0x00B0);
1838 ret = toSDMM(1, this_point->m_lat, 1);
1842 ret = toSDMM(2, this_point->m_lon, 1);
1846 wxDateTime timestamp = this_point->GetCreateTime();
1847 if (timestamp.IsValid())
1848 ret = timestamp2s(timestamp, m_tz_selection, m_LMT_Offset,
1855 if ((item > 0) && this_point->GetCreateTime().IsValid() &&
1856 prev_point->GetCreateTime().IsValid()) {
1857 DistanceBearingMercator(this_point->m_lat, this_point->m_lon, slat,
1858 slon, >_brg, >_leg_dist);
1860 double seconds = this_point->GetCreateTime()
1861 .Subtract(prev_point->GetCreateTime())
1865 if (seconds > 0.) speed = gt_leg_dist / seconds * 3600;
1867 ret.Printf(_T(
"%5.2f"), toUsrSpeed(speed));
1879 int OCPNTrackListCtrl::OnGetItemColumnImage(
long item,
long column)
const {
void OnDeleteLink(wxCommandEvent &event)
General purpose GUI support.