KiCad PCB EDA Suite
Loading...
Searching...
No Matches
confirm.h
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2007 Jean-Pierre Charras, jp.charras at wanadoo.fr
5 * Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, you may find one here:
19 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20 * or you may search the http://www.gnu.org website for the version 2 license,
21 * or you may write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23 */
24
32#ifndef __INCLUDE__CONFIRM_H__
33#define __INCLUDE__CONFIRM_H__
34
35#include <wx/richmsgdlg.h>
36#include <vector>
37#include <functional>
38
39class wxCheckBox;
40class wxStaticBitmap;
41
45class KIDIALOG : public wxRichMessageDialog
46{
47public:
50
51 KIDIALOG( wxWindow* aParent, const wxString& aMessage, const wxString& aCaption,
52 long aStyle = wxOK );
53 KIDIALOG( wxWindow* aParent, const wxString& aMessage, KD_TYPE aType,
54 const wxString& aCaption = "" );
55
56 bool SetOKCancelLabels( const ButtonLabel& ok, const ButtonLabel& cancel ) override
57 {
58 m_cancelMeansCancel = false;
59 return wxRichMessageDialog::SetOKCancelLabels( ok, cancel );
60 }
61
63 void DoNotShowCheckbox( wxString file, int line );
64
66 bool DoNotShowAgain() const;
67 void ForceShowAgain();
68
69 bool Show( bool aShow = true ) override;
70 int ShowModal() override;
71
72protected:
73 // Helper functions for wxRichMessageDialog constructor
74 static wxString getCaption( KD_TYPE aType, const wxString& aCaption );
75 static long getStyle( KD_TYPE aType );
76
77protected:
78 unsigned long m_hash; // Unique id
79 bool m_cancelMeansCancel; // If the Cancel button is renamed then it should be
80 // saved by the DoNotShowAgain checkbox. If it's really
81 // a cancel then it should not.
82};
83
84
89bool OverrideLock( wxWindow* aParent, const wxString& aMessage );
90
91
102bool HandleUnsavedChanges( wxWindow* aParent, const wxString& aMessage,
103 const std::function<bool()>& aSaveFunction );
104
105
115int UnsavedChangesDialog( wxWindow* aParent, const wxString& aMessage, bool* aApplyToAll );
116
117int UnsavedChangesDialog( wxWindow* aParent, const wxString& aMessage );
118
119
123bool ConfirmRevertDialog( wxWindow* parent, const wxString& aMessage );
124
125
131void DisplayError( wxWindow* aParent, const wxString& aText, int aDisplayTime = 0 );
132
140void DisplayErrorMessage( wxWindow* aParent, const wxString& aMessage,
141 const wxString& aExtraInfo = wxEmptyString );
142
143
151void DisplayInfoMessage( wxWindow* parent, const wxString& aMessage,
152 const wxString& aExtraInfo = wxEmptyString );
153
162bool IsOK( wxWindow* aParent, const wxString& aMessage );
163
178int OKOrCancelDialog( wxWindow* aParent, const wxString& aWarning, const wxString& aMessage,
179 const wxString& aDetailedMessage = wxEmptyString,
180 const wxString& aOKLabel = wxEmptyString,
181 const wxString& aCancelLabel = wxEmptyString, bool* aApplyToAll = nullptr );
182
183
184
194int SelectSingleOption( wxWindow* aParent, const wxString& aTitle, const wxString& aMessage,
195 const wxArrayString& aOptions );
196
197#endif /* __INCLUDE__CONFIRM_H__ */
Helper class to create more flexible dialogs, including 'do not show again' checkbox handling.
Definition: confirm.h:46
KD_TYPE
< Dialog type. Selects appropriate icon and default dialog title
Definition: confirm.h:49
@ KD_INFO
Definition: confirm.h:49
@ KD_QUESTION
Definition: confirm.h:49
@ KD_ERROR
Definition: confirm.h:49
@ KD_NONE
Definition: confirm.h:49
@ KD_WARNING
Definition: confirm.h:49
void ForceShowAgain()
Definition: confirm.cpp:73
bool DoNotShowAgain() const
Definition: confirm.cpp:67
bool m_cancelMeansCancel
Definition: confirm.h:79
static long getStyle(KD_TYPE aType)
Definition: confirm.cpp:141
unsigned long m_hash
Definition: confirm.h:78
void DoNotShowCheckbox(wxString file, int line)
Checks the 'do not show again' setting for the dialog.
Definition: confirm.cpp:59
bool SetOKCancelLabels(const ButtonLabel &ok, const ButtonLabel &cancel) override
Shows the 'do not show again' checkbox.
Definition: confirm.h:56
int ShowModal() override
Definition: confirm.cpp:103
static wxString getCaption(KD_TYPE aType, const wxString &aCaption)
Definition: confirm.cpp:123
bool Show(bool aShow=true) override
Definition: confirm.cpp:79
int SelectSingleOption(wxWindow *aParent, const wxString &aTitle, const wxString &aMessage, const wxArrayString &aOptions)
Display a dialog with radioboxes asking the user to select an option.
Definition: confirm.cpp:392
int OKOrCancelDialog(wxWindow *aParent, const wxString &aWarning, const wxString &aMessage, const wxString &aDetailedMessage=wxEmptyString, const wxString &aOKLabel=wxEmptyString, const wxString &aCancelLabel=wxEmptyString, bool *aApplyToAll=nullptr)
Display a warning dialog with aMessage and returns the user response.
Definition: confirm.cpp:256
bool IsOK(wxWindow *aParent, const wxString &aMessage)
Display a yes/no dialog with aMessage and returns the user response.
Definition: confirm.cpp:363
void DisplayErrorMessage(wxWindow *aParent, const wxString &aMessage, const wxString &aExtraInfo=wxEmptyString)
Display an error message with aMessage.
Definition: confirm.cpp:308
bool OverrideLock(wxWindow *aParent, const wxString &aMessage)
Display a dialog indicating the file is already open, with an option to reset the lock.
Definition: confirm.cpp:158
void DisplayInfoMessage(wxWindow *parent, const wxString &aMessage, const wxString &aExtraInfo=wxEmptyString)
Display an informational message box with aMessage.
Definition: confirm.cpp:335
bool HandleUnsavedChanges(wxWindow *aParent, const wxString &aMessage, const std::function< bool()> &aSaveFunction)
Display a dialog with Save, Cancel and Discard Changes buttons.
Definition: confirm.cpp:243
bool ConfirmRevertDialog(wxWindow *parent, const wxString &aMessage)
Display a confirmation dialog for a revert action.
Definition: confirm.cpp:232
int UnsavedChangesDialog(wxWindow *aParent, const wxString &aMessage, bool *aApplyToAll)
A specialized version of HandleUnsavedChanges which handles an apply-to-all checkbox.
Definition: confirm.cpp:180
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime=0)
Display an error or warning message box with aMessage.
Definition: confirm.cpp:283