Package jexer
Class TWindow
- java.lang.Object
-
- jexer.TWidget
-
- jexer.TWindow
-
- All Implemented Interfaces:
java.lang.Comparable<TWidget>
- Direct Known Subclasses:
DemoCheckBoxWindow
,DemoEditorWindow
,DemoMainWindow
,DemoMsgBoxWindow
,DemoPixelsWindow
,DemoTableWindow
,DemoTextFieldWindow
,DemoTextWindow
,DemoTreeViewWindow
,TDesktop
,TEditColorThemeWindow
,TExceptionDialog
,TFileOpenBox
,THelpWindow
,TMenu
,TMessageBox
,TScreenOptionsWindow
,TScrollableWindow
,TWindowBackend
public class TWindow extends TWidget
TWindow is the top-level container and drawing surface for other widgets.
-
-
Field Summary
Fields Modifier and Type Field Description static int
ABSOLUTEXY
Window is placed at absolute position (no smart placement) (default no).static int
CENTERED
Window is centered (default no).protected java.lang.String
helpTopic
The help topic for this window.static int
HIDEONCLOSE
Hitting the closebox with the mouse calls TApplication.hideWindow() rather than TApplication.closeWindow() (default no).protected boolean
inKeyboardResize
If true, then the user selected "Size/Move" (or hit Ctrl-F5) and is resizing/moving the window via the keyboard.protected boolean
inWindowMove
If true, then the user clicked on the title bar and is moving the window.protected boolean
inWindowResize
If true, then the user clicked on the bottom right corner and is resizing the window.static int
MODAL
Window is modal (default no).protected TMouseEvent
mouse
Remember mouse state.static int
NOCLOSEBOX
Window has no close box (default no).static int
NOZOOMBOX
Window has no maximize box (default no).protected Tackboard
overlay
A means of drawing arbitrary items on top of all widgets on this window.static int
OVERRIDEMENU
Menus cannot be used when this window is active (default no).static int
RESIZABLE
Window is resizable (default yes).protected TStatusBar
statusBar
A window may have a status bar associated with it.protected Tackboard
underlay
A means of drawing arbitrary items underneath all widgets on this window.
-
Constructor Summary
Constructors Constructor Description TWindow(TApplication application, java.lang.String title, int width, int height)
Public constructor.TWindow(TApplication application, java.lang.String title, int width, int height, int flags)
Public constructor.TWindow(TApplication application, java.lang.String title, int x, int y, int width, int height)
Public constructor.TWindow(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 void
activate()
Activate window (bring to top and receive events).void
addOverlay(TackboardItem item)
Add a tackboard item to the overlay.void
addShortcutKeypress(TKeypress key)
Add a keypress to be overridden for this window.void
addUnderlay(TackboardItem item)
Add a tackboard item to the underlay.void
center()
Recenter the window on-screen.protected void
clearShortcutKeypresses()
Remove all keypresses to be overridden for this window.void
close()
Close window.void
draw()
Called by TApplication.drawChildren() to render on screen.void
ensureOnScreen()
Move the window as needed to ensure it is visible on screen.TApplication
getApplication()
Get this TWindow's parent TApplication.CellAttributes
getBackground()
Retrieve the background color.CellAttributes
getBorder()
Retrieve the border color.CellAttributes
getBorderControls()
Retrieve the color used by the window movement/sizing controls.java.lang.String
getHelpTopic()
Get this window's help topic to load.int
getMaximumWindowHeight()
Get the maximum height for this window.int
getMaximumWindowWidth()
Get the maximum width for this window.int
getMinimumWindowHeight()
Get the minimum height for this window.int
getMinimumWindowWidth()
Get the minimum width for this window.Screen
getScreen()
Get the Screen.TStatusBar
getStatusBar()
Get the window's status bar, or null if it does not have one.java.lang.String
getTitle()
Get window title.int
getZ()
Get Z order.boolean
hasCloseBox()
Returns true if this window has a close box.boolean
hasHiddenMouse()
Returns true if this window does not want the application-wide mouse pointer drawn over it.boolean
hasOverriddenMenu()
Returns true if this window does not want menus to work while it is visible.boolean
hasZoomBox()
Returns true if this window has a maximize/zoom box.void
hide()
Hide window.boolean
inMovements()
See if this window is undergoing any movement/resize/etc.boolean
isHidden()
Returns true if this window is hidden.boolean
isModal()
Returns true if this window is modal.boolean
isResizable()
Returns true if this window is resizable.boolean
isShortcutKeypress(TKeypress key)
Determine if a keypress is overridden for this window.boolean
isShown()
Returns true if this window is shown.void
maximize()
Maximize window.protected boolean
mouseOnClose()
Returns true if the mouse is currently on the close button.protected boolean
mouseOnMaximize()
Returns true if the mouse is currently on the maximize/restore button.protected boolean
mouseOnResize()
Returns true if the mouse is currently on the resizable lower right corner.TStatusBar
newStatusBar(java.lang.String text)
Set the window's status bar to a new one.protected void
onClose()
Subclasses should override this method to cleanup resources.void
onCommand(TCommandEvent command)
Handle posted command events.protected void
onFocus()
Called by application.switchWindow() when this window gets the focus, and also by application.addWindow().protected void
onHide()
Called by application.hideWindow().void
onKeypress(TKeypressEvent keypress)
Handle keystrokes.void
onMenu(TMenuEvent menu)
Handle posted menu events.void
onMouseDown(TMouseEvent mouse)
Handle mouse button presses.void
onMouseMotion(TMouseEvent mouse)
Handle mouse movements.void
onMouseUp(TMouseEvent mouse)
Handle mouse button releases.protected void
onPreClose()
Subclasses should override this method to perform any user prompting before they are offscreen.void
onResize(TResizeEvent resize)
Method that subclasses can override to handle window/screen resize events.protected void
onShow()
Called by application.showWindow().protected void
onUnfocus()
Called by application.switchWindow() when another window gets the focus.void
removeShortcutKeypress(TKeypress key)
Remove a keypress to be overridden for this window.void
restore()
Restore (unmaximize) window.void
setCloseBox(boolean closeBox)
Set this window's close box flag.void
setHiddenMouse(boolean hideMouse)
Set request to prevent the application-wide mouse pointer from being drawn over this window.void
setMaximumWindowHeight(int maximumWindowHeight)
Set the maximum height for this window.void
setMaximumWindowWidth(int maximumWindowWidth)
Set the maximum width for this window.void
setMinimumWindowHeight(int minimumWindowHeight)
Set the minimum height for this window.void
setMinimumWindowWidth(int minimumWindowWidth)
Set the minimum width for this window.void
setResizable(boolean resizable)
Set this window's resizable flag.void
setTackboardsDirty()
Mark the underlay and overlay dirty.void
setTitle(java.lang.String title)
Set window title.void
setZ(int z)
Set Z order.void
setZoomBox(boolean zoomBox)
Set this window's maximize/zoom box flag.void
show()
Show window.void
stopMovements()
Stop any pending movement/resize/etc.java.lang.String
toString()
Generate a human-readable string for this window.-
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, 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, getMouseStyle, getParent, getTheme, getWidgetUnderMouse, getWidth, getWindow, getX, getY, handleEvent, hasChild, hLineXY, inputBox, inputBox, inputBox, isAbsoluteActive, isActive, isCursorVisible, isDrawable, isEchoKeystrokes, isEnabled, isPixelMouse, 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, setMouseStyle, setParent, setupForTWindow, setVisible, setWidth, setWindow, setX, setY, splitHorizontal, splitVertical, switchWidget, toPrettyString, toPrettyString, vLineXY
-
-
-
-
Field Detail
-
RESIZABLE
public static final int RESIZABLE
Window is resizable (default yes).- See Also:
- Constant Field Values
-
MODAL
public static final int MODAL
Window is modal (default no).- 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.
-
underlay
protected Tackboard underlay
A means of drawing arbitrary items underneath all widgets on this window.
-
overlay
protected Tackboard overlay
A means of drawing arbitrary items on top of all widgets on 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 windowtitle
- window title, will be centered along the top borderwidth
- width of windowheight
- 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 windowtitle
- window title, will be centered along the top borderwidth
- width of windowheight
- height of windowflags
- 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 windowtitle
- window title, will be centered along the top borderx
- column relative to parenty
- row relative to parentwidth
- width of windowheight
- 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 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
-
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 classTWidget
- 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:
onMouseMotion
in classTWidget
- Parameters:
mouse
- mouse motion event
-
onKeypress
public void onKeypress(TKeypressEvent keypress)
Handle keystrokes.- Overrides:
onKeypress
in classTWidget
- Parameters:
keypress
- keystroke event
-
onCommand
public void onCommand(TCommandEvent command)
Handle posted command events.
-
onMenu
public void onMenu(TMenuEvent menu)
Handle posted menu events.
-
onResize
public void onResize(TResizeEvent resize)
Method that subclasses can override to handle window/screen resize events.
-
getApplication
public final TApplication getApplication()
Get this TWindow's parent TApplication.- Overrides:
getApplication
in classTWidget
- Returns:
- this TWindow's parent TApplication
-
getScreen
public final Screen getScreen()
Get the Screen.
-
draw
public void draw()
Called by TApplication.drawChildren() to render on screen.
-
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).
-
close
public void close()
Close window. Note that windows without a close box can still be closed by calling the close() method.
-
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 pointer drawn over it.- Returns:
- true if this window does not want the application-wide mouse pointer drawn over it
-
setHiddenMouse
public final void setHiddenMouse(boolean hideMouse)
Set request to prevent the application-wide mouse pointer from being drawn over this window.- Parameters:
hideMouse
- if true, this window does not want the application-wide mouse pointer 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.
-
addUnderlay
public void addUnderlay(TackboardItem item)
Add a tackboard item to the underlay.- Parameters:
item
- the item to add
-
addOverlay
public void addOverlay(TackboardItem item)
Add a tackboard item to the overlay.- Parameters:
item
- the item to add
-
setTackboardsDirty
public void setTackboardsDirty()
Mark the underlay and overlay dirty.
-
-