KChart

KChartTextLabelCache.h
1 /*
2  * Copyright (C) 2001-2015 Klaralvdalens Datakonsult AB. All rights reserved.
3  *
4  * This file is part of the KD Chart library.
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License as
8  * published by the Free Software Foundation; either version 2 of
9  * the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program. If not, see <https://www.gnu.org/licenses/>.
18  */
19 
20 #ifndef KCHARTTEXTLABELCACHE_H
21 #define KCHARTTEXTLABELCACHE_H
22 
23 #include <QPixmap>
24 #include <QFont>
25 #include <QBrush>
26 #include <QPen>
27 
28 #include "KChartEnums.h"
29 
34 public:
36  virtual ~PrerenderedElement() {}
37 
41  virtual const QPixmap& pixmap() const = 0;
42 
46 
48  void setPosition( const QPointF& position );
50  const QPointF& position() const;
51 
59 
60 protected:
67  virtual void invalidate() const = 0;
68 
69 private:
70  QPointF m_position;
71  KChartEnums::PositionValue m_referencePoint;
72 };
73 
90 // FIXME this is merely a prototype
91 // FIXME caching could be done by a second layer that can be used to,
92 // e.g., query for a prerendered element by id or name, or by changing
93 // the pixmap() method to do lazy evaluation.
95 {
96 public:
99 
100 
104  void setFont( const QFont& font );
105 
109  const QFont& font() const;
110 
111 
115  void setText( const QString& text );
116 
120  const QString& text() const;
121 
122 
126  void setBrush( const QBrush& brush );
127 
131  const QBrush& brush() const;
132 
133  void setPen( const QPen& );
134  const QPen& pen() const;
135 
136 
140  void setAngle( qreal angle );
141 
145  qreal angle() const;
146 
147  // reimpl PrerenderedElement:
148  const QPixmap& pixmap() const override;
150  // overload: return location of referencePoint():
152 
153 protected:
154 
158  void invalidate() const override;
159 
160 private:
164  void paint() const;
165 
166  // store the settings (these are used for the painting):
167  mutable bool m_dirty;
168  QFont m_font;
169  QString m_text;
170  QBrush m_brush;
171  QPen m_pen;
172  qreal m_angle;
173 
174  // these are valid once the label has been rendered:
175  mutable QPixmap m_pixmap;
176  mutable QPointF m_referenceBottomLeft;
177  mutable QPointF m_textBaseLineVector;
178  mutable QPointF m_textAscendVector;
179 };
180 
181 #endif
PositionValue
Numerical values of the static KChart::Position instances, for using a Position::value() with a switc...
Definition: KChartEnums.h:189
void setPosition(const QPointF &position)
Set the position of the element.
virtual QPointF referencePointLocation(KChartEnums::PositionValue) const =0
Return the location of the reference point relatively to the pixmap&#39;s origin.
void setReferencePoint(KChartEnums::PositionValue)
Set the reference point of the element.
base class for prerendered elements like labels, pixmaps, markers, etc.
virtual const QPixmap & pixmap() const =0
Returns the rendered element.
PrerenderedLabel is an internal KChart class that simplifies creation and caching of cached text labe...
const QPointF & position() const
Get the position of the element.
Definition of global enums.
virtual void invalidate() const =0
invalidate() needs to be called if any of the properties that determine the visual appearance of the ...
KChartEnums::PositionValue referencePoint() const
Get the reference point of the element.
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Thu Sep 24 2020 22:36:58 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.