2013-10-18 13:32:22 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2007 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
2017-07-20 14:06:41 +00:00
|
|
|
* Copyright (C) 1992-2017 KiCad Developers, see AUTHORS.txt for contributors.
|
2013-10-18 13:32:22 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
2009-01-19 19:08:42 +00:00
|
|
|
/**
|
2011-11-08 16:37:25 +00:00
|
|
|
* This file is part of the common library
|
2009-01-19 19:08:42 +00:00
|
|
|
* @file confirm.h
|
|
|
|
* @see common.h
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __INCLUDE__CONFIRM_H__
|
2016-01-18 05:17:56 +00:00
|
|
|
#define __INCLUDE__CONFIRM_H__
|
|
|
|
|
2018-03-02 15:52:45 +00:00
|
|
|
#include <wx/richmsgdlg.h>
|
2017-11-06 08:35:05 +00:00
|
|
|
#include <vector>
|
2009-01-19 19:08:42 +00:00
|
|
|
|
2018-02-21 17:26:45 +00:00
|
|
|
class wxCheckBox;
|
|
|
|
class wxStaticBitmap;
|
|
|
|
|
|
|
|
/**
|
2018-03-02 15:52:45 +00:00
|
|
|
* Helper class to create more flexible dialogs, including 'do not show again' checkbox handling.
|
2018-02-21 17:26:45 +00:00
|
|
|
*/
|
2018-03-02 15:52:45 +00:00
|
|
|
class KIDIALOG : public wxRichMessageDialog
|
2018-02-21 17:26:45 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
///> Dialog type. Selects appropriate icon and default dialog title
|
2018-02-22 19:46:43 +00:00
|
|
|
enum KD_TYPE { KD_NONE, KD_INFO, KD_QUESTION, KD_WARNING, KD_ERROR };
|
2018-02-21 17:26:45 +00:00
|
|
|
|
2018-03-02 15:52:45 +00:00
|
|
|
KIDIALOG( wxWindow* aParent, const wxString& aMessage, const wxString& aCaption, long aStyle = wxOK );
|
|
|
|
KIDIALOG( wxWindow* aParent, const wxString& aMessage, KD_TYPE aType, const wxString& aCaption = "" );
|
2018-02-21 17:26:45 +00:00
|
|
|
|
|
|
|
///> Shows the 'do not show again' checkbox
|
2018-03-02 15:52:45 +00:00
|
|
|
void DoNotShowCheckbox()
|
|
|
|
{
|
|
|
|
ShowCheckBox( _( "Do not show again" ), false );
|
|
|
|
}
|
2018-02-21 17:26:45 +00:00
|
|
|
|
|
|
|
///> Checks the 'do not show again' setting for the dialog
|
|
|
|
bool DoNotShowAgain() const;
|
|
|
|
void ForceShowAgain();
|
|
|
|
|
2018-03-02 15:52:45 +00:00
|
|
|
bool Show( bool aShow = true ) override;
|
2018-02-21 17:26:45 +00:00
|
|
|
int ShowModal() override;
|
|
|
|
|
|
|
|
protected:
|
2018-03-02 15:52:45 +00:00
|
|
|
///> Sets the dialog hash value
|
|
|
|
void setHash();
|
2018-02-21 17:26:45 +00:00
|
|
|
|
|
|
|
///> Unique identifier of the dialog
|
2018-03-02 15:52:45 +00:00
|
|
|
unsigned long m_hash;
|
2018-02-21 17:26:45 +00:00
|
|
|
|
2018-03-02 15:52:45 +00:00
|
|
|
// Helper functions for wxRichMessageDialog constructor
|
|
|
|
static wxString getCaption( KD_TYPE aType, const wxString& aCaption );
|
|
|
|
static long getStyle( KD_TYPE aType );
|
2018-02-21 17:26:45 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2012-03-08 17:47:23 +00:00
|
|
|
/**
|
|
|
|
* Function DisplayExitDialog
|
|
|
|
* displays a dialog with 3 buttons:
|
|
|
|
* Save and Exit
|
|
|
|
* Cancel
|
|
|
|
* Exit without save
|
|
|
|
*
|
|
|
|
* @param aParent = the parent window
|
|
|
|
* @param aMessage = the main message to put in dialog
|
|
|
|
* If empty, the standard message will be shown:
|
|
|
|
* Save the changes before closing?
|
|
|
|
* @return wxID_YES, wxID_CANCEL, wxID_NO.
|
|
|
|
*/
|
|
|
|
int DisplayExitDialog( wxWindow* aParent, const wxString& aMessage );
|
|
|
|
|
2009-01-19 19:08:42 +00:00
|
|
|
|
2011-11-08 16:37:25 +00:00
|
|
|
/**
|
|
|
|
* Function DisplayError
|
|
|
|
* displays an error or warning message box with \a aMessage.
|
|
|
|
*
|
|
|
|
* @warning Setting \a displaytime does not work. Do not use it.
|
|
|
|
*/
|
|
|
|
void DisplayError( wxWindow* parent, const wxString& aMessage, int displaytime = 0 );
|
2009-01-19 19:08:42 +00:00
|
|
|
|
2017-07-20 13:03:33 +00:00
|
|
|
/**
|
|
|
|
* Function DisplayErrorMessage
|
|
|
|
* displays an error message with \a aMessage
|
|
|
|
*
|
|
|
|
* @param aParent is the parent window
|
|
|
|
* @param aMessage is the message text to display
|
|
|
|
* @param aExtraInfo is extra data that can be optionally displayed in a collapsible pane
|
|
|
|
*/
|
2017-09-23 09:20:10 +00:00
|
|
|
void DisplayErrorMessage( wxWindow* aParent, const wxString& aMessage, const wxString& aExtraInfo = wxEmptyString );
|
2017-07-20 13:03:33 +00:00
|
|
|
|
|
|
|
|
2011-11-08 16:37:25 +00:00
|
|
|
/**
|
|
|
|
* Function DisplayInfoMessage
|
|
|
|
* displays an informational message box with \a aMessage.
|
|
|
|
*
|
2017-07-20 13:03:33 +00:00
|
|
|
* @param aParent is the parent window
|
|
|
|
* @param aMessage is the message text to display
|
|
|
|
* @param aExtraInfo is the extra data that can be optionally displayed in a collapsible pane
|
2011-11-08 16:37:25 +00:00
|
|
|
*/
|
2017-09-23 09:20:10 +00:00
|
|
|
void DisplayInfoMessage( wxWindow* parent, const wxString& aMessage, const wxString& aExtraInfo = wxEmptyString );
|
2009-01-19 19:08:42 +00:00
|
|
|
|
2011-11-08 16:37:25 +00:00
|
|
|
/**
|
|
|
|
* Function IsOK
|
2013-10-18 13:32:22 +00:00
|
|
|
* displays a yes/no dialog with \a aMessage and returns the user response.
|
|
|
|
*
|
|
|
|
* @param aParent is the parent window. NULL can be used if the parent is the top level window.
|
|
|
|
* @param aMessage is the message to display in the dialog box.
|
2011-11-08 16:37:25 +00:00
|
|
|
*
|
|
|
|
* @return True if user selected the yes button, otherwise false.
|
|
|
|
*/
|
2013-10-18 13:32:22 +00:00
|
|
|
bool IsOK( wxWindow* aParent, const wxString& aMessage );
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function YesNoCancelDialog
|
|
|
|
* displays a yes/no/cancel dialog with \a aMessage and returns the user response.
|
|
|
|
*
|
|
|
|
* @param aParent is the parent window. NULL can be used if the parent is the top level window.
|
|
|
|
* @param aPrimaryMessage is the message to display in the top part of the dialog box using
|
|
|
|
* a bold font.
|
|
|
|
* @param aSecondaryMessage is the message to display in the lower part of the dialog box
|
|
|
|
* using the default system UI font.
|
|
|
|
* @param aYesButtonText is the text to display in the yes button when defined.
|
|
|
|
* @param aNoButtonText is the text to display in the no button when defiend.
|
|
|
|
* @param aCancelButtonText is the text to display in the cancel button when defined.
|
|
|
|
*
|
|
|
|
* @return wxID_YES, wxID_NO, or wxID_CANCEL depending on the button the user selected.
|
|
|
|
*/
|
|
|
|
int YesNoCancelDialog( wxWindow* aParent,
|
|
|
|
const wxString& aPrimaryMessage,
|
|
|
|
const wxString& aSecondaryMessage,
|
|
|
|
const wxString& aYesButtonText = wxEmptyString,
|
|
|
|
const wxString& aNoButtonText = wxEmptyString,
|
|
|
|
const wxString& aCancelButtonText = wxEmptyString );
|
|
|
|
|
2011-11-08 16:37:25 +00:00
|
|
|
|
2011-09-06 07:02:18 +00:00
|
|
|
|
2017-11-06 08:35:05 +00:00
|
|
|
/**
|
|
|
|
* Displays a dialog with radioboxes asking the user to select an option.
|
2018-03-02 16:30:10 +00:00
|
|
|
*
|
2017-11-06 08:35:05 +00:00
|
|
|
* @param aParent is the parent window.
|
|
|
|
* @param aTitle is the dialog title.
|
|
|
|
* @param aMessage is a text label displayed in the first row of the dialog.
|
|
|
|
* @param aOptions is a vector of possible options.
|
|
|
|
* @return Index of the selected option or -1 when the dialog has been cancelled.
|
|
|
|
*/
|
|
|
|
int SelectSingleOption( wxWindow* aParent, const wxString& aTitle, const wxString& aMessage,
|
|
|
|
const wxArrayString& aOptions );
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Displays a dialog with checkboxes asking the user to select one or more options.
|
2018-03-02 16:54:03 +00:00
|
|
|
*
|
2017-11-06 08:35:05 +00:00
|
|
|
* @param aParent is the parent window.
|
|
|
|
* @param aTitle is the dialog title.
|
|
|
|
* @param aMessage is a text label displayed in the first row of the dialog.
|
|
|
|
* @param aOptions is a vector of possible options.
|
|
|
|
* @param aDefaultState is the default state for the checkboxes.
|
2018-03-02 16:54:03 +00:00
|
|
|
* @return Pair containing a boolean value equal to true when the selection has been confirmed and
|
|
|
|
* an integer array containing indices of the selected options.
|
2017-11-06 08:35:05 +00:00
|
|
|
*/
|
2018-03-02 16:54:03 +00:00
|
|
|
std::pair<bool, wxArrayInt> SelectMultipleOptions( wxWindow* aParent, const wxString& aTitle,
|
2017-11-06 08:35:05 +00:00
|
|
|
const wxString& aMessage, const wxArrayString& aOptions, bool aDefaultState = false );
|
|
|
|
|
2018-03-02 16:54:03 +00:00
|
|
|
std::pair<bool, wxArrayInt> SelectMultipleOptions( wxWindow* aParent, const wxString& aTitle,
|
2017-11-21 17:17:30 +00:00
|
|
|
const wxString& aMessage, const std::vector<std::string>& aOptions, bool aDefaultState = false );
|
|
|
|
|
2009-01-19 19:08:42 +00:00
|
|
|
#endif /* __INCLUDE__CONFIRM_H__ */
|