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/dialog.h>
35 #include <vector>
36 
37 class wxCheckBox;
38 class wxStaticBitmap;
39 
47 class KI_DIALOG : wxDialog
48 {
49 public:
52 
53  KI_DIALOG( wxWindow* aParent, const wxString& aMessage );
54 
56  KI_DIALOG& Type( KD_TYPE aType );
57 
59  KI_DIALOG& Title( const wxString& aTitle );
60 
62  KI_DIALOG& Buttons( long aButtons );
63 
66 
68  bool DoNotShowAgain() const;
69  void ForceShowAgain();
70 
71  int ShowModal() override;
72 
73 protected:
74  void onButtonClick( wxCommandEvent& aEvent );
75 
77  unsigned long hash() const;
78 
80  wxString m_message;
81 
84 
86  wxString m_customTitle;
87 
88  // Widgets
89  wxBoxSizer* m_sizerMain;
90  wxBoxSizer* m_sizerUpper;
91  wxBoxSizer* m_btnSizer;
92  wxCheckBox* m_cbDoNotShow;
93  wxStaticBitmap* m_icon;
94  std::vector<wxButton*> m_buttons;
95 };
96 
97 
111 int DisplayExitDialog( wxWindow* aParent, const wxString& aMessage );
112 
113 
120 void DisplayError( wxWindow* parent, const wxString& aMessage, int displaytime = 0 );
121 
130 void DisplayErrorMessage( wxWindow* aParent, const wxString& aMessage, const wxString& aExtraInfo = wxEmptyString );
131 
132 
141 void DisplayInfoMessage( wxWindow* parent, const wxString& aMessage, const wxString& aExtraInfo = wxEmptyString );
142 
152 bool IsOK( wxWindow* aParent, const wxString& aMessage );
153 
169 int YesNoCancelDialog( wxWindow* aParent,
170  const wxString& aPrimaryMessage,
171  const wxString& aSecondaryMessage,
172  const wxString& aYesButtonText = wxEmptyString,
173  const wxString& aNoButtonText = wxEmptyString,
174  const wxString& aCancelButtonText = wxEmptyString );
175 
176 
177 
186 int SelectSingleOption( wxWindow* aParent, const wxString& aTitle, const wxString& aMessage,
187  const wxArrayString& aOptions );
188 
198 std::pair<bool, std::vector<int>> SelectMultipleOptions( wxWindow* aParent, const wxString& aTitle,
199  const wxString& aMessage, const wxArrayString& aOptions, bool aDefaultState = false );
200 
201 std::pair<bool, std::vector<int>> SelectMultipleOptions( wxWindow* aParent, const wxString& aTitle,
202  const wxString& aMessage, const std::vector<std::string>& aOptions, bool aDefaultState = false );
203 
204 #endif /* __INCLUDE__CONFIRM_H__ */
bool DoNotShowAgain() const
Checks the &#39;do not show again&#39; setting for the dialog
Definition: confirm.cpp:160
KI_DIALOG & Type(KD_TYPE aType)
Sets the dialog type
Definition: confirm.cpp:68
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:340
wxCheckBox * m_cbDoNotShow
Definition: confirm.h:92
void DisplayError(wxWindow *parent, const wxString &aMessage, int displaytime=0)
Function DisplayError displays an error or warning message box with aMessage.
Definition: confirm.cpp:241
std::pair< bool, std::vector< int > > SelectMultipleOptions(wxWindow *aParent, const wxString &aTitle, const wxString &aMessage, const wxArrayString &aOptions, bool aDefaultState=false)
Displays a dialog with checkboxes asking the user to select one or more options.
Definition: confirm.cpp:475
void DisplayInfoMessage(wxWindow *parent, const wxString &aMessage, const wxString &aExtraInfo=wxEmptyString)
Function DisplayInfoMessage displays an informational message box with aMessage.
Definition: confirm.cpp:272
wxStaticBitmap * m_icon
Definition: confirm.h:93
int ShowModal() override
Definition: confirm.cpp:172
KD_TYPE
Dialog type. Selects appropriate icon and default dialog title
Definition: confirm.h:51
int DisplayExitDialog(wxWindow *aParent, const wxString &aMessage)
Function DisplayExitDialog displays a dialog with 3 buttons: Save and Exit Cancel Exit without save...
Definition: confirm.cpp:229
std::vector< wxButton * > m_buttons
Definition: confirm.h:94
unsigned long hash() const
Unique identifier of the dialog
Definition: confirm.cpp:198
KI_DIALOG & Buttons(long aButtons)
Selects the button set (combination of wxOK, wxCANCEL, wxYES, wxNO, wxAPPLY, wxCLOSE, wxHELP)
Definition: confirm.cpp:111
KI_DIALOG(wxWindow *aParent, const wxString &aMessage)
Definition: confirm.cpp:45
void DisplayErrorMessage(wxWindow *aParent, const wxString &aMessage, const wxString &aExtraInfo=wxEmptyString)
Function DisplayErrorMessage displays an error message with aMessage.
Definition: confirm.cpp:255
wxString m_message
Text message shown in the dialog
Definition: confirm.h:80
wxBoxSizer * m_sizerUpper
Definition: confirm.h:90
KI_DIALOG & DoNotShowCheckbox()
Shows the &#39;do not show again&#39; checkbox
Definition: confirm.cpp:148
Helper class to create more flexible dialogs, e.g:
Definition: confirm.h:47
bool IsOK(wxWindow *aParent, const wxString &aMessage)
Function IsOK displays a yes/no dialog with aMessage and returns the user response.
Definition: confirm.cpp:289
void ForceShowAgain()
Definition: confirm.cpp:166
wxString m_customTitle
Custom title requested, if any was requested
Definition: confirm.h:86
wxBoxSizer * m_sizerMain
Definition: confirm.h:89
KI_DIALOG & Title(const wxString &aTitle)
Sets the dialog title
Definition: confirm.cpp:103
int YesNoCancelDialog(wxWindow *aParent, const wxString &aPrimaryMessage, const wxString &aSecondaryMessage, const wxString &aYesButtonText=wxEmptyString, const wxString &aNoButtonText=wxEmptyString, const wxString &aCancelButtonText=wxEmptyString)
Function YesNoCancelDialog displays a yes/no/cancel dialog with aMessage and returns the user respons...
Definition: confirm.cpp:326
KD_TYPE m_type
Dialog type
Definition: confirm.h:83
void onButtonClick(wxCommandEvent &aEvent)
Definition: confirm.cpp:192
wxBoxSizer * m_btnSizer
Definition: confirm.h:91