tbx  0.7.6
Classes | Public Member Functions | Protected Member Functions | List of all members
tbx::view::ReportView Class Reference

Class to handle the display/interaction with a list of items presented in columns. More...

#include <reportview.h>

Inheritance diagram for tbx::view::ReportView:
tbx::view::ItemView tbx::RedrawListener tbx::ScrollRequestListener tbx::MouseClickListener tbx::view::SelectionListener tbx::Listener tbx::Listener tbx::Listener tbx::Listener

Public Member Functions

 ReportView (tbx::Window window)
 Construct a report view for a window. More...
 
virtual ~ReportView ()
 Destructor of report view.
 
virtual void auto_size (bool on)
 Turn on or off auto sizing. More...
 
void row_height (unsigned int height)
 Change the row height. More...
 
unsigned int row_height () const
 Get the height of one row of the report.
 
void column_gap (unsigned int gap)
 Change the gap between columns. More...
 
unsigned int column_gap () const
 Get the gap between columns in the report.
 
unsigned int add_column (ItemRenderer *cr, unsigned int width=0)
 Add a column to the report view. More...
 
void remove_column (unsigned int column)
 Remove column from report. More...
 
unsigned int column_count () const
 Get the number of columns in the report view.
 
unsigned int row_count () const
 Get the number of rows in the report view.
 
void column_width (unsigned int column, unsigned int width)
 Set the column width. More...
 
unsigned int column_width (unsigned int column) const
 Returns column width. More...
 
void size_column_to_width (unsigned int column, unsigned int min_width=0, unsigned int max_width=0xFFFFFFFF)
 Size column to content. More...
 
void size_all_to_width (unsigned int min_width=0, unsigned int max_width=0xFFFFFFFF)
 Size all columns to content. More...
 
virtual void redraw (const tbx::RedrawEvent &event)
 Redraw the window. More...
 
virtual void update_window_extent ()
 Called to update the window extent needed to contain this view. More...
 
virtual void refresh ()
 Called to refresh the entire views contents. More...
 
virtual void inserted (unsigned int where, unsigned int how_many)
 Call after inserting rows into the collection the ReportView is showing. More...
 
virtual void removing (unsigned int where, unsigned int how_many)
 Inform the view that items are about to be removed. More...
 
virtual void removed (unsigned int where, unsigned int how_many)
 Call after removing rows from the collection the ReportView is showing. More...
 
virtual void changing (unsigned int where, unsigned int how_many)
 Inform the view that items are about to be changed. More...
 
virtual void changed (unsigned int where, unsigned int how_many)
 Inform the view that items have been changed. More...
 
virtual void cleared ()
 Whole view has been cleared.
 
void cell_changing (unsigned int index, unsigned int column)
 Inform the view that one column has been changed. More...
 
void cell_changed (unsigned int index, unsigned int column)
 Inform the view that items have been changed. More...
 
virtual unsigned int insert_index (const Point &scr_pt) const
 Return the index for inserting an item from a screen point. More...
 
virtual unsigned int screen_index (const Point &scr_pt) const
 Return the index under the screen point, does not check if it hits content of the item renderer. More...
 
virtual unsigned int hit_test (const Point &scr_pt) const
 Return the index under the screen point, checks if it hits content of the item renderer. More...
 
virtual void get_bounds (BBox &bounds, unsigned int index) const
 Get bounding box of the given index in work area coordinates. More...
 
virtual void get_bounds (BBox &bounds, unsigned int first, unsigned int last) const
 Get bounding box of the range of indices in work area coordinates. More...
 
void get_cell_bounds (BBox &bounds, unsigned int row, unsigned int column) const
 Get the cell bounds for the specified column and row. More...
 
unsigned int column_from_x (int x) const
 Get column from position on window. More...
 
int x_from_column (unsigned int column) const
 Return x coordinate relative to window of column. More...
 
- Public Member Functions inherited from tbx::view::ItemView
 ItemView (Window window)
 Construct the item view with the given renderer. More...
 
virtual ~ItemView ()
 Destructor removed any listeners.
 
tbx::Windowwindow ()
 Return the Window that this item view is attached to.
 
const tbx::Marginmargin () const
 Return the margin around the data in the window.
 
