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_AlertWindow.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
29//==============================================================================
44class JUCE_API AlertWindow : public TopLevelWindow
45{
46public:
47 //==============================================================================
58 AlertWindow (const String& title,
59 const String& message,
60 MessageBoxIconType iconType,
61 Component* associatedComponent = nullptr);
62
64 ~AlertWindow() override;
65
66 //==============================================================================
69 MessageBoxIconType getAlertType() const noexcept { return alertIconType; }
70
71 //==============================================================================
76 void setMessage (const String& message);
77
78 //==============================================================================
87 void addButton (const String& name,
88 int returnValue,
89 const KeyPress& shortcutKey1 = KeyPress(),
90 const KeyPress& shortcutKey2 = KeyPress());
91
93 int getNumButtons() const;
94
102 Button* getButton (int index) const;
103
109 Button* getButton (const String& buttonName) const;
110
112 void triggerButtonClick (const String& buttonName);
113
120 void setEscapeKeyCancels (bool shouldEscapeKeyCancel);
121
122 //==============================================================================
135 void addTextEditor (const String& name,
136 const String& initialContents,
137 const String& onScreenLabel = String(),
138 bool isPasswordBox = false);
139
148 String getTextEditorContents (const String& nameOfTextEditor) const;
149
151 TextEditor* getTextEditor (const String& nameOfTextEditor) const;
152
153 //==============================================================================
165 void addComboBox (const String& name,
166 const StringArray& items,
167 const String& onScreenLabel = String());
168
175 ComboBox* getComboBoxComponent (const String& nameOfList) const;
176
177 //==============================================================================
183 void addTextBlock (const String& text);
184
185 //==============================================================================
197 void addProgressBarComponent (double& progressValue, std::optional<ProgressBar::Style> style = std::nullopt);
198
199 //==============================================================================
206 void addCustomComponent (Component* component);
207
211 int getNumCustomComponents() const;
212
219 Component* getCustomComponent (int index) const;
220
229 Component* removeCustomComponent (int index);
230
231 //==============================================================================
233 bool containsAnyExtraComponents() const;
234
235 //==============================================================================
236 #if JUCE_MODAL_LOOPS_PERMITTED
252 static void JUCE_CALLTYPE showMessageBox (MessageBoxIconType iconType,
253 const String& title,
254 const String& message,
255 const String& buttonText = String(),
256 Component* associatedComponent = nullptr);
257
268 static int JUCE_CALLTYPE show (const MessageBoxOptions& options);
269 #endif
270
286 static void JUCE_CALLTYPE showAsync (const MessageBoxOptions& options,
288
300 static void JUCE_CALLTYPE showAsync (const MessageBoxOptions& options,
301 std::function<void (int)> callback);
302
324 static void JUCE_CALLTYPE showMessageBoxAsync (MessageBoxIconType iconType,
325 const String& title,
326 const String& message,
327 const String& buttonText = String(),
328 Component* associatedComponent = nullptr,
329 ModalComponentManager::Callback* callback = nullptr);
330
368 static bool JUCE_CALLTYPE showOkCancelBox (MessageBoxIconType iconType,
369 const String& title,
370 const String& message,
372 const String& button1Text = String(),
373 const String& button2Text = String(),
374 Component* associatedComponent = nullptr,
375 ModalComponentManager::Callback* callback = nullptr);
376 #else
377 const String& button1Text,
378 const String& button2Text,
379 Component* associatedComponent,
381 #endif
382
424 static int JUCE_CALLTYPE showYesNoCancelBox (MessageBoxIconType iconType,
425 const String& title,
426 const String& message,
428 const String& button1Text = String(),
429 const String& button2Text = String(),
430 const String& button3Text = String(),
431 Component* associatedComponent = nullptr,
432 ModalComponentManager::Callback* callback = nullptr);
433 #else
434 const String& button1Text,
435 const String& button2Text,
436 const String& button3Text,
437 Component* associatedComponent,
439 #endif
440
471 [[nodiscard]] static ScopedMessageBox showScopedAsync (const MessageBoxOptions& options,
472 std::function<void (int)> callback);
473
474 //==============================================================================
475 #if JUCE_MODAL_LOOPS_PERMITTED && ! defined (DOXYGEN)
484 [[deprecated ("Use the NativeMessageBox methods instead for more options")]]
485 static bool JUCE_CALLTYPE showNativeDialogBox (const String& title,
486 const String& bodyText,
487 bool isOkCancel);
488 #endif
489
490
491 //==============================================================================
500 {
501 backgroundColourId = 0x1001800,
502 textColourId = 0x1001810,
503 outlineColourId = 0x1001820
504 };
505
506 //==============================================================================
510 struct JUCE_API LookAndFeelMethods
511 {
512 virtual ~LookAndFeelMethods() = default;
513
514 virtual AlertWindow* createAlertWindow (const String& title, const String& message,
515 const String& button1,
516 const String& button2,
517 const String& button3,
518 MessageBoxIconType iconType,
519 int numButtons,
520 Component* associatedComponent) = 0;
521
522 virtual void drawAlertBox (Graphics&, AlertWindow&, const Rectangle<int>& textArea, TextLayout&) = 0;
523
524 virtual int getAlertBoxWindowFlags() = 0;
525
526 virtual Array<int> getWidthsForTextButtons (AlertWindow&, const Array<TextButton*>&) = 0;
527 virtual int getAlertWindowButtonHeight() = 0;
528
529 virtual Font getAlertWindowTitleFont() = 0;
530 virtual Font getAlertWindowMessageFont() = 0;
531 virtual Font getAlertWindowFont() = 0;
532 };
533
534 //==============================================================================
536
537 static constexpr auto NoIcon = MessageBoxIconType::NoIcon;
538 static constexpr auto QuestionIcon = MessageBoxIconType::QuestionIcon;
539 static constexpr auto WarningIcon = MessageBoxIconType::WarningIcon;
540 static constexpr auto InfoIcon = MessageBoxIconType::InfoIcon;
541
543 std::unique_ptr<AccessibilityHandler> createAccessibilityHandler() override;
544
545protected:
546 //==============================================================================
548 void paint (Graphics&) override;
550 void mouseDown (const MouseEvent&) override;
552 void mouseDrag (const MouseEvent&) override;
554 bool keyPressed (const KeyPress&) override;
556 void lookAndFeelChanged() override;
558 void userTriedToCloseWindow() override;
560 int getDesktopWindowStyleFlags() const override;
562 float getDesktopScaleFactor() const override { return desktopScale * Desktop::getInstance().getGlobalScaleFactor(); }
563
564private:
565 //==============================================================================
566 String text;
567 TextLayout textLayout;
568 Label accessibleMessageLabel;
569 MessageBoxIconType alertIconType;
570 ComponentBoundsConstrainer constrainer;
571 ComponentDragger dragger;
572 Rectangle<int> textArea;
574 OwnedArray<TextEditor> textBoxes;
575 OwnedArray<ComboBox> comboBoxes;
576 OwnedArray<ProgressBar> progressBars;
577 Array<Component*> customComps;
578 OwnedArray<Component> textBlocks;
579 Array<Component*> allComps;
580 StringArray textboxNames, comboBoxNames;
581 Component* const associatedComponent;
582 bool escapeKeyCancels = true;
583 float desktopScale = 1.0f;
584
585 void exitAlert (Button* button);
586 void updateLayout (bool onlyIncreaseSize);
587
589};
590
591} // namespace juce
A window that displays a message and has buttons for the user to react to it.
ColourIds
A set of colour IDs to use to change the colour of various aspects of the alert box.
MessageBoxIconType getAlertType() const noexcept
Returns the type of alert icon that was specified when the window was created.
float getDesktopScaleFactor() const override
Returns the default scale factor to use for this component when it is placed on the desktop.
Holds a resizable array of primitive or copy-by-value objects.
Definition juce_Array.h:56
A base class for buttons.
Definition juce_Button.h:43
A component that lets the user choose from a drop-down list of choices.
A class that imposes restrictions on a Component's size or position.
An object to take care of the logic for dragging components around with the mouse.
The base class for all JUCE user-interface objects.
Represents a particular font, including its size, style, etc.
Definition juce_Font.h:42
A graphics context, used for drawing a component or image.
Represents a key press, including any modifier keys that are needed.
A component that displays a text string, and can optionally become a text editor when clicked.
Definition juce_Label.h:41
Class used to create a set of options to pass to the AlertWindow and NativeMessageBox methods for sho...
Receives callbacks when a modal component is dismissed.
Contains position and status information about a mouse event.
An array designed for holding objects.
Manages a rectangle and allows geometric operations to be performed on it.
Objects of this type can be used to programmatically close message boxes.
A special array for holding a list of strings.
The JUCE String class!
Definition juce_String.h:53
An editable text box.
A Pre-formatted piece of text, which may contain multiple fonts and colours.
A base class for top-level windows.
#define JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(className)
This is a shorthand way of writing both a JUCE_DECLARE_NON_COPYABLE and JUCE_LEAK_DETECTOR macro for ...
#define JUCE_MODAL_LOOPS_PERMITTED
Some operating environments don't provide a modal loop mechanism, so this flag can be used to disable...
#define JUCE_CALLTYPE
This macro defines the C calling convention used as the standard for JUCE calls.
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,...
This abstract base class is implemented by LookAndFeel classes to provide alert-window drawing functi...