OpenCPN Partial API docs
TrackPropDlg.h
1 /***************************************************************************
2  *
3  * Project: OpenCPN
4  * Purpose: Track Properties Dialog
5  * Author: David Register
6  *
7  ***************************************************************************
8  * Copyright (C) 2013 by David S. Register *
9  * *
10  * This program is free software; you can redistribute it and/or modify *
11  * it under the terms of the GNU General Public License as published by *
12  * the Free Software Foundation; either version 2 of the License, or *
13  * (at your option) any later version. *
14  * *
15  * This program is distributed in the hope that it will be useful, *
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
18  * GNU General Public License for more details. *
19  * *
20  * You should have received a copy of the GNU General Public License *
21  * along with this program; if not, write to the *
22  * Free Software Foundation, Inc., *
23  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
24  **************************************************************************/
25 
26 #ifndef __TRACKPROPDLG_H__
27 #define __TRACKPROPDLG_H__
28 
29 #include <wx/clipbrd.h>
30 #include <wx/artprov.h>
31 #include <wx/xrc/xmlres.h>
32 #include <wx/intl.h>
33 #include <wx/string.h>
34 #include <wx/stattext.h>
35 #include <wx/gdicmn.h>
36 #include <wx/font.h>
37 #include <wx/colour.h>
38 #include <wx/settings.h>
39 #include <wx/textctrl.h>
40 #include <wx/sizer.h>
41 #include <wx/checkbox.h>
42 #include <wx/choice.h>
43 #include <wx/clipbrd.h>
44 #include <wx/colour.h>
45 #include <wx/font.h>
46 #include <wx/frame.h>
47 #include <wx/gdicmn.h>
48 #include <wx/hyperlink.h>
49 #include <wx/icon.h>
50 #include <wx/image.h>
51 #include <wx/intl.h>
52 #include <wx/listctrl.h>
53 #include <wx/panel.h>
54 #include <wx/radiobut.h>
55 #include <wx/scrolwin.h>
56 #include <wx/button.h>
57 #include <wx/tglbtn.h>
58 #include <wx/notebook.h>
59 
60 #if wxCHECK_VERSION(2, 9, 0)
61 #include <wx/dialog.h>
62 #else
63 #include "scrollingdialog.h"
64 #endif
65 
66 #include "LinkPropDlg.h"
67 
68 #ifdef __WXOSX__
69 #define DIALOG_PARENT wxFrame
70 #else
71 #define DIALOG_PARENT wxDialog
72 #endif
73 
74 #define ID_RCLK_MENU_COPY_TEXT 7013
75 
76 #define ID_TRK_MENU_ADD 7014
77 #define ID_TRK_MENU_EDIT 7015
78 #define ID_TRK_MENU_DELETE 7016
79 
84 class wxListCtrl;
85 class OCPNTrackListCtrl;
86 class Track;
87 class TrackPoint;
88 class HyperlinkList;
89 
93 class TrackPropDlg : public DIALOG_PARENT {
94 private:
95  static bool instanceFlag;
96  static TrackPropDlg* single;
97  TrackPropDlg(wxWindow* parent, wxWindowID id, const wxString& title,
98  const wxPoint& pos, const wxSize& size, long style);
99 
100  TrackPoint* m_pExtendPoint;
101  Track* m_pExtendTrack;
102  TrackPoint* m_pEntrackPoint;
103  bool m_bStartNow;
104 
105  double m_planspeed;
106  double m_avgspeed;
107 
108  int m_nSelected; // index of point selected in Properties dialog row
109 
110  bool IsThisTrackExtendable();
111  bool SaveChanges(void);
112 
113  HyperlinkList* m_pMyLinkList;
114  void OnHyperLinkClick(wxHyperlinkEvent& event);
115  wxHyperlinkCtrl* m_pEditedLink;
116  void PopupMenuHandler(wxCommandEvent& event);
117  void OnActivate(wxActivateEvent& event);
118 
119 protected:
120  wxNotebook* m_notebook1;
121  wxScrolledWindow* m_panelBasic;
122  wxStaticText* m_stName;
123  wxTextCtrl* m_tName;
124  wxStaticText* m_stFrom;
125  wxTextCtrl* m_tFrom;
126  wxStaticText* m_stTo;
127  wxTextCtrl* m_tTo;
128  wxCheckBox* m_cbShow;
129  wxStaticText* m_stColor;
130  wxChoice* m_cColor;
131  wxStaticText* m_stStyle;
132  wxChoice* m_cStyle;
133  wxStaticText* m_stWidth;
134  wxChoice* m_cWidth;
135  wxStaticText* m_stTotDistance;
136  wxTextCtrl* m_tTotDistance;
137  wxStaticText* m_stAvgSpeed;
138  wxTextCtrl* m_tAvgSpeed;
139  wxStaticText* m_stTimeEnroute;
140  wxTextCtrl* m_tTimeEnroute;
141  wxStaticText* m_stShowTime;
142  wxRadioButton* m_rbShowTimeUTC;
143  wxRadioButton* m_rbShowTimePC;
144  wxRadioButton* m_rbShowTimeLocal;
145  OCPNTrackListCtrl* m_lcPoints;
146  wxScrolledWindow* m_panelAdvanced;
147  wxStaticText* m_stDescription;
148  wxTextCtrl* m_tDescription;
149  wxScrolledWindow* m_scrolledWindowLinks;
150  wxHyperlinkCtrl* m_hyperlink1;
151  wxMenu* m_menuLink;
152  wxButton* m_buttonAddLink;
153  wxToggleButton* m_toggleBtnEdit;
154  wxStaticText* m_staticTextEditEnabled;
155  wxStdDialogButtonSizer* m_sdbBtmBtnsSizer;
156  wxButton* m_sdbBtmBtnsSizerOK;
157  wxButton* m_sdbBtmBtnsSizerCancel;
158  wxStaticBoxSizer* sbSizerLinks;
159  wxBoxSizer* bSizerLinks;
160 
161  wxButton* m_sdbBtmBtnsSizerPrint;
162  wxButton* m_sdbBtmBtnsSizerSplit;
163  wxButton* m_sdbBtmBtnsSizerExtend;
164  wxButton* m_sdbBtmBtnsSizerToRoute;
165  wxButton* m_sdbBtmBtnsSizerExport;
166 
167  wxMenuItem* m_menuItemEdit;
168  wxMenuItem* m_menuItemAdd;
169  wxMenuItem* m_menuItemDelete;
170 
171  wxScrolledWindow* itemDialog1;
172  bool m_bcompact;
173 
174  // Virtual event handlers, overide them in your derived class
175  void OnCancelBtnClick(wxCommandEvent& event);
176  void OnOKBtnClick(wxCommandEvent& event);
177  void OnPrintBtnClick(wxCommandEvent& event);
178  void OnSplitBtnClick(wxCommandEvent& event);
179  void OnExtendBtnClick(wxCommandEvent& event);
180  void OnToRouteBtnClick(wxCommandEvent& event);
181  void OnExportBtnClick(wxCommandEvent& event);
182  void OnTrackPropCopyTxtClick(wxCommandEvent& event);
183  void OnTrackPropListClick(wxListEvent& event);
184  void OnTrackPropRightClick(wxListEvent& event);
185  void OnTrackPropMenuSelected(wxCommandEvent& event);
186  void OnDeleteLink(wxCommandEvent& event);
187  void OnEditLink(wxCommandEvent& event);
188  void OnAddLink(wxCommandEvent& event);
189  void OnEditLinkToggle(wxCommandEvent& event);
190  void OnShowTimeTZ(wxCommandEvent& event);
191  void CreateControls(void);
192  void CreateControlsCompact(void);
193 
194 public:
195  static TrackPropDlg* getInstance(
196  wxWindow* parent, wxWindowID id = wxID_ANY,
197  const wxString& title = _("Track properties"),
198  const wxPoint& pos = wxDefaultPosition,
199  const wxSize& size = wxSize(680, 440),
200  long style = FRAME_WITH_LINKS_STYLE);
201  static bool getInstanceFlag() { return instanceFlag; }
202  ~TrackPropDlg();
203 
204  void m_hyperlink1OnContextMenu(wxMouseEvent& event) {
205  m_hyperlink1->PopupMenu(m_menuLink, event.GetPosition());
206  }
207 
208  void SetTrackAndUpdate(Track* pt);
209  bool UpdateProperties();
210  void InitializeList();
211  Track* GetTrack() { return m_pTrack; }
212 
213  void RecalculateSize(void);
214 
215  Track* m_pTrack;
216 
217  void m_hyperlinkContextMenu(wxMouseEvent& event);
218 };
219 
220 class OCPNTrackListCtrl : public wxListCtrl {
221 public:
222  OCPNTrackListCtrl(wxWindow* parent, wxWindowID id, const wxPoint& pos,
223  const wxSize& size, long style);
225 
226  wxString OnGetItemText(long item, long column) const;
227  int OnGetItemColumnImage(long item, long column) const;
228 
229  Track* m_pTrack;
230  int m_tz_selection;
231  int m_LMT_Offset;
232 };
233 
234 #endif //__TRACKPROPDLG_H__
Class TrackPropDlg.
Definition: TrackPropDlg.h:93
bool UpdateProperties()
void OnDeleteLink(wxCommandEvent &event)
Definition: track.h:78