Qwt User's Guide: qwt_text_engine.h Source File

Qwt User's Guide 5.2.3

- Main Page
- Related Pages
- Classes

qwt_text_engine.h
1 /* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
2 * Qwt Widget Library
3 * Copyright (C) 1997 Josef Wilgen
4 * Copyright (C) 2003 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 // vim: expandtab
11
12 #ifndef QWT_TEXT_ENGINE_H
13 #define QWT_TEXT_ENGINE_H 1
14
15 #include <qsize.h>
16 #include "qwt_global.h"
17
18 class QFont;
19 class QRect;
20 class QString;
21 class QPainter;
22
38 class QWT_EXPORT QwtTextEngine
39 {
40 public:
41 virtual ~QwtTextEngine();
42
53 virtual int heightForWidth(const QFont &font, int flags,
54 const QString &text, int width) const = 0;
55
65 virtual QSize textSize(const QFont &font, int flags,
66 const QString &text) const = 0;
67
74 virtual bool mightRender(const QString &text) const = 0;
75
91 virtual void textMargins(const QFont &font, const QString &text,
92 int &left, int &right, int &top, int &bottom) const = 0;
93
102 virtual void draw(QPainter *painter, const QRect &rect,
103 int flags, const QString &text) const = 0;
104
105 protected:
106 QwtTextEngine();
107 };
108
109
116 class QWT_EXPORT QwtPlainTextEngine: public QwtTextEngine
117 {
118 public:
119 QwtPlainTextEngine();
120 virtual ~QwtPlainTextEngine();
121
122 virtual int heightForWidth(const QFont &font, int flags,
123 const QString &text, int width) const;
124
125 virtual QSize textSize(const QFont &font, int flags,
126 const QString &text) const;
127
128 virtual void draw(QPainter *painter, const QRect &rect,
129 int flags, const QString &text) const;
130
131 virtual bool mightRender(const QString &) const;
132
133 virtual void textMargins(const QFont &, const QString &,
134 int &left, int &right, int &top, int &bottom) const;
135
136 private:
137 class PrivateData;
138 PrivateData *d_data;
139 };
140
141
142 #ifndef QT_NO_RICHTEXT
143
150 class QWT_EXPORT QwtRichTextEngine: public QwtTextEngine
151 {
152 public:
153 QwtRichTextEngine();
154
155 virtual int heightForWidth(const QFont &font, int flags,
156 const QString &text, int width) const;
157
158 virtual QSize textSize(const QFont &font, int flags,
159 const QString &text) const;
160
161 virtual void draw(QPainter *painter, const QRect &rect,
162 int flags, const QString &text) const;
163
164 virtual bool mightRender(const QString &) const;
165
166 virtual void textMargins(const QFont &, const QString &,
167 int &left, int &right, int &top, int &bottom) const;
168 private:
169 QString taggedText(const QString &, int flags) const;
170 };
171
172 #endif // !QT_NO_RICHTEXT
173
174 #endif