Fl_Slider.H 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. //
  2. // "$Id: Fl_Slider.H 9553 2012-05-28 15:39:12Z greg.ercolano $"
  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. /* \file
  19. Fl_Slider widget . */
  20. #ifndef Fl_Slider_H
  21. #define Fl_Slider_H
  22. #ifndef Fl_Valuator_H
  23. #include "Fl_Valuator.H"
  24. #endif
  25. // values for type(), lowest bit indicate horizontal:
  26. #define FL_VERT_SLIDER 0
  27. #define FL_HOR_SLIDER 1
  28. #define FL_VERT_FILL_SLIDER 2
  29. #define FL_HOR_FILL_SLIDER 3
  30. #define FL_VERT_NICE_SLIDER 4
  31. #define FL_HOR_NICE_SLIDER 5
  32. /**
  33. The Fl_Slider widget contains a sliding knob inside a box. It is
  34. often used as a scrollbar. Moving the box all the way to the
  35. top/left sets it to the minimum(), and to the bottom/right to the
  36. maximum(). The minimum() may be greater than the maximum() to
  37. reverse the slider direction.
  38. Use void Fl_Widget::type(int) to set how the slider is drawn,
  39. which can be one of the following:
  40. \li FL_VERTICAL - Draws a vertical slider (this is the default).
  41. \li FL_HORIZONTAL - Draws a horizontal slider.
  42. \li FL_VERT_FILL_SLIDER - Draws a filled vertical slider,
  43. useful as a progress or value meter.
  44. \li FL_HOR_FILL_SLIDER - Draws a filled horizontal slider,
  45. useful as a progress or value meter.
  46. \li FL_VERT_NICE_SLIDER - Draws a vertical slider with a nice
  47. looking control knob.
  48. \li FL_HOR_NICE_SLIDER - Draws a horizontal slider with a
  49. nice looking control knob.
  50. \image html slider.png
  51. \image latex slider.png "Fl_Slider" width=4cm
  52. */
  53. class FL_EXPORT Fl_Slider : public Fl_Valuator {
  54. float slider_size_;
  55. uchar slider_;
  56. void _Fl_Slider();
  57. void draw_bg(int, int, int, int);
  58. protected:
  59. // these allow subclasses to put the slider in a smaller area:
  60. void draw(int, int, int, int);
  61. int handle(int, int, int, int, int);
  62. void draw();
  63. public:
  64. int handle(int);
  65. Fl_Slider(int X,int Y,int W,int H, const char *L = 0);
  66. Fl_Slider(uchar t,int X,int Y,int W,int H, const char *L);
  67. int scrollvalue(int pos,int size,int first,int total);
  68. void bounds(double a, double b);
  69. /**
  70. Get the dimensions of the moving piece of slider.
  71. */
  72. float slider_size() const {return slider_size_;}
  73. /**
  74. Set the dimensions of the moving piece of slider. This is
  75. the fraction of the size of the entire widget. If you set this
  76. to 1 then the slider cannot move. The default value is .08.
  77. For the "fill" sliders this is the size of the area around the
  78. end that causes a drag effect rather than causing the slider to
  79. jump to the mouse.
  80. */
  81. void slider_size(double v);
  82. /** Gets the slider box type. */
  83. Fl_Boxtype slider() const {return (Fl_Boxtype)slider_;}
  84. /** Sets the slider box type. */
  85. void slider(Fl_Boxtype c) {slider_ = c;}
  86. DECLARE_CLASS_CHEAP_RTTI_2(Fl_Slider, Fl_Valuator)
  87. };
  88. #endif
  89. //
  90. // End of "$Id: Fl_Slider.H 9553 2012-05-28 15:39:12Z greg.ercolano $".
  91. //