1 /*
2     This program is free software; you can redistribute it and/or
3     modify it under the terms of the GNU General Public License
4     as published by the Free Software Foundation; either version 2
5     of the License, or (at your option) any later version.
6 
7     This program is distributed in the hope that it will be useful,
8     but WITHOUT ANY WARRANTY; without even the implied warranty of
9     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10     GNU General Public License for more details.
11 
12     You should have received a copy of the GNU General Public License
13     along with this program; if not, write to the Free Software
14     Foundation, Inc., 51 Franklin Street, Fifth Floor,
15     Boston, MA  02110-1301, USA.
16 
17     ---
18     Copyright (C) 2010, Anders Lund <anders@alweb.dk>
19  */
20 
21 #ifndef _RouteManagerDialog_h_
22 #define _RouteManagerDialog_h_
23 
24 #include <wx/frame.h>
25 #include <wx/timer.h>
26 #include <wx/notebook.h>
27 #include <wx/panel.h>
28 #include <wx/listctrl.h>
29 #include <wx/notebook.h>
30 #include <wx/stattext.h>
31 #include <wx/textctrl.h>
32 #include <wx/checkbox.h>
33 
34 #define NAME_COLUMN 2
35 #define DISTANCE_COLUMN 3
36 
37 enum {
38       SORT_ON_DISTANCE  = 1,
39       SORT_ON_NAME
40 };
41 
42 enum TrackContextMenu {
43       TRACK_MERGE  = 1,
44       TRACK_COPY_TEXT,
45       TRACK_CLEAN
46 };
47 
48 class wxButton;
49 class Route;
50 class Track;
51 class Layer;
52 class RoutePoint;
53 
54 class RouteManagerDialog : public wxFrame {
55       DECLARE_EVENT_TABLE()
56 
57       public:
58             static RouteManagerDialog* getInstance(wxWindow *parent);
getInstanceFlag()59             static bool getInstanceFlag(){ return instanceFlag; }
60             ~RouteManagerDialog();
61 
62             void OnClose(wxCloseEvent& event);
63             void OnOK(wxCommandEvent& event);
64 
65             void SetColorScheme();
66             void RecalculateSize();
67             void UpdateRouteListCtrl();     // Rebuild route list
68             void UpdateTrkListCtrl();
69             void UpdateWptListCtrl(RoutePoint *rp_select = NULL, bool b_retain_sort = true);
70             void UpdateLayListCtrl();
71             void UpdateWptListCtrlViz();
72 
73             void UpdateLists();
74 
75             void OnTabSwitch(wxNotebookEvent& event);
76             static void WptShowPropertiesDialog( RoutePoint* wp, wxWindow* parent );
77             void TrackToRoute( Track *track );
78 
79       private:
80             static bool instanceFlag;
81             static RouteManagerDialog *single;
82 
83             RouteManagerDialog(wxWindow *parent);
84 
85             void Create();
86             void UpdateRteButtons();           // Correct button state
87             void MakeAllRoutesInvisible();  // Mark all routes as invisible. Does not flush settings.
88             void ZoomtoRoute(Route *route); // Attempt to zoom route into the view
89             void UpdateTrkButtons();           // Correct button state
90             void UpdateWptButtons();           // Correct button state
91             void UpdateLayButtons();           // Correct button state
92             void ToggleLayerContentsOnChart(Layer *layer);
93             void ToggleLayerContentsOnListing(Layer *layer);
94             void ToggleLayerContentsNames(Layer *layer);
95             void AddNewLayer(bool isPersistent);
96 
97             // event handlers
98             void OnRteDeleteClick(wxCommandEvent &event);
99             void OnRtePropertiesClick(wxCommandEvent &event);
100             void OnRteZoomtoClick(wxCommandEvent &event);
101             void OnRteActivateClick(wxCommandEvent &event);
102             void OnRteReverseClick(wxCommandEvent &event);
103             void OnRteExportClick(wxCommandEvent &event);
104             void OnRteToggleVisibility(wxMouseEvent &event);
105             void OnRteBtnLeftDown(wxMouseEvent &event); // record control key state for some action buttons
106             void OnRteDeleteAllClick(wxCommandEvent &event);
107             void OnRteSelected(wxListEvent &event);
108             void OnRteSendToGPSClick(wxCommandEvent &event);
109             void OnRteDefaultAction(wxListEvent &event);
110             void OnRteColumnClicked(wxListEvent &event);
111             void OnTrkDefaultAction(wxListEvent &event);
112             void OnTrkNewClick(wxCommandEvent &event);
113             void OnTrkPropertiesClick(wxCommandEvent &event);
114             void OnTrkDeleteClick(wxCommandEvent &event);
115             void OnTrkExportClick(wxCommandEvent &event);
116             void OnTrkRouteFromTrackClick(wxCommandEvent &event);
117             void OnTrkDeleteAllClick(wxCommandEvent &event);
118             void OnTrkSelected(wxListEvent &event);
119             void OnTrkToggleVisibility(wxMouseEvent &event);
120             void OnTrkColumnClicked(wxListEvent &event);
121             void OnTrkRightClick(wxListEvent &event);
122             void OnTrkMenuSelected(wxCommandEvent &event);
123             void OnWptDefaultAction(wxListEvent &event);
124             void OnWptNewClick(wxCommandEvent &event);
125             void OnWptPropertiesClick(wxCommandEvent &event);
126             void OnWptZoomtoClick(wxCommandEvent &event);
127             void OnWptDeleteClick(wxCommandEvent &event);
128             void OnWptGoToClick(wxCommandEvent &event);
129             void OnWptExportClick(wxCommandEvent &event);
130             void OnWptSendToGPSClick(wxCommandEvent &event);
131             void OnWptDeleteAllClick(wxCommandEvent &event);
132             void OnWptSelected(wxListEvent &event);
133             void OnWptToggleVisibility(wxMouseEvent &event);
134             void OnWptColumnClicked(wxListEvent &event);
135             void OnLayDefaultAction(wxListEvent &event);
136             void OnLayNewClick(wxCommandEvent &event);
137             void OnPerLayNewClick(wxCommandEvent &event);
138             void OnLayPropertiesClick(wxCommandEvent &event);
139             void OnLayToggleChartClick(wxCommandEvent &event);
140             void OnLayToggleListingClick(wxCommandEvent &event);
141             void OnLayToggleNamesClick(wxCommandEvent &event);
142             void OnLayDeleteClick(wxCommandEvent &event);
143             void OnLaySelected(wxListEvent &event);
144             void OnLayToggleVisibility(wxMouseEvent &event);
145             void OnLayColumnClicked(wxListEvent &event);
146             void OnImportClick(wxCommandEvent &event);
147             void OnExportClick(wxCommandEvent &event);
148             void OnExportVizClick(wxCommandEvent &event);
149             void OnFilterChanged( wxCommandEvent& event );
150             void OnKey( wxKeyEvent& ke );
151 
152             // properties
153             wxNotebook *m_pNotebook;
154             wxPanel    *m_pPanelRte;
155             wxPanel    *m_pPanelTrk;
156             wxPanel    *m_pPanelWpt;
157             wxPanel     *m_pPanelLay;
158             wxListCtrl *m_pRouteListCtrl;
159             wxListCtrl *m_pTrkListCtrl;
160             wxListCtrl *m_pWptListCtrl;
161             wxListCtrl  *m_pLayListCtrl;
162             wxStaticText *m_stFilterWpt;
163             wxTextCtrl *m_tFilterWpt;
164             wxStaticText *m_stFilterRte;
165             wxTextCtrl *m_tFilterRte;
166             wxStaticText *m_stFilterTrk;
167             wxTextCtrl *m_tFilterTrk;
168             wxStaticText *m_stFilterLay;
169             wxTextCtrl *m_tFilterLay;
170 
171             wxButton *btnRteProperties;
172             wxButton *btnRteActivate;
173             wxButton *btnRteZoomto;
174             wxButton *btnRteReverse;
175             wxButton *btnRteDelete;
176             wxButton *btnRteExport;
177             wxButton *btnRteSendToGPS;
178             wxButton *btnRteDeleteAll;
179             wxButton *btnTrkNew;
180             wxButton *btnTrkProperties;
181             wxButton *btnTrkDelete;
182             wxButton *btnTrkExport;
183             wxButton *btnTrkRouteFromTrack;
184             wxButton *btnTrkDeleteAll;
185             wxButton *btnWptNew;
186             wxButton *btnWptProperties;
187             wxButton *btnWptZoomto;
188             wxButton *btnWptDelete;
189             wxButton *btnWptGoTo;
190             wxButton *btnWptExport;
191             wxButton *btnWptSendToGPS;
192             wxButton *btnWptDeleteAll;
193             wxButton *btnLayNew;
194             wxButton *btnPerLayNew;
195             //wxButton *btnLayProperties;
196             wxCheckBox *cbLayToggleChart;
197             wxCheckBox *cbLayToggleListing;
198             wxCheckBox *cbLayToggleNames;
199             wxButton *btnLayDelete;
200             wxButton *btnImport;
201             wxButton *btnExport;
202             wxButton *btnExportViz;
203 
204             bool m_bPossibleClick;    // do
205             bool m_bCtrlDown;         // record control key state for some action buttons
206             bool m_bNeedConfigFlush;  // if true, update config in destructor
207 
208             int m_lastWptItem;
209             int m_lastTrkItem;
210             int m_lastRteItem;
211 
212             int m_charWidth;
213             int m_listIconSize;
214 };
215 
216 #endif // _RouteManagerDialog_h_
217 // kate: indent-width 6; indent-mode cstyle; space-indent on;
218