tbx
0.7.3
|
Base class for views that show an indexed list of items. More...
#include <itemview.h>
Public Member Functions | |
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. | |
virtual void | auto_size (bool on)=0 |
Set to true to resize the the view automatically when an item is added/removed or changed. More... | |
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 | redraw (const tbx::RedrawEvent &event)=0 |
Subclasses must override the redraw event to draw the items in the view. | |
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 void | update_window_extent ()=0 |
Called to update the window extent needed to contain this view. | |
virtual void | refresh ()=0 |
Called to refresh the entire views contents. | |
virtual void | inserted (unsigned int where, unsigned int how_many)=0 |
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)=0 |
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)=0 |
Inform the view that items have been changed. More... | |
virtual void | cleared ()=0 |
Inform the view that all the data has been cleared. | |
virtual unsigned int | insert_index (const Point &scr_pt) const =0 |
Return the index for inserting an item from a screen point. | |
virtual unsigned int | screen_index (const Point &scr_pt) const =0 |
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 =0 |
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 =0 |
Get bounding box of the given index in work area coordinates. | |
virtual void | get_bounds (BBox &bounds, unsigned int first, unsigned int last) const =0 |
Get bounding box of the range of indices in work area coordinates. | |
![]() | |
virtual | ~Listener () |
Destroy the listener object. | |
![]() | |
virtual | ~MouseClickListener () |
Destructor. | |
Static Public Attributes | |
static const unsigned int | NO_INDEX = -1 |
Constant for invalid index. More... | |
Protected Types | |
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 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 | |
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. | |
Base class for views that show an indexed list of items.
The view does not maintain the list of items itself, it must be told when the list of items are changed using the inserted, removed and changed methods.
The items are rendered using the ItemRenderer passed to the constructor.
|
protected |
Internal view flags enum, can be one or more of the following.
Enumerator | |
---|---|
NONE |
No flags size. |
AUTO_SIZE |
Autosizing on. |
SELECT_DRAG |
Select by dragging box allowed. |
SELECT_DRAG_ON_ITEM |
Select by dragging box starting on an item allowed. |
SELECT_MENU |
Menu button selects item if no others selected. |
AUTO_SIZE_CHECKED |
Removing or changing called. |
WANT_AUTO_SIZE |
Need to auto size on removed called. |
LAST_SELECT_MENU |
Last selection was caused by menu button. |
NO_UPDATES |
Do not update window. |
tbx::view::ItemView::ItemView | ( | Window | window | ) |
Construct the item view with the given renderer.
By default auto sizing is on a select dragging when using a multiple selection
void tbx::view::ItemView::add_click_listener | ( | ItemViewClickListener * | listener | ) |
Add a listener for a click on the item view.
The click listeners are run after any selection process.
void tbx::view::ItemView::allow_drag_selection | ( | bool | on, |
bool | on_item = false |
||
) |
Allow selection of multiple items by using a drag box.
on | allow or disallow drag selection |
on_item | set to true to allow drag selection starting on an item |
|
pure virtual |
Set to true to resize the the view automatically when an item is added/removed or changed.
Derived classes should set the AUTO_SIZE flag and when set on should recalculate the size for the existing items.
Implemented in tbx::view::TileView, tbx::view::ListView, and tbx::view::ReportView.
|
pure virtual |
Inform the view that items have been changed.
where | location of first change |
how_many | number of items changed |
Implemented in tbx::view::ReportView, tbx::view::ListView, and tbx::view::TileView.
|
inlinevirtual |
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 in tbx::view::ReportView, tbx::view::ListView, and tbx::view::TileView.
|
pure 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
Implemented in tbx::view::ReportView, tbx::view::ListView, and tbx::view::TileView.
|
pure virtual |
Inform the view that items have been inserted.
where | location for insertion |
how_many | number of items inserted |
Implemented in tbx::view::ReportView, tbx::view::ListView, and tbx::view::TileView.
void tbx::view::ItemView::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.
Usually you would add the ItemViewClearMenuSelection as a has been hidden listener to the menu on the views window so a menu selection is removed when the menu is closed.
on | true to turn menu selection on, false to turn it off. |
|
virtual |
Mouse clicked on window containing list view.
The version in this class processes the selection if necessary and fires the ItemViewClickListeners.
If it is overridden then this functionality will be lost unless it is replaced or the ItemView implementation called.
Implements tbx::MouseClickListener.
|
inlineprotectedvirtual |
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 in tbx::view::ReportView, tbx::view::ListView, and tbx::view::TileView.
|
pure virtual |
Inform the view that items have been removed.
where | location for removal |
how_many | number of items removed |
Implemented in tbx::view::ReportView, tbx::view::ListView, and tbx::view::TileView.
|
inlinevirtual |
Inform the view that items are about to be removed.
This call is optional, but it stops the need for a full scan of the list when auto size is on.
Reimplemented in tbx::view::ReportView, tbx::view::ListView, and tbx::view::TileView.
|
pure 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 |
Implemented in tbx::view::ReportView, tbx::view::ListView, and tbx::view::TileView.
|
virtual |
Process scroll requests.
This allows page clicks on the scroll bar to take into account the margins.
It makes line clicks on the scroll bar move 32 units left/right and 40 OS units up/down.
The appropriate flag in the window must be set for this event to be generated.
Override this to customise the scrolling behaviour.
Implements tbx::ScrollRequestListener.
void tbx::view::ItemView::selection | ( | Selection * | selection | ) |
Set the selection model to use for the item view.
selection | Selection model to use for selecting items in the list or 0 to disable selection. |
|
inline |
Get the selection model used for selecting items in the list.
|
inline |
Get the selection model used for selecting items in the list.
|
virtual |
Selection has changed event handling.
The ItemView implementation forces a redraw of the items that have had there selection changed.
Implements tbx::view::SelectionListener.
|
inline |
Enable/disable updating of attached window.
After turning on updates - a call to update_window_extents to refresh the window
updates | true to turn on updates (the default), false to turn them off |
|
inline |
Check if updates of the attached window are enabled.
|
static |
Constant for invalid index.
Used as a result from hit testing.