Qwt User's Guide: qwt_text.h Source File

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
51 class QWT_EXPORT QwtText
52{
53 public:
54
64 enum TextFormat
65 {
72 AutoText = 0,
73
75 PlainText,
76
78 RichText,
79
93 MathMLText,
94
99 TeXText,
100
105 OtherFormat = 100
106 };
107
114 enum PaintAttribute
115 {
117 PaintUsingTextFont = 0x01,
118
120 PaintUsingTextColor = 0x02,
121
123 PaintBackground = 0x04
124 };
125
126 Q_DECLARE_FLAGS( PaintAttributes, PaintAttribute )
127
128
132 enum LayoutAttribute
133 {
140 MinimumLayout = 0x01
141 };
142
143 Q_DECLARE_FLAGS( LayoutAttributes, LayoutAttribute )
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
QwtTextEngine
Abstract base class for rendering text strings.
Definition qwt_text_engine.h:31
QwtText
A class representing a text.
Definition qwt_text.h:52
QwtText::LayoutAttribute
LayoutAttribute
Layout Attributes The layout attributes affects some aspects of the layout of the text.
Definition qwt_text.h:133
QwtText::TextFormat
TextFormat
Text format.
Definition qwt_text.h:65
QwtText::RichText
@ RichText
Use the Scribe framework (Qt Rich Text) to render the text.
Definition qwt_text.h:78
QwtText::PlainText
@ PlainText
Draw the text as it is, using a QwtPlainTextEngine.
Definition qwt_text.h:75
QwtText::MathMLText
@ MathMLText
Definition qwt_text.h:93
QwtText::TeXText
@ TeXText
Definition qwt_text.h:99
QwtText::LayoutAttributes
QFlags< LayoutAttribute > LayoutAttributes
Definition qwt_text.h:143
QwtText::PaintAttribute
PaintAttribute
Paint Attributes.
Definition qwt_text.h:115
QwtText::PaintAttributes
QFlags< PaintAttribute > PaintAttributes
Definition qwt_text.h:126