source: NonGTP/glut/FLTK/include/fltk/Slider.h @ 814

Revision 814, 2.7 KB checked in by gumbau, 18 years ago (diff)

Glut initial import used by Geometry modules

Line 
1//
2// "$Id: Slider.h 4303 2005-05-01 03:33:52Z spitzak $"
3//
4// Slider value control. By default it moves vertically with the
5// minimum number at the bottom. See HorizontalSlider for one that
6// moves across (which is usually the default in other toolkits).
7//
8// Copyright 1998-2003 by Bill Spitzak and others.
9//
10// This library is free software; you can redistribute it and/or
11// modify it under the terms of the GNU Library General Public
12// License as published by the Free Software Foundation; either
13// version 2 of the License, or (at your option) any later version.
14//
15// This library is distributed in the hope that it will be useful,
16// but WITHOUT ANY WARRANTY; without even the implied warranty of
17// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18// Library General Public License for more details.
19//
20// You should have received a copy of the GNU Library General Public
21// License along with this library; if not, write to the Free Software
22// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
23// USA.
24//
25// Please report all bugs and problems to "fltk-bugs@fltk.org".
26//
27
28#ifndef fltk_Slider_h
29#define fltk_Slider_h
30
31#ifndef fltk_Valuator_h
32#include "Valuator.h"
33#endif
34
35namespace fltk {
36
37class FL_API Slider : public Valuator {
38
39  unsigned short slider_size_;
40  unsigned short tick_size_;
41  unsigned short old_position;
42
43public:
44
45  enum { // bit flags for type():
46    LINEAR              = 0,
47    TICK_ABOVE          = 2,
48    TICK_LEFT           = TICK_ABOVE,
49    TICK_BELOW          = 4,
50    TICK_RIGHT          = TICK_BELOW,
51    TICK_BOTH           = TICK_ABOVE|TICK_BELOW,
52    LOG                 = 8
53#ifdef FLTK_1_SLIDER
54    // for back-compatability only
55    ,VERTICAL           = 0,
56    HORIZONTAL          = 1,
57    FILL                = 16
58#endif
59  };
60  bool horizontal() const {return !(flags()&LAYOUT_VERTICAL) || (type()&1);}
61  bool log() const {return (type()&LOG)!=0;}
62
63  void draw();
64  int handle(int);
65
66  Slider(int x,int y,int w,int h, const char *l = 0);
67  static NamedStyle* default_style;
68
69  unsigned short slider_size() const {return slider_size_;}
70  void slider_size(int n) {slider_size_ = (unsigned short)n;}
71  unsigned short tick_size() const {return tick_size_;}
72  void tick_size(int n) {tick_size_ = (unsigned short)n;}
73 
74#ifdef FLTK_1_SLIDER
75  // back comptability:
76  Box* slider() const {return buttonbox();}
77  void slider(Box* b) {buttonbox(b);}
78  void slider_size(double v) {slider_size(int(v*w()));}
79#endif
80
81  //protected:
82
83  int slider_position(double value, int w);
84  double position_value(int x, int w);
85  int handle(int event, const Rectangle&);
86  void draw_ticks(const Rectangle&, int min_spacing);
87  bool draw(const Rectangle&, Flags flags, bool slot);
88};
89
90}
91
92#endif
93
94//
95// End of "$Id: Slider.h 4303 2005-05-01 03:33:52Z spitzak $".
96//
Note: See TracBrowser for help on using the repository browser.