OpenCPN Partial API docs
Loading...
Searching...
No Matches
REST_server_gui.cpp
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#include <wx/arrstr.h>
26#include <wx/button.h>
27#include <wx/combobox.h>
28#include <wx/dialog.h>
29#include <wx/dynarray.h>
30#include <wx/event.h>
31#include <wx/gdicmn.h>
32#include <wx/sizer.h>
33#include <wx/stattext.h>
34#include <wx/string.h>
35#include <wx/window.h>
36
37// #include "conn_params.h"
38// #include "OCPNPlatform.h"
39// #include "route_gui.h"
40// #include "route.h"
41// #include "route_point_gui.h"
42// #include "route_point.h"
43// #include "ser_ports.h"
44
45#include "REST_server_gui.h"
46#include "FontMgr.h"
47
48IMPLEMENT_DYNAMIC_CLASS(AcceptObjectDialog, wxDialog)
49
50BEGIN_EVENT_TABLE(AcceptObjectDialog, wxDialog)
51 EVT_BUTTON(ID_STG_CANCEL, AcceptObjectDialog::OnCancelClick)
52 EVT_BUTTON(ID_STG_OK, AcceptObjectDialog::OnOKClick)
53END_EVENT_TABLE()
54
56 m_OKButton = NULL;
57 m_CancelButton = NULL;
58 premtext = NULL;
59}
60
61AcceptObjectDialog::AcceptObjectDialog(wxWindow* parent, wxWindowID id,
62 const wxString& caption, const wxString& hint,
63 const wxPoint& pos, const wxSize& size, long style) {
64 wxFont* pif = FontMgr::Get().GetFont(_T("Dialog"));
65 SetFont( *pif );
66 Create(parent, id, caption, hint, pos, size, style);
67}
68
69AcceptObjectDialog::~AcceptObjectDialog() {
70 delete m_OKButton;
71 delete m_CancelButton;
72}
73
74bool AcceptObjectDialog::Create(wxWindow* parent, wxWindowID id,
75 const wxString& caption, const wxString& hint,
76 const wxPoint& pos, const wxSize& size, long style) {
77 SetExtraStyle(GetExtraStyle() | wxWS_EX_BLOCK_EVENTS);
78 wxDialog::Create(parent, id, caption, pos, size, style);
79
80 CreateControls(hint);
81 GetSizer()->Fit(this);
82 GetSizer()->SetSizeHints(this);
83 Centre();
84
85 return TRUE;
86}
87
88void AcceptObjectDialog::CreateControls(const wxString& hint) {
89 AcceptObjectDialog* itemDialog1 = this;
90
91 wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxVERTICAL);
92 SetSizer(itemBoxSizer2);
93
94
95 // Add a reminder text box
96 itemBoxSizer2->AddSpacer(20);
97
98 premtext = new wxStaticText( this, -1, "A loooooooooooooooooooooooooooooooooooooooooooooong line\n");
99 itemBoxSizer2->Add(premtext, 0, wxEXPAND | wxALL, 10);
100
101 // Create a progress gauge
102// wxStaticBox* prog_box = new wxStaticBox(this, wxID_ANY, _("Progress..."));
103//
104// wxStaticBoxSizer* prog_box_sizer = new wxStaticBoxSizer(prog_box, wxVERTICAL);
105// itemBoxSizer2->Add(prog_box_sizer, 0, wxEXPAND | wxALL, 5);
106//
107// m_pgauge = new wxGauge(this, -1, 100);
108// prog_box_sizer->Add(m_pgauge, 0, wxEXPAND | wxALL, 5);
109
110 m_pCheck1 = new wxCheckBox(this, ID_STG_CHECK1, m_checkbox1_msg);
111 itemBoxSizer2->Add(m_pCheck1, 0, wxEXPAND | wxALL, 10);
112
113 if(!m_checkbox1_msg.Length())
114 m_pCheck1->Hide();
115
116
117 // OK/Cancel/etc.
118 wxBoxSizer* itemBoxSizer16 = new wxBoxSizer(wxHORIZONTAL);
119 itemBoxSizer2->Add(itemBoxSizer16, 0, wxALIGN_RIGHT | wxALL, 5);
120
121 m_CancelButton = new wxButton(itemDialog1, ID_STG_CANCEL, _("Cancel"),
122 wxDefaultPosition, wxDefaultSize, 0);
123 itemBoxSizer16->Add(m_CancelButton, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
124
125 m_OKButton = new wxButton(itemDialog1, ID_STG_OK, "OK",
126 wxDefaultPosition, wxDefaultSize, 0);
127 itemBoxSizer16->Add(m_OKButton, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
128 m_OKButton->SetDefault();
129}
130
131void AcceptObjectDialog::SetMessage(const wxString &msg) {
132 if (premtext) {
133 premtext->SetLabel(msg);
134 premtext->Refresh(true);
135 }
136}
137
138void AcceptObjectDialog::SetCheck1Message(const wxString &msg) {
139 m_checkbox1_msg = msg;
140 m_pCheck1->SetLabel(msg);
141 m_pCheck1->Show();
142 GetSizer()->Fit(this);
143}
144
145void AcceptObjectDialog::OnOKClick(wxCommandEvent& event) {
146 EndModal(ID_STG_OK);
147}
148
149void AcceptObjectDialog::OnCancelClick(wxCommandEvent& event) {
150 EndModal(ID_STG_CANCEL);
151}
152
153
154IMPLEMENT_DYNAMIC_CLASS(PINCreateDialog, wxDialog)
155
156BEGIN_EVENT_TABLE(PINCreateDialog, wxDialog)
157 EVT_BUTTON(ID_STG_CANCEL, PINCreateDialog::OnCancelClick)
158 EVT_BUTTON(ID_STG_OK, PINCreateDialog::OnOKClick)
159END_EVENT_TABLE()
160
162 m_OKButton = NULL;
163 m_CancelButton = NULL;
164 premtext = NULL;
165}
166
167PINCreateDialog::PINCreateDialog(wxWindow* parent, wxWindowID id,
168 const wxString& caption, const wxString& hint,
169 const wxPoint& pos, const wxSize& size, long style) {
170 wxFont* pif = FontMgr::Get().GetFont(_T("Dialog"));
171 SetFont( *pif );
172 Create(parent, id, caption, hint, pos, size, style);
173}
174
175PINCreateDialog::~PINCreateDialog() {
176 delete m_OKButton;
177 delete m_CancelButton;
178}
179
180bool PINCreateDialog::Create(wxWindow* parent, wxWindowID id,
181 const wxString& caption, const wxString& hint,
182 const wxPoint& pos, const wxSize& size, long style) {
183 SetExtraStyle(GetExtraStyle() | wxWS_EX_BLOCK_EVENTS);
184 wxDialog::Create(parent, id, caption, pos, size, style);
185
186 CreateControls(hint);
187 GetSizer()->Fit(this);
188 GetSizer()->SetSizeHints(this);
189 Centre();
190
191 return TRUE;
192}
193
194void PINCreateDialog::CreateControls(const wxString& hint) {
195 PINCreateDialog* itemDialog1 = this;
196
197 wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxVERTICAL);
198 SetSizer(itemBoxSizer2);
199
200
201 // Add a reminder text box
202 itemBoxSizer2->AddSpacer(20);
203
204 premtext = new wxStaticText( this, -1, "A loooooooooooooooooooooooooooooooooooooooooooooong line\n");
205 itemBoxSizer2->Add(premtext, 0, wxEXPAND | wxALL, 10);
206
207 m_pText1 = new wxTextCtrl(this, wxID_ANY, wxEmptyString,
208 wxDefaultPosition, wxDefaultSize, wxTE_READONLY | wxTE_CENTRE);
209 itemBoxSizer2->Add(m_pText1, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 10);
210 m_pText1->SetMinSize(wxSize(6 * GetCharWidth(), -1));
211
212 // OK/Cancel/etc.
213 wxBoxSizer* itemBoxSizer16 = new wxBoxSizer(wxHORIZONTAL);
214 itemBoxSizer2->Add(itemBoxSizer16, 0, wxALIGN_RIGHT | wxALL, 5);
215
216 m_CancelButton = new wxButton(itemDialog1, ID_STG_CANCEL, _("Cancel"),
217 wxDefaultPosition, wxDefaultSize, 0);
218 itemBoxSizer16->Add(m_CancelButton, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
219
220 m_OKButton = new wxButton(itemDialog1, ID_STG_OK, "OK",
221 wxDefaultPosition, wxDefaultSize, 0);
222 itemBoxSizer16->Add(m_OKButton, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
223 m_OKButton->SetDefault();
224}
225
226void PINCreateDialog::SetMessage(const wxString &msg) {
227 if (premtext) {
228 premtext->SetLabel(msg);
229 premtext->Refresh(true);
230 }
231}
232
233void PINCreateDialog::SetText1Message(const wxString &msg) {
234 m_pText1->ChangeValue(msg);
235 m_pText1->Show();
236 GetSizer()->Fit(this);
237}
238
239void PINCreateDialog::OnOKClick(wxCommandEvent& event) {
240 Close();
241}
242
243void PINCreateDialog::OnCancelClick(wxCommandEvent& event) {
244 Close();
245}
"Accept Object" Dialog Definition