1 //
2 // "$Id$"
3 //
4 // Slider header file for the Fast Light Tool Kit (FLTK).
5 //
6 // Copyright 1998-2010 by Bill Spitzak and others.
7 //
8 // This library is free software. Distribution and use rights are outlined in
9 // the file "COPYING" which should have been included with this file.  If this
10 // file is missing or damaged, see the license at:
11 //
12 //     http://www.fltk.org/COPYING.php
13 //
14 // Please report all bugs and problems on the following page:
15 //
16 //     http://www.fltk.org/str.php
17 //
18 
19 /* \file
20    Fl_Slider widget . */
21 
22 #ifndef Fl_Slider_H
23 #define Fl_Slider_H
24 
25 #ifndef Fl_Valuator_H
26 #include "Fl_Valuator.H"
27 #endif
28 
29 // values for type(), lowest bit indicate horizontal:
30 #define FL_VERT_SLIDER		0
31 #define FL_HOR_SLIDER		1
32 #define FL_VERT_FILL_SLIDER	2
33 #define FL_HOR_FILL_SLIDER	3
34 #define FL_VERT_NICE_SLIDER	4
35 #define FL_HOR_NICE_SLIDER	5
36 
37 /**
38   The Fl_Slider widget contains a sliding knob inside a box. It is
39   often used as a scrollbar.  Moving the box all the way to the
40   top/left sets it to the minimum(), and to the bottom/right to the
41   maximum().  The minimum() may be greater than the maximum() to
42   reverse the slider direction.
43 
44   Use void Fl_Widget::type(int) to set how the slider is drawn,
45   which can be one of the following:
46 
47   \li FL_VERTICAL - Draws a vertical slider (this is the default).
48   \li FL_HORIZONTAL - Draws a horizontal slider.
49   \li FL_VERT_FILL_SLIDER - Draws a filled vertical slider,
50       useful as a progress or value meter.
51   \li FL_HOR_FILL_SLIDER - Draws a filled horizontal  slider,
52       useful as a progress or value meter.
53   \li FL_VERT_NICE_SLIDER - Draws a vertical slider with  a nice
54       looking control knob.
55   \li FL_HOR_NICE_SLIDER - Draws a horizontal slider with  a
56       nice looking control knob.
57 
58   \image html  slider.png
59   \image latex slider.png "Fl_Slider" width=4cm
60 */
61 class FL_EXPORT Fl_Slider : public Fl_Valuator {
62 
63   float slider_size_;
64   uchar slider_;
65   void _Fl_Slider();
66   void draw_bg(int, int, int, int);
67 
68 protected:
69 
70   // these allow subclasses to put the slider in a smaller area:
71   void draw(int, int, int, int);
72   int handle(int, int, int, int, int);
73   void draw();
74 
75 public:
76 
77   int handle(int);
78   Fl_Slider(int X,int Y,int W,int H, const char *L = 0);
79   Fl_Slider(uchar t,int X,int Y,int W,int H, const char *L);
80 
81   int scrollvalue(int pos,int size,int first,int total);
82   void bounds(double a, double b);
83 
84   /**
85     Get the dimensions of the moving piece of slider.
86   */
slider_size()87   float slider_size() const {return slider_size_;}
88 
89   /**
90     Set the dimensions of the moving piece of slider. This is
91     the fraction of the size of the entire widget. If you set this
92     to 1 then the slider cannot move.  The default value is .08.
93 
94     For the "fill" sliders this is the size of the area around the
95     end that causes a drag effect rather than causing the slider to
96     jump to the mouse.
97   */
98   void slider_size(double v);
99 
100   /** Gets the slider box type. */
slider()101   Fl_Boxtype slider() const {return (Fl_Boxtype)slider_;}
102 
103   /** Sets the slider box type. */
slider(Fl_Boxtype c)104   void slider(Fl_Boxtype c) {slider_ = c;}
105 };
106 
107 #endif
108 
109 //
110 // End of "$Id$".
111 //
112