TextGUI
, WindowBasedTextGUI
public class MultiWindowTextGUI extends AbstractTextGUI implements WindowBasedTextGUI
Note: This class used to always wrap the Screen
object with a VirtualScreen
to ensure that the UI
always fits. As of 3.1.0, we don't do this anymore so when you create the MultiWindowTextGUI
you can wrap
the screen parameter yourself if you want to keep this behavior.
TextGUI.Listener
Constructor | Description |
---|---|
MultiWindowTextGUI(TextGUIThreadFactory guiThreadFactory,
Screen screen) |
Creates a new
MultiWindowTextGUI that uses the specified Screen as the backend for all drawing
operations. |
MultiWindowTextGUI(TextGUIThreadFactory guiThreadFactory,
Screen screen,
WindowManager windowManager) |
Creates a new
MultiWindowTextGUI that uses the specified Screen as the backend for all drawing
operations. |
MultiWindowTextGUI(TextGUIThreadFactory guiThreadFactory,
Screen screen,
WindowManager windowManager,
WindowPostRenderer postRenderer,
Component background) |
Creates a new
MultiWindowTextGUI that uses the specified Screen as the backend for all drawing
operations. |
MultiWindowTextGUI(Screen screen) |
Creates a new
MultiWindowTextGUI that uses the specified Screen as the backend for all drawing
operations. |
MultiWindowTextGUI(Screen screen,
WindowManager windowManager,
Component background) |
Creates a new
MultiWindowTextGUI that uses the specified Screen as the backend for all drawing
operations. |
MultiWindowTextGUI(Screen screen,
WindowManager windowManager,
WindowPostRenderer postRenderer,
Component background) |
Creates a new
MultiWindowTextGUI that uses the specified Screen as the backend for all drawing
operations. |
MultiWindowTextGUI(Screen screen,
TextColor backgroundColor) |
Deprecated.
It's preferred to use a custom background component if you want to customize the background color,
or you should change the theme. Using this constructor won't work well with theming.
|
Modifier and Type | Method | Description |
---|---|---|
WindowBasedTextGUI |
addWindow(Window window) |
Adds a window to the TextGUI system, depending on the window manager this window may or may not be immediately
visible.
|
WindowBasedTextGUI |
addWindowAndWait(Window window) |
Adds a window to the TextGUI system, depending on the window manager this window may or may not be immediately
visible.
|
protected void |
changeWindowHintsForDragged(Window window) |
In order for window to be draggable, it would no longer be CENTERED.
|
WindowBasedTextGUI |
cycleActiveWindow(boolean reverse) |
Switches the active window by cyclically shuffling the window list.
|
protected void |
drawGUI(TextGUIGraphics graphics) |
Draws the entire GUI using a
TextGUIGraphics object |
Window |
getActiveWindow() |
Returns the window which the TextGUI considers the active one at the time of the method call.
|
BasePane |
getBackgroundPane() |
Returns the container for the background, which works as a single large component that takes up the whole
terminal area and is always behind all windows.
|
TerminalPosition |
getCursorPosition() |
Top-level method for drilling in to the GUI and figuring out, in global coordinates, where to place the text
cursor on the screen at this time.
|
Interactable |
getFocusedInteractable() |
Returns the interactable component currently in focus
|
WindowManager |
getWindowManager() |
Returns the window manager that is currently controlling this TextGUI.
|
WindowPostRenderer |
getWindowPostRenderer() |
Returns the
WindowPostRenderer for this WindowBasedTextGUI |
Collection<Window> |
getWindows() |
Returns a list of all windows currently in the TextGUI.
|
boolean |
handleInput(KeyStroke keyStroke) |
This method should take the user input and feed it to the focused component for handling.
|
protected void |
ifMouseDownPossiblyChangeActiveWindow(KeyStroke keyStroke) |
|
protected void |
ifMouseDownPossiblyStartTitleDrag(KeyStroke keyStroke) |
|
protected void |
ifMouseDragPossiblyMoveWindow(KeyStroke keyStroke) |
|
boolean |
isEOFWhenNoWindows() |
Returns whether the TextGUI should return EOF when you try to read input while there are no windows in the window
manager.
|
boolean |
isPendingUpdate() |
This method can be used to determine if any component has requested a redraw.
|
WindowBasedTextGUI |
moveToBottom(Window window) |
|
WindowBasedTextGUI |
moveToTop(Window window) |
Windows are internally stored as a stack and newer windows are added at the top of the stack.
|
protected KeyStroke |
readKeyStroke() |
Reads one key from the input queue, blocking or non-blocking depending on if blocking I/O has been enabled.
|
WindowBasedTextGUI |
removeWindow(Window window) |
Removes a window from the TextGUI.
|
MultiWindowTextGUI |
setActiveWindow(Window activeWindow) |
Selects a particular window to be considered 'active' and receive all input events
|
void |
setEOFWhenNoWindows(boolean eofWhenNoWindows) |
Sets whether the TextGUI should return EOF when you try to read input while there are no windows in the window
manager.
|
void |
setVirtualScreenEnabled(boolean virtualScreenEnabled) |
Deprecated.
This method don't do anything anymore (as of 3.1.0)
|
void |
updateScreen() |
Updates the screen, to make any changes visible to the user.
|
void |
waitForWindowToClose(Window window) |
Waits for the specified window to be closed
|
addListener, fireUnhandledKeyStroke, getGUIThread, getScreen, getTheme, invalidate, isBlockingIO, pollInput, processInput, removeListener, setBlockingIO, setTheme
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
addListener, getGUIThread, getScreen, getTheme, processInput, removeListener, setTheme
public MultiWindowTextGUI(Screen screen)
MultiWindowTextGUI
that uses the specified Screen
as the backend for all drawing
operations. The background area of the GUI will be a solid color, depending on theme (default is blue). The
current thread will be used as the GUI thread for all Lanterna library operations.screen
- Screen to use as the backend for drawing operationspublic MultiWindowTextGUI(TextGUIThreadFactory guiThreadFactory, Screen screen)
MultiWindowTextGUI
that uses the specified Screen
as the backend for all drawing
operations. The background area of the GUI will be a solid color, depending on theme (default is blue). This
constructor allows you control the threading model for the UI.guiThreadFactory
- Factory implementation to use when creating the TextGUIThread
screen
- Screen to use as the backend for drawing operationspublic MultiWindowTextGUI(TextGUIThreadFactory guiThreadFactory, Screen screen, WindowManager windowManager)
MultiWindowTextGUI
that uses the specified Screen
as the backend for all drawing
operations. The background area of the GUI will be a solid color, depending on theme (default is blue). This
constructor allows you control the threading model for the UI and set a custom WindowManager
.guiThreadFactory
- Factory implementation to use when creating the TextGUIThread
screen
- Screen to use as the backend for drawing operationswindowManager
- Custom window manager to use@Deprecated public MultiWindowTextGUI(Screen screen, TextColor backgroundColor)
MultiWindowTextGUI
that uses the specified Screen
as the backend for all drawing
operations. The background area of the GUI is a solid color as decided by the backgroundColor
parameter.screen
- Screen to use as the backend for drawing operationsbackgroundColor
- Color to use for the GUI backgroundpublic MultiWindowTextGUI(Screen screen, WindowManager windowManager, Component background)
MultiWindowTextGUI
that uses the specified Screen
as the backend for all drawing
operations. The background area of the GUI will be the component supplied instead of the usual backdrop. This
constructor allows you to set a custom WindowManager
instead of DefaultWindowManager
.screen
- Screen to use as the backend for drawing operationswindowManager
- Window manager implementation to usebackground
- Component to use as the background of the GUI, behind all the windowspublic MultiWindowTextGUI(Screen screen, WindowManager windowManager, WindowPostRenderer postRenderer, Component background)
MultiWindowTextGUI
that uses the specified Screen
as the backend for all drawing
operations. The background area of the GUI will be the component supplied instead of the usual backdrop. This
constructor allows you to set a custom WindowManager
instead of DefaultWindowManager
as well
as a custom WindowPostRenderer
that can be used to tweak the appearance of any window.screen
- Screen to use as the backend for drawing operationswindowManager
- Window manager implementation to usepostRenderer
- WindowPostRenderer
object to invoke after each window has been drawnbackground
- Component to use as the background of the GUI, behind all the windowspublic MultiWindowTextGUI(TextGUIThreadFactory guiThreadFactory, Screen screen, WindowManager windowManager, WindowPostRenderer postRenderer, Component background)
MultiWindowTextGUI
that uses the specified Screen
as the backend for all drawing
operations. The background area of the GUI will be the component supplied instead of the usual backdrop. This
constructor allows you to set a custom WindowManager
instead of DefaultWindowManager
as well
as a custom WindowPostRenderer
that can be used to tweak the appearance of any window. This constructor
also allows you to control the threading model for the UI.guiThreadFactory
- Factory implementation to use when creating the TextGUIThread
screen
- Screen to use as the backend for drawing operationswindowManager
- Window manager implementation to usepostRenderer
- WindowPostRenderer
object to invoke after each window has been drawnbackground
- Component to use as the background of the GUI, behind all the windowspublic boolean isPendingUpdate()
TextGUI
true
, you may want to call updateScreen()
.isPendingUpdate
in interface TextGUI
isPendingUpdate
in class AbstractTextGUI
true
if this TextGUI has a change and is waiting for someone to call updateScreen()
public void updateScreen() throws IOException
TextGUI
updateScreen
in interface TextGUI
updateScreen
in class AbstractTextGUI
IOException
- In case there was an underlying I/O errorprotected KeyStroke readKeyStroke() throws IOException
AbstractTextGUI
setBlockingIO(true)
.readKeyStroke
in class AbstractTextGUI
KeyStroke
or null
if blocking I/O is disabled and there was
no input waitingIOException
- In case of an I/O error while reading inputprotected void drawGUI(TextGUIGraphics graphics)
AbstractTextGUI
TextGUIGraphics
objectdrawGUI
in class AbstractTextGUI
graphics
- Graphics object to draw usingpublic TerminalPosition getCursorPosition()
AbstractTextGUI
getCursorPosition
in class AbstractTextGUI
null
if the cursor should be hiddenpublic void setEOFWhenNoWindows(boolean eofWhenNoWindows)
eofWhenNoWindows
- Should the GUI return EOF when there are no windows leftpublic boolean isEOFWhenNoWindows()
@Deprecated public void setVirtualScreenEnabled(boolean virtualScreenEnabled)
setVirtualScreenEnabled
in interface TextGUI
virtualScreenEnabled
- Not used anymorepublic Interactable getFocusedInteractable()
TextGUI
getFocusedInteractable
in interface TextGUI
public boolean handleInput(KeyStroke keyStroke)
AbstractTextGUI
handleInput
in class AbstractTextGUI
keyStroke
- KeyStroke
representing the user inputtrue
if the input was recognized and handled by the GUI, indicating that the GUI should be redrawnprotected void ifMouseDownPossiblyChangeActiveWindow(KeyStroke keyStroke)
protected void ifMouseDownPossiblyStartTitleDrag(KeyStroke keyStroke)
protected void ifMouseDragPossiblyMoveWindow(KeyStroke keyStroke)
protected void changeWindowHintsForDragged(Window window)
public WindowManager getWindowManager()
WindowBasedTextGUI
getWindowManager
in interface WindowBasedTextGUI
public WindowBasedTextGUI addWindow(Window window)
WindowBasedTextGUI
addWindowAndWait(..)
.
Windows are internally stored as a stack and newer windows are added at the top of the stack. The GUI system will
render windows in a predictable order from bottom to top. You can modify the stack by using
moveToTop(..)
to move a Window from its current position in the stack to the top.addWindow
in interface WindowBasedTextGUI
window
- Window to add to the GUIpublic WindowBasedTextGUI addWindowAndWait(Window window)
WindowBasedTextGUI
addWindow(..)
. This method call is useful for modal dialogs that requires a certain user input
before the application can continue.
Windows are internally stored as a stack and newer windows are added at the top of the stack. The GUI system will
render windows in a predictable order from bottom to top. You can modify the stack by using
moveToTop(..)
to move a Window from its current position in the stack to the top.addWindowAndWait
in interface WindowBasedTextGUI
window
- Window to add to the GUIpublic WindowBasedTextGUI removeWindow(Window window)
WindowBasedTextGUI
removeWindow
in interface WindowBasedTextGUI
window
- Window to closepublic void waitForWindowToClose(Window window)
WindowBasedTextGUI
waitForWindowToClose
in interface WindowBasedTextGUI
window
- Window to wait forpublic Collection<Window> getWindows()
WindowBasedTextGUI
getWindows
in interface WindowBasedTextGUI
public MultiWindowTextGUI setActiveWindow(Window activeWindow)
WindowBasedTextGUI
setActiveWindow
in interface WindowBasedTextGUI
activeWindow
- Window to become active and receive input eventspublic Window getActiveWindow()
WindowBasedTextGUI
getActiveWindow
in interface WindowBasedTextGUI
null
public BasePane getBackgroundPane()
WindowBasedTextGUI
getBackgroundPane
in interface WindowBasedTextGUI
BasePane
used by this WindowBasedTextGUI
public WindowPostRenderer getWindowPostRenderer()
WindowBasedTextGUI
WindowPostRenderer
for this WindowBasedTextGUI
getWindowPostRenderer
in interface WindowBasedTextGUI
WindowPostRenderer
for this WindowBasedTextGUI
public WindowBasedTextGUI moveToTop(Window window)
WindowBasedTextGUI
moveToTop
in interface WindowBasedTextGUI
window
- Window in the stack to move to the top positionpublic WindowBasedTextGUI moveToBottom(Window window)
public WindowBasedTextGUI cycleActiveWindow(boolean reverse)
reverse
parameter is false
then the current top window is placed at the bottom of the stack and the window immediately behind it is the new
top. If reverse
is set to true
then the window at the bottom of the stack is moved up to the
front and the previous top window will be immediately below itcycleActiveWindow
in interface WindowBasedTextGUI
reverse
- Direction to cycle through the windowsCopyright © 2020. All rights reserved.