ubit
uslider.hpp
1 /************************************************************************
2  *
3  * uslider.hpp
4  * Ubit GUI Toolkit - Version 6
5  * (C) 2009 | Eric Lecolinet | TELECOM ParisTech | http://www.enst.fr/~elc/ubit
6  *
7  * ***********************************************************************
8  * COPYRIGHT NOTICE :
9  * THIS PROGRAM IS DISTRIBUTED WITHOUT ANY WARRANTY AND WITHOUT EVEN THE
10  * IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
11  * YOU CAN REDISTRIBUTE IT AND/OR MODIFY IT UNDER THE TERMS OF THE GNU
12  * GENERAL PUBLIC LICENSE AS PUBLISHED BY THE FREE SOFTWARE FOUNDATION;
13  * EITHER VERSION 2 OF THE LICENSE, OR (AT YOUR OPTION) ANY LATER VERSION.
14  * SEE FILES 'COPYRIGHT' AND 'COPYING' FOR MORE DETAILS.
15  * ***********************************************************************/
16 
17 #ifndef _uslider_hpp_
18 #define _uslider_hpp_ 1
19 #include <ubit/unumber.hpp>
20 #include <ubit/ubox.hpp>
21 #include <ubit/ustyle.hpp>
22 namespace ubit {
23 
24  struct USliderStyle : public UStyle {
25  USliderStyle();
26  const UStyle& getStyle(UUpdateContext* ctx) const;
27  // default is hstyle
28  UStyle vstyle;
29  };
30 
31  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
44  class USlider: public UBox {
45  public:
46  UCLASS(USlider)
47 
48  USlider(const UArgs& = UArgs::none);
54  USlider(UFloat& value, const UArgs& = UArgs::none);
62  float getValue() const {return *pvalue;}
64 
65  USlider& setValue(float val) {*pvalue = val; return *this;}
71  UFloat& value() {return *pvalue;}
78  // - - - impl. - - - - - - - - - - - - - - - - - - - - - - - - - - -
79 
80  static UStyle* createStyle() {return createSliderStyle();}
81  static USliderStyle* createSliderStyle() {return new USliderStyle;}
82 
83  virtual UBox* createKnob();
85 
86  virtual UBox* createRail();
88 
89  protected:
90  uptr<UFloat> pvalue; // corresponding value (percent)
91  uptr<UBox> prail, pknob;
92  uptr<UPos> pknob_pos;
93  uptr<class UPosControl> pknob_ctrl;
94 
95  void constructs();
96  virtual void gotoPosCB(UMouseEvent&);
97  virtual void actionCB(UEvent&); //UNodeEvent
98  virtual void changeCB(UEvent&); //UNodeEvent
99  };
100 
101 
102  USlider& uslider(const UArgs& a = UArgs::none);
104 
105  USlider& uslider(UFloat& value, const UArgs& a = UArgs::none);
107 
108  USlider& uhslider(const UArgs& a = UArgs::none);
110 
111  USlider& uvslider(const UArgs& a = UArgs::none);
113 
114 }
115 #endif
116 
117 
Box container.
Definition: ubox.hpp:64
Ubit Event class.
Definition: uevent.hpp:30
UFloat & value()
return the internal value model.
Definition: uslider.hpp:71
USlider & setValue(float val)
changes the current value (a float between 0 and 100).
Definition: uslider.hpp:65
Smart Pointer for UObject instances (.
Definition: uobject.hpp:365
Definition: uslider.hpp:24
Argument list (for passing arguments to constructor or add functions).
Definition: uargs.hpp:43
Definition: uupdatecontext.hpp:32
Slider widget.
Definition: uslider.hpp:44
Definition: uhardfont.hpp:31
static const UArgs none
the empty arglist.
Definition: uargs.hpp:45
Active Float.
Definition: unumber.hpp:140
float getValue() const
returns the current value (a float between 0 and 100).
Definition: uslider.hpp:62
Compiled Object Style.
Definition: ustyle.hpp:44
mouse events
Definition: uevent.hpp:172