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.

158 lines
9.5KB

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