Qwt User's Guide  6.2.0
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 
16 class QFont;
17 class QString;
18 class QColor;
19 class QPen;
20 class QBrush;
21 class QSizeF;
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 
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 
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 
213 Q_DECLARE_OPERATORS_FOR_FLAGS( QwtText::PaintAttributes )
214 Q_DECLARE_OPERATORS_FOR_FLAGS( QwtText::LayoutAttributes )
215 
216 Q_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