tbx
0.7.5
|
Class to show items in a list down the window. More...
#include <listview.h>
Public Member Functions | |
ListView (tbx::Window window, ItemRenderer *item_renderer=0) | |
Constructor. | |
virtual | ~ListView () |
Destructor. | |
void | item_renderer (ItemRenderer *ir) |
Change the item renderer. More... | |
void | row_height (unsigned int height) |
Change the row height. More... | |
unsigned int | row_height () const |
Return the row height. | |
virtual void | auto_size (bool on) |
Turn on or off auto sizing. More... | |
void | width (unsigned int width) |
Set the width. More... | |
unsigned int | width () const |
Return the current width of the ListView. | |
unsigned int | max_width (unsigned int from, unsigned int end) |
Measure the maximum width for a range of rows. More... | |
unsigned int | check_width (unsigned int from, unsigned int end) |
Check if width has been reduced to less then _width. More... | |
void | size_to_width (unsigned int min_width=0, unsigned int max_width=0xFFFFFFFF) |
Size width to match content. More... | |
virtual void | redraw (const tbx::RedrawEvent &event) |
Redraw the List view. | |
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) |
Inform the view that items have been inserted. 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) |
Inform the view that items have been removed. 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. | |
virtual unsigned int | insert_index (const Point &scr_pt) const |
Return the index for inserting an item from a screen point. | |
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. | |
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. | |
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. | |
![]() | |
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... | |
![]() | |
void | process_mouse_click (int index, MouseClickEvent &event) |
Helper function to process mouse clicks. | |
![]() | |
Listener () | |
Construct the Listener object. | |
Protected Attributes | |
ItemRenderer * | _item_renderer |
Object used to render itesm. | |
unsigned int | _height |
Height of one item. | |
unsigned int | _width |
Width of list view. | |
![]() | |
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. | |
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... | |
Class to show items in a list down the window.
|
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.
Implements tbx::view::ItemView.
|
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::ListView::check_width | ( | unsigned int | from, |
unsigned int | end | ||
) |
Check if width has been reduced to less then _width.
Measures from first to end-1
from | first row to measure (inclusive) |
end | last row to measure (not inclusive) |
|
virtual |
Return the index under the screen point, checks if it hits content of the item renderer.
Returns: NO_INDEX if doesn't hit content
Implements tbx::view::ItemView.
|
virtual |
Inform the view that items have been inserted.
where | location for insertion |
how_many | number of items inserted |
Implements tbx::view::ItemView.
void tbx::view::ListView::item_renderer | ( | ItemRenderer * | ir | ) |
Change the item renderer.
If there are items already defined it will resize or refresh the view depending on if auto_size is set.
unsigned int tbx::view::ListView::max_width | ( | unsigned int | from, |
unsigned int | end | ||
) |
Measure the maximum width for a range of rows.
Measures from first to end-1
from | first row to measure (inclusive) |
end | last row to measure (not inclusive) |
|
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 |
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.
|
virtual |
Inform the view that items have been removed.
where | location for removal |
how_many | number of items 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::ListView::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.
void tbx::view::ListView::size_to_width | ( | unsigned int | min = 0 , |
unsigned int | max = 0xFFFFFFFF |
||
) |
Size width to match content.
Does nothing if there is no content
Using this function to set the width automatically turns off auto sizing
|
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.
void tbx::view::ListView::width | ( | unsigned int | width | ) |
Set the width.
Setting the width automatically turns of auto sizing