KiCad PCB EDA Suite
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-2019 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 
31 #ifndef __INCLUDE__CONFIRM_H__
32 #define __INCLUDE__CONFIRM_H__
33 
34 #include <wx/richmsgdlg.h>
35 #include <vector>
36 #include <functional>
37 
38 class wxCheckBox;
39 class wxStaticBitmap;
40 
44 class KIDIALOG : public wxRichMessageDialog
45 {
46 public:
49 
50  KIDIALOG( wxWindow* aParent, const wxString& aMessage, const wxString& aCaption,
51  long aStyle = wxOK );
52  KIDIALOG( wxWindow* aParent, const wxString& aMessage, KD_TYPE aType,
53  const wxString& aCaption = "" );
54 
56  void DoNotShowCheckbox( wxString file, int line );
57 
59  bool DoNotShowAgain() const;
60  void ForceShowAgain();
61 
62  bool Show( bool aShow = true ) override;
63  int ShowModal() override;
64 
65 protected:
67  unsigned long m_hash;
68 
69  // Helper functions for wxRichMessageDialog constructor
70  static wxString getCaption( KD_TYPE aType, const wxString& aCaption );
71  static long getStyle( KD_TYPE aType );
72 };
73 
74 
85 bool HandleUnsavedChanges( wxWindow* aParent, const wxString& aMessage,
86  const std::function<bool()>& aSaveFunction );
87 
88 
98 int UnsavedChangesDialog( wxWindow* aParent, wxString aMessage, bool* aApplyToAll );
99 
100 int UnsavedChangesDialog( wxWindow* aParent, const wxString& aMessage );
101 
102 
106 bool ConfirmRevertDialog( wxWindow* parent, const wxString& aMessage );
107 
108 
114 void DisplayError( wxWindow* parent, const wxString& aMessage, int displaytime = 0 );
115 
123 void DisplayErrorMessage( wxWindow* aParent, const wxString& aMessage,
124  const wxString& aExtraInfo = wxEmptyString );
125 
126 
134 void DisplayInfoMessage( wxWindow* parent, const wxString& aMessage,
135  const wxString& aExtraInfo = wxEmptyString );
136 
145 bool IsOK( wxWindow* aParent, const wxString& aMessage );
146 
159 int OKOrCancelDialog( wxWindow* aParent, const wxString& aWarning, const wxString& aMessage,
160  const wxString& aOKLabel, const wxString& aCancelLabel, bool* aApplyToAll );
161 
162 
163 
173 int SelectSingleOption( wxWindow* aParent, const wxString& aTitle, const wxString& aMessage,
174  const wxArrayString& aOptions );
175 
176 #endif /* __INCLUDE__CONFIRM_H__ */
bool ConfirmRevertDialog(wxWindow *parent, const wxString &aMessage)
Display a confirmation dialog for a revert action.
Definition: confirm.cpp:197
void DoNotShowCheckbox(wxString file, int line)
Shows the 'do not show again' checkbox
Definition: confirm.cpp:60
int SelectSingleOption(wxWindow *aParent, const wxString &aTitle, const wxString &aMessage, const wxArrayString &aOptions)
Displays a dialog with radioboxes asking the user to select an option.
Definition: confirm.cpp:304
Helper class to create more flexible dialogs, including 'do not show again' checkbox handling.
Definition: confirm.h:44
void DisplayError(wxWindow *parent, const wxString &aMessage, int displaytime=0)
Display an error or warning message box with aMessage.
Definition: confirm.cpp:243
KD_TYPE
Dialog type. Selects appropriate icon and default dialog title
Definition: confirm.h:48
void DisplayInfoMessage(wxWindow *parent, const wxString &aMessage, const wxString &aExtraInfo=wxEmptyString)
Display an informational message box with aMessage.
Definition: confirm.cpp:276
int OKOrCancelDialog(wxWindow *aParent, const wxString &aWarning, const wxString &aMessage, const wxString &aOKLabel, const wxString &aCancelLabel, bool *aApplyToAll)
Displays a warning dialog with aMessage and returns the user response.
Definition: confirm.cpp:221
static wxString getCaption(KD_TYPE aType, const wxString &aCaption)
Definition: confirm.cpp:120
void DisplayErrorMessage(wxWindow *aParent, const wxString &aMessage, const wxString &aExtraInfo=wxEmptyString)
Display an error message with aMessage.
Definition: confirm.cpp:258
bool Show(bool aShow=true) override
Definition: confirm.cpp:80
static long getStyle(KD_TYPE aType)
Definition: confirm.cpp:138
void ForceShowAgain()
Definition: confirm.cpp:74
bool DoNotShowAgain() const
Checks the 'do not show again' setting for the dialog
Definition: confirm.cpp:68
bool IsOK(wxWindow *aParent, const wxString &aMessage)
Display a yes/no dialog with aMessage and returns the user response.
Definition: confirm.cpp:294
int UnsavedChangesDialog(wxWindow *aParent, wxString aMessage, bool *aApplyToAll)
A specialized version of HandleUnsavedChanges which handles an apply-to-all checkbox.
Definition: confirm.cpp:155
KIDIALOG(wxWindow *aParent, const wxString &aMessage, const wxString &aCaption, long aStyle=wxOK)
Definition: confirm.cpp:44
int ShowModal() override
Definition: confirm.cpp:102
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:208
unsigned long m_hash
Unique identifier of the dialog
Definition: confirm.h:67