NAME
TScroller - base class for scrollable views in Turbo Vision
HIERARCHY
TObject
TView
TScroller
TTextDevice
TTerminal
SYNOPSIS
use TUI::Views;
my $scroller = TScroller->new(
bounds => $bounds,
aHScrollBar => $hBar,
aVScrollBar => $vBar
);
$scroller->setLimit(100, 50);
$scroller->scrollTo(10, 5);
DESCRIPTION
TScroller provides the core infrastructure for scrollable views in Turbo Vision. It maintains a two-dimensional scroll offset and coordinates scrolling behavior between the view and optional horizontal and vertical scroll bars.
The class itself does not render content. Instead, it serves as a base class for views that display scrollable data, such as text devices and terminal-like output views. Descendants are responsible for drawing their content relative to the current scroll position.
TScroller keeps its internal scroll offset synchronized with attached scroll bars. When the scroll bars change, the scroller updates its offset and redraws the view. Conversely, programmatic changes to the scroll position are reflected in the scroll bars.
ATTRIBUTES
The following attributes describe the scrolling state of the view. Attributes marked as read-only are managed internally.
- delta
-
Current scroll offset as a point (TPoint). Represents the horizontal and vertical scroll position.
- limit
-
Maximum allowed scroll offset (TPoint). Defines the bounds of the scrollable area.
- aHScrollBar
-
Reference to the horizontal scroll bar (TScrollBar), if present.
- aVScrollBar
-
Reference to the vertical scroll bar (TScrollBar), if present.
- drawLock
-
Internal counter used to suppress redraw operations during batch updates.
- drawFlag
-
Indicates whether a redraw is pending once drawing is re-enabled.
CONSTRUCTOR
new
my $scroller = TScroller->new(
bounds => $bounds,
aHScrollBar => $hBar,
aVScrollBar => $vBar
);
Creates a new scroller with the specified bounds and optional scroll bars.
- bounds
-
Bounding rectangle of the scroller (TRect).
- aHScrollBar
-
Horizontal scroll bar associated with the scroller (TScrollBar or undef).
- aVScrollBar
-
Vertical scroll bar associated with the scroller (TScrollBar or undef).
new_TScroller
my $scroller = new_TScroller($bounds, $hBar | undef, $vBar | undef);
Factory-style constructor using positional arguments.
This constructor is equivalent to calling new with named parameters and is provided for compatibility with traditional Turbo Vision construction patterns.
DESTRUCTOR
DEMOLISH
$self->DEMOLISH($in_global_destruction);
Destroys the scroller and releases references to associated scroll bars. This method corresponds to the Turbo Vision destructor and is normally invoked automatically.
METHODS
changeBounds
$scroller->changeBounds($bounds);
Updates the bounds of the scroller and recalculates internal geometry.
checkDraw
$scroller->checkDraw();
Performs a deferred redraw if drawing was previously suppressed.
getPalette
my $palette = $scroller->getPalette();
Returns the color palette used by the scroller.
handleEvent
$scroller->handleEvent($event);
Processes events relevant to scrolling, including notifications from attached scroll bars.
scrollDraw
$scroller->scrollDraw();
Synchronizes the internal scroll offset with the scroll bar values and redraws the view if necessary.
scrollTo
$scroller->scrollTo($x, $y);
Sets the scroll position to the specified coordinates.
setLimit
$scroller->setLimit($x, $y);
Defines the maximum scrollable range and updates the scroll bars accordingly.
setState
$scroller->setState($state, $enable);
Updates the state flags of the scroller and redraws if required.
shutDown
$scroller->shutDown();
Shuts down the scroller and clears associated resources.
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) 2025-2026 the "AUTHORS" as listed above.
This software is licensed under the MIT license (see the LICENSE file, which is part of the distribution).