Skip to main content

Class JtvWindow

public class JtvWindow
extends JtvGroup

A bordered, titled window with optional close, zoom, and resize controls.

JtvWindow extends JtvGroup to provide a standard JT Vision window. It automatically creates and inserts a JtvFrame that draws the border, title bar, close button, zoom button, and resize corner icons.

Window flags

The flags field is a bitmask of wfXXXX constants that control which interactive features are enabled:

  • wfMove — the window can be dragged by its title bar.
  • wfGrow — the window can be resized from its bottom corners.
  • wfClose — a close button is shown; clicking it or pressing Ctrl+F4 sends cmClose.
  • wfZoom — a zoom button is shown; clicking it or pressing F5 toggles the window between its normal and maximum size.

All four flags are set by default. When selected, the corresponding commands (cmResize, cmClose, cmZoom, cmNext, cmPrev) are enabled in the global command set and disabled again when the window loses focus.

Colour palettes

Three built-in palettes are available, selected by the paletteIndex field: wpBlueWindow (default), wpCyanWindow, and wpGrayWindow.

Colour palette

Each window palette has 8 entries:

  1. Passive (inactive) frame colour.
  2. Active frame colour.
  3. Frame icons colour (close, zoom, resize).
  4. Scroll bar page area colour.
  5. Scroll bar arrow controls colour.
  6. Scroller normal text colour.
  7. Scroller selected text colour.
  8. Reserved.

Scroll bars

Use standardScrollBar(int) to create a keyboard-driven scroll bar attached to the window frame. Pass sbVertical or sbHorizontal (optionally OR-ed with sbHandleKeyboard) to control orientation.

Zoom

Calling zoom() toggles between the maximum size and the size stored in zoomRect. zoomRect is updated whenever the window is at a non-maximum size when zoom is activated.

org.viktor44.jtvision.views.JtvWindow

Summary​

Constructors​

VisibilitySignature
publicJtvWindow(JtvRect bounds, String aTitle, int aNumber)

Fields​

ModifiersField nameType
protectedflagsint
protectedzoomRectorg.viktor44.jtvision.core.JtvRect
protectednumberint
protectedpaletteIndexint
protectedtitleString
protectedframeorg.viktor44.jtvision.views.JtvFrame
public static finalcpBlueWindoworg.viktor44.jtvision.core.JtvPalette
public static finalcpCyanWindoworg.viktor44.jtvision.core.JtvPalette
public static finalcpGrayWindoworg.viktor44.jtvision.core.JtvPalette

Methods​

ModifiersMethod signatureReturn type
publicclose()void
publicgetPalette()org.viktor44.jtvision.core.JtvPalette
publicgetTitle(int maxSize)String
publichandleEvent(JtvEvent event)void
protectedinitFrame(JtvRect r)org.viktor44.jtvision.views.JtvFrame
publicsetState(int aState, boolean enable)void
publicstandardScrollBar(int aOptions)org.viktor44.jtvision.views.JtvScrollBar
publiczoom()void
publicgetFlags()int
publicsetFlags(int flags)void
publicgetZoomRect()org.viktor44.jtvision.core.JtvRect
publicsetZoomRect(JtvRect zoomRect)void
publicgetNumber()int
publicsetNumber(int number)void
publicgetPaletteIndex()int
publicsetPaletteIndex(int paletteIndex)void
publicgetTitle()String
publicsetTitle(String title)void

Constructors​

JtvWindow(JtvRect bounds, String aTitle, int aNumber)​

Creates a window.

Initialises flags to wfMove | wfGrow | wfClose | wfZoom, palette to wpBlueWindow, and state includes sfShadow. Options include ofSelectable | ofTopSelect (the window floats to the front when selected) and grow-mode is gfGrowAll | gfGrowRel.

Parameters

  • bounds - the initial bounding rectangle
  • aTitle - the title bar text
  • aNumber - the window number (use wnNoNumber to omit)

Fields​

int flags​

Bitmask of wfXXXX window-feature flags (wfMove, wfGrow, wfClose, wfZoom).

org.viktor44.jtvision.core.JtvRect zoomRect​

The bounding rectangle to restore when the window is un-zoomed. Updated by zoom() before maximising.

int number​

The window's sequence number displayed in the title bar (e.g. :1). Use wnNoNumber to suppress the number display.

int paletteIndex​

Selects the window colour palette: wpBlueWindow, wpCyanWindow, or wpGrayWindow.

String title​

The text displayed in the window's title bar. Accessed by the frame via getTitle(int).

org.viktor44.jtvision.views.JtvFrame frame​

The JtvFrame child view that draws this window's border, title, and control icons. Set to null during shutDown().

org.viktor44.jtvision.core.JtvPalette cpBlueWindow​

