Documentation | InterfaceKit | Slider
SYNOPSIS
Perl
use HaikuR1::Slider qw(:hash_mark_location :thumb_style); my $slider = HaikuR1::Slider->new( frame => $frame, name => "$name 1", label => $label, message => $message, minValue => $min_value, maxValue => $max_value, posture => $posture, thumbType => $thumbType, resizingMode => $resizing_mode, flags => $view_flags, ); $window->AddChild($slider);
Python
from HaikuR1.InterfaceKit import Slider, B_BUTTON_BEHAVIOR, B_TOGGLE_BEHAVIOR, B_POP_UP_BEHAVIOR slider = Slider( frame = frame, name = name, label = label, message = message, minValue = min_value, maxValue = max_value, posture = posture, thumbType = thumbType, resizingMode = resizingMode, flags = flags, ) window.AddChild(slider)
DESCRIPTION
Exposes the BSlider
object.
For more information on Slider, see the Be Book class description, the Be Book overview, and the Haiku Book class description.
METHODS
Constructor
Creates a Slider.
Perl
HaikuR1::Slider->new( frame => $frame, name => $name, label => $label, message => $message, minValue => $minValue, maxValue => $maxValue, posture => $posture, thumbType => $thumbType, resizingMode => $resizingMode, flags => $flags, ); HaikuR1::Slider->new($archive);
Python
Slider( frame = frame, name = name, label = label, message = message, minValue = minValue, maxValue = maxValue, posture = posture, thumbType = thumbType, resizingMode = resizingMode, flags = flags, ) Slider(archive)
frame
A Rect that indicates where on the parent Window the View should be. You should not specify a frame on a View that will be added to a parent which uses a Layout.
name
A string, the Button's internal name.
label
A string, the text that will be displayed on the Button.
message
A Message that will be sent when the Button is Invoked.
minValue
,maxValue
Integers, the range of the Slider's values
posture
An integer, one of the orientation constants; defaults to
B_HORIZONTAL
.thumbType
An integer, one of the thumb style constants defaults to
B_BLOCK_THUMB
.resizingMode
An integer, the resizing mode. (See the resizing mode constants.) Should only be specified when there is a frame. Defaults to
B_FOLLOW_NONE
.flags
An integer, view flags. (See the view flag constants.)
archive
A Message, contains an archived version of the Slider.
Frames
BarFrame
HashMarksFrame
ThumbFrame
Gets the indicated frame Rect.
Perl
$slider->BarFrame(); $slider->HashMarksFrame(); $slider->ThumbFrame();
Python
slider.BarFrame() slider.HashMarksFrame() slider.ThumbFrame()
Limits
GetLimits
SetLimits
MinLimitLabel
MaxLimitLabel
SetLimitLabels
Gets or sets the ends of the Slider's range, or the labels associated with
those values. SetLimits
and SetLimitLabels
may also be called as hooks.
Note: the limit labels are blank by default.
Perl
$slider->GetLimits(); $slider->SetLimits($min, $max); $slider->MinLimitLabel(); $slider->MaxLimitLabel(); $slider->SetLimitLabels($minLabel, $maxLabel);
Python
slider.GetLimits() slider.SetLimits(min, max) slider.MinLimitLabel() slider.MaxLimitLabel() slider.SetLimitLabels(minLabel, maxLabel)
min
,max
Integers, the values of the limits of the range.
minLabel
,maxLabel
Strings, the label values for each limit.
OffscreenView
If the C++ code has been compiled with a particular setting, all rendering will be done in an offscreen view. If the C++ code has not been compiled with that setting, this method will return the Slider itself.
Either way, if you want to change the way something is drawn in one of your overridden hooks, you should call this method and draw to the returned View.
Perl
$slider->OffscreenView();
Python
slider.OffscreenView()
Position
SetPosition
Gets or sets the current position of the Slider knob.SetPosition
may also be
called as a hook.
Perl
$slider->Position(); $slider->SetPosition($position);
Python
slider.Position() slider.SetPosition(position)
position
A floating point number between
0
and1
, the new position.
Properties
ModificationMessage
SetModificationMessage
SnoozeAmount
SetSnoozeAmount
KeyIncrementValue
SetKeyIncrementValue
HashMarkCount
SetHashMarkCount
HashMarks
SetHashMarks
Style
SetStyle
BarColor
SetBarColor
FillColor
UseFillColor
Orientation
SetOrientation
BarThickness
SetBarThickness
These methods do what you expect. The setter methods may also be called as hooks. By default, a Slider:
- has no modification message
- snoozes for
20 000
microseconds - has a key increment of
1
- does not display hash marks
- uses a block thumb (can be changed in the constructor)
- has a bar color slightly darker than the background
- does not use a fill color
- is horizontal (can be changed in the constructor)
- has a bar thickness of 6.0
The difference between the standard Control message and the modification message is that the modification message is sent when the user is changing the value (i.e., while the mouse button is held down, or when a key is pressed) and the standard message is sent when the user has finished changing the value (i.e., the mouse or key is released).
If you want to change some element in real time while the user is changing the value, the set a modification message and use it to track those changes. If you only care about what the user's final choice of value was, leave the modification message empty and don't worry about it.
Perl
$slider->ModificationMessage(); $slider->SetModificationMessage($message); $slider->SnoozeAmount(); $slider->SetSnoozeAmount($amount); $slider->KeyIncrementValue(); $slider->SetKeyIncrementValue($value); $slider->HashMarkCount(); $slider->SetHashMarkCount($count); $slider->HashMarks(); $slider->SetHashMarks($where); $slider->Style(); $slider->SetStyle($style); $slider->BarColor(); $slider->SetBarColor($color); $slider->FillColor(); $slider->UseFillColor($color); $slider->Orientation(); $slider->SetOrientation($posture); $slider->BarThickness(); $slider->SetBarThickness($thickness);
Python
slider.ModificationMessage() slider.SetModificationMessage(message) slider.SnoozeAmount() slider.SetSnoozeAmount(amount) slider.KeyIncrementValue() slider.SetKeyIncrementValue(value) slider.HashMarkCount() slider.SetHashMarkCount(count) slider.HashMarks() slider.SetHashMarks(where) slider.Style() slider.SetStyle(style) slider.BarColor() slider.SetBarColor(color) slider.FillColor() slider.UseFillColor(color) slider.Orientation() slider.SetOrientation(posture) slider.BarThickness() slider.SetBarThickness(thickness)
message
The midification Message.
amount
An integer, the snooze amount in microseconds.
value
An integer, the amount the Slider will change for key presses.
count
An integer, the number of hash marks to draw.
where
An integer hash mark location constant.
style
An integer thumb style constant.
color
An rgb_color, the new bar or fill color. (Fill color can be set to the empty value to turn off fill coloring.)
posture
An integer orientation constant.
thickness
A floating point number, the new thickness.
UpdateTextChanged
Signals that the has update text has changed; this will result in the UpdateText hook being called.
Perl
$slider->UpdateTextChanged();
Python
slider.UpdateTextChanged()
HOOKS
Drawing
DrawSlider
DrawBar
DrawHashMarks
DrawThumb
DrawFocusMark
DrawText
Called during drawing, allowing you to override an individual element without
overriding the entire Draw hook. Draw
calls
DrawSlider
, which calls the other five methods.
Perl
$slider->DrawSlider(); $slider->DrawBar(); $slider->DrawHashMarks(); $slider->DrawThumb(); $slider->DrawFocusMark(); $slider->DrawText();
Python
slider.DrawSlider() slider.DrawBar() slider.DrawHashMarks() slider.DrawThumb() slider.DrawFocusMark() slider.DrawText()
UpdateText
MaxUpdateTextWidth
UpdateText
is called when the system needs to fetch the update text. The
default version returns an empty string.
MaxUpdateTextWidth
is called when the system needs to determine how much
space to reserve for the update text. The default version currently returns
the width of the label for the maximum value.
Perl
$slider->UpdateText(); $slider->MaxUpdateTextWidth();
Python
slider.UpdateText() slider.MaxUpdateTextWidth()
ValueForPoint
Called when the user changes the Slider position with the mouse.
Perl
$slider->ValueForPoint($point);
Python
slider.ValueForPoint(point)
point
A Point, the mouse location in the Slider's coordinate system. (Note: the Be Book indicates this is screen coordinates, but the Haiku code operates on View coordinates.)
CONSTANTS
Hash mark location
Perl
use HaikuR1::Slider qw(:hash_mark_location)
Python
Python does not support export tags.
- B_HASH_MARKS_NONE
- B_HASH_MARKS_TOP
- B_HASH_MARKS_LEFT
- B_HASH_MARKS_BOTTOM
- B_HASH_MARKS_RIGHT
- B_HASH_MARKS_BOTH
Thumb style
Perl
use HaikuR1::Slider qw(:thumb_style)
Python
Python does not support export tags.
- B_BLOCK_THUMB
- B_TRIANGLE_THUMB
SCRIPTING SUITE
Slider inherits the following suites: