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>
31 #include <wx/gdicmn.h>
33 #include <wx/stattext.h>
34 #include <wx/string.h>
35 #include <wx/window.h>
38 #include "rest_server_gui.h"
39 #include "routemanagerdialog.h"
42 #include "androidUTIL.h"
49 static wxDialog* DisplayDlg(
const std::string& msg,
const std::string& txt1) {
50 auto dlg =
new PINCreateDialog(
dynamic_cast<wxWindow*
>(gFrame), wxID_ANY,
51 _(
"OpenCPN Server Message"),
52 "", wxDefaultPosition, wxDefaultSize,
55 dlg->SetText1Message(txt1);
60 static void UpdateRouteMgr() {
61 if( pRouteManagerDialog && pRouteManagerDialog->IsShown() ) {
62 pRouteManagerDialog->UpdateTrkListCtrl();
63 pRouteManagerDialog->UpdateWptListCtrl();
64 pRouteManagerDialog->UpdateRouteListCtrl();
69 const wxString& check1msg) {
71 int result = dlg.ShowModal();
72 bool check1 = dlg.GetCheck1Value();
79 [](
const std::string& msg,
const std::string& text1) {
80 return DisplayDlg(msg, text1); };
81 ctx.update_route_mgr = []() { UpdateRouteMgr(); };
82 ctx.run_accept_object_dlg =
83 [](
const wxString& msg,
const wxString& check1msg) {
84 return RunAcceptObjectDlg(msg, check1msg); };
85 ctx.top_level_refresh = []() {
dynamic_cast<wxWindow*
>(gFrame)->Refresh(); };
92 EVT_BUTTON(ID_STG_CANCEL, AcceptObjectDialog::OnCancelClick)
93 EVT_BUTTON(ID_STG_OK, AcceptObjectDialog::OnOKClick)
98 m_CancelButton = NULL;
102 AcceptObjectDialog::AcceptObjectDialog(wxWindow* parent,
103 const wxString& caption,
104 const wxString& msg1,
107 wxDefaultSize, SYMBOL_STG_STYLE,
110 AcceptObjectDialog::AcceptObjectDialog(wxWindow* parent, wxWindowID
id,
111 const wxString& caption,
const wxString& hint,
112 const wxPoint& pos,
const wxSize& size,
long style,
113 const wxString& msg1,
const wxString& msg2) {
114 wxFont* pif = FontMgr::Get().GetFont(_T(
"Dialog"));
116 m_checkbox1_msg = msg2;
117 Create(parent,
id, caption, hint, pos, size, style, msg1, msg2);
119 androidDisableRotation();
123 AcceptObjectDialog::~AcceptObjectDialog() {
125 delete m_CancelButton;
127 androidEnableRotation();
132 bool AcceptObjectDialog::Create(wxWindow* parent, wxWindowID
id,
133 const wxString& caption,
const wxString& hint,
134 const wxPoint& pos,
const wxSize& size,
long style,
135 const wxString& msg1,
const wxString& msg2) {
136 SetExtraStyle(GetExtraStyle() | wxWS_EX_BLOCK_EVENTS);
137 wxDialog::Create(parent,
id, caption, pos, size, style);
139 CreateControls(hint, msg1, msg2);
140 GetSizer()->Fit(
this);
141 GetSizer()->SetSizeHints(
this);
147 void AcceptObjectDialog::CreateControls(
const wxString& hint,
const wxString& msg1,
const wxString& msg2) {
150 wxBoxSizer* itemBoxSizer2 =
new wxBoxSizer(wxVERTICAL);
151 SetSizer(itemBoxSizer2);
155 itemBoxSizer2->AddSpacer(20);
157 premtext =
new wxStaticText(
this, -1, msg1);
158 itemBoxSizer2->Add(premtext, 0, wxEXPAND | wxALL, 10);
160 m_pCheck1 =
new wxCheckBox(
this, ID_STG_CHECK1, m_checkbox1_msg);
161 itemBoxSizer2->Add(m_pCheck1, 0, wxEXPAND | wxALL, 10);
163 if(!m_checkbox1_msg.Length())
168 wxBoxSizer* itemBoxSizer16 =
new wxBoxSizer(wxHORIZONTAL);
169 itemBoxSizer2->Add(itemBoxSizer16, 0, wxALIGN_RIGHT | wxALL, 5);
171 m_CancelButton =
new wxButton(itemDialog1, ID_STG_CANCEL, _(
"Cancel"),
172 wxDefaultPosition, wxDefaultSize, 0);
173 itemBoxSizer16->Add(m_CancelButton, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
175 m_OKButton =
new wxButton(itemDialog1, ID_STG_OK,
"OK",
176 wxDefaultPosition, wxDefaultSize, 0);
177 itemBoxSizer16->Add(m_OKButton, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
178 m_OKButton->SetDefault();
181 void AcceptObjectDialog::SetMessage(
const wxString &msg) {
183 premtext->SetLabel(msg);
184 premtext->Refresh(
true);
188 void AcceptObjectDialog::SetCheck1Message(
const wxString &msg) {
189 m_checkbox1_msg = msg;
190 m_pCheck1->SetLabel(msg);
192 GetSizer()->Fit(
this);
195 void AcceptObjectDialog::OnOKClick(wxCommandEvent& event) {
197 SetReturnCode(ID_STG_OK);
200 void AcceptObjectDialog::OnCancelClick(wxCommandEvent& event) {
201 EndModal(ID_STG_CANCEL);
203 androidDisableRotation();
211 EVT_BUTTON(ID_STG_CANCEL, PINCreateDialog::OnCancelClick)
212 EVT_BUTTON(ID_STG_OK, PINCreateDialog::OnOKClick)
217 m_CancelButton = NULL;
220 androidEnableRotation();
225 PINCreateDialog::PINCreateDialog(wxWindow* parent, wxWindowID
id,
226 const wxString& caption,
const wxString& hint,
227 const wxPoint& pos,
const wxSize& size,
long style) {
228 wxFont* pif = FontMgr::Get().GetFont(_T(
"Dialog"));
230 Create(parent,
id, caption, hint, pos, size, style);
232 androidDisableRotation();
237 PINCreateDialog::~PINCreateDialog() {
239 delete m_CancelButton;
241 androidEnableRotation();
246 wxDialog* PINCreateDialog::Initiate(
const std::string& msg,
247 const std::string& text1) {
249 wxID_ANY, _(
"OpenCPN Server Message"),
"",
250 wxDefaultPosition, wxDefaultSize, SYMBOL_STG_STYLE );
251 dlg->SetMessage(msg);
252 dlg->SetText1Message(text1);
257 void PINCreateDialog::DeInit(){
262 bool PINCreateDialog::Create(wxWindow* parent, wxWindowID
id,
263 const wxString& caption,
const wxString& hint,
264 const wxPoint& pos,
const wxSize& size,
long style) {
265 SetExtraStyle(GetExtraStyle() | wxWS_EX_BLOCK_EVENTS);
266 wxDialog::Create(parent,
id, caption, pos, size, style);
268 CreateControls(hint);
269 GetSizer()->Fit(
this);
270 GetSizer()->SetSizeHints(
this);
276 void PINCreateDialog::CreateControls(
const wxString& hint) {
279 wxBoxSizer* itemBoxSizer2 =
new wxBoxSizer(wxVERTICAL);
280 SetSizer(itemBoxSizer2);
284 itemBoxSizer2->AddSpacer(20);
286 premtext =
new wxStaticText(
this, -1,
"A loooooooooooooooooooooooooooooooooooooooooooooong line\n");
287 itemBoxSizer2->Add(premtext, 0, wxEXPAND | wxALL, 10);
289 m_pText1 =
new wxTextCtrl(
this, wxID_ANY, wxEmptyString,
290 wxDefaultPosition, wxDefaultSize, wxTE_READONLY | wxTE_CENTRE);
291 itemBoxSizer2->Add(m_pText1, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 5);
292 m_pText1->SetMinSize(wxSize(7 * GetCharWidth(), -1));
295 wxBoxSizer* itemBoxSizer16 =
new wxBoxSizer(wxHORIZONTAL);
296 itemBoxSizer2->Add(itemBoxSizer16, 0, wxALIGN_RIGHT | wxALL, 5);
298 m_CancelButton =
new wxButton(itemDialog1, ID_STG_CANCEL, _(
"Cancel"),
299 wxDefaultPosition, wxDefaultSize, 0);
300 itemBoxSizer16->Add(m_CancelButton, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
302 m_OKButton =
new wxButton(itemDialog1, ID_STG_OK,
"OK",
303 wxDefaultPosition, wxDefaultSize, 0);
304 itemBoxSizer16->Add(m_OKButton, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
305 m_OKButton->SetDefault();
308 void PINCreateDialog::SetMessage(
const wxString &msg) {
310 premtext->SetLabel(msg);
311 premtext->Refresh(
true);
315 void PINCreateDialog::SetText1Message(
const wxString &msg) {
316 m_pText1->ChangeValue(msg);
318 GetSizer()->Fit(
this);
321 void PINCreateDialog::OnOKClick(wxCommandEvent& event) {
325 void PINCreateDialog::OnCancelClick(wxCommandEvent& event) {
"Accept Object" Dialog Definition
Callbacks for handling dialogs and RouteManager updates.
Returned status from RunAcceptObjectDlg.