Documentation | InterfaceKit | ScrollBar
SYNOPSIS
Perl
use HaikuR1::Application; use HaikuR1::Window; use HaikuR1::View; use HaikuR1::ScrollBar; # define MyApplication, MyWindow, MyView, and MyScrollBar subclass here my $app = MyApplication->new($signature); my $window = MyWindow->new( frame => Rect->new($left, $top, $right, $bottom), title => $title, type => B_TITLED_WINDOW, flags => B_QUIT_ON_WINDOW_CLOSE, workspaces => B_CURRENT_WORKSPACE, ); my $view = MyView->new( frame => Rect->new($vleft, $vtop, $vright, $vbottom), name => $name, resizingMode => $resizing_mode, flags = >$vflags, ); my $scrollbar = MyScrollBar->new( frame => Rect->new($vleft, $vtop, $vright, $vbottom), name => $name2, target => $view, min => $min, max => $max, direction => $direction, ); $window->AddChild($scrollview); $window->Show(); $app->Run(); # wait for an event to Quit the app or window
Python
from HaikuR1.ApplicationKit import Application from HaikuR1.InterfaceKit import Window from HaikuR1.InterfaceKit import View from HaikuR1.InterfaceKit import ScrollBar # define MyApplication, MyWindow, MyView, and MyScrollBar subclass here app = MyApplication(signature) window = MyWindow( frame = Rect(left, top, right, bottom), title = title, type = B_TITLED_WINDOW, flags = B_QUIT_ON_WINDOW_CLOSE, workspaces = B_CURRENT_WORKSPACE, ) view = MyView( frame = Rect(vleft, vtop, vright, vbottom), name = name, resizingMode = resizing_mode, flags = >vflags, ) scrollbar = MyScrollBar( frame = Rect(vleft, vtop, vright, vbottom), name = name2, target = view, min = min, max = max, direction = direction, ) window.AddChild(scrollview) window.Show() app.Run() # wait for an event to Quit the app or window
DESCRIPTION
Exposes the BScrollBar
object.
For more information on ScrollBar, see the Be Book class description, the Be Book overview, and the Haiku Book class description.
METHODS
Constructor
Creates a ScrollBar.
Perl
HaikuR1::ScrollBar->new( frame => $frame, name => $name, target => $target, min => $min, max => $max, direction => $direction, ); HaikuR1::ScrollBar->newWithoutFrame( name => $name, target => $target, min => $min, max => $max, direction => $direction, ); HaikuR1::ScrollBar->newFromArchive($archive);
Python
ScrollBar( frame = frame, name = name, target = target, min = min, max = max, direction = direction, ) ScrollBar.WithoutFrame( name = name, target = target, min = min, max = max, direction = direction, ) ScrollBar.FromArchive(archive)
frame
A Rect that indicates where on the parent Window the ScrollBar should be. You should not specify a frame on a ScrollBar that will be added to a parent which uses a Layout.
name
A string, the ScrollBar's internal name.
target
A View, the target of the ScrollBar; that is, the View that the ScrollBar will scroll.
min
,max
Floating point numbers, the initial range for the ScrollBar.
direction
One of the orientation constants.
archive
A Message, contains an archived version of the ScrollBar.
Border
SetBorderHighlighted
Sets the ScrollBar's highlighted state.
This method is used internally when the target View's focus rectangle should extend around the ScrollBar. You probably won't need to use it unless you are creating a custom View.
Perl
$scrollbar->SetBorderHighlighted($state);
Python
scrollbar.SetBorderHighlighted(state)
state
A boolean; if true, the border is highlighted.
Orientation
SetOrientation
Gets or sets the ScrollBar's direction (horizontal or vertical).
Perl
$scrollbar->Orientation(); $scrollbar->SetOrientation($direction);
Python
scrollbar.Orientation() scrollbar.SetOrientation(direction)
direction
One of the orientation constants.
Proportion
SetProportion
Gets or sets the ScrollBar's proportion; the proportion is a value between 1 and 0 that indicates the proportion of the target View's contents that is visible inside the View.
For example, if half of the View's contents are visible at a time within the
View's frame, set the proportion to 0.5
.
Perl
$scrollbar->Proportion(); $scrollbar->SetProportion($proportion);
Python
scrollbar.Proportion() scrollbar.SetProportion(proportion)
proportion
A floating point number, the new proportion.
Range
GetRange
SetRange
Get or sets the ScrollBar's range; that is, the minimum and maximum allowable values.
Perl
Two values are returned (not an array reference).
Perl
$scrollbar->GetRange(); $scrollbar->SetRange($min, $max);
Python
scrollbar.GetRange() scrollbar.SetRange(min, max)
min
,max
Floating point numbers, the new range for the ScrollBar.
Steps
GetSteps
SetSteps
Gets or sets the ScrollBar's steps; that is, the amounts by which user action changes the scrollbar.
Perl
Two values are returned (not an array reference).
Perl
$scrollbar->GetSteps(); $scrollbar->SetSteps($smallStep, $largeStep);
Python
scrollbar.GetSteps() scrollbar.SetSteps(smallStep, largeStep)
smallStep
A floating point number, the amount the View scrolls when the user clicks one of the arrows at the end of the ScrollBar. (The default value is
1.0
, which is probably too small.)largeStep
A floating point number, the amount the View scrolls when the user clicks in the bar itself but not on the knob. (The default value is
10.0
, which is probably too small.)
Target
SetTarget
Gets or sets the ScrollBar's target.
Perl
$scrollbar->Target(); $scrollbar->SetTarget($target); $scrollbar->SetTarget($targetName);
Python
scrollbar.Target() scrollbar.SetTarget(target) scrollbar.SetTarget(targetName)
target
A View, the new target.
targetName
A string, the name of the new target. This function uses Window.FindView internally, so both the ScrollBar and the target View must already be attached to the same Window for this to work.
Value
SetValue
Gets or sets the ScrollBar's value; the value should be within the range; if it is not, it will be accordingly adjusted.
Perl
$scrollbar->Value(); $scrollbar->SetValue($value);
Python
scrollbar.Value() scrollbar.SetValue(value)
value
A floating point number, the new value.
HOOKS
ValueChanged
Called when the value changes. This method is called whenever the value changes.
The default version does the range checking, so be sure to call the base class version if you override this.
Perl
$scrollbar->ValueChanged($newValue);
Python
scrollbar.ValueChanged(newValue)
newValue
A floating point number, the new value.
ARCHIVABLE INTERFACE
ScrollView
inherits the methods and hooks of Archivable.
HANDLER INTERFACE
ScrollView
inherits the methods and hooks of Handler.
VIEW INTERFACE
ScrollView
inherits the methods and hooks of View.
The following differ from the View
versions:
AttachedToWindow
Sends the ScrollBar's value to the App Server. If you override this hook in a custom ScrollBar, be sure to call the base class version to make sure this happens.
WindowActivated
Under some circumstances (see below), ScrollBars are disabled when the Window becomes inactive. If you override this hook in a custom ScrollBar, you should call the base class version to ensure this occurs.
CONSTANTS
The ScrollBar constants represent values used when compiling the C++ code. It is possible, for example, to use set_scroll_bar_info to set a different width and height than those indicated by the constants.
(Please note, however, that set_scroll_bar_info
affects the entire system.
At this time, the public Haiku R1 API does not support setting widths for
individual scrollbars.)
Size
Perl
use HaikuR1::ScrollBar qw(:size)
Python
Python does not support export tags.
- B_V_SCROLL_BAR_WIDTH
- B_H_SCROLL_BAR_HEIGHT
- SCROLL_BAR_MAXIMUM_KNOB_SIZE
- SCROLL_BAR_MINIMUM_KNOB_SIZE
Other constants
These constants do not have an export tag.
DISABLES_ON_WINDOW_DEACTIVATION
If this is set to a true value, then ScrollBars will be disabled when the Window is deactivated.
(This is also a system-wide setting that is defined when the C++ code is compiled.)
SCRIPTING SUITE
ScrollBar inherits the following suites: