OpenCPN Partial API docs
Loading...
Searching...
No Matches
dialog_alert.h
1/***************************************************************************
2 * Copyright (C) 2025 by NoCodeHummel *
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, write to the *
16 * Free Software Foundation, Inc., *
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
18 ***************************************************************************
19 */
20#ifndef DIALOG_ALERT_H
21#define DIALOG_ALERT_H
22
23#include <string>
24#include <wx/timer.h>
25
26#include "dialog_base.h"
27#include "dialog_footer.h"
28
33public:
38 virtual void OnConfirm(const bool result) = 0;
39};
40
47class AlertDialog : public BaseDialog {
48public:
54 AlertDialog(wxWindow* parent, const std::string& title);
55
62 AlertDialog(wxWindow* parent, const std::string& title,
63 const std::string& action);
64
66
72
77 void SetTimer(int seconds);
78
83 void SetMessage(const std::string& msg);
84
89 void SetDefaultButton(int id);
90
95 void SetCancelLabel(const std::string& label);
96
101 int ShowModal() override;
102
107 static int GetConfirmation(wxWindow* parent, const std::string& title,
108 const std::string& action, const std::string& msg);
109
110private:
111 std::string m_action;
112 wxTimer m_timer;
113 IAlertConfirmation* m_listener;
114 void OnClick(wxCommandEvent& event);
115 void OnTimer(wxTimerEvent& evt);
116};
117
118#endif // DIALOG_ALERT_H
A modal message dialog with confirmation button and cancel button.
void SetListener(IAlertConfirmation *listener)
Listen for response.
int ShowModal() override
Show dialog and return response.
void SetMessage(const std::string &msg)
Set alert message.
AlertDialog(wxWindow *parent, const std::string &title)
Alert dialog with close button.
static int GetConfirmation(wxWindow *parent, const std::string &title, const std::string &action, const std::string &msg)
Helper that returns the dialog response.
void SetDefaultButton(int id)
Set default button (for enter).
void SetTimer(int seconds)
Activate timer.
void SetCancelLabel(const std::string &label)
Overwrite cancel button label.
AlertDialog(wxWindow *parent, const std::string &title, const std::string &action)
Alert dialog with labelled confirmation button and cancel.
Dialog layout with content sizer.
Definition dialog_base.h:33
Alert confirmation listener interface.
virtual void OnConfirm(const bool result)=0
Handle confirmation response.