29enum class ResultCodeMappingMode
38 ResultCodeMappingMode mode)
40 class Adapter final :
public detail::ScopedMessageBoxInterface
43 explicit Adapter (
const MessageBoxOptions& options)
44 : inner (detail::ScopedMessageBoxInterface::create (options)),
49 inner->runAsync ([fn, n =
numButtons] (
int result)
55 int runSync()
override
72 return mode == ResultCodeMappingMode::plainIndex ? detail::ScopedMessageBoxInterface::create (
opts)
76static int showNativeBoxUnmanaged (
const MessageBoxOptions&
opts,
77 ModalComponentManager::Callback*
cb,
78 ResultCodeMappingMode mode)
81 return detail::ConcreteScopedMessageBoxImpl::showUnmanaged (std::move (
implementation),
cb);
84#if JUCE_MODAL_LOOPS_PERMITTED
86 const String& title,
const String& message,
87 Component* associatedComponent)
89 showNativeBoxUnmanaged (MessageBoxOptions().withIconType (iconType)
91 .withMessage (message)
92 .withButton (
TRANS (
"OK"))
93 .withAssociatedComponent (associatedComponent),
95 ResultCodeMappingMode::plainIndex);
98int JUCE_CALLTYPE NativeMessageBox::show (
const MessageBoxOptions& options)
100 return showNativeBoxUnmanaged (options,
nullptr, ResultCodeMappingMode::plainIndex);
110 showNativeBoxUnmanaged (options, callback, ResultCodeMappingMode::alertWindow);
119 return showNativeBoxUnmanaged (options, callback, ResultCodeMappingMode::alertWindow) != 0;
128 return showNativeBoxUnmanaged (options, callback, ResultCodeMappingMode::alertWindow);
137 return showNativeBoxUnmanaged (options, callback, ResultCodeMappingMode::alertWindow);
143 showNativeBoxUnmanaged (options, callback, ResultCodeMappingMode::plainIndex);
154 auto implementation = makeNativeMessageBoxWithMappedResult (options, ResultCodeMappingMode::alertWindow);
155 return detail::ConcreteScopedMessageBoxImpl::show (std::move (
implementation), std::move (callback));
The base class for all JUCE user-interface objects.
Class used to create a set of options to pass to the AlertWindow and NativeMessageBox methods for sho...
static MessageBoxOptions makeOptionsYesNo(MessageBoxIconType iconType, const String &title, const String &message, const String &button1Text=String(), const String &button2Text=String(), Component *associatedComponent=nullptr)
Creates options suitable for a message box with two buttons.
static MessageBoxOptions makeOptionsYesNoCancel(MessageBoxIconType iconType, const String &title, const String &message, const String &button1Text=String(), const String &button2Text=String(), const String &button3Text=String(), Component *associatedComponent=nullptr)
Creates options suitable for a message box with three buttons.
static MessageBoxOptions makeOptionsOkCancel(MessageBoxIconType iconType, const String &title, const String &message, const String &button1Text=String(), const String &button2Text=String(), Component *associatedComponent=nullptr)
Creates options suitable for a message box with two buttons.
static MessageBoxOptions makeOptionsOk(MessageBoxIconType iconType, const String &title, const String &message, const String &buttonText=String(), Component *associatedComponent=nullptr)
Creates options suitable for a message box with a single button.
static ModalComponentManager::Callback * create(CallbackFn &&fn)
This is a utility function to create a ModalComponentManager::Callback that will call a callable obje...
Receives callbacks when a modal component is dismissed.
static int JUCE_CALLTYPE showYesNoBox(MessageBoxIconType iconType, const String &title, const String &message, Component *associatedComponent, ModalComponentManager::Callback *callback)
Shows a dialog box with two buttons.
static void JUCE_CALLTYPE showMessageBoxAsync(MessageBoxIconType iconType, const String &title, const String &message, Component *associatedComponent=nullptr, ModalComponentManager::Callback *callback=nullptr)
Shows a dialog box that just has a message and a single 'ok' button to close it.
static bool JUCE_CALLTYPE showOkCancelBox(MessageBoxIconType iconType, const String &title, const String &message, Component *associatedComponent, ModalComponentManager::Callback *callback)
Shows a dialog box with two buttons.
static ScopedMessageBox showScopedAsync(const MessageBoxOptions &options, std::function< void(int)> callback)
Shows a dialog box using the specified options.
static int JUCE_CALLTYPE showYesNoCancelBox(MessageBoxIconType iconType, const String &title, const String &message, Component *associatedComponent, ModalComponentManager::Callback *callback)
Shows a dialog box with three buttons.
static void JUCE_CALLTYPE showAsync(const MessageBoxOptions &options, ModalComponentManager::Callback *callback)
Shows a dialog box using the specified options.
Objects of this type can be used to programmatically close message boxes.
#define TRANS(stringLiteral)
Uses the LocalisedStrings class to translate the given string literal.
MessageBoxIconType
The type of icon to show in the dialog box.
Type unalignedPointerCast(void *ptr) noexcept
Casts a pointer to another type via void*, which suppresses the cast-align warning which sometimes ar...