guit  0.1
 All Classes Functions Variables Typedefs Enumerations Friends
gtable.hpp
1 //
2 // Table 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 Guit_Table_hpp
9 #define Guit_Table_hpp
10 #include <gbox.hpp>
11 namespace guit {
12 
28 class GTable : public GBox {
29 protected:
30  GTable(GadgetType&, GString const& css_and_title);
31 
32 public:
33  ~GTable();
34  GTable(GString const& css_and_title = "");
35  GTable& clone(GClone const&) override;
36 
37  GTable* toTable() override {return this;}
38 
43  int columnCount(int* minColumnCount = 0) const;
44 
47  int rowCount() const {return childCount();}
48 
52  Gadget* childAt(int row) const override {return GBox::childAt(row);}
53 
57  virtual Gadget* childAt(int row, int column);
58 
59  using GBox::perform;
60 
63  void perform(std::function<void(Gadget& cell)> fun) override;
64 
69  virtual void perform(std::function<void(Gadget& cell, int row, int column)> fun);
70 
71  Gadget& createDefaultItem(GString const& arg) override;
72 
73  using GType = GadgetType_<GTable,GBox>;
74  static GType& Type();
75  GType& type() const override {return Type();}
76 
77 protected:
78  using Views = std::vector<GTable*>;
79  std::shared_ptr<Views> views_; // all table instances
80  void pack(GRender* parent_render) override;
81 };
82 
83 
85 GTable& Table(GString const& css_and_title = "");
86 
87 
88 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
89 
91 class GTRow : public GBox {
92 protected:
93  GTRow(GadgetType&, GString const& css);
94 
95 public:
96  GTRow(GString const& css = "");
97 
98  GTRow& clone(GClone const&) override;
99  GTRow* toTRow() override {return this;}
100 
102  static GType& Type();
103  GType& type() const override {return Type();}
104 
105  Gadget& createDefaultItem(GString const& arg) override;
106 
107 protected:
108  GDim computeInsideSize(GRender&) override;
109  void readValues(std::istream&, GIOBuffer&) override;
110  void writeValues(std::ostream&, GIOBuffer&) const override;
111 };
112 
113 
115 GTRow& TRow(GString const& css = "");
116 
117 
118 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
119 
121 class GTHead : public GTRow {
122 protected:
123  GTHead(GadgetType&, GString const& css);
124 
125 public:
126  GTHead(GString const& css = "");
127 
128  GTHead& clone(GClone const&) override;
129  GTHead* toTHead() override {return this;}
130 
132  static GType& Type();
133  GType& type() const override {return Type();}
134 };
135 
136 
138 GTHead& THead(GString const& css = "");
139 
140 
141 }
142 #endif