-
- All Superinterfaces:
Composite
- All Known Subinterfaces:
Window
- All Known Implementing Classes:
AbstractBasePane
,AbstractWindow
,ActionListDialog
,BasicWindow
,ComboBox.PopupWindow
,DialogWindow
,DirectoryDialog
,FileDialog
,ListSelectDialog
,MenuPopupWindow
,MessageDialog
,TextInputDialog
,WaitingDialog
public interface BasePane extends Composite
BasePane is the base container in a Text GUI. A text gui may have several base panes, although they are always independent. One common example of this is a multi-window system where each window is a base pane. Think of the base pane as a root container, the ultimate parent of all components added to a GUI. When you useMultiWindowTextGUI
, the background space behind the windows is aBasePane
too, just like each of the windows. They are all drawn separately and composited together. EveryBasePane
has a single component that is drawn over the entire area theBasePane
is occupying, it's very likely you want to set this component to be a container of some sort, probably aPanel
, that can host multiple child components.- See Also:
Panel
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
draw(TextGUIGraphics graphics)
Called by the GUI system (or something imitating the GUI system) to draw the root container.TerminalPosition
fromGlobal(TerminalPosition position)
Returns a position expressed in global coordinates, i.e.Component
getComponent()
Returns the component that is the content of the BasePane.TerminalPosition
getCursorPosition()
Returns the position of where to put the terminal cursor according to this root container.Interactable
getFocusedInteractable()
Returns the component in the root container that currently has input focus.MenuBar
getMenuBar()
Returns theMenuBar
assigned to this base pane/window, if any, otherwise returns {code null}.TextGUI
getTextGUI()
Returns the TextGUI this BasePane belongs to ornull
if none.Theme
getTheme()
Returns the text GUITheme
associated with this base pane/window.boolean
handleInput(KeyStroke key)
Called by the GUI system to delegate a keyboard input event.void
invalidate()
Invalidates the whole root container (including all of its child components) which will cause them all to be recalculated (for containers) and redrawn.boolean
isInvalid()
Checks if this root container (i.e.void
setComponent(Component component)
Sets the top-level component inside this BasePane.void
setEnableDirectionBasedMovements(boolean enableDirectionBasedMovements)
If set to false, using the keyboard arrows keys will have the same effect as using the tab and reverse tab.void
setFocusedInteractable(Interactable interactable)
Sets the component currently in focus within this root container, or sets no component in focus ifnull
is passed in.void
setMenuBar(MenuBar menubar)
Sets the activeMenuBar
for this base pane/window.void
setStrictFocusChange(boolean strictFocusChange)
If set to true, up/down array keys will not translate to next/previous if there are no more components above/below.void
setTheme(Theme theme)
TerminalPosition
toGlobal(TerminalPosition localPosition)
Returns a position in a root container's local coordinate space to global coordinates
-
-
-
Method Detail
-
getTextGUI
TextGUI getTextGUI()
Returns the TextGUI this BasePane belongs to ornull
if none. One example of when this method returnsnull
is when calling it on a Window that hasn't been displayed yet.- Returns:
- The TextGUI this BasePane belongs to
-
draw
void draw(TextGUIGraphics graphics)
Called by the GUI system (or something imitating the GUI system) to draw the root container. The TextGUIGraphics object should be used to perform the drawing operations.- Parameters:
graphics
- TextGraphics object to draw with
-
isInvalid
boolean isInvalid()
Checks if this root container (i.e. any of its child components) has signaled that what it's currently displaying is out of date and needs re-drawing.- Returns:
true
if the container's content is invalid and needs redrawing,false
otherwise
-
invalidate
void invalidate()
Invalidates the whole root container (including all of its child components) which will cause them all to be recalculated (for containers) and redrawn.
-
handleInput
boolean handleInput(KeyStroke key)
Called by the GUI system to delegate a keyboard input event. The root container will decide what to do with this input, usually sending it to one of its sub-components, but if it isn't able to find any handler for this input it should returnfalse
so that the GUI system can take further decisions on what to do with it.- Parameters:
key
- Keyboard input- Returns:
true
If the root container could handle the input, false otherwise
-
getComponent
Component getComponent()
Returns the component that is the content of the BasePane. This is probably the root of a hierarchy of nested Panels but it could also be a single component.- Specified by:
getComponent
in interfaceComposite
- Returns:
- Component which is the content of this BasePane
-
setComponent
void setComponent(Component component)
Sets the top-level component inside this BasePane. If you want it to contain only one component, you can set it directly, but for more complicated GUIs you probably want to create a hierarchy of panels and set the first one here.- Specified by:
setComponent
in interfaceComposite
- Parameters:
component
- Component which this BasePane is using as it's content
-
getFocusedInteractable
Interactable getFocusedInteractable()
Returns the component in the root container that currently has input focus. There can only be one component at a time being in focus.- Returns:
- Interactable component that is currently in receiving input focus
-
setFocusedInteractable
void setFocusedInteractable(Interactable interactable)
Sets the component currently in focus within this root container, or sets no component in focus ifnull
is passed in.- Parameters:
interactable
- Interactable to focus, ornull
to clear focus
-
getCursorPosition
TerminalPosition getCursorPosition()
Returns the position of where to put the terminal cursor according to this root container. This is typically derived from which component has focus, ornull
if no component has focus or if the root container 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 root container. You can use your TextGUI implementation to translate these to global coordinates.- Returns:
- Local position of where to place the cursor, or
null
if the cursor shouldn't be visible
-
toGlobal
TerminalPosition toGlobal(TerminalPosition localPosition)
Returns a position in a root container's local coordinate space to global coordinates- Parameters:
localPosition
- The local position to translate- Returns:
- The local position translated to global coordinates
-
fromGlobal
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 base pane. CallingfromGlobal(toGlobal(..))
should return the exact same position.- Parameters:
position
- Position expressed in global coordinates to translate to local coordinates of this BasePane- Returns:
- The global coordinates expressed as local coordinates
-
setStrictFocusChange
void setStrictFocusChange(boolean strictFocusChange)
If set to true, up/down array keys will not translate to next/previous if there are no more components above/below.- Parameters:
strictFocusChange
- Will not allow relaxed navigation if set totrue
-
setEnableDirectionBasedMovements
void setEnableDirectionBasedMovements(boolean enableDirectionBasedMovements)
If set to false, using the keyboard arrows keys will have the same effect as using the tab and reverse tab. Lanterna will map arrow down and arrow right to tab, going to the next component, and array up and array left to reverse tab, going to the previous component. If set to true, Lanterna will search for the next component starting at the cursor position in the general direction of the arrow. By default this is enabled.In Lanterna 2, direction based movements were not available.
- Parameters:
enableDirectionBasedMovements
- Should direction based focus movements be enabled?
-
getTheme
Theme getTheme()
Returns the text GUITheme
associated with this base pane/window. This is either coming from theTextGUI
this object is associated with, the theme set as the override throughsetTheme(Theme)
ornull
if this base pane/window isn't added to anyTextGUI
and doesn't have any override.- Returns:
- The
Theme
this base pane/window is expected to use when drawing the contents
-
setTheme
void setTheme(Theme theme)
Sets the overrideTheme
to use for this base pane/window, rather than the defaultTheme
associated with theTextGUI
it is attached to. If called withnull
, it will clear the override and use the default value instead.- Parameters:
theme
-Theme
to assign to this base pane/window, ornull
to reset
-
setMenuBar
void setMenuBar(MenuBar menubar)
Sets the activeMenuBar
for this base pane/window. The menu will be rendered at the top (inside the window decorations if set on a window), if set. If called withnull
, any previously set menu bar is removed.- Parameters:
menubar
- TheMenuBar
to assign to this pane/window
-
-