BasicWindow
, DialogWindow
public abstract class AbstractWindow extends AbstractBasePane<Window> implements Window
BasicWindow
and adding components to it.AbstractBasePane.ContentHolder
Window.Hint
contentHolder, interactableLookupMap
Constructor | 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 | Description |
---|---|---|
void |
addWindowListener(WindowListener windowListener) |
Adds a
WindowListener to this Window . |
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. row and column offset from the top-left corner of the
terminal into a position relative to the top-left corner of the window.
|
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.
|
WindowPostRenderer |
getPostRenderer() |
Returns a post-renderer the GUI system should invoke after the window has been drawn.
|
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 |
removeWindowListener(WindowListener windowListener) |
Removes a
WindowListener from this Window . |
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 |
setFixedSize(TerminalSize size) |
Calling this method will add the FIXED_SIZE window hint (if it wasn't present already) and attempt to force the
window to always have the size specified.
|
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) |
Deprecated.
|
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 |
setWindowPostRenderer(WindowPostRenderer windowPostRenderer) |
Sets the post-renderer to use for this window.
|
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.
|
addBasePaneListener, getBasePaneListeners, getComponent, getCursorPosition, getFocusedInteractable, getTheme, invalidate, isInvalid, removeBasePaneListener, setComponent, setEnableDirectionBasedMovements, setFocusedInteractable, setFocusedInteractable, setStrictFocusChange, setTheme
getTheme, setEnableDirectionBasedMovements, setStrictFocusChange, setTheme
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getComponent, getCursorPosition, getFocusedInteractable, invalidate, isInvalid, setComponent, setFocusedInteractable
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<Window>
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 WindowPostRenderer getPostRenderer()
Window
null
, the GUI system will fall back to
it's own global override and after that to the current theme. If these are all null
, no post-rendering
is done.getPostRenderer
in interface Window
WindowPostRenderer
to invoke after this window is drawn, or null
fallback to the GUI
system's default.public void addWindowListener(WindowListener windowListener)
Window
WindowListener
to this Window
. If it has already been added, the call will do nothing.addWindowListener
in interface Window
windowListener
- Listener to attach to this Window
public void removeWindowListener(WindowListener windowListener)
Window
WindowListener
from this Window
. If the listener isn't in the list of listeners, this
call does nothing.removeWindowListener
in interface Window
windowListener
- Listener to remove from this Window
public void setWindowPostRenderer(WindowPostRenderer windowPostRenderer)
windowPostRenderer
- Window post-renderer to assign to this windowpublic 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
@Deprecated public void setSize(TerminalSize size)
Window
Important: if you are writing your own WindowManager
, you should call setDecoratedSize
instead of this when decided the size of the window.
public void setFixedSize(TerminalSize size)
Window
WindowManager
if this size and hint
are going to be honored.setFixedSize
in interface Window
size
- New size of your fixed-size windowpublic final TerminalSize getDecoratedSize()
Window
setDecoratedSize(..)
.getDecoratedSize
in interface Window
public final void setDecoratedSize(TerminalSize decoratedSize)
Window
getDecoratedSize()
call incorrect until
the next redraw.
Important: if you are writing your own WindowManager
, you should call this method instead of
setSize
when decided the size of the window.
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 © 2020. All rights reserved.