guit  0.1
 All Classes Functions Variables Typedefs Enumerations Friends
gitem.hpp
1 //
2 // Item Gadgets: labels, buttons and menu/list items.
3 // Guit GUI Toolkit
4 // Copyright © 2019/2020 Eric Lecolinet. All rights reserved.
5 // http://www.telecom-paris.fr/~elc
6 //
7 
8 #ifndef Guit_Item_hpp
9 #define Guit_Item_hpp
10 #include <gadget.hpp>
11 namespace guit {
12 
24 
69 class GItem : public Gadget {
70 protected:
71  GItem(GadgetType& t) : Gadget(t) {}
72  GItem(GadgetType&, GString const& css_and_title);
73 
74 public:
75  ~GItem();
76  explicit GItem(GString const& css_and_title = "");
77 
78  GItem& clone(GClone const&) override;
79  GItem* toItem() override {return this;}
80 
87  GString text() const override;
88 
91  virtual GItem& operator=(GString const& str);
92  virtual GItem& operator=(float);
94 
95  GItem& setMultiLine(bool value = true);
96 
98  virtual void doAction();
99 
101  GString stringValue() const override;
102 
104  void setValue(GString const& text) override;
105 
106  bool hasValue() const override {return isCheckable();}
107 
108  GProp* valueProp() override;
109 
110  using GType = GadgetType_<GItem,Gadget>;
111  static GType& Type();
112  GType& type() const override {return Type();}
113 
116  using Gadget::add;
117  void add(GWindow*) override;
118  void add(GMenu*) override;
119  void addProp(GProp&, bool add_to_list) override;
120  void pack(GRender* parent_render) override;
121  class GTextCache* tcache_{};
123 };
124 
126 GItem& Item(GString const& css_and_text = "");
127 
128 
129 
130 class GLabel : public GItem {
131 public:
132  GLabel(GString const& css_and_title = "");
133  GLabel& clone(GClone const&) override;
134 
135  using GItem::operator=;
136 
137  using GType = GadgetType_<GLabel,GItem>;
138  static GType& Type();
139  GType& type() const override {return Type();}
140 };
141 
143 GLabel& Label(GString const& css_and_title = "");
144 
145 
146 
147 class GButton : public GItem {
148 public:
149  GButton(GString const& css_and_title = "");
150  GButton& clone(GClone const&) override;
151 
152  using GItem::operator=;
153 
154  using GType = GadgetType_<GButton,GItem>;
155  static GType& Type();
156  GType& type() const override {return Type();}
157 };
158 
160 GButton& Button(GString const& css_and_title = "");
161 
162 
163 
164 class GLinkItem : public GItem {
165 public:
166  GLinkItem(GString const& css_and_title = "");
167  GLinkItem& clone(GClone const&) override;
168 
169  using GItem::operator=;
170 
171  using GType = GadgetType_<GLinkItem,GItem>;
172  static GType& Type();
173  GType& type() const override {return Type();}
174 };
175 
177 GLinkItem& LinkItem(GString const& css_and_title = "");
178 
179 
180 
181 class GChoiceItem : public GItem {
182 public:
183  GChoiceItem(GString const& css_and_title = "");
184  GChoiceItem& clone(GClone const&) override;
185 
186  using GItem::operator=;
187 
188  using GType = GadgetType_<GChoiceItem,GItem>;
189  static GType& Type();
190  GType& type() const override {return Type();}
191 };
192 
194 GChoiceItem& ChoiceItem(GString const& css_and_title = "");
195 
196 
197 
198 class GCheckItem : public GItem {
199 public:
200  GCheckItem(GString const& css_and_title = "");
201  GCheckItem& clone(GClone const&) override;
202 
203  using GItem::operator=;
204 
205  using GType = GadgetType_<GCheckItem,GItem>;
206  static GType& Type();
207  GType& type() const override {return Type();}
208 };
209 
211 GCheckItem& CheckItem(GString const& css_and_title = "");
212 
213 
214 
215 class GRadioItem : public GItem {
216 public:
217  GRadioItem(GString const& css_and_title = "");
218  GRadioItem& clone(GClone const&) override;
219 
220  using GItem::operator=;
221 
222  using GType = GadgetType_<GRadioItem,GItem>;
223  static GType& Type();
224  GType& type() const override {return Type();}
225 };
226 
228 GRadioItem& RadioItem(GString const& css_and_title = "");
229 
230 
231 
232 class GTitle : public GItem {
233 public:
234  GTitle(GString const& css_and_title = "");
235  GTitle& clone(GClone const&) override;
236 
237  using GItem::operator=;
238  Place place() const override {return Place::Top;}
239 
240  using GType = GadgetType_<GTitle,GItem>;
241  static GType& Type();
242  GType& type() const override {return Type();}
243 };
244 
246 GTitle& Title(GString const& css_and_title = "");
247 
248 
249 
250 class GSeparator : public GItem {
251 public:
252  GSeparator(GString const& css = "");
253  GSeparator& clone(GClone const&) override;
254 
255  using GType = GadgetType_<GSeparator,GItem>;
256  static GType& Type();
257  GType& type() const override {return Type();}
258 };
259 
261 GSeparator& Separator(GString const& css = "");
262 
263 
264 
266 class GFiller : public GItem {
267 public:
268  GFiller(GString const& css = "");
269  GFiller& clone(GClone const&) override;
270 
272  static GType& Type();
273  GType& type() const override {return Type();}
274 };
275 
277 GFiller& Filler(GString const& css = "");
278 
279 }
280 #endif