void margin (const tbx::Margin &margin)
 Change the margin.
 
bool auto_size () const
 Returns true if auto size is on.
 
void updates_enabled (bool updates)
 Enable/disable updating of attached window. More...
 
bool updates_enabled () const
 Check if updates of the attached window are enabled. More...
 
unsigned int count () const
 Returns number of items being displayed.
 
void selection (Selection *selection)
 Set the selection model to use for the item view. More...
 
Selectionselection () const
 Get the selection model used for selecting items in the list. More...
 
Selectionselection ()
 Get the selection model used for selecting items in the list. More...
 
void add_click_listener (ItemViewClickListener *listener)
 Add a listener for a click on the item view. More...
 
void remove_click_listener (ItemViewClickListener *listener)
 Remove a listener for a click on the item view.
 
void allow_drag_selection (bool on, bool on_item=false)
 Allow selection of multiple items by using a drag box. More...
 
void menu_selects (bool on)
 Turn on/off selection of an item when the menu button is pressed over an item and no other item is selected. More...
 
bool menu_selects () const
 Returns true if the menu button selects an item.
 
void clear_menu_selection ()
 Clear the current selection if it was made by the menu button.
 
bool last_selection_menu () const
 Returns true if the last selection was made by the menu button.
 
virtual void scroll_request (const tbx::ScrollRequestEvent &event)
 Process scroll requests. More...
 
virtual void mouse_click (tbx::MouseClickEvent &event)
 Mouse clicked on window containing list view. More...
 
virtual void selection_changed (const SelectionChangedEvent &event)
 Selection has changed event handling. More...
 
- Public Member Functions inherited from tbx::Listener
virtual ~Listener ()
 Destroy the listener object.
 
- Public Member Functions inherited from tbx::MouseClickListener
virtual ~MouseClickListener ()
 Destructor.
 

Protected Member Functions

virtual void process_drag_selection (const BBox &drag_box, bool adjust)
 Override this method to process selection by dragging. More...
 
unsigned int calc_row_height () const
 Calculate the row height from the first row of the report. More...
 
bool adjust_max_width (unsigned int start, unsigned int end)
 Adjust column widths and total width if any items in the given range exceed the current widths. More...
 
bool adjust_min_width (unsigned int from, unsigned int end)
 Check if any of the column widths have been reduced and adjust columns if necessary. More...
 
- Protected Member Functions inherited from tbx::view::ItemView
void process_mouse_click (int index, MouseClickEvent &event)
 Helper function to process mouse clicks.
 
- Protected Member Functions inherited from tbx::Listener
 Listener ()
 Construct the Listener object.
 

Additional Inherited Members

- Static Public Attributes inherited from tbx::view::ItemView
static const unsigned int NO_INDEX = -1
 Constant for invalid index. More...
 
- Protected Types inherited from tbx::view::ItemView
enum  ViewFlags {
  NONE = 0, AUTO_SIZE = 1, SELECT_DRAG = 2, SELECT_DRAG_ON_ITEM = 4,
  SELECT_MENU = 8, AUTO_SIZE_CHECKED = 0x100, WANT_AUTO_SIZE = 0x200, LAST_SELECT_MENU = 0x400,
  NO_UPDATES = 0x800
}
 Internal view flags enum, can be one or more of the following. More...
 
- Protected Attributes inherited from tbx::view::ItemView
Window _window
 Window displaying this view.
 
Margin _margin
 Margin around areas displaying items.
 
Selection_selection
 Selection model.
 
SafeList< ItemViewClickListener > * _click_listeners
 Listeners for a mouse click on the view.
 
unsigned int _count
 Number of items displayed in this view.
 
unsigned int _flags
 Internal view flags.
 

Detailed Description

Class to handle the display/interaction with a list of items presented in columns.

Constructor & Destructor Documentation

◆ ReportView()

tbx::view::ReportView::ReportView ( tbx::Window  window)

Construct a report view for a window.

Parameters
windowWindow displaying the report view

Member Function Documentation

◆ add_column()

unsigned int tbx::view::ReportView::add_column ( ItemRenderer cr,
unsigned int  width = 0 
)

Add a column to the report view.

Parameters
crRenderer to render cells for the column
widththe width of the column (any value other than zero turns off auto size for all columns)
Returns
zero based column number

