File: qwt__text_8cpp-source.html

package info (click to toggle)
libqwt 4.2.0-4.1
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 9,832 kB
  • ctags: 5,512
  • sloc: cpp: 22,973; ansic: 244; makefile: 66
file content (351 lines) | stat: -rw-r--r-- 25,343 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>Qwt User&apos;s Guide: qwt_text.cpp Source File</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.3.8 -->
<div class="qindex"><a class="qindex" href="index.html">Main&nbsp;Page</a> | <a class="qindex" href="hierarchy.html">Class&nbsp;Hierarchy</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Class&nbsp;List</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Class&nbsp;Members</a> | <a class="qindex" href="globals.html">File&nbsp;Members</a> | <a class="qindex" href="pages.html">Related&nbsp;Pages</a></div>
<h1>qwt_text.cpp</h1><pre class="fragment"><div>00001 <span class="comment">/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************</span>
00002 <span class="comment"> * Qwt Widget Library</span>
00003 <span class="comment"> * Copyright (C) 1997   Josef Wilgen</span>
00004 <span class="comment"> * Copyright (C) 2003   Uwe Rathmann</span>
00005 <span class="comment"> *</span>
00006 <span class="comment"> * This library is free software; you can redistribute it and/or</span>
00007 <span class="comment"> * modify it under the terms of the Qwt License, Version 1.0</span>
00008 <span class="comment"> *****************************************************************************/</span>
00009 
00010 <span class="comment">// vim: expandtab</span>
00011 
00012 <span class="preprocessor">#include &lt;qpainter.h&gt;</span>
00013 <span class="preprocessor">#include &lt;qpalette.h&gt;</span>
00014 <span class="preprocessor">#include &lt;qstylesheet.h&gt;</span>
00015 <span class="preprocessor">#include "qwt_painter.h"</span>
00016 <span class="preprocessor">#include "qwt_text.h"</span>
00017 
00018 Qt::TextFormat QwtText::d_defaultFormat = Qt::AutoText;
00019 
<a name="l00031"></a><a class="code" href="class_qwt_text.html#b0">00031</a> <a class="code" href="class_qwt_text.html#b0">QwtText::QwtText</a>(<span class="keyword">const</span> QString &amp;text, <span class="keyword">const</span> QFont &amp;font, 
00032         <span class="keywordtype">int</span> align, <span class="keyword">const</span> QColor &amp;color, <span class="keyword">const</span> QPen &amp;pen, <span class="keyword">const</span> QBrush &amp;brush):
00033     d_align(align),
00034     d_text(text),
00035     d_font(font),
00036     d_color(color),
00037     d_fm(font),
00038     d_rectPen(pen),
00039     d_rectBrush(brush)
00040 {
00041 }
00042 
<a name="l00044"></a><a class="code" href="class_qwt_text.html#a0">00044</a> <a class="code" href="class_qwt_text.html#a0">QwtText::~QwtText</a>() 
00045 {
00046 }
00047 
<a name="l00061"></a><a class="code" href="class_qwt_text.html#e1">00061</a> <a class="code" href="class_qwt_text.html">QwtText</a> *<a class="code" href="class_qwt_text.html#e0">QwtText::makeText</a>(<span class="keyword">const</span> QString &amp;text, 
00062     <span class="keywordtype">int</span> align, <span class="keyword">const</span> QFont &amp;font, <span class="keyword">const</span> QColor &amp;color,
00063     <span class="keyword">const</span> QPen &amp;pen, <span class="keyword">const</span> QBrush &amp;brush)
00064 {
00065     <span class="keywordflow">return</span> <a class="code" href="class_qwt_text.html#e0">makeText</a>(text, d_defaultFormat, align, font, color, pen, brush);
00066 }
00067 
<a name="l00081"></a><a class="code" href="class_qwt_text.html#e0">00081</a> <a class="code" href="class_qwt_text.html">QwtText</a> *<a class="code" href="class_qwt_text.html#e0">QwtText::makeText</a>(<span class="keyword">const</span> QString &amp;text, Qt::TextFormat format,
00082     <span class="keywordtype">int</span> align, <span class="keyword">const</span> QFont &amp;font, <span class="keyword">const</span> QColor &amp;color,
00083     <span class="keyword">const</span> QPen &amp;pen, <span class="keyword">const</span> QBrush &amp;brush)
00084 {
00085 <span class="preprocessor">#ifndef QT_NO_RICHTEXT</span>
00086 <span class="preprocessor"></span>    <span class="keywordflow">if</span> (format == Qt::RichText || ((format == Qt::AutoText)
00087             &amp;&amp; QStyleSheet::mightBeRichText(text)))
00088     {
00089         <span class="keywordflow">return</span> <span class="keyword">new</span> <a class="code" href="class_qwt_rich_text.html">QwtRichText</a>(text, font, align, color, pen, brush);
00090     }
00091     <span class="keywordflow">else</span>
00092 <span class="preprocessor">#endif</span>
00093 <span class="preprocessor"></span>    {
00094         <span class="keywordflow">return</span> <span class="keyword">new</span> <a class="code" href="class_qwt_plain_text.html">QwtPlainText</a>(text, font, align, color, pen, brush);
00095     }
00096 }
00097 
<a name="l00099"></a><a class="code" href="class_qwt_text.html#e2">00099</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_text.html#e2">QwtText::setDefaultFormat</a>(Qt::TextFormat format)
00100 {
00101     d_defaultFormat = format;
00102 }
00103 
<a name="l00105"></a><a class="code" href="class_qwt_text.html#e3">00105</a> Qt::TextFormat <a class="code" href="class_qwt_text.html#e3">QwtText::defaultFormat</a>()
00106 {
00107     <span class="keywordflow">return</span> d_defaultFormat;
00108 }
00109 
<a name="l00111"></a><a class="code" href="class_qwt_text.html#a1">00111</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_text.html#a1">QwtText::setText</a>(<span class="keyword">const</span> QString &amp;text) 
00112 { 
00113     d_text = text; 
00114 }
00115 
<a name="l00117"></a><a class="code" href="class_qwt_text.html#a2">00117</a> QString <a class="code" href="class_qwt_text.html#a2">QwtText::text</a>()<span class="keyword"> const </span>
00118 <span class="keyword"></span>{ 
00119     <span class="keywordflow">return</span> d_text; 
00120 }
00121 
<a name="l00123"></a><a class="code" href="class_qwt_text.html#a5">00123</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_text.html#a5">QwtText::setFont</a>(<span class="keyword">const</span> QFont &amp;font) 
00124 {
00125     d_font = font; 
00126     d_fm = QFontMetrics(font);
00127 }
00128 
<a name="l00130"></a><a class="code" href="class_qwt_text.html#a6">00130</a> QFont <a class="code" href="class_qwt_text.html#a6">QwtText::font</a>()<span class="keyword"> const </span>
00131 <span class="keyword"></span>{ 
00132     <span class="keywordflow">return</span> d_font; 
00133 }
00134 
<a name="l00136"></a><a class="code" href="class_qwt_text.html#a7">00136</a> QFontMetrics <a class="code" href="class_qwt_text.html#a7">QwtText::fontMetrics</a>()<span class="keyword"> const </span>
00137 <span class="keyword"></span>{ 
00138     <span class="keywordflow">return</span> d_fm; 
00139 }
00140 
<a name="l00145"></a><a class="code" href="class_qwt_text.html#a8">00145</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_text.html#a8">QwtText::setAlignment</a>(<span class="keywordtype">int</span> align) 
00146 { 
00147     d_align = align; 
00148 }
00149 
<a name="l00151"></a><a class="code" href="class_qwt_text.html#a9">00151</a> <span class="keywordtype">int</span> <a class="code" href="class_qwt_text.html#a9">QwtText::alignment</a>()<span class="keyword"> const </span>
00152 <span class="keyword"></span>{ 
00153     <span class="keywordflow">return</span> d_align; 
00154 }
00155 
<a name="l00157"></a><a class="code" href="class_qwt_text.html#a10">00157</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_text.html#a10">QwtText::setColor</a>(<span class="keyword">const</span> QColor &amp;color) 
00158 { 
00159     d_color = color; 
00160 }
00161 
<a name="l00163"></a><a class="code" href="class_qwt_text.html#a11">00163</a> QColor <a class="code" href="class_qwt_text.html#a11">QwtText::color</a>()<span class="keyword"> const </span>
00164 <span class="keyword"></span>{ 
00165     <span class="keywordflow">return</span> d_color; 
00166 }
00167 
<a name="l00169"></a><a class="code" href="class_qwt_text.html#a12">00169</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_text.html#a12">QwtText::setRectPen</a>(<span class="keyword">const</span> QPen &amp;pen) 
00170 { 
00171     d_rectPen = pen; 
00172 }
00173 
<a name="l00175"></a><a class="code" href="class_qwt_text.html#a13">00175</a> QPen <a class="code" href="class_qwt_text.html#a13">QwtText::rectPen</a>()<span class="keyword"> const </span>
00176 <span class="keyword"></span>{ 
00177     <span class="keywordflow">return</span> d_rectPen; 
00178 }
00179 
<a name="l00181"></a><a class="code" href="class_qwt_text.html#a14">00181</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_text.html#a14">QwtText::setRectBrush</a>(<span class="keyword">const</span> QBrush &amp;brush) 
00182 { 
00183     d_rectBrush = brush; 
00184 }
00185 
<a name="l00187"></a><a class="code" href="class_qwt_text.html#a15">00187</a> QBrush <a class="code" href="class_qwt_text.html#a15">QwtText::rectBrush</a>()<span class="keyword"> const </span>
00188 <span class="keyword"></span>{ 
00189     <span class="keywordflow">return</span> d_rectBrush; 
00190 }
00191 
<a name="l00203"></a><a class="code" href="class_qwt_plain_text.html#a0">00203</a> <a class="code" href="class_qwt_plain_text.html#a0">QwtPlainText::QwtPlainText</a>(<span class="keyword">const</span> QString &amp;text, <span class="keyword">const</span> QFont &amp;font,
00204         <span class="keywordtype">int</span> align, <span class="keyword">const</span> QColor &amp;color, <span class="keyword">const</span> QPen &amp;pen, <span class="keyword">const</span> QBrush &amp;brush):
00205     <a class="code" href="class_qwt_text.html">QwtText</a>(text, font, align, color, pen, brush) 
00206 {
00207 }
00208 
<a name="l00216"></a><a class="code" href="class_qwt_plain_text.html#a1">00216</a> <a class="code" href="class_qwt_plain_text.html#a0">QwtPlainText::QwtPlainText</a>(<span class="keyword">const</span> QString &amp;text, 
00217         <span class="keyword">const</span> QFont &amp;font, <span class="keyword">const</span> QColor &amp;color):
00218     <a class="code" href="class_qwt_text.html">QwtText</a>(text, font, 
00219         Qt::AlignCenter | Qt::WordBreak | Qt::ExpandTabs, color) 
00220 {
00221 }
00222 
<a name="l00224"></a><a class="code" href="class_qwt_plain_text.html#a2">00224</a> <a class="code" href="class_qwt_text.html">QwtText</a> *<a class="code" href="class_qwt_plain_text.html#a2">QwtPlainText::clone</a>()<span class="keyword"> const</span>
00225 <span class="keyword"></span>{
00226     <span class="keywordflow">return</span> <span class="keyword">new</span> <a class="code" href="class_qwt_plain_text.html#a0">QwtPlainText</a>(
00227         <a class="code" href="class_qwt_text.html#a2">text</a>(), <a class="code" href="class_qwt_text.html#a6">font</a>(), <a class="code" href="class_qwt_text.html#a9">alignment</a>(), <a class="code" href="class_qwt_text.html#a11">color</a>(), <a class="code" href="class_qwt_text.html#a13">rectPen</a>(), <a class="code" href="class_qwt_text.html#a15">rectBrush</a>());
00228 }
00229 
<a name="l00235"></a><a class="code" href="class_qwt_plain_text.html#a3">00235</a> <span class="keywordtype">int</span> <a class="code" href="class_qwt_plain_text.html#a3">QwtPlainText::heightForWidth</a>(<span class="keywordtype">int</span> width)<span class="keyword"> const</span>
00236 <span class="keyword"></span>{
00237     <span class="keyword">const</span> QwtLayoutMetrics metrics(QwtPainter::metricsMap());
00238     <span class="keywordflow">return</span> metrics.heightForWidth(<a class="code" href="class_qwt_text.html#a2">text</a>(), width, <a class="code" href="class_qwt_text.html#a9">alignment</a>(), <a class="code" href="class_qwt_text.html#a7">fontMetrics</a>());
00239 }
00240 
<a name="l00246"></a><a class="code" href="class_qwt_plain_text.html#a5">00246</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_plain_text.html#a5">QwtPlainText::draw</a>(QPainter *painter, <span class="keyword">const</span> QRect &amp;rect)<span class="keyword"> const</span>
00247 <span class="keyword"></span>{
00248     painter-&gt;save();
00249     painter-&gt;setPen(<a class="code" href="class_qwt_text.html#a13">rectPen</a>());
00250     painter-&gt;setBrush(<a class="code" href="class_qwt_text.html#a15">rectBrush</a>());
00251     <a class="code" href="class_qwt_painter.html#e12">QwtPainter::drawRect</a>(painter, rect);
00252     painter-&gt;restore();
00253 
00254     painter-&gt;save();
00255     painter-&gt;setFont(<a class="code" href="class_qwt_text.html#a6">font</a>());
00256     painter-&gt;setPen(<a class="code" href="class_qwt_text.html#a11">color</a>());
00257     <a class="code" href="class_qwt_painter.html#e7">QwtPainter::drawText</a>(painter, rect, <a class="code" href="class_qwt_text.html#a9">alignment</a>(), <a class="code" href="class_qwt_text.html#a2">text</a>());
00258     painter-&gt;restore();
00259 }
00260 
<a name="l00261"></a><a class="code" href="class_qwt_plain_text.html#a4">00261</a> QRect <a class="code" href="class_qwt_plain_text.html#a4">QwtPlainText::boundingRect</a>(QPainter *painter)<span class="keyword"> const</span>
00262 <span class="keyword"></span>{
00263     <span class="keyword">const</span> QwtLayoutMetrics metrics(QwtPainter::metricsMap());
00264     
00265     <span class="keywordflow">if</span> (painter)
00266     {
00267         painter-&gt;save();
00268         painter-&gt;setFont(<a class="code" href="class_qwt_text.html#a6">font</a>());
00269         <span class="keyword">const</span> QRect rect = metrics.boundingRect(<a class="code" href="class_qwt_text.html#a2">text</a>(), 
00270             <a class="code" href="class_qwt_text.html#a9">alignment</a>(), painter);
00271         painter-&gt;restore();
00272         <span class="keywordflow">return</span> rect;
00273     }
00274 
00275     <span class="keywordflow">return</span> metrics.boundingRect(<a class="code" href="class_qwt_text.html#a2">text</a>(), <a class="code" href="class_qwt_text.html#a9">alignment</a>(), <a class="code" href="class_qwt_text.html#a7">fontMetrics</a>());
00276 }
00277 
00278 <span class="preprocessor">#ifndef QT_NO_RICHTEXT</span>
00279 <span class="preprocessor"></span>
<a name="l00291"></a><a class="code" href="class_qwt_rich_text.html#a0">00291</a> <a class="code" href="class_qwt_rich_text.html#a0">QwtRichText::QwtRichText</a>(<span class="keyword">const</span> QString &amp;text, <span class="keyword">const</span> QFont &amp;font,
00292         <span class="keywordtype">int</span> align, <span class="keyword">const</span> QColor &amp;color, <span class="keyword">const</span> QPen &amp;pen, <span class="keyword">const</span> QBrush &amp;brush):
00293     <a class="code" href="class_qwt_text.html">QwtText</a>(text, font, align, color, pen, brush),
00294     d_doc(new QSimpleRichText(text, font))
00295 { 
00296     <a class="code" href="class_qwt_rich_text.html#a4">setText</a>(text); 
00297 }
00298 
<a name="l00306"></a><a class="code" href="class_qwt_rich_text.html#a1">00306</a> <a class="code" href="class_qwt_rich_text.html#a0">QwtRichText::QwtRichText</a>(<span class="keyword">const</span> QString &amp;text, <span class="keyword">const</span> QFont &amp;font,
00307         <span class="keyword">const</span> QColor &amp;color):
00308     <a class="code" href="class_qwt_text.html">QwtText</a>(text, font,
00309         Qt::AlignCenter | Qt::WordBreak | Qt::ExpandTabs, color),
00310     d_doc(new QSimpleRichText(text, font))
00311 { 
00312     <a class="code" href="class_qwt_rich_text.html#a4">setText</a>(text); 
00313 }
00314 
<a name="l00316"></a><a class="code" href="class_qwt_rich_text.html#a2">00316</a> <a class="code" href="class_qwt_rich_text.html#a2">QwtRichText::~QwtRichText</a>() 
00317 { 
00318     <span class="keyword">delete</span> d_doc; 
00319 }
00320 
<a name="l00322"></a><a class="code" href="class_qwt_rich_text.html#a3">00322</a> <a class="code" href="class_qwt_text.html">QwtText</a> *<a class="code" href="class_qwt_rich_text.html#a3">QwtRichText::clone</a>()<span class="keyword"> const</span>
00323 <span class="keyword"></span>{
00324     <span class="keywordflow">return</span> <span class="keyword">new</span> <a class="code" href="class_qwt_rich_text.html#a0">QwtRichText</a>(
00325         <a class="code" href="class_qwt_text.html#a2">text</a>(), <a class="code" href="class_qwt_text.html#a6">font</a>(), <a class="code" href="class_qwt_text.html#a9">alignment</a>(), <a class="code" href="class_qwt_text.html#a11">color</a>(), <a class="code" href="class_qwt_text.html#a13">rectPen</a>(), <a class="code" href="class_qwt_text.html#a15">rectBrush</a>());
00326 }
00327 
<a name="l00329"></a><a class="code" href="class_qwt_rich_text.html#a4">00329</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_rich_text.html#a4">QwtRichText::setText</a>(<span class="keyword">const</span> QString &amp;text)
00330 {
00331     <a class="code" href="class_qwt_text.html#a1">QwtText::setText</a>(text);
00332 
00333     <span class="keyword">delete</span> d_doc;
00334     d_doc = <span class="keyword">new</span> QSimpleRichText(taggedText(text, <a class="code" href="class_qwt_text.html#a9">alignment</a>()), <a class="code" href="class_qwt_text.html#a6">font</a>());
00335 }
00336 
<a name="l00338"></a><a class="code" href="class_qwt_rich_text.html#a5">00338</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_rich_text.html#a5">QwtRichText::setFont</a>(<span class="keyword">const</span> QFont &amp;font)
00339 {
00340 <span class="preprocessor">#if QT_VERSION &gt;= 300</span>
00341 <span class="preprocessor"></span>    d_doc-&gt;setDefaultFont(font);
00342 <span class="preprocessor">#endif</span>
00343 <span class="preprocessor"></span>    <a class="code" href="class_qwt_text.html#a5">QwtText::setFont</a>(font);
00344 }
00345 
<a name="l00347"></a><a class="code" href="class_qwt_rich_text.html#a6">00347</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_rich_text.html#a6">QwtRichText::setAlignment</a>(<span class="keywordtype">int</span> align)
00348 {
00349     <a class="code" href="class_qwt_text.html#a8">QwtText::setAlignment</a>(align);
00350 
00351     <span class="keyword">delete</span> d_doc;
00352     d_doc = <span class="keyword">new</span> QSimpleRichText(taggedText(<a class="code" href="class_qwt_text.html#a2">text</a>(), align), <a class="code" href="class_qwt_text.html#a6">font</a>());
00353 }
00354 
<a name="l00360"></a><a class="code" href="class_qwt_rich_text.html#a7">00360</a> <span class="keywordtype">int</span> <a class="code" href="class_qwt_rich_text.html#a7">QwtRichText::heightForWidth</a>(<span class="keywordtype">int</span> width)<span class="keyword"> const</span>
00361 <span class="keyword"></span>{
00362 <span class="preprocessor">#if QT_VERSION &lt; 300</span>
00363 <span class="preprocessor"></span>    <span class="keyword">const</span> QFont defaultFont = QFont::defaultFont();
00364     QFont::setDefaultFont(<a class="code" href="class_qwt_text.html#a6">font</a>());
00365 <span class="preprocessor">#endif</span>
00366 <span class="preprocessor"></span>
00367     <span class="keyword">const</span> QwtLayoutMetrics metrics(QwtPainter::metricsMap());
00368     <span class="keyword">const</span> <span class="keywordtype">int</span> height = metrics.heightForWidth(*d_doc, width);
00369 
00370 <span class="preprocessor">#if QT_VERSION &lt; 300</span>
00371 <span class="preprocessor"></span>    QFont::setDefaultFont(defaultFont);
00372 <span class="preprocessor">#endif</span>
00373 <span class="preprocessor"></span>
00374     <span class="keywordflow">return</span> height;
00375 }
00376 
<a name="l00382"></a><a class="code" href="class_qwt_rich_text.html#a9">00382</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_rich_text.html#a9">QwtRichText::draw</a>(QPainter *painter, <span class="keyword">const</span> QRect &amp;rect)<span class="keyword"> const</span>
00383 <span class="keyword"></span>{
00384     painter-&gt;save();
00385     painter-&gt;setPen(<a class="code" href="class_qwt_text.html#a13">rectPen</a>());
00386     painter-&gt;setBrush(<a class="code" href="class_qwt_text.html#a15">rectBrush</a>());
00387     <a class="code" href="class_qwt_painter.html#e12">QwtPainter::drawRect</a>(painter, rect);
00388     painter-&gt;restore();
00389 
00390     painter-&gt;save();
00391 
00392     painter-&gt;setPen(<a class="code" href="class_qwt_text.html#a11">color</a>());
00393 <span class="preprocessor">#if QT_VERSION &lt; 300</span>
00394 <span class="preprocessor"></span>    <span class="keyword">const</span> QFont defaultFont = QFont::defaultFont();
00395     QFont::setDefaultFont(<a class="code" href="class_qwt_text.html#a6">font</a>());
00396 <span class="preprocessor">#else</span>
00397 <span class="preprocessor"></span>    painter-&gt;setFont(<a class="code" href="class_qwt_text.html#a6">font</a>());
00398 <span class="preprocessor">#endif</span>
00399 <span class="preprocessor"></span>
00400     <a class="code" href="class_qwt_painter.html#e11">QwtPainter::drawSimpleRichText</a>(painter, rect, <a class="code" href="class_qwt_text.html#a9">alignment</a>(), *d_doc);
00401 
00402 <span class="preprocessor">#if QT_VERSION &lt; 300</span>
00403 <span class="preprocessor"></span>    QFont::setDefaultFont(defaultFont);
00404 <span class="preprocessor">#endif</span>
00405 <span class="preprocessor"></span>    painter-&gt;restore();
00406 }
00407 
<a name="l00408"></a><a class="code" href="class_qwt_rich_text.html#a8">00408</a> QRect <a class="code" href="class_qwt_rich_text.html#a8">QwtRichText::boundingRect</a>(QPainter *painter)<span class="keyword"> const</span>
00409 <span class="keyword"></span>{
00410 <span class="preprocessor">#if QT_VERSION &lt; 300</span>
00411 <span class="preprocessor"></span>    <span class="keyword">const</span> QFont defaultFont = QFont::defaultFont();
00412     QFont::setDefaultFont(<a class="code" href="class_qwt_text.html#a6">font</a>());
00413 <span class="preprocessor">#endif</span>
00414 <span class="preprocessor"></span>
00415     <span class="keyword">const</span> QwtLayoutMetrics metrics(QwtPainter::metricsMap());
00416     <span class="keyword">const</span> QRect rect = metrics.boundingRect(*d_doc, <a class="code" href="class_qwt_text.html#a9">alignment</a>(), painter);
00417 
00418 <span class="preprocessor">#if QT_VERSION &lt; 300</span>
00419 <span class="preprocessor"></span>    QFont::setDefaultFont(defaultFont);
00420 <span class="preprocessor">#endif</span>
00421 <span class="preprocessor"></span>
00422     <span class="keywordflow">return</span> rect;
00423 }
00424 
00426 QString QwtRichText::taggedText(<span class="keyword">const</span> QString &amp;text, <span class="keywordtype">int</span> align)<span class="keyword"> const</span>
00427 <span class="keyword"></span>{
00428     QString rich = text;
00429 
00430     <span class="comment">// By default QwtSimpleRichText is Qt::AlignLeft</span>
00431 <span class="preprocessor">#if QT_VERSION &gt;= 300</span>
00432 <span class="preprocessor"></span>    <span class="keywordflow">if</span> (align &amp; Qt::AlignJustify) 
00433     {
00434         rich.prepend(QString::fromLatin1(<span class="stringliteral">"&lt;div align=\"justify\"&gt;"</span>));
00435         rich.append(QString::fromLatin1(<span class="stringliteral">"&lt;/div&gt;"</span>));
00436     } <span class="keywordflow">else</span>
00437 <span class="preprocessor">#endif</span>
00438 <span class="preprocessor"></span>    <span class="keywordflow">if</span> (align &amp; Qt::AlignRight)
00439     {
00440         rich.prepend(QString::fromLatin1(<span class="stringliteral">"&lt;div align=\"right\"&gt;"</span>));
00441         rich.append(QString::fromLatin1(<span class="stringliteral">"&lt;/div&gt;"</span>));
00442     }
00443     <span class="keywordflow">else</span> <span class="keywordflow">if</span> (align &amp; Qt::AlignHCenter) 
00444     {
00445         rich.prepend(QString::fromLatin1(<span class="stringliteral">"&lt;div align=\"center\"&gt;"</span>));
00446         rich.append(QString::fromLatin1(<span class="stringliteral">"&lt;/div&gt;"</span>));
00447     }
00448 
00449     <span class="keywordflow">return</span> rich;
00450 }
00451 
00452 <span class="preprocessor">#endif</span>
00453 <span class="preprocessor"></span>
00454 <span class="comment">// Local Variables:</span>
00455 <span class="comment">// mode: C++</span>
00456 <span class="comment">// c-file-style: "stroustrup"</span>
00457 <span class="comment">// indent-tabs-mode: nil</span>
00458 <span class="comment">// End:</span>
</div></pre><hr size="1"><address style="align: right;"><small>Generated on Tue Nov 16 21:12:21 2004 for Qwt User's Guide by
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border=0 ></a> 1.3.8 </small></address>
</body>
</html>