tbx  0.7.6
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_ */
tbx
A library for creating RISC OS toolbox applications.
Definition: abouttobeshownlistener.cc:35
tbx::view::TileView::_cols_per_row
int _cols_per_row
Number of tiles in a row.
Definition: tileview.h:53
tbx::view::TileView::recalc_layout
bool recalc_layout(const BBox &visible_area)
Recalculate the cell layout and update/refresh the window.
Definition: tileview.cc:271
tbx::view::TileView
Class to show items tiled in a window.
Definition: tileview.h:49
tbx::view::TileView::_item_renderer
ItemRenderer * _item_renderer
Renderer for items in the tile view.
Definition: tileview.h:51
tbx::view::TileView::item_renderer
void item_renderer(ItemRenderer *ir)
Change the item renderer.
Definition: tileview.cc:62
tbx::Window
The Window object represents a toolbox window.
Definition: window.h:70
tbx::view::TileView::insert_index
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
tbx::view::TileView::redraw
virtual void redraw(const tbx::RedrawEvent &event)
Redraw the window.
Definition: tileview.cc:184
tbx::view::TileView::update_window_extent
virtual void update_window_extent()
Update the Window extent after a change in size.
Definition: tileview.cc:256
tbx::view::TileView::TileView
TileView(tbx::Window window, ItemRenderer *item_renderer=0)
Construct a tile view for specific Window using the given item renderer.
Definition: tileview.cc:42
tbx::view::TileView::tile_size
const tbx::Size & tile_size() const
Return the size of a tile.
Definition: tileview.h:64
tbx::view::TileView::size_to_tiles
void size_to_tiles()
Size to match content.
Definition: tileview.cc:127
tbx::view::TileView::get_bounds
virtual void get_bounds(BBox &bounds, unsigned int index) const
Get the cell bounds for the specified index.
Definition: tileview.cc:649
tbx::view::TileView::hit_test
virtual unsigned int hit_test(const Point &scr_pt) const
Hit test the given screen point.
Definition: tileview.cc:612
tbx::view::ItemView::auto_size
bool auto_size() const
Returns true if auto size is on.
Definition: itemview.h:128
tbx::OpenWindowEvent
Event data for open window request listener.
Definition: openwindowlistener.h:40
tbx::view::TileView::removing
virtual void removing(unsigned int where, unsigned int how_many)
Inform the view that items are about to be removed.
Definition: tileview.cc:359
tbx::view::ItemView::window
tbx::Window & window()
Return the Window that this item view is attached to.
Definition: itemview.h:107
tbx::view::TileView::process_drag_selection
virtual void process_drag_selection(const BBox &drag_box, bool adjust)
Override this method to process selection by dragging.
Definition: tileview.cc:690
tbx::BBox
Class to represent a two dimensional bounding box.
Definition: bbox.h:38
tbx::OpenWindowListener
Listener for Wimp Open Window Request events.
Definition: openwindowlistener.h:98
tbx::view::TileView::inserted
virtual void inserted(unsigned int where, unsigned int how_many)
Inform the view that items have been inserted.
Definition: tileview.cc:311
tbx::Size
Class to represent a two-dimensional size.
Definition: size.h:35
tbx::view::ItemView
Base class for views that show an indexed list of items.
Definition: itemview.h:68
tbx::view::TileView::changed
virtual void changed(unsigned int where, unsigned int how_many)
Inform the view that items have been changed.
Definition: tileview.cc:451
tbx::view::TileView::changing
virtual void changing(unsigned int where, unsigned int how_many)
Inform the view that items are about to be changed.
Definition: tileview.cc:427
tbx::view::TileView::refresh
virtual void refresh()
Refresh the whole report view.
Definition: tileview.cc:300
tbx::Point
Class to represent a position in two dimensional space.
Definition: point.h:37
tbx::view::TileView::removed
virtual void removed(unsigned int where, unsigned int how_many)
Inform the view that items have been removed.
Definition: tileview.cc:383
tbx::view::TileView::screen_index
virtual unsigned int screen_index(const Point &scr_pt) const
Get item index for the screen location (if any)
Definition: tileview.cc:579
tbx::view::ItemRenderer
Base class to render an indexed item.
Definition: itemrenderer.h:54
tbx::view::TileView::open_window
virtual void open_window(tbx::OpenWindowEvent &event)
Window has been opened or resized, so re do layout.
Definition: tileview.cc:242
tbx::view::TileView::check_size
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
tbx::RedrawEvent
Event passed to redraw listener to give details on the area that needs a redraw.
Definition: redrawlistener.h:44
tbx::view::TileView::_tile_size
tbx::Size _tile_size
Size of tiles.
Definition: tileview.h:52
tbx::view::TileView::cleared
virtual void cleared()
Whole view has been cleared.
Definition: tileview.cc:512
tbx::view::TileView::max_size
tbx::Size max_size(unsigned int from, unsigned int end)
Measure the maximum tile size for a range of items.
Definition: tileview.cc:146