LMMS
Loading...
Searching...
No Matches
juce::TopLevelWindow Class Reference

#include <juce_TopLevelWindow.h>

Inheritance diagram for juce::TopLevelWindow:
juce::Component juce::MouseListener juce::AlertWindow juce::ResizableWindow juce::KeyMappingEditorComponent::ChangeKeyButton::KeyEntryWindow juce::DocumentWindow juce::FileChooserDialogBox juce::DialogWindow juce::MultiDocumentPanelWindow juce::DefaultDialogWindow juce::Toolbar::CustomisationDialog

Public Member Functions

 TopLevelWindow (const String &name, bool addToDesktop)
 ~TopLevelWindow () override
bool isActiveWindow () const noexcept
void centreAroundComponent (Component *componentToCentreAround, int width, int height)
void setDropShadowEnabled (bool useShadow)
bool isDropShadowEnabled () const noexcept
void setUsingNativeTitleBar (bool useNativeTitleBar)
bool isUsingNativeTitleBar () const noexcept
void addToDesktop ()
void addToDesktop (int windowStyleFlags, void *nativeWindowToAttachTo=nullptr) override
Public Member Functions inherited from juce::Component
 Component () noexcept
 ~Component () override
 Component (const String &componentName) noexcept
String getName () const noexcept
virtual void setName (const String &newName)
String getComponentID () const noexcept
void setComponentID (const String &newID)
virtual void setVisible (bool shouldBeVisible)
bool isVisible () const noexcept
bool isShowing () const
void removeFromDesktop ()
bool isOnDesktop () const noexcept
ComponentPeergetPeer () const
virtual void userTriedToCloseWindow ()
virtual void minimisationStateChanged (bool isNowMinimised)
virtual float getDesktopScaleFactor () const
void toFront (bool shouldAlsoGainKeyboardFocus)
void toBack ()
void toBehind (Component *other)
void setAlwaysOnTop (bool shouldStayOnTop)
bool isAlwaysOnTop () const noexcept
int getX () const noexcept
int getY () const noexcept
int getWidth () const noexcept
int getHeight () const noexcept
int getRight () const noexcept
Point< intgetPosition () const noexcept
int getBottom () const noexcept
Rectangle< intgetBounds () const noexcept
Rectangle< intgetLocalBounds () const noexcept
Rectangle< intgetBoundsInParent () const noexcept
int getScreenX () const
int getScreenY () const
Point< intgetScreenPosition () const
Rectangle< intgetScreenBounds () const
Point< intgetLocalPoint (const Component *sourceComponent, Point< int > pointRelativeToSourceComponent) const
Point< float > getLocalPoint (const Component *sourceComponent, Point< float > pointRelativeToSourceComponent) const
Rectangle< intgetLocalArea (const Component *sourceComponent, Rectangle< int > areaRelativeToSourceComponent) const
Rectangle< float > getLocalArea (const Component *sourceComponent, Rectangle< float > areaRelativeToSourceComponent) const
Point< intlocalPointToGlobal (Point< int > localPoint) const
Point< float > localPointToGlobal (Point< float > localPoint) const
Rectangle< intlocalAreaToGlobal (Rectangle< int > localArea) const
Rectangle< float > localAreaToGlobal (Rectangle< float > localArea) const
void setTopLeftPosition (int x, int y)
void setTopLeftPosition (Point< int > newTopLeftPosition)
void setTopRightPosition (int x, int y)
void setSize (int newWidth, int newHeight)
void setBounds (int x, int y, int width, int height)
void setBounds (Rectangle< int > newBounds)
void setBoundsRelative (float proportionalX, float proportionalY, float proportionalWidth, float proportionalHeight)
void setBoundsRelative (Rectangle< float > proportionalArea)
void setBoundsInset (BorderSize< int > borders)
void setBoundsToFit (Rectangle< int > targetArea, Justification justification, bool onlyReduceInSize)
void setCentrePosition (int x, int y)
void setCentrePosition (Point< int > newCentrePosition)
void setCentreRelative (float x, float y)
void centreWithSize (int width, int height)
void setTransform (const AffineTransform &transform)
AffineTransform getTransform () const
bool isTransformed () const noexcept
int proportionOfWidth (float proportion) const noexcept
int proportionOfHeight (float proportion) const noexcept
int getParentWidth () const noexcept
int getParentHeight () const noexcept
Rectangle< intgetParentMonitorArea () const
int getNumChildComponents () const noexcept
ComponentgetChildComponent (int index) const noexcept
int getIndexOfChildComponent (const Component *child) const noexcept
const Array< Component * > & getChildren () const noexcept
ComponentfindChildWithID (StringRef componentID) const noexcept
void addChildComponent (Component *child, int zOrder=-1)
void addChildComponent (Component &child, int zOrder=-1)
void addAndMakeVisible (Component *child, int zOrder=-1)
void addAndMakeVisible (Component &child, int zOrder=-1)
void addChildAndSetID (Component *child, const String &componentID)
void removeChildComponent (Component *childToRemove)
ComponentremoveChildComponent (int childIndexToRemove)
void removeAllChildren ()
void deleteAllChildren ()
ComponentgetParentComponent () const noexcept
template<class TargetClass>
TargetClass * findParentComponentOfClass () const
ComponentgetTopLevelComponent () const noexcept
bool isParentOf (const Component *possibleChild) const noexcept
virtual void childrenChanged ()
virtual bool hitTest (int x, int y)
void setInterceptsMouseClicks (bool allowClicksOnThisComponent, bool allowClicksOnChildComponents) noexcept
void getInterceptsMouseClicks (bool &allowsClicksOnThisComponent, bool &allowsClicksOnChildComponents) const noexcept
bool contains (Point< int > localPoint)
bool contains (Point< float > localPoint)
bool reallyContains (Point< int > localPoint, bool returnTrueIfWithinAChild)
bool reallyContains (Point< float > localPoint, bool returnTrueIfWithinAChild)
ComponentgetComponentAt (int x, int y)
ComponentgetComponentAt (Point< int > position)
ComponentgetComponentAt (Point< float > position)
void repaint ()
void repaint (int x, int y, int width, int height)
void repaint (Rectangle< int > area)
void setBufferedToImage (bool shouldBeBuffered)
Image createComponentSnapshot (Rectangle< int > areaToGrab, bool clipImageToComponentBounds=true, float scaleFactor=1.0f)
void paintEntireComponent (Graphics &context, bool ignoreAlphaLevel)
void setPaintingIsUnclipped (bool shouldPaintWithoutClipping) noexcept
bool isPaintingUnclipped () const noexcept
void setComponentEffect (ImageEffectFilter *newEffect)
ImageEffectFiltergetComponentEffect () const noexcept
LookAndFeelgetLookAndFeel () const noexcept
void setLookAndFeel (LookAndFeel *newLookAndFeel)
virtual void lookAndFeelChanged ()
void sendLookAndFeelChange ()
void setOpaque (bool shouldBeOpaque)
bool isOpaque () const noexcept
void setBroughtToFrontOnMouseClick (bool shouldBeBroughtToFront) noexcept
bool isBroughtToFrontOnMouseClick () const noexcept
void setExplicitFocusOrder (int newFocusOrderIndex)
int getExplicitFocusOrder () const
void setFocusContainerType (FocusContainerType containerType) noexcept
bool isFocusContainer () const noexcept
bool isKeyboardFocusContainer () const noexcept
ComponentfindFocusContainer () const
ComponentfindKeyboardFocusContainer () const
void setWantsKeyboardFocus (bool wantsFocus) noexcept
bool getWantsKeyboardFocus () const noexcept
void setMouseClickGrabsKeyboardFocus (bool shouldGrabFocus)
bool getMouseClickGrabsKeyboardFocus () const noexcept
void grabKeyboardFocus ()
void giveAwayKeyboardFocus ()
bool hasKeyboardFocus (bool trueIfChildIsFocused) const
void moveKeyboardFocusToSibling (bool moveToNext)
virtual std::unique_ptr< ComponentTraversercreateFocusTraverser ()
virtual std::unique_ptr< ComponentTraversercreateKeyboardFocusTraverser ()
void setHasFocusOutline (bool hasFocusOutline) noexcept
bool hasFocusOutline () const noexcept
bool isEnabled () const noexcept
void setEnabled (bool shouldBeEnabled)
virtual void enablementChanged ()
float getAlpha () const noexcept
void setAlpha (float newAlpha)
virtual void alphaChanged ()
void setMouseCursor (const MouseCursor &cursorType)
virtual MouseCursor getMouseCursor ()
void updateMouseCursor () const
virtual void paint (Graphics &g)
virtual void paintOverChildren (Graphics &g)
void mouseMove (const MouseEvent &event) override
void mouseEnter (const MouseEvent &event) override
void mouseExit (const MouseEvent &event) override
void mouseDown (const MouseEvent &event) override
void mouseDrag (const MouseEvent &event) override
void mouseUp (const MouseEvent &event) override
void mouseDoubleClick (const MouseEvent &event) override
void mouseWheelMove (const MouseEvent &event, const MouseWheelDetails &wheel) override
void mouseMagnify (const MouseEvent &event, float scaleFactor) override
void setRepaintsOnMouseActivity (bool shouldRepaint) noexcept
void addMouseListener (MouseListener *newListener, bool wantsEventsForAllNestedChildComponents)
void removeMouseListener (MouseListener *listenerToRemove)
void addKeyListener (KeyListener *newListener)
void removeKeyListener (KeyListener *listenerToRemove)
virtual bool keyPressed (const KeyPress &key)
virtual bool keyStateChanged (bool isKeyDown)
virtual void modifierKeysChanged (const ModifierKeys &modifiers)
virtual void focusGained (FocusChangeType cause)
virtual void focusLost (FocusChangeType cause)
bool isMouseOver (bool includeChildren=false) const
bool isMouseButtonDown (bool includeChildren=false) const
bool isMouseOverOrDragging (bool includeChildren=false) const
Point< intgetMouseXYRelative () const
virtual void resized ()
virtual void moved ()
virtual void childBoundsChanged (Component *child)
virtual void parentSizeChanged ()
virtual void broughtToFront ()
void addComponentListener (ComponentListener *newListener)
void removeComponentListener (ComponentListener *listenerToRemove)
void postCommandMessage (int commandId)
virtual void handleCommandMessage (int commandId)
void enterModalState (bool takeKeyboardFocus=true, ModalComponentManager::Callback *callback=nullptr, bool deleteWhenDismissed=false)
void exitModalState (int returnValue)
bool isCurrentlyModal (bool onlyConsiderForemostModalComponent=true) const noexcept
bool isCurrentlyBlockedByAnotherModalComponent () const
virtual bool canModalEventBeSentToComponent (const Component *targetComponent)
virtual void inputAttemptWhenModal ()
NamedValueSetgetProperties () noexcept
const NamedValueSetgetProperties () const noexcept
Colour findColour (int colourID, bool inheritFromParent=false) const
void setColour (int colourID, Colour newColour)
void removeColour (int colourID)
bool isColourSpecified (int colourID) const
void copyAllExplicitColoursTo (Component &target) const
virtual void colourChanged ()
voidgetWindowHandle () const
PositionergetPositioner () const noexcept
void setPositioner (Positioner *newPositioner)
void setCachedComponentImage (CachedComponentImage *newCachedImage)
CachedComponentImagegetCachedComponentImage () const noexcept
void setViewportIgnoreDragFlag (bool ignoreDrag) noexcept
bool getViewportIgnoreDragFlag () const noexcept
String getTitle () const noexcept
void setTitle (const String &newTitle)
String getDescription () const noexcept
void setDescription (const String &newDescription)
String getHelpText () const noexcept
void setHelpText (const String &newHelpText)
void setAccessible (bool shouldBeAccessible)
bool isAccessible () const noexcept
AccessibilityHandlergetAccessibilityHandler ()
void invalidateAccessibilityHandler ()
void setFocusContainer (bool shouldBeFocusContainer) noexcept
void contains (int, int)=delete
Public Member Functions inherited from juce::MouseListener
virtual ~MouseListener ()=default

