GnuCashew ~ Web Application compatible with GnuCash sql data files.
GCW
Loading...
Searching...
No Matches
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
8namespace 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. Key features include
16** auto-resizing columns.
17**
18** Code Credit:
19** https://redmine.webtoolkit.eu/boards/1/topics/11110?r=18058#message-18058
20** Matt Russell ([email protected])
21**
22**/
24: public Wt::WTableView
25{
26public:
27
28 /*! Default table header height */
29 const static int kTableHeaderRowHeight;
30
31 /*! Default table row height */
32 const static int kTableBodyRowHeight;
33
34 /*! Assumed table cell padding */
35 const static int kTableCellPadding;
36
37 /*! Width that a scroll bar adds to a table */
38 const static int kScrollBarWidth;
39
40 /*! Default fixed width a date/time column takes up (without wrapping) */
41 const static int kDefaultDateTimeWidth;
42
43 /*!
44 ** \brief ctor
45 */
46 TableView() ;
47
48 /*!
49 ** Upon a table resize, size the columns appropriately.
50 **
51 ** @param int width Full table width
52 ** @param int height Full table height
53 */
54 auto layoutSizeChanged( int _width, int _height )-> void override ;
55
56 /*!
57 ** Overload setColumnWidth so we can save what the user specifies into our
58 ** map. This implementation can take both absolute and relative
59 ** (percentage) widths. Percentages are interpretted as the percentage of
60 ** non-allocated width remaining. i.e. if a table is 100px, and one column
61 ** has an absolute width of 20px, then the two following relative columns
62 ** should both use 50%, which would yeild 40px each (minus padding.)
63 */
64 auto setColumnWidth( int _column, const Wt::WLength & _width )-> void override ;
65
66 /*!
67 ** Set the number of visible rows before a scroll bar appears
68 */
69 auto setVisibleRows( int _rows )-> void { m_visible_rows = _rows; }
70
71protected:
72
73 auto handleClick ( const Wt::WModelIndex & _index, const Wt::WMouseEvent & _event )-> void;
74// auto handleDoubleClick ( const Wt::WModelIndex & _index, const Wt::WMouseEvent & _event )-> void;
75 auto handleMouseDown ( const Wt::WModelIndex & _index, const Wt::WMouseEvent & _event )-> void;
76// auto handleMouseUp ( const Wt::WModelIndex & _index, const Wt::WMouseEvent & _event )-> void;
77
79
80 /*
81 ** Map table columns to width
82 */
83 std::map< int, Wt::WLength > m_widths;
84
85 /*
86 ** Rows visible before scroll bar
87 */
89
90 /*
91 ** Indicates which row is being edited
92 */
93 int m_editingRow = -1;
94
95}; // endclass TableView :
96
97 } // endnamespace Gui {
98} // endnamespace GCW {
99
100#endif // end#ifndef __TABLEVIEW_H___
101
102
Custom Table View Class.
Definition TableView.h:25
auto setVisibleRows(int _rows) -> void
Definition TableView.h:69
static const int kTableBodyRowHeight
Definition TableView.h:32
auto handleClick(const Wt::WModelIndex &_index, const Wt::WMouseEvent &_event) -> void
Handle Click Event.
auto handleMouseDown(const Wt::WModelIndex &_index, const Wt::WMouseEvent &_event) -> void
static const int kTableHeaderRowHeight
Definition TableView.h:29
static const int kScrollBarWidth
Definition TableView.h:38
Wt::WModelIndex m_lastIndexClick
Definition TableView.h:78
auto layoutSizeChanged(int _width, int _height) -> void override
static const int kTableCellPadding
Definition TableView.h:35
std::map< int, Wt::WLength > m_widths
Definition TableView.h:83
auto setColumnWidth(int _column, const Wt::WLength &_width) -> void override
static const int kDefaultDateTimeWidth
Definition TableView.h:41
Definition App.h:18