tbx  0.7.3
iconitemrenderer.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  * iconitemrenderer.h
27  *
28  * Created on: 22 Apr 2010
29  * Author: alanb
30  */
31 
32 #ifndef TBX_ICONITEMRENDERER_H_
33 #define TBX_ICONITEMRENDERER_H_
34 
35 #include "itemrenderer.h"
36 
37 namespace tbx {
38 
39 namespace view {
40 
52 {
53  ItemViewValue<std::string> *_sprite_name_provider;
54  bool _use_client_area;
55 
56 protected:
57  IconItemRenderer(bool use_client = true);
58 
59 public:
60  IconItemRenderer(ItemViewValue<std::string> *np, bool use_client = true);
62  virtual ~IconItemRenderer();
63 
64  virtual std::string text(unsigned int index) const;
65  virtual std::string sprite_name(unsigned int index) const;
66 
75  virtual bool use_client_sprite_area(unsigned int index) const {return _use_client_area;}
76 
87  virtual void render(const ItemRenderer::Info &info);
88 
89  static tbx::Size standard_size(unsigned int width = 160, unsigned int sprite_height = 68);
90 
91  virtual unsigned int width(unsigned int index) const;
92  virtual unsigned int height(unsigned int index) const;
93  virtual Size size(unsigned int index) const;
94  virtual bool hit_test(unsigned int index, const Size &size, const Point &pos) const;
95  virtual bool intersects(unsigned int index, const Size &size, const BBox &box) const;
96 
97  void get_sprite_box(unsigned int index, const Size &size, BBox &sbox) const;
98  void get_text_box(unsigned int index, const Size &size, BBox &sbox) const;
99 };
100 
101 }
102 
103 }
104 
105 #endif /* TBX_ICONITEMRENDERER_H_ */
virtual Size size(unsigned int index) const
Called to get the size of the item.
Definition: iconitemrenderer.cc:233
Class to represent a two-dimensional size.
Definition: size.h:34
virtual std::string sprite_name(unsigned int index) const
Return the sprite name for the icon.
Definition: iconitemrenderer.cc:116
virtual bool intersects(unsigned int index, const Size &size, const BBox &box) const
Check if the given rectangle intersects the content of the cell rather than a margin or background...
Definition: iconitemrenderer.cc:295
Class to represent a two dimensional bounding box.
Definition: bbox.h:37
void get_text_box(unsigned int index, const Size &size, BBox &sbox) const
Get text box relative to bottom left corner.
Definition: iconitemrenderer.cc:336
void get_sprite_box(unsigned int index, const Size &size, BBox &sbox) const
Gets sprite box relative to bottom left corner.
Definition: iconitemrenderer.cc:313
IconItemRenderer(bool use_client=true)
Protected constructor for derived renderer which must provide the text() and sprite_name() overrides...
Definition: iconitemrenderer.cc:57
virtual bool use_client_sprite_area(unsigned int index) const
Returns true to use the client sprite area to retrieve the sprite to display, or false for the wimp s...
Definition: iconitemrenderer.h:75
Class to render an icon with text similar to the normal view in the filer.
Definition: iconitemrenderer.h:51
Base class for item renderer that work on a specific type and use an ItemViewValue object to return t...
Definition: itemrenderer.h:159
virtual void render(const ItemRenderer::Info &info)
Called to render each item that needs drawing.
Definition: iconitemrenderer.cc:149
Class to represent a position in two dimensional space.
Definition: point.h:36
static tbx::Size standard_size(unsigned int width=160, unsigned int sprite_height=68)
Return standard size for an icon with the given text width and sprite height.
Definition: iconitemrenderer.cc:128
virtual bool hit_test(unsigned int index, const Size &size, const Point &pos) const
Check if the point given hits content of the cell rather then a margin or background.
Definition: iconitemrenderer.cc:267
Information on what needs to be redrawn.
Definition: itemrenderer.h:63
virtual unsigned int width(unsigned int index) const
Return the width of the given item.
Definition: iconitemrenderer.cc:215
virtual unsigned int height(unsigned int index) const
Return height of item.
Definition: iconitemrenderer.cc:223
virtual std::string text(unsigned int index) const
Return the text for the icon.
Definition: iconitemrenderer.cc:104