Blue-window palette — 8 entries, used when paletteIndex is wpBlueWindow:

  • 8 — passive frame.
  • 9 — active frame.
  • 10 — frame icons (close, zoom, resize).
  • 11 — scroll bar page area.
  • 12 — scroll bar arrow controls.
  • 13 — scroller normal text.
  • 14 — scroller selected text.
  • 15 — reserved.

org.viktor44.jtvision.core.JtvPalette cpCyanWindow​

Cyan-window palette — 8 entries, used when paletteIndex is wpCyanWindow:

  • 16 — passive frame.
  • 17 — active frame.
  • 18 — frame icons (close, zoom, resize).
  • 19 — scroll bar page area.
  • 20 — scroll bar arrow controls.
  • 21 — scroller normal text.
  • 22 — scroller selected text.
  • 23 — reserved.

org.viktor44.jtvision.core.JtvPalette cpGrayWindow​

Gray-window palette — 8 entries, used when paletteIndex is wpGrayWindow:

  • 24 — passive frame.
  • 25 — active frame.
  • 26 — frame icons (close, zoom, resize).
  • 27 — scroll bar page area.
  • 28 — scroll bar arrow controls.
  • 29 — scroller normal text.
  • 30 — scroller selected text.
  • 31 — reserved.

Methods​

close()​

Validates and removes this window from its owner if valid(int) approves cmClose.

getPalette()​

Returns the colour palette for the current paletteIndex choice. Defaults to cpBlueWindow for any unrecognised palette value.

Returns

the active window colour palette

getTitle(int maxSize)​

Returns the title bar text, truncated to maxSize characters. The frame uses this method when rendering the title.

Parameters

  • maxSize - the maximum number of characters to return

Returns

the window title (currently ignores the maxSize limit)

handleEvent(JtvEvent event)​

Overrides:

handleEvent(JtvEvent event) in org.viktor44.jtvision.views.JtvGroup

Handles window-specific commands and keyboard shortcuts:

  • cmResize — starts an interactive drag/resize session when wfMove or wfGrow is set.
  • cmClose — closes the window (non-modal) or sends cmCancel (modal).
  • cmZoom — toggles the zoom state when wfZoom is set.
  • Tab / Shift+Tab — moves focus forward or backward among children.
  • cmSelectWindowNum broadcast — selects this window if its number matches.

Parameters

  • event - the incoming event

initFrame(JtvRect r)​

Constructs JtvFrame for the given bounds.

Parameters

  • r - the frame's bounding rectangle (the window's extent)

Returns

a new JtvFrame

setState(int aState, boolean enable)​

Overrides:

setState(int aState, boolean enable) in org.viktor44.jtvision.views.JtvGroup

Propagates the sfSelected state change by toggling sfActive on the window and its frame, and enabling or disabling the window-management command set (cmNext, cmPrev, cmResize, cmClose, cmZoom).

Parameters

  • aState - the state bits to modify
  • enable - true to set; false to clear

standardScrollBar(int aOptions)​

Creates and inserts a scroll bar aligned to one of the window's interior edges.

For a vertical scroll bar the bar occupies the rightmost column; for a horizontal scroll bar it occupies the bottom row. If sbHandleKeyboard is included in aOptions, the scroll bar receives keyboard events via ofPostProcess.

Parameters

  • aOptions - sbVertical or sbHorizontal, optionally OR-ed with sbHandleKeyboard

Returns

the newly created and inserted JtvScrollBar

zoom()​

Toggles between the maximum size and the pre-zoom size stored in zoomRect.

If the window is not already at maximum size, zoomRect is updated with the current bounds before the window is expanded to the maximum. If the window is already at maximum size, zoomRect is restored.

getFlags()​

Bitmask of wfXXXX window-feature flags (wfMove, wfGrow, wfClose, wfZoom).

setFlags(int flags)​

Bitmask of wfXXXX window-feature flags (wfMove, wfGrow, wfClose, wfZoom).

Parameters

  • flags

getZoomRect()​

The bounding rectangle to restore when the window is un-zoomed. Updated by zoom() before maximising.

setZoomRect(JtvRect zoomRect)​

The bounding rectangle to restore when the window is un-zoomed. Updated by zoom() before maximising.

Parameters

  • zoomRect

getNumber()​

The window's sequence number displayed in the title bar (e.g. :1). Use wnNoNumber to suppress the number display.

setNumber(int number)​

The window's sequence number displayed in the title bar (e.g. :1). Use wnNoNumber to suppress the number display.

Parameters

  • number

getPaletteIndex()​

Selects the window colour palette: wpBlueWindow, wpCyanWindow, or wpGrayWindow.

setPaletteIndex(int paletteIndex)​

Selects the window colour palette: wpBlueWindow, wpCyanWindow, or wpGrayWindow.

Parameters

  • paletteIndex

getTitle()​

The text displayed in the window's title bar. Accessed by the frame via getTitle(int).

setTitle(String title)​

The text displayed in the window's title bar. Accessed by the frame via getTitle(int).

Parameters

  • title