◆ adjust_max_width()

bool tbx::view::ReportView::adjust_max_width ( unsigned int  start,
unsigned int  end 
)
protected

Adjust column widths and total width if any items in the given range exceed the current widths.

Note: Does not refresh the display

Parameters
startfirst row to check (inclusive)
endlast row to check (not inclusive)
Returns
true if any column was adjusted

◆ adjust_min_width()

bool tbx::view::ReportView::adjust_min_width ( unsigned int  from,
unsigned int  end 
)
protected

Check if any of the column widths have been reduced and adjust columns if necessary.

Measures from first to end-1

Parameters
fromfirst row to measure (inclusive)
endlast row to measure (not inclusive)
Returns
true if any widths have changed.

◆ auto_size()

void tbx::view::ReportView::auto_size ( bool  on)
virtual

Turn on or off auto sizing.

When auto sizing is on the item width is checked whenever an item is added, changed or removed.

To prevent a scan of the whole list on removal call the removing method before actually doing a removal.

Parameters
ontrue to turn autosizing on

Implements tbx::view::ItemView.

◆ calc_row_height()

unsigned int tbx::view::ReportView::calc_row_height ( ) const
protected

Calculate the row height from the first row of the report.

Returns
calculated row height

◆ cell_changed()

void tbx::view::ReportView::cell_changed ( unsigned int  index,
unsigned int  column 
)

Inform the view that items have been changed.

Parameters
indexlocation of item that will be changed from
columnThe column that has been changed

◆ cell_changing()

void tbx::view::ReportView::cell_changing ( unsigned int  index,
unsigned int  column 
)

Inform the view that one column has been changed.

This call is optional, but it stops the need for a full scan every time something an item is changed when auto size is on.

Parameters
indexlocation of item that will be changed from
columnThe column that has been changed

◆ changed()

void tbx::view::ReportView::changed ( unsigned int  where,
unsigned int  how_many 
)
virtual

Inform the view that items have been changed.

Parameters
wherelocation of first change
how_manynumber of items changed

Implements tbx::view::ItemView.

◆ changing()

void tbx::view::ReportView::changing ( unsigned int  where,
unsigned int  how_many 
)
virtual

Inform the view that items are about to be changed.

This call is optional, but it stops the need for a full scan every time something an item is changed when auto size is on.

Parameters
wherelocation items will be changed from
how_manynumber of items that will be changed

Reimplemented from tbx::view::ItemView.

◆ column_from_x()

unsigned int tbx::view::ReportView::column_from_x ( int  x) const

Get column from position on window.

Parameters
xhorizontal position from the left of the window work area

◆ column_gap()

void tbx::view::ReportView::column_gap ( unsigned int  gap)

Change the gap between columns.

Parameters
gapnew gap between the columns

◆ column_width() [1/2]

unsigned int tbx::view::ReportView::column_width ( unsigned int  column) const

Returns column width.

Parameters
column0 based column to return width for
Returns
column width or 0 if column >= column_count()

◆ column_width() [2/2]

void tbx::view::ReportView::column_width ( unsigned int  column,
unsigned int  width 
)

Set the column width.

Setting the column width turns of auto sizing

Parameters
columnzero based column number to set width for
widthnew width of the column

◆ get_bounds() [1/2]

void tbx::view::ReportView::get_bounds ( BBox bounds,
unsigned int  first,
unsigned int  last 
) const
virtual

Get bounding box of the range of indices in work area coordinates.

Parameters
boundsupdated to bounds of given rows
firstfirst zero based row number
lastlast zero based row number

Implements tbx::view::ItemView.

◆ get_bounds() [2/2]

void tbx::view::ReportView::get_bounds ( BBox bounds,
unsigned int  index 
) const
virtual

Get bounding box of the given index in work area coordinates.

Parameters
boundsupdated to bounds of row with given index
indexzero based row number

Implements tbx::view::ItemView.

◆ get_cell_bounds()

void tbx::view::ReportView::get_cell_bounds ( BBox bounds,
unsigned int  row,
unsigned int  column 
) const

Get the cell bounds for the specified column and row.

It is permitted to specifiy a column and row outside of the used cells.

