mirror of https://github.com/fltk/fltk
updated Fl_Slider and Fl_Scrollbar documentation (STR #2156 - part 2)
converted html tags to doxygen rationalised doxygen comments renamed Fl_Slider::scrollvalue() and Fl_Scrollbar::value() parameters git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@6683 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
parent
039a9be3f5
commit
26c355b6a0
|
@ -34,18 +34,20 @@
|
|||
#include "Fl_Slider.H"
|
||||
|
||||
/**
|
||||
The Fl_Scrollbar widget displays a slider with arrow buttons
|
||||
at the ends of the scrollbar. Clicking on the arrows move up/left and
|
||||
down/right by linesize(). Scrollbars also accept
|
||||
FL_SHORTCUT events: the arrows move by linesize(), and
|
||||
vertical scrollbars take Page Up/Down (they move by the page size minus
|
||||
linesize()) and Home/End (they jump to the top or bottom).
|
||||
<P>Scrollbars have step(1) preset (they always return
|
||||
integers). If desired you can set the step() to non-integer
|
||||
values. You will then have to use casts to get at the floating-point
|
||||
versions of value() from Fl_Slider. </P>
|
||||
<P ALIGN=CENTER>\image html scrollbar.gif
|
||||
\image latex scrollbar.eps "Fl_Scrollbar" width=4cm
|
||||
The Fl_Scrollbar widget displays a slider with arrow buttons at
|
||||
the ends of the scrollbar. Clicking on the arrows move up/left and
|
||||
down/right by linesize(). Scrollbars also accept FL_SHORTCUT events:
|
||||
the arrows move by linesize(), and vertical scrollbars take Page
|
||||
Up/Down (they move by the page size minus linesize()) and Home/End
|
||||
(they jump to the top or bottom).
|
||||
|
||||
Scrollbars have step(1) preset (they always return integers). If
|
||||
desired you can set the step() to non-integer values. You will then
|
||||
have to use casts to get at the floating-point versions of value()
|
||||
from Fl_Slider.
|
||||
|
||||
\image html scrollbar.gif
|
||||
\image latex scrollbar.eps "Fl_Scrollbar" width=4cm
|
||||
*/
|
||||
class FL_EXPORT Fl_Scrollbar : public Fl_Slider {
|
||||
|
||||
|
@ -58,30 +60,32 @@ protected:
|
|||
|
||||
public:
|
||||
|
||||
Fl_Scrollbar(int x,int y,int w,int h, const char *l = 0);
|
||||
Fl_Scrollbar(int X,int Y,int W,int H, const char *L = 0);
|
||||
~Fl_Scrollbar();
|
||||
int handle(int);
|
||||
|
||||
/**
|
||||
Gets the integer value (position) of the slider in the scrollbar.
|
||||
You can get the floating point value with Fl_Slider::value().
|
||||
|
||||
\see Fl_Scrollbar::value(int p)
|
||||
\see Fl_Scrollbar::value(int p, int s, int top, int total)
|
||||
\see Fl_Scrollbar::value(int pos, int size, int first, int total)
|
||||
*/
|
||||
int value() const {return int(Fl_Slider::value());}
|
||||
|
||||
/**
|
||||
Sets the value (position) of the slider in the scrollbar.
|
||||
|
||||
\see Fl_Scrollbar::value()
|
||||
\see Fl_Scrollbar::value(int p, int s, int top, int total)
|
||||
\see Fl_Scrollbar::value(int pos, int size, int first, int total)
|
||||
*/
|
||||
int value(int p) {return int(Fl_Slider::value((double)p));}
|
||||
|
||||
/**
|
||||
Sets the position, size and range of the slider in the scrollbar.
|
||||
\param[in] p position, first line displayed
|
||||
\param[in] s window size, number of lines displayed
|
||||
\param[in] top number of first line
|
||||
\param[in] pos position, first line displayed
|
||||
\param[in] size window size, number of lines displayed
|
||||
\param[in] first number of first line
|
||||
\param[in] total total number of lines
|
||||
|
||||
You should call this every time your window changes size, your data
|
||||
|
@ -89,21 +93,20 @@ public:
|
|||
to a callback from this scrollbar).
|
||||
All necessary calls to redraw() are done.
|
||||
|
||||
Calls Fl_Slider::scrollvalue(int p, int s, int top, int total).
|
||||
Calls Fl_Slider::scrollvalue(int pos, int size, int first, int total).
|
||||
*/
|
||||
int value(int p, int s, int top, int total) {
|
||||
return scrollvalue(p, s, top, total);
|
||||
int value(int pos, int size, int first, int total) {
|
||||
return scrollvalue(pos, size, first, total);
|
||||
}
|
||||
|
||||
/**
|
||||
This number controls how big the steps are that the arrow keys do. In
|
||||
addition page up/down move by the size last sent to value()
|
||||
minus one linesize(). The default is 16.
|
||||
Get the size of step, in lines, that the arror keys move.
|
||||
*/
|
||||
int linesize() const {return linesize_;}
|
||||
|
||||
/**
|
||||
This number controls how big the steps are that the arrow keys do. In
|
||||
addition page up/down move by the size last sent to value()
|
||||
This number controls how big the steps are that the arrow keys do.
|
||||
In addition page up/down move by the size last sent to value()
|
||||
minus one linesize(). The default is 16.
|
||||
*/
|
||||
void linesize(int i) {linesize_ = i;}
|
||||
|
|
|
@ -44,29 +44,28 @@
|
|||
#define FL_HOR_NICE_SLIDER 5
|
||||
|
||||
/**
|
||||
The Fl_Slider widget contains a sliding knob inside a box. It
|
||||
if 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.
|
||||
The Fl_Slider widget contains a sliding knob inside a box. It if
|
||||
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.
|
||||
|
||||
<P>Use void Fl_Widget::type(int) to set how the slider is drawn,
|
||||
Use void Fl_Widget::type(int) to set how the slider is drawn,
|
||||
which can be one of the following:
|
||||
<UL>
|
||||
<LI>FL_VERTICAL - Draws a vertical slider (this is the
|
||||
default). </LI>
|
||||
<LI>FL_HORIZONTAL - Draws a horizontal slider. </LI>
|
||||
<LI>FL_VERT_FILL_SLIDER - Draws a filled vertical slider,
|
||||
useful as a progress or value meter. </LI>
|
||||
<LI>FL_HOR_FILL_SLIDER - Draws a filled horizontal slider,
|
||||
useful as a progress or value meter. </LI>
|
||||
<LI>FL_VERT_NICE_SLIDER - Draws a vertical slider with a nice
|
||||
looking control knob. </LI>
|
||||
<LI>FL_HOR_NICE_SLIDER - Draws a horizontal slider with a
|
||||
nice looking control knob. </LI>
|
||||
</UL>
|
||||
<P ALIGN=CENTER>\image html slider.gif
|
||||
\image latex slider.eps "Fl_Slider" width=4cm
|
||||
|
||||
\li FL_VERTICAL - Draws a vertical slider (this is the default).
|
||||
\li FL_HORIZONTAL - Draws a horizontal slider.
|
||||
\li FL_VERT_FILL_SLIDER - Draws a filled vertical slider,
|
||||
useful as a progress or value meter.
|
||||
\li FL_HOR_FILL_SLIDER - Draws a filled horizontal slider,
|
||||
useful as a progress or value meter.
|
||||
\li FL_VERT_NICE_SLIDER - Draws a vertical slider with a nice
|
||||
looking control knob.
|
||||
\li FL_HOR_NICE_SLIDER - Draws a horizontal slider with a
|
||||
nice looking control knob.
|
||||
|
||||
\image html slider.gif
|
||||
\image latex slider.eps "Fl_Slider" width=4cm
|
||||
*/
|
||||
class FL_EXPORT Fl_Slider : public Fl_Valuator {
|
||||
|
||||
|
@ -85,24 +84,31 @@ protected:
|
|||
public:
|
||||
|
||||
int handle(int);
|
||||
Fl_Slider(int x,int y,int w,int h, const char *l = 0);
|
||||
Fl_Slider(uchar t,int x,int y,int w,int h, const char *l);
|
||||
Fl_Slider(int X,int Y,int W,int H, const char *L = 0);
|
||||
Fl_Slider(uchar t,int X,int Y,int W,int H, const char *L);
|
||||
|
||||
int scrollvalue(int windowtop,int windowsize,int first,int totalsize);
|
||||
int scrollvalue(int pos,int size,int first,int total);
|
||||
void bounds(double a, double b);
|
||||
|
||||
/**
|
||||
Get or set the dimensions of the moving piece of slider. 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.
|
||||
<P>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.
|
||||
Get the dimensions of the moving piece of slider.
|
||||
*/
|
||||
float slider_size() const {return slider_size_;}
|
||||
/** See float slider_size() const */
|
||||
|
||||
/**
|
||||
Set the dimensions of the moving piece of slider. 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.
|
||||
*/
|
||||
void slider_size(double v);
|
||||
|
||||
/** Gets the slider box type. */
|
||||
Fl_Boxtype slider() const {return (Fl_Boxtype)slider_;}
|
||||
|
||||
/** Sets the slider box type. */
|
||||
void slider(Fl_Boxtype c) {slider_ = c;}
|
||||
};
|
||||
|
|
|
@ -256,9 +256,8 @@ void Fl_Scrollbar::draw() {
|
|||
}
|
||||
|
||||
/**
|
||||
Creates a new Fl_Scrollbar widget using the given position,
|
||||
size, and label string. You need to do type(FL_HORIZONTAL) if
|
||||
you want a horizontal scrollbar.
|
||||
Creates a new Fl_Scrollbar widget with given position, size, and label.
|
||||
You need to do type(FL_HORIZONTAL) if you want a horizontal scrollbar.
|
||||
*/
|
||||
Fl_Scrollbar::Fl_Scrollbar(int X, int Y, int W, int H, const char* L)
|
||||
: Fl_Slider(X, Y, W, H, L) {
|
||||
|
|
|
@ -40,25 +40,24 @@ void Fl_Slider::_Fl_Slider() {
|
|||
Creates a new Fl_Slider widget using the given position,
|
||||
size, and label string. The default boxtype is FL_DOWN_BOX.
|
||||
*/
|
||||
Fl_Slider::Fl_Slider(int X, int Y, int W, int H, const char* l)
|
||||
: Fl_Valuator(X, Y, W, H, l) {
|
||||
Fl_Slider::Fl_Slider(int X, int Y, int W, int H, const char* L)
|
||||
: Fl_Valuator(X, Y, W, H, L) {
|
||||
box(FL_DOWN_BOX);
|
||||
_Fl_Slider();
|
||||
}
|
||||
|
||||
/**
|
||||
Creates a new Fl_Slider widget using the given position,
|
||||
size, and label string. The default boxtype is FL_DOWN_BOX.
|
||||
Creates a new Fl_Slider widget using the given box type, position,
|
||||
size, and label string.
|
||||
*/
|
||||
Fl_Slider::Fl_Slider(uchar t, int X, int Y, int W, int H, const char* l)
|
||||
: Fl_Valuator(X, Y, W, H, l) {
|
||||
Fl_Slider::Fl_Slider(uchar t, int X, int Y, int W, int H, const char* L)
|
||||
: Fl_Valuator(X, Y, W, H, L) {
|
||||
type(t);
|
||||
box(t==FL_HOR_NICE_SLIDER || t==FL_VERT_NICE_SLIDER ?
|
||||
FL_FLAT_BOX : FL_DOWN_BOX);
|
||||
_Fl_Slider();
|
||||
}
|
||||
|
||||
/** See float Fl_Slider::slider_size() const */
|
||||
void Fl_Slider::slider_size(double v) {
|
||||
if (v < 0) v = 0;
|
||||
if (v > 1) v = 1;
|
||||
|
@ -81,18 +80,18 @@ void Fl_Slider::bounds(double a, double b) {
|
|||
|
||||
/**
|
||||
Sets the size and position of the sliding knob in the box.
|
||||
\param[in] p position, first line displayed
|
||||
\param[in] W window, number of lines displayed
|
||||
\param[in] t top, number of first line
|
||||
\param[in] l length, total number of lines
|
||||
\param[in] pos position of first line displayed
|
||||
\param[in] size size of window in lines
|
||||
\param[in] first number of first line
|
||||
\param[in] total total number of lines
|
||||
Returns Fl_Valuator::value(p)
|
||||
*/
|
||||
int Fl_Slider::scrollvalue(int p, int W, int t, int l) {
|
||||
int Fl_Slider::scrollvalue(int pos, int size, int first, int total) {
|
||||
step(1, 1);
|
||||
if (p+W > t+l) l = p+W-t;
|
||||
slider_size(W >= l ? 1.0 : double(W)/double(l));
|
||||
bounds(t, l-W+t);
|
||||
return value(p);
|
||||
if (pos+size > first+total) total = pos+size-first;
|
||||
slider_size(size >= total ? 1.0 : double(size)/double(total));
|
||||
bounds(first, total-size+first);
|
||||
return value(pos);
|
||||
}
|
||||
|
||||
// All slider interaction is done as though the slider ranges from
|
||||
|
|
Loading…
Reference in New Issue