guit  0.1
 All Classes Functions Variables Typedefs Enumerations Friends
gint.hpp
1 //
2 // Int Prop
3 // Guit GUI Toolkit
4 // Copyright © 2019/2020 Eric Lecolinet. All rights reserved.
5 // http://www.telecom-paris.fr/~elc
6 //
7 
8 #ifndef GuitInt_hpp
9 #define GuitInt_hpp
10 #include <gnumber.hpp>
11 namespace guit {
12 
14 class GInt : public GNumber_<int> {
15 public:
16  using Super = GNumber_<int> ;
17 
18  GInt();
19  GInt(int value);
20  GInt(int value, int min, int max = highest());
21  GInt(GInt const& value);
22  GInt(GString const& value);
23  GInt* clone(bool copy_value) const override;
24 
25  GInt* toInt() override {return this;}
26 
28  auto operator~() {return GNumPropRef_<GInt>(*this);}
29 
32 
34  GInt& setRange(int min, int max) {Super::setRange(min,max); return *this;}
35  GInt& setRangeF(float min, float max) override {Super::setRangeF(min,max); return *this;}
36 
40  GInt& setCycles(bool);
41 
42  GInt& operator=(int value) {set(value,false); return *this;}
43  GInt& operator=(GInt const& value) {set(value,false); return *this;}
44  GInt& operator=(GString const& value) {set(value); return *this;}
45 
46  GInt& operator++() {increase(); return *this;}
47  GInt& operator++(int) {increase(); return *this;}
48  GInt& operator--() {decrease(); return *this;}
49  GInt& operator--(int) {decrease(); return *this;}
50  GInt& operator+=(int delta) {increase(delta); return *this;}
51  GInt& operator-=(int delta) {increase(-delta); return *this;}
52 
53  void increase(int const& delta) override;
54  void increase() override {increase(+1);}
55  void decrease() override {increase(-1);}
56 
57  using GType = GPropType_<GInt,GProp>;
58  static GType& Type();
59  GType& type() const override {return Type();}
60 };
61 
62 
65 GInt& Int();
66 inline GInt& Int(int value) {return *new GInt(value);}
67 GInt& Int(int value, int min, int max = GInt::highest());
68 GInt& Int(GString const& value);
70 
71 }
72 #endif