Static Public Member Functions

static int getNumTopLevelWindows () noexcept
static TopLevelWindowgetTopLevelWindow (int index) noexcept
static TopLevelWindowgetActiveTopLevelWindow () noexcept
Static Public Member Functions inherited from juce::Component
static float JUCE_CALLTYPE getApproximateScaleFactorForComponent (const Component *targetComponent)
static Component *JUCE_CALLTYPE getCurrentlyFocusedComponent () noexcept
static void JUCE_CALLTYPE unfocusAllComponents ()
static void JUCE_CALLTYPE beginDragAutoRepeat (int millisecondsBetweenCallbacks)
static bool JUCE_CALLTYPE isMouseButtonDownAnywhere () noexcept
static int JUCE_CALLTYPE getNumCurrentlyModalComponents () noexcept
static Component *JUCE_CALLTYPE getCurrentlyModalComponent (int index=0) noexcept

Protected Member Functions

virtual void activeWindowStatusChanged ()
void focusOfChildComponentChanged (FocusChangeType) override
void parentHierarchyChanged () override
virtual int getDesktopWindowStyleFlags () const
void recreateDesktopWindow ()
void visibilityChanged () override
Protected Member Functions inherited from juce::Component
virtual ComponentPeercreateNewPeer (int styleFlags, void *nativeWindowToAttachTo)

Private Member Functions

std::unique_ptr< AccessibilityHandlercreateAccessibilityHandler () override
void setWindowActive (bool)

Private Attributes

bool useDropShadow = true
bool useNativeTitleBar = true
bool isCurrentlyActive = false
std::unique_ptr< DropShadowershadower

Friends

class TopLevelWindowManager
class ResizableWindow

Additional Inherited Members

Public Types inherited from juce::Component
enum class  FocusContainerType { none , focusContainer , keyboardFocusContainer }
enum  FocusChangeType { focusChangedByMouseClick , focusChangedByTabKey , focusChangedDirectly }
Static Protected Member Functions inherited from juce::Component
static std::unique_ptr< AccessibilityHandlercreateIgnoredAccessibilityHandler (Component &)

Detailed Description

A base class for top-level windows.

This class is used for components that are considered a major part of your application - e.g. ResizableWindow, DocumentWindow, DialogWindow, AlertWindow, etc. Things like menus that pop up briefly aren't derived from it.

A TopLevelWindow is probably on the desktop, but this isn't mandatory - it could itself be the child of another component.

The class manages a list of all instances of top-level windows that are in use, and each one is also given the concept of being "active". The active window is one that is actively being used by the user. This isn't quite the same as the component with the keyboard focus, because there may be a popup menu or other temporary window which gets keyboard focus while the active top level window is unchanged.

