LMMS
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//==============================================================================
45{
46public:
47 //==============================================================================
58 AlertWindow (const String& title,
59 const String& message,
60 MessageBoxIconType iconType,
62
64 ~AlertWindow() override;
65
66 //==============================================================================
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
96 void triggerButtonClick (const String& buttonName);
97
104 void setEscapeKeyCancels (bool shouldEscapeKeyCancel);
105
106 //==============================================================================
119 void addTextEditor (const String& name,
120 const String& initialContents,
121 const String& onScreenLabel = String(),
122 bool isPasswordBox = false);
123
132 String getTextEditorContents (const String& nameOfTextEditor) const;
133
135 TextEditor* getTextEditor (const String& nameOfTextEditor) const;
136
137 //==============================================================================
149 void addComboBox (const String& name,
150 const StringArray& items,
151 const String& onScreenLabel = String());
152
159 ComboBox* getComboBoxComponent (const String& nameOfList) const;
160
161 //==============================================================================
167 void addTextBlock (const String& text);
168
169 //==============================================================================
176 void addProgressBarComponent (double& progressValue);
177
178 //==============================================================================
185 void addCustomComponent (Component* component);
186
190 int getNumCustomComponents() const;
191
198 Component* getCustomComponent (int index) const;
199
208 Component* removeCustomComponent (int index);
209
210 //==============================================================================
212 bool containsAnyExtraComponents() const;
213
214 //==============================================================================
215 #if JUCE_MODAL_LOOPS_PERMITTED
231 static void JUCE_CALLTYPE showMessageBox (MessageBoxIconType iconType,
232 const String& title,
233 const String& message,
234 const String& buttonText = String(),
235 Component* associatedComponent = nullptr);
236
247 static int JUCE_CALLTYPE show (const MessageBoxOptions& options);
248 #endif
249
265 static void JUCE_CALLTYPE showAsync (const MessageBoxOptions& options,
267
279 static void JUCE_CALLTYPE showAsync (const MessageBoxOptions& options,
280 std::function<void (int)> callback);
281
303 static void JUCE_CALLTYPE showMessageBoxAsync (MessageBoxIconType iconType,
304 const String& title,
305 const String& message,
306 const String& buttonText = String(),
307 Component* associatedComponent = nullptr,
309
345 static bool JUCE_CALLTYPE showOkCancelBox (MessageBoxIconType iconType,
346 const String& title,
347 const String& message,
349 const String& button1Text = String(),
350 const String& button2Text = String(),
351 Component* associatedComponent = nullptr,
353 #else
354 const String& button1Text,
355 const String& button2Text,
356 Component* associatedComponent,
358 #endif
359
399 static int JUCE_CALLTYPE showYesNoCancelBox (MessageBoxIconType iconType,
400 const String& title,
401 const String& message,
403 const String& button1Text = String(),
404 const String& button2Text = String(),
405 const String& button3Text = String(),
406 Component* associatedComponent = nullptr,
408 #else
409 const String& button1Text,
410 const String& button2Text,
411 const String& button3Text,
412 Component* associatedComponent,
414 #endif
415
416 //==============================================================================
417 #if JUCE_MODAL_LOOPS_PERMITTED && ! defined (DOXYGEN)
426 [[deprecated ("Use the NativeMessageBox methods instead for more options")]]
427 static bool JUCE_CALLTYPE showNativeDialogBox (const String& title,
428 const String& bodyText,
429 bool isOkCancel);
430 #endif
431
432
433 //==============================================================================
442 {
443 backgroundColourId = 0x1001800,
444 textColourId = 0x1001810,
445 outlineColourId = 0x1001820
446 };
447
448 //==============================================================================
453 {
454 virtual ~LookAndFeelMethods() = default;
455
457 const String& button1,
458 const String& button2,
459 const String& button3,
460 MessageBoxIconType iconType,
461 int numButtons,
463
465
466 virtual int getAlertBoxWindowFlags() = 0;
467
469 virtual int getAlertWindowButtonHeight() = 0;
470
474 };
475
476 //==============================================================================
478
479 static constexpr auto NoIcon = MessageBoxIconType::NoIcon;
482 static constexpr auto InfoIcon = MessageBoxIconType::InfoIcon;
483
484protected:
485 //==============================================================================
487 void paint (Graphics&) override;
489 void mouseDown (const MouseEvent&) override;
491 void mouseDrag (const MouseEvent&) override;
493 bool keyPressed (const KeyPress&) override;
495 void lookAndFeelChanged() override;
497 void userTriedToCloseWindow() override;
499 int getDesktopWindowStyleFlags() const override;
501 float getDesktopScaleFactor() const override { return desktopScale * Desktop::getInstance().getGlobalScaleFactor(); }
502
503private:
504 //==============================================================================
521 bool escapeKeyCancels = true;
522 float desktopScale = 1.0f;
523
524 std::unique_ptr<AccessibilityHandler> createAccessibilityHandler() override;
525 void exitAlert (Button* button);
526 void updateLayout (bool onlyIncreaseSize);
527
529};
530
531} // namespace juce
#define noexcept
Definition DistrhoDefines.h:72
static void message(int level, const char *fmt,...)
Definition adplugdb.cpp:120
void mouseDown(const MouseEvent &) override
Definition juce_AlertWindow.cpp:517
ColourIds
Definition juce_AlertWindow.h:442
@ textColourId
Definition juce_AlertWindow.h:444
@ outlineColourId
Definition juce_AlertWindow.h:445
@ backgroundColourId
Definition juce_AlertWindow.h:443
StringArray textboxNames
Definition juce_AlertWindow.h:519
static constexpr auto WarningIcon
Definition juce_AlertWindow.h:481
ComponentDragger dragger
Definition juce_AlertWindow.h:510
OwnedArray< TextEditor > textBoxes
Definition juce_AlertWindow.h:513
OwnedArray< ComboBox > comboBoxes
Definition juce_AlertWindow.h:514
OwnedArray< TextButton > buttons
Definition juce_AlertWindow.h:512
StringArray comboBoxNames
Definition juce_AlertWindow.h:519
String text
Definition juce_AlertWindow.h:505
MessageBoxIconType getAlertType() const noexcept
Definition juce_AlertWindow.h:69
float desktopScale
Definition juce_AlertWindow.h:522
Rectangle< int > textArea
Definition juce_AlertWindow.h:511
Array< Component * > allComps
Definition juce_AlertWindow.h:518
void updateLayout(bool onlyIncreaseSize)
Definition juce_AlertWindow.cpp:359
Array< Component * > customComps
Definition juce_AlertWindow.h:516
void lookAndFeelChanged() override
Definition juce_AlertWindow.cpp:553
static constexpr auto NoIcon
Definition juce_AlertWindow.h:479
OwnedArray< Component > textBlocks
Definition juce_AlertWindow.h:517
void mouseDrag(const MouseEvent &) override
Definition juce_AlertWindow.cpp:522
int getDesktopWindowStyleFlags() const override
Definition juce_AlertWindow.cpp:562
MessageBoxIconType AlertIconType
Definition juce_AlertWindow.h:477
OwnedArray< ProgressBar > progressBars
Definition juce_AlertWindow.h:515
Component *const associatedComponent
Definition juce_AlertWindow.h:520
void exitAlert(Button *button)
Definition juce_AlertWindow.cpp:104
bool escapeKeyCancels
Definition juce_AlertWindow.h:521
MessageBoxIconType alertIconType
Definition juce_AlertWindow.h:508
void paint(Graphics &) override
Definition juce_AlertWindow.cpp:324
std::unique_ptr< AccessibilityHandler > createAccessibilityHandler() override
Definition juce_AlertWindow.cpp:797
static constexpr auto QuestionIcon
Definition juce_AlertWindow.h:480
Label accessibleMessageLabel
Definition juce_AlertWindow.h:507
ComponentBoundsConstrainer constrainer
Definition juce_AlertWindow.h:509
static constexpr auto InfoIcon
Definition juce_AlertWindow.h:482
AlertWindow(const String &title, const String &message, MessageBoxIconType iconType, Component *associatedComponent=nullptr)
Definition juce_AlertWindow.cpp:39
TextLayout textLayout
Definition juce_AlertWindow.h:506
bool keyPressed(const KeyPress &) override
Definition juce_AlertWindow.cpp:527
void userTriedToCloseWindow() override
Definition juce_AlertWindow.cpp:79
float getDesktopScaleFactor() const override
Definition juce_AlertWindow.h:501
Definition juce_Array.h:56
Definition juce_Button.h:43
Definition juce_ComboBox.h:49
Definition juce_ComponentBoundsConstrainer.h:44
Definition juce_ComponentDragger.h:59
Definition juce_Component.h:36
static Desktop &JUCE_CALLTYPE getInstance()
Definition juce_Desktop.cpp:50
Definition juce_Font.h:42
Definition juce_GraphicsContext.h:45
Definition juce_KeyPress.h:40
Definition juce_Label.h:41
Definition juce_MessageBoxOptions.h:63
Definition juce_ModalComponentManager.h:56
Definition juce_MouseEvent.h:39
Definition juce_OwnedArray.h:51
Definition juce_Rectangle.h:67
Definition juce_StringArray.h:35
Definition juce_String.h:53
Definition juce_TextEditor.h:43
Definition juce_TextLayout.h:41
TopLevelWindow(const String &name, bool addToDesktop)
Definition juce_TopLevelWindow.cpp:134
static const char * title
Definition pugl.h:1747
static const char * name
Definition pugl.h:1582
#define JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(className)
#define JUCE_MODAL_LOOPS_PERMITTED
#define JUCE_CALLTYPE
#define JUCE_API
Definition juce_StandardHeader.h:152
Definition carla_juce.cpp:31
MessageBoxIconType
Definition juce_MessageBoxOptions.h:31
@ WarningIcon
Definition juce_MessageBoxOptions.h:35
@ QuestionIcon
Definition juce_MessageBoxOptions.h:33
@ NoIcon
Definition juce_MessageBoxOptions.h:32
@ InfoIcon
Definition juce_MessageBoxOptions.h:37
Definition juce_AlertWindow.h:453
virtual void drawAlertBox(Graphics &, AlertWindow &, const Rectangle< int > &textArea, TextLayout &)=0
virtual AlertWindow * createAlertWindow(const String &title, const String &message, const String &button1, const String &button2, const String &button3, MessageBoxIconType iconType, int numButtons, Component *associatedComponent)=0
virtual Array< int > getWidthsForTextButtons(AlertWindow &, const Array< TextButton * > &)=0
const char * text
Definition swell-functions.h:167
RECT const char void(* callback)(const char *droppath))) SWELL_API_DEFINE(BOOL
Definition swell-functions.h:1004
#define const
Definition zconf.h:137