Index: trunk/BNC/qwt/qwt_text_engine.cpp
===================================================================
--- trunk/BNC/qwt/qwt_text_engine.cpp	(revision 9383)
+++ trunk/BNC/qwt/qwt_text_engine.cpp	(revision 11158)
@@ -1,3 +1,3 @@
-/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
+/******************************************************************************
  * Qwt Widget Library
  * Copyright (C) 1997   Josef Wilgen
@@ -9,6 +9,6 @@
 
 #include "qwt_text_engine.h"
-#include "qwt_math.h"
 #include "qwt_painter.h"
+
 #include <qpainter.h>
 #include <qpixmap.h>
@@ -20,5 +20,5 @@
 #include <qabstracttextdocumentlayout.h>
 
-static QString taggedRichText( const QString &text, int flags )
+static QString taggedRichText( const QString& text, int flags )
 {
     QString richText = text;
@@ -27,16 +27,16 @@
     if ( flags & Qt::AlignJustify )
     {
-        richText.prepend( QString::fromLatin1( "<div align=\"justify\">" ) );
-        richText.append( QString::fromLatin1( "</div>" ) );
+        richText.prepend( QLatin1String( "<div align=\"justify\">" ) );
+        richText.append( QLatin1String ( "</div>" ) );
     }
     else if ( flags & Qt::AlignRight )
     {
-        richText.prepend( QString::fromLatin1( "<div align=\"right\">" ) );
-        richText.append( QString::fromLatin1( "</div>" ) );
+        richText.prepend( QLatin1String ( "<div align=\"right\">" ) );
+        richText.append( QLatin1String ( "</div>" ) );
     }
     else if ( flags & Qt::AlignHCenter )
     {
-        richText.prepend( QString::fromLatin1( "<div align=\"center\">" ) );
-        richText.append( QString::fromLatin1( "</div>" ) );
+        richText.prepend( QLatin1String ( "<div align=\"center\">" ) );
+        richText.append( QLatin1String ( "</div>" ) );
     }
 
@@ -44,59 +44,62 @@
 }
 
-class QwtRichTextDocument: public QTextDocument
-{
-public:
-    QwtRichTextDocument( const QString &text, int flags, const QFont &font )
-    {
-        setUndoRedoEnabled( false );
-        setDefaultFont( font );
-        setHtml( text );
-
-        // make sure we have a document layout
-        ( void )documentLayout();
-
-        QTextOption option = defaultTextOption();
-        if ( flags & Qt::TextWordWrap )
-            option.setWrapMode( QTextOption::WordWrap );
-        else
-            option.setWrapMode( QTextOption::NoWrap );
-
-        option.setAlignment( static_cast<Qt::Alignment>( flags ) );
-        setDefaultTextOption( option );
-
-        QTextFrame *root = rootFrame();
-        QTextFrameFormat fm = root->frameFormat();
-        fm.setBorder( 0 );
-        fm.setMargin( 0 );
-        fm.setPadding( 0 );
-        fm.setBottomMargin( 0 );
-        fm.setLeftMargin( 0 );
-        root->setFrameFormat( fm );
-
-        adjustSize();
-    }
-};
+namespace
+{
+    class QwtRichTextDocument : public QTextDocument
+    {
+      public:
+        QwtRichTextDocument( const QString& text, int flags, const QFont& font )
+        {
+            setUndoRedoEnabled( false );
+            setDefaultFont( font );
+            setHtml( text );
+
+            // make sure we have a document layout
+            ( void )documentLayout();
+
+            QTextOption option = defaultTextOption();
+            if ( flags & Qt::TextWordWrap )
+                option.setWrapMode( QTextOption::WordWrap );
+            else
+                option.setWrapMode( QTextOption::NoWrap );
+
+            option.setAlignment( static_cast< Qt::Alignment >( flags ) );
+            setDefaultTextOption( option );
+
+            QTextFrame* root = rootFrame();
+            QTextFrameFormat fm = root->frameFormat();
+            fm.setBorder( 0 );
+            fm.setMargin( 0 );
+            fm.setPadding( 0 );
+            fm.setBottomMargin( 0 );
+            fm.setLeftMargin( 0 );
+            root->setFrameFormat( fm );
+
+            adjustSize();
+        }
+    };
+}
 
 class QwtPlainTextEngine::PrivateData
 {
-public:
-    int effectiveAscent( const QFont &font ) const
+  public:
+    int effectiveAscent( const QFont& font ) const
     {
         const QString fontKey = font.key();
 
-        QMap<QString, int>::const_iterator it =
-            d_ascentCache.constFind( fontKey );
-
-        if ( it != d_ascentCache.constEnd() )
+        QMap< QString, int >::const_iterator it =
+            m_ascentCache.constFind( fontKey );
+
+        if ( it != m_ascentCache.constEnd() )
             return *it;
 
         const int ascent = findAscent( font );
-        d_ascentCache.insert( fontKey, ascent );
+        m_ascentCache.insert( fontKey, ascent );
 
         return ascent;
     }
 
-private:
-    int findAscent( const QFont &font ) const
+  private:
+    static int findAscent( const QFont& font )
     {
         static const QString dummy( "E" );
@@ -104,5 +107,6 @@
 
         const QFontMetrics fm( font );
-        QPixmap pm( fm.width( dummy ), fm.height() );
+
+        QPixmap pm( QwtPainter::horizontalAdvance( fm, dummy ), fm.height() );
         pm.fill( white );
 
@@ -117,5 +121,5 @@
         for ( row = 0; row < img.height(); row++ )
         {
-            const QRgb *line = reinterpret_cast<const QRgb *>(
+            const QRgb* line = reinterpret_cast< const QRgb* >(
                 img.scanLine( row ) );
 
@@ -131,5 +135,5 @@
     }
 
-    mutable QMap<QString, int> d_ascentCache;
+    mutable QMap< QString, int > m_ascentCache;
 };
 
@@ -147,5 +151,5 @@
 QwtPlainTextEngine::QwtPlainTextEngine()
 {
-    d_data = new PrivateData;
+    m_data = new PrivateData;
 }
 
@@ -153,5 +157,5 @@
 QwtPlainTextEngine::~QwtPlainTextEngine()
 {
-    delete d_data;
+    delete m_data;
 }
 
@@ -165,7 +169,7 @@
 
    \return Calculated height
-*/
+ */
 double QwtPlainTextEngine::heightForWidth( const QFont& font, int flags,
-        const QString& text, double width ) const
+    const QString& text, double width ) const
 {
     const QFontMetricsF fm( font );
@@ -177,13 +181,13 @@
 
 /*!
-  Returns the size, that is needed to render text
-
-  \param font Font of the text
-  \param flags Bitwise OR of the flags used like in QPainter::drawText
-  \param text Text to be rendered
-
-  \return Calculated size
-*/
-QSizeF QwtPlainTextEngine::textSize( const QFont &font,
+   Returns the size, that is needed to render text
+
+   \param font Font of the text
+   \param flags Bitwise OR of the flags used like in QPainter::drawText
+   \param text Text to be rendered
+
+   \return Calculated size
+ */
+QSizeF QwtPlainTextEngine::textSize( const QFont& font,
     int flags, const QString& text ) const
 {
@@ -196,33 +200,33 @@
 
 /*!
-  Return margins around the texts
-
-  \param font Font of the text
-  \param left Return 0
-  \param right Return 0
-  \param top Return value for the top margin
-  \param bottom Return value for the bottom margin
-*/
-void QwtPlainTextEngine::textMargins( const QFont &font, const QString &,
-    double &left, double &right, double &top, double &bottom ) const
+   Return margins around the texts
+
+   \param font Font of the text
+   \param left Return 0
+   \param right Return 0
+   \param top Return value for the top margin
+   \param bottom Return value for the bottom margin
+ */
+void QwtPlainTextEngine::textMargins( const QFont& font, const QString&,
+    double& left, double& right, double& top, double& bottom ) const
 {
     left = right = top = 0;
 
     const QFontMetricsF fm( font );
-    top = fm.ascent() - d_data->effectiveAscent( font );
+    top = fm.ascent() - m_data->effectiveAscent( font );
     bottom = fm.descent();
 }
 
 /*!
-  \brief Draw the text in a clipping rectangle
-
-  A wrapper for QPainter::drawText.
-
-  \param painter Painter
-  \param rect Clipping rectangle
-  \param flags Bitwise OR of the flags used like in QPainter::drawText
-  \param text Text to be rendered
-*/
-void QwtPlainTextEngine::draw( QPainter *painter, const QRectF &rect,
+   \brief Draw the text in a clipping rectangle
+
+   A wrapper for QPainter::drawText.
+
+   \param painter Painter
+   \param rect Clipping rectangle
+   \param flags Bitwise OR of the flags used like in QPainter::drawText
+   \param text Text to be rendered
+ */
+void QwtPlainTextEngine::draw( QPainter* painter, const QRectF& rect,
     int flags, const QString& text ) const
 {
@@ -231,8 +235,8 @@
 
 /*!
-  Test if a string can be rendered by this text engine.
-  \return Always true. All texts can be rendered by QwtPlainTextEngine
-*/
-bool QwtPlainTextEngine::mightRender( const QString & ) const
+   Test if a string can be rendered by this text engine.
+   \return Always true. All texts can be rendered by QwtPlainTextEngine
+ */
+bool QwtPlainTextEngine::mightRender( const QString& ) const
 {
     return true;
@@ -255,7 +259,7 @@
 
    \return Calculated height
-*/
+ */
 double QwtRichTextEngine::heightForWidth( const QFont& font, int flags,
-        const QString& text, double width ) const
+    const QString& text, double width ) const
 {
     QwtRichTextDocument doc( text, flags, font );
@@ -266,14 +270,14 @@
 
 /*!
-  Returns the size, that is needed to render text
-
-  \param font Font of the text
-  \param flags Bitwise OR of the flags used like in QPainter::drawText()
-  \param text Text to be rendered
-
-  \return Calculated size
-*/
-
-QSizeF QwtRichTextEngine::textSize( const QFont &font,
+   Returns the size, that is needed to render text
+
+   \param font Font of the text
+   \param flags Bitwise OR of the flags used like in QPainter::drawText()
+   \param text Text to be rendered
+
+   \return Calculated size
+ */
+
+QSizeF QwtRichTextEngine::textSize( const QFont& font,
     int flags, const QString& text ) const
 {
@@ -292,12 +296,12 @@
 
 /*!
-  Draw the text in a clipping rectangle
-
-  \param painter Painter
-  \param rect Clipping rectangle
-  \param flags Bitwise OR of the flags like in for QPainter::drawText()
-  \param text Text to be rendered
-*/
-void QwtRichTextEngine::draw( QPainter *painter, const QRectF &rect,
+   Draw the text in a clipping rectangle
+
+   \param painter Painter
+   \param rect Clipping rectangle
+   \param flags Bitwise OR of the flags like in for QPainter::drawText()
+   \param text Text to be rendered
+ */
+void QwtRichTextEngine::draw( QPainter* painter, const QRectF& rect,
     int flags, const QString& text ) const
 {
@@ -313,6 +317,6 @@
 
    \return Tagged text
-*/
-QString QwtRichTextEngine::taggedText( const QString &text, int flags ) const
+ */
+QString QwtRichTextEngine::taggedText( const QString& text, int flags ) const
 {
     return taggedRichText( text, flags );
@@ -320,10 +324,10 @@
 
 /*!
-  Test if a string can be rendered by this text engine
-
-  \param text Text to be tested
-  \return Qt::mightBeRichText(text);
-*/
-bool QwtRichTextEngine::mightRender( const QString &text ) const
+   Test if a string can be rendered by this text engine
+
+   \param text Text to be tested
+   \return Qt::mightBeRichText(text);
+ */
+bool QwtRichTextEngine::mightRender( const QString& text ) const
 {
     return Qt::mightBeRichText( text );
@@ -331,13 +335,13 @@
 
 /*!
-  Return margins around the texts
-
-  \param left Return 0
-  \param right Return 0
-  \param top Return 0
-  \param bottom Return 0
-*/
-void QwtRichTextEngine::textMargins( const QFont &, const QString &,
-    double &left, double &right, double &top, double &bottom ) const
+   Return margins around the texts
+
+   \param left Return 0
+   \param right Return 0
+   \param top Return 0
+   \param bottom Return 0
+ */
+void QwtRichTextEngine::textMargins( const QFont&, const QString&,
+    double& left, double& right, double& top, double& bottom ) const
 {
     left = right = top = bottom = 0;
