Package jexer

Class TWindow

    • Field Detail

      • RESIZABLE

        public static final int RESIZABLE
        Window is resizable (default yes).
        See Also:
        Constant Field Values
      • CENTERED

        public static final int CENTERED
        Window is centered (default no).
        See Also:
        Constant Field Values
      • NOCLOSEBOX

        public static final int NOCLOSEBOX
        Window has no close box (default no). Window can still be closed via TApplication.closeWindow() and TWindow.close().
        See Also:
        Constant Field Values
      • NOZOOMBOX

        public static final int NOZOOMBOX
        Window has no maximize box (default no).
        See Also:
        Constant Field Values
      • ABSOLUTEXY

        public static final int ABSOLUTEXY
        Window is placed at absolute position (no smart placement) (default no).
        See Also:
        Constant Field Values
      • HIDEONCLOSE

        public static final int HIDEONCLOSE
        Hitting the closebox with the mouse calls TApplication.hideWindow() rather than TApplication.closeWindow() (default no).
        See Also:
        Constant Field Values
      • OVERRIDEMENU

        public static final int OVERRIDEMENU
        Menus cannot be used when this window is active (default no).
        See Also:
        Constant Field Values
      • inWindowMove

        protected boolean inWindowMove
        If true, then the user clicked on the title bar and is moving the window.
      • inWindowResize

        protected boolean inWindowResize
        If true, then the user clicked on the bottom right corner and is resizing the window.
      • inKeyboardResize

        protected boolean inKeyboardResize
        If true, then the user selected "Size/Move" (or hit Ctrl-F5) and is resizing/moving the window via the keyboard.
      • mouse

        protected TMouseEvent mouse
        Remember mouse state.
      • statusBar

        protected TStatusBar statusBar
        A window may have a status bar associated with it. TApplication will draw this status bar last, and will also route events to it first before the window.
      • helpTopic

        protected java.lang.String helpTopic
        The help topic for this window.
    • Constructor Detail

      • TWindow

        public TWindow​(TApplication application,
                       java.lang.String title,
                       int width,
                       int height)
        Public constructor. Window will be located at (0, 0).
        Parameters:
        application - TApplication that manages this window
        title - window title, will be centered along the top border
        width - width of window
        height - height of window
      • TWindow

        public TWindow​(TApplication application,
                       java.lang.String title,
                       int width,
                       int height,
                       int flags)
        Public constructor. Window will be located at (0, 0).
        Parameters:
        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
      • TWindow

        public TWindow​(TApplication application,
                       java.lang.String title,
                       int x,
                       int y,
                       int width,
                       int height)
        Public constructor.
        Parameters:
        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
      • TWindow

        public TWindow​(TApplication application,
                       java.lang.String title,
                       int x,
                       int y,
                       int width,
                       int height,
                       int flags)
        Public constructor.
        Parameters:
        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

      • mouseOnClose

        protected boolean mouseOnClose()
        Returns true if the mouse is currently on the close button.
        Returns:
        true if mouse is currently on the close button
      • mouseOnMaximize

        protected boolean mouseOnMaximize()
        Returns true if the mouse is currently on the maximize/restore button.
        Returns:
        true if the mouse is currently on the maximize/restore button
      • mouseOnResize

        protected boolean mouseOnResize()
        Returns true if the mouse is currently on the resizable lower right corner.
        Returns:
        true if the mouse is currently on the resizable lower right corner
      • onPreClose

        protected void onPreClose()
        Subclasses should override this method to perform any user prompting before they are offscreen. Note that unlike other windowing toolkits, windows can NOT use this function in some manner to avoid being closed. This is called by application.closeWindow().
      • onClose

        protected void onClose()
        Subclasses should override this method to cleanup resources. This is called by application.closeWindow().
      • onFocus

        protected void onFocus()
        Called by application.switchWindow() when this window gets the focus, and also by application.addWindow().
      • onUnfocus

        protected void onUnfocus()
        Called by application.switchWindow() when another window gets the focus.
      • onHide

        protected void onHide()
        Called by application.hideWindow().
      • onShow

        protected void onShow()
        Called by application.showWindow().
      • onMouseDown

        public void onMouseDown​(TMouseEvent mouse)
        Handle mouse button presses.
        Overrides:
        onMouseDown in class TWidget
        Parameters:
        mouse - mouse button event
      • onMouseUp

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

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

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

        public void onCommand​(TCommandEvent command)
        Handle posted command events.
        Overrides:
        onCommand in class TWidget
        Parameters:
        command - command event
      • onMenu

        public void onMenu​(TMenuEvent menu)
        Handle posted menu events.
        Overrides:
        onMenu in class TWidget
        Parameters:
        menu - menu event
      • onResize

        public void onResize​(TResizeEvent resize)
        Method that subclasses can override to handle window/screen resize events.
        Overrides:
        onResize in class TWidget
        Parameters:
        resize - resize event
      • getApplication

        public final TApplication getApplication()
        Get this TWindow's parent TApplication.
        Overrides:
        getApplication in class TWidget
        Returns:
        this TWindow's parent TApplication
      • getScreen

        public final Screen getScreen()
        Get the Screen.
        Overrides:
        getScreen in class TWidget
        Returns:
        the Screen
      • draw

        public void draw()
        Called by TApplication.drawChildren() to render on screen.
        Overrides:
        draw in class TWidget
      • getTitle

        public final java.lang.String getTitle()
        Get window title.
        Returns:
        window title
      • setTitle

        public final void setTitle​(java.lang.String title)
        Set window title.
        Parameters:
        title - new window title
      • getZ

        public final int getZ()
        Get Z order. Lower number means more in-front.
        Returns:
        Z value. Lower number means more in-front.
      • setZ

        public final void setZ​(int z)
        Set Z order. Lower number means more in-front.
        Parameters:
        z - the new Z value. Lower number means more in-front.
      • addShortcutKeypress

        public void addShortcutKeypress​(TKeypress key)
        Add a keypress to be overridden for this window.
        Parameters:
        key - the key to start taking control of
      • removeShortcutKeypress

        public void removeShortcutKeypress​(TKeypress key)
        Remove a keypress to be overridden for this window.
        Parameters:
        key - the key to stop taking control of
      • clearShortcutKeypresses

        protected void clearShortcutKeypresses()
        Remove all keypresses to be overridden for this window.
      • isShortcutKeypress

        public boolean isShortcutKeypress​(TKeypress key)
        Determine if a keypress is overridden for this window.
        Parameters:
        key - the key to check
        Returns:
        true if this window wants to process this key on its own
      • getStatusBar

        public TStatusBar getStatusBar()
        Get the window's status bar, or null if it does not have one.
        Returns:
        the status bar, or null
      • newStatusBar

        public TStatusBar newStatusBar​(java.lang.String text)
        Set the window's status bar to a new one.
        Parameters:
        text - the status bar text
        Returns:
        the status bar
      • getMaximumWindowWidth

        public final int getMaximumWindowWidth()
        Get the maximum width for this window.
        Returns:
        the maximum width
      • setMaximumWindowWidth

        public final void setMaximumWindowWidth​(int maximumWindowWidth)
        Set the maximum width for this window.
        Parameters:
        maximumWindowWidth - new maximum width
      • getMinimumWindowWidth

        public final int getMinimumWindowWidth()
        Get the minimum width for this window.
        Returns:
        the minimum width
      • setMinimumWindowWidth

        public final void setMinimumWindowWidth​(int minimumWindowWidth)
        Set the minimum width for this window.
        Parameters:
        minimumWindowWidth - new minimum width
      • getMaximumWindowHeight

        public final int getMaximumWindowHeight()
        Get the maximum height for this window.
        Returns:
        the maximum height
      • setMaximumWindowHeight

        public final void setMaximumWindowHeight​(int maximumWindowHeight)
        Set the maximum height for this window.
        Parameters:
        maximumWindowHeight - new maximum height
      • getMinimumWindowHeight

        public final int getMinimumWindowHeight()
        Get the minimum height for this window.
        Returns:
        the minimum height
      • setMinimumWindowHeight

        public final void setMinimumWindowHeight​(int minimumWindowHeight)
        Set the minimum height for this window.
        Parameters:
        minimumWindowHeight - new minimum height
      • center

        public final void center()
        Recenter the window on-screen.
      • ensureOnScreen

        public void ensureOnScreen()
        Move the window as needed to ensure it is visible on screen.
      • maximize

        public void maximize()
        Maximize window.
      • restore

        public void restore()
        Restore (unmaximize) window.
      • isHidden

        public final boolean isHidden()
        Returns true if this window is hidden.
        Returns:
        true if this window is hidden, false if the window is shown
      • isShown

        public final boolean isShown()
        Returns true if this window is shown.
        Returns:
        true if this window is shown, false if the window is hidden
      • hide

        public void hide()
        Hide window. A hidden window will still have its onIdle() called, and will also have onClose() called at application exit. Hidden windows will not receive any other events.
      • show

        public void show()
        Show window.
      • activate

        public void activate()
        Activate window (bring to top and receive events).
        Overrides:
        activate in class TWidget
      • close

        public void close()
        Close window. Note that windows without a close box can still be closed by calling the close() method.
        Overrides:
        close in class TWidget
      • inMovements

        public boolean inMovements()
        See if this window is undergoing any movement/resize/etc.
        Returns:
        true if the window is moving
      • stopMovements

        public void stopMovements()
        Stop any pending movement/resize/etc.
      • isModal

        public final boolean isModal()
        Returns true if this window is modal.
        Returns:
        true if this window is modal
      • hasCloseBox

        public final boolean hasCloseBox()
        Returns true if this window has a close box.
        Returns:
        true if this window has a close box
      • setCloseBox

        public final void setCloseBox​(boolean closeBox)
        Set this window's close box flag.
        Parameters:
        closeBox - if true, this window will have a close box
      • hasZoomBox

        public final boolean hasZoomBox()
        Returns true if this window has a maximize/zoom box.
        Returns:
        true if this window has a maximize/zoom box
      • setZoomBox

        public final void setZoomBox​(boolean zoomBox)
        Set this window's maximize/zoom box flag.
        Parameters:
        zoomBox - if true, this window will have a maximize/zoom box
      • hasOverriddenMenu

        public final boolean hasOverriddenMenu()
        Returns true if this window does not want menus to work while it is visible.
        Returns:
        true if this window does not want menus to work while it is visible
      • isResizable

        public final boolean isResizable()
        Returns true if this window is resizable.
        Returns:
        true if this window is resizable
      • setResizable

        public final void setResizable​(boolean resizable)
        Set this window's resizable flag.
        Parameters:
        resizable - if true, this window will be resizable
      • getBackground

        public CellAttributes getBackground()
        Retrieve the background color.
        Returns:
        the background color
      • getBorder

        public CellAttributes getBorder()
        Retrieve the border color.
        Returns:
        the border color
      • getBorderControls

        public CellAttributes getBorderControls()
        Retrieve the color used by the window movement/sizing controls.
        Returns:
        the color used by the zoom box, resize bar, and close box
      • hasHiddenMouse

        public boolean hasHiddenMouse()
        Returns true if this window does not want the application-wide mouse cursor drawn over it.
        Returns:
        true if this window does not want the application-wide mouse cursor drawn over it
      • setHiddenMouse

        public final void setHiddenMouse​(boolean hideMouse)
        Set request to prevent the application-wide mouse cursor from being drawn over this window.
        Parameters:
        hideMouse - if true, this window does not want the application-wide mouse cursor drawn over it
      • getHelpTopic

        public java.lang.String getHelpTopic()
        Get this window's help topic to load.
        Returns:
        the topic name
      • toString

        public java.lang.String toString()
        Generate a human-readable string for this window.
        Overrides:
        toString in class TWidget
        Returns:
        a human-readable string