AbstractWindow
, ActionListDialog
, BasicWindow
, DialogWindow
, FileDialog
, ListSelectDialog
, MessageDialog
, TextInputDialog
, WaitingDialog
public interface Window extends BasePane
Modifier and Type | Interface | Description |
---|---|---|
static class |
Window.Hint |
Window hints are meta-data stored along with the window that can be used to give the GUI system some ideas of how
this window wants to be treated.
|
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 window.
|
TerminalPosition |
fromGlobal(TerminalPosition position) |
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.
|
Component |
getComponent() |
Returns the component which is the top-level in the component hierarchy inside this window.
|
TerminalPosition |
getCursorPosition() |
Returns the position of where to put the terminal cursor according to this window.
|
TerminalSize |
getDecoratedSize() |
Returns the last known size of the window including window decorations put on by the window manager.
|
Interactable |
getFocusedInteractable() |
Returns the component in the window that currently has input focus.
|
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's window manager when it has decided that this window should receive the keyboard input.
|
void |
invalidate() |
Invalidates the whole window (including all of its child components) which will cause it to be recalculated
and redrawn.
|
boolean |
isInvalid() |
This method is used to determine if the window requires re-drawing.
|
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 |
setComponent(Component component) |
Sets the top-level component in the window, this will be the only component unless it's a container of some kind
that you add child-components to.
|
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 |
setFocusedInteractable(Interactable interactable) |
Sets the component currently in focus within this window, or sets no component in focus if
null
is passed in. |
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.
This method is deprecated now as it probably doesn't do what you think. Please use
setFixedSize or setDecoratedSize instead, depending on what you are trying to do. |
void |
setTextGUI(WindowBasedTextGUI textGUI) |
DON'T CALL THIS METHOD YOURSELF, it is called automatically by the TextGUI system when you add a 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.
|
getTheme, setEnableDirectionBasedMovements, setStrictFocusChange, setTheme
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
void setTextGUI(WindowBasedTextGUI textGUI)
textGUI
- TextGUI this window belongs to from now onString getTitle()
WindowDecorationRenderer
used by the TextGUI
boolean isVisible()
void setVisible(boolean visible)
visible
- whether the window should be visible or notboolean isInvalid()
void invalidate()
invalidate
in interface BasePane
TerminalSize getPreferredSize()
void close()
void setHints(Collection<Window.Hint> hints)
hints
- Set of hints to be active for this windowSet<Window.Hint> getHints()
TerminalPosition getPosition()
void setPosition(TerminalPosition topLeft)
getPosition()
call incorrect until the next redraw.topLeft
- Global coordinates of the top-left corner of the windowTerminalSize getSize()
@Deprecated void setSize(TerminalSize size)
setFixedSize
or setDecoratedSize
instead, depending on what you are trying to do.
Important: if you are writing your own WindowManager
, you should call setDecoratedSize
instead of this when decided the size of the window.
size
- New size of your fixed-size windowvoid setFixedSize(TerminalSize size)
WindowManager
if this size and hint
are going to be honored.size
- New size of your fixed-size windowTerminalSize getDecoratedSize()
setDecoratedSize(..)
.void setDecoratedSize(TerminalSize decoratedSize)
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.
decoratedSize
- Size of the window, including window decorationsvoid setContentOffset(TerminalPosition offset)
offset
- Offset from the top-left corner of the window (including decorations) to the top-left corner of
the content area.void waitUntilClosed()
WindowPostRenderer getPostRenderer()
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.WindowPostRenderer
to invoke after this window is drawn, or null
fallback to the GUI
system's default.void addWindowListener(WindowListener windowListener)
WindowListener
to this Window
. If it has already been added, the call will do nothing.windowListener
- Listener to attach to this Window
void removeWindowListener(WindowListener windowListener)
WindowListener
from this Window
. If the listener isn't in the list of listeners, this
call does nothing.windowListener
- Listener to remove from this Window
void draw(TextGUIGraphics graphics)
boolean handleInput(KeyStroke key)
false
so that the window manager can take
further decisions on what to do with it.handleInput
in interface BasePane
key
- Keyboard inputtrue
If the window could handle the input, false otherwisevoid setComponent(Component component)
setComponent
in interface BasePane
setComponent
in interface Composite
component
- Component to use as the top-level object in the WindowComponent getComponent()
getComponent
in interface BasePane
getComponent
in interface Composite
Interactable getFocusedInteractable()
getFocusedInteractable
in interface BasePane
void setFocusedInteractable(Interactable interactable)
null
is passed in.setFocusedInteractable
in interface BasePane
interactable
- Interactable to focus, or null
to clear focusTerminalPosition getCursorPosition()
null
if no component has focus or if the window doesn't
want the cursor to be visible. Note that the coordinates are in local coordinate space, relative to the top-left
corner of the window. You can use your TextGUI implementation to translate these to global coordinates.getCursorPosition
in interface BasePane
null
if the cursor shouldn't be visibleTerminalPosition toGlobal(TerminalPosition localPosition)
TerminalPosition fromGlobal(TerminalPosition position)
fromGlobal(toGlobal(..))
should return the exact same position.fromGlobal
in interface BasePane
position
- Position expressed in global coordinates to translate to local coordinates of this WindowCopyright © 2020. All rights reserved.