guit  0.1
 All Classes Functions Variables Typedefs Enumerations Friends
gflow.hpp
1 //
2 // Gadget Flow.
3 // Guit GUI Toolkit
4 // Copyright © 2020 Eric Lecolinet. All rights reserved.
5 // http://www.telecom-paris.fr/~elc
6 //
7 
8 #ifndef GuitFlow_hpp
9 #define GuitFlow_hpp
10 #include <gvarprop.hpp>
11 namespace guit {
12 
13 class GFlowValue {
14 public:
15  GFlowValue() = default;
16  GFlowValue(int8_t kind, int16_t gridsize) : kind(kind), gridsize(gridsize) {}
17  bool operator==(GFlowValue const&) const;
18  bool operator!=(GFlowValue const&) const;
19  int8_t kind{};
20  int16_t gridsize{};
21 };
22 
23 inline bool gconvert(GFlowValue const& from, GFlowValue& to) {to = from; return true;}
24 bool gconvert(GString const& from, GFlowValue& to);
25 bool gconvert(GFlowValue const& from, GString& to);
26 
27 
38 class GFlow : public GVarProp_<GFlowValue> {
39 public:
41  enum Kind : int8_t {Column, Row, Pie, Stack};
42 
44  static GFlow column, row, pie, stack;
45 
50  GFlow();
51  GFlow(GString const& value);
52  GFlow(Kind kind, int16_t gridsize = 0);
53  GFlow(GFlow const&);
54  GFlow(GFlowValue const&);
56 
57  GFlow* clone(bool copy_value) const override;
58 
59  GFlow& operator=(GFlow const& flow) {set(flow); return *this;}
60  GFlow& operator=(GString const& flow) {set(flow); return *this;}
61 
62  int16_t gridSize() const {return value_.gridsize;}
63 
64  using GType = GPropType_<GFlow,GProp>;
65  static GType& Type();
66  GType& type() const override {return Type();}
67 
70  bool onAdd(Gadget*) override;
71  void updateGadget(Gadget&) override;
72  void addModes(GadgetModes&) override;
73  void apply(Gadget* g, GRender& r, Specif) final;
75 
76 private:
77  friend class Gadget;
78 };
79 
82 inline GFlow& Flow() {return *new GFlow();}
83 inline GFlow& Flow(GString const& value) {return *new GFlow(value);}
85 
86 }
87 #endif