guit  0.1
 All Classes Functions Variables Typedefs Enumerations Friends
gvalueitem.hpp
1 //
2 // Item Gadgets with a numerical value
3 // Guit GUI Toolkit
4 // Copyright © 2019/2020 Eric Lecolinet. All rights reserved.
5 // http://www.telecom-paris.fr/~elc
6 //
7 #ifndef Guit_ValueItem_hpp
8 #define Guit_ValueItem_hpp
9 #include <gitem.hpp>
10 #include <gfloat.hpp>
11 namespace guit {
12 
19 class GValueItem : public GItem {
20 protected:
21  GValueItem(GadgetType& c) : GItem(c) {}
22  GValueItem(GadgetType&, GString const& css_value_title);
23 
24 public:
25  ~GValueItem();
26  explicit GValueItem(GString const& css_value_title = "");
27  explicit GValueItem(float value);
28  GValueItem& clone(GClone const&) override;
29 
30  GValueItem* toValueItem() override {return this;}
31 
36  float value() const;
37  GString stringValue() const override;
39 
45  virtual void setValue(float value);
46  void setValue(GString const&) override;
48 
53  GValueItem& setRange(float min, float max);
54  float min() const;
55  float max() const;
57 
66  GNumber& operator()();
67  GProp* valueProp() override {return value_;}
69 
70  bool hasValue() const override {return true;}
71 
72  using GType = GadgetType_<GValueItem,GItem>;
73  static GType& Type();
74  GType& type() const override {return Type();}
75 
78  virtual GFlow::Kind getFlow();
79  void initSpec(GString const& spec);
80  void initClone(Gadget& from, GClone const&) override;
81  void addProp(GProp&, bool add_to_proplist) override;
82  void doPaint(GRenderGraphics&, GRender* parr) override;
83  void movedResizedCB(GRect const& initialframe) override;
84  virtual void paintContent(GRenderGraphics&, GRender&, GFlow::Kind dir);
85  virtual void mouseDrag(GMouseEvent&);
86  //gptr<GNumber> value_;
87  gptr<class GFloat> value_;
88  float offset_{};
90 };
91 
92 
95 GValueItem& ValueItem(GString const& css_and_value = "");
96 GValueItem& ValueItem(float value);
98 
99 }
100 #endif