1 //
2 // "$Id$"
3 //
4 // Scroll bar 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_Scrollbar widget . */
21 
22 #ifndef Fl_Scrollbar_H
23 #define Fl_Scrollbar_H
24 
25 #include "Fl_Slider.H"
26 
27 /**
28   The Fl_Scrollbar widget displays a slider with arrow buttons at
29   the ends of the scrollbar. Clicking on the arrows move up/left and
30   down/right by linesize(). Scrollbars also accept FL_SHORTCUT events:
31   the arrows move by linesize(), and vertical scrollbars take Page
32   Up/Down (they move by the page size minus linesize()) and Home/End
33   (they jump to the top or bottom).
34 
35   Scrollbars have step(1) preset (they always return integers). If
36   desired you can set the step() to non-integer values. You will then
37   have to use casts to get at the floating-point versions of value()
38   from Fl_Slider.
39 
40   \image html  scrollbar.png
41   \image latex scrollbar.png "Fl_Scrollbar" width=4cm
42 */
43 class FL_EXPORT Fl_Scrollbar : public Fl_Slider {
44 
45   int linesize_;
46   int pushed_;
47   static void timeout_cb(void*);
48   void increment_cb();
49 protected:
50   void draw();
51 
52 public:
53 
54   Fl_Scrollbar(int X,int Y,int W,int H, const char *L = 0);
55   ~Fl_Scrollbar();
56   int handle(int);
57 
58   /**
59     Gets the integer value (position) of the slider in the scrollbar.
60     You can get the floating point value with Fl_Slider::value().
61 
62     \see Fl_Scrollbar::value(int p)
63     \see Fl_Scrollbar::value(int pos, int size, int first, int total)
64   */
value()65   int value() const {return int(Fl_Slider::value());}
66 
67   /**
68     Sets the value (position) of the slider in the scrollbar.
69 
70     \see Fl_Scrollbar::value()
71     \see Fl_Scrollbar::value(int pos, int size, int first, int total)
72   */
value(int p)73   int value(int p) {return int(Fl_Slider::value((double)p));}
74 
75   /**
76     Sets the position, size and range of the slider in the scrollbar.
77     \param[in] pos   position, first line displayed
78     \param[in] windowSize  number of lines displayed
79     \param[in] first number of first line
80     \param[in] total total number of lines
81 
82     You should call this every time your window changes size, your data
83     changes size, or your scroll position changes (even if in response
84     to a callback from this scrollbar).
85     All necessary calls to redraw() are done.
86 
87     Calls Fl_Slider::scrollvalue(int pos, int size, int first, int total).
88   */
value(int pos,int windowSize,int first,int total)89   int value(int pos, int windowSize, int first, int total) {
90     return scrollvalue(pos, windowSize, first, total);
91   }
92 
93   /**
94     Get the size of step, in lines, that the arror keys move.
95   */
linesize()96   int linesize() const {return linesize_;}
97 
98   /**
99     This number controls how big the steps are that the arrow keys do.
100     In addition page up/down move by the size last sent to value()
101     minus one linesize().  The default is 16.
102   */
linesize(int i)103   void linesize(int i) {linesize_ = i;}
104 
105 };
106 
107 #endif
108 
109 //
110 // End of "$Id$".
111 //
112