~ubuntu-branches/ubuntu/oneiric/qwt/oneiric-proposed

« back to all changes in this revision

Viewing changes to qwt-5.1.1/src/qwt_text.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Fathi Boudra
  • Date: 2009-04-12 23:25:58 UTC
  • mfrom: (1.1.4 upstream) (2.1.2 squeeze)
  • Revision ID: james.westby@ubuntu.com-20090412232558-3bl06x785yr8xm8u
Tags: 5.1.2-1
* New upstream release.
* Bump compat/debhelper to 7.
* Bump Standards-Version to 3.8.1. No changes needed.
* Invert Maintainers and Uploaders field.
* Fix lintian warnings:
  - dh_clean _k deprecated.
  - missing dependency on libc.

Show diffs side-by-side

added added

removed removed

Lines of Context:
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
 
#include <qmap.h>
13
 
#include <qfont.h>
14
 
#include <qcolor.h>
15
 
#include <qpen.h>
16
 
#include <qbrush.h>
17
 
#include <qpainter.h>
18
 
#include "qwt_painter.h"
19
 
#include "qwt_text_engine.h"
20
 
#include "qwt_text.h"
21
 
#if QT_VERSION >= 0x040000
22
 
#include <qapplication.h>
23
 
#include <qdesktopwidget.h>
24
 
#endif
25
 
 
26
 
class QwtTextEngineDict
27
 
{
28
 
public:
29
 
    QwtTextEngineDict();
30
 
    ~QwtTextEngineDict();
31
 
 
32
 
    void setTextEngine(QwtText::TextFormat, QwtTextEngine *);
33
 
    const QwtTextEngine *textEngine(QwtText::TextFormat) const;
34
 
    const QwtTextEngine *textEngine(const QString &, 
35
 
        QwtText::TextFormat) const;
36
 
 
37
 
private:
38
 
    typedef QMap<int, QwtTextEngine *> EngineMap;
39
 
 
40
 
    inline const QwtTextEngine *engine(EngineMap::const_iterator &it) const 
41
 
    {
42
 
#if QT_VERSION < 0x040000
43
 
        return it.data();
44
 
#else
45
 
        return it.value();
46
 
#endif
47
 
    }
48
 
 
49
 
    EngineMap d_map;
50
 
};
51
 
 
52
 
QwtTextEngineDict::QwtTextEngineDict()
53
 
{
54
 
    d_map.insert(QwtText::PlainText, new QwtPlainTextEngine());
55
 
#ifndef QT_NO_RICHTEXT
56
 
    d_map.insert(QwtText::RichText, new QwtRichTextEngine());
57
 
#endif
58
 
}
59
 
 
60
 
QwtTextEngineDict::~QwtTextEngineDict()
61
 
{
62
 
    for ( EngineMap::const_iterator it = d_map.begin(); 
63
 
        it != d_map.end(); ++it )
64
 
    {
65
 
        QwtTextEngine *textEngine = (QwtTextEngine *)engine(it);
66
 
        delete textEngine;
67
 
    }
68
 
}
69
 
 
70
 
const QwtTextEngine *QwtTextEngineDict::textEngine(const QString& text,
71
 
    QwtText::TextFormat format) const
72
 
{
73
 
    if ( format == QwtText::AutoText )
74
 
    {
75
 
        for ( EngineMap::const_iterator it = d_map.begin(); 
76
 
            it != d_map.end(); ++it )
77
 
        {
78
 
            if ( it.key() != QwtText::PlainText )
79
 
            {
80
 
                const QwtTextEngine *e = engine(it);
81
 
                if ( e && e->mightRender(text) )
82
 
                    return (QwtTextEngine *)e;
83
 
            }
84
 
        }
85
 
    }
86
 
 
87
 
    EngineMap::const_iterator it = d_map.find(format);
88
 
    if ( it != d_map.end() )
89
 
    {
90
 
        const QwtTextEngine *e = engine(it);
91
 
        if ( e )
92
 
            return e;
93
 
    }
94
 
 
95
 
    it = d_map.find(QwtText::PlainText);
96
 
    return engine(it);
97
 
}
98
 
 
99
 
void QwtTextEngineDict::setTextEngine(QwtText::TextFormat format, 
100
 
    QwtTextEngine *engine)
101
 
