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)
frameA 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.
nameA string, the Button's internal name.
labelA string, the text that will be displayed on the Button.
messageA Message that will be sent when the Button is Invoked.
minValue,maxValueIntegers, the range of the Slider's values
postureAn integer, one of the orientation constants; defaults to
B_HORIZONTAL.thumbTypeAn integer, one of the thumb style constants defaults to
B_BLOCK_THUMB.resizingModeAn integer, the resizing mode. (See the resizing mode constants.) Should only be specified when there is a frame. Defaults to
B_FOLLOW_NONE.flagsAn integer, view flags. (See the view flag constants.)
archiveA 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,maxIntegers, the values of the limits of the range.
minLabel,maxLabelStrings, 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)
positionA floating point number between
0and1, 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 000microseconds - 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)
messageThe midification Message.
amountAn integer, the snooze amount in microseconds.
valueAn integer, the amount the Slider will change for key presses.
countAn integer, the number of hash marks to draw.
whereAn integer hash mark location constant.
styleAn integer thumb style constant.
colorAn rgb_color, the new bar or fill color. (Fill color can be set to the empty value to turn off fill coloring.)
postureAn integer orientation constant.
thicknessA 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)
pointA 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: