Audio plugin host https://kx.studio/carla
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.

165 lines
9.5KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2015 - ROLI Ltd.
  5. Permission is granted to use this software under the terms of either:
  6. a) the GPL v2 (or any later version)
  7. b) the Affero GPL v3
  8. Details of these licenses can be found at: www.gnu.org/licenses
  9. JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
  10. WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  11. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  12. ------------------------------------------------------------------------------
  13. To release a closed-source product which uses JUCE, commercial licenses are
  14. available: visit www.juce.com for more information.
  15. ==============================================================================
  16. */
  17. #ifndef JUCE_NATIVEMESSAGEBOX_H_INCLUDED
  18. #define JUCE_NATIVEMESSAGEBOX_H_INCLUDED
  19. //==============================================================================
  20. /**
  21. This class contains some static methods for showing native alert windows.
  22. */
  23. class NativeMessageBox
  24. {
  25. public:
  26. /** Shows a dialog box that just has a message and a single 'ok' button to close it.
  27. The box is shown modally, and the method will block until the user has clicked its
  28. button (or pressed the escape or return keys).
  29. @param iconType the type of icon to show
  30. @param title the headline to show at the top of the box
  31. @param message a longer, more descriptive message to show underneath the title
  32. @param associatedComponent if this is non-null, it specifies the component that the
  33. alert window should be associated with. Depending on the look
  34. and feel, this might be used for positioning of the alert window.
  35. */
  36. #if JUCE_MODAL_LOOPS_PERMITTED
  37. static void JUCE_CALLTYPE showMessageBox (AlertWindow::AlertIconType iconType,
  38. const String& title,
  39. const String& message,
  40. Component* associatedComponent = nullptr);
  41. #endif
  42. /** Shows a dialog box that just has a message and a single 'ok' button to close it.
  43. The box will be displayed and placed into a modal state, but this method will return
  44. immediately, and the callback will be invoked later when the user dismisses the box.
  45. @param iconType the type of icon to show
  46. @param title the headline to show at the top of the box
  47. @param message a longer, more descriptive message to show underneath the title
  48. @param associatedComponent if this is non-null, it specifies the component that the
  49. alert window should be associated with. Depending on the look
  50. and feel, this might be used for positioning of the alert window.
  51. @param callback if this is non-null, the callback will receive a call to its
  52. modalStateFinished() when the box is dismissed. The callback object
  53. will be owned and deleted by the system, so make sure that it works
  54. safely and doesn't keep any references to objects that might be deleted
  55. before it gets called.
  56. */
  57. static void JUCE_CALLTYPE showMessageBoxAsync (AlertWindow::AlertIconType iconType,
  58. const String& title,
  59. const String& message,
  60. Component* associatedComponent = nullptr,
  61. ModalComponentManager::Callback* callback = nullptr);
  62. /** Shows a dialog box with two buttons.
  63. Ideal for ok/cancel or yes/no choices. The return key can also be used
  64. to trigger the first button, and the escape key for the second button.
  65. If the callback parameter is null, the box is shown modally, and the method will
  66. block until the user has clicked the button (or pressed the escape or return keys).
  67. If the callback parameter is non-null, the box will be displayed and placed into a
  68. modal state, but this method will return immediately, and the callback will be invoked
  69. later when the user dismisses the box.
  70. @param iconType the type of icon to show
  71. @param title the headline to show at the top of the box
  72. @param message a longer, more descriptive message to show underneath the title
  73. @param associatedComponent if this is non-null, it specifies the component that the
  74. alert window should be associated with. Depending on the look
  75. and feel, this might be used for positioning of the alert window.
  76. @param callback if this is non-null, the box will be launched asynchronously,
  77. returning immediately, and the callback will receive a call to its
  78. modalStateFinished() when the box is dismissed, with its parameter
  79. being 1 if the ok button was pressed, or 0 for cancel, The callback object
  80. will be owned and deleted by the system, so make sure that it works
  81. safely and doesn't keep any references to objects that might be deleted
  82. before it gets called.
  83. @returns true if button 1 was clicked, false if it was button 2. If the callback parameter
  84. is not null, the method always returns false, and the user's choice is delivered
  85. later by the callback.
  86. */
  87. static bool JUCE_CALLTYPE showOkCancelBox (AlertWindow::AlertIconType iconType,
  88. const String& title,
  89. const String& message,
  90. #if JUCE_MODAL_LOOPS_PERMITTED
  91. Component* associatedComponent = nullptr,
  92. ModalComponentManager::Callback* callback = nullptr);
  93. #else
  94. Component* associatedComponent,
  95. ModalComponentManager::Callback* callback);
  96. #endif
  97. /** Shows a dialog box with three buttons.
  98. Ideal for yes/no/cancel boxes.
  99. The escape key can be used to trigger the third button.
  100. If the callback parameter is null, the box is shown modally, and the method will
  101. block until the user has clicked the button (or pressed the escape or return keys).
  102. If the callback parameter is non-null, the box will be displayed and placed into a
  103. modal state, but this method will return immediately, and the callback will be invoked
  104. later when the user dismisses the box.
  105. @param iconType the type of icon to show
  106. @param title the headline to show at the top of the box
  107. @param message a longer, more descriptive message to show underneath the title
  108. @param associatedComponent if this is non-null, it specifies the component that the
  109. alert window should be associated with. Depending on the look
  110. and feel, this might be used for positioning of the alert window.
  111. @param callback if this is non-null, the box will be launched asynchronously,
  112. returning immediately, and the callback will receive a call to its
  113. modalStateFinished() when the box is dismissed, with its parameter
  114. being 1 if the "yes" button was pressed, 2 for the "no" button, or 0
  115. if it was cancelled, The callback object will be owned and deleted by the
  116. system, so make sure that it works safely and doesn't keep any references
  117. to objects that might be deleted before it gets called.
  118. @returns If the callback parameter has been set, this returns 0. Otherwise, it returns one
  119. of the following values:
  120. - 0 if 'cancel' was pressed
  121. - 1 if 'yes' was pressed
  122. - 2 if 'no' was pressed
  123. */
  124. static int JUCE_CALLTYPE showYesNoCancelBox (AlertWindow::AlertIconType iconType,
  125. const String& title,
  126. const String& message,
  127. #if JUCE_MODAL_LOOPS_PERMITTED
  128. Component* associatedComponent = nullptr,
  129. ModalComponentManager::Callback* callback = nullptr);
  130. #else
  131. Component* associatedComponent,
  132. ModalComponentManager::Callback* callback);
  133. #endif
  134. private:
  135. NativeMessageBox() JUCE_DELETED_FUNCTION;
  136. JUCE_DECLARE_NON_COPYABLE (NativeMessageBox)
  137. };
  138. #endif // JUCE_NATIVEMESSAGEBOX_H_INCLUDED