42 if (escapeKeyTriggersCloseButton)
63 if (escapeKeyTriggersCloseButton)
69 if (!
close->isRegisteredForShortcut (
esc))
86 if (options.
content.willDeleteObject())
107DialogWindow::LaunchOptions::LaunchOptions() noexcept {}
119 d->enterModalState (
true,
nullptr,
true);
123#if JUCE_MODAL_LOOPS_PERMITTED
124int DialogWindow::LaunchOptions::runModal()
126 return launchAsync()->runModalLoop();
133 Component*
const componentToCentreAround,
135 const bool escapeKeyTriggersCloseButton,
136 const bool resizable,
137 const bool useBottomRightCornerResizer)
141 o.content.setNonOwned (contentComponent);
142 o.componentToCentreAround = componentToCentreAround;
143 o.dialogBackgroundColour = backgroundColour;
144 o.escapeKeyTriggersCloseButton = escapeKeyTriggersCloseButton;
145 o.useNativeTitleBar =
false;
146 o.resizable = resizable;
147 o.useBottomRightCornerResizer = useBottomRightCornerResizer;
152#if JUCE_MODAL_LOOPS_PERMITTED
153int DialogWindow::showModalDialog (
const String& dialogTitle,
155 Component*
const componentToCentreAround,
157 const bool escapeKeyTriggersCloseButton,
158 const bool resizable,
159 const bool useBottomRightCornerResizer)
162 o.dialogTitle = dialogTitle;
163 o.content.setNonOwned (contentComponent);
164 o.componentToCentreAround = componentToCentreAround;
165 o.dialogBackgroundColour = backgroundColour;
166 o.escapeKeyTriggersCloseButton = escapeKeyTriggersCloseButton;
167 o.useNativeTitleBar =
false;
168 o.resizable = resizable;
169 o.useBottomRightCornerResizer = useBottomRightCornerResizer;
178 return std::make_unique<AccessibilityHandler> (*
this, AccessibilityRole::dialogWindow);
Represents a colour, also including a transparency value.
The base class for all JUCE user-interface objects.
int getHeight() const noexcept
Returns the component's height in pixels.
static float JUCE_CALLTYPE getApproximateScaleFactorForComponent(const Component *targetComponent)
Returns the approximate scale factor for a given component by traversing its parent hierarchy and app...
void setAlwaysOnTop(bool shouldStayOnTop)
Sets whether the component should always be kept at the front of its siblings.
virtual void resized()
Called when this component's size has been changed.
int getWidth() const noexcept
Returns the component's width in pixels.
virtual bool keyPressed(const KeyPress &key)
Called when a key is pressed.
virtual void setVisible(bool shouldBeVisible)
Makes the component visible or invisible.
void closeButtonPressed() override
This method is called when the user tries to close the window.
A dialog-box style window.
~DialogWindow() override
Destructor.
bool keyPressed(const KeyPress &) override
Called when a key is pressed.
static void showDialog(const String &dialogTitle, Component *contentComponent, Component *componentToCentreAround, Colour backgroundColour, bool escapeKeyTriggersCloseButton, bool shouldBeResizable=false, bool useBottomRightCornerResizer=false)
Easy way of quickly showing a dialog box containing a given component.
virtual bool escapeKeyPressed()
Called when the escape key is pressed.
void resized() override
Called when this component's size has been changed.
std::unique_ptr< AccessibilityHandler > createAccessibilityHandler() override
Override this method to return a custom AccessibilityHandler for this component.
DialogWindow(const String &name, Colour backgroundColour, bool escapeKeyTriggersCloseButton, bool addToDesktop=true, float desktopScale=1.0f)
Creates a DialogWindow.
A resizable window with a title bar and maximise, minimise and close buttons.
Button * getCloseButton() const noexcept
Returns the close button, (or nullptr if there isn't one).
Represents a key press, including any modifier keys that are needed.
static const int escapeKey
key-code for the escape key
void setResizable(bool shouldBeResizable, bool useBottomRightCornerResizer)
Make the window resizable or fixed.
void setContentOwned(Component *newContentComponent, bool resizeToFitWhenContentChangesSize)
Changes the current content component.
void setContentNonOwned(Component *newContentComponent, bool resizeToFitWhenContentChangesSize)
Changes the current content component.
void centreAroundComponent(Component *componentToCentreAround, int width, int height)
This will set the bounds of the window so that it's centred in front of another window.
void setUsingNativeTitleBar(bool useNativeTitleBar)
Sets whether an OS-native title bar will be used, or a JUCE one.
Type unalignedPointerCast(void *ptr) noexcept
Casts a pointer to another type via void*, which suppresses the cast-align warning which sometimes ar...
This class defines a collection of settings to be used to open a DialogWindow.
DialogWindow * create()
Creates a new DialogWindow instance with these settings.
Component * componentToCentreAround
If this is not a nullptr, it indicates a component that you'd like to position this dialog box in fro...
Colour dialogBackgroundColour
The background colour for the window.
bool useNativeTitleBar
If true, the dialog will use a native title bar.
OptionalScopedPointer< Component > content
The content component to show in the window.
bool useBottomRightCornerResizer
Indicates whether to use a border or corner resizer component.
DialogWindow * launchAsync()
Launches a new modal dialog window.
bool resizable
If true, the window will be resizable.
bool escapeKeyTriggersCloseButton
If true, then the escape key will trigger the dialog's close button.
String dialogTitle
The title to give the window.
static bool areThereAnyAlwaysOnTopWindows()
Returns true if any windows have a z order that is higher than normal.