openshot-audio  0.1.7
Classes | Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
AlertWindow Class Reference

#include <juce_AlertWindow.h>

Inheritance diagram for AlertWindow:
Button::Listener KeyMappingEditorComponent::ChangeKeyButton::KeyEntryWindow

Classes

struct  LookAndFeelMethods
 

Public Types

enum  AlertIconType { NoIcon, QuestionIcon, WarningIcon, InfoIcon }
 
enum  ColourIds { backgroundColourId = 0x1001800, textColourId = 0x1001810, outlineColourId = 0x1001820 }
 

Public Member Functions

 AlertWindow (const String &title, const String &message, AlertIconType iconType, Component *associatedComponent=nullptr)
 
 ~AlertWindow ()
 
AlertIconType getAlertType () const noexcept
 
void setMessage (const String &message)
 
void addButton (const String &name, int returnValue, const KeyPress &shortcutKey1=KeyPress(), const KeyPress &shortcutKey2=KeyPress())
 
int getNumButtons () const
 
void triggerButtonClick (const String &buttonName)
 
void setEscapeKeyCancels (bool shouldEscapeKeyCancel)
 
void addTextEditor (const String &name, const String &initialContents, const String &onScreenLabel=String::empty, bool isPasswordBox=false)
 
String getTextEditorContents (const String &nameOfTextEditor) const
 
TextEditorgetTextEditor (const String &nameOfTextEditor) const
 
void addComboBox (const String &name, const StringArray &items, const String &onScreenLabel=String::empty)
 
ComboBoxgetComboBoxComponent (const String &nameOfList) const
 
void addTextBlock (const String &text)
 
void addProgressBarComponent (double &progressValue)
 
void addCustomComponent (Component *component)
 
int getNumCustomComponents () const
 
ComponentgetCustomComponent (int index) const
 
ComponentremoveCustomComponent (int index)
 
bool containsAnyExtraComponents () const
 

Static Public Member Functions

static void JUCE_CALLTYPE showMessageBoxAsync (AlertIconType iconType, const String &title, const String &message, const String &buttonText=String::empty, Component *associatedComponent=nullptr, ModalComponentManager::Callback *callback=nullptr)
 
static bool JUCE_CALLTYPE showOkCancelBox (AlertIconType iconType, const String &title, const String &message, const String &button1Text, const String &button2Text, Component *associatedComponent, ModalComponentManager::Callback *callback)
 
static int JUCE_CALLTYPE showYesNoCancelBox (AlertIconType iconType, const String &title, const String &message, const String &button1Text, const String &button2Text, const String &button3Text, Component *associatedComponent, ModalComponentManager::Callback *callback)
 

Protected Member Functions

void paint (Graphics &) override
 
void mouseDown (const MouseEvent &) override
 
void mouseDrag (const MouseEvent &) override
 
bool keyPressed (const KeyPress &) override
 
void buttonClicked (Button *) override
 
void lookAndFeelChanged () override
 
void userTriedToCloseWindow () override
 
int getDesktopWindowStyleFlags () const override
 

Detailed Description

A window that displays a message and has buttons for the user to react to it.

For simple dialog boxes with just a couple of buttons on them, there are some static methods for running these.

For more complex dialogs, an AlertWindow can be created, then it can have some buttons and components added to it, and its runModalLoop() method is then used to show it. The value returned by runModalLoop() shows which button the user pressed to dismiss the box.

See Also
ThreadWithProgressWindow

Member Enumeration Documentation

The type of icon to show in the dialog box.

Enumerator
NoIcon 

No icon will be shown on the dialog box.

QuestionIcon 

A question-mark icon, for dialog boxes that need the user to answer a question.

WarningIcon 

An exclamation mark to indicate that the dialog is a warning about something and shouldn't be ignored.

InfoIcon 

An icon that indicates that the dialog box is just giving the user some information, which doesn't require a response from them.

Shows an operating-system native dialog box.

Parameters
titlethe title to use at the top
bodyTextthe longer message to show
isOkCancelif true, this will show an ok/cancel box, if false, it'll show a box with just an ok button
Returns
true if the ok button was pressed, false if they pressed cancel.A set of colour IDs to use to change the colour of various aspects of the alert box.

These constants can be used either via the Component::setColour(), or LookAndFeel::setColour() methods.

See Also
Component::setColour, Component::findColour, LookAndFeel::setColour, LookAndFeel::findColour
Enumerator
backgroundColourId 

The background colour for the window.

textColourId 

The colour for the text.

outlineColourId 

An optional colour to use to draw a border around the window.

Constructor & Destructor Documentation

AlertWindow::AlertWindow ( const String title,
const String message,
AlertIconType  iconType,
Component associatedComponent = nullptr 
)

Creates an AlertWindow.

Parameters
titlethe headline to show at the top of the dialog box
messagea longer, more descriptive message to show underneath the headline
iconTypethe type of icon to display
associatedComponentif this is non-null, it specifies the component that the alert window should be associated with. Depending on the look and feel, this might be used for positioning of the alert window.
AlertWindow::~AlertWindow ( )

