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 
37 class wxCheckBox;
38 class wxStaticBitmap;
39 
43 class KIDIALOG : public wxRichMessageDialog
44 {
45 public:
48 
49  KIDIALOG( wxWindow* aParent, const wxString& aMessage, const wxString& aCaption, long aStyle = wxOK );
50  KIDIALOG( wxWindow* aParent, const wxString& aMessage, KD_TYPE aType, const wxString& aCaption = "" );
51 
54  {
55  ShowCheckBox( _( "Do not show again" ), false );
56  }
57 
59  bool DoNotShowAgain() const;
60  void ForceShowAgain();
61 
62  bool Show( bool aShow = true ) override;
63  int ShowModal() override;
64 
65 protected:
67  void setHash();
68 
70  unsigned long m_hash;
71 
72  // Helper functions for wxRichMessageDialog constructor
73  static wxString getCaption( KD_TYPE aType, const wxString& aCaption );
74  static long getStyle( KD_TYPE aType );
75 };
76 
77 
91 int DisplayExitDialog( wxWindow* aParent, const wxString& aMessage );
92 
93 
100 void DisplayError( wxWindow* parent, const wxString& aMessage, int displaytime = 0 );
101 
110 void DisplayErrorMessage( wxWindow* aParent, const wxString& aMessage, const wxString& aExtraInfo = wxEmptyString );
111 
112 
121 void DisplayInfoMessage( wxWindow* parent, const wxString& aMessage, const wxString& aExtraInfo = wxEmptyString );
122 
132 bool IsOK( wxWindow* aParent, const wxString& aMessage );
133 
149 int YesNoCancelDialog( wxWindow* aParent,
150  const wxString& aPrimaryMessage,
151  const wxString& aSecondaryMessage,
152  const wxString& aYesButtonText = wxEmptyString,
153  const wxString& aNoButtonText = wxEmptyString,
154  const wxString& aCancelButtonText = wxEmptyString );
155 
156 
157 
167 int SelectSingleOption( wxWindow* aParent, const wxString& aTitle, const wxString& aMessage,
168  const wxArrayString& aOptions );
169 
181 std::pair<bool, wxArrayInt> SelectMultipleOptions( wxWindow* aParent, const wxString& aTitle,
182  const wxString& aMessage, const wxArrayString& aOptions, bool aDefaultState = false );
183 
184 std::pair<bool, wxArrayInt> SelectMultipleOptions( wxWindow* aParent, const wxString& aTitle,
185  const wxString& aMessage, const std::vector<std::string>& aOptions, bool aDefaultState = false );
186 
187 #endif /* __INCLUDE__CONFIRM_H__ */
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:284
Helper class to create more flexible dialogs, including &#39;do not show again&#39; checkbox handling...
Definition: confirm.h:43
void DoNotShowCheckbox()
Shows the &#39;do not show again&#39; checkbox
Definition: confirm.h:53
void DisplayError(wxWindow *parent, const wxString &aMessage, int displaytime=0)
Function DisplayError displays an error or warning message box with aMessage.
Definition: confirm.cpp:185
KD_TYPE
Dialog type. Selects appropriate icon and default dialog title
Definition: confirm.h:47
void DisplayInfoMessage(wxWindow *parent, const wxString &aMessage, const wxString &aExtraInfo=wxEmptyString)
Function DisplayInfoMessage displays an informational message box with aMessage.
Definition: confirm.cpp:216
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:173
void setHash()
Sets the dialog hash value
Definition: confirm.cpp:109
static wxString getCaption(KD_TYPE aType, const wxString &aCaption)
Definition: confirm.cpp:117
void DisplayErrorMessage(wxWindow *aParent, const wxString &aMessage, const wxString &aExtraInfo=wxEmptyString)
Function DisplayErrorMessage displays an error message with aMessage.
Definition: confirm.cpp:199
bool DoNotShowAgain() const
Checks the &#39;do not show again&#39; setting for the dialog
Definition: confirm.cpp:61
bool Show(bool aShow=true) override
Definition: confirm.cpp:73
static long getStyle(KD_TYPE aType)
Definition: confirm.cpp:135
void ForceShowAgain()
Definition: confirm.cpp:67
bool IsOK(wxWindow *aParent, const wxString &aMessage)
Function IsOK displays a yes/no dialog with aMessage and returns the user response.
Definition: confirm.cpp:233
std::pair< bool, wxArrayInt > 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:349
KIDIALOG(wxWindow *aParent, const wxString &aMessage, const wxString &aCaption, long aStyle=wxOK)
Definition: confirm.cpp:45
int ShowModal() override
Definition: confirm.cpp:91
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:270
unsigned long m_hash
Unique identifier of the dialog
Definition: confirm.h:70