guit  0.1
 All Classes Functions Variables Typedefs Enumerations Friends
gadgettype.hpp
1 //
2 // Gadget Type.
3 // Guit GUI Toolkit
4 // Copyright © 2020 Eric Lecolinet. All rights reserved.
5 // http://www.telecom-paris.fr/~elc
6 //
7 
8 #ifndef Guit_GadgetType_hpp
9 #define Guit_GadgetType_hpp
10 #include <gtypes.hpp>
11 namespace guit {
12 
14 class GadgetType {
15 public:
18  GString const& name() const {return name_;}
19  GId id() const {return id_;}
20  GStyle& style() const {return *style_;}
22 
24  virtual Gadget& newInstance(GString const& arg = "") = 0;
25 
29  static Gadget* createInstance(GString const& type_name, GString const& arg);
30 
32  static GadgetType* findType(GString const& type_name);
33 
34  bool operator==(GadgetType const& other) const;
35  bool operator!=(GadgetType const& other) const;
36 
38  void operator delete(void*);
39 
40  virtual ~GadgetType() = default;
41 
42 protected:
43  friend class Gadget;
44  GadgetType(GString const& name);
45  GadgetType(GadgetType&) = delete;
46  GadgetType(GadgetType&&) = delete;
47  GadgetType& operator=(GadgetType const&) = delete;
48 
49  GString name_;
50  GStyle* style_{};
51  GId id_{};
52 };
53 
54 
56 template <class T, class Super>
57 class GadgetType_ : public Super::GType {
58 public:
60  using InstanceType = T;
61 
62  T& newInstance(GString const& arg = "") override {return *new T(arg);}
63 
65  GadgetType_(GString const& name) : Super::GType(name) {}
66 };
67 
68 
70 struct GadgetModes {
71  using Type = uint32_t;
72  Type dir:2, placement:3, menuLayout:1, unclippedLayers:1, stealTitle:1,
73 multiLine:1, richText:1,
74 shown:1, active:1, checked:1, enabled:1, focus:1,
75 activable:1, downActivable:1, checkable:1, focusable:1, internal:1,
76 catchEvents:1, ignoreEvents:1, choiceBehavior:2,
77 hasTip:1, hasCheck:1, hasChoice:1;
78 };
79 
80 
82 struct GadgetSettings {
83  using Type = uint8_t;
84  Type trulyEnabled:1, hotkeySet:1, modesSet:1, itemsSet:1, hasItems:1,
85 hasOpener:1, hasMenu:1, hasViews:1;
86 };
87 
88 
90 struct GadgetLayout {
91  using Type = uint8_t;
92  Type flexType:2, passivePos:1, activePos:1, activeSize:1, reshapeFrame:1,
93 hasLayers:1;
94  uint8_t layer{};
95  int8_t flex1{}, flex2{}; //uint8_t wpercent{}, hpercent{};
96 };
97 
98 
100 struct GadgetShape {
101  class GBorderValue* border{};
102  float start{}, extent{};
103 };
104 
105 }
106 #endif