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-2024 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 <kicommon.h>
36#include <wx/richmsgdlg.h>
37#include <vector>
38#include <functional>
39
40class wxCheckBox;
41class wxStaticBitmap;
42
46class KICOMMON_API KIDIALOG : public wxRichMessageDialog
47{
48public:
50 enum KD_TYPE { KD_NONE, KD_INFO, KD_QUESTION, KD_WARNING, KD_ERROR };
51
52 KIDIALOG( wxWindow* aParent, const wxString& aMessage, const wxString& aCaption,
53 long aStyle = wxOK );
54 KIDIALOG( wxWindow* aParent, const wxString& aMessage, KD_TYPE aType,
55 const wxString& aCaption = "" );
56
57 bool SetOKCancelLabels( const ButtonLabel& ok, const ButtonLabel& cancel ) override
58 {
59 m_cancelMeansCancel = false;
60 return wxRichMessageDialog::SetOKCancelLabels( ok, cancel );
61 }
62
64 void DoNotShowCheckbox( wxString file, int line );
65
67 bool DoNotShowAgain() const;
68 void ForceShowAgain();
69
70 bool Show( bool aShow = true ) override;
71 int ShowModal() override;
72
73protected:
74 // Helper functions for wxRichMessageDialog constructor
75 static wxString getCaption( KD_TYPE aType, const wxString& aCaption );
76 static long getStyle( KD_TYPE aType );
77
78protected:
79 unsigned long m_hash; // Unique id
80 bool m_cancelMeansCancel; // If the Cancel button is renamed then it should be
81 // saved by the DoNotShowAgain checkbox. If it's really
82 // a cancel then it should not.
83};
84
85
90KICOMMON_API bool AskOverrideLock( wxWindow* aParent, const wxString& aMessage );
91
92
103KICOMMON_API bool HandleUnsavedChanges( wxWindow* aParent, const wxString& aMessage,
104 const std::function<bool()>& aSaveFunction );
105
106
116KICOMMON_API int UnsavedChangesDialog( wxWindow* aParent, const wxString& aMessage,
117 bool* aApplyToAll );
118
119KICOMMON_API int UnsavedChangesDialog( wxWindow* aParent, const wxString& aMessage );
120
121
125KICOMMON_API bool ConfirmRevertDialog( wxWindow* parent, const wxString& aMessage );
126
127
133KICOMMON_API void DisplayError( wxWindow* aParent, const wxString& aText, int aDisplayTime = 0 );
134
142KICOMMON_API void DisplayErrorMessage( wxWindow* aParent, const wxString& aMessage,
143 const wxString& aExtraInfo = wxEmptyString );
144
145
153KICOMMON_API void DisplayInfoMessage( wxWindow* parent, const wxString& aMessage,
154 const wxString& aExtraInfo = wxEmptyString );
155
164KICOMMON_API bool IsOK( wxWindow* aParent, const wxString& aMessage );
165
180KICOMMON_API int OKOrCancelDialog( wxWindow* aParent, const wxString& aWarning,
181 const wxString& aMessage,
182 const wxString& aDetailedMessage = wxEmptyString,
183 const wxString& aOKLabel = wxEmptyString,
184 const wxString& aCancelLabel = wxEmptyString,
185 bool* aApplyToAll = nullptr );
186
187
188
198KICOMMON_API int SelectSingleOption( wxWindow* aParent, const wxString& aTitle,
199 const wxString& aMessage,
200 const wxArrayString& aOptions );
201
202#endif /* __INCLUDE__CONFIRM_H__ */
Helper class to create more flexible dialogs, including 'do not show again' checkbox handling.
Definition: confirm.h:47
KD_TYPE
< Dialog type. Selects appropriate icon and default dialog title
Definition: confirm.h:50
bool m_cancelMeansCancel
Definition: confirm.h:80
unsigned long m_hash
Definition: confirm.h:79
bool SetOKCancelLabels(const ButtonLabel &ok, const ButtonLabel &cancel) override
Shows the 'do not show again' checkbox.
Definition: confirm.h:57
KICOMMON_API void DisplayErrorMessage(wxWindow *aParent, const wxString &aMessage, const wxString &aExtraInfo=wxEmptyString)
Display an error message with aMessage.
Definition: confirm.cpp:305
KICOMMON_API void DisplayInfoMessage(wxWindow *parent, const wxString &aMessage, const wxString &aExtraInfo=wxEmptyString)
Display an informational message box with aMessage.
Definition: confirm.cpp:332
KICOMMON_API 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:389
KICOMMON_API bool AskOverrideLock(wxWindow *aParent, const wxString &aMessage)
Display a dialog indicating the file is already open, with an option to reset the lock.
Definition: confirm.cpp:155
KICOMMON_API bool ConfirmRevertDialog(wxWindow *parent, const wxString &aMessage)
Display a confirmation dialog for a revert action.
Definition: confirm.cpp:229
KICOMMON_API 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:240
KICOMMON_API void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime=0)
Display an error or warning message box with aMessage.
Definition: confirm.cpp:280
KICOMMON_API 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:253
KICOMMON_API bool IsOK(wxWindow *aParent, const wxString &aMessage)
Display a yes/no dialog with aMessage and returns the user response.
Definition: confirm.cpp:360
KICOMMON_API int UnsavedChangesDialog(wxWindow *aParent, const wxString &aMessage, bool *aApplyToAll)
A specialized version of HandleUnsavedChanges which handles an apply-to-all checkbox.
Definition: confirm.cpp:177
#define KICOMMON_API
Definition: kicommon.h:28