32 #ifndef TBX_ITEMVIEW_H_
33 #define TBX_ITEMVIEW_H_
35 #include "../window.h"
36 #include "../mouseclicklistener.h"
37 #include "../margin.h"
38 #include "../draghandler.h"
39 #include "../safelist.h"
40 #include "../hasbeenhiddenlistener.h"
41 #include "../scrollrequestlistener.h"
42 #include "itemrenderer.h"
43 #include "selection.h"
52 class ItemViewClickListener;
208 virtual void inserted(
unsigned int where,
unsigned int how_many) = 0;
216 virtual void removing(
unsigned int where,
unsigned int how_many) {}
224 virtual void removed(
unsigned int where,
unsigned int how_many) = 0;
235 virtual void changing(
unsigned int where,
unsigned int how_many) {};
243 virtual void changed(
unsigned int where,
unsigned int how_many) = 0;
282 virtual void get_bounds(
BBox &bounds,
unsigned int first,
unsigned int last)
const = 0;
308 Selector(
ItemView *me,
bool adjust) : _me(me), _adjust(adjust) {};
310 virtual void drag_finished(
const tbx::BBox &
final);
311 virtual void drag_cancelled();
351 unsigned int index()
const {
return _index;}
Selection * selection()
Get the selection model used for selecting items in the list.
Definition: itemview.h:164
Listener for selection changed events.
Definition: selection.h:130
ItemViewClickEvent(ItemView &source, unsigned int index, const MouseClickEvent &click_event)
Constructor.
Definition: itemview.h:330
Listener for mouse clicks on a Window.
Definition: mouseclicklistener.h:130
A library for creating RISC OS toolbox applications.
Definition: abouttobeshownlistener.cc:35
unsigned int count() const
Returns number of items being displayed.
Definition: itemview.h:149
Selection * _selection
Selection model.
Definition: itemview.h:72
ItemView(Window window)
Construct the item view with the given renderer.
Definition: itemview.cc:43
virtual unsigned int insert_index(const Point &scr_pt) const =0
Return the index for inserting an item from a screen point.
bool menu_selects() const
Returns true if the menu button selects an item.
Definition: itemview.cc:165
virtual void inserted(unsigned int where, unsigned int how_many)=0
Inform the view that items have been inserted.
const MouseClickEvent & click_event() const
Returns original mouse click event on the window containing this item view.
Definition: itemview.h:356
The Window object represents a toolbox window.
Definition: window.h:70
void process_mouse_click(int index, MouseClickEvent &event)
Helper function to process mouse clicks.
Definition: itemview.cc:361
@ SELECT_DRAG
Select by dragging box allowed.
Definition: itemview.h:82
virtual void removed(unsigned int where, unsigned int how_many)=0
Inform the view that items have been removed.
Window _window
Window displaying this view.
Definition: itemview.h:70
virtual void refresh()=0
Called to refresh the entire views contents.
@ SELECT_MENU
Menu button selects item if no others selected.
Definition: itemview.h:84
bool last_selection_menu() const
Returns true if the last selection was made by the menu button.
Definition: itemview.cc:184
static const unsigned int NO_INDEX
Constant for invalid index.
Definition: itemview.h:101
virtual void mouse_click(tbx::MouseClickEvent &event)
Mouse clicked on window containing list view.
Definition: itemview.cc:290
@ WANT_AUTO_SIZE
Need to auto size on removed called.
Definition: itemview.h:86
virtual void changing(unsigned int where, unsigned int how_many)
Inform the view that items are about to be changed.
Definition: itemview.h:235
Listener for an object has been hidden event.
Definition: hasbeenhiddenlistener.h:36
@ AUTO_SIZE
Autosizing on.
Definition: itemview.h:81
virtual void cleared()=0
Inform the view that all the data has been cleared.
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 ~ItemView()
Destructor removed any listeners.
Definition: itemview.cc:57
ViewFlags
Internal view flags enum, can be one or more of the following.
Definition: itemview.h:80
bool auto_size() const
Returns true if auto size is on.
Definition: itemview.h:128
virtual void auto_size(bool on)=0
Set to true to resize the the view automatically when an item is added/removed or changed.
virtual void removing(unsigned int where, unsigned int how_many)
Inform the view that items are about to be removed.
Definition: itemview.h:216
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.
tbx::Window & window()
Return the Window that this item view is attached to.
Definition: itemview.h:107
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.
virtual void itemview_clicked(const ItemViewClickEvent &event)=0
Method called when an item in the view is clicked.
virtual void get_bounds(BBox &bounds, unsigned int index) const =0
Get bounding box of the given index in work area coordinates.
void updates_enabled(bool updates)
Enable/disable updating of attached window.
Definition: itemview.h:137
bool updates_enabled() const
Check if updates of the attached window are enabled.
Definition: itemview.h:144
@ NO_UPDATES
Do not update window.
Definition: itemview.h:88
Class to represent a two dimensional bounding box.
Definition: bbox.h:38
Margin _margin
Margin around areas displaying items.
Definition: itemview.h:71
virtual void selection_changed(const SelectionChangedEvent &event)
Selection has changed event handling.
Definition: itemview.cc:378
virtual void changed(unsigned int where, unsigned int how_many)=0
Inform the view that items have been changed.
Simple one way linked list of pointers that provides a single iterator that can be used safely if ite...
Definition: safelist.h:45
ItemView & source() const
Return item view this event occurred on.
Definition: itemview.h:336
bool item_hit() const
Return true if an item was hit.
Definition: itemview.h:346
Base class for views that show an indexed list of items.
Definition: itemview.h:68
@ LAST_SELECT_MENU
Last selection was caused by menu button.
Definition: itemview.h:87
virtual void scroll_request(const tbx::ScrollRequestEvent &event)
Process scroll requests.
Definition: itemview.cc:213
Event for click on a window.
Definition: mouseclicklistener.h:42
void add_click_listener(ItemViewClickListener *listener)
Add a listener for a click on the item view.
Definition: itemview.cc:100
Class to report status of a drag started on a window.
Definition: draghandler.h:36
Class with the details of a select, deselect or toggle operation.
Definition: selection.h:45
Event for click on ItemView.
Definition: itemview.h:321
@ AUTO_SIZE_CHECKED
Removing or changing called.
Definition: itemview.h:85
Redraw event listener.
Definition: redrawlistener.h:76
SafeList< ItemViewClickListener > * _click_listeners
Listeners for a mouse click on the view.
Definition: itemview.h:74
Class to represent a position in two dimensional space.
Definition: point.h:37
Base class for all toolbox event listeners.
Definition: listener.h:34
Listener for clicks on the item view.
Definition: itemview.h:363
unsigned int index() const
Returns index click occurred on or NO_INDEX if click did not hit an item.
Definition: itemview.h:351
virtual void update_window_extent()=0
Called to update the window extent needed to contain this view.
void clear_menu_selection()
Clear the current selection if it was made by the menu button.
Definition: itemview.cc:173
virtual void process_drag_selection(const BBox &drag_box, bool adjust)
Override this method to process selection by dragging.
Definition: itemview.h:293
Event passed to redraw listener to give details on the area that needs a redraw.
Definition: redrawlistener.h:44
void remove_click_listener(ItemViewClickListener *listener)
Remove a listener for a click on the item view.
Definition: itemview.cc:113
virtual void redraw(const tbx::RedrawEvent &event)=0
Subclasses must override the redraw event to draw the items in the view.
Base class for selections of one or more indices from a zero based range.
Definition: selection.h:146
const tbx::Margin & margin() const
Return the margin around the data in the window.
Definition: itemview.h:113
@ NONE
No flags size.
Definition: itemview.h:80
void allow_drag_selection(bool on, bool on_item=false)
Allow selection of multiple items by using a drag box.
Definition: itemview.cc:133
unsigned int _count
Number of items displayed in this view.
Definition: itemview.h:75
unsigned int _flags
Internal view flags.
Definition: itemview.h:90
Class to represent a margin around an area.
Definition: margin.h:35
Selection * selection() const
Get the selection model used for selecting items in the list.
Definition: itemview.h:158
Class to provide information on a toolbox event.
Definition: eventinfo.h:49
@ SELECT_DRAG_ON_ITEM
Select by dragging box starting on an item allowed.
Definition: itemview.h:83
static const unsigned int NO_INDEX
Constant for index when there was no index hit.
Definition: itemview.h:341