Package jexer.backend
Class TWindowBackend
- java.lang.Object
-
- jexer.TWidget
-
- jexer.TWindow
-
- jexer.backend.TWindowBackend
-
public class TWindowBackend extends TWindow implements Backend
TWindowBackend uses a window in one TApplication to provide a backend for another TApplication. Note that TWindow has its own getScreen() and setTitle() functions. Clients in TWindowBackend's application won't be able to use it to get at the other application's screen. getOtherScreen() has been provided.
-
-
Field Summary
-
Fields inherited from class jexer.TWindow
ABSOLUTEXY, borderStyleActive, borderStyleActiveModal, borderStyleInactive, borderStyleMoving, CENTERED, helpTopic, HIDEONCLOSE, inKeyboardResize, inWindowMove, inWindowResize, MODAL, mouse, NOCLOSEBOX, NOZOOMBOX, overlay, OVERRIDEMENU, RESIZABLE, statusBar, underlay
-
-
Constructor Summary
Constructors Constructor Description TWindowBackend(java.lang.Object listener, TApplication application, java.lang.String title, int width, int height)Public constructor.TWindowBackend(java.lang.Object listener, TApplication application, java.lang.String title, int width, int height, int flags)Public constructor.TWindowBackend(java.lang.Object listener, TApplication application, java.lang.String title, int x, int y, int width, int height)Public constructor.TWindowBackend(java.lang.Object listener, TApplication application, java.lang.String title, int x, int y, int width, int height, int flags)Public constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.awt.ColorattrToBackgroundColor(CellAttributes attr)Convert a CellAttributes background color to an AWT Color.java.awt.ColorattrToForegroundColor(CellAttributes attr)Convert a CellAttributes foreground color to an AWT Color.voiddraw()Draw the foreground colors grid.voidflushScreen()Subclasses must provide an implementation that syncs the logical screen to the physical device.voidgetEvents(java.util.List<TInputEvent> queue)Subclasses must provide an implementation to get keyboard, mouse, and screen resize events.ScreengetOtherScreen()Getter for the other application's screen.SessionInfogetSessionInfo()Getter for sessionInfo.booleanhasEvents()Check if there are events in the queue.booleanisImagesOverText()Check if backend will support incomplete image fragments over text display.booleanisPixelMouse()Check if backend is reporting pixel-based mouse position.booleanisReadOnly()Check if backend is read-only.protected booleanmouseOnOtherScreen(TMouseEvent mouse)Returns true if the mouse is currently in the otherScreen window.voidonClose()Subclasses should override this method to cleanup resources.voidonKeypress(TKeypressEvent keypress)Handle keystrokes.voidonMouseDown(TMouseEvent mouse)Handle mouse button presses.voidonMouseMotion(TMouseEvent mouse)Handle mouse movements.voidonMouseUp(TMouseEvent mouse)Handle mouse button releases.voidonResize(TResizeEvent event)Handle window/screen resize events.voidreloadOptions()Reload backend options from System properties.voidsetDrawLock(java.lang.Object drawLock)Set the object to sync to in draw().voidsetListener(java.lang.Object listener)Set listener to a different Object.voidsetOtherApplication(TApplication application)Set the other screen's application.voidsetPixelMouse(boolean pixelMouse)Set request for backend to report pixel-based mouse position.voidsetReadOnly(boolean readOnly)Set read-only flag.voidshutdown()Subclasses must provide an implementation that closes sockets, restores console, etc.-
Methods inherited from class jexer.TWindow
activate, addOverlay, addShortcutKeypress, addUnderlay, center, clearShortcutKeypresses, close, disableCloseEffect, disableOpenEffect, ensureOnScreen, getAlpha, getApplication, getBackground, getBorder, getBorderControls, getBorderStyle, getBorderStyleForeground, getBorderStyleInactive, getBorderStyleModal, getBorderStyleMoving, getHelpTopic, getMaximumWindowHeight, getMaximumWindowWidth, getMinimumWindowHeight, getMinimumWindowWidth, getMouseStyle, getScreen, getStatusBar, getTitle, getWindowTheme, getZ, hasCloseBox, hasHiddenMouse, hasOverriddenMenu, hasZoomBox, hide, inMovements, isHidden, isModal, isResizable, isShortcutKeypress, isShown, maximize, mouseOnClose, mouseOnMaximize, mouseOnResize, newStatusBar, onCommand, onFocus, onHide, onMenu, onPostDraw, onPreClose, onShow, onUnfocus, removeShortcutKeypress, restore, setAlpha, setBorderStyleForeground, setBorderStyleInactive, setBorderStyleModal, setBorderStyleMoving, setCloseBox, setHiddenMouse, setMaximumWindowHeight, setMaximumWindowWidth, setMinimumWindowHeight, setMinimumWindowWidth, setResizable, setTackboardsDirty, setTitle, setWindowTheme, setZ, setZoomBox, show, stopMovements, toString
-
Methods inherited from class jexer.TWidget
activate, activate, activateAll, addButton, addCalendar, addCheckBox, addCheckBox, addComboBox, addDirectoryList, addDirectoryList, addDirectoryList, addDirectoryList, addEditor, addField, addField, addField, addField, addImage, addImage, addImage, addImage, addLabel, addLabel, addLabel, addLabel, addLabel, addLabel, addList, addList, addList, addList, addPanel, addPasswordField, addPasswordField, addPasswordField, addProgressBar, addRadioGroup, addRadioGroup, addSpinner, addSplitPane, addTable, addTable, addText, addText, addTreeViewWidget, addTreeViewWidget, compareTo, doRepaint, drawBox, drawBox, drawBoxShadow, drawChildren, fileOpenBox, fileOpenBox, fileOpenBox, fileOpenBox, fileSaveBox, getAbsoluteX, getAbsoluteY, getActiveChild, getAttrXY, getChildren, getClipboard, getCursorAbsoluteX, getCursorAbsoluteY, getCursorX, getCursorY, getCustomMousePointer, getHeight, getLayoutManager, getLocale, getParent, getTheme, getWidgetUnderMouse, getWidth, getWindow, getX, getY, handleEvent, hasChild, hLineXY, hLineXY, inputBox, inputBox, inputBox, isAbsoluteActive, isActive, isCursorVisible, isDrawable, isEchoKeystrokes, isEnabled, isVisible, messageBox, messageBox, mouseWouldHit, onIdle, onMouseDoubleClick, putAll, putAttrXY, putAttrXY, putCharXY, putCharXY, putCharXY, putStringXY, putStringXY, remove, remove, remove, remove, removeAll, resetTabOrder, setActive, setCursorVisible, setCursorX, setCursorY, setCustomMousePointer, setDimensions, setEchoKeystrokes, setEchoKeystrokes, setEnabled, setHeight, setLayoutManager, setLocale, setMouseStyle, setParent, setupForTWindow, setVisible, setWidth, setWindow, setX, setY, splitHorizontal, splitVertical, switchWidget, toPrettyString, toPrettyString, vLineXY, vLineXY
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface jexer.backend.Backend
getScreen, setMouseStyle, setTitle
-
-
-
-
Constructor Detail
-
TWindowBackend
public TWindowBackend(java.lang.Object listener, TApplication application, java.lang.String title, int width, int height)Public constructor. Window will be located at (0, 0).- Parameters:
listener- the object this backend needs to wake up when new input comes inapplication- TApplication that manages this windowtitle- window title, will be centered along the top borderwidth- width of windowheight- height of window
-
TWindowBackend
public TWindowBackend(java.lang.Object listener, TApplication application, java.lang.String title, int width, int height, int flags)Public constructor. Window will be located at (0, 0).- Parameters:
listener- the object this backend needs to wake up when new input comes inapplication- TApplication that manages this windowtitle- window title, will be centered along the top borderwidth- width of windowheight- height of windowflags- bitmask of RESIZABLE, CENTERED, or MODAL
-
TWindowBackend
public TWindowBackend(java.lang.Object listener, TApplication application, java.lang.String title, int x, int y, int width, int height)Public constructor.- Parameters:
listener- the object this backend needs to wake up when new input comes inapplication- TApplication that manages this windowtitle- window title, will be centered along the top borderx- column relative to parenty- row relative to parentwidth- width of windowheight- height of window
-
TWindowBackend
public TWindowBackend(java.lang.Object listener, TApplication application, java.lang.String title, int x, int y, int width, int height, int flags)Public constructor.- Parameters:
listener- the object this backend needs to wake up when new input comes inapplication- TApplication that manages this windowtitle- window title, will be centered along the top borderx- column relative to parenty- row relative to parentwidth- width of windowheight- height of windowflags- mask of RESIZABLE, CENTERED, or MODAL
-
-
Method Detail
-
onResize
public void onResize(TResizeEvent event)
Handle window/screen resize events.
-
mouseOnOtherScreen
protected boolean mouseOnOtherScreen(TMouseEvent mouse)
Returns true if the mouse is currently in the otherScreen window.- Parameters:
mouse- mouse event- Returns:
- true if mouse is currently in the otherScreen window.
-
onMouseDown
public void onMouseDown(TMouseEvent mouse)
Handle mouse button presses.- Overrides:
onMouseDownin classTWindow- Parameters:
mouse- mouse button event
-
onMouseUp
public void onMouseUp(TMouseEvent mouse)
Handle mouse button releases.
-
onMouseMotion
public void onMouseMotion(TMouseEvent mouse)
Handle mouse movements.- Overrides:
onMouseMotionin classTWindow- Parameters:
mouse- mouse motion event
-
onKeypress
public void onKeypress(TKeypressEvent keypress)
Handle keystrokes.- Overrides:
onKeypressin classTWindow- Parameters:
keypress- keystroke event
-
onClose
public void onClose()
Subclasses should override this method to cleanup resources. This is called by application.closeWindow().
-
getSessionInfo
public final SessionInfo getSessionInfo()
Getter for sessionInfo.- Specified by:
getSessionInfoin interfaceBackend- Returns:
- the SessionInfo
-
flushScreen
public void flushScreen()
Subclasses must provide an implementation that syncs the logical screen to the physical device.- Specified by:
flushScreenin interfaceBackend
-
hasEvents
public boolean hasEvents()
Check if there are events in the queue.
-
getEvents
public void getEvents(java.util.List<TInputEvent> queue)
Subclasses must provide an implementation to get keyboard, mouse, and screen resize events.
-
shutdown
public void shutdown()
Subclasses must provide an implementation that closes sockets, restores console, etc.
-
setListener
public void setListener(java.lang.Object listener)
Set listener to a different Object.- Specified by:
setListenerin interfaceBackend- Parameters:
listener- the new listening object that run() wakes up on new input
-
reloadOptions
public void reloadOptions()
Reload backend options from System properties.- Specified by:
reloadOptionsin interfaceBackend
-
isReadOnly
public boolean isReadOnly()
Check if backend is read-only.- Specified by:
isReadOnlyin interfaceBackend- Returns:
- true if user input events from the backend are discarded
-
setReadOnly
public void setReadOnly(boolean readOnly)
Set read-only flag.- Specified by:
setReadOnlyin interfaceBackend- Parameters:
readOnly- if true, then input events will be discarded
-
isImagesOverText
public boolean isImagesOverText()
Check if backend will support incomplete image fragments over text display.- Specified by:
isImagesOverTextin interfaceBackend- Returns:
- true if images can partially obscure text
-
isPixelMouse
public boolean isPixelMouse()
Check if backend is reporting pixel-based mouse position.- Specified by:
isPixelMousein interfaceBackend- Overrides:
isPixelMousein classTWidget- Returns:
- true if single-pixel mouse movements are reported
-
setPixelMouse
public void setPixelMouse(boolean pixelMouse)
Set request for backend to report pixel-based mouse position.- Specified by:
setPixelMousein interfaceBackend- Parameters:
pixelMouse- if true, single-pixel mouse movements will be reported, if the backend supports it
-
setDrawLock
public void setDrawLock(java.lang.Object drawLock)
Set the object to sync to in draw().- Parameters:
drawLock- the object to synchronize on
-
getOtherScreen
public Screen getOtherScreen()
Getter for the other application's screen.- Returns:
- the Screen
-
setOtherApplication
public void setOtherApplication(TApplication application)
Set the other screen's application.- Parameters:
application- the application driving the other screen
-
attrToForegroundColor
public java.awt.Color attrToForegroundColor(CellAttributes attr)
Convert a CellAttributes foreground color to an AWT Color.- Specified by:
attrToForegroundColorin interfaceBackend- Parameters:
attr- the text attributes- Returns:
- the AWT Color
-
attrToBackgroundColor
public java.awt.Color attrToBackgroundColor(CellAttributes attr)
Convert a CellAttributes background color to an AWT Color.- Specified by:
attrToBackgroundColorin interfaceBackend- Parameters:
attr- the text attributes- Returns:
- the AWT Color
-
-