tbx  0.7.5
tileview.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  * tileview.h
27  *
28  * Created on: 16 Apr 2010
29  * Author: alanb
30  */
31 
32 #ifndef TBX_TILEVIEW_H_
33 #define TBX_TILEVIEW_H_
34 
35 #include "itemview.h"
36 #include "../openwindowlistener.h"
37 
38 namespace tbx {
39 
40 namespace view {
41 
49 {
50 protected:
54 
55 public:
57  virtual ~TileView();
58 
59  void item_renderer(ItemRenderer *ir);
60 
64  const tbx::Size &tile_size() const {return _tile_size;}
65  void tile_size(tbx::Size new_size);
66 
67  tbx::Size max_size(unsigned int from, unsigned int end);
68  tbx::Size check_size(unsigned int from, unsigned int end);
69  void size_to_tiles();
70 
71  virtual void auto_size(bool on);
72  // Window events used
73  virtual void redraw(const tbx::RedrawEvent &event);
74  virtual void open_window(tbx::OpenWindowEvent &event);
75 
76  virtual void update_window_extent();
77  virtual void refresh();
78 
79  virtual void inserted(unsigned int where, unsigned int how_many);
80  virtual void removing(unsigned int where, unsigned int how_many);
81  virtual void removed(unsigned int where, unsigned int how_many);
82  virtual void changing(unsigned int where, unsigned int how_many);
83  virtual void changed(unsigned int where, unsigned int how_many);
84  virtual void cleared();
85 
86  virtual unsigned int insert_index(const Point &scr_pt) const;
87  virtual unsigned int screen_index(const Point &scr_pt) const;
88  virtual unsigned int hit_test(const Point &scr_pt) const;
89 
90  virtual void get_bounds(BBox &bounds, unsigned int index) const;
91 
95  virtual void get_bounds(BBox &bounds, unsigned int first, unsigned int last) const;
96 
97 protected:
106  virtual void process_drag_selection(const BBox &drag_box, bool adjust);
107 
108  bool recalc_layout(const BBox &visible_area);
109 
110 
111 };
112 
113 }
114 
115 }
116 
117 #endif /* TBX_TILEVIEW_H_ */
A library for creating RISC OS toolbox applications.
Definition: abouttobeshownlistener.cc:34
Class to represent a two-dimensional size.
Definition: size.h:34
ItemRenderer * _item_renderer
Renderer for items in the tile view.
Definition: tileview.h:51
Helper classes to display and edit data.
virtual void redraw(const tbx::RedrawEvent &event)
Redraw the window.
Definition: tileview.cc:184
bool recalc_layout(const BBox &visible_area)
Recalculate the cell layout and update/refresh the window.
Definition: tileview.cc:271
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 update_window_extent()
Update the Window extent after a change in size.
Definition: tileview.cc:256
virtual void get_bounds(BBox &bounds, unsigned int index) const
Get the cell bounds for the specified index.
Definition: tileview.cc:649
virtual unsigned int insert_index(const Point &scr_pt) const
Find the index to insert an item based on the screen coordinates given.
Definition: tileview.cc:543
Class to show items tiled in a window.
Definition: tileview.h:48
void item_renderer(ItemRenderer *ir)
Change the item renderer.
Definition: tileview.cc:62
Base class for views that show an indexed list of items.
Definition: itemview.h:63
TileView(tbx::Window window, ItemRenderer *item_renderer=0)
Construct a tile view for specific Window using the given item renderer.
Definition: tileview.cc:42
virtual unsigned int hit_test(const Point &scr_pt) const
Hit test the given screen point.
Definition: tileview.cc:612
Base class to render an indexed item.
Definition: itemrenderer.h:53
virtual void inserted(unsigned int where, unsigned int how_many)
Inform the view that items have been inserted.
Definition: tileview.cc:311
Class to represent a position in two dimensional space.
Definition: point.h:36
const tbx::Size & tile_size() const
Return the size of a tile.
Definition: tileview.h:64
void size_to_tiles()
Size to match content.
Definition: tileview.cc:127
virtual void changing(unsigned int where, unsigned int how_many)
Inform the view that items are about to be changed.
Definition: tileview.cc:427
virtual void process_drag_selection(const BBox &drag_box, bool adjust)
Override this method to process selection by dragging.
Definition: tileview.cc:690
Event passed to redraw listener to give details on the area that needs a redraw.
Definition: redrawlistener.h:43
virtual void removing(unsigned int where, unsigned int how_many)
Inform the view that items are about to be removed.
Definition: tileview.cc:359
virtual void changed(unsigned int where, unsigned int how_many)
Inform the view that items have been changed.
Definition: tileview.cc:451
virtual void refresh()
Refresh the whole report view.
Definition: tileview.cc:300
bool auto_size() const
Returns true if auto size is on.
Definition: itemview.h:128
The Window object represents a toolbox window.
Definition: window.h:69
virtual void removed(unsigned int where, unsigned int how_many)
Inform the view that items have been removed.
Definition: tileview.cc:383
virtual void cleared()
Whole view has been cleared.
Definition: tileview.cc:512
tbx::Size _tile_size
Size of tiles.
Definition: tileview.h:52
tbx::Size check_size(unsigned int from, unsigned int end)
Check if size has been reduced to less than tile_size.
Definition: tileview.cc:167
virtual unsigned int screen_index(const Point &scr_pt) const
Get item index for the screen location (if any)
Definition: tileview.cc:579
Listener for Wimp Open Window Request events.
Definition: openwindowlistener.h:97
Event data for open window request listener.
Definition: openwindowlistener.h:39
virtual void open_window(tbx::OpenWindowEvent &event)
Window has been opened or resized, so re do layout.
Definition: tileview.cc:242
int _cols_per_row
Number of tiles in a row.
Definition: tileview.h:53
tbx::Size max_size(unsigned int from, unsigned int end)
Measure the maximum tile size for a range of items.
Definition: tileview.cc:146