20#include <wx/combobox.h>
22#include <wx/dynarray.h>
26#include <wx/stattext.h>
35#include "androidUTIL.h"
38static wxDialog* DisplayDlg(
const std::string& msg,
const std::string& txt1) {
40 wxTheApp->GetTopWindow(), wxID_ANY, _(
"OpenCPN Server Message"),
"",
41 wxDefaultPosition, wxDefaultSize, SYMBOL_STG_STYLE);
43 dlg->SetText1Message(txt1);
48static void UpdateRouteMgr() {
49 if (pRouteManagerDialog && pRouteManagerDialog->IsShown()) {
50 pRouteManagerDialog->UpdateTrkListCtrl();
51 pRouteManagerDialog->UpdateWptListCtrl();
52 pRouteManagerDialog->UpdateRouteListCtrl();
57 const wxString& check1msg) {
59 int result = dlg.ShowModal();
60 bool check1 = dlg.GetCheck1Value();
66 ctx.
run_pincode_dlg = [](
const std::string& msg,
const std::string& text1) {
67 return DisplayDlg(msg, text1);
71 const wxString& check1msg) {
72 return RunAcceptObjectDlg(msg, check1msg);
74 ctx.top_level_refresh = []() { wxTheApp->GetTopWindow()->Refresh(); };
79EVT_BUTTON(ID_STG_CANCEL, AcceptObjectDialog::OnCancelClick)
80EVT_BUTTON(ID_STG_OK, AcceptObjectDialog::OnOKClick)
85 m_CancelButton = NULL;
89AcceptObjectDialog::AcceptObjectDialog(wxWindow* parent,
90 const wxString& caption,
94 wxDefaultSize, SYMBOL_STG_STYLE, msg1, msg2) {}
96AcceptObjectDialog::AcceptObjectDialog(wxWindow* parent, wxWindowID
id,
97 const wxString& caption,
98 const wxString& hint,
const wxPoint& pos,
99 const wxSize& size,
long style,
100 const wxString& msg1,
101 const wxString& msg2) {
102 wxFont* pif = FontMgr::Get().
GetFont(_(
"Dialog"));
104 m_checkbox1_msg = msg2;
105 Create(parent,
id, caption, hint, pos, size, style, msg1, msg2);
107 androidDisableRotation();
111AcceptObjectDialog::~AcceptObjectDialog() {
113 delete m_CancelButton;
115 androidEnableRotation();
119bool AcceptObjectDialog::Create(wxWindow* parent, wxWindowID
id,
120 const wxString& caption,
const wxString& hint,
121 const wxPoint& pos,
const wxSize& size,
122 long style,
const wxString& msg1,
123 const wxString& msg2) {
124 SetExtraStyle(GetExtraStyle() | wxWS_EX_BLOCK_EVENTS);
125 wxDialog::Create(parent,
id, caption, pos, size, style);
127 CreateControls(hint, msg1, msg2);
128 GetSizer()->Fit(
this);
129 GetSizer()->SetSizeHints(
this);
135void AcceptObjectDialog::CreateControls(
const wxString& hint,
136 const wxString& msg1,
137 const wxString& msg2) {
140 wxBoxSizer* itemBoxSizer2 =
new wxBoxSizer(wxVERTICAL);
141 SetSizer(itemBoxSizer2);
144 itemBoxSizer2->AddSpacer(20);
146 premtext =
new wxStaticText(
this, -1, msg1);
147 itemBoxSizer2->Add(premtext, 0, wxEXPAND | wxALL, 10);
149 m_pCheck1 =
new wxCheckBox(
this, ID_STG_CHECK1, m_checkbox1_msg);
150 itemBoxSizer2->Add(m_pCheck1, 0, wxEXPAND | wxALL, 10);
152 if (!m_checkbox1_msg.Length()) m_pCheck1->Hide();
155 wxBoxSizer* itemBoxSizer16 =
new wxBoxSizer(wxHORIZONTAL);
156 itemBoxSizer2->Add(itemBoxSizer16, 0, wxALIGN_RIGHT | wxALL, 5);
158 m_CancelButton =
new wxButton(itemDialog1, ID_STG_CANCEL, _(
"Cancel"),
159 wxDefaultPosition, wxDefaultSize, 0);
160 itemBoxSizer16->Add(m_CancelButton, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
162 m_OKButton =
new wxButton(itemDialog1, ID_STG_OK,
"OK", wxDefaultPosition,
164 itemBoxSizer16->Add(m_OKButton, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
165 m_OKButton->SetDefault();
168void AcceptObjectDialog::SetMessage(
const wxString& msg) {
170 premtext->SetLabel(msg);
171 premtext->Refresh(
true);
175void AcceptObjectDialog::SetCheck1Message(
const wxString& msg) {
176 m_checkbox1_msg = msg;
177 m_pCheck1->SetLabel(msg);
179 GetSizer()->Fit(
this);
182void AcceptObjectDialog::OnOKClick(wxCommandEvent& event) {
184 SetReturnCode(ID_STG_OK);
187void AcceptObjectDialog::OnCancelClick(wxCommandEvent& event) {
188 EndModal(ID_STG_CANCEL);
190 androidDisableRotation();
195EVT_BUTTON(ID_STG_CANCEL, PINCreateDialog::OnCancelClick)
196EVT_BUTTON(ID_STG_OK, PINCreateDialog::OnOKClick)
201 m_CancelButton = NULL;
204 androidEnableRotation();
208PINCreateDialog::PINCreateDialog(wxWindow* parent, wxWindowID
id,
209 const wxString& caption,
const wxString& hint,
210 const wxPoint& pos,
const wxSize& size,
212 wxFont* pif = FontMgr::Get().
GetFont(_(
"Dialog"));
214 Create(parent,
id, caption, hint, pos, size, style);
216 androidDisableRotation();
220PINCreateDialog::~PINCreateDialog() {
222 delete m_CancelButton;
224 androidEnableRotation();
228wxDialog* PINCreateDialog::Initiate(
const std::string& msg,
229 const std::string& text1) {
231 wxTheApp->GetTopWindow(), wxID_ANY, _(
"OpenCPN Server Message"),
"",
232 wxDefaultPosition, wxDefaultSize, SYMBOL_STG_STYLE);
233 dlg->SetMessage(msg);
234 dlg->SetText1Message(text1);
239void PINCreateDialog::DeInit() {
244bool PINCreateDialog::Create(wxWindow* parent, wxWindowID
id,
245 const wxString& caption,
const wxString& hint,
246 const wxPoint& pos,
const wxSize& size,
248 SetExtraStyle(GetExtraStyle() | wxWS_EX_BLOCK_EVENTS);
249 wxDialog::Create(parent,
id, caption, pos, size, style);
251 CreateControls(hint);
252 GetSizer()->Fit(
this);
253 GetSizer()->SetSizeHints(
this);
259void PINCreateDialog::CreateControls(
const wxString& hint) {
262 wxBoxSizer* itemBoxSizer2 =
new wxBoxSizer(wxVERTICAL);
263 SetSizer(itemBoxSizer2);
266 itemBoxSizer2->AddSpacer(20);
268 premtext =
new wxStaticText(
269 this, -1,
"A loooooooooooooooooooooooooooooooooooooooooooooong line\n");
270 itemBoxSizer2->Add(premtext, 0, wxEXPAND | wxALL, 10);
272 m_pText1 =
new wxTextCtrl(
this, wxID_ANY,
"", wxDefaultPosition,
273 wxDefaultSize, wxTE_READONLY | wxTE_CENTRE);
274 itemBoxSizer2->Add(m_pText1, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 5);
275 m_pText1->SetMinSize(wxSize(7 * GetCharWidth(), -1));
278 wxBoxSizer* itemBoxSizer16 =
new wxBoxSizer(wxHORIZONTAL);
279 itemBoxSizer2->Add(itemBoxSizer16, 0, wxALIGN_RIGHT | wxALL, 5);
281 m_CancelButton =
new wxButton(itemDialog1, ID_STG_CANCEL, _(
"Cancel"),
282 wxDefaultPosition, wxDefaultSize, 0);
283 itemBoxSizer16->Add(m_CancelButton, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
285 m_OKButton =
new wxButton(itemDialog1, ID_STG_OK,
"OK", wxDefaultPosition,
287 itemBoxSizer16->Add(m_OKButton, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
288 m_OKButton->SetDefault();
291void PINCreateDialog::SetMessage(
const wxString& msg) {
293 premtext->SetLabel(msg);
294 premtext->Refresh(
true);
298void PINCreateDialog::SetText1Message(
const wxString& msg) {
299 m_pText1->ChangeValue(msg);
301 GetSizer()->Fit(
this);
304void PINCreateDialog::OnOKClick(wxCommandEvent& event) { Close(); }
306void 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.