{
102
 
    if ( format == QwtText::AutoText )
103
 
        return;
104
 
 
105
 
    if ( format == QwtText::PlainText && engine == NULL )
106
 
        return;
107
 
 
108
 
    EngineMap::const_iterator it = d_map.find(format);
109
 
    if ( it != d_map.end() )
110
 
    {
111
 
        const QwtTextEngine *e = this->engine(it);
112
 
        if ( e )
113
 
            delete e;
114
 
 
115
 
        d_map.remove(format);
116
 
    }
117
 
 
118
 
    if ( engine != NULL )
119
 
        d_map.insert(format, engine);
120
 
}
121
 
 
122
 
const QwtTextEngine *QwtTextEngineDict::textEngine(
123
 
    QwtText::TextFormat format) const
124
 
{
125
 
    const QwtTextEngine *e = NULL;
126
 
 
127
 
    EngineMap::const_iterator it = d_map.find(format);
128
 
    if ( it != d_map.end() )
129
 
        e = engine(it);
130
 
 
131
 
    return e;
132
 
}
133
 
 
134
 
static QwtTextEngineDict *engineDict = NULL;
135
 
 
136
 
class QwtText::PrivateData
137
 
{
138
 
public:
139
 
    PrivateData():
140
 
        renderFlags(Qt::AlignCenter),
141
 
        backgroundPen(Qt::NoPen),
142
 
        backgroundBrush(Qt::NoBrush),
143
 
        paintAttributes(0),
144
 
        layoutAttributes(0),
145
 
        textEngine(NULL)
146
 
    {
147
 
    }
148
 
 
149
 
    int renderFlags;
150
 
    QString text;
151
 
    QFont font;
152
 
    QColor color;
153
 
    QPen backgroundPen;
154
 
    QBrush backgroundBrush;
155
 
 
156
 
    int paintAttributes;
157
 
    int layoutAttributes;
158
 
 
159
 
    const QwtTextEngine *textEngine;
160
 
};
161
 
 
162
 
class QwtText::LayoutCache
163
 
{
164
 
public:
165
 
    void invalidate()
166
 
    {
167
 
        textSize = QSize();
168
 
    }
169
 
 
170
 
    QFont font;
171
 
    QSize textSize;
172
 
};
173
 
 
174
 
/*!
175
 
   Constructor
176
 
 
177
 
   \param text Text content
178
 
   \param textFormat Text format
179
 
*/
180
 
QwtText::QwtText(const QString &text, QwtText::TextFormat textFormat)
181
 
{
182
 
    d_data = new PrivateData;
183
 
    d_data->text = text;
184
 
    d_data->textEngine = textEngine(text, textFormat);
185
 
 
186
 
    d_layoutCache = new LayoutCache;
187
 
}
188
 
 
189
 
//! Copy constructor
190
 
QwtText::QwtText(const QwtText &other)
191
 
{
192
 
    d_data = new PrivateData;
193
 
    *d_data = *other.d_data;
194
 
 
195
 
    d_layoutCache = new LayoutCache;
196
 
    *d_layoutCache = *other.d_layoutCache;
197
 
}
198
 
 
199
 
//! Destructor
200
 
QwtText::~QwtText() 
201
 
{
202
 
    delete d_data;
203
 
    delete d_layoutCache;
204
 
}
205
 
 
206
 
//! Assignement operator
207
 
QwtText &QwtText::operator=(const QwtText &other)
208
 
{
209
 
    *d_data = *other.d_data;
210
 
    *d_layoutCache = *other.d_layoutCache;
211
 
    return *this;
212
 
}
213
 
    
214
 
int QwtText::operator==(const QwtText &other) const
215
 
{
216
 
    return d_data->renderFlags == other.d_data->renderFlags &&
217
 
        d_data->text == other.d_data->text &&
218
 
        d_data->font == other.d_data->font &&
219
 
        d_data->color == other.d_data->color &&
220
 
        d_data->backgroundPen == other.d_data->backgroundPen &&
221
 
        d_data->backgroundBrush == other.d_data->backgroundBrush &&
222
 
        d_data->paintAttributes == other.d_data->paintAttributes &&
223
 
        d_data->textEngine == other.d_data->textEngine;
224
 
}
225
 
 
226
 
int QwtText::operator!=(const QwtText &other) const // invalidate
227
 
