tbx
0.7.3
|
Class to show items tiled in a window. More...
#include <tileview.h>
Public Member Functions | |
TileView (tbx::Window window, ItemRenderer *item_renderer=0) | |
Construct a tile view for specific Window using the given item renderer. | |
void | item_renderer (ItemRenderer *ir) |
Change the item renderer. More... | |
const tbx::Size & | tile_size () const |
Return the size of a tile. | |
void | tile_size (tbx::Size new_size) |
Set the size of a tile in the tile view. More... | |
tbx::Size | max_size (unsigned int from, unsigned int end) |
Measure the maximum tile size for a range of items. More... | |
tbx::Size | check_size (unsigned int from, unsigned int end) |
Check if size has been reduced to less than tile_size. More... | |
void | size_to_tiles () |
Size to match content. More... | |
virtual void | auto_size (bool on) |
Turn on or off auto sizing. More... | |
virtual void | redraw (const tbx::RedrawEvent &event) |
Redraw the window. | |
virtual void | open_window (tbx::OpenWindowEvent &event) |
Window has been opened or resized, so re do layout. | |
virtual void | update_window_extent () |
Update the Window extent after a change in size. More... | |
virtual void | refresh () |
Refresh the whole report view. 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 |
Find the index to insert an item based on the screen coordinates given. More... | |
virtual unsigned int | screen_index (const Point &scr_pt) const |
Get item index for the screen location (if any) More... | |
virtual unsigned int | hit_test (const Point &scr_pt) const |
Hit test the given screen point. More... | |
virtual void | get_bounds (BBox &bounds, unsigned int index) const |
Get the cell bounds for the specified index. 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. | |
![]() | |
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... | |
bool | recalc_layout (const BBox &visible_area) |
Recalculate the cell layout and update/refresh the window. 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 |
Renderer for items in the tile view. | |
tbx::Size | _tile_size |
Size of tiles. | |
int | _cols_per_row |
Number of tiles in a row. | |
![]() | |
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 tiled in a window.
Each item is placed in a cell of the same size and the items are wrapped depending on the current width of the window.
|
virtual |
Turn on or off auto sizing.
When auto sizing is on the item size 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.
tbx::Size tbx::view::TileView::check_size | ( | unsigned int | from, |
unsigned int | end | ||
) |
Check if size has been reduced to less than tile_size.
Measures from first to end-1
from | first row to measure (inclusive) |
end | last row to measure (not inclusive) |
|
virtual |
Get the cell bounds for the specified index.
bounds | bounding box to update (work area coordinates) |
index | index to retrieve the bounds for |
Implements tbx::view::ItemView.
|
virtual |
Hit test the given screen point.
Unlike screen_index this uses the cell renderer to see if it has actually hit content rather than just somewhere in the cell.
returns: index of hit or -1 if none.
Implements tbx::view::ItemView.
|
virtual |
Find the index to insert an item based on the screen coordinates given.
scr_pt | position to find the index for |
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::TileView::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.
tbx::Size tbx::view::TileView::max_size | ( | unsigned int | from, |
unsigned int | end | ||
) |
Measure the maximum tile size for a range of items.
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.
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.
|
protected |
Recalculate the cell layout and update/refresh the window.
visible_area | visible area of window on screen |
|
virtual |
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.
|
virtual |
Get item index for the screen location (if any)
scr_pt | position on screen (screen coordinates) |
Implements tbx::view::ItemView.
void tbx::view::TileView::size_to_tiles | ( | ) |
Size to match content.
Does nothing if there is no content
Using this function to set the size automatically turns off auto sizing
void tbx::view::TileView::tile_size | ( | tbx::Size | new_size | ) |
Set the size of a tile in the tile view.
Calling this function automatically turns of auto sizing
new_size | the new size of a tile in the view |
|
virtual |
Update the Window extent after a change in size.
Note: TileView do not change the width of the extent, just the height.
Implements tbx::view::ItemView.