Destroys the AlertWindow

Member Function Documentation

void AlertWindow::addButton ( const String name,
int  returnValue,
const KeyPress shortcutKey1 = KeyPress(),
const KeyPress shortcutKey2 = KeyPress() 
)

Adds a button to the window.

Parameters
namethe text to show on the button
returnValuethe value that should be returned from runModalLoop() if this is the button that the user presses.
shortcutKey1an optional key that can be pressed to trigger this button
shortcutKey2a second optional key that can be pressed to trigger this button
void AlertWindow::addComboBox ( const String name,
const StringArray items,
const String onScreenLabel = String::empty 
)

Adds a drop-down list of choices to the box.

After the box has been shown, the getComboBoxComponent() method can be used to find out which item the user picked.

Parameters
namethe label to use for the drop-down list
itemsthe list of items to show in it
onScreenLabelif this is non-empty, it will be displayed next to the combo-box to label it.
See Also
getComboBoxComponent
void AlertWindow::addCustomComponent ( Component component)

Adds a user-defined component to the dialog box.

Parameters
componentthe component to add - its size should be set up correctly before it is passed in. The caller is responsible for deleting the component later on - the AlertWindow won't delete it.
void AlertWindow::addProgressBarComponent ( double &  progressValue)

Adds a progress-bar to the window.

Parameters
progressValuea variable that will be repeatedly checked while the dialog box is visible, to see how far the process has got. The value should be in the range 0 to 1.0
void AlertWindow::addTextBlock ( const String text)

Adds a block of text.

This is handy for adding a multi-line note next to a textbox or combo-box, to provide more details about what's going on.

void AlertWindow::addTextEditor ( const String name,
const String initialContents,
const String onScreenLabel = String::empty,
bool  isPasswordBox = false 
)

Adds a textbox to the window for entering strings.

Parameters
namean internal name for the text-box. This is the name to pass to the getTextEditorContents() method to find out what the user typed-in.
initialContentsa string to show in the text box when it's first shown
onScreenLabelif this is non-empty, it will be displayed next to the text-box to label it.
isPasswordBoxif true, the text editor will display asterisks instead of the actual text
See Also
getTextEditorContents
void AlertWindow::buttonClicked ( Button )
overrideprotectedvirtual

Called when the button is clicked.

Implements Button::Listener.

bool AlertWindow::containsAnyExtraComponents ( ) const

Returns true if the window contains any components other than just buttons.

AlertIconType AlertWindow::getAlertType ( ) const
inlinenoexcept

Returns the type of alert icon that was specified when the window was created.

ComboBox * AlertWindow::getComboBoxComponent ( const String nameOfList) const

Returns a drop-down list that was added to the AlertWindow.

Parameters
nameOfListthe name that was passed into the addComboBox() method when creating the drop-down
Returns
the ComboBox component, or nullptr if none was found for the given name.
Component * AlertWindow::getCustomComponent ( int  index) const

Returns one of the custom components in the dialog box.

Parameters
indexa value 0 to (getNumCustomComponents() - 1). Out-of-range indexes will return nullptr
See Also
getNumCustomComponents, addCustomComponent
int AlertWindow::getDesktopWindowStyleFlags ( ) const
overrideprotected
int AlertWindow::getNumButtons ( ) const

Returns the number of buttons that the window currently has.

int AlertWindow::getNumCustomComponents ( ) const

Returns the number of custom components in the dialog box.

See Also
getCustomComponent, addCustomComponent
TextEditor * AlertWindow::getTextEditor ( const String nameOfTextEditor) const

Returns a pointer to a textbox that was added with addTextEditor().

String AlertWindow::getTextEditorContents ( const String nameOfTextEditor) const

Returns the contents of a named textbox.

After showing an AlertWindow that contains a text editor, this can be used to find out what the user has typed into it.

Parameters
nameOfTextEditorthe name of the text box that you're interested in
See Also
addTextEditor
bool AlertWindow::keyPressed ( const KeyPress key)
overrideprotected
void AlertWindow::lookAndFeelChanged ( )
overrideprotected
void AlertWindow::mouseDown ( const MouseEvent e)
overrideprotected
void AlertWindow::mouseDrag ( const MouseEvent e)
overrideprotected
void AlertWindow::paint ( Graphics g)
overrideprotected
Component * AlertWindow::removeCustomComponent ( int  index)

Removes one of the custom components in the dialog box. Note that this won't delete it, it just removes the component from the window

Parameters
indexa value 0 to (getNumCustomComponents() - 1). Out-of-range indexes will return nullptr
Returns
the component that was removed (or null)
See Also
getNumCustomComponents, addCustomComponent
void AlertWindow::setEscapeKeyCancels ( bool  shouldEscapeKeyCancel)

