Qwt User's Guide 6.3.0
Loading...
Searching...
No Matches
qwt_text.h
1/******************************************************************************
2 * Qwt Widget Library
3 * Copyright (C) 1997 Josef Wilgen
4 * Copyright (C) 2002 Uwe Rathmann
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the Qwt License, Version 1.0
8 *****************************************************************************/
9
10#ifndef QWT_TEXT_H
11#define QWT_TEXT_H
12
13#include "qwt_global.h"
14#include <qmetatype.h>
15
16class QFont;
17class QString;
18class QColor;
19class QPen;
20class QBrush;
21class QSizeF;
22class QRectF;
23class QPainter;
24class QwtTextEngine;
25
51class QWT_EXPORT QwtText
52{
53 public:
54
65 {
72 AutoText = 0,
73
76
79
94
100
105 OtherFormat = 100
106 };
107
115 {
117 PaintUsingTextFont = 0x01,
118
120 PaintUsingTextColor = 0x02,
121
123 PaintBackground = 0x04
124 };
125
126 Q_DECLARE_FLAGS( PaintAttributes, PaintAttribute )
127
128
133 {
140 MinimumLayout = 0x01
141 };
142
144
145 QwtText();
146 QwtText( const QString&, TextFormat textFormat = AutoText );
147 QwtText( const QwtText& );
148
149 ~QwtText();
150
151 QwtText& operator=( const QwtText& );
152
153 bool operator==( const QwtText& ) const;
154 bool operator!=( const QwtText& ) const;
155
156 void setText( const QString&,
157 QwtText::TextFormat textFormat = AutoText );
158 QString text() const;
159
160 bool isNull() const;
161 bool isEmpty() const;
162
163 void setFont( const QFont& );
164 QFont font() const;
165
166 QFont usedFont( const QFont& ) const;
167
168 void setRenderFlags( int );
169 int renderFlags() const;
170
171 void setColor( const QColor& );
172 QColor color() const;
173
174 QColor usedColor( const QColor& ) const;
175
176 void setBorderRadius( double );
177 double borderRadius() const;
178
179 void setBorderPen( const QPen& );
180 QPen borderPen() const;
181
182 void setBackgroundBrush( const QBrush& );
183 QBrush backgroundBrush() const;
184
185 void setPaintAttribute( PaintAttribute, bool on = true );
186 bool testPaintAttribute( PaintAttribute ) const;
187
188 void setLayoutAttribute( LayoutAttribute, bool on = true );
189 bool testLayoutAttribute( LayoutAttribute ) const;
190
191 double heightForWidth( double width ) const;
192 double heightForWidth( double width, const QFont& ) const;
193
194 QSizeF textSize() const;
195 QSizeF textSize( const QFont& ) const;
196
197 void draw( QPainter* painter, const QRectF& rect ) const;
198
199 static const QwtTextEngine* textEngine(
200 const QString& text, QwtText::TextFormat = AutoText );
201
202 static const QwtTextEngine* textEngine( QwtText::TextFormat );
203 static void setTextEngine( QwtText::TextFormat, QwtTextEngine* );
204
205 private:
206 class PrivateData;
207 PrivateData* m_data;
208
209 class LayoutCache;
210 LayoutCache* m_layoutCache;
211};
212
213Q_DECLARE_OPERATORS_FOR_FLAGS( QwtText::PaintAttributes )
214Q_DECLARE_OPERATORS_FOR_FLAGS( QwtText::LayoutAttributes )
215
216Q_DECLARE_METATYPE( QwtText )
217
218#endif
Abstract base class for rendering text strings.
A class representing a text.
Definition qwt_text.h:52
LayoutAttribute
Layout Attributes The layout attributes affects some aspects of the layout of the text.
Definition qwt_text.h:133
TextFormat
Text format.
Definition qwt_text.h:65
@ RichText
Use the Scribe framework (Qt Rich Text) to render the text.
Definition qwt_text.h:78
@ PlainText
Draw the text as it is, using a QwtPlainTextEngine.
Definition qwt_text.h:75
@ MathMLText
Definition qwt_text.h:93
@ TeXText
Definition qwt_text.h:99
QFlags< LayoutAttribute > LayoutAttributes
Definition qwt_text.h:143
PaintAttribute
Paint Attributes.
Definition qwt_text.h:115
QFlags< PaintAttribute > PaintAttributes
Definition qwt_text.h:126