Chemical Data Processing Library C++ API - Version 1.1.1
QtFontMetrics.hpp
Go to the documentation of this file.
1 /*
2  * QtFontMetrics.hpp
3  *
4  * This file is part of the Chemical Data Processing Toolkit
5  *
6  * Copyright (C) 2003 Thomas Seidel <thomas.seidel@univie.ac.at>
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public License
19  * along with this library; see the file COPYING. If not, write to
20  * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21  * Boston, MA 02111-1307, USA.
22  */
23 
29 #ifndef CDPL_VIS_QTFONTMETRICS_HPP
30 #define CDPL_VIS_QTFONTMETRICS_HPP
31 
32 #include <memory>
33 
34 #include "CDPL/Vis/APIPrefix.hpp"
35 #include "CDPL/Vis/FontMetrics.hpp"
36 
37 
38 class QFontMetricsF;
39 class QPaintDevice;
40 
41 
42 namespace CDPL
43 {
44 
45  namespace Vis
46  {
47 
56  {
57 
58  public:
63  QtFontMetrics(QPaintDevice* paint_dev = 0);
64 
69 
70  void setFont(const Font& font);
71 
72  double getAscent() const;
73  double getDescent() const;
74  double getHeight() const;
75  double getLeading() const;
76 
77  double getWidth(const std::string& str) const;
78  double getWidth(char ch) const;
79 
80  void getBounds(const std::string& str, Rectangle2D& bounds) const;
81  void getBounds(char ch, Rectangle2D& bounds) const;
82 
83  private:
85 
86  QtFontMetrics& operator=(const QtFontMetrics&);
87 
88  QPaintDevice* qPaintDevice;
89  std::unique_ptr<QFontMetricsF> qFontMetrics;
90  };
91  } // namespace Vis
92 } // namespace CDPL
93 
94 #endif // CDPL_VIS_QTFONTMETRICS_HPP
CDPL::Vis::QtFontMetrics::setFont
void setFont(const Font &font)
Specifies the font for which to obtain the metrics.
CDPL::Vis::QtFontMetrics
Implements the FontMetrics interface for the Qt rendering backend.
Definition: QtFontMetrics.hpp:56
CDPL::Vis::QtFontMetrics::getWidth
double getWidth(char ch) const
Returns the advance width for the character ch.
CDPL::Vis::QtFontMetrics::getWidth
double getWidth(const std::string &str) const
Returns the total advance width for the characters in the string str.
CDPL::Vis::QtFontMetrics::getBounds
void getBounds(char ch, Rectangle2D &bounds) const
Returns the bounding rectangle of the character ch relative to the left-most point on the baseline.
CDPL::Vis::Font
Specifies a font for drawing text.
Definition: Font.hpp:54
FontMetrics.hpp
Definition of the class CDPL::Vis::FontMetrics.
CDPL::Vis::QtFontMetrics::getBounds
void getBounds(const std::string &str, Rectangle2D &bounds) const
Returns the total bounding rectangle for the characters in the string str.
CDPL::Vis::QtFontMetrics::QtFontMetrics
QtFontMetrics(QPaintDevice *paint_dev=0)
Constructs a font metrics object for Qt's default font and the given paint device.
CDPL::Vis::QtFontMetrics::getLeading
double getLeading() const
Returns the leading of the font.
CDPL::Vis::QtFontMetrics::getAscent
double getAscent() const
Returns the ascent of the font.
CDPL::Vis::QtFontMetrics::getHeight
double getHeight() const
Returns the height of the font.
CDPL::Vis::QtFontMetrics::~QtFontMetrics
~QtFontMetrics()
Destructor.
CDPL
The namespace of the Chemical Data Processing Library.
CDPL::Vis::Rectangle2D
Specifies an axis aligned rectangular area in 2D space.
Definition: Rectangle2D.hpp:51
CDPL::Vis::QtFontMetrics::getDescent
double getDescent() const
Returns the descent of the font.
CDPL::Vis::FontMetrics
An interface class with methods that provide information about the metrics of a font.
Definition: FontMetrics.hpp:71
CDPL_VIS_QT_API
#define CDPL_VIS_QT_API
Tells the compiler/linker which classes, functions and variables are part of the library API.
APIPrefix.hpp
Definition of the preprocessor macro CDPL_VIS_API.