If set to true and the window contains no buttons, then pressing the escape key will make the alert cancel its modal state. By default this setting is true - turn it off if you don't want the box to respond to the escape key. Note that it is ignored if you have any buttons, and in that case you should give the buttons appropriate keypresses to trigger cancelling if you want to.

void AlertWindow::setMessage ( const String message)

Changes the dialog box's message.

This will also resize the window to fit the new message if required.

void AlertWindow::showMessageBoxAsync ( AlertIconType  iconType,
const String title,
const String message,
const String buttonText = String::empty,
Component associatedComponent = nullptr,
ModalComponentManager::Callback callback = nullptr 
)
static

Shows a dialog box that just has a message and a single button to get rid of it.

The box will be displayed and placed into a modal state, but this method will return immediately, and if a callback was supplied, it will be invoked later when the user dismisses the box.

Parameters
iconTypethe type of icon to show
titlethe headline to show at the top of the box
messagea longer, more descriptive message to show underneath the headline
buttonTextthe text to show in the button - if this string is empty, the default string "OK" (or a localised version) will be used.
associatedComponentif this is non-null, it specifies the component that the alert window should be associated with. Depending on the look and feel, this might be used for positioning of the alert window.
callbackif this is non-null, the callback will receive a call to its modalStateFinished() when the box is dismissed. The callback object will be owned and deleted by the system, so make sure that it works safely and doesn't keep any references to objects that might be deleted before it gets called.
bool AlertWindow::showOkCancelBox ( AlertIconType  iconType,
const String title,
const String message,
const String button1Text,
const String button2Text,
Component associatedComponent,
ModalComponentManager::Callback callback 
)
static

Shows a dialog box with two buttons.

Ideal for ok/cancel or yes/no choices. The return key can also be used to trigger the first button, and the escape key for the second button.

If the callback parameter is null, the box is shown modally, and the method will block until the user has clicked the button (or pressed the escape or return keys). If the callback parameter is non-null, the box will be displayed and placed into a modal state, but this method will return immediately, and the callback will be invoked later when the user dismisses the box.

Parameters
iconTypethe type of icon to show
titlethe headline to show at the top of the box
messagea longer, more descriptive message to show underneath the headline
button1Textthe text to show in the first button - if this string is empty, the default string "OK" (or a localised version of it) will be used.
button2Textthe text to show in the second button - if this string is empty, the default string "cancel" (or a localised version of it) will be used.
associatedComponentif this is non-null, it specifies the component that the alert window should be associated with. Depending on the look and feel, this might be used for positioning of the alert window.
callbackif this is non-null, the menu will be launched asynchronously, returning immediately, and the callback will receive a call to its modalStateFinished() when the box is dismissed, with its parameter being 1 if the ok button was pressed, or 0 for cancel. The callback object will be owned and deleted by the system, so make sure that it works safely and doesn't keep any references to objects that might be deleted before it gets called.
Returns
true if button 1 was clicked, false if it was button 2. If the callback parameter is not null, the method always returns false, and the user's choice is delivered later by the callback.
int AlertWindow::showYesNoCancelBox ( AlertIconType  iconType,
const String title,
const String message,
const String button1Text,
const String button2Text,
const String button3Text,
Component associatedComponent,
ModalComponentManager::Callback callback 
)
static

Shows a dialog box with three buttons.

Ideal for yes/no/cancel boxes.

The escape key can be used to trigger the third button.

If the callback parameter is null, the box is shown modally, and the method will block until the user has clicked the button (or pressed the escape or return keys). If the callback parameter is non-null, the box will be displayed and placed into a modal state, but this method will return immediately, and the callback will be invoked later when the user dismisses the box.

Parameters
iconTypethe type of icon to show
titlethe headline to show at the top of the box
messagea longer, more descriptive message to show underneath the headline
button1Textthe text to show in the first button - if an empty string, then "yes" will be used (or a localised version of it)
button2Textthe text to show in the first button - if an empty string, then "no" will be used (or a localised version of it)
button3Textthe text to show in the first button - if an empty string, then "cancel" will be used (or a localised version of it)
associatedComponentif this is non-null, it specifies the component that the alert window should be associated with. Depending on the look and feel, this might be used for positioning of the alert window.
callbackif this is non-null, the menu will be launched asynchronously, returning immediately, and the callback will receive a call to its modalStateFinished() when the box is dismissed, with its parameter being 1 if the "yes" button was pressed, 2 for the "no" button, or 0 if it was cancelled. The callback object will be owned and deleted by the system, so make sure that it works safely and doesn't keep any references to objects that might be deleted before it gets called.
Returns
If the callback parameter has been set, this returns 0. Otherwise, it returns one of the following values:
  • 0 if the third button was pressed (normally used for 'cancel')
  • 1 if the first button was pressed (normally used for 'yes')
  • 2 if the middle button was pressed (normally used for 'no')
void AlertWindow::triggerButtonClick ( const String buttonName)

Invokes a click of one of the buttons.

void AlertWindow::userTriedToCloseWindow ( )
overrideprotected

The documentation for this class was generated from the following files: