SliderCtrl.h

Zbigniew Rebacz, 03/22/2014 02:46 PM

Download (1.55 KB)

 
1
class SliderCtrl : public Ctrl {
2
        int           value;
3
        int           min, max, step;
4
        bool          round_step;
5
        bool                  jump;
6

    
7
        int           SliderToClient(int value) const;
8
        int           ClientToSlider(int x) const;
9

    
10
        int           HoVe(int  x, int  y) const;
11
        int&          HoVeR(int& x, int& y) const;
12

    
13
        int           Min() const     { return Upp::min(min, max); };
14
        int           Max() const     { return Upp::max(min, max); };
15

    
16
public:
17
        typedef SliderCtrl CLASSNAME;
18

    
19
        Callback           WhenSlideFinish;
20
        
21
        SliderCtrl();
22
        virtual ~SliderCtrl();
23

    
24
        virtual void  Paint(Draw& draw);
25
        virtual bool  Key(dword key, int repcnt);
26
        virtual void  LeftDown(Point pos, dword keyflags);
27
        virtual void  LeftRepeat(Point pos, dword keyflags);
28
        virtual void  LeftUp(Point pos, dword keyflags);
29
        virtual void  MouseMove(Point pos, dword keyflags);
30
        virtual void  GotFocus();
31
        virtual void  LostFocus();
32

    
33
        virtual void  SetData(const Value& value);
34
        virtual Value GetData() const;
35

    
36
        void          Inc();
37
        void          Dec();
38

    
39
        SliderCtrl&   MinMax(int _min, int _max);
40
        SliderCtrl&   Range(int max)                  { return MinMax(0, max); }
41
        int           GetMin() const                  { return min; }
42
        int           GetMax() const                  { return max; }
43

    
44
        bool          IsVert() const;
45
        SliderCtrl&   Jump(bool v = true)                          { jump = v; return *this; }
46

    
47
        SliderCtrl&   Step(int _step, bool _r = true) { step = _step; round_step = _r; return *this; }
48
        int           GetStep() const                 { return step; }
49
        bool          IsRoundStep() const             { return round_step; }
50
};