22#include <wx/combobox.h>
24#include <wx/dynarray.h>
28#include <wx/stattext.h>
37#include "androidUTIL.h"
40static wxDialog* DisplayDlg(
const std::string& msg,
const std::string& txt1) {
42 wxTheApp->GetTopWindow(), wxID_ANY, _(
"OpenCPN Server Message"),
"",
43 wxDefaultPosition, wxDefaultSize, SYMBOL_STG_STYLE);
45 dlg->SetText1Message(txt1);
50static void UpdateRouteMgr() {
51 if (pRouteManagerDialog && pRouteManagerDialog->IsShown()) {
52 pRouteManagerDialog->UpdateTrkListCtrl();
53 pRouteManagerDialog->UpdateWptListCtrl();
54 pRouteManagerDialog->UpdateRouteListCtrl();
59 const wxString& check1msg) {
61 int result = dlg.ShowModal();
62 bool check1 = dlg.GetCheck1Value();
68 ctx.
run_pincode_dlg = [](
const std::string& msg,
const std::string& text1) {
69 return DisplayDlg(msg, text1);
73 const wxString& check1msg) {
74 return RunAcceptObjectDlg(msg, check1msg);
76 ctx.top_level_refresh = []() { wxTheApp->GetTopWindow()->Refresh(); };
81EVT_BUTTON(ID_STG_CANCEL, AcceptObjectDialog::OnCancelClick)
82EVT_BUTTON(ID_STG_OK, AcceptObjectDialog::OnOKClick)
87 m_CancelButton = NULL;
91AcceptObjectDialog::AcceptObjectDialog(wxWindow* parent,
92 const wxString& caption,
96 wxDefaultSize, SYMBOL_STG_STYLE, msg1, msg2) {}
98AcceptObjectDialog::AcceptObjectDialog(wxWindow* parent, wxWindowID
id,
99 const wxString& caption,
100 const wxString& hint,
const wxPoint& pos,
101 const wxSize& size,
long style,
102 const wxString& msg1,
103 const wxString& msg2) {
104 wxFont* pif = FontMgr::Get().
GetFont(_(
"Dialog"));
106 m_checkbox1_msg = msg2;
107 Create(parent,
id, caption, hint, pos, size, style, msg1, msg2);
109 androidDisableRotation();
113AcceptObjectDialog::~AcceptObjectDialog() {
115 delete m_CancelButton;
117 androidEnableRotation();
121bool AcceptObjectDialog::Create(wxWindow* parent, wxWindowID
id,
122 const wxString& caption,
const wxString& hint,
123 const wxPoint& pos,
const wxSize& size,
124 long style,
const wxString& msg1,
125 const wxString& msg2) {
126 SetExtraStyle(GetExtraStyle() | wxWS_EX_BLOCK_EVENTS);
127 wxDialog::Create(parent,
id, caption, pos, size, style);
129 CreateControls(hint, msg1, msg2);
130 GetSizer()->Fit(
this);
131 GetSizer()->SetSizeHints(
this);
137void AcceptObjectDialog::CreateControls(
const wxString& hint,
138 const wxString& msg1,
139 const wxString& msg2) {
142 wxBoxSizer* itemBoxSizer2 =
new wxBoxSizer(wxVERTICAL);
143 SetSizer(itemBoxSizer2);
146 itemBoxSizer2->AddSpacer(20);
148 premtext =
new wxStaticText(
this, -1, msg1);
149 itemBoxSizer2->Add(premtext, 0, wxEXPAND | wxALL, 10);
151 m_pCheck1 =
new wxCheckBox(
this, ID_STG_CHECK1, m_checkbox1_msg);
152 itemBoxSizer2->Add(m_pCheck1, 0, wxEXPAND | wxALL, 10);
154 if (!m_checkbox1_msg.Length()) m_pCheck1->Hide();
157 wxBoxSizer* itemBoxSizer16 =
new wxBoxSizer(wxHORIZONTAL);
158 itemBoxSizer2->Add(itemBoxSizer16, 0, wxALIGN_RIGHT | wxALL, 5);
160 m_CancelButton =
new wxButton(itemDialog1, ID_STG_CANCEL, _(
"Cancel"),
161 wxDefaultPosition, wxDefaultSize, 0);
162 itemBoxSizer16->Add(m_CancelButton, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
164 m_OKButton =
new wxButton(itemDialog1, ID_STG_OK,
"OK", wxDefaultPosition,
166 itemBoxSizer16->Add(m_OKButton, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
167 m_OKButton->SetDefault();
170void AcceptObjectDialog::SetMessage(
const wxString& msg) {
172 premtext->SetLabel(msg);
173 premtext->Refresh(
true);
177void AcceptObjectDialog::SetCheck1Message(
const wxString& msg) {
178 m_checkbox1_msg = msg;
179 m_pCheck1->SetLabel(msg);
181 GetSizer()->Fit(
this);
184void AcceptObjectDialog::OnOKClick(wxCommandEvent& event) {
186 SetReturnCode(ID_STG_OK);
189void AcceptObjectDialog::OnCancelClick(wxCommandEvent& event) {
190 EndModal(ID_STG_CANCEL);
192 androidDisableRotation();
197EVT_BUTTON(ID_STG_CANCEL, PINCreateDialog::OnCancelClick)
198EVT_BUTTON(ID_STG_OK, PINCreateDialog::OnOKClick)
203 m_CancelButton = NULL;
206 androidEnableRotation();
210PINCreateDialog::PINCreateDialog(wxWindow* parent, wxWindowID
id,
211 const wxString& caption,
const wxString& hint,
212 const wxPoint& pos,
const wxSize& size,
214 wxFont* pif = FontMgr::Get().
GetFont(_(
"Dialog"));
216 Create(parent,
id, caption, hint, pos, size, style);
218 androidDisableRotation();
222PINCreateDialog::~PINCreateDialog() {
224 delete m_CancelButton;
226 androidEnableRotation();
230wxDialog* PINCreateDialog::Initiate(
const std::string& msg,
231 const std::string& text1) {
233 wxTheApp->GetTopWindow(), wxID_ANY, _(
"OpenCPN Server Message"),
"",
234 wxDefaultPosition, wxDefaultSize, SYMBOL_STG_STYLE);
235 dlg->SetMessage(msg);
236 dlg->SetText1Message(text1);
241void PINCreateDialog::DeInit() {
246bool PINCreateDialog::Create(wxWindow* parent, wxWindowID
id,
247 const wxString& caption,
const wxString& hint,
248 const wxPoint& pos,
const wxSize& size,
250 SetExtraStyle(GetExtraStyle() | wxWS_EX_BLOCK_EVENTS);
251 wxDialog::Create(parent,
id, caption, pos, size, style);
253 CreateControls(hint);
254 GetSizer()->Fit(
this);
255 GetSizer()->SetSizeHints(
this);
261void PINCreateDialog::CreateControls(
const wxString& hint) {
264 wxBoxSizer* itemBoxSizer2 =
new wxBoxSizer(wxVERTICAL);
265 SetSizer(itemBoxSizer2);
268 itemBoxSizer2->AddSpacer(20);
270 premtext =
new wxStaticText(
271 this, -1,
"A loooooooooooooooooooooooooooooooooooooooooooooong line\n");
272 itemBoxSizer2->Add(premtext, 0, wxEXPAND | wxALL, 10);
274 m_pText1 =
new wxTextCtrl(
this, wxID_ANY,
"", wxDefaultPosition,
275 wxDefaultSize, wxTE_READONLY | wxTE_CENTRE);
276 itemBoxSizer2->Add(m_pText1, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 5);
277 m_pText1->SetMinSize(wxSize(7 * GetCharWidth(), -1));
280 wxBoxSizer* itemBoxSizer16 =
new wxBoxSizer(wxHORIZONTAL);
281 itemBoxSizer2->Add(itemBoxSizer16, 0, wxALIGN_RIGHT | wxALL, 5);
283 m_CancelButton =
new wxButton(itemDialog1, ID_STG_CANCEL, _(
"Cancel"),
284 wxDefaultPosition, wxDefaultSize, 0);
285 itemBoxSizer16->Add(m_CancelButton, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
287 m_OKButton =
new wxButton(itemDialog1, ID_STG_OK,
"OK", wxDefaultPosition,
289 itemBoxSizer16->Add(m_OKButton, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
290 m_OKButton->SetDefault();
293void PINCreateDialog::SetMessage(
const wxString& msg) {
295 premtext->SetLabel(msg);
296 premtext->Refresh(
true);
300void PINCreateDialog::SetText1Message(
const wxString& msg) {
301 m_pText1->ChangeValue(msg);
303 GetSizer()->Fit(
this);
306void PINCreateDialog::OnOKClick(wxCommandEvent& event) { Close(); }
308void PINCreateDialog::OnCancelClick(wxCommandEvent& event) { Close(); }
"Accept Object" Dialog Definition
wxFont * GetFont(const wxString &TextElement, int requested_font_size=0)
Get a font object for a UI element.
Callbacks for handling dialogs and RouteManager updates.
std::function< void(void)> update_route_mgr
Update Route manager after updates to underlying nav_object_database.
std::function< AcceptObjectDlgResult(const wxString &msg, const wxString &check1msg)> run_accept_object_dlg
Run the "Accept Object" dialog, returns value from ShowModal().
std::function< wxDialog *(const std::string &msg, const std::string &text1)> run_pincode_dlg
Run the "Server wants a pincode" dialog.
Returned status from RunAcceptObjectDlg.