Virtual Testbed
Ship dynamics simulator for extreme conditions
TablePanel.hh
1 #ifndef VTESTBED_GUI_TABLEPANEL_HH
2 #define VTESTBED_GUI_TABLEPANEL_HH
3 
4 #include <string>
5 #include <vector>
6 
7 #include <vtestbed/gui/Window.hh>
8 
9 namespace vtb {
10 
11  namespace gui {
12 
13  class TablePanel: public Window {
14 
15  private:
19 
20  public:
21  using table_type = array2;
22 
23  private:
24  width_array _width;
25  array1 _columns;
26  array2 _table;
27  size_t _selected_row = 0;
28  size_t _sort_column = 0;
29  bool _ascending = false;
30  bool _show_first_column = false;
31 
32  public:
33 
34  inline void columns(array1 rhs) { this->_columns = std::move(rhs); }
35  inline void width(width_array rhs) { this->_width = std::move(rhs); }
36  inline const table_type& table() const { return this->_table; }
37 
38  inline const array1&
39  selected_row() const {
40  return this->_table[this->_selected_row];
41  }
42 
43  inline bool empty() const { return this->_table.empty(); }
44 
45  inline void
46  table(array2&& rhs) {
47  this->_table = std::move(rhs);
48  auto max_row = this->_table.size()-1;
49  if (max_row < this->_selected_row) { this->_selected_row = max_row; }
50  }
51 
52  inline void
53  show_first_column(bool b) {
54  this->_show_first_column = b;
55  }
56 
57  void draw();
58 
59  };
60 
61  class TableDialog: public TablePanel {
62 
63  public:
64  bool draw();
65 
66  };
67 
68  }
69 
70 }
71 
72 #endif // vim:filetype=cpp
Main namespace.
Definition: convert.hh:9