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
|
2024-02-02 17:47:34 +00:00
|
|
|
* Copyright (C) 1992-2024 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
|
|
|
/**
|
2021-01-25 12:42:36 +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__
|
|
|
|
|
2023-09-23 14:24:47 +00:00
|
|
|
#include <kicommon.h>
|
2024-04-27 19:57:24 +00:00
|
|
|
#include <wx/string.h>
|
|
|
|
#include <wx/arrstr.h>
|
|
|
|
//#include <wx/richmsgdlg.h>
|
|
|
|
//#include <vector>
|
|
|
|
//#include <functional>
|
2009-01-19 19:08:42 +00:00
|
|
|
|
2024-04-27 19:57:24 +00:00
|
|
|
class wxWindow;
|
2018-02-21 17:26:45 +00:00
|
|
|
|
|
|
|
|
2021-08-31 14:03:40 +00:00
|
|
|
/**
|
|
|
|
* Display a dialog indicating the file is already open, with an option to reset the lock.
|
|
|
|
* @return true if the lock was reset.
|
|
|
|
*/
|
2023-09-23 14:24:47 +00:00
|
|
|
KICOMMON_API bool AskOverrideLock( wxWindow* aParent, const wxString& aMessage );
|
2021-08-31 14:03:40 +00:00
|
|
|
|
|
|
|
|
2012-03-08 17:47:23 +00:00
|
|
|
/**
|
2019-06-15 16:05:33 +00:00
|
|
|
* Display a dialog with Save, Cancel and Discard Changes buttons.
|
2012-03-08 17:47:23 +00:00
|
|
|
*
|
|
|
|
* @param aParent = the parent window
|
|
|
|
* @param aMessage = the main message to put in dialog
|
2018-08-11 20:46:03 +00:00
|
|
|
* @param aSaveFunction = a function to save changes, if requested. Must return true if
|
|
|
|
* the save was successful and false otherwise (which will result
|
|
|
|
* in HandleUnsavedChanges() returning wxID_CANCEL).
|
|
|
|
* @return wxID_YES, wxID_CANCEL, wxID_NO.
|
|
|
|
*/
|
2023-09-23 14:24:47 +00:00
|
|
|
KICOMMON_API bool HandleUnsavedChanges( wxWindow* aParent, const wxString& aMessage,
|
|
|
|
const std::function<bool()>& aSaveFunction );
|
2018-08-11 20:46:03 +00:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
2019-06-15 16:05:33 +00:00
|
|
|
* A specialized version of HandleUnsavedChanges which handles an apply-to-all checkbox.
|
2018-08-11 20:46:03 +00:00
|
|
|
*
|
|
|
|
* @param aParent = the parent window
|
|
|
|
* @param aMessage = the main message to put in dialog
|
2018-08-01 23:06:12 +00:00
|
|
|
* @param aApplyToAll = if non-null an "Apply to all" checkbox will be shown and it's value
|
|
|
|
* written back to the bool.
|
2012-03-08 17:47:23 +00:00
|
|
|
* @return wxID_YES, wxID_CANCEL, wxID_NO.
|
|
|
|
*/
|
2023-09-23 14:24:47 +00:00
|
|
|
KICOMMON_API int UnsavedChangesDialog( wxWindow* aParent, const wxString& aMessage,
|
|
|
|
bool* aApplyToAll );
|
2012-03-08 17:47:23 +00:00
|
|
|
|
2023-09-23 14:24:47 +00:00
|
|
|
KICOMMON_API int UnsavedChangesDialog( wxWindow* aParent, const wxString& aMessage );
|
2019-06-15 16:05:33 +00:00
|
|
|
|
2009-01-19 19:08:42 +00:00
|
|
|
|
2018-10-03 21:44:17 +00:00
|
|
|
/**
|
2019-06-15 16:05:33 +00:00
|
|
|
* Display a confirmation dialog for a revert action.
|
2018-10-03 21:44:17 +00:00
|
|
|
*/
|
2023-09-23 14:24:47 +00:00
|
|
|
KICOMMON_API bool ConfirmRevertDialog( wxWindow* parent, const wxString& aMessage );
|
2018-10-03 21:44:17 +00:00
|
|
|
|
|
|
|
|
2011-11-08 16:37:25 +00:00
|
|
|
/**
|
2019-06-15 16:05:33 +00:00
|
|
|
* Display an error or warning message box with \a aMessage.
|
2011-11-08 16:37:25 +00:00
|
|
|
*
|
|
|
|
* @warning Setting \a displaytime does not work. Do not use it.
|
|
|
|
*/
|
2023-09-23 14:24:47 +00:00
|
|
|
KICOMMON_API void DisplayError( wxWindow* aParent, const wxString& aText, int aDisplayTime = 0 );
|
2009-01-19 19:08:42 +00:00
|
|
|
|
2017-07-20 13:03:33 +00:00
|
|
|
/**
|
2019-06-15 16:05:33 +00:00
|
|
|
* Display an error message 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 extra data that can be optionally displayed in a collapsible pane
|
|
|
|
*/
|
2023-09-23 14:24:47 +00:00
|
|
|
KICOMMON_API 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
|
|
|
/**
|
2019-06-15 16:05:33 +00:00
|
|
|
* Display an informational message box with \a aMessage.
|
2011-11-08 16:37:25 +00:00
|
|
|
*
|
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
|
|
|
*/
|
2023-09-23 14:24:47 +00:00
|
|
|
KICOMMON_API 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
|
|
|
/**
|
2019-06-15 16:05:33 +00:00
|
|
|
* Display a yes/no dialog with \a aMessage and returns the user response.
|
2013-10-18 13:32:22 +00:00
|
|
|
*
|
|
|
|
* @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.
|
|
|
|
*/
|
2023-09-23 14:24:47 +00:00
|
|
|
KICOMMON_API bool IsOK( wxWindow* aParent, const wxString& aMessage );
|
2013-10-18 13:32:22 +00:00
|
|
|
|
|
|
|
/**
|
2021-01-25 12:42:36 +00:00
|
|
|
* Display a warning dialog with \a aMessage and returns the user response.
|
2013-10-18 13:32:22 +00:00
|
|
|
*
|
|
|
|
* @param aParent is the parent window. NULL can be used if the parent is the top level window.
|
2018-08-01 23:06:12 +00:00
|
|
|
* @param aWarning is the warning to display in the top part of the dialog box using a bold font.
|
|
|
|
* @param aMessage is the message to display in the lower part of the dialog box using the
|
|
|
|
* default system UI font.
|
2020-02-14 19:07:27 +00:00
|
|
|
* @param aDetailedMessage is the message to display in the "Show detailed information" section.
|
|
|
|
* Passing wxEmptyString will hide this portion of the dialog.
|
2018-08-01 23:06:12 +00:00
|
|
|
* @param aOKLabel is the text to display in the OK button.
|
|
|
|
* @param aCancelLabel is the text to display in the cancel button.
|
2013-10-18 13:32:22 +00:00
|
|
|
*
|
2019-06-15 16:05:33 +00:00
|
|
|
* @return wxID_OK or wxID_CANCEL depending on the button the user selected.
|
2013-10-18 13:32:22 +00:00
|
|
|
*/
|
2023-09-23 14:24:47 +00:00
|
|
|
KICOMMON_API int OKOrCancelDialog( wxWindow* aParent, const wxString& aWarning,
|
|
|
|
const wxString& aMessage,
|
|
|
|
const wxString& aDetailedMessage = wxEmptyString,
|
|
|
|
const wxString& aOKLabel = wxEmptyString,
|
2024-02-02 17:47:34 +00:00
|
|
|
const wxString& aCancelLabel = wxEmptyString,
|
|
|
|
bool* aApplyToAll = nullptr );
|
2013-10-18 13:32:22 +00:00
|
|
|
|
2011-11-08 16:37:25 +00:00
|
|
|
|
2011-09-06 07:02:18 +00:00
|
|
|
|
2017-11-06 08:35:05 +00:00
|
|
|
/**
|
2021-01-25 12:42:36 +00:00
|
|
|
* Display 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.
|
2019-06-15 16:05:33 +00:00
|
|
|
* @return Index of the selected option or -1 when the dialog has been canceled.
|
2017-11-06 08:35:05 +00:00
|
|
|
*/
|
2023-09-23 14:24:47 +00:00
|
|
|
KICOMMON_API int SelectSingleOption( wxWindow* aParent, const wxString& aTitle,
|
|
|
|
const wxString& aMessage,
|
|
|
|
const wxArrayString& aOptions );
|
2017-11-06 08:35:05 +00:00
|
|
|
|
2009-01-19 19:08:42 +00:00
|
|
|
#endif /* __INCLUDE__CONFIRM_H__ */
|