OpenCPN Partial API docs
SendToPeerDlg.h
1 /***************************************************************************
2  *
3  * Project: OpenCPN
4  *
5  ***************************************************************************
6  * Copyright (C) 2010 by David S. Register *
7  * *
8  * This program is free software; you can redistribute it and/or modify *
9  * it under the terms of the GNU General Public License as published by *
10  * the Free Software Foundation; either version 2 of the License, or *
11  * (at your option) any later version. *
12  * *
13  * This program is distributed in the hope that it will be useful, *
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
16  * GNU General Public License for more details. *
17  * *
18  * You should have received a copy of the GNU General Public License *
19  * along with this program; if not, write to the *
20  * Free Software Foundation, Inc., *
21  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
22  ***************************************************************************
23  */
24 
25 #ifndef __SENDTOPEERDLG_H__
26 #define __SENDTOPEERDLG_H__
27 
28 #include <vector>
29 
30 #include <wx/wxprec.h>
31 #ifndef WX_PRECOMP
32 #include <wx/wx.h>
33 #endif // precompiled headers
34 
35 #include <vector>
36 
37 #include <wx/button.h>
38 #include <wx/checkbox.h>
39 #include <wx/combobox.h>
40 #include <wx/dialog.h>
41 #include <wx/event.h>
42 #include <wx/gauge.h>
43 #include <wx/gdicmn.h>
44 #include <wx/stattext.h>
45 #include <wx/string.h>
46 #include <wx/timer.h>
47 #include <wx/window.h>
48 
49 #include "model/route.h"
50 #include "model/route_point.h"
51 #include "model/track.h"
52 
53 #include "observable_evtvar.h"
54 
55 
56 // Constants for SendToPeer... Dialog
57 #define ID_STPDIALOG 10006
58 #define SYMBOL_STP_STYLE \
59  wxCAPTION | wxRESIZE_BORDER | wxSYSTEM_MENU | wxCLOSE_BOX | \
60  wxFRAME_FLOAT_ON_PARENT
61 #define SYMBOL_STP_TITLE _("Send to Peer")
62 #define SYMBOL_STP_IDNAME ID_STPDIALOG
63 #define SYMBOL_STP_SIZE wxSize(500, 500)
64 #define SYMBOL_STP_POSITION wxDefaultPosition
65 
66 enum { ID_STP_CANCEL = 10000, ID_STP_OK, ID_STP_CHOICE_PEER, ID_STP_SCAN };
67 
71 class SendToPeerDlg : public wxDialog {
72  DECLARE_DYNAMIC_CLASS(SendToPeerDlg)
73  DECLARE_EVENT_TABLE()
74 
75 public:
76  SendToPeerDlg();
77  ~SendToPeerDlg();
78 
79  bool Create(wxWindow* parent, wxWindowID id = SYMBOL_STP_IDNAME,
80  const wxString& caption = SYMBOL_STP_TITLE,
81  const wxString& hint = SYMBOL_STP_TITLE,
82  const wxPoint& pos = SYMBOL_STP_POSITION,
83  const wxSize& size = SYMBOL_STP_SIZE,
84  long style = SYMBOL_STP_STYLE);
85  void SetRoute(Route* pRoute) { m_RouteList.push_back(pRoute); }
86  void SetWaypoint(RoutePoint* pRoutePoint) { m_RoutePointList.push_back(pRoutePoint); }
87  void SetTrack(Track* pTrack) { m_TrackList.push_back(pTrack); }
88  void SetMessage(wxString message);
89  void SetScanOnCreate(bool s){ m_bScanOnCreate = s;}
90  void SetScanTime(int t){ m_scanTime = t * 2;}
91 
92 private:
93  void CreateControls([[maybe_unused]] const wxString& hint);
94 
95  void OnCancelClick(wxCommandEvent& event);
96  void OnSendClick([[maybe_unused]] wxCommandEvent& event);
97  void OnScanClick(wxCommandEvent& event);
98  void OnTimerAutoscan(wxTimerEvent &event);
99  void OnTimerScanTick(wxTimerEvent &event);
100  void DoScan();
101  bool EnableActivateChkbox();
102 
103  std::vector<Route*> m_RouteList;
104  std::vector<RoutePoint*> m_RoutePointList;
105  std::vector<Track*> m_TrackList;
106  wxComboBox* m_PeerListBox;
107  wxGauge* m_pgauge;
108  wxButton* m_CancelButton;
109  wxButton* m_SendButton;
110  wxStaticText* premtext;
111  wxButton* m_RescanButton;
112  wxCheckBox* m_activate_chkbox;
113  EventVar progress;
114  ObsListener progress_listener;
115  std::string m_ownipAddr;
116 
117  wxTimer m_autoScanTimer;
118  wxTimer m_ScanTickTimer;
119  int m_tick;
120  int m_scanTime;
121  bool m_bScanOnCreate;
122 
123 };
124 
125 #endif
Generic event handling between MVC Model and Controller based on a shared EventVar variable.
Define an action to be performed when a KeyProvider is notified.
Definition: observable.h:210
Definition: route.h:75
Route "Send to Peer..." Dialog Definition.
Definition: SendToPeerDlg.h:71
Definition: track.h:78