Package jexer.backend

Class TWindowBackend

  • All Implemented Interfaces:
    java.lang.Comparable<TWidget>, Backend

    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.
    • 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 in
        application - TApplication that manages this window
        title - window title, will be centered along the top border
        width - width of window
        height - 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 in
        application - TApplication that manages this window
        title - window title, will be centered along the top border
        width - width of window
        height - height of window
        flags - 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 in
        application - TApplication that manages this window
        title - window title, will be centered along the top border
        x - column relative to parent
        y - row relative to parent
        width - width of window
        height - 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 in
        application - TApplication that manages this window
        title - window title, will be centered along the top border
        x - column relative to parent
        y - row relative to parent
        width - width of window
        height - height of window
        flags - mask of RESIZABLE, CENTERED, or MODAL
    • Method Detail

      • onResize

        public void onResize​(TResizeEvent event)
        Handle window/screen resize events.
        Overrides:
        onResize in class TWindow
        Parameters:
        event - resize event
      • 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:
        onMouseDown in class TWindow
        Parameters:
        mouse - mouse button event
      • onMouseUp

        public void onMouseUp​(TMouseEvent mouse)
        Handle mouse button releases.
        Overrides:
        onMouseUp in class TWindow
        Parameters:
        mouse - mouse button release event
      • onMouseMotion

        public void onMouseMotion​(TMouseEvent mouse)
        Handle mouse movements.
        Overrides:
        onMouseMotion in class TWindow
        Parameters:
        mouse - mouse motion event
      • onKeypress

        public void onKeypress​(TKeypressEvent keypress)
        Handle keystrokes.
        Overrides:
        onKeypress in class TWindow
        Parameters:
        keypress - keystroke event
      • draw

        public void draw()
        Draw the foreground colors grid.
        Overrides:
        draw in class TWindow
      • onClose

        public void onClose()
        Subclasses should override this method to cleanup resources. This is called by application.closeWindow().
        Overrides:
        onClose in class TWindow
      • getSessionInfo

        public final SessionInfo getSessionInfo()
        Getter for sessionInfo.
        Specified by:
        getSessionInfo in interface Backend
        Returns:
        the SessionInfo
      • flushScreen

        public void flushScreen()
        Subclasses must provide an implementation that syncs the logical screen to the physical device.
        Specified by:
        flushScreen in interface Backend
      • hasEvents

        public boolean hasEvents()
        Check if there are events in the queue.
        Specified by:
        hasEvents in interface Backend
        Returns:
        if true, getEvents() has something to return to the application
      • getEvents

        public void getEvents​(java.util.List<TInputEvent> queue)
        Subclasses must provide an implementation to get keyboard, mouse, and screen resize events.
        Specified by:
        getEvents in interface Backend
        Parameters:
        queue - list to append new events to
      • shutdown

        public void shutdown()
        Subclasses must provide an implementation that closes sockets, restores console, etc.
        Specified by:
        shutdown in interface Backend
      • setListener

        public void setListener​(java.lang.Object listener)
        Set listener to a different Object.
        Specified by:
        setListener in interface Backend
        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:
        reloadOptions in interface Backend
      • isReadOnly

        public boolean isReadOnly()
        Check if backend is read-only.
        Specified by:
        isReadOnly in interface Backend
        Returns:
        true if user input events from the backend are discarded
      • setReadOnly

        public void setReadOnly​(boolean readOnly)
        Set read-only flag.
        Specified by:
        setReadOnly in interface Backend
        Parameters:
        readOnly - if true, then input events will be discarded
      • 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