Fl_Scrollbar.H 3.3 KB

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