The JUCE cross-platform C++ framework, with DISTRHO/KXStudio specific changes
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.

160 lines
9.4KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2013 - Raw Material Software 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_JUCEHEADER__
  18. #define __JUCE_NATIVEMESSAGEBOX_JUCEHEADER__
  19. /**
  20. This class contains some static methods for showing native alert windows.
  21. */
  22. class NativeMessageBox
  23. {
  24. public:
  25. /** Shows a dialog box that just has a message and a single 'ok' button to close it.
  26. The box is shown modally, and the method will block until the user has clicked its
  27. button (or pressed the escape or return keys).
  28. @param iconType the type of icon to show
  29. @param title the headline to show at the top of the box
  30. @param message a longer, more descriptive message to show underneath the title
  31. @param associatedComponent if this is non-null, it specifies the component that the
  32. alert window should be associated with. Depending on the look
  33. and feel, this might be used for positioning of the alert window.
  34. */
  35. #if JUCE_MODAL_LOOPS_PERMITTED
  36. static void JUCE_CALLTYPE showMessageBox (AlertWindow::AlertIconType iconType,
  37. const String& title,
  38. const String& message,
  39. Component* associatedComponent = nullptr);
  40. #endif
  41. /** Shows a dialog box that just has a message and a single 'ok' button to close it.
  42. The box will be displayed and placed into a modal state, but this method will return
  43. immediately, and the callback will be invoked later when the user dismisses the box.
  44. @param iconType the type of icon to show
  45. @param title the headline to show at the top of the box
  46. @param message a longer, more descriptive message to show underneath the title
  47. @param associatedComponent if this is non-null, it specifies the component that the
  48. alert window should be associated with. Depending on the look
  49. and feel, this might be used for positioning of the alert window.
  50. @param callback if this is non-null, the callback will receive a call to its
  51. modalStateFinished() when the box is dismissed. The callback object
  52. will be owned and deleted by the system, so make sure that it works
  53. safely and doesn't keep any references to objects that might be deleted
  54. before it gets called.
  55. */
  56. static void JUCE_CALLTYPE showMessageBoxAsync (AlertWindow::AlertIconType iconType,
  57. const String& title,
  58. const String& message,
  59. Component* associatedComponent = nullptr,
  60. ModalComponentManager::Callback* callback = nullptr);
  61. /** Shows a dialog box with two buttons.
  62. Ideal for ok/cancel or yes/no choices. The return key can also be used
  63. to trigger the first button, and the escape key for the second button.
  64. If the callback parameter is null, the box is shown modally, and the method will
  65. block until the user has clicked the button (or pressed the escape or return keys).
  66. If the callback parameter is non-null, the box will be displayed and placed into a
  67. modal state, but this method will return immediately, and the callback will be invoked
  68. later when the user dismisses the box.
  69. @param iconType the type of icon to show
  70. @param title the headline to show at the top of the box
  71. @param message a longer, more descriptive message to show underneath the title
  72. @param associatedComponent if this is non-null, it specifies the component that the
  73. alert window should be associated with. Depending on the look
  74. and feel, this might be used for positioning of the alert window.
  75. @param callback if this is non-null, the box will be launched asynchronously,
  76. returning immediately, and the callback will receive a call to its
  77. modalStateFinished() when the box is dismissed, with its parameter
  78. being 1 if the ok button was pressed, or 0 for cancel, The callback object
  79. will be owned and deleted by the system, so make sure that it works
  80. safely and doesn't keep any references to objects that might be deleted
  81. before it gets called.
  82. @returns true if button 1 was clicked, false if it was button 2. If the callback parameter
  83. is not null, the method always returns false, and the user's choice is delivered
  84. later by the callback.
  85. */
  86. static bool JUCE_CALLTYPE showOkCancelBox (AlertWindow::AlertIconType iconType,
  87. const String& title,
  88. const String& message,
  89. #if JUCE_MODAL_LOOPS_PERMITTED
  90. Component* associatedComponent = nullptr,
  91. ModalComponentManager::Callback* callback = nullptr);
  92. #else
  93. Component* associatedComponent,
  94. ModalComponentManager::Callback* callback);
  95. #endif
  96. /** Shows a dialog box with three buttons.
  97. Ideal for yes/no/cancel boxes.
  98. The escape key can be used to trigger the third button.
  99. If the callback parameter is null, the box is shown modally, and the method will
  100. block until the user has clicked the button (or pressed the escape or return keys).
  101. If the callback parameter is non-null, the box will be displayed and placed into a
  102. modal state, but this method will return immediately, and the callback will be invoked
  103. later when the user dismisses the box.
  104. @param iconType the type of icon to show
  105. @param title the headline to show at the top of the box
  106. @param message a longer, more descriptive message to show underneath the title
  107. @param associatedComponent if this is non-null, it specifies the component that the
  108. alert window should be associated with. Depending on the look
  109. and feel, this might be used for positioning of the alert window.
  110. @param callback if this is non-null, the box will be launched asynchronously,
  111. returning immediately, and the callback will receive a call to its
  112. modalStateFinished() when the box is dismissed, with its parameter
  113. being 1 if the "yes" button was pressed, 2 for the "no" button, or 0
  114. if it was cancelled, The callback object will be owned and deleted by the
  115. system, so make sure that it works safely and doesn't keep any references
  116. to objects that might be deleted before it gets called.
  117. @returns If the callback parameter has been set, this returns 0. Otherwise, it returns one
  118. of the following values:
  119. - 0 if 'cancel' was pressed
  120. - 1 if 'yes' was pressed
  121. - 2 if 'no' was pressed
  122. */
  123. static int JUCE_CALLTYPE showYesNoCancelBox (AlertWindow::AlertIconType iconType,
  124. const String& title,
  125. const String& message,
  126. #if JUCE_MODAL_LOOPS_PERMITTED
  127. Component* associatedComponent = nullptr,
  128. ModalComponentManager::Callback* callback = nullptr);
  129. #else
  130. Component* associatedComponent,
  131. ModalComponentManager::Callback* callback);
  132. #endif
  133. };
  134. #endif // __JUCE_NATIVEMESSAGEBOX_JUCEHEADER__