mirror of
https://github.com/cookiengineer/audacity
synced 2025-08-10 09:01:13 +02:00
... Should have no effect on generated code, except perhaps some slight faster virtual function calls. Mostly useful as documentation of design intent. Tried to mark every one of our classes that inherits from another, or is a base for others, or has abstract virtual functions, and a few others besides.
103 lines
2.5 KiB
C++
103 lines
2.5 KiB
C++
/**********************************************************************
|
|
|
|
Audacity: A Digital Audio Editor
|
|
|
|
Warning.cpp
|
|
|
|
Dominic Mazzoni
|
|
|
|
*******************************************************************//**
|
|
|
|
\class WarningDialog
|
|
\brief Gives a warning message, that can be dismissed, with crucially
|
|
the ability to not see similar warnings again for this session.
|
|
|
|
*//********************************************************************/
|
|
|
|
|
|
|
|
#include "../Audacity.h"
|
|
|
|
#include "Warning.h"
|
|
|
|
#include "../Prefs.h"
|
|
#include "../ShuttleGui.h"
|
|
|
|
#include <wx/artprov.h>
|
|
#include <wx/button.h>
|
|
#include <wx/checkbox.h>
|
|
#include <wx/dialog.h>
|
|
#include <wx/intl.h>
|
|
#include <wx/sizer.h>
|
|
#include <wx/stattext.h>
|
|
|
|
class WarningDialog final : public wxDialog
|
|
{
|
|
public:
|
|
// constructors and destructors
|
|
WarningDialog(wxWindow *parent,
|
|
wxString message,
|
|
bool showCancelButton);
|
|
|
|
private:
|
|
void OnOK(wxCommandEvent& event);
|
|
|
|
wxCheckBox *mCheckBox;
|
|
|
|
DECLARE_EVENT_TABLE()
|
|
};
|
|
|
|
BEGIN_EVENT_TABLE(WarningDialog, wxDialog)
|
|
EVT_BUTTON(wxID_OK, WarningDialog::OnOK)
|
|
END_EVENT_TABLE()
|
|
|
|
WarningDialog::WarningDialog(wxWindow *parent, wxString message, bool showCancelButton)
|
|
: wxDialog(parent, wxID_ANY, (wxString)_("Warning"),
|
|
wxDefaultPosition, wxDefaultSize,
|
|
(showCancelButton ? wxDEFAULT_DIALOG_STYLE : wxCAPTION | wxSYSTEM_MENU)) // Unlike wxDEFAULT_DIALOG_STYLE, no wxCLOSE_BOX.
|
|
{
|
|
SetName(GetTitle());
|
|
|
|
SetIcon(wxArtProvider::GetIcon(wxART_WARNING, wxART_MESSAGE_BOX));
|
|
ShuttleGui S(this, eIsCreating);
|
|
|
|
S.SetBorder(10);
|
|
S.StartVerticalLay(false);
|
|
{
|
|
S.AddUnits(message);
|
|
mCheckBox = S.AddCheckBox(_("Don't show this warning again"), wxT("false"));
|
|
}
|
|
|
|
S.SetBorder(0);
|
|
S.AddStandardButtons(showCancelButton ? eOkButton | eCancelButton : eOkButton);
|
|
|
|
Fit();
|
|
CentreOnParent();
|
|
}
|
|
|
|
void WarningDialog::OnOK(wxCommandEvent& WXUNUSED(event))
|
|
{
|
|
EndModal(mCheckBox->GetValue() ? wxID_NO : wxID_YES); // return YES, if message should be shown again
|
|
}
|
|
|
|
int ShowWarningDialog(wxWindow *parent,
|
|
const wxString &internalDialogName,
|
|
const wxString &message,
|
|
bool showCancelButton)
|
|
{
|
|
wxString key(wxT("/Warnings/") + internalDialogName);
|
|
if (!gPrefs->Read(key, (long) true)) {
|
|
return wxID_OK;
|
|
}
|
|
|
|
WarningDialog dlog(parent, message, showCancelButton);
|
|
|
|
int retCode = dlog.ShowModal();
|
|
if (retCode == wxID_CANCEL)
|
|
return retCode;
|
|
|
|
gPrefs->Write(key, (retCode == wxID_YES));
|
|
gPrefs->Flush();
|
|
return wxID_OK;
|
|
}
|