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
35public:
39 virtual ~IAlertConfirmation() = default;
40
45 virtual void OnConfirm(const bool result) = 0;
46};
47
54class AlertDialog : public BaseDialog {
55public:
61 AlertDialog(wxWindow* parent, const std::string& title);
62
69 AlertDialog(wxWindow* parent, const std::string& title,
70 const std::string& action);
71
73
79
84 void SetTimer(int seconds);
85
90 void SetMessage(const std::string& msg);
91
96 void SetDefaultButton(int id);
97
102 void SetCancelLabel(const std::string& label);
103
108 int ShowModal() override;
109
114 static int GetConfirmation(wxWindow* parent, const std::string& title,
115 const std::string& action, const std::string& msg);
116
117private:
118 std::string m_action;
119 wxTimer m_timer;
120 IAlertConfirmation* m_listener;
121 void OnClick(wxCommandEvent& event);
122 void OnTimer(wxTimerEvent& evt);
123};
124
125#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 ~IAlertConfirmation()=default
Destroy the IAlertConfirmation object.
virtual void OnConfirm(const bool result)=0
Handle confirmation response.