1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
// *****************************************************************************
// * This file is part of the FreeFileSync project. It is distributed under *
// * GNU General Public License: https://www.gnu.org/licenses/gpl-3.0 *
// * Copyright (C) Zenju (zenju AT freefilesync DOT org) - All Rights Reserved *
// *****************************************************************************
#ifndef POPUP_DLG_H_820780154723456
#define POPUP_DLG_H_820780154723456
#include <set>
#include <zen/zstring.h>
#include <wx/window.h>
#include <wx/bitmap.h>
#include <wx/string.h>
namespace zen
{
//parent window, optional: support correct dialog placement above parent on multiple monitor systems
//this module requires error, warning and info image files in Icons.zip, see <wx+/image_resources.h>
struct PopupDialogCfg;
enum class DialogInfoType
{
info,
warning,
error,
};
enum class ConfirmationButton3
{
cancel,
accept,
accept2,
decline,
};
enum class ConfirmationButton
{
cancel = static_cast<int>(ConfirmationButton3::cancel), //[!] Clang requires "static_cast"
accept = static_cast<int>(ConfirmationButton3::accept), //
};
enum class ConfirmationButton2
{
cancel = static_cast<int>(ConfirmationButton3::cancel),
accept = static_cast<int>(ConfirmationButton3::accept),
accept2 = static_cast<int>(ConfirmationButton3::accept2),
};
enum class QuestionButton2
{
cancel = static_cast<int>(ConfirmationButton3::cancel),
yes = static_cast<int>(ConfirmationButton3::accept),
no = static_cast<int>(ConfirmationButton3::decline),
};
void showNotificationDialog(wxWindow* parent, DialogInfoType type, const PopupDialogCfg& cfg);
ConfirmationButton showConfirmationDialog(wxWindow* parent, DialogInfoType type, const PopupDialogCfg& cfg, const wxString& labelAccept);
ConfirmationButton2 showConfirmationDialog(wxWindow* parent, DialogInfoType type, const PopupDialogCfg& cfg, const wxString& labelAccept, const wxString& labelAccept2);
ConfirmationButton3 showConfirmationDialog(wxWindow* parent, DialogInfoType type, const PopupDialogCfg& cfg, const wxString& labelAccept, const wxString& labelAccept2, const wxString& labelDecline);
QuestionButton2 showQuestionDialog (wxWindow* parent, DialogInfoType type, const PopupDialogCfg& cfg, const wxString& labelYes, const wxString& labelNo);
//----------------------------------------------------------------------------------------------------------------
class StandardPopupDialog;
struct PopupDialogCfg
{
PopupDialogCfg& setIcon (const wxImage& bmp ) { icon = bmp; return *this; }
PopupDialogCfg& setTitle (const wxString& label) { title = label; return *this; }
PopupDialogCfg& setMainInstructions (const wxString& label) { textMain = label; return *this; } //set at least one of these!
PopupDialogCfg& setDetailInstructions(const wxString& label) { textDetail = label; return *this; } //
PopupDialogCfg& disableButton(ConfirmationButton3 button) { disabledButtons.insert(button); return *this; }
PopupDialogCfg& remindWhenPending(const Zstring& soundFilePath) { soundFileAlertPending = soundFilePath; return *this; }
PopupDialogCfg& setCheckBox(bool& value, const wxString& label, ConfirmationButton3 disableWhenChecked = ConfirmationButton3::cancel)
{
checkBoxValue = &value;
checkBoxLabel = label;
buttonToDisableWhenChecked = disableWhenChecked;
return *this;
}
private:
friend class StandardPopupDialog;
wxImage icon;
wxString title;
wxString textMain;
wxString textDetail;
std::set<ConfirmationButton3> disabledButtons;
Zstring soundFileAlertPending;
bool* checkBoxValue = nullptr; //in/out
wxString checkBoxLabel;
ConfirmationButton3 buttonToDisableWhenChecked = ConfirmationButton3::cancel;
};
}
#endif //POPUP_DLG_H_820780154723456
|