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"
48static wxDialog* DisplayDlg(
const std::string& msg,
const std::string& txt1) {
50 dynamic_cast<wxWindow*
>(gFrame), wxID_ANY, _(
"OpenCPN Server Message"),
51 "", wxDefaultPosition, wxDefaultSize, SYMBOL_STG_STYLE);
53 dlg->SetText1Message(txt1);
58static void UpdateRouteMgr() {
59 if (pRouteManagerDialog && pRouteManagerDialog->IsShown()) {
60 pRouteManagerDialog->UpdateTrkListCtrl();
61 pRouteManagerDialog->UpdateWptListCtrl();
62 pRouteManagerDialog->UpdateRouteListCtrl();
67 const wxString& check1msg) {
69 int result = dlg.ShowModal();
70 bool check1 = dlg.GetCheck1Value();
76 ctx.run_pincode_dlg = [](
const std::string& msg,
const std::string& text1) {
77 return DisplayDlg(msg, text1);
79 ctx.update_route_mgr = []() { UpdateRouteMgr(); };
80 ctx.run_accept_object_dlg = [](
const wxString& msg,
81 const wxString& check1msg) {
82 return RunAcceptObjectDlg(msg, check1msg);
84 ctx.top_level_refresh = []() {
dynamic_cast<wxWindow*
>(gFrame)->Refresh(); };
89EVT_BUTTON(ID_STG_CANCEL, AcceptObjectDialog::OnCancelClick)
90EVT_BUTTON(ID_STG_OK, AcceptObjectDialog::OnOKClick)
95 m_CancelButton = NULL;
99AcceptObjectDialog::AcceptObjectDialog(wxWindow* parent,
100 const wxString& caption,
101 const wxString& msg1,
104 wxDefaultSize, SYMBOL_STG_STYLE, msg1, msg2) {}
106AcceptObjectDialog::AcceptObjectDialog(wxWindow* parent, wxWindowID
id,
107 const wxString& caption,
108 const wxString& hint,
const wxPoint& pos,
109 const wxSize& size,
long style,
110 const wxString& msg1,
111 const wxString& msg2) {
112 wxFont* pif = FontMgr::Get().
GetFont(_(
"Dialog"));
114 m_checkbox1_msg = msg2;
115 Create(parent,
id, caption, hint, pos, size, style, msg1, msg2);
117 androidDisableRotation();
121AcceptObjectDialog::~AcceptObjectDialog() {
123 delete m_CancelButton;
125 androidEnableRotation();
129bool AcceptObjectDialog::Create(wxWindow* parent, wxWindowID
id,
130 const wxString& caption,
const wxString& hint,
131 const wxPoint& pos,
const wxSize& size,
132 long style,
const wxString& msg1,
133 const wxString& msg2) {
134 SetExtraStyle(GetExtraStyle() | wxWS_EX_BLOCK_EVENTS);
135 wxDialog::Create(parent,
id, caption, pos, size, style);
137 CreateControls(hint, msg1, msg2);
138 GetSizer()->Fit(
this);
139 GetSizer()->SetSizeHints(
this);
145void AcceptObjectDialog::CreateControls(
const wxString& hint,
146 const wxString& msg1,
147 const wxString& msg2) {
150 wxBoxSizer* itemBoxSizer2 =
new wxBoxSizer(wxVERTICAL);
151 SetSizer(itemBoxSizer2);
154 itemBoxSizer2->AddSpacer(20);
156 premtext =
new wxStaticText(
this, -1, msg1);
157 itemBoxSizer2->Add(premtext, 0, wxEXPAND | wxALL, 10);
159 m_pCheck1 =
new wxCheckBox(
this, ID_STG_CHECK1, m_checkbox1_msg);
160 itemBoxSizer2->Add(m_pCheck1, 0, wxEXPAND | wxALL, 10);
162 if (!m_checkbox1_msg.Length()) m_pCheck1->Hide();
165 wxBoxSizer* itemBoxSizer16 =
new wxBoxSizer(wxHORIZONTAL);
166 itemBoxSizer2->Add(itemBoxSizer16, 0, wxALIGN_RIGHT | wxALL, 5);
168 m_CancelButton =
new wxButton(itemDialog1, ID_STG_CANCEL, _(
"Cancel"),
169 wxDefaultPosition, wxDefaultSize, 0);
170 itemBoxSizer16->Add(m_CancelButton, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
172 m_OKButton =
new wxButton(itemDialog1, ID_STG_OK,
"OK", wxDefaultPosition,
174 itemBoxSizer16->Add(m_OKButton, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
175 m_OKButton->SetDefault();
178void AcceptObjectDialog::SetMessage(
const wxString& msg) {
180 premtext->SetLabel(msg);
181 premtext->Refresh(
true);
185void AcceptObjectDialog::SetCheck1Message(
const wxString& msg) {
186 m_checkbox1_msg = msg;
187 m_pCheck1->SetLabel(msg);
189 GetSizer()->Fit(
this);
192void AcceptObjectDialog::OnOKClick(wxCommandEvent& event) {
194 SetReturnCode(ID_STG_OK);
197void AcceptObjectDialog::OnCancelClick(wxCommandEvent& event) {
198 EndModal(ID_STG_CANCEL);
200 androidDisableRotation();
205EVT_BUTTON(ID_STG_CANCEL, PINCreateDialog::OnCancelClick)
206EVT_BUTTON(ID_STG_OK, PINCreateDialog::OnOKClick)
211 m_CancelButton = NULL;
214 androidEnableRotation();
218PINCreateDialog::PINCreateDialog(wxWindow* parent, wxWindowID
id,
219 const wxString& caption,
const wxString& hint,
220 const wxPoint& pos,
const wxSize& size,
222 wxFont* pif = FontMgr::Get().
GetFont(_(
"Dialog"));
224 Create(parent,
id, caption, hint, pos, size, style);
226 androidDisableRotation();
230PINCreateDialog::~PINCreateDialog() {
232 delete m_CancelButton;
234 androidEnableRotation();
238wxDialog* PINCreateDialog::Initiate(
const std::string& msg,
239 const std::string& text1) {
241 dynamic_cast<wxWindow*
>(gFrame), wxID_ANY, _(
"OpenCPN Server Message"),
242 "", wxDefaultPosition, wxDefaultSize, SYMBOL_STG_STYLE);
243 dlg->SetMessage(msg);
244 dlg->SetText1Message(text1);
249void PINCreateDialog::DeInit() {
254bool PINCreateDialog::Create(wxWindow* parent, wxWindowID
id,
255 const wxString& caption,
const wxString& hint,
256 const wxPoint& pos,
const wxSize& size,
258 SetExtraStyle(GetExtraStyle() | wxWS_EX_BLOCK_EVENTS);
259 wxDialog::Create(parent,
id, caption, pos, size, style);
261 CreateControls(hint);
262 GetSizer()->Fit(
this);
263 GetSizer()->SetSizeHints(
this);
269void PINCreateDialog::CreateControls(
const wxString& hint) {
272 wxBoxSizer* itemBoxSizer2 =
new wxBoxSizer(wxVERTICAL);
273 SetSizer(itemBoxSizer2);
276 itemBoxSizer2->AddSpacer(20);
278 premtext =
new wxStaticText(
279 this, -1,
"A loooooooooooooooooooooooooooooooooooooooooooooong line\n");
280 itemBoxSizer2->Add(premtext, 0, wxEXPAND | wxALL, 10);
282 m_pText1 =
new wxTextCtrl(
this, wxID_ANY, wxEmptyString, wxDefaultPosition,
283 wxDefaultSize, wxTE_READONLY | wxTE_CENTRE);
284 itemBoxSizer2->Add(m_pText1, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 5);
285 m_pText1->SetMinSize(wxSize(7 * GetCharWidth(), -1));
288 wxBoxSizer* itemBoxSizer16 =
new wxBoxSizer(wxHORIZONTAL);
289 itemBoxSizer2->Add(itemBoxSizer16, 0, wxALIGN_RIGHT | wxALL, 5);
291 m_CancelButton =
new wxButton(itemDialog1, ID_STG_CANCEL, _(
"Cancel"),
292 wxDefaultPosition, wxDefaultSize, 0);
293 itemBoxSizer16->Add(m_CancelButton, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
295 m_OKButton =
new wxButton(itemDialog1, ID_STG_OK,
"OK", wxDefaultPosition,
297 itemBoxSizer16->Add(m_OKButton, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
298 m_OKButton->SetDefault();
301void PINCreateDialog::SetMessage(
const wxString& msg) {
303 premtext->SetLabel(msg);
304 premtext->Refresh(
true);
308void PINCreateDialog::SetText1Message(
const wxString& msg) {
309 m_pText1->ChangeValue(msg);
311 GetSizer()->Fit(
this);
314void PINCreateDialog::OnOKClick(wxCommandEvent& event) { Close(); }
316void 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.