tbx
0.7.3
|
Class to handle the display/interaction with a list of items presented in columns. More...
#include <reportview.h>
Public Member Functions | |
ReportView (tbx::Window window) | |
Construct a report view for a window. More... | |
virtual | ~ReportView () |
Destructor of report view. More... | |
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... | |
![]() | |
ItemView (Window window) | |
Construct the item view with the given renderer. More... | |
virtual | ~ItemView () |
Destructor removed any listeners. | |
tbx::Window & | window () |
Return the Window that this item view is attached to. | |
const tbx::Margin & | margin () 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... | |
Selection * | selection () const |
Get the selection model used for selecting items in the list. More... | |
Selection * | selection () |
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... | |
![]() | |
virtual | ~Listener () |
Destroy the listener object. | |
![]() | |
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... | |
![]() | |
void | process_mouse_click (int index, MouseClickEvent &event) |
Helper function to process mouse clicks. | |
![]() | |
Listener () | |
Construct the Listener object. | |
Additional Inherited Members | |
![]() | |
static const unsigned int | NO_INDEX = -1 |
Constant for invalid index. More... | |
![]() | |
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... | |
![]() | |
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. | |
Class to handle the display/interaction with a list of items presented in columns.
tbx::view::ReportView::ReportView | ( | tbx::Window | window | ) |
Construct a report view for a window.
window | Window displaying the report view |
|
virtual |
Destructor of report view.
unsigned int tbx::view::ReportView::add_column | ( | ItemRenderer * | cr, |
unsigned int | width = 0 |
||
) |
Add a column to the report view.
cr | Renderer to render cells for the column |
width | the width of the column (any value other than zero turns off auto size for all columns) |
|
protected |
Adjust column widths and total width if any items in the given range exceed the current widths.
Note: Does not refresh the display
start | first row to check (inclusive) |
end | last row to check (not inclusive) |
|
protected |
Check if any of the column widths have been reduced and adjust columns if necessary.
Measures from first to end-1
from | first row to measure (inclusive) |
end | last row to measure (not inclusive) |
|
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.
on | true to turn autosizing on |
Implements tbx::view::ItemView.
|
protected |
Calculate the row height from the first row of the report.
void tbx::view::ReportView::cell_changed | ( | unsigned int | index, |
unsigned int | column | ||
) |
Inform the view that items have been changed.
index | location of item that will be changed from |
column | The column that has been changed |
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.
index | location of item that will be changed from |
column | The column that has been changed |
|
virtual |
Inform the view that items have been changed.
where | location of first change |
how_many | number of items changed |
Implements tbx::view::ItemView.
|
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.
where | location items will be changed from |
how_many | number of items that will be changed |
Reimplemented from tbx::view::ItemView.
unsigned int tbx::view::ReportView::column_from_x | ( | int | x | ) | const |
Get column from position on window.
x | horizontal position from the left of the window work area |
void tbx::view::ReportView::column_gap | ( | unsigned int | gap | ) |
Change the gap between columns.
gap | new gap between the columns |
void tbx::view::ReportView::column_width | ( | unsigned int | column, |
unsigned int | width | ||
) |
Set the column width.
Setting the column width turns of auto sizing
column | zero based column number to set width for |
width | new width of the column |
unsigned int tbx::view::ReportView::column_width | ( | unsigned int | column | ) | const |
Returns column width.
column | 0 based column to return width for |
|
virtual |
Get bounding box of the given index in work area coordinates.
bounds | updated to bounds of row with given index |
index | zero based row number |
Implements tbx::view::ItemView.
|
virtual |
Get bounding box of the range of indices in work area coordinates.
bounds | updated to bounds of given rows |
first | first zero based row number |
last | last zero based row number |
Implements tbx::view::ItemView.
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.
bounds | bounding box to update (work area coordinates) |
row | row to retrieve the bounds for |
column | column to retrieve the bounds for |
|
virtual |
Return the index under the screen point, checks if it hits content of the item renderer.
scr_pt | location on screen to test |
Returns: NO_INDEX if doesn't hit content
Implements tbx::view::ItemView.
|
virtual |
Return the index for inserting an item from a screen point.
scr_pt | position to find the index for in screen coordinates |
Implements tbx::view::ItemView.
|
virtual |
Call after inserting rows into the collection the ReportView is showing.
where | row column was inserted at |
how_many | number of columns inserted |
Implements tbx::view::ItemView.
|
protectedvirtual |
Override this method to process selection by dragging.
allow_drag_selection must be set for this to be called.
drag_box | Final bounding box of drag |
adjust | adjust button was used for selection |
Reimplemented from tbx::view::ItemView.
|
virtual |
Redraw the window.
event | information on area needing redraw |
Implements tbx::view::ItemView.
|
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.
void tbx::view::ReportView::remove_column | ( | unsigned int | column | ) |
Remove column from report.
column | zero based column number to remove |
|
virtual |
Call after removing rows from the collection the ReportView is showing.
where | location items were removed from |
how_many | number of items that were removed |
Implements tbx::view::ItemView.
|
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.
where | location items will be removed from |
how_many | number of items that will be removed |
Reimplemented from tbx::view::ItemView.
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.
height | new row height |
|
virtual |
Return the index under the screen point, does not check if it hits content of the item renderer.
scr_pt | the point to test |
Implements tbx::view::ItemView.
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
min_width | minimum width of any column |
max_width | maximum width of any column |
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
column | column to resize |
min_width | minimum width of the column |
max_width | maximum width of the column |
|
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.
int tbx::view::ReportView::x_from_column | ( | unsigned int | column | ) | const |
Return x coordinate relative to window of column.