27#include <wx/combobox.h>
29#include <wx/dynarray.h>
33#include <wx/stattext.h>
38#include "rest_server_gui.h"
39#include "routemanagerdialog.h"
42#include "androidUTIL.h"
47static wxDialog* DisplayDlg(
const std::string& msg,
const std::string& txt1) {
49 wxTheApp->GetTopWindow(), wxID_ANY, _(
"OpenCPN Server Message"),
"",
50 wxDefaultPosition, wxDefaultSize, SYMBOL_STG_STYLE);
52 dlg->SetText1Message(txt1);
57static void UpdateRouteMgr() {
58 if (pRouteManagerDialog && pRouteManagerDialog->IsShown()) {
59 pRouteManagerDialog->UpdateTrkListCtrl();
60 pRouteManagerDialog->UpdateWptListCtrl();
61 pRouteManagerDialog->UpdateRouteListCtrl();
66 const wxString& check1msg) {
68 int result = dlg.ShowModal();
69 bool check1 = dlg.GetCheck1Value();
75 ctx.run_pincode_dlg = [](
const std::string& msg,
const std::string& text1) {
76 return DisplayDlg(msg, text1);
78 ctx.update_route_mgr = []() { UpdateRouteMgr(); };
79 ctx.run_accept_object_dlg = [](
const wxString& msg,
80 const wxString& check1msg) {
81 return RunAcceptObjectDlg(msg, check1msg);
83 ctx.top_level_refresh = []() { wxTheApp->GetTopWindow()->Refresh(); };
88EVT_BUTTON(ID_STG_CANCEL, AcceptObjectDialog::OnCancelClick)
89EVT_BUTTON(ID_STG_OK, AcceptObjectDialog::OnOKClick)
94 m_CancelButton = NULL;
98AcceptObjectDialog::AcceptObjectDialog(wxWindow* parent,
99 const wxString& caption,
100 const wxString& msg1,
103 wxDefaultSize, SYMBOL_STG_STYLE, msg1, msg2) {}
105AcceptObjectDialog::AcceptObjectDialog(wxWindow* parent, wxWindowID
id,
106 const wxString& caption,
107 const wxString& hint,
const wxPoint& pos,
108 const wxSize& size,
long style,
109 const wxString& msg1,
110 const wxString& msg2) {
111 wxFont* pif = FontMgr::Get().
GetFont(_(
"Dialog"));
113 m_checkbox1_msg = msg2;
114 Create(parent,
id, caption, hint, pos, size, style, msg1, msg2);
116 androidDisableRotation();
120AcceptObjectDialog::~AcceptObjectDialog() {
122 delete m_CancelButton;
124 androidEnableRotation();
128bool AcceptObjectDialog::Create(wxWindow* parent, wxWindowID
id,
129 const wxString& caption,
const wxString& hint,
130 const wxPoint& pos,
const wxSize& size,
131 long style,
const wxString& msg1,
132 const wxString& msg2) {
133 SetExtraStyle(GetExtraStyle() | wxWS_EX_BLOCK_EVENTS);
134 wxDialog::Create(parent,
id, caption, pos, size, style);
136 CreateControls(hint, msg1, msg2);
137 GetSizer()->Fit(
this);
138 GetSizer()->SetSizeHints(
this);
144void AcceptObjectDialog::CreateControls(
const wxString& hint,
145 const wxString& msg1,
146 const wxString& msg2) {
149 wxBoxSizer* itemBoxSizer2 =
new wxBoxSizer(wxVERTICAL);
150 SetSizer(itemBoxSizer2);
153 itemBoxSizer2->AddSpacer(20);
155 premtext =
new wxStaticText(
this, -1, msg1);
156 itemBoxSizer2->Add(premtext, 0, wxEXPAND | wxALL, 10);
158 m_pCheck1 =
new wxCheckBox(
this, ID_STG_CHECK1, m_checkbox1_msg);
159 itemBoxSizer2->Add(m_pCheck1, 0, wxEXPAND | wxALL, 10);
161 if (!m_checkbox1_msg.Length()) m_pCheck1->Hide();
164 wxBoxSizer* itemBoxSizer16 =
new wxBoxSizer(wxHORIZONTAL);
165 itemBoxSizer2->Add(itemBoxSizer16, 0, wxALIGN_RIGHT | wxALL, 5);
167 m_CancelButton =
new wxButton(itemDialog1, ID_STG_CANCEL, _(
"Cancel"),
168 wxDefaultPosition, wxDefaultSize, 0);
169 itemBoxSizer16->Add(m_CancelButton, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
171 m_OKButton =
new wxButton(itemDialog1, ID_STG_OK,
"OK", wxDefaultPosition,
173 itemBoxSizer16->Add(m_OKButton, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
174 m_OKButton->SetDefault();
177void AcceptObjectDialog::SetMessage(
const wxString& msg) {
179 premtext->SetLabel(msg);
180 premtext->Refresh(
true);
184void AcceptObjectDialog::SetCheck1Message(
const wxString& msg) {
185 m_checkbox1_msg = msg;
186 m_pCheck1->SetLabel(msg);
188 GetSizer()->Fit(
this);
191void AcceptObjectDialog::OnOKClick(wxCommandEvent& event) {
193 SetReturnCode(ID_STG_OK);
196void AcceptObjectDialog::OnCancelClick(wxCommandEvent& event) {
197 EndModal(ID_STG_CANCEL);
199 androidDisableRotation();
204EVT_BUTTON(ID_STG_CANCEL, PINCreateDialog::OnCancelClick)
205EVT_BUTTON(ID_STG_OK, PINCreateDialog::OnOKClick)
210 m_CancelButton = NULL;
213 androidEnableRotation();
217PINCreateDialog::PINCreateDialog(wxWindow* parent, wxWindowID
id,
218 const wxString& caption,
const wxString& hint,
219 const wxPoint& pos,
const wxSize& size,
221 wxFont* pif = FontMgr::Get().
GetFont(_(
"Dialog"));
223 Create(parent,
id, caption, hint, pos, size, style);
225 androidDisableRotation();
229PINCreateDialog::~PINCreateDialog() {
231 delete m_CancelButton;
233 androidEnableRotation();
237wxDialog* PINCreateDialog::Initiate(
const std::string& msg,
238 const std::string& text1) {
240 wxTheApp->GetTopWindow(), wxID_ANY, _(
"OpenCPN Server Message"),
"",
241 wxDefaultPosition, wxDefaultSize, SYMBOL_STG_STYLE);
242 dlg->SetMessage(msg);
243 dlg->SetText1Message(text1);
248void PINCreateDialog::DeInit() {
253bool PINCreateDialog::Create(wxWindow* parent, wxWindowID
id,
254 const wxString& caption,
const wxString& hint,
255 const wxPoint& pos,
const wxSize& size,
257 SetExtraStyle(GetExtraStyle() | wxWS_EX_BLOCK_EVENTS);
258 wxDialog::Create(parent,
id, caption, pos, size, style);
260 CreateControls(hint);
261 GetSizer()->Fit(
this);
262 GetSizer()->SetSizeHints(
this);
268void PINCreateDialog::CreateControls(
const wxString& hint) {
271 wxBoxSizer* itemBoxSizer2 =
new wxBoxSizer(wxVERTICAL);
272 SetSizer(itemBoxSizer2);
275 itemBoxSizer2->AddSpacer(20);
277 premtext =
new wxStaticText(
278 this, -1,
"A loooooooooooooooooooooooooooooooooooooooooooooong line\n");
279 itemBoxSizer2->Add(premtext, 0, wxEXPAND | wxALL, 10);
281 m_pText1 =
new wxTextCtrl(
this, wxID_ANY, wxEmptyString, wxDefaultPosition,
282 wxDefaultSize, wxTE_READONLY | wxTE_CENTRE);
283 itemBoxSizer2->Add(m_pText1, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 5);
284 m_pText1->SetMinSize(wxSize(7 * GetCharWidth(), -1));
287 wxBoxSizer* itemBoxSizer16 =
new wxBoxSizer(wxHORIZONTAL);
288 itemBoxSizer2->Add(itemBoxSizer16, 0, wxALIGN_RIGHT | wxALL, 5);
290 m_CancelButton =
new wxButton(itemDialog1, ID_STG_CANCEL, _(
"Cancel"),
291 wxDefaultPosition, wxDefaultSize, 0);
292 itemBoxSizer16->Add(m_CancelButton, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
294 m_OKButton =
new wxButton(itemDialog1, ID_STG_OK,
"OK", wxDefaultPosition,
296 itemBoxSizer16->Add(m_OKButton, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
297 m_OKButton->SetDefault();
300void PINCreateDialog::SetMessage(
const wxString& msg) {
302 premtext->SetLabel(msg);
303 premtext->Refresh(
true);
307void PINCreateDialog::SetText1Message(
const wxString& msg) {
308 m_pText1->ChangeValue(msg);
310 GetSizer()->Fit(
this);
313void PINCreateDialog::OnOKClick(wxCommandEvent& event) { Close(); }
315void PINCreateDialog::OnCancelClick(wxCommandEvent& event) { Close(); }
"Accept Object" Dialog Definition
wxFont * GetFont(const wxString &TextElement, int requested_font_size=0)
Gets a font object for a UI element.
Callbacks for handling dialogs and RouteManager updates.
Returned status from RunAcceptObjectDlg.