A base class for top-level windows. More...
Inherits Component.
Inherited by AlertWindow, and ResizableWindow.
Public Member Functions | |
| TopLevelWindow (const String &name, bool addToDesktop) | |
| Creates a TopLevelWindow. | |
| ~TopLevelWindow () | |
| Destructor. | |
| bool | isActiveWindow () const noexcept |
| True if this is currently the TopLevelWindow that is actively being used. | |
| 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 | setDropShadowEnabled (bool useShadow) |
| Turns the drop-shadow on and off. | |
| void | setUsingNativeTitleBar (bool useNativeTitleBar) |
| Sets whether an OS-native title bar will be used, or a Juce one. | |
| bool | isUsingNativeTitleBar () const noexcept |
| Returns true if the window is currently using an OS-native title bar. | |
| virtual void | addToDesktop (int windowStyleFlags, void *nativeWindowToAttachTo=nullptr) |
| Makes this component appear as a window on the desktop. | |
Static Public Member Functions | |
| static int | getNumTopLevelWindows () noexcept |
| Returns the number of TopLevelWindow objects currently in use. | |
| static TopLevelWindow * | getTopLevelWindow (int index) noexcept |
| Returns one of the TopLevelWindow objects currently in use. | |
| static TopLevelWindow * | getActiveTopLevelWindow () noexcept |
| Returns the currently-active top level window. | |
Protected Member Functions | |
| virtual void | activeWindowStatusChanged () |
| This callback happens when this window becomes active or inactive. | |
| void | focusOfChildComponentChanged (FocusChangeType cause) |
| Called to indicate that one of this component's children has been focused or unfocused. | |
| void | parentHierarchyChanged () |
| Called to indicate that the component's parents have changed. | |
| virtual int | getDesktopWindowStyleFlags () const |
| void | recreateDesktopWindow () |
| void | visibilityChanged () |
| Called when this component's visiblility changes. | |
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.
| TopLevelWindow::TopLevelWindow | ( | const String & | name, |
| bool | addToDesktop | ||
| ) |
Creates a TopLevelWindow.
| name | the name to give the component |
| addToDesktop | if true, the window will be automatically added to the desktop; if false, you can use it as a child component |
| TopLevelWindow::~TopLevelWindow | ( | ) |
Destructor.
| bool TopLevelWindow::isActiveWindow | ( | ) | const |
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.
| void 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 relevent parent window, which is a bit neater than just having it appear in the middle of the screen.
If componentToCentreAround is 0, then the currently active TopLevelWindow will be used instead. If no window is focused, it'll just default to the middle of the screen.
| void TopLevelWindow::setDropShadowEnabled | ( | bool | useShadow ) |
Turns the drop-shadow on and off.
| void TopLevelWindow::setUsingNativeTitleBar | ( | bool | useNativeTitleBar ) |
Sets whether an OS-native title bar will be used, or a Juce one.
| bool TopLevelWindow::isUsingNativeTitleBar | ( | ) | const |
Returns true if the window is currently using an OS-native title bar.
References Component::isOnDesktop().
| static int TopLevelWindow::getNumTopLevelWindows | ( | ) | [static] |
Returns the number of TopLevelWindow objects currently in use.
| static TopLevelWindow* TopLevelWindow::getTopLevelWindow | ( | int | index ) | [static] |
Returns one of the TopLevelWindow objects currently in use.
The index is 0 to (getNumTopLevelWindows() - 1).
| static TopLevelWindow* TopLevelWindow::getActiveTopLevelWindow | ( | ) | [static] |
Returns the currently-active top level window.
There might not be one, of course, so this can return 0.
| virtual void TopLevelWindow::addToDesktop | ( | int | windowStyleFlags, |
| void * | nativeWindowToAttachTo = nullptr |
||
| ) | [virtual] |
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 be first be removed from that parent. Likewise if a component on the desktop is subsequently added to another component, it'll be removed from the desktop.
| windowStyleFlags | a combination of the flags specified in the ComponentPeer::StyleFlags enum, which define the window's characteristics. |
| nativeWindowToAttachTo | this 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 |
Reimplemented from Component.
| virtual void TopLevelWindow::activeWindowStatusChanged | ( | ) | [protected, virtual] |
This callback happens when this window becomes active or inactive.
Reimplemented in MultiDocumentPanelWindow, and ResizableWindow.
| void TopLevelWindow::focusOfChildComponentChanged | ( | FocusChangeType | cause ) | [protected, virtual] |
Called to indicate that one of this component's children has been focused or unfocused.
Essentially this means that 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).
Reimplemented from Component.
| void TopLevelWindow::parentHierarchyChanged | ( | ) | [protected, virtual] |
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.
Reimplemented from Component.
| virtual int TopLevelWindow::getDesktopWindowStyleFlags | ( | ) | const [protected, virtual] |
Reimplemented in AlertWindow, and ResizableWindow.
| void TopLevelWindow::recreateDesktopWindow | ( | ) | [protected] |
| void TopLevelWindow::visibilityChanged | ( | ) | [protected, virtual] |
Called when this component's visiblility changes.
Reimplemented from Component.
Reimplemented in ResizableWindow.