Empirical
_TableCol.h
Go to the documentation of this file.
1 
12 #ifndef EMP_WEB_TABLE_COL_H
13 #define EMP_WEB_TABLE_COL_H
14 
15 namespace emp {
16 namespace web {
17 
19  class TableCol : public TableWidget {
20  public:
21  TableCol(size_t r, size_t c, const std::string & in_id="") : TableWidget(r,c,in_id) { ; }
22  TableCol(const TableWidget & in) : TableWidget(in) { ; }
23  TableCol(const Widget & in) : TableWidget(in) { ; }
24  TableCol(internal::TableInfo * in_info, size_t _col=0) : TableWidget(in_info, 0, _col) { ; }
25 
27  void DoCSS(const std::string & setting, const std::string & value) override {
28  if (Info()->cols.size() == 0) Info()->cols.resize(GetNumCols());
29  Info()->cols[cur_col].extras.style.Set(setting, value);
30  if (IsActive()) Info()->ReplaceHTML(); // @CAO only should replace cell's CSS
31  }
32 
33  void DoAttr(const std::string & setting, const std::string & value) override {
34  if (Info()->cols.size() == 0) Info()->cols.resize(GetNumCols());
35  Info()->cols[cur_col].extras.attr.Set(setting, value);
36  if (IsActive()) Info()->ReplaceHTML(); // @CAO only should replace cell's CSS
37  }
38 
39  void DoListen(const std::string & event_name, size_t fun_id) override {
40  if (Info()->cols.size() == 0) Info()->cols.resize(GetNumCols());
41  Info()->cols[cur_col].extras.listen.Set(event_name, fun_id);
42  if (IsActive()) Info()->ReplaceHTML(); // @CAO only should replace cell's CSS
43  }
44 
45  TableCol & Clear() { Info()->ClearCol(cur_col); return *this; }
46  TableCol & ClearStyle() { Info()->cols[cur_col].extras.style.Clear(); return *this; }
47  TableCol & ClearAttr() { Info()->cols[cur_col].extras.attr.Clear(); return *this; }
48  TableCol & ClearListen() { Info()->cols[cur_col].extras.listen.Clear(); return *this; }
49  TableCol & ClearExtras() { Info()->cols[cur_col].extras.Clear(); return *this; }
50  TableCol & ClearChildren() { Info()->ClearColChildren(cur_col); return *this; }
51  TableCol & ClearCells() { Info()->ClearCol(cur_col); return *this; }
52 
54  std::string GetCSS(const std::string & setting) override {
55  return Info()->cols[cur_col].extras.GetStyle(setting);
56  }
57 
58  };
59 
60 }
61 }
62 
63 #endif
TableCol & ClearCells()
Definition: _TableCol.h:51
bool IsActive() const
Test if the activity state of this widget is currently ACTIVE.
Definition: Widget.h:395
size_t cur_col
Definition: Table.h:517
TableCol(const Widget &in)
Definition: _TableCol.h:23
void DoListen(const std::string &event_name, size_t fun_id) override
Definition: _TableCol.h:39
Definition: Table.h:513
TableCol & ClearAttr()
Definition: _TableCol.h:47
TableCol & ClearStyle()
Definition: _TableCol.h:46
TableCol & Clear()
Definition: _TableCol.h:45
void DoAttr(const std::string &setting, const std::string &value) override
Definition: _TableCol.h:33
std::string GetCSS(const std::string &setting) override
Get the current CSS value for the specified setting of this Table column.
Definition: _TableCol.h:54
size_t GetNumCols() const
Definition: Table.h:561
TableCol(const TableWidget &in)
Definition: _TableCol.h:22
internal::TableInfo * Info()
Get a properly cast version of info.
Definition: Table.h:522
If we are in emscripten, make sure to include the header.
Definition: array.h:37
void ClearCol(size_t col_id)
Definition: Table.h:372
Widget is effectively a smart pointer to a WidgetInfo object, plus some basic accessors.
Definition: Widget.h:78
An object that focuses on a single column in a specified table.
Definition: _TableCol.h:19
emp::vector< TableColInfo > cols
Detail object for each row.
Definition: Table.h:114
TableCol & ClearExtras()
Definition: _TableCol.h:49
TableCol & ClearChildren()
Definition: _TableCol.h:50
Definition: Table.h:107
void DoCSS(const std::string &setting, const std::string &value) override
Apply CSS to appropriate column based on current state.
Definition: _TableCol.h:27
void ClearColChildren(size_t col_id)
Definition: Table.h:331
TableCol(size_t r, size_t c, const std::string &in_id="")
Definition: _TableCol.h:21
void ReplaceHTML() override
Definition: Table.h:462
TableCol(internal::TableInfo *in_info, size_t _col=0)
Definition: _TableCol.h:24
TableCol & ClearListen()
Definition: _TableCol.h:48