55 positionTitleBarButtonsOnLeft (
true)
57 positionTitleBarButtonsOnLeft (
false)
75 for (
auto& b : titleBarButtons)
82void DocumentWindow::repaintTitleBar()
111 requiredButtons = buttons;
112 positionTitleBarButtonsOnLeft =
onLeft;
133 if (menuBarModel !=
nullptr)
142 return menuBar.get();
150 if (menuBar !=
nullptr)
198 for (
auto& b : titleBarButtons)
202 if (positionTitleBarButtonsOnLeft)
215 ! drawTitleTextCentred);
228 .positionDocumentWindowButtons (*
this,
231 titleBarButtons[0].get(),
232 titleBarButtons[1].get(),
233 titleBarButtons[2].get(),
234 positionTitleBarButtonsOnLeft);
236 if (menuBar !=
nullptr)
251 border.setTop (border.getTop()
253 + (menuBar !=
nullptr ? menuBarHeight : 0));
276int DocumentWindow::getDesktopWindowStyleFlags()
const
278 auto styleFlags = ResizableWindow::getDesktopWindowStyleFlags();
289 for (
auto& b : titleBarButtons)
296 if ((requiredButtons & minimiseButton) != 0) titleBarButtons[0].reset (
lf.createDocumentWindowButton (minimiseButton));
297 if ((requiredButtons & maximiseButton) != 0) titleBarButtons[1].reset (
lf.createDocumentWindowButton (maximiseButton));
298 if ((requiredButtons & closeButton) != 0) titleBarButtons[2].reset (
lf.createDocumentWindowButton (closeButton));
300 for (
auto& b : titleBarButtons)
304 if (buttonListener ==
nullptr)
305 buttonListener.reset (
new ButtonListenerProxy (*
this));
307 b->addListener (buttonListener.get());
308 b->setWantsKeyboardFocus (
false);
340 for (
auto& b : titleBarButtons)
344 if (menuBar !=
nullptr)
345 menuBar->setEnabled (isActive);
Represents a colour, also including a transparency value.
@ windowHasMaximiseButton
Indicates that if the window has a title bar, it should have a maximise button on it.
@ windowHasCloseButton
Indicates that if the window has a title bar, it should have a close button on it.
@ windowHasMinimiseButton
Indicates that if the window has a title bar, it should have a minimise button on it.
The base class for all JUCE user-interface objects.
bool contains(Point< int > localPoint)
Returns true if a given point lies within this component or one of its children.
virtual void parentHierarchyChanged()
Called to indicate that the component's parents have changed.
int getIndexOfChildComponent(const Component *child) const noexcept
Returns the index of this component in the list of child components.
int getHeight() const noexcept
Returns the component's height in pixels.
virtual void userTriedToCloseWindow()
For components on the desktop, this is called if the system wants to close the window.
void addAndMakeVisible(Component *child, int zOrder=-1)
Adds a child component to this one, and also makes the child visible if it isn't already.
void setEnabled(bool shouldBeEnabled)
Enables or disables this component.
void repaint()
Marks the whole component as needing to be redrawn.
virtual void resized()
Called when this component's size has been changed.
virtual void setName(const String &newName)
Sets the name of this component.
void mouseDoubleClick(const MouseEvent &event) override
Called when a mouse button has been double-clicked on a component.
int getWidth() const noexcept
Returns the component's width in pixels.
LookAndFeel & getLookAndFeel() const noexcept
Finds the appropriate look-and-feel to use for this component.
virtual void lookAndFeelChanged()
Called to let the component react to a change in the look-and-feel setting.
virtual void paint(Graphics &g)
Components can override this method to draw their content.
String getName() const noexcept
Returns the name of this component.
A resizable window with a title bar and maximise, minimise and close buttons.
virtual void maximiseButtonPressed()
Callback that is triggered when the maximise button is pressed, or when the title-bar is double-click...
Button * getCloseButton() const noexcept
Returns the close button, (or nullptr if there isn't one).
Component * getMenuBarComponent() const noexcept
Returns the current menu bar component, or null if there isn't one.
DocumentWindow(const String &name, Colour backgroundColour, int requiredButtons, bool addToDesktop=true)
Creates a DocumentWindow.
Button * getMaximiseButton() const noexcept
Returns the maximise button, (or nullptr if there isn't one).
void setMenuBarComponent(Component *newMenuBarComponent)
Replaces the current menu bar with a custom component.
~DocumentWindow() override
Destructor.
virtual void minimiseButtonPressed()
Callback that is triggered when the minimise button is pressed.
void setTitleBarTextCentred(bool textShouldBeCentred)
Sets whether the title should be centred within the window.
void setIcon(const Image &imageToUse)
Sets an icon to show in the title bar, next to the title.
void setTitleBarHeight(int newHeight)
Changes the height of the title-bar.
Button * getMinimiseButton() const noexcept
Returns the minimise button, (or nullptr if there isn't one).
virtual void closeButtonPressed()
This method is called when the user tries to close the window.
void setMenuBar(MenuBarModel *menuBarModel, int menuBarHeight=0)
Creates a menu inside this window.
void setName(const String &newName) override
Changes the component's name.
void setTitleBarButtonsRequired(int requiredButtons, bool positionTitleBarButtonsOnLeft)
Changes the set of title-bar buttons being shown.
int getTitleBarHeight() const
Returns the current title bar height.
A graphics context, used for drawing a component or image.
bool reduceClipRegion(int x, int y, int width, int height)
Intersects the current clipping region with another region.
void setOrigin(Point< int > newOrigin)
Moves the position of the context's origin.
Holds a fixed-size bitmap.
bool isValid() const noexcept
Returns true if this image isn't null.
static const int F4Key
key-code for the F4 key
@ commandModifier
Command key flag - on windows this is the same as the CTRL key flag.
@ altModifier
ALT key flag.
Manages a rectangle and allows geometric operations to be performed on it.
A base class for top-level windows that can be dragged around and resized.
void setFullScreen(bool shouldBeFullScreen)
Puts the window into full-screen mode, or restores it to its normal size.
void resized() override
(if overriding this, make sure you call ResizableWindow::resized() in your subclass)
void setResizeLimits(int newMinimumWidth, int newMinimumHeight, int newMaximumWidth, int newMaximumHeight) noexcept
This sets the maximum and minimum sizes for the window.
bool isKioskMode() const
Returns true if the window has been placed in kiosk-mode.
void lookAndFeelChanged() override
Called to let the component react to a change in the look-and-feel setting.
virtual BorderSize< int > getContentComponentBorder()
Returns the insets to use when positioning the content component.
void paint(Graphics &) override
Components can override this method to draw their content.
virtual BorderSize< int > getBorderThickness()
Returns the width of the frame to use around the window.
bool isFullScreen() const
Returns true if the window is currently in full-screen mode.
void activeWindowStatusChanged() override
This callback happens when this window becomes active or inactive.
void setMinimised(bool shouldMinimise)
Minimises the window, or restores it to its previous position and size.
bool isUsingNativeTitleBar() const noexcept
Returns true if the window is currently using an OS-native title bar.
bool isActiveWindow() const noexcept
True if this is currently the TopLevelWindow that is actively being used.
constexpr Type jmin(Type a, Type b)
Returns the smaller of two values.
constexpr Type jmax(Type a, Type b)
Returns the larger of two values.
@ dontSendNotification
No notification message should be sent.
Type unalignedPointerCast(void *ptr) noexcept
Casts a pointer to another type via void*, which suppresses the cast-align warning which sometimes ar...