A top-level window also has an optional drop-shadow.

See also
ResizableWindow, DocumentWindow, DialogWindow

@tags{GUI}

Constructor & Destructor Documentation

◆ TopLevelWindow()

juce::TopLevelWindow::TopLevelWindow ( const String & name,
bool addToDesktop )

Creates a TopLevelWindow.

Parameters
namethe name to give the component
addToDesktopif true, the window will be automatically added to the desktop; if false, you can use it as a child component

◆ ~TopLevelWindow()

juce::TopLevelWindow::~TopLevelWindow ( )
override

Destructor.

Member Function Documentation

◆ activeWindowStatusChanged()

void juce::TopLevelWindow::activeWindowStatusChanged ( )
protectedvirtual

This callback happens when this window becomes active or inactive.

See also
isActiveWindow

Reimplemented in juce::DocumentWindow, juce::MultiDocumentPanelWindow, and juce::ResizableWindow.

◆ addToDesktop() [1/2]

void juce::TopLevelWindow::addToDesktop ( )

Adds the window to the desktop using the default flags.

◆ addToDesktop() [2/2]

void juce::TopLevelWindow::addToDesktop ( int windowStyleFlags,
void * nativeWindowToAttachTo = nullptr )
overridevirtual

Makes this component appear as a window on the desktop.

Note that before calling this, you should make sure that the component's opacity is set correctly using setOpaque(). If the component is non-opaque, the windowing system will try to create a special transparent window for it, which will generally take a lot more CPU to operate (and might not even be possible on some platforms).

If the component is inside a parent component at the time this method is called, it will first be removed from that parent. Likewise if a component is on the desktop and is subsequently added to another component, it'll be removed from the desktop.

Parameters
windowStyleFlagsa combination of the flags specified in the ComponentPeer::StyleFlags enum, which define the window's characteristics.
nativeWindowToAttachTothis allows an OS object to be passed-in as the window in which the juce component should place itself. On Windows, this would be a HWND, a HIViewRef on the Mac. Not necessarily supported on all platforms, and best left as 0 unless you know what you're doing.
See also
removeFromDesktop, isOnDesktop, userTriedToCloseWindow, getPeer, ComponentPeer::setMinimised, ComponentPeer::StyleFlags, ComponentPeer::getStyleFlags, ComponentPeer::setFullScreen

Reimplemented from juce::Component.

◆ centreAroundComponent()

void juce::TopLevelWindow::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.

If your app has a few windows open and want to pop up a dialog box for one of them, you can use this to show it in front of the relevant parent window, which is a bit neater than just having it appear in the middle of the screen.

If componentToCentreAround is nullptr, then the currently active TopLevelWindow will be used instead. If no window is focused, it'll just default to the middle of the screen.

◆ createAccessibilityHandler()

std::unique_ptr< AccessibilityHandler > juce::TopLevelWindow::createAccessibilityHandler ( )
overrideprivatevirtual

Override this method to return a custom AccessibilityHandler for this component.