{
228
 
   return !(other == *this);
229
 
}
230
 
 
231
 
/*!
232
 
   Assign a new text content
233
 
 
234
 
   \param text Text content
235
 
   \param textFormat Text format
236
 
*/
237
 
void QwtText::setText(const QString &text, 
238
 
    QwtText::TextFormat textFormat) 
239
 
240
 
    d_data->text = text; 
241
 
    d_data->textEngine = textEngine(text, textFormat);
242
 
    d_layoutCache->invalidate();
243
 
}
244
 
 
245
 
/*! 
246
 
   Return the text.
247
 
   \sa setText
248
 
*/
249
 
QString QwtText::text() const 
250
 
251
 
    return d_data->text; 
252
 
}
253
 
 
254
 
/*!
255
 
   \brief Change the render flags
256
 
 
257
 
   The default setting is Qt::AlignCenter
258
 
 
259
 
   \param renderFlags Bitwise OR of the flags used like in QPainter::drawText
260
 
 
261
 
   \sa renderFlags, QwtTextEngine::draw
262
 
   \note Some renderFlags might have no effect, depending on the text format.
263
 
*/
264
 
void QwtText::setRenderFlags(int renderFlags) 
265
 
266
 
    if ( renderFlags != d_data->renderFlags )
267
 
    {
268
 
        d_data->renderFlags = renderFlags; 
269
 
        d_layoutCache->invalidate();
270
 
    }
271
 
}
272
 
 
273
 
/*!
274
 
   \return Render flags
275
 
   \sa setRenderFlags
276
 
*/
277
 
int QwtText::renderFlags() const 
278
 
279
 
    return d_data->renderFlags; 
280
 
}
281
 
 
282
 
/*! 
283
 
   Set the font.
284
 
 
285
 
   \param font Font
286
 
   \note Setting the font might have no effect, when
287
 
         the text contains control sequences for setting fonts.
288
 
*/
289
 
void QwtText::setFont(const QFont &font) 
290
 
{
291
 
    d_data->font = font; 
292
 
    setPaintAttribute(PaintUsingTextFont);
293
 
}
294
 
 
295
 
//! Return the font.
296
 
QFont QwtText::font() const 
297
 
298
 
    return d_data->font; 
299
 
}
300
 
 
301
 
/*!
302
 
  Return the font of the text, if it has one. 
303
 
  Otherwise return defaultFont.
304
 
 
305
 
  \param defaultFont Default font
306
 
  \sa setFont, font, PaintAttributes
307
 
*/
308
 
QFont QwtText::usedFont(const QFont &defaultFont) const
309
 
{
310
 
    if ( d_data->paintAttributes & PaintUsingTextFont )
311
 
        return d_data->font;
312
 
 
313
 
    return defaultFont;
314
 
}
315
 
 
316
 
/*! 
317
 
   Set the pen color used for painting the text.
318
 
 
319
 
   \param color Color
320
 
   \note Setting the color might have no effect, when
321
 
         the text contains control sequences for setting colors.
322
 
*/
323
 
void QwtText::setColor(const QColor &color) 
324
 
325
 
    d_data->color = color; 
326
 
    setPaintAttribute(PaintUsingTextColor);
327
 
}
328
 
 
329
 
//! Return the pen color, used for painting the text
330
 
QColor QwtText::color() const 
331
 
332
 
    return d_data->color; 
333
 
}
334
 
 
335
 
/*!
336
 
  Return the color of the text, if it has one. 
337
 
  Otherwise return defaultColor.
338
 
 
339
 
  \param defaultColor Default color
340
 
  \sa setColor, color, PaintAttributes
341
 
*/
342
 
QColor QwtText::usedColor(const QColor &defaultColor) const
343
 
{
344
 
    if ( d_data->paintAttributes & PaintUsingTextColor )
345
 
        return d_data->color;
346
 
 
347
 
    return defaultColor;
348
 
}
349
 
 
350
 
/*!
351
 
   Set the background pen
352
 
 
353
 
   \param pen Background pen
354
 
   \sa backgroundPen, setBackgroundBrush
355
 
*/
356
 
void QwtText::setBackgroundPen(const QPen &pen) 
357
 
358
 
    d_data->backgroundPen = pen; 
359
 
    setPaintAttribute(PaintBackground);
