GnuCashew ~ GnuCash Enabled Web
GCW
Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | List of all members
GCW::Gui::TableView Class Reference

Custom Table View Class. More...

#include <TableView.h>

Inherits Wt::WTableView.

Public Member Functions

 TableView ()
 
auto layoutSizeChanged (int width, int height) -> void override
 
auto setColumnWidth (int column, const Wt::WLength &width) -> void override
 
auto setVisibleRows (int rows) -> void
 

Static Public Attributes

static const int kTableHeaderRowHeight = 30
 
static const int kTableBodyRowHeight = 20
 
static const int kTableCellPadding = 7
 
static const int kScrollBarWidth = 20
 
static const int kDefaultDateTimeWidth = 120
 

Protected Member Functions

auto handleMouseDown (const Wt::WModelIndex &_index, const Wt::WMouseEvent &_event) -> void
 Handle Click Event. More...
 

Protected Attributes

Wt::WModelIndex m_lastIndexClick
 
std::map< int, Wt::WLength > widths_
 
int visible_rows_ = -1
 
int m_editingRow = -1
 

Detailed Description

Custom Table View Class.

Implementing our own table view class derived from the Wt one. This implementation is designed to be layout aware.

Code Credit: https://redmine.webtoolkit.eu/boards/1/topics/11110?r=18058#message-18058

Definition at line 22 of file TableView.h.

Constructor & Destructor Documentation

◆ TableView()

GCW::Gui::TableView::TableView ( )

Definition at line 99 of file TableView.cpp.

References kTableBodyRowHeight, and kTableHeaderRowHeight.

Member Function Documentation

◆ handleMouseDown()

void GCW::Gui::TableView::handleMouseDown ( const Wt::WModelIndex &  _index,
const Wt::WMouseEvent &  _event 
) -> void
protected

Handle Click Event.

This handler responds to 'click' events in the view.

The intent here is to provide some 'handling' when the user is mouse-ing around the table view. He should be able to click around to get editors to open, and select rows and whatnot.

The 'purpose' for the handler is due to the fact that the view responds differently if the view is editable or not. For instance, if an index is read-only, clicking on it causes the view to 'select' the entire row. But, if the index is 'Editable' then you are placed in to the editor but the view 'selection' is still visible, even if it's on another row. Further, the editor widget that opened, did not signal to the rest of the row that it should be 'selected'.

Definition at line 486 of file TableView.cpp.

References BREAKFOOTER, and BREAKHEADER.

◆ layoutSizeChanged()

auto GCW::Gui::TableView::layoutSizeChanged ( int  width,
int  height 
) -> void
override

Upon a table resize, size the columns appropriately.

Parameters
intwidth Full table width
intheight Full table height

Definition at line 258 of file TableView.cpp.

◆ setColumnWidth()

auto GCW::Gui::TableView::setColumnWidth ( int  column,
const Wt::WLength &  width 
) -> void
override

Overload setColumnWidth so we can save what the user specifies into our map. This implementation can take both absolute and relative (percentage) widths. Percentages are interpretted as the percentage of non-allocated width remaining. i.e. if a table is 100px, and one column has an absolute width of 20px, then the two following relative columns should both use 50%, which would yeild 40px each (minus padding.)

Definition at line 320 of file TableView.cpp.

◆ setVisibleRows()

auto GCW::Gui::TableView::setVisibleRows ( int  rows) -> void
inline

Set the number of visible rows before a scroll bar appears

Definition at line 68 of file TableView.h.

References visible_rows_.

Member Data Documentation

◆ kDefaultDateTimeWidth

const int GCW::Gui::TableView::kDefaultDateTimeWidth = 120
static

Default fixed width a date/time column takes up (without wrapping)

Definition at line 40 of file TableView.h.

◆ kScrollBarWidth

const int GCW::Gui::TableView::kScrollBarWidth = 20
static

Width that a scroll bar adds to a table

Definition at line 37 of file TableView.h.

◆ kTableBodyRowHeight

const int GCW::Gui::TableView::kTableBodyRowHeight = 20
static

Default table row height

Definition at line 31 of file TableView.h.

Referenced by TableView().

◆ kTableCellPadding

const int GCW::Gui::TableView::kTableCellPadding = 7
static

Assumed table cell padding

Definition at line 34 of file TableView.h.

◆ kTableHeaderRowHeight

const int GCW::Gui::TableView::kTableHeaderRowHeight = 30
static

Default table header height

Definition at line 28 of file TableView.h.

Referenced by TableView().

◆ m_editingRow

int GCW::Gui::TableView::m_editingRow = -1
protected

Definition at line 95 of file TableView.h.

◆ m_lastIndexClick

Wt::WModelIndex GCW::Gui::TableView::m_lastIndexClick
protected

Definition at line 77 of file TableView.h.

◆ visible_rows_

int GCW::Gui::TableView::visible_rows_ = -1
protected

Definition at line 89 of file TableView.h.

Referenced by setVisibleRows().

◆ widths_

std::map< int, Wt::WLength > GCW::Gui::TableView::widths_
protected

Definition at line 83 of file TableView.h.


The documentation for this class was generated from the following files: