NAME
Fl::Slider - Widget with a Sliding Knob Inside a Box
Description
The Fl::Slider widget contains a sliding knob inside a box.
It is often used as a scrollbar. Moving the box all the way to the top/left sets it to the minimum(), and to the bottom/right to the maximum(). The minimum() may be greater than the maximum() to reverse the slider direction.
Use Fl::Widget->type($type) to set how the slider is drawn, which can be one of the following:
- FL_VERTICAL - Draws a vertical slider (this is the default).
- FL_HORIZONTAL - Draws a horizontal slider.
- FL_VERT_FILL_SLIDER - Draws a filled vertical slider, useful as a progress or value meter.
- FL_HOR_FILL_SLIDER - Draws a filled horizontal slider, useful as a progress or value meter.
- FL_VERT_NICE_SLIDER - Draws a vertical slider with a nice looking control knob.
- FL_HOR_NICE_SLIDER - Draws a horizontal slider with a nice looking control knob.
All of these values can be imported with the :type
tag.
Methods
Fl::Slider inherits from Fl::Valuator and Fl::Widget. On top of that, it exposes the following methods...
new(...)
my $val_a = Fl::Slider->new(0, 0, 250, 500, 'Important Stuff');
my $val_b = Fl::Slider->new(0, 0, 250, 500);
The constructor creates a new widget using the given position, size, and label.
The default boxtype is FL_DOWN_BOX.
The destructor removes the widget.
bounds(...)
$val_b->bounds($a, $b);
Sets the minimum ($a
) and maximum ($b
) values for the valuator widget. If either values is changed, a partial redraw is asked.
scrollvalue(...)
my $value = $val_a->scrollvalue($pos, $size, $first, $total);
Sets the size and position of the sliding knob in the box.
$pos
would be the position of the first line displayed, $size
is the size of the window in lines, $first
is the number of the first line, and $total
is the total number of lines.
The return value is the same as <FL::Valuator-
value();>>
slider(...)
my $boxtype = $val_a->slider();
$val_b->slider( FL_UP_BOX );
Gets or sets the slider box type.
slider_size(...)
Set the dimensions of the moving piece of slider.
$val_b->slider_size( .13 );
This is the fraction of the size of the entire widget. If you set this to 1
then the slider cannot move. The default value is .08
.
For the "fill" sliders this is the size of the area around the end that causes a drag effect rather than causing the slider to jump to the mouse.
LICENSE
Copyright (C) Sanko Robinson.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
AUTHOR
Sanko Robinson <sanko@cpan.org>