guit  0.1
 All Classes Functions Variables Typedefs Enumerations Friends
gprop.hpp
1 //
2 // Base class of Props
3 // guit GUI Toolkit
4 // Copyright © 2020 Eric Lecolinet. All rights reserved.
5 // http://www.telecom-paris.fr/~elc
6 //
7 
8 #ifndef Guit_Prop_hpp
9 #define Guit_Prop_hpp
10 #include <gobject.hpp>
11 #include <gproptype.hpp>
12 namespace guit {
13 
23 class GProp : public GObject {
24 public:
25  using IsProp = bool;
26  using IsGadgetChild = bool;
27 
29  using Specif = int32_t;
30 
34  virtual GProp* clone(bool copy_value) const {return nullptr;}
35 
39  using GType = GPropType;
40  static GType& Type();
41  virtual GType& type() const {return Type();}
43 
46  GString typeName() const override;
47  int role() const;
49 
52  GProp* toProp() override {return this;}
53  GProp const* toProp() const override {return this;}
55 
59  virtual bool isMutable() const {return false;}
60 
64  virtual void setImmutable() {}
65 
66  virtual bool isString() const {return false;}
67  virtual bool isNumber() const {return false;}
68  virtual bool isCondProp() const {return false;}
69 
72  virtual GString stringValue() const {return "";}
73 
76  virtual float floatValue() const {return 0.f;}
77 
80  virtual bool boolValue() const {return false;}
81 
84  bool write(GString const& filename) const;
85  virtual void write(std::ostream& out) const;
86  friend std::ostream& operator<<(std::ostream& out, GProp const&);
88 
93  virtual bool isEquivalent(GProp const& other) const;
94 
97  virtual bool onAdd(Gadget*);
98 
101  virtual void onRemove(Gadget*);
102 
103  virtual void addModes(struct GadgetModes&) {}
104  virtual void removeModes(struct GadgetModes&) {}
105  virtual void apply(Gadget*, GRender&, Specif) {}
106  virtual void fire(GEvent&) {}
107  virtual void updateGadget(Gadget&) {}
108 
111  virtual class GVarProp* toVarProp() {return nullptr;}
112  virtual class GVarProp* toMutableProp() {return nullptr;}
113  virtual class GText* toText() {return nullptr;}
114  virtual class GBool* toBool() {return nullptr;}
115  virtual class GNumber* toNumber() {return nullptr;}
116  virtual class GInt* toInt() {return nullptr;}
117  virtual class GFloat* toFloat(){return nullptr;}
118  virtual class GPos* toPos() {return nullptr;}
119  virtual class GPos const* toPos() const {return nullptr;}
120  virtual class GSize* toSize() {return nullptr;}
121  virtual class GSize const* toSize() const {return nullptr;}
122  virtual class GChoice* toChoice() {return nullptr;}
123  virtual class GAnim* toAnim() {return nullptr;}
124  virtual class GCond* toCond() {return nullptr;}
125  virtual class GExpr* toExpr() {return nullptr;}
126  virtual class GBoolExpr* toBoolExpr() {return nullptr;}
127  virtual class GExprWrapper* toExprWrapper() {return nullptr;}
128  virtual class GPropWrapper* toPropWrapper() {return nullptr;}
129  virtual class GNotifier* toNotifier() {return nullptr;}
131 
132 protected:
133  GProp() = default;
134  GProp(GProp const&) = delete;
135  GProp(GProp const&&) = delete;
136  GProp& operator=(GProp const&) = delete;
137  GProp& operator=(GProp const&&) = delete;
138 };
139 
140 }
141 #endif