guit  0.1
 All Classes Functions Variables Typedefs Enumerations Friends
galign.hpp
1 //
2 // Alignment and justification of the content of a gadget.
3 // Guit GUI Toolkit
4 // Copyright © 2019/2020 Eric Lecolinet. All rights reserved.
5 // http://www.telecom-paris.fr/~elc
6 //
7 
8 #ifndef GuitAlign_hpp
9 #define GuitAlign_hpp
10 #include <gvarprop.hpp>
11 namespace guit {
12 
13 class GAlignValue {
14  public:
15  GAlignValue();
16  GAlignValue(int8_t main, int8_t cross, int8_t icon);
17  bool operator==(GAlignValue const&) const;
18  bool operator!=(GAlignValue const&) const;
19  int8_t main, cross, icon;
20 };
21 
22 inline bool gconvert(GAlignValue const& from, GAlignValue& to) {to = from; return true;}
23 bool gconvert(GString const& from, GAlignValue& to);
24 bool gconvert(GAlignValue const& from, GString& to);
25 
26 
41 class GAlign : public GVarProp_<GAlignValue> {
42 public:
43  using Super = GVarProp_<GAlignValue>;
44  enum Layout : int8_t {Start, Center, End, Extend, Equal};
45 
46  GAlign();
47  GAlign(Layout main, Layout cross, Layout icon = Start);
48  GAlign(GAlign const&);
49  GAlign(GAlignValue const&);
50 
59  GAlign(GString const&);
60 
61  GAlign* clone(bool copy_value) const override;
62 
63  Layout mainLayout() const {return Layout(value_.main);}
64  Layout crossLayout() const {return Layout(value_.cross);}
65  Layout iconLayout() const {return Layout(value_.icon);}
66 
67  GAlign& operator=(GAlign const& val) {set(val); return *this;}
68  GAlign& operator=(GString const& val) {set(val); return *this;}
69 
70  void setMainLayout(Layout);
71  void setCrossLaoyut(Layout);
72  void setIconLayout(Layout);
73 
74  using GType = GPropType_<GAlign,GProp>;
75  static GType& Type();
76  GType& type() const override {return Type();}
77 
78  void updateGadget(Gadget&) override;
79  void apply(Gadget*, GRender&, Specif) final;
80 };
81 
82 
85 inline GAlign& Align() {return *new GAlign();}
86 inline GAlign& Align(GString const& value) {return *new GAlign(value);}
88 
89 }
90 #endif