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.

juce_NativeMessageBox.h 13KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2017 - ROLI Ltd.
  5. JUCE is an open source library subject to commercial or open-source
  6. licensing.
  7. By using JUCE, you agree to the terms of both the JUCE 5 End-User License
  8. Agreement and JUCE 5 Privacy Policy (both updated and effective as of the
  9. 27th April 2017).
  10. End User License Agreement: www.juce.com/juce-5-licence
  11. Privacy Policy: www.juce.com/juce-5-privacy-policy
  12. Or: You may also use this code under the terms of the GPL v3 (see
  13. www.gnu.org/licenses).
  14. JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
  15. EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
  16. DISCLAIMED.
  17. ==============================================================================
  18. */
  19. namespace juce
  20. {
  21. //==============================================================================
  22. /**
  23. This class contains some static methods for showing native alert windows.
  24. */
  25. class NativeMessageBox
  26. {
  27. public:
  28. /** Shows a dialog box that just has a message and a single 'ok' button to close it.
  29. The box is shown modally, and the method will block until the user has clicked its
  30. button (or pressed the escape or return keys).
  31. @param iconType the type of icon to show
  32. @param title the headline to show at the top of the box
  33. @param message a longer, more descriptive message to show underneath the title
  34. @param associatedComponent if this is non-null, it specifies the component that the
  35. alert window should be associated with. Depending on the look
  36. and feel, this might be used for positioning of the alert window.
  37. */
  38. #if JUCE_MODAL_LOOPS_PERMITTED
  39. static void JUCE_CALLTYPE showMessageBox (AlertWindow::AlertIconType iconType,
  40. const String& title,
  41. const String& message,
  42. Component* associatedComponent = nullptr);
  43. #endif
  44. /** Shows a dialog box that just has a message and a single 'ok' button to close it.
  45. The box will be displayed and placed into a modal state, but this method will return
  46. immediately, and the callback will be invoked later when the user dismisses the box.
  47. @param iconType the type of icon to show
  48. @param title the headline to show at the top of the box
  49. @param message a longer, more descriptive message to show underneath the title
  50. @param associatedComponent if this is non-null, it specifies the component that the
  51. alert window should be associated with. Depending on the look
  52. and feel, this might be used for positioning of the alert window.
  53. @param callback if this is non-null, the callback will receive a call to its
  54. modalStateFinished() when the box is dismissed. The callback object
  55. will be owned and deleted by the system, so make sure that it works
  56. safely and doesn't keep any references to objects that might be deleted
  57. before it gets called. You can use the ModalCallbackFunction to easily
  58. pass in a lambda for this parameter.
  59. @see ModalCallbackFunction
  60. */
  61. static void JUCE_CALLTYPE showMessageBoxAsync (AlertWindow::AlertIconType iconType,
  62. const String& title,
  63. const String& message,
  64. Component* associatedComponent = nullptr,
  65. ModalComponentManager::Callback* callback = nullptr);
  66. /** Shows a dialog box with two buttons.
  67. Ideal for ok/cancel or yes/no choices. The return key can also be used
  68. to trigger the first button, and the escape key for the second button.
  69. If the callback parameter is null, the box is shown modally, and the method will
  70. block until the user has clicked the button (or pressed the escape or return keys).
  71. If the callback parameter is non-null, the box will be displayed and placed into a
  72. modal state, but this method will return immediately, and the callback will be invoked
  73. later when the user dismisses the box.
  74. @param iconType the type of icon to show
  75. @param title the headline to show at the top of the box
  76. @param message a longer, more descriptive message to show underneath the title
  77. @param associatedComponent if this is non-null, it specifies the component that the
  78. alert window should be associated with. Depending on the look
  79. and feel, this might be used for positioning of the alert window.
  80. @param callback if this is non-null, the box will be launched asynchronously,
  81. returning immediately, and the callback will receive a call to its
  82. modalStateFinished() when the box is dismissed, with its parameter
  83. being 1 if the ok button was pressed, or 0 for cancel, The callback object
  84. will be owned and deleted by the system, so make sure that it works
  85. safely and doesn't keep any references to objects that might be deleted
  86. before it gets called. You can use the ModalCallbackFunction to easily
  87. pass in a lambda for this parameter.
  88. @returns true if button 1 was clicked, false if it was button 2. If the callback parameter
  89. is not null, the method always returns false, and the user's choice is delivered
  90. later by the callback.
  91. @see ModalCallbackFunction
  92. */
  93. static bool JUCE_CALLTYPE showOkCancelBox (AlertWindow::AlertIconType iconType,
  94. const String& title,
  95. const String& message,
  96. #if JUCE_MODAL_LOOPS_PERMITTED
  97. Component* associatedComponent = nullptr,
  98. ModalComponentManager::Callback* callback = nullptr);
  99. #else
  100. Component* associatedComponent,
  101. ModalComponentManager::Callback* callback);
  102. #endif
  103. /** Shows a dialog box with three buttons.
  104. Ideal for yes/no/cancel boxes.
  105. The escape key can be used to trigger the third button.
  106. If the callback parameter is null, the box is shown modally, and the method will
  107. block until the user has clicked the button (or pressed the escape or return keys).
  108. If the callback parameter is non-null, the box will be displayed and placed into a
  109. modal state, but this method will return immediately, and the callback will be invoked
  110. later when the user dismisses the box.
  111. @param iconType the type of icon to show
  112. @param title the headline to show at the top of the box
  113. @param message a longer, more descriptive message to show underneath the title
  114. @param associatedComponent if this is non-null, it specifies the component that the
  115. alert window should be associated with. Depending on the look
  116. and feel, this might be used for positioning of the alert window.
  117. @param callback if this is non-null, the box will be launched asynchronously,
  118. returning immediately, and the callback will receive a call to its
  119. modalStateFinished() when the box is dismissed, with its parameter
  120. being 1 if the "yes" button was pressed, 2 for the "no" button, or 0
  121. if it was cancelled, The callback object will be owned and deleted by the
  122. system, so make sure that it works safely and doesn't keep any references
  123. to objects that might be deleted before it gets called. You can use the
  124. ModalCallbackFunction to easily pass in a lambda for this parameter.
  125. @returns If the callback parameter has been set, this returns 0. Otherwise, it returns one
  126. of the following values:
  127. - 0 if 'cancel' was pressed
  128. - 1 if 'yes' was pressed
  129. - 2 if 'no' was pressed
  130. @see ModalCallbackFunction
  131. */
  132. static int JUCE_CALLTYPE showYesNoCancelBox (AlertWindow::AlertIconType iconType,
  133. const String& title,
  134. const String& message,
  135. #if JUCE_MODAL_LOOPS_PERMITTED
  136. Component* associatedComponent = nullptr,
  137. ModalComponentManager::Callback* callback = nullptr);
  138. #else
  139. Component* associatedComponent,
  140. ModalComponentManager::Callback* callback);
  141. #endif
  142. /** Shows a dialog box with two buttons.
  143. Ideal for yes/no boxes.
  144. The escape key can be used to trigger the no button.
  145. If the callback parameter is null, the box is shown modally, and the method will
  146. block until the user has clicked the button (or pressed the escape or return keys).
  147. If the callback parameter is non-null, the box will be displayed and placed into a
  148. modal state, but this method will return immediately, and the callback will be invoked
  149. later when the user dismisses the box.
  150. @param iconType the type of icon to show
  151. @param title the headline to show at the top of the box
  152. @param message a longer, more descriptive message to show underneath the title
  153. @param associatedComponent if this is non-null, it specifies the component that the
  154. alert window should be associated with. Depending on the look
  155. and feel, this might be used for positioning of the alert window.
  156. @param callback if this is non-null, the box will be launched asynchronously,
  157. returning immediately, and the callback will receive a call to its
  158. modalStateFinished() when the box is dismissed, with its parameter
  159. being 1 if the "yes" button was pressed or 0 for the "no" button was
  160. pressed. The callback object will be owned and deleted by the
  161. system, so make sure that it works safely and doesn't keep any references
  162. to objects that might be deleted before it gets called. You can use the
  163. ModalCallbackFunction to easily pass in a lambda for this parameter.
  164. @returns If the callback parameter has been set, this returns 0. Otherwise, it returns one
  165. of the following values:
  166. - 0 if 'no' was pressed
  167. - 1 if 'yes' was pressed
  168. @see ModalCallbackFunction
  169. */
  170. static int JUCE_CALLTYPE showYesNoBox (AlertWindow::AlertIconType iconType,
  171. const String& title,
  172. const String& message,
  173. #if JUCE_MODAL_LOOPS_PERMITTED
  174. Component* associatedComponent = nullptr,
  175. ModalComponentManager::Callback* callback = nullptr);
  176. #else
  177. Component* associatedComponent,
  178. ModalComponentManager::Callback* callback);
  179. #endif
  180. private:
  181. NativeMessageBox() JUCE_DELETED_FUNCTION;
  182. JUCE_DECLARE_NON_COPYABLE (NativeMessageBox)
  183. };
  184. } // namespace juce