tbx  0.7.3
listview.h
1 /*
2  * tbx RISC OS toolbox library
3  *
4  * Copyright (C) 2010 Alan Buckley All Rights Reserved.
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a
7  * copy of this software and associated documentation files (the "Software"),
8  * to deal in the Software without restriction, including without limitation
9  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10  * and/or sell copies of the Software, and to permit persons to whom the
11  * Software is furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included
14  * in all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22  * THE SOFTWARE.
23  */
24 
25 /*
26  * listview.h
27  *
28  * Created on: 25 Mar 2010
29  * Author: alanb
30  */
31 
32 #ifndef TBX_LISTVIEW_H_
33 #define TBX_LISTVIEW_H_
34 
35 #include "itemview.h"
36 
37 namespace tbx {
38 
39 namespace view {
40 
46 class ListView : public ItemView
47 {
48 protected:
50  unsigned int _height;
51  unsigned int _width;
52 
53 public:
55  virtual ~ListView();
56 
57  void item_renderer(ItemRenderer *ir);
58 
59 
60  void row_height(unsigned int height);
64  unsigned int row_height() const {return _height;}
65 
66  virtual void auto_size(bool on);
67 
68  void width(unsigned int width);
72  unsigned int width() const;
73 
74  unsigned int max_width(unsigned int from, unsigned int end);
75  unsigned int check_width(unsigned int from, unsigned int end);
76 
77  void size_to_width(unsigned int min_width = 0, unsigned int max_width = 0xFFFFFFFF);
78 
79  virtual void redraw(const tbx::RedrawEvent &event);
80 
85  virtual void update_window_extent();
86 
90  virtual void refresh();
91 
92  virtual void inserted(unsigned int where, unsigned int how_many);
93  virtual void removing(unsigned int where, unsigned int how_many);
94  virtual void removed(unsigned int where, unsigned int how_many);
95  virtual void changing(unsigned int where, unsigned int how_many);
96  virtual void changed(unsigned int where, unsigned int how_many);
97  virtual void cleared();
98 
99  virtual unsigned int insert_index(const Point &scr_pt) const;
100  virtual unsigned int screen_index(const Point &scr_pt) const;
101  virtual unsigned int hit_test(const Point &scr_pt) const;
102 
103 
104  virtual void get_bounds(BBox &bounds, unsigned int index) const;
105  virtual void get_bounds(BBox &bounds, unsigned int first, unsigned int last) const;
106 
107 protected:
116  virtual void process_drag_selection(const BBox &drag_box, bool adjust);
117 
118 };
119 
120 }
121 
122 }
123 
124 #endif /* LISTVIEW_H_ */
virtual void removed(unsigned int where, unsigned int how_many)
Inform the view that items have been removed.
Definition: listview.cc:363
virtual void changing(unsigned int where, unsigned int how_many)
Inform the view that items are about to be changed.
Definition: listview.cc:400
virtual ~ListView()
Destructor.
Definition: listview.cc:55
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
void item_renderer(ItemRenderer *ir)
Change the item renderer.
Definition: listview.cc:66
Base class for views that show an indexed list of items.
Definition: itemview.h:63
virtual void cleared()
Whole view has been cleared.
Definition: listview.cc:477
virtual void update_window_extent()
Called to update the window extent needed to contain this view.
Definition: listview.cc:261
Base class to render an indexed item.
Definition: itemrenderer.h:53
virtual void get_bounds(BBox &bounds, unsigned int index) const
Get bounding box of the given index in work area coordinates.
Definition: listview.cc:589
unsigned int width() const
Return the current width of the ListView.
Class to represent a position in two dimensional space.
Definition: point.h:36
Event passed to redraw listener to give details on the area that needs a redraw.
Definition: redrawlistener.h:43
bool auto_size() const
Returns true if auto size is on.
Definition: itemview.h:128
virtual void process_drag_selection(const BBox &drag_box, bool adjust)
Override this method to process selection by dragging.
Definition: listview.cc:616
virtual void changed(unsigned int where, unsigned int how_many)
Inform the view that items have been changed.
Definition: listview.cc:423
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...
Definition: listview.cc:523
The Window object represents a toolbox window.
Definition: window.h:69
ListView(tbx::Window window, ItemRenderer *item_renderer=0)
Constructor.
Definition: listview.cc:44
virtual void removing(unsigned int where, unsigned int how_many)
Inform the view that items are about to be removed.
Definition: listview.cc:340
unsigned int _width
Width of list view.
Definition: listview.h:51
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.
Definition: listview.cc:550
void size_to_width(unsigned int min_width=0, unsigned int max_width=0xFFFFFFFF)
Size width to match content.
Definition: listview.cc:196
virtual void inserted(unsigned int where, unsigned int how_many)
Inform the view that items have been inserted.
Definition: listview.cc:302
unsigned int _height
Height of one item.
Definition: listview.h:50
ItemRenderer * _item_renderer
Object used to render itesm.
Definition: listview.h:49
Class to show items in a list down the window.
Definition: listview.h:46
unsigned int check_width(unsigned int from, unsigned int end)
Check if width has been reduced to less then _width.
Definition: listview.cc:177
virtual unsigned int insert_index(const Point &scr_pt) const
Return the index for inserting an item from a screen point.
Definition: listview.cc:505
unsigned int row_height() const
Return the row height.
Definition: listview.h:64
virtual void redraw(const tbx::RedrawEvent &event)
Redraw the List view.
Definition: listview.cc:212
virtual void refresh()
Called to refresh the entire views contents.
Definition: listview.cc:286
unsigned int max_width(unsigned int from, unsigned int end)
Measure the maximum width for a range of rows.
Definition: listview.cc:157