NAME
TView - base class for all visual components in Turbo Vision
HIERARCHY
TObject
TView
SYNOPSIS
use TUI::Views;
my $view = TView->new(bounds => $bounds);
$view->draw();
$view->handleEvent($event);
DESCRIPTION
TView is the fundamental base class for all visible objects in Turbo Vision. Every visual component shown on the screen ultimately derives from TView.
The class provides the core infrastructure required for drawing, event handling, coordinate transformation, focus management, command processing, and interaction with the owning view hierarchy. Most applications do not use TView directly but instead instantiate one of its many descendants such as dialogs, windows, list viewers, or menu views.
TView defines a large number of methods, many of which are intended for internal use or for implementation by subclasses. Application code typically interacts with TView through state flags, command handling, drawing helpers, and event dispatch.
The behavior and appearance of a view are controlled primarily through its state, options, event mask, and geometry attributes.
Commonly Used Features
In day-to-day application code, the most relevant configuration fields are growMode, dragMode, helpCtx, state, options, and eventMask. They define resize behavior, input handling, help context, and event routing.
The methods most commonly touched outside framework internals are clearEvent, commandEnabled, dataSize, disableCommands, draw, drawView, enableCommands, getColor, getCommands, getHelpCtx, getPalette, getState, hideCursor, normalCursor, select, setCommands, setState, show, showCursor, valid, writeLine, and writeStr.
VARIABLES
The following global variables define default behavior and visual properties shared by all TView objects.
$shadowSize
Default size of the view shadow, specified as a TPoint.
$shadowAttr
Attribute value used when drawing view shadows.
$showMarkers
Controls whether focus and selection markers are displayed.
$specialChars
Array reference defining special navigation and marker characters.
$errorAttr
Attribute value used to render views in an error state.
$commandSetChanged
Indicates whether the active command set has been modified.
$curCommandSet
Holds the current default command set used for command enabling and dispatch.
ATTRIBUTES
The following attributes define the geometry, state, and ownership of a view. Unless otherwise noted, attributes are part of the public view state and may be read or modified by application code.
- next
-
Internal link to the next view in the owner's Z-ordered view list. This attribute is managed internally.
- size
-
Size of the view as a
TPoint. - origin
-
Upper-left corner of the view relative to its owner.
- cursor
-
Current cursor position within the view.
- owner
-
Owning group of this view (TGroup). This reference is managed internally.
- options
-
View option flags (Int), typically a combination of
ofXXXXconstants. - eventMask
-
Event mask controlling which event classes are accepted by the view.
- state
-
Current state flags of the view, such as visibility, selection, and cursor mode (
sfXXXXconstants). - growMode
-
Grow mode flags controlling how the view resizes when its owner changes size (
gfXXXXconstants). - dragMode
-
Drag behavior flags controlling how the view responds to mouse dragging (
dmXXXXconstants). - helpCtx
-
Help context identifier associated with the view.
CONSTRUCTOR
new
my $view = TView->new(bounds => $bounds);
Creates and initializes a new view with the specified bounding rectangle. The view is created with default state, option, and event mask values.
- bounds
-
Bounding rectangle of the view (TRect).
new_TView
my $view = new_TView($bounds);
Factory-style constructor using positional arguments.
This constructor is equivalent to calling new with the bounds parameter and is provided for compatibility with traditional Turbo Vision construction patterns.
DESTRUCTOR
DEMOLISH
$self->DEMOLISH($in_global_destruction);
Destroys the view and removes it from the screen and the view hierarchy. This method corresponds to the Turbo Vision destructor and is normally called automatically by the owning group.
METHODS
TView defines a comprehensive set of methods for drawing, event handling, state management, and interaction with the view hierarchy. Many of these methods are intended to be used by subclasses or internally by the framework.
new
my $view = TView->new(bounds => $bounds);
Initializes an instance of TView with the specified bounds.
- bounds
-
The bounds of the view (TRect).
DEMOLISH
$self->DEMOLISH();
TopView
my $view = $self->TopView();
Returns the top view in the view hierarchy.
awaken
$self->awaken();
Prepares the view for activation.
blockCursor
$self->blockCursor();
Sets the cursor to block mode.
calcBounds
$self->calcBounds($bounds, $delta);
Calculates the bounds of the view based on the given delta.
changeBounds
$self->changeBounds($bounds);
Changes the bounds of the view.
clearEvent
$self->clearEvent($event);
Clears the specified event.
commandEnabled
my $bool = TView->commandEnabled($command);
Checks if the specified command is enabled.
containsMouse
my $bool = $self->containsMouse($event);
Checks if the mouse is within the view's bounds.
dataSize
my $size = $self->dataSize();
Returns the size of the view's data.
disableCommand
$self->disableCommand($command);
Disables the specified command.
disableCommands
$self->disableCommands($commands);
Disables the specified commands.
dragView
$self->dragView($event, $mode, $limits, $minSize, $maxSize);
Handles the dragging of the view.
draw
$self->draw();
Draws the view on the screen.
drawCursor
$self->drawCursor();
Draws the cursor in the view.
drawHide
$self->drawHide($lastView | undef);
Hides the view by drawing over it.
drawShow
$self->drawShow($lastView | undef);
Shows the view by drawing it.
drawUnderRect
$self->drawUnderRect($r, $lastView | undef);
Draws the view under the specified rectangle.
drawUnderView
$self->drawUnderView($doShadow, $lastView | undef);
Draws the view under another view.
drawView
$self->drawView();
Draws the view.
enableCommand
$self->enableCommand($command);
Enables the specified command.
enableCommands
$self->enableCommands($commands);
Enables the specified commands.
endModal
$self->endModal($command);
Ends the modal state of the view.
eventAvail
my $bool = $self->eventAvail();
Checks if an event is available.
execute
my $cmd = $self->execute();
Executes the view.
exposed
my $bool = $self->exposed();
Checks if the view is exposed.
focus
my $bool = $self->focus();
Sets the focus to the view.
getBounds
my $rect = $self->getBounds();
Returns the bounds of the view.
getClipRect
my $rect = $self->getClipRect();
Returns the clipping rectangle of the view.
getColor
my $int = $self->getColor($color);
Returns the color of the view.
getCommands
$self->getCommands($commands);
Gets the commands of the view.
getData
$self->getData(\@rec);
Returns the data of the view.
getEvent
$self->getEvent($event);
Gets the specified event.
getExtent
my $rect = $self->getExtent();
Returns the extent of the view.
getHelpCtx
my $int = $self->getHelpCtx();
Returns the help context of the view.
getPalette
my $palette = $self->getPalette();
Returns the view's color palette.
getState
my $bool = $self->getState($aState);
Returns the state of the view.
growTo
$self->growTo($x, $y);
Grows the view to the specified size.
handleEvent
$self->handleEvent($event);
Handles an event sent to the view.
hide
$self->hide();
Hides the view.
hideCursor
$self->hideCursor();
Hides the cursor in the view.
keyEvent
$self->keyEvent($event);
Handles a key event.
locate
$self->locate($bounds);
Positions the view within the specified bounds.
makeFirst
my $void = $self->makeFirst();
Moves the view to the front of the view hierarchy.
makeGlobal
my $point = $self->makeGlobal($source);
Converts a local point to a global point.
makeLocal
my $point = $self->makeLocal($source);
Converts a global point to a local point.
mapColor
my $int = $self->mapColor($color);
Maps a color to the view's palette.
mouseEvent
my $bool = $self->mouseEvent($event, $mask);
Handles a mouse event.
mouseInView
my $bool = $self->mouseInView($mouse);
Checks if the mouse is within the view.
moveTo
$self->moveTo($x, $y);
Moves the view to the specified position.
nextView
my $view | undef = $self->nextView();
Returns the next view in the view hierarchy.
normalCursor
$self->normalCursor();
Sets the cursor to normal mode.
prev
my $view | undef = $self->prev();
Returns the previous view in the view hierarchy.
prevView
my $view | undef = $self->prevView();
Returns the previous view in the view hierarchy.
putEvent
$self->putEvent($event);
Puts an event in the event queue.
putInFrontOf
$self->putInFrontOf($target | undef);
Puts the view in front of the specified target view.
resetCursor
$self->resetCursor();
Resets the cursor in the view.
select
$self->select();
Selects the view.
setBounds
$self->setBounds($bounds);
Sets the bounds of the view to the specified values.
setCmdState
$self->setCmdState($commands, $enable);
Sets the command state of the view.
setCommands
$self->setCommands($commands);
Sets the commands of the view.
setCursor
$self->setCursor($x, $y);
Sets the position of the cursor in the view to the specified values.
setData
$self->setData($rec);
Sets the data of the view to the specified values.
setState
$self->setState($aState, $enable);
Sets the state of the view to the specified value.
show
$self->show();
Shows the view.
showCursor
$self->showCursor();
Displays the cursor in the view.
shutDown
$self->shutDown();
Shuts down the view.
sizeLimits
$self->sizeLimits($min, $max);
Determines the minimum and maximum sizes of the view.
valid
my $bool = $self->valid($command);
Checks if the view is valid for the specified command.
writeBuf
$self->writeBuf($x, $y, $w, $h, $b);
Writes a buffer to the view.
writeChar
$self->writeChar($x, $y, $c, $color, $count);
Writes a character to the view.
writeLine
$self->writeLine($x, $y, $w, $h, $b);
Writes a line to the view.
writeStr
$self->writeStr($x, $y, $str, $color);
Writes a string to the view.
AUTHORS
- Borland International (original Turbo Vision design)
- J. Schneider <brickpool@cpan.org> (Perl implementation and maintenance)
COPYRIGHT AND LICENSE
Copyright (c) 1990-1994, 1997 by Borland International
Copyright (c) 2021-2026 the "AUTHORS" as listed above.
This software is licensed under the MIT license (see the LICENSE file, which is part of the distribution). This documentation is provided under the same terms as the Turbo Vision library itself.