JUCE-7.0.12-0-g4f43011b96 JUCE-7.0.12-0-g4f43011b96
JUCE — C++ application framework with suport for VST, VST3, LV2 audio plug-ins

« « « Anklang Documentation
Loading...
Searching...
No Matches
juce_MessageBoxOptions.h
Go to the documentation of this file.
1 /*
2 ==============================================================================
3
4 This file is part of the JUCE library.
5 Copyright (c) 2022 - Raw Material Software Limited
6
7 JUCE is an open source library subject to commercial or open-source
8 licensing.
9
10 By using JUCE, you agree to the terms of both the JUCE 7 End-User License
11 Agreement and JUCE Privacy Policy.
12
13 End User License Agreement: www.juce.com/juce-7-licence
14 Privacy Policy: www.juce.com/juce-privacy-policy
15
16 Or: You may also use this code under the terms of the GPL v3 (see
17 www.gnu.org/licenses).
18
19 JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
20 EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
21 DISCLAIMED.
22
23 ==============================================================================
24*/
25
26namespace juce
27{
28
31{
32 NoIcon,
40};
41
42//==============================================================================
62class JUCE_API MessageBoxOptions
63{
64public:
65 MessageBoxOptions() = default;
66 MessageBoxOptions (const MessageBoxOptions&) = default;
67 MessageBoxOptions& operator= (const MessageBoxOptions&) = default;
68
69 //==============================================================================
71 [[nodiscard]] MessageBoxOptions withIconType (MessageBoxIconType type) const { return withMember (*this, &MessageBoxOptions::iconType, type); }
72
74 [[nodiscard]] MessageBoxOptions withTitle (const String& boxTitle) const { return withMember (*this, &MessageBoxOptions::title, boxTitle); }
75
77 [[nodiscard]] MessageBoxOptions withMessage (const String& boxMessage) const { return withMember (*this, &MessageBoxOptions::message, boxMessage); }
78
85 [[nodiscard]] MessageBoxOptions withButton (const String& text) const { auto copy = *this; copy.buttons.add (text); return copy; }
86
88 [[nodiscard]] MessageBoxOptions withAssociatedComponent (Component* component) const { return withMember (*this, &MessageBoxOptions::associatedComponent, component); }
89
95 [[nodiscard]] MessageBoxOptions withParentComponent (Component* component) const { return withMember (*this, &MessageBoxOptions::parentComponent, component); }
96
97 //==============================================================================
102 MessageBoxIconType getIconType() const noexcept { return iconType; }
103
108 String getTitle() const { return title; }
109
114 String getMessage() const { return message; }
115
120 int getNumButtons() const noexcept { return buttons.size(); }
121
126 String getButtonText (int buttonIndex) const { return buttons[buttonIndex]; }
127
132 Component* getAssociatedComponent() const noexcept { return associatedComponent; }
133
138 Component* getParentComponent() const noexcept { return parentComponent; }
139
144 static MessageBoxOptions makeOptionsOk (MessageBoxIconType iconType,
145 const String& title,
146 const String& message,
147 const String& buttonText = String(),
148 Component* associatedComponent = nullptr);
149
154 static MessageBoxOptions makeOptionsOkCancel (MessageBoxIconType iconType,
155 const String& title,
156 const String& message,
157 const String& button1Text = String(),
158 const String& button2Text = String(),
159 Component* associatedComponent = nullptr);
160
165 static MessageBoxOptions makeOptionsYesNo (MessageBoxIconType iconType,
166 const String& title,
167 const String& message,
168 const String& button1Text = String(),
169 const String& button2Text = String(),
170 Component* associatedComponent = nullptr);
171
176 static MessageBoxOptions makeOptionsYesNoCancel (MessageBoxIconType iconType,
177 const String& title,
178 const String& message,
179 const String& button1Text = String(),
180 const String& button2Text = String(),
181 const String& button3Text = String(),
182 Component* associatedComponent = nullptr);
183
184private:
185 //==============================================================================
186 MessageBoxIconType iconType = MessageBoxIconType::InfoIcon;
187 String title, message;
188 StringArray buttons;
189 WeakReference<Component> associatedComponent;
190 WeakReference<Component> parentComponent;
191};
192
193} // namespace juce
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...
MessageBoxIconType getIconType() const noexcept
Returns the icon type of the dialog box.
Component * getParentComponent() const noexcept
Returns the component that will be used as the parent of the dialog box.
Component * getAssociatedComponent() const noexcept
Returns the component that the dialog box is associated with.
MessageBoxOptions withMessage(const String &boxMessage) const
Sets the message that should be displayed in the dialog box.
MessageBoxOptions withTitle(const String &boxTitle) const
Sets the title of the dialog box.
MessageBoxOptions withButton(const String &text) const
If the string passed in is not empty, this will add a button to the dialog box with the specified tex...
int getNumButtons() const noexcept
Returns the number of buttons that have been added to the dialog box.
MessageBoxOptions withIconType(MessageBoxIconType type) const
Sets the type of icon that should be used for the dialog box.
String getTitle() const
Returns the title of the dialog box.
String getMessage() const
Returns the message of the dialog box.
String getButtonText(int buttonIndex) const
Returns the text that has been set for one of the buttons of the dialog box.
MessageBoxOptions withAssociatedComponent(Component *component) const
The component that the dialog box should be associated with.
MessageBoxOptions withParentComponent(Component *component) const
The component that will contain the message box (e.g.
A special array for holding a list of strings.
The JUCE String class!
Definition juce_String.h:53
This class acts as a pointer which will automatically become null if the object to which it points is...
JUCE Namespace.
MessageBoxIconType
The type of icon to show in the dialog box.
@ WarningIcon
An exclamation mark to indicate that the dialog is a warning about something and shouldn't be ignored...
@ QuestionIcon
A question-mark icon, for dialog boxes that need the user to answer a question.
@ NoIcon
No icon will be shown on the dialog box.
@ InfoIcon
An icon that indicates that the dialog box is just giving the user some information,...
Object withMember(Object copy, Member OtherObject::*member, Other &&value)
Copies an object, sets one of the copy's members to the specified value, and then returns the copy.