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.

155 lines
9.1KB

  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. /**
  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. */
  52. static void JUCE_CALLTYPE showMessageBoxAsync (AlertWindow::AlertIconType iconType,
  53. const String& title,
  54. const String& message,
  55. Component* associatedComponent = nullptr);
  56. /** Shows a dialog box with two buttons.
  57. Ideal for ok/cancel or yes/no choices. The return key can also be used
  58. to trigger the first button, and the escape key for the second button.
  59. If the callback parameter is null, the box is shown modally, and the method will
  60. block until the user has clicked the button (or pressed the escape or return keys).
  61. If the callback parameter is non-null, the box will be displayed and placed into a
  62. modal state, but this method will return immediately, and the callback will be invoked
  63. later when the user dismisses the box.
  64. @param iconType the type of icon to show
  65. @param title the headline to show at the top of the box
  66. @param message a longer, more descriptive message to show underneath the title
  67. @param associatedComponent if this is non-null, it specifies the component that the
  68. alert window should be associated with. Depending on the look
  69. and feel, this might be used for positioning of the alert window.
  70. @param callback if this is non-null, the box will be launched asynchronously,
  71. returning immediately, and the callback will receive a call to its
  72. modalStateFinished() when the box is dismissed, with its parameter
  73. being 1 if the ok button was pressed, or 0 for cancel, The callback object
  74. will be owned and deleted by the system, so make sure that it works
  75. safely and doesn't keep any references to objects that might be deleted
  76. before it gets called.
  77. @returns true if button 1 was clicked, false if it was button 2. If the callback parameter
  78. is not null, the method always returns false, and the user's choice is delivered
  79. later by the callback.
  80. */
  81. static bool JUCE_CALLTYPE showOkCancelBox (AlertWindow::AlertIconType iconType,
  82. const String& title,
  83. const String& message,
  84. #if JUCE_MODAL_LOOPS_PERMITTED
  85. Component* associatedComponent = nullptr,
  86. ModalComponentManager::Callback* callback = nullptr);
  87. #else
  88. Component* associatedComponent,
  89. ModalComponentManager::Callback* callback);
  90. #endif
  91. /** Shows a dialog box with three buttons.
  92. Ideal for yes/no/cancel boxes.
  93. The escape key can be used to trigger the third button.
  94. If the callback parameter is null, the box is shown modally, and the method will
  95. block until the user has clicked the button (or pressed the escape or return keys).
  96. If the callback parameter is non-null, the box will be displayed and placed into a
  97. modal state, but this method will return immediately, and the callback will be invoked
  98. later when the user dismisses the box.
  99. @param iconType the type of icon to show
  100. @param title the headline to show at the top of the box
  101. @param message a longer, more descriptive message to show underneath the title
  102. @param associatedComponent if this is non-null, it specifies the component that the
  103. alert window should be associated with. Depending on the look
  104. and feel, this might be used for positioning of the alert window.
  105. @param callback if this is non-null, the box will be launched asynchronously,
  106. returning immediately, and the callback will receive a call to its
  107. modalStateFinished() when the box is dismissed, with its parameter
  108. being 1 if the "yes" button was pressed, 2 for the "no" button, or 0
  109. if it was cancelled, The callback object will be owned and deleted by the
  110. system, so make sure that it works safely and doesn't keep any references
  111. to objects that might be deleted before it gets called.
  112. @returns If the callback parameter has been set, this returns 0. Otherwise, it returns one
  113. of the following values:
  114. - 0 if 'cancel' was pressed
  115. - 1 if 'yes' was pressed
  116. - 2 if 'no' was pressed
  117. */
  118. static int JUCE_CALLTYPE showYesNoCancelBox (AlertWindow::AlertIconType iconType,
  119. const String& title,
  120. const String& message,
  121. #if JUCE_MODAL_LOOPS_PERMITTED
  122. Component* associatedComponent = nullptr,
  123. ModalComponentManager::Callback* callback = nullptr);
  124. #else
  125. Component* associatedComponent,
  126. ModalComponentManager::Callback* callback);
  127. #endif
  128. };
  129. #endif // __JUCE_NATIVEMESSAGEBOX_JUCEHEADER__