Qwt User's Guide  6.1.6
qwt_text.h
1 /* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
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 <qstring.h>
15 #include <qsize.h>
16 #include <qfont.h>
17 #include <qmetatype.h>
18 
19 class QColor;
20 class QPen;
21 class QBrush;
22 class QRectF;
23 class QPainter;
24 class QwtTextEngine;
25 
51 class QWT_EXPORT QwtText
52 {
53 public:
54 
65  {
72  AutoText = 0,
73 
76 
79 
92 
98 
103  OtherFormat = 100
104  };
105 
113  {
115  PaintUsingTextFont = 0x01,
116 
118  PaintUsingTextColor = 0x02,
119 
121  PaintBackground = 0x04
122  };
123 
125  typedef QFlags<PaintAttribute> PaintAttributes;
126 
132  {
139  MinimumLayout = 0x01
140  };
141 
143  typedef QFlags<LayoutAttribute> LayoutAttributes;
144 
145  QwtText( const QString & = QString(),
146  TextFormat textFormat = AutoText );
147  QwtText( const QwtText & );
148  ~QwtText();
149 
150  QwtText &operator=( const QwtText & );
151 
152  bool operator==( const QwtText & ) const;
153  bool operator!=( const QwtText & ) const;
154 
155  void setText( const QString &,
156  QwtText::TextFormat textFormat = AutoText );
157  QString text() const;
158 
159  bool isNull() const;
160  bool isEmpty() const;
161 
162  void setFont( const QFont & );
163  QFont font() const;
164 
165  QFont usedFont( const QFont & ) const;
166 
167  void setRenderFlags( int );
168  int renderFlags() const;
169 
170  void setColor( const QColor & );
171  QColor color() const;
172 
173  QColor usedColor( const QColor & ) const;
174 
175  void setBorderRadius( double );
176  double borderRadius() const;
177 
178  void setBorderPen( const QPen & );
179  QPen borderPen() const;
180 
181  void setBackgroundBrush( const QBrush & );
182  QBrush backgroundBrush() const;
183 
184  void setPaintAttribute( PaintAttribute, bool on = true );
185  bool testPaintAttribute( PaintAttribute ) const;
186 
187  void setLayoutAttribute( LayoutAttribute, bool on = true );
188  bool testLayoutAttribute( LayoutAttribute ) const;
189 
190  double heightForWidth( double width, const QFont & = QFont() ) const;
191  QSizeF textSize( const QFont & = QFont() ) const;
192 
193  void draw( QPainter *painter, const QRectF &rect ) const;
194 
195  static const QwtTextEngine *textEngine(
196  const QString &text, QwtText::TextFormat = AutoText );
197 
198  static const QwtTextEngine *textEngine( QwtText::TextFormat );
199  static void setTextEngine( QwtText::TextFormat, QwtTextEngine * );
200 
201 private:
202  class PrivateData;
203  PrivateData *d_data;
204 
205  class LayoutCache;
206  LayoutCache *d_layoutCache;
207 };
208 
210 inline bool QwtText::isNull() const
211 {
212  return text().isNull();
213 }
214 
216 inline bool QwtText::isEmpty() const
217 {
218  return text().isEmpty();
219 }
220 
221 Q_DECLARE_OPERATORS_FOR_FLAGS( QwtText::PaintAttributes )
222 Q_DECLARE_OPERATORS_FOR_FLAGS( QwtText::LayoutAttributes )
223 
224 Q_DECLARE_METATYPE( QwtText )
225 
226 #endif
QwtText::TeXText
@ TeXText
Definition: qwt_text.h:97
QwtText::LayoutAttribute
LayoutAttribute
Layout Attributes The layout attributes affects some aspects of the layout of the text.
Definition: qwt_text.h:132
QwtTextEngine
Abstract base class for rendering text strings.
Definition: qwt_text_engine.h:36
QwtText::PaintAttribute
PaintAttribute
Paint Attributes.
Definition: qwt_text.h:113
QwtText
A class representing a text.
Definition: qwt_text.h:52
QwtText::RichText
@ RichText
Use the Scribe framework (Qt Rich Text) to render the text.
Definition: qwt_text.h:78
QwtText::isEmpty
bool isEmpty() const
Definition: qwt_text.h:216
QwtText::TextFormat
TextFormat
Text format.
Definition: qwt_text.h:65
QwtText::isNull
bool isNull() const
Definition: qwt_text.h:210
QwtText::MathMLText
@ MathMLText
Definition: qwt_text.h:91
QwtText::text
QString text() const
Definition: qwt_text.cpp:253
QwtText::PlainText
@ PlainText
Draw the text as it is, using a QwtPlainTextEngine.
Definition: qwt_text.h:75
QwtText::PaintAttributes
QFlags< PaintAttribute > PaintAttributes
Paint attributes.
Definition: qwt_text.h:125
QwtText::LayoutAttributes
QFlags< LayoutAttribute > LayoutAttributes
Layout attributes.
Definition: qwt_text.h:143