GnuCashew ~ GnuCash Enabled Web
GCW
TableView.h
Go to the documentation of this file.
1 #line 2 "src/Gui/TableView.h"
2 
3 #ifndef __GUI_TABLEVIEW_H___
4 #define __GUI_TABLEVIEW_H___
5 
6 #include <Wt/WTableView.h>
7 
8 namespace GCW {
9  namespace Gui {
10 
11 /*!
12 ** \brief Custom Table View Class
13 **
14 ** Implementing our own table view class derived from the Wt one. This
15 ** implementation is designed to be layout aware.
16 **
17 ** Code Credit:
18 ** https://redmine.webtoolkit.eu/boards/1/topics/11110?r=18058#message-18058
19 **
20 **
21 **/
22 class TableView
23 : public Wt::WTableView
24 {
25 public:
26 
27  /** Default table header height */
28  const static int kTableHeaderRowHeight;
29 
30  /** Default table row height */
31  const static int kTableBodyRowHeight;
32 
33  /** Assumed table cell padding */
34  const static int kTableCellPadding;
35 
36  /** Width that a scroll bar adds to a table */
37  const static int kScrollBarWidth;
38 
39  /** Default fixed width a date/time column takes up (without wrapping) */
40  const static int kDefaultDateTimeWidth;
41 
42  TableView();
43 
44  /*!
45  ** Upon a table resize, size the columns appropriately.
46  **
47  ** @param int width Full table width
48  ** @param int height Full table height
49  **
50  */
51  auto layoutSizeChanged( int width, int height )-> void override;
52 
53  /*!
54  ** Overload setColumnWidth so we can save what the user specifies into our
55  ** map. This implementation can take both absolute and relative
56  ** (percentage) widths. Percentages are interpretted as the percentage of
57  ** non-allocated width remaining. i.e. if a table is 100px, and one column
58  ** has an absolute width of 20px, then the two following relative columns
59  ** should both use 50%, which would yeild 40px each (minus padding.)
60  **
61  */
62  auto setColumnWidth(int column, const Wt::WLength& width)-> void override;
63 
64  /*!
65  ** Set the number of visible rows before a scroll bar appears
66  **
67  */
68  auto setVisibleRows(int rows)-> void { visible_rows_ = rows; }
69 
70 protected:
71 
72 // auto handleClick ( const Wt::WModelIndex & _index, const Wt::WMouseEvent & _event )-> void;
73 // auto handleDoubleClick ( const Wt::WModelIndex & _index, const Wt::WMouseEvent & _event )-> void;
74  auto handleMouseDown ( const Wt::WModelIndex & _index, const Wt::WMouseEvent & _event )-> void;
75 // auto handleMouseUp ( const Wt::WModelIndex & _index, const Wt::WMouseEvent & _event )-> void;
76 
77  Wt::WModelIndex m_lastIndexClick;
78 
79  /*
80  ** Map table columns to width
81  **
82  */
83  std::map< int, Wt::WLength > widths_;
84 
85  /*
86  ** Rows visible before scroll bar
87  **
88  */
89  int visible_rows_ = -1;
90 
91  /*
92  ** Indicates which row is being edited
93  **
94  */
95  int m_editingRow = -1;
96 
97 }; // endclass TableView :
98 
99  } // endnamespace Gui {
100 } // endnamespace GCW {
101 
102 #endif // end#ifndef __TABLEVIEW_H___
103 
104 
Custom Table View Class.
Definition: TableView.h:24
std::map< int, Wt::WLength > widths_
Definition: TableView.h:83
static const int kTableBodyRowHeight
Definition: TableView.h:31
static const int kTableHeaderRowHeight
Definition: TableView.h:28
static const int kScrollBarWidth
Definition: TableView.h:37
Wt::WModelIndex m_lastIndexClick
Definition: TableView.h:77
auto layoutSizeChanged(int width, int height) -> void override
Definition: TableView.cpp:259
auto handleMouseDown(const Wt::WModelIndex &_index, const Wt::WMouseEvent &_event) -> void
Handle Click Event.
Definition: TableView.cpp:487
static const int kTableCellPadding
Definition: TableView.h:34
auto setVisibleRows(int rows) -> void
Definition: TableView.h:68
auto setColumnWidth(int column, const Wt::WLength &width) -> void override
Definition: TableView.cpp:321
static const int kDefaultDateTimeWidth
Definition: TableView.h:40
Definition: App.h:17