Audacity 3.2.0
AudacityDontAskAgainMessageDialog.cpp
Go to the documentation of this file.
1/**********************************************************************
2
3 Audacity: A Digital Audio Editor
4
5 AudacityDontAskAgainMessageDialog.cpp
6
7 A yes-no dialog with a don't-ask-again checkbox.
8
9**********************************************************************/
10
12
13#include <wx/checkbox.h>
14#include <wx/sizer.h>
15#include <wx/stattext.h>
16
17namespace
18{
19constexpr auto style = wxDEFAULT_DIALOG_STYLE | wxCENTRE;
20}
21
26
28 wxWindow* parent, const TranslatableString& caption,
29 const TranslatableString& message)
31 parent, wxID_ANY, caption, wxDefaultPosition, wxDefaultSize, style)
32{
33 wxStaticText* messageText =
34 new wxStaticText(this, wxID_ANY, message.Translation());
35
36 // Add a checkbox
37 wxCheckBox* checkBox =
38 new wxCheckBox(this, wxID_ANY, XO("Don't ask me again").Translation());
39
40 // Add sizers to arrange controls
41 wxBoxSizer* mainSizer = new wxBoxSizer(wxVERTICAL);
42 constexpr auto border = 10;
43 mainSizer->Add(messageText, 0, wxALL | wxALIGN_CENTER, border);
44
45 // This is where you specified wxOK | wxCANCEL buttons which you saw in your
46 // dialog wxOK had no effect because this flag isn't handled by the wxDialog,
47 // but even if it did, then you would likely got two rows of buttons
48 wxStdDialogButtonSizer* buttonSizer =
49 CreateStdDialogButtonSizer(wxYES | wxNO);
50
51 // Add checkbox to the sizer so that it shows first
52 buttonSizer->Insert(0, checkBox, 0, wxALL | wxALIGN_CENTER, border);
53 mainSizer->Add(buttonSizer, 0, wxALL | wxALIGN_CENTER, border);
54
55 SetSizerAndFit(mainSizer);
56 // Manually implement wxCENTRE flag behavior
57 if (style | wxCENTRE != 0)
58 CentreOnParent();
59
60 SetEscapeId(wxID_NO);
61}
62
64{
65 return ShowModal() == wxID_YES;
66}
67
69{
70 return mChecked;
71}
72
74{
75 mChecked = evt.IsChecked();
76}
77
79{
80 EndModal(wxID_NO);
81}
END_EVENT_TABLE()
XO("Cut/Copy/Paste")
Holds a msgid for the translation catalog; may also bind format arguments.