Parameters
boundsbounding box to update (work area coordinates)
rowrow to retrieve the bounds for
columncolumn to retrieve the bounds for

◆ hit_test()

unsigned int tbx::view::ReportView::hit_test ( const Point scr_pt) const
virtual

Return the index under the screen point, checks if it hits content of the item renderer.

Parameters
scr_ptlocation on screen to test

Returns: NO_INDEX if doesn't hit content

Implements tbx::view::ItemView.

◆ insert_index()

unsigned int tbx::view::ReportView::insert_index ( const Point scr_pt) const
virtual

Return the index for inserting an item from a screen point.

Parameters
scr_ptposition to find the index for in screen coordinates
Returns
index for insert (returns count() if below last item).

Implements tbx::view::ItemView.

◆ inserted()

void tbx::view::ReportView::inserted ( unsigned int  where,
unsigned int  how_many 
)
virtual

Call after inserting rows into the collection the ReportView is showing.

Parameters
whererow column was inserted at
how_manynumber of columns inserted

Implements tbx::view::ItemView.

◆ process_drag_selection()

void tbx::view::ReportView::process_drag_selection ( const BBox drag_box,
bool  adjust 
)
protectedvirtual

Override this method to process selection by dragging.

allow_drag_selection must be set for this to be called.

Parameters
drag_boxFinal bounding box of drag
adjustadjust button was used for selection

Reimplemented from tbx::view::ItemView.

◆ redraw()

void tbx::view::ReportView::redraw ( const tbx::RedrawEvent event)
virtual

Redraw the window.

Parameters
eventinformation on area needing redraw

Implements tbx::view::ItemView.

◆ refresh()

void tbx::view::ReportView::refresh ( )
virtual

Called to refresh the entire views contents.

Refresh the whole report view.

It should also be called if all the data changes.

Implements tbx::view::ItemView.

◆ remove_column()

void tbx::view::ReportView::remove_column ( unsigned int  column)

Remove column from report.

Parameters
columnzero based column number to remove

◆ removed()

void tbx::view::ReportView::removed ( unsigned int  where,
unsigned int  how_many 
)
virtual

Call after removing rows from the collection the ReportView is showing.

Parameters
wherelocation items were removed from
how_manynumber of items that were removed

Implements tbx::view::ItemView.

◆ removing()

void tbx::view::ReportView::removing ( unsigned int  where,
unsigned int  how_many 
)
virtual

Inform the view that items are about to be removed.

This call is optional, but it stops the need for a full scan every time something is removed when auto size is on.

Parameters
wherelocation items will be removed from
how_manynumber of items that will be removed

Reimplemented from tbx::view::ItemView.

◆ row_height()

void tbx::view::ReportView::row_height ( unsigned int  height)

Change the row height.

If the row height is 0. It will take the height from the first item in the list. This is how the view starts up.

Parameters
heightnew row height

◆ screen_index()

unsigned int tbx::view::ReportView::screen_index ( const Point scr_pt) const
virtual

Return the index under the screen point, does not check if it hits content of the item renderer.

Parameters
scr_ptthe point to test
Returns
the index of the item below the point or NO_INDEX if the point is not over an item.

Implements tbx::view::ItemView.

◆ size_all_to_width()

void tbx::view::ReportView::size_all_to_width ( unsigned int  min_width = 0,
unsigned int  max_width = 0xFFFFFFFF 
)

Size all columns to content.

Does nothing if there is no content

Parameters
min_widthminimum width of any column
max_widthmaximum width of any column

◆ size_column_to_width()

void tbx::view::ReportView::size_column_to_width ( unsigned int  column,
unsigned int  min_width = 0,
unsigned int  max_width = 0xFFFFFFFF 
)

Size column to content.

Does nothing if there is no content

Parameters
columncolumn to resize
min_widthminimum width of the column
max_widthmaximum width of the column

◆ update_window_extent()

void tbx::view::ReportView::update_window_extent ( )
virtual

Called to update the window extent needed to contain this view.

Update the Window extent after a change in size.

Implements tbx::view::ItemView.

◆ x_from_column()

int tbx::view::ReportView::x_from_column ( unsigned int  column) const

Return x coordinate relative to window of column.

Returns
horzontal distance of column from left of the window work area

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