tbx  0.7.3
fontitemrenderer.h
1 /*
2  * tbx RISC OS toolbox library
3  *
4  * Copyright (C) 2015 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 * FontItemRenderer.h
26  *
27  * Created on: 17 Jun 2015
28  * Author: alanb
29  */
30 
31 #ifndef FONTITEMRENDERER_H_
32 #define FONTITEMRENDERER_H_
33 
34 #include "../font.h"
35 #include "itemrenderer.h"
36 
37 namespace tbx {
38 namespace view {
39 
43 class FontItemRenderer : public TypedItemRenderer<std::string>
44 {
45  tbx::Font _font;
46  unsigned int _baseline;
47  unsigned int _height;
48 
49 public:
56  : tbx::view::TypedItemRenderer<std::string>(vv),
57  _baseline(0), _height(40)
58  {
59  }
60 
68  : TypedItemRenderer<std::string>(vv),
69  _baseline(0), _height(40)
70  {
71  this->font(font);
72  }
73 
74 
75  virtual ~FontItemRenderer() {};
76 
80  tbx::Font font() {return _font;}
81 
89  void font(tbx::Font font);
90 
95  unsigned int height() const {return _height;}
101  void height(unsigned int height) {_height = height;}
107  unsigned int baseline() const {return _baseline;}
114  void baseline(unsigned int baseline) {_baseline = baseline;}
115 
121  virtual void render(const ItemRenderer::Info &info);
122 
128  virtual unsigned int width(unsigned int index) const;
129 
135  virtual unsigned int height(unsigned int index) const {return _height;}
136 
142  virtual tbx::Size size(unsigned int index) const;
143 };
144 
145 } /* namespace view */
146 } /* namespace tbx */
147 
148 #endif /* FONTITEMRENDERER_H_ */
Class to represent a two-dimensional size.
Definition: size.h:34
virtual tbx::Size size(unsigned int index) const
Called to get the size of the cell.
Definition: fontitemrenderer.cc:76
unsigned int baseline() const
Get the font base line.
Definition: fontitemrenderer.h:107
tbx::Font font()
Get the font used to render an item.
Definition: fontitemrenderer.h:80
virtual unsigned int height(unsigned int index) const
Get font row height.
Definition: fontitemrenderer.h:135
Base class for item renderer that work on a specific type and use an ItemViewValue object to return t...
Definition: itemrenderer.h:159
FontItemRenderer(tbx::view::ItemViewValue< std::string > *vv)
Construct with object to give value to render.
Definition: fontitemrenderer.h:55
unsigned int height() const
Get the height of the renderer.
Definition: fontitemrenderer.h:95
void baseline(unsigned int baseline)
Set the font base line.
Definition: fontitemrenderer.h:114
Information on what needs to be redrawn.
Definition: itemrenderer.h:63
void height(unsigned int height)
Set the height of the renderer.
Definition: fontitemrenderer.h:101
FontItemRenderer(tbx::Font font, ItemViewValue< std::string > *vv)
Construct renderer with give font and object to give value to render.
Definition: fontitemrenderer.h:67
Class to handle painting and measuring text using an outline font.
Definition: font.h:60
ItemRenderer to render text with a given font in a fixed height.
Definition: fontitemrenderer.h:43
virtual void render(const ItemRenderer::Info &info)
Render text in black using font set.
Definition: fontitemrenderer.cc:54
virtual unsigned int width(unsigned int index) const
Used to measure the width of a column.
Definition: fontitemrenderer.cc:70