You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

121 lines
3.6KB

  1. //
  2. // "$Id: Fl_Slider.H 7981 2010-12-08 23:53:04Z 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; you can redistribute it and/or
  9. // modify it under the terms of the GNU Library General Public
  10. // License as published by the Free Software Foundation; either
  11. // version 2 of the License, or (at your option) any later version.
  12. //
  13. // This library is distributed in the hope that it will be useful,
  14. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16. // Library General Public License for more details.
  17. //
  18. // You should have received a copy of the GNU Library General Public
  19. // License along with this library; if not, write to the Free Software
  20. // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
  21. // USA.
  22. //
  23. // Please report all bugs and problems on the following page:
  24. //
  25. // http://www.fltk.org/str.php
  26. //
  27. /* \file
  28. Fl_Slider widget . */
  29. #ifndef Fl_Slider_H
  30. #define Fl_Slider_H
  31. #ifndef Fl_Valuator_H
  32. #include "Fl_Valuator.H"
  33. #endif
  34. // values for type(), lowest bit indicate horizontal:
  35. #define FL_VERT_SLIDER 0
  36. #define FL_HOR_SLIDER 1
  37. #define FL_VERT_FILL_SLIDER 2
  38. #define FL_HOR_FILL_SLIDER 3
  39. #define FL_VERT_NICE_SLIDER 4
  40. #define FL_HOR_NICE_SLIDER 5
  41. /**
  42. The Fl_Slider widget contains a sliding knob inside a box. It if
  43. often used as a scrollbar. Moving the box all the way to the
  44. top/left sets it to the minimum(), and to the bottom/right to the
  45. maximum(). The minimum() may be greater than the maximum() to
  46. reverse the slider direction.
  47. Use void Fl_Widget::type(int) to set how the slider is drawn,
  48. which can be one of the following:
  49. \li FL_VERTICAL - Draws a vertical slider (this is the default).
  50. \li FL_HORIZONTAL - Draws a horizontal slider.
  51. \li FL_VERT_FILL_SLIDER - Draws a filled vertical slider,
  52. useful as a progress or value meter.
  53. \li FL_HOR_FILL_SLIDER - Draws a filled horizontal slider,
  54. useful as a progress or value meter.
  55. \li FL_VERT_NICE_SLIDER - Draws a vertical slider with a nice
  56. looking control knob.
  57. \li FL_HOR_NICE_SLIDER - Draws a horizontal slider with a
  58. nice looking control knob.
  59. \image html slider.png
  60. \image latex slider.png "Fl_Slider" width=4cm
  61. */
  62. class FL_EXPORT Fl_Slider : public Fl_Valuator {
  63. float slider_size_;
  64. uchar slider_;
  65. void _Fl_Slider();
  66. void draw_bg(int, int, int, int);
  67. protected:
  68. // these allow subclasses to put the slider in a smaller area:
  69. void draw(int, int, int, int);
  70. int handle(int, int, int, int, int);
  71. void draw();
  72. public:
  73. int handle(int);
  74. Fl_Slider(int X,int Y,int W,int H, const char *L = 0);
  75. Fl_Slider(uchar t,int X,int Y,int W,int H, const char *L);
  76. int scrollvalue(int pos,int size,int first,int total);
  77. void bounds(double a, double b);
  78. /**
  79. Get the dimensions of the moving piece of slider.
  80. */
  81. float slider_size() const {return slider_size_;}
  82. /**
  83. Set the dimensions of the moving piece of slider. This is
  84. the fraction of the size of the entire widget. If you set this
  85. to 1 then the slider cannot move. The default value is .08.
  86. For the "fill" sliders this is the size of the area around the
  87. end that causes a drag effect rather than causing the slider to
  88. jump to the mouse.
  89. */
  90. void slider_size(double v);
  91. /** Gets the slider box type. */
  92. Fl_Boxtype slider() const {return (Fl_Boxtype)slider_;}
  93. /** Sets the slider box type. */
  94. void slider(Fl_Boxtype c) {slider_ = c;}
  95. };
  96. #endif
  97. //
  98. // End of "$Id: Fl_Slider.H 7981 2010-12-08 23:53:04Z greg.ercolano $".
  99. //