KChart

KChartTextAttributes.h
1/*
2 * SPDX-FileCopyrightText: 2001-2015 Klaralvdalens Datakonsult AB. All rights reserved.
3 *
4 * This file is part of the KD Chart library.
5 *
6 * SPDX-License-Identifier: GPL-2.0-or-later
7 */
8
9#ifndef KCHARTTEXTATTRIBUTES_H
10#define KCHARTTEXTATTRIBUTES_H
11
12#include <QDebug>
13#include <QMetaType>
14#include "KChartGlobal.h"
15#include "KChartMeasure.h"
16
17QT_BEGIN_NAMESPACE
18class QPen;
19class QFont;
20class QTextDocument;
21QT_END_NAMESPACE
22
23namespace KChart {
24
25 /**
26 * \brief A set of text attributes.
27 *
28 * TextAttributes encapsulates settings that have to do with
29 * text. This includes font, fontsize, color, whether the text
30 * is rotated, etc
31 */
32class KCHART_EXPORT TextAttributes
33{
34public:
37 TextAttributes &operator= ( const TextAttributes& );
38 bool operator==( const TextAttributes& ) const;
39 inline bool operator!=( const TextAttributes& other ) const
40 { return !operator==(other); }
41
43
44 /**
45 * Set whether the text is to be rendered at all.
46 * \param visible Whether the text is visible.
47 */
48 void setVisible( bool visible );
49
50 /**
51 * \return Whether the text is visible.
52 */
53 bool isVisible() const;
54
55 /**
56 * Set the font to be used for rendering the text.
57 *
58 * \note All of the font's attributes will be used - except of its size!
59 * To specify the size please use setFontSize (or setMinimalFontSize, resp.)
60 *
61 * \param font The font to use.
62 *
63 * \sa setFontSize, setMinimalFontSize
64 */
65 void setFont( const QFont& font );
66
67 /**
68 * \return The font that is used for rendering text.
69 */
70 QFont font() const;
71
72 /**
73 * Set the size of the font used for rendering text.
74 * \param measure The measure to use.
75 * \see Measure
76 */
77 void setFontSize( const Measure & measure );
78
79 /**
80 * \return The measure used for the font size.
81 */
82 Measure fontSize() const;
83
84 /**
85 * Set the minimal size of the font used for rendering text.
86 * \param measure The measure to use.
87 * \see Measure
88 */
89 void setMinimalFontSize( const Measure & measure );
90
91 /**
92 * \return The measure used for the minimal font size.
93 */
94 Measure minimalFontSize() const;
95
96 /**
97 * \brief Returns the font size that is used at drawing time.
98 *
99 * This method is called at drawing time. It returns the
100 * font size as it is used for rendering text, taking into account
101 * any measures that were set via setFontSize and/or setMinimalFontSize.
102 */
103 qreal calculatedFontSize( const QSizeF &referenceSize,
104 KChartEnums::MeasureOrientation autoReferenceOrientation ) const;
105
106 /**
107 * \brief Returns the font size that is used at drawing time.
108 *
109 * This method is called at drawing time. It returns the
110 * font size as it is used for rendering text, taking into account
111 * any measures that were set via setFontSize and/or setMinimalFontSize.
112 */
113#if defined(Q_COMPILER_MANGLES_RETURN_TYPE)
114 const qreal calculatedFontSize(
115#else
116 qreal calculatedFontSize(
117#endif
118 const QObject* autoReferenceArea,
119 KChartEnums::MeasureOrientation autoReferenceOrientation ) const;
120
121 /**
122 * \brief Returns the font in the size that is used at drawing time.
123 *
124 * This method is called at drawing time. It returns the
125 * font as it is used for rendering text, taking into account
126 * any measures that were set via setFontSize and/or setMinimalFontSize.
127 */
128 const QFont calculatedFont(
129 const QObject* autoReferenceArea,
130 KChartEnums::MeasureOrientation autoReferenceOrientation ) const;
131
132 /**
133 * \return Whether the text has an absolute font size set.
134 */
135 bool hasAbsoluteFontSize() const;
136
137 /**
138 * Set whether the text should be automatically rotated as
139 * needed when space is tight.
140 * \param autoRotate Whether text should be automatically rotated.
141 */
142 void setAutoRotate( bool autoRotate );
143
144 /**
145 * \return Whether text is automatically rotated when space is
146 * tight.
147 */
148 bool autoRotate() const;
149
150 /**
151 * Set whether the text should automatically be shrunk if
152 * space is tight.
153 * \param autoShrink Whether text should be auto-shrunk.
154 */
155 void setAutoShrink( bool autoShrink );
156
157 /**
158 * \return Whether text is automatically shrunk if space is
159 * tight.
160 */
161 bool autoShrink() const;
162
163 /**
164 * Set the rotation angle to use for the text.
165 *
166 * \note For axis titles the rotation angle can be set to one of the
167 * following angles: 0, 90, 180, 270
168 * Any other values specified will be replaced by the next smaller
169 * one of the allowed values, so no matter what you set the rotation
170 * will always be one of these four values.
171 *
172 * \param rotation The rotation angle.
173 */
174 void setRotation( int rotation );
175 void resetRotation();
176 bool hasRotation() const;
177
178 /**
179 * \return The rotation angle used for rendering the text.
180 */
181 int rotation() const;
182
183 /**
184 * Set the pen to use for rendering the text.
185 * \param pen The pen to use.
186 */
187 void setPen( const QPen& pen );
188
189 /**
190 * \return The pen used for rendering the text.
191 */
192 QPen pen() const;
193
194 /**
195 * \return The document used for the drawing the text or NULL if the
196 * default document is used.
197 */
198 QTextDocument* textDocument() const;
199
200 /**
201 * Sets the document to use for the text. The previous document is deleted.
202 */
203 void setTextDocument(QTextDocument* layout);
204
205 // FIXME KChartEnums::TextLayoutPolicy?
206
207private:
208 KCHART_DECLARE_PRIVATE_BASE_VALUE( TextAttributes )
209
210}; // End of class TextAttributes
211
212}
213
214#if !defined(QT_NO_DEBUG_STREAM)
215KCHART_EXPORT QDebug operator<<(QDebug, const KChart::TextAttributes& );
216#endif /* QT_NO_DEBUG_STREAM */
217
218KCHART_DECLARE_SWAP_SPECIALISATION( KChart::TextAttributes )
219
220QT_BEGIN_NAMESPACE
221Q_DECLARE_TYPEINFO( KChart::TextAttributes, Q_MOVABLE_TYPE );
222QT_END_NAMESPACE
223Q_DECLARE_METATYPE( KChart::TextAttributes )
224
225#endif // KCHARTTEXTATTRIBUTES_H
Contains KChart macros.
Declaring the class KChart::Measure.
MeasureOrientation
Measure orientation mode: the way how the absolute value of a KChart::Measure is determined during KC...
Measure is used to specify relative and absolute sizes in KChart, e.g.
A set of text attributes.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:02:46 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.