java.lang.Object
com.googlecode.lanterna.gui2.DefaultWindowManager
- All Implemented Interfaces:
WindowManager
The default window manager implementation used by Lanterna. New windows will be generally added in a tiled manner,
starting in the top-left corner and moving down-right as new windows are added. By using the various window hints
that are available you have some control over how the window manager will place and size the windows.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor, will create a window manager that usesDefaultWindowDecorationRenderer
for drawing window decorations, unless the current theme has an override.DefaultWindowManager
(WindowDecorationRenderer windowDecorationRenderer, TerminalSize initialScreenSize) Creates a newDefaultWindowManager
using a specifiedwindowDecorationRendererOverride
for drawing window decorations.DefaultWindowManager
(TerminalSize initialScreenSize) Creates a newDefaultWindowManager
using aDefaultWindowDecorationRenderer
for drawing window decorations, unless the current theme has an override. -
Method Summary
Modifier and TypeMethodDescriptiongetWindowDecorationRenderer
(Window window) Returns theWindowDecorationRenderer
for a particular windowboolean
Will be polled by the theWindowBasedTextGUI
to see if the window manager believes an update is required.void
onAdded
(WindowBasedTextGUI textGUI, Window window, List<Window> allWindows) Called whenever a window is added to theWindowBasedTextGUI
.void
onRemoved
(WindowBasedTextGUI textGUI, Window window, List<Window> allWindows) Called whenever a window is removed from aWindowBasedTextGUI
.protected void
prepareWindow
(TerminalSize screenSize, Window window) Called byDefaultWindowManager
when iterating through all windows to decide their size and position.void
prepareWindows
(WindowBasedTextGUI textGUI, List<Window> allWindows, TerminalSize screenSize) Called by the GUI system before iterating through all windows during the drawing process.
-
Field Details
-
windowDecorationRendererOverride
-
lastKnownScreenSize
-
-
Constructor Details
-
DefaultWindowManager
public DefaultWindowManager()Default constructor, will create a window manager that usesDefaultWindowDecorationRenderer
for drawing window decorations, unless the current theme has an override. Any size calculations done before the text GUI has actually been started and displayed on the terminal will assume the terminal size is 80x24. -
DefaultWindowManager
Creates a newDefaultWindowManager
using aDefaultWindowDecorationRenderer
for drawing window decorations, unless the current theme has an override. Any size calculations done before the text GUI has actually been started and displayed on the terminal will use the size passed in with theinitialScreenSize
parameter (ifnull
then size will be assumed to be 80x24)- Parameters:
initialScreenSize
- Size to assume the terminal has until the text GUI is started and can be notified of the correct size
-
DefaultWindowManager
public DefaultWindowManager(WindowDecorationRenderer windowDecorationRenderer, TerminalSize initialScreenSize) Creates a newDefaultWindowManager
using a specifiedwindowDecorationRendererOverride
for drawing window decorations. Any size calculations done before the text GUI has actually been started and displayed on the terminal will use the size passed in with theinitialScreenSize
parameter- Parameters:
windowDecorationRenderer
- Window decoration renderer to use when drawing windowsinitialScreenSize
- Size to assume the terminal has until the text GUI is started and can be notified of the correct size
-
-
Method Details
-
isInvalid
public boolean isInvalid()Description copied from interface:WindowManager
Will be polled by the theWindowBasedTextGUI
to see if the window manager believes an update is required. For example, it could be that there is no input, no events and none of the components are invalid, but the window manager decides for some other reason that the GUI needs to be updated, in that case you should returntrue
here. Please note that returningfalse
will not prevent updates from happening, it's just stating that the window manager isn't aware of some internal state change that would require an update.- Specified by:
isInvalid
in interfaceWindowManager
- Returns:
true
if the window manager believes the GUI needs to be update,false
otherwise
-
getWindowDecorationRenderer
Description copied from interface:WindowManager
Returns theWindowDecorationRenderer
for a particular window- Specified by:
getWindowDecorationRenderer
in interfaceWindowManager
- Parameters:
window
- Window to get the decoration renderer for- Returns:
WindowDecorationRenderer
for the window
-
onAdded
Description copied from interface:WindowManager
Called whenever a window is added to theWindowBasedTextGUI
. This gives the window manager an opportunity to setup internal state, if required, or decide on an initial position of the window- Specified by:
onAdded
in interfaceWindowManager
- Parameters:
textGUI
- GUI that the window was added toowindow
- Window that was addedallWindows
- All windows, including the new window, in the GUI
-
onRemoved
Description copied from interface:WindowManager
Called whenever a window is removed from aWindowBasedTextGUI
. This gives the window manager an opportunity to clear internal state if needed.- Specified by:
onRemoved
in interfaceWindowManager
- Parameters:
textGUI
- GUI that the window was removed fromwindow
- Window that was removedallWindows
- All windows, excluding the removed window, in the GUI
-
prepareWindows
public void prepareWindows(WindowBasedTextGUI textGUI, List<Window> allWindows, TerminalSize screenSize) Description copied from interface:WindowManager
Called by the GUI system before iterating through all windows during the drawing process. The window manager should ensure the position and decorated size of all windows at this point by usingWindow.setPosition(..)
andWindow.setDecoratedSize(..)
. Be sure to inspect the window hints assigned to the window, in case you want to try to honour them. Use theWindowManager.getWindowDecorationRenderer(Window)
method to get the currently assigned window decoration rendering class which can tell you the decorated size of a window given it's content size.- Specified by:
prepareWindows
in interfaceWindowManager
- Parameters:
textGUI
- Text GUI that is about to draw the windowsallWindows
- All windows that are going to be drawn, in the order they will be drawnscreenSize
- Size of the terminal that is available to draw on
-
prepareWindow
Called byDefaultWindowManager
when iterating through all windows to decide their size and position. If you overrideDefaultWindowManager
to add your own logic to how windows are placed on the screen, you can override this method and selectively choose which window to interfere with. Note that the two key properties that are read by the GUI system after preparing all windows are the position and decorated size. Your custom implementation should set these two fields directly on the window. You can infer the decorated size from the content size by using the window decoration renderer that is attached to the window manager.- Parameters:
screenSize
- Size of the terminal that is available to draw onwindow
- Window to prepare decorated size and position for
-