You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

161 lines
6.2 KiB

  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 The 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. /**
  25. * This file is part of the common library.
  26. *
  27. * @file confirm.h
  28. * @see common.h
  29. */
  30. #ifndef __INCLUDE__CONFIRM_H__
  31. #define __INCLUDE__CONFIRM_H__
  32. #include <kicommon.h>
  33. #include <wx/string.h>
  34. #include <wx/arrstr.h>
  35. //#include <wx/richmsgdlg.h>
  36. //#include <vector>
  37. //#include <functional>
  38. class wxWindow;
  39. /**
  40. * Display a dialog indicating the file is already open, with an option to reset the lock.
  41. * @return true if the lock was reset.
  42. */
  43. KICOMMON_API bool AskOverrideLock( wxWindow* aParent, const wxString& aMessage );
  44. /**
  45. * Display a dialog with Save, Cancel and Discard Changes buttons.
  46. *
  47. * @param aParent = the parent window
  48. * @param aMessage = the main message to put in dialog
  49. * @param aSaveFunction = a function to save changes, if requested. Must return true if
  50. * the save was successful and false otherwise (which will result
  51. * in HandleUnsavedChanges() returning wxID_CANCEL).
  52. * @return wxID_YES, wxID_CANCEL, wxID_NO.
  53. */
  54. KICOMMON_API bool HandleUnsavedChanges( wxWindow* aParent, const wxString& aMessage,
  55. const std::function<bool()>& aSaveFunction );
  56. /**
  57. * A specialized version of HandleUnsavedChanges which handles an apply-to-all checkbox.
  58. *
  59. * @param aParent = the parent window
  60. * @param aMessage = the main message to put in dialog
  61. * @param aApplyToAll = if non-null an "Apply to all" checkbox will be shown and it's value
  62. * written back to the bool.
  63. * @return wxID_YES, wxID_CANCEL, wxID_NO.
  64. */
  65. KICOMMON_API int UnsavedChangesDialog( wxWindow* aParent, const wxString& aMessage,
  66. bool* aApplyToAll );
  67. KICOMMON_API int UnsavedChangesDialog( wxWindow* aParent, const wxString& aMessage );
  68. /**
  69. * Display a confirmation dialog for a revert action.
  70. */
  71. KICOMMON_API bool ConfirmRevertDialog( wxWindow* parent, const wxString& aMessage );
  72. /**
  73. * Display an error or warning message box with \a aMessage.
  74. *
  75. * @warning Setting \a displaytime does not work. Do not use it.
  76. */
  77. KICOMMON_API void DisplayError( wxWindow* aParent, const wxString& aText, int aDisplayTime = 0 );
  78. /**
  79. * Display an error message with \a aMessage
  80. *
  81. * @param aParent is the parent window
  82. * @param aMessage is the message text to display
  83. * @param aExtraInfo is extra data that can be optionally displayed in a collapsible pane
  84. */
  85. KICOMMON_API void DisplayErrorMessage( wxWindow* aParent, const wxString& aMessage,
  86. const wxString& aExtraInfo = wxEmptyString );
  87. /**
  88. * Display an informational message box with \a aMessage.
  89. *
  90. * @param aParent is the parent window
  91. * @param aMessage is the message text to display
  92. * @param aExtraInfo is the extra data that can be optionally displayed in a collapsible pane
  93. */
  94. KICOMMON_API void DisplayInfoMessage( wxWindow* parent, const wxString& aMessage,
  95. const wxString& aExtraInfo = wxEmptyString );
  96. /**
  97. * Display a yes/no dialog with \a aMessage and returns the user response.
  98. *
  99. * @param aParent is the parent window. NULL can be used if the parent is the top level window.
  100. * @param aMessage is the message to display in the dialog box.
  101. *
  102. * @return True if user selected the yes button, otherwise false.
  103. */
  104. KICOMMON_API bool IsOK( wxWindow* aParent, const wxString& aMessage );
  105. /**
  106. * Display a warning dialog with \a aMessage and returns the user response.
  107. *
  108. * @param aParent is the parent window. NULL can be used if the parent is the top level window.
  109. * @param aWarning is the warning to display in the top part of the dialog box using a bold font.
  110. * @param aMessage is the message to display in the lower part of the dialog box using the
  111. * default system UI font.
  112. * @param aDetailedMessage is the message to display in the "Show detailed information" section.
  113. * Passing wxEmptyString will hide this portion of the dialog.
  114. * @param aOKLabel is the text to display in the OK button.
  115. * @param aCancelLabel is the text to display in the cancel button.
  116. *
  117. * @return wxID_OK or wxID_CANCEL depending on the button the user selected.
  118. */
  119. KICOMMON_API int OKOrCancelDialog( wxWindow* aParent, const wxString& aWarning,
  120. const wxString& aMessage,
  121. const wxString& aDetailedMessage = wxEmptyString,
  122. const wxString& aOKLabel = wxEmptyString,
  123. const wxString& aCancelLabel = wxEmptyString,
  124. bool* aApplyToAll = nullptr );
  125. /**
  126. * Display a dialog with radioboxes asking the user to select an option.
  127. *
  128. * @param aParent is the parent window.
  129. * @param aTitle is the dialog title.
  130. * @param aMessage is a text label displayed in the first row of the dialog.
  131. * @param aOptions is a vector of possible options.
  132. * @return Index of the selected option or -1 when the dialog has been canceled.
  133. */
  134. KICOMMON_API int SelectSingleOption( wxWindow* aParent, const wxString& aTitle,
  135. const wxString& aMessage,
  136. const wxArrayString& aOptions );
  137. #endif /* __INCLUDE__CONFIRM_H__ */