public abstract class AbstractWindow extends AbstractBasePane implements Window
BasicWindow
and adding components to it.AbstractBasePane.ContentHolder
Window.Hint
contentHolder, interactableLookupMap
Constructor and Description |
---|
AbstractWindow()
Default constructor, this creates a window with no title
|
AbstractWindow(String title)
Creates a window with a specific title that will (probably) be drawn in the window decorations
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes the window, which will remove it from the GUI
|
void |
draw(TextGUIGraphics graphics)
Called by the GUI system (or something imitating the GUI system) to draw the root container.
|
TerminalPosition |
fromGlobal(TerminalPosition globalPosition)
Returns a position expressed in global coordinates, i.e.
|
TerminalSize |
getDecoratedSize()
Returns the last known size of the window including window decorations put on by the window manager.
|
Set<Window.Hint> |
getHints()
Returns a set of window hints that can be used by the text gui system, the window manager or any other part that
is interacting with windows.
|
TerminalPosition |
getPosition()
Returns the position of the window, as last specified by the window manager.
|
TerminalSize |
getPreferredSize()
Returns the size this window would like to be
|
TerminalSize |
getSize()
Returns the last known size of the window.
|
WindowBasedTextGUI |
getTextGUI()
Returns the TextGUI this BasePane belongs to or
null if none. |
String |
getTitle()
This method returns the title of the window, which is normally drawn at the top-left corder of the window
decoration, but depending on the
WindowDecorationRenderer used by the TextGUI |
boolean |
handleInput(KeyStroke key)
Called by the GUI system to delegate a keyboard input event.
|
boolean |
isVisible()
This values is optionally used by the window manager to decide if the windows should be drawn or not.
|
void |
setCloseWindowWithEscape(boolean closeWindowWithEscape)
Setting this property to
true will cause pressing the ESC key to close the window. |
void |
setContentOffset(TerminalPosition offset)
This method is called by the GUI system to update the window on, as of the last drawing operation, the distance
from the top-left position of the window including decorations to the top-left position of the actual content
area.
|
void |
setDecoratedSize(TerminalSize decoratedSize)
This method is called by the GUI system to update the window on how large it is, counting window decorations too.
|
void |
setHints(Collection<Window.Hint> hints)
Updates the set of active hints for this window.
|
void |
setPosition(TerminalPosition topLeft)
This method is called by the GUI system to update the window on where the window manager placed it.
|
void |
setSize(TerminalSize size)
This method is called by the GUI system to update the window on how large it is, excluding window decorations.
|
void |
setTextGUI(WindowBasedTextGUI textGUI)
DON'T CALL THIS METHOD YOURSELF, it is called automatically by the TextGUI system when you add a window.
|
void |
setTitle(String title)
Alters the title of the window to the supplied string
|
void |
setVisible(boolean visible)
This values is optionally used by the window manager to decide if the windows should be drawn or not.
|
TerminalPosition |
toGlobal(TerminalPosition localPosition)
Returns a position in the window's local coordinate space to global coordinates
|
void |
waitUntilClosed()
Waits for the window to close.
|
getComponent, getCursorPosition, getFocusedInteractable, invalidate, isInvalid, setComponent, setEnableDirectionBasedMovements, setFocusedInteractable, setFocusedInteractable, setStrictFocusChange
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getComponent, getCursorPosition, getFocusedInteractable, invalidate, isInvalid, setComponent, setFocusedInteractable
setEnableDirectionBasedMovements, setStrictFocusChange
public AbstractWindow()
public AbstractWindow(String title)
title
- Title of this windowpublic void setCloseWindowWithEscape(boolean closeWindowWithEscape)
true
will cause pressing the ESC key to close the window. This used to be the
default behaviour of lanterna 3 during the development cycle but is not longer the case. You are encouraged to
put proper buttons or other kind of components to clearly mark to the user how to close the window instead of
magically taking ESC, but sometimes it can be useful (when doing testing, for example) to enable this mode.closeWindowWithEscape
- If true
, this window will self-close if you press ESC keypublic void setTextGUI(WindowBasedTextGUI textGUI)
Window
setTextGUI
in interface Window
textGUI
- TextGUI this window belongs to from now onpublic WindowBasedTextGUI getTextGUI()
BasePane
null
if none. One example of when this method returns
null
is when calling it on a Window that hasn't been displayed yet.getTextGUI
in interface BasePane
getTextGUI
in interface Window
public void setTitle(String title)
title
- New title of the windowpublic String getTitle()
Window
WindowDecorationRenderer
used by the TextGUI
public boolean isVisible()
Window
public void setVisible(boolean visible)
Window
setVisible
in interface Window
visible
- whether the window should be visible or notpublic void draw(TextGUIGraphics graphics)
BasePane
public boolean handleInput(KeyStroke key)
BasePane
false
so that the GUI system can take further decisions on what to do with it.handleInput
in interface BasePane
handleInput
in interface Window
handleInput
in class AbstractBasePane
key
- Keyboard inputtrue
If the root container could handle the input, false otherwisepublic TerminalPosition toGlobal(TerminalPosition localPosition)
Window
public TerminalPosition fromGlobal(TerminalPosition globalPosition)
Window
fromGlobal(toGlobal(..))
should return the exact same position.fromGlobal
in interface BasePane
fromGlobal
in interface Window
globalPosition
- Position expressed in global coordinates to translate to local coordinates of this Windowpublic TerminalSize getPreferredSize()
Window
getPreferredSize
in interface Window
public void setHints(Collection<Window.Hint> hints)
Window
public Set<Window.Hint> getHints()
Window
public final TerminalPosition getPosition()
Window
getPosition
in interface Window
public final void setPosition(TerminalPosition topLeft)
Window
getPosition()
call incorrect until the next redraw.setPosition
in interface Window
topLeft
- Global coordinates of the top-left corner of the windowpublic final TerminalSize getSize()
Window
public void setSize(TerminalSize size)
Window
public final TerminalSize getDecoratedSize()
Window
setDecoratedSize(..)
.getDecoratedSize
in interface Window
public final void setDecoratedSize(TerminalSize decoratedSize)
Window
getDecoratedSize()
call incorrect until
the next redraw.setDecoratedSize
in interface Window
decoratedSize
- Size of the window, including window decorationspublic void setContentOffset(TerminalPosition offset)
Window
setContentOffset
in interface Window
offset
- Offset from the top-left corner of the window (including decorations) to the top-left corner of
the content area.public void close()
Window
public void waitUntilClosed()
Window
waitUntilClosed
in interface Window
Copyright © 2016. All rights reserved.