The default implementation creates and returns a AccessibilityHandler object with an unspecified role, meaning that it will be visible to accessibility clients but without a specific role, action callbacks or interfaces. To control how accessibility clients see and interact with your component subclass AccessibilityHandler, implement the desired behaviours, and return an instance of it from this method in your component subclass.

The accessibility handler you return here is guaranteed to be destroyed before its Component, so it's safe to store and use a reference back to the Component inside the AccessibilityHandler if necessary.

See also
getAccessibilityHandler

Reimplemented from juce::Component.

◆ focusOfChildComponentChanged()

void juce::TopLevelWindow::focusOfChildComponentChanged ( FocusChangeType cause)
overrideprotectedvirtual

Called to indicate a change in whether or not this component is the parent of the currently-focused component.

Essentially this is called when the return value of a call to hasKeyboardFocus (true) has changed. It happens when focus moves from one of this component's children (at any depth) to a component that isn't contained in this one, (or vice-versa). Note that this method does NOT get called to when focus simply moves from one of its child components to another.

See also
focusGained, setWantsKeyboardFocus, getCurrentlyFocusedComponent, hasKeyboardFocus

Reimplemented from juce::Component.

◆ getActiveTopLevelWindow()

TopLevelWindow * juce::TopLevelWindow::getActiveTopLevelWindow ( )
staticnoexcept

Returns the currently-active top level window. There might not be one, of course, so this can return nullptr.

◆ getDesktopWindowStyleFlags()

int juce::TopLevelWindow::getDesktopWindowStyleFlags ( ) const
protectedvirtual

◆ getNumTopLevelWindows()

int juce::TopLevelWindow::getNumTopLevelWindows ( )
staticnoexcept

Returns the number of TopLevelWindow objects currently in use.

See also
getTopLevelWindow

◆ getTopLevelWindow()

TopLevelWindow * juce::TopLevelWindow::getTopLevelWindow ( int index)
staticnoexcept

Returns one of the TopLevelWindow objects currently in use. The index is 0 to (getNumTopLevelWindows() - 1).

◆ isActiveWindow()

bool juce::TopLevelWindow::isActiveWindow ( ) const
inlinenoexcept

True if this is currently the TopLevelWindow that is actively being used.

This isn't quite the same as having keyboard focus, because the focus may be on a child component or a temporary pop-up menu, etc, while this window is still considered to be active.

See also
activeWindowStatusChanged

◆ isDropShadowEnabled()

bool juce::TopLevelWindow::isDropShadowEnabled ( ) const
inlinenoexcept

True if drop-shadowing is enabled.

◆ isUsingNativeTitleBar()

bool juce::TopLevelWindow::isUsingNativeTitleBar ( ) const
noexcept

Returns true if the window is currently using an OS-native title bar.

See also
setUsingNativeTitleBar

◆ parentHierarchyChanged()

void juce::TopLevelWindow::parentHierarchyChanged ( )
overrideprotectedvirtual

Called to indicate that the component's parents have changed.

When a component is added or removed from its parent, this method will be called on all of its children (recursively - so all children of its children will also be called as well).

Subclasses can override this if they need to react to this in some way.

See also
getParentComponent, isShowing, ComponentListener::componentParentHierarchyChanged

Reimplemented from juce::Component.

◆ recreateDesktopWindow()

void juce::TopLevelWindow::recreateDesktopWindow ( )
protected

◆ setDropShadowEnabled()

void juce::TopLevelWindow::setDropShadowEnabled ( bool useShadow)

Turns the drop-shadow on and off.

◆ setUsingNativeTitleBar()

void juce::TopLevelWindow::setUsingNativeTitleBar ( bool useNativeTitleBar)

Sets whether an OS-native title bar will be used, or a JUCE one.

See also
isUsingNativeTitleBar

◆ setWindowActive()

void juce::TopLevelWindow::setWindowActive ( bool isNowActive)
private

◆ visibilityChanged()

void juce::TopLevelWindow::visibilityChanged ( )
overrideprotectedvirtual

Called when this component's visibility changes.

See also
setVisible, isVisible

Reimplemented from juce::Component.

◆ ResizableWindow

friend class ResizableWindow
friend

◆ TopLevelWindowManager

friend class TopLevelWindowManager
friend

Member Data Documentation

◆ isCurrentlyActive

bool juce::TopLevelWindow::isCurrentlyActive = false
private

◆ shadower

std::unique_ptr<DropShadower> juce::TopLevelWindow::shadower
private

◆ useDropShadow

bool juce::TopLevelWindow::useDropShadow = true
private

◆ useNativeTitleBar

bool juce::TopLevelWindow::useNativeTitleBar = true
private

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