OpenCPN Partial API docs
Loading...
Searching...
No Matches
n0183_ctx_factory.h
Go to the documentation of this file.
1/**************************************************************************
2 * Copyright (C) 2023 by Alec Leamas
3 * *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
8 * *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
13 * *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, see <https://www.gnu.org/licenses/>. *
16 **************************************************************************/
17
24// FIXME (leamas) use separate cpp file
25
26#ifndef _N0183_DLG_CTX_FACTORY_H__
27#define _N0183_DLG_CTX_FACTORY_H__
28
29#include <string>
30
31#include <wx/string.h>
32
33#include "gui_lib.h"
34#include "send_to_gps_dlg.h"
36
37static bool ConfirmOverwrite() {
38 int r =
39 OCPNMessageBox(NULL, _("Overwrite Garmin device route number 1?"),
40 _("OpenCPN Message"), wxOK | wxCANCEL | wxICON_QUESTION);
41 return r == wxID_OK;
42}
43
44static N0183DlgCtx GetDialogCtx(SendToGpsDlg* dialog) {
45 N0183DlgCtx dlg_ctx;
46 dlg_ctx.set_value = [dialog](int v) {
47 if (!dialog || !dialog->GetProgressGauge()) return;
48 dialog->GetProgressGauge()->SetValue(v);
49 dialog->GetProgressGauge()->Refresh();
50 dialog->GetProgressGauge()->Update();
51 };
52 dlg_ctx.set_range = [dialog](int r) {
53 if (!dialog || !dialog->GetProgressGauge()) return;
54 dialog->GetProgressGauge()->SetRange(r);
55 };
56 dlg_ctx.pulse = [dialog](void) {
57 if (!dialog || !dialog->GetProgressGauge()) return;
58 dialog->GetProgressGauge()->Pulse();
59 };
60 dlg_ctx.set_message = [dialog](const std::string& s) {
61 dialog->SetMessage(wxString(s));
62 };
63 dlg_ctx.confirm_overwrite = []() { return ConfirmOverwrite(); };
64 return dlg_ctx;
65}
66
67#endif // _N0183_DLG_CTX_FACTORY_H__
Dialog for sending routes/waypoints to a GPS device.
NMEA Data Multiplexer Object.
General purpose GUI support.
Send route/waypoint to GPS dialog.