Empirical
_TableRow.h
Go to the documentation of this file.
1 
12 #ifndef EMP_WEB_TABLE_ROW_H
13 #define EMP_WEB_TABLE_ROW_H
14 
15 namespace emp {
16 namespace web {
17 
19  class TableRow : public TableWidget {
20  public:
21  TableRow(size_t r, size_t c, const std::string & in_id="") : TableWidget(r,c,in_id) { ; }
22  TableRow(const TableWidget & in) : TableWidget(in) { ; }
23  TableRow(const Widget & in) : TableWidget(in) { ; }
24  TableRow(internal::TableInfo * in_info, size_t _row=0) : TableWidget(in_info, _row, 0) { ; }
25 
26  // Apply CSS to appropriate component based on current state.
27  void DoCSS(const std::string & setting, const std::string & value) override {
28  Info()->rows[cur_row].extras.style.Set(setting, value);
29  if (IsActive()) Info()->ReplaceHTML(); // @CAO only should replace cell's CSS
30  }
31 
32  void DoAttr(const std::string & setting, const std::string & value) override {
33  Info()->rows[cur_row].extras.attr.Set(setting, value);
34  if (IsActive()) Info()->ReplaceHTML(); // @CAO only should replace cell's CSS
35  }
36 
37  void DoListen(const std::string & event_name, size_t fun_id) override {
38  Info()->rows[cur_row].extras.listen.Set(event_name, fun_id);
39  if (IsActive()) Info()->ReplaceHTML(); // @CAO only should replace cell's CSS
40  }
41 
42  bool InStateRow() const { return true; }
43 
44  TableRow & Clear() { Info()->ClearRow(cur_row); return *this; }
45  TableRow & ClearStyle() { Info()->rows[cur_row].extras.style.Clear(); return *this; }
46  TableRow & ClearAttr() { Info()->rows[cur_row].extras.attr.Clear(); return *this; }
47  TableRow & ClearListen() { Info()->rows[cur_row].extras.listen.Clear(); return *this; }
48  TableRow & ClearExtras() { Info()->rows[cur_row].extras.Clear(); return *this; }
49  TableRow & ClearChildren() { Info()->ClearRowChildren(cur_row); return *this; }
50  TableRow & ClearCells() { Info()->ClearRow(cur_row); return *this; }
51 
52  std::string GetCSS(const std::string & setting) override {
53  return Info()->rows[cur_row].extras.GetStyle(setting);
54  }
55 
56  };
57 
58 }
59 }
60 
61 #endif
TableRow & Clear()
Definition: _TableRow.h:44
TableRow & ClearStyle()
Definition: _TableRow.h:45
bool IsActive() const
Test if the activity state of this widget is currently ACTIVE.
Definition: Widget.h:395
void ClearRow(size_t row_id)
Definition: Table.h:368
TableRow & ClearCells()
Definition: _TableRow.h:50
TableRow(const Widget &in)
Definition: _TableRow.h:23
void ClearRowChildren(size_t row_id)
Definition: Table.h:328
TableRow(size_t r, size_t c, const std::string &in_id="")
Definition: _TableRow.h:21
void DoListen(const std::string &event_name, size_t fun_id) override
Definition: _TableRow.h:37
Definition: Table.h:513
TableRow & ClearAttr()
Definition: _TableRow.h:46
std::string GetCSS(const std::string &setting) override
Definition: _TableRow.h:52
TableRow & ClearListen()
Definition: _TableRow.h:47
An object that focuses on a single column in a specified table.
Definition: _TableRow.h:19
emp::vector< TableRowInfo > rows
Definition: Table.h:113
bool InStateRow() const
Definition: _TableRow.h:42
void DoCSS(const std::string &setting, const std::string &value) override
Definition: _TableRow.h:27
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
TableRow(const TableWidget &in)
Definition: _TableRow.h:22
Widget is effectively a smart pointer to a WidgetInfo object, plus some basic accessors.
Definition: Widget.h:78
Definition: Table.h:107
size_t cur_row
Definition: Table.h:516
TableRow & ClearChildren()
Definition: _TableRow.h:49
void ReplaceHTML() override
Definition: Table.h:462
TableRow & ClearExtras()
Definition: _TableRow.h:48
TableRow(internal::TableInfo *in_info, size_t _row=0)
Definition: _TableRow.h:24
void DoAttr(const std::string &setting, const std::string &value) override
Definition: _TableRow.h:32