public interface Window extends BasePane
Modifier and Type | Interface and 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 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 window.
|
TerminalPosition |
fromGlobal(TerminalPosition position)
Returns a position expressed in global coordinates, i.e.
|
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.
|
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 |
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 |
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)
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 |
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.
|
setEnableDirectionBasedMovements, setStrictFocusChange
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()
void setSize(TerminalSize size)
size
- New size of the windowTerminalSize getDecoratedSize()
setDecoratedSize(..)
.void setDecoratedSize(TerminalSize decoratedSize)
getDecoratedSize()
call incorrect until
the next redraw.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()
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 © 2016. All rights reserved.