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