360
 
}
361
 
 
362
 
/*! 
363
 
   \return Background pen
364
 
   \sa setBackgroundPen, backgroundBrush
365
 
*/
366
 
QPen QwtText::backgroundPen() const 
367
 
368
 
    return d_data->backgroundPen; 
369
 
}
370
 
 
371
 
/*!
372
 
   Set the background brush
373
 
 
374
 
   \param brush Background brush
375
 
   \sa backgroundBrush, setBackgroundPen
376
 
*/
377
 
void QwtText::setBackgroundBrush(const QBrush &brush) 
378
 
379
 
    d_data->backgroundBrush = brush; 
380
 
    setPaintAttribute(PaintBackground);
381
 
}
382
 
 
383
 
/*! 
384
 
   \return Background brush
385
 
   \sa setBackgroundBrush, backgroundPen
386
 
*/
387
 
QBrush QwtText::backgroundBrush() const 
388
 
389
 
    return d_data->backgroundBrush; 
390
 
}
391
 
 
392
 
/*!
393
 
   Change a paint attribute
394
 
 
395
 
   \param attribute Paint attribute
396
 
   \param on On/Off
397
 
 
398
 
   \note Used by setFont, setColor, setBackgroundPen and setBackgroundBrush
399
 
   \sa testPaintAttribute
400
 
*/
401
 
void QwtText::setPaintAttribute(PaintAttribute attribute, bool on)
402
 
{
403
 
    if ( on )
404
 
        d_data->paintAttributes |= attribute;
405
 
    else
406
 
        d_data->paintAttributes &= ~attribute;
407
 
}
408
 
 
409
 
/*!
410
 
   Test a paint attribute
411
 
 
412
 
   \param attribute Paint attribute
413
 
   \return true, if attribute is enabled
414
 
 
415
 
   \sa setPaintAttribute
416
 
*/
417
 
bool QwtText::testPaintAttribute(PaintAttribute attribute) const
418
 
{
419
 
    return d_data->paintAttributes & attribute;
420
 
}
421
 
 
422
 
/*!
423
 
   Change a layout attribute
424
 
 
425
 
   \param attribute Layout attribute
426
 
   \param on On/Off
427
 
   \sa testLayoutAttribute
428
 
*/ 
429
 
void QwtText::setLayoutAttribute(LayoutAttribute attribute, bool on)
430
 
{
431
 
    if ( on )
432
 
        d_data->layoutAttributes |= attribute;
433
 
    else
434
 
        d_data->layoutAttributes &= ~attribute;
435
 
}
436
 
 
437
 
/*!
438
 
   Test a layout attribute
439
 
 
440
 
   \param attribute Layout attribute
441
 
   \return true, if attribute is enabled
442
 
 
443
 
   \sa setLayoutAttribute
444
 
*/
445
 
bool QwtText::testLayoutAttribute(LayoutAttribute attribute) const
446
 
{
447
 
    return d_data->layoutAttributes | attribute;
448
 
}
449
 
 
450
 
/*!
451
 
   Find the height for a given width
452
 
 
453
 
   \param defaultFont Font, used for the calculation if the text has no font
454
 
   \param width Width
455
 
 
456
 
   \return Calculated height
457
 
*/
458
 
int QwtText::heightForWidth(int width, const QFont &defaultFont) const
459
 
{
460
 
    const QwtMetricsMap map = QwtPainter::metricsMap();
461
 
    width = map.layoutToScreenX(width);
462
 
 
463
 
#if QT_VERSION < 0x040000
464
 
    const QFont font = usedFont(defaultFont);
465
 
#else
466
 
    // We want to calculate in screen metrics. So
467
 
    // we need a font that uses screen metrics
468
 
 
469
 
    const QFont font(usedFont(defaultFont), QApplication::desktop());
470
 
#endif
471
 
 
472
 
    int h = 0;
473
 
 
474
 
    if ( d_data->layoutAttributes & MinimumLayout )
475
 
    {
476
 
        int left, right, top, bottom;
477
 
        d_data->textEngine->textMargins(font, d_data->text,
478
 
            left, right, top, bottom);
479
 
 
480
 
        h = d_data->textEngine->heightForWidth(
481
 
            font, d_data->renderFlags, d_data->text, 
482
 
            width + left + right);
483
 
 
484
 
        h -= top + bottom;
485
 
    }
486
 
    else
487
 
    {
488
 
        h = d_data->textEngine->heightForWidth(
489
 
            font, d_data->renderFlags, d_data->text, width);
490
 
    }
491
 
 
492
 
    h = map.screenToLayoutY(h);
493
 
    return h;
494
 
}
495
 
 
496
 
/*!
497
 
   Find the height for a given width
498
 
 
499
 
   \param defaultFont Font, used for the calculation if the text has no font
500
 
 
501
 
   \return Calculated height
502
 
*/
503
 
 
504
 
/*!
505
 
   Returns the size, that is needed to render text
506
 
 
507
 
   \param defaultFont Font of the text
508
 
   \return Caluclated size
509
 
*/
510
 
QSize QwtText::textSize(const QFont &defaultFont) const
511
 
{
512
 
#if QT_VERSION < 0x040000
513
 
    const QFont font(usedFont(defaultFont));
514
 
#else
515
 
    // We want to calculate in screen metrics. So
516
 
    // we need a font that uses screen metrics
517
 
 
518
 
    const QFont font(usedFont(defaultFont), QApplication::desktop());
519
 
#endif
520
 
 
521
 
    if ( !d_layoutCache->textSize.isValid() 
522
 
        || d_layoutCache->font != font )
523
 
    {
524
 
        d_layoutCache->textSize = d_data->textEngine->textSize(
525
 
            font, d_data->renderFlags, d_data->text);
526
 
        d_layoutCache->font = font;
527
 
    }
528
 
 
529
 
    QSize sz = d_layoutCache->textSize;
530
 
 
531
 
    const QwtMetricsMap map = QwtPainter::metricsMap();
532
 
 
533
 
    if ( d_data->layoutAttributes & MinimumLayout )
534
 
    {
535
 
        int left, right, top, bottom;
536
 
        d_data->textEngine->textMargins(font, d_data->text,
537
 
            left, right, top, bottom);
538
 
        sz -= QSize(left + right, top + bottom);
539
 
#if QT_VERSION >= 0x040000
540
 
        if ( !map.isIdentity() )
541
 
        {
542
 
#ifdef __GNUC__
543
 
#endif
544
 
            /*
545
 
                When printing in high resolution, the tick labels
546
 
                of are cut of. We need to find out why, but for
547
 
                the moment we add a couple of pixels instead.
548
 
             */
549
 
            sz += QSize(3, 0);
550
 
        }
551
 
#endif
552
 
    }
553
 
 
554
 
    sz = map.screenToLayout(sz);
555
 
    return sz;
556
 
}
557
 
 
558
 
/*!
559
 
   Draw a text into a rectangle
560
 
 
561
 
   \param painter Painter
562
 
   \param rect Rectangle
563
 
*/
564
 
void QwtText::draw(QPainter *painter, const QRect &rect) const
565
 
{
566
 
    if ( d_data->paintAttributes & PaintBackground )
567
 
    {
568
 
        if ( d_data->backgroundPen != Qt::NoPen || 
569
 
            d_data->backgroundBrush != Qt::NoBrush )
570
 
        {
571
 
            painter->save();
572
 
            painter->setPen(d_data->backgroundPen);
573
 
            painter->setBrush(d_data->backgroundBrush);
574
 
#if QT_VERSION < 0x040000
575
 
            QwtPainter::drawRect(painter, rect);
576
 
#else
577
 
            const QRect r(rect.x(), rect.y(), 
578
 
                rect.width() - 1, rect.height() - 1);
579
 
            QwtPainter::drawRect(painter, r);
580
 
#endif
581
 
            painter->restore();
582
 
        }
583
 
    }
584
 
 
585
 
    painter->save();
586
 
 
587
 
    if ( d_data->paintAttributes & PaintUsingTextFont )
588
 
    {
589
 
        painter->setFont(d_data->font);
590
 
    }
591
 
 
592
 
    if ( d_data->paintAttributes & PaintUsingTextColor )
593
 
    {
594
 
        if ( d_data->color.isValid() )
595
 
            painter->setPen(d_data->color);
596
 
    }
597
 
 
598
 
    QRect expandedRect = rect;
599
 
    if ( d_data->layoutAttributes & MinimumLayout )
600
 
    {
601
 
#if QT_VERSION < 0x040000
602
 
        const QFont font(painter->font());
603
 
#else
604
 
        // We want to calculate in screen metrics. So
605
 
        // we need a font that uses screen metrics
606
 
 
607
 
        const QFont font(painter->font(), QApplication::desktop());
608
 
#endif
609
 
 
610
 
        int left, right, top, bottom;
611
 
        d_data->textEngine->textMargins(
612
 
            font, d_data->text,
613
 
            left, right, top, bottom);
614
 
 
615
 
        const QwtMetricsMap map = QwtPainter::metricsMap();
616
 
        left = map.screenToLayoutX(left);
617
 
        right = map.screenToLayoutX(right);
618
 
        top = map.screenToLayoutY(top);
619
 
        bottom = map.screenToLayoutY(bottom);
620
 
 
621
 
        expandedRect.setTop(rect.top() - top);
622
 
        expandedRect.setBottom(rect.bottom() + bottom);
623
 
        expandedRect.setLeft(rect.left() - left);
624
 
        expandedRect.setRight(rect.right() + right);
625
 
    }
626
 
 
627
 
    d_data->textEngine->draw(painter, expandedRect, 
628
 
        d_data->renderFlags, d_data->text);
629
 
 
630
 
    painter->restore();
631
 
}
632
 
 
633
 
/*!
634
 
   Find the text engine for a text format
635
 
 
636
 
   In case of QwtText::AutoText the first text engine 
637
 
   (beside QwtPlainTextEngine) is returned, where QwtTextEngine::mightRender
638
 
   returns true. If there is none QwtPlainTextEngine is returnd.
639
 
 
640
 
   If no text engine is registered for the format QwtPlainTextEngine 
641
 
   is returnd.
642
 
 
643
 
   \param text Text, needed in case of AutoText
644
 
   \param format Text format
645
 
*/
646
 
const QwtTextEngine *QwtText::textEngine(const QString &text,
647
 
    QwtText::TextFormat format)
648
 
{
649
 
    if ( engineDict == NULL )
650
 
    {
651
 
        /*
652
 
          Note: engineDict is allocated, the first time it is used, 
653
 
                but never deleted, because there is no known last access time.
654
 
                So don't be irritated, if it is reported as a memory leak
655
 
                from your memory profiler.
656
 
         */
657
 
        engineDict = new QwtTextEngineDict();
658
 
    }
659
 
 
660
 
    return engineDict->textEngine(text, format);
661
 
}
662
 
 
663
 
/*!
664
 
   Assign/Replace a text engine for a text format
665
 
 
666
 
   With setTextEngine it is possible to extend Qwt with
667
 
   other types of text formats. 
668
 
 
669
 
   Owner of a commercial Qt license can build the qwtmathml library, 
670
 
   that is based on the MathML renderer, that is included in MML Widget 
671
 
   component of the Qt solutions package.
672
 
 
673
 
   For QwtText::PlainText it is not allowed to assign a engine == NULL.
674
 
   
675
 
   \param format Text format
676
 
   \param engine Text engine
677
 
 
678
 
   \sa QwtMathMLTextEngine
679
 
   \warning Using QwtText::AutoText does nothing.
680
 
*/
681
 
void QwtText::setTextEngine(QwtText::TextFormat format, 
682
 
    QwtTextEngine *engine)
683
 
{
684
 
    if ( engineDict == NULL )
685
 
        engineDict = new QwtTextEngineDict();
686
 
 
687
 
    engineDict->setTextEngine(format, engine);
688
 
}
689
 
 
690
 
/*!
691
 
   \brief Find the text engine for a text format
692
 
 
693
 
   textEngine can be used to find out if a text format is supported. 
694
 
   F.e, if one wants to use MathML labels, the MathML renderer from the 
695
 
   commercial Qt solutions package might be required, that is not 
696
 
   available in Qt Open Source Edition environments.
697
 
 
698
 
   \param format Text format
699
 
   \return The text engine, or NULL if no engine is available.
700
 
*/
701
 
const QwtTextEngine *QwtText::textEngine(QwtText::TextFormat format)
702
 
{
703
 
    if ( engineDict == NULL )
704
 
        engineDict = new QwtTextEngineDict();
705
 
 
706
 
    return engineDict->textEngine(format);
707
 
}