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-2017 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, long aStyle = wxOK );
51  KIDIALOG( wxWindow* aParent, const wxString& aMessage, KD_TYPE aType, const wxString& aCaption = "" );
52 
54  void DoNotShowCheckbox( wxString file, int line );
55 
57  bool DoNotShowAgain() const;
58  void ForceShowAgain();
59 
60  bool Show( bool aShow = true ) override;
61  int ShowModal() override;
62 
63 protected:
65  unsigned long m_hash;
66 
67  // Helper functions for wxRichMessageDialog constructor
68  static wxString getCaption( KD_TYPE aType, const wxString& aCaption );
69  static long getStyle( KD_TYPE aType );
70 };
71 
72 
84 bool HandleUnsavedChanges( wxWindow* aParent, const wxString& aMessage,
85  const std::function<bool()>& aSaveFunction );
86 
87 
98 int UnsavedChangesDialog( wxWindow* aParent, const wxString& aMessage, bool* aApplyToAll );
99 
100 
105 bool ConfirmRevertDialog( wxWindow* parent, const wxString& aMessage );
106 
107 
114 void DisplayError( wxWindow* parent, const wxString& aMessage, int displaytime = 0 );
115 
124 void DisplayErrorMessage( wxWindow* aParent, const wxString& aMessage, const wxString& aExtraInfo = wxEmptyString );
125 
126 
135 void DisplayInfoMessage( wxWindow* parent, const wxString& aMessage, const wxString& aExtraInfo = wxEmptyString );
136 
146 bool IsOK( wxWindow* aParent, const wxString& aMessage );
147 
161 int YesOrCancelDialog( wxWindow* aParent, const wxString& aWarning, const wxString& aMessage,
162  const wxString& aOKLabel, const wxString& aCancelLabel,
163  bool* aApplyToAll = nullptr );
164 
165 
166 
176 int SelectSingleOption( wxWindow* aParent, const wxString& aTitle, const wxString& aMessage,
177  const wxArrayString& aOptions );
178 
179 #endif /* __INCLUDE__CONFIRM_H__ */
bool ConfirmRevertDialog(wxWindow *parent, const wxString &aMessage)
Function ConfirmRevertDialog displays a confirmation for a revert action.
Definition: confirm.cpp:200
void DoNotShowCheckbox(wxString file, int line)
Shows the &#39;do not show again&#39; 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 &#39;do not show again&#39; checkbox handling...
Definition: confirm.h:44
void DisplayError(wxWindow *parent, const wxString &aMessage, int displaytime=0)
Function DisplayError displays an error or warning message box with aMessage.
Definition: confirm.cpp:245
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)
Function DisplayInfoMessage displays an informational message box with aMessage.
Definition: confirm.cpp:277
static wxString getCaption(KD_TYPE aType, const wxString &aCaption)
Definition: confirm.cpp:120
void DisplayErrorMessage(wxWindow *aParent, const wxString &aMessage, const wxString &aExtraInfo=wxEmptyString)
Function DisplayErrorMessage displays an error message with aMessage.
Definition: confirm.cpp:259
bool DoNotShowAgain() const
Checks the &#39;do not show again&#39; setting for the dialog
Definition: confirm.cpp:68
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 IsOK(wxWindow *aParent, const wxString &aMessage)
Function IsOK displays a yes/no dialog with aMessage and returns the user response.
Definition: confirm.cpp:295
KIDIALOG(wxWindow *aParent, const wxString &aMessage, const wxString &aCaption, long aStyle=wxOK)
Definition: confirm.cpp:45
int ShowModal() override
Definition: confirm.cpp:102
int YesOrCancelDialog(wxWindow *aParent, const wxString &aWarning, const wxString &aMessage, const wxString &aOKLabel, const wxString &aCancelLabel, bool *aApplyToAll=nullptr)
Function YesOrCancelDialog displays a warning dialog with aMessage and returns the user response...
Definition: confirm.cpp:226
bool HandleUnsavedChanges(wxWindow *aParent, const wxString &aMessage, const std::function< bool()> &aSaveFunction)
Function HandleUnsavedChanges displays a dialog with Save, Cancel and Discard Changes buttons...
Definition: confirm.cpp:213
int UnsavedChangesDialog(wxWindow *aParent, const wxString &aMessage, bool *aApplyToAll)
Function UnsavedChangesDialog a specialized version of HandleUnsavedChanges which handles an apply-to...
Definition: confirm.cpp:182
unsigned long m_hash
Unique identifier of the dialog
Definition: confirm.h:65