Index: trunk/BNC/qwt/qwt_scale_widget.cpp
===================================================================
--- trunk/BNC/qwt/qwt_scale_widget.cpp	(revision 9383)
+++ trunk/BNC/qwt/qwt_scale_widget.cpp	(revision 11158)
@@ -1,3 +1,3 @@
-/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
+/******************************************************************************
  * Qwt Widget Library
  * Copyright (C) 1997   Josef Wilgen
@@ -15,17 +15,19 @@
 #include "qwt_scale_div.h"
 #include "qwt_text.h"
+#include "qwt_interval.h"
 #include "qwt_scale_engine.h"
+
 #include <qpainter.h>
 #include <qevent.h>
-#include <qmath.h>
 #include <qstyle.h>
 #include <qstyleoption.h>
 #include <qapplication.h>
+#include <qmargins.h>
 
 class QwtScaleWidget::PrivateData
 {
-public:
-    PrivateData():
-        scaleDraw( NULL )
+  public:
+    PrivateData()
+        : scaleDraw( NULL )
     {
         colorBar.colorMap = NULL;
@@ -38,5 +40,5 @@
     }
 
-    QwtScaleDraw *scaleDraw;
+    QwtScaleDraw* scaleDraw;
 
     int borderDist[2];
@@ -56,14 +58,14 @@
         int width;
         QwtInterval interval;
-        QwtColorMap *colorMap;
+        QwtColorMap* colorMap;
     } colorBar;
 };
 
 /*!
-  \brief Create a scale with the position QwtScaleWidget::Left
-  \param parent Parent widget
-*/
-QwtScaleWidget::QwtScaleWidget( QWidget *parent ):
-    QWidget( parent )
+   \brief Create a scale with the position QwtScaleWidget::Left
+   \param parent Parent widget
+ */
+QwtScaleWidget::QwtScaleWidget( QWidget* parent )
+    : QWidget( parent )
 {
     initScale( QwtScaleDraw::LeftScale );
@@ -71,11 +73,10 @@
 
 /*!
-  \brief Constructor
-  \param align Alignment.
-  \param parent Parent widget
-*/
-QwtScaleWidget::QwtScaleWidget(
-        QwtScaleDraw::Alignment align, QWidget *parent ):
-    QWidget( parent )
+   \brief Constructor
+   \param align Alignment.
+   \param parent Parent widget
+ */
+QwtScaleWidget::QwtScaleWidget( QwtScaleDraw::Alignment align, QWidget* parent )
+    : QWidget( parent )
 {
     initScale( align );
@@ -85,5 +86,5 @@
 QwtScaleWidget::~QwtScaleWidget()
 {
-    delete d_data;
+    delete m_data;
 }
 
@@ -91,37 +92,36 @@
 void QwtScaleWidget::initScale( QwtScaleDraw::Alignment align )
 {
-    d_data = new PrivateData;
-
-    d_data->layoutFlags = 0;
+    m_data = new PrivateData;
+
     if ( align == QwtScaleDraw::RightScale )
-        d_data->layoutFlags |= TitleInverted;
-
-    d_data->borderDist[0] = 0;
-    d_data->borderDist[1] = 0;
-    d_data->minBorderDist[0] = 0;
-    d_data->minBorderDist[1] = 0;
-    d_data->margin = 4;
-    d_data->titleOffset = 0;
-    d_data->spacing = 2;
-
-    d_data->scaleDraw = new QwtScaleDraw;
-    d_data->scaleDraw->setAlignment( align );
-    d_data->scaleDraw->setLength( 10 );
-
-    d_data->scaleDraw->setScaleDiv(
+        m_data->layoutFlags |= TitleInverted;
+
+    m_data->borderDist[0] = 0;
+    m_data->borderDist[1] = 0;
+    m_data->minBorderDist[0] = 0;
+    m_data->minBorderDist[1] = 0;
+    m_data->margin = 4;
+    m_data->titleOffset = 0;
+    m_data->spacing = 2;
+
+    m_data->scaleDraw = new QwtScaleDraw;
+    m_data->scaleDraw->setAlignment( align );
+    m_data->scaleDraw->setLength( 10 );
+
+    m_data->scaleDraw->setScaleDiv(
         QwtLinearScaleEngine().divideScale( 0.0, 100.0, 10, 5 ) );
 
-    d_data->colorBar.colorMap = new QwtLinearColorMap();
-    d_data->colorBar.isEnabled = false;
-    d_data->colorBar.width = 10;
+    m_data->colorBar.colorMap = new QwtLinearColorMap();
+    m_data->colorBar.isEnabled = false;
+    m_data->colorBar.width = 10;
 
     const int flags = Qt::AlignHCenter
         | Qt::TextExpandTabs | Qt::TextWordWrap;
-    d_data->title.setRenderFlags( flags );
-    d_data->title.setFont( font() );
+    m_data->title.setRenderFlags( flags );
+    m_data->title.setFont( font() );
 
     QSizePolicy policy( QSizePolicy::MinimumExpanding,
         QSizePolicy::Fixed );
-    if ( d_data->scaleDraw->orientation() == Qt::Vertical )
+    if ( m_data->scaleDraw->orientation() == Qt::Vertical )
         policy.transpose();
 
@@ -138,13 +138,13 @@
 
    \sa testLayoutFlag(), LayoutFlag
-*/
+ */
 void QwtScaleWidget::setLayoutFlag( LayoutFlag flag, bool on )
 {
-    if ( ( ( d_data->layoutFlags & flag ) != 0 ) != on )
+    if ( ( ( m_data->layoutFlags & flag ) != 0 ) != on )
     {
         if ( on )
-            d_data->layoutFlags |= flag;
+            m_data->layoutFlags |= flag;
         else
-            d_data->layoutFlags &= ~flag;
+            m_data->layoutFlags &= ~flag;
 
         update();
@@ -158,21 +158,21 @@
    \return true/false
    \sa setLayoutFlag(), LayoutFlag
-*/
+ */
 bool QwtScaleWidget::testLayoutFlag( LayoutFlag flag ) const
 {
-    return ( d_data->layoutFlags & flag );
-}
-
-/*!
-  Give title new text contents
-
-  \param title New title
-  \sa title(), setTitle(const QwtText &);
-*/
-void QwtScaleWidget::setTitle( const QString &title )
-{
-    if ( d_data->title.text() != title )
-    {
-        d_data->title.setText( title );
+    return ( m_data->layoutFlags & flag );
+}
+
+/*!
+   Give title new text contents
+
+   \param title New title
+   \sa title(), setTitle(const QwtText &);
+ */
+void QwtScaleWidget::setTitle( const QString& title )
+{
+    if ( m_data->title.text() != title )
+    {
+        m_data->title.setText( title );
         layoutScale();
     }
@@ -180,13 +180,13 @@
 
 /*!
-  Give title new text contents
-
-  \param title New title
-  \sa title()
-  \warning The title flags are interpreted in
+   Give title new text contents
+
+   \param title New title
+   \sa title()
+   \warning The title flags are interpreted in
                direction of the label, AlignTop, AlignBottom can't be set
                as the title will always be aligned to the scale.
-*/
-void QwtScaleWidget::setTitle( const QwtText &title )
+ */
+void QwtScaleWidget::setTitle( const QwtText& title )
 {
     QwtText t = title;
@@ -194,7 +194,7 @@
     t.setRenderFlags( flags );
 
-    if ( t != d_data->title )
-    {
-        d_data->title = t;
+    if ( t != m_data->title )
+    {
+        m_data->title = t;
         layoutScale();
     }
@@ -202,19 +202,20 @@
 
 /*!
-  Change the alignment
-
-  \param alignment New alignment
-  \sa alignment()
-*/
+   Change the alignment
+
+   \param alignment New alignment
+   \sa alignment()
+ */
 void QwtScaleWidget::setAlignment( QwtScaleDraw::Alignment alignment )
 {
-    if ( d_data->scaleDraw )
-        d_data->scaleDraw->setAlignment( alignment );
+    if ( m_data->scaleDraw == NULL )
+        return;
+
+    m_data->scaleDraw->setAlignment( alignment );
 
     if ( !testAttribute( Qt::WA_WState_OwnSizePolicy ) )
     {
-        QSizePolicy policy( QSizePolicy::MinimumExpanding,
-            QSizePolicy::Fixed );
-        if ( d_data->scaleDraw->orientation() == Qt::Vertical )
+        QSizePolicy policy( QSizePolicy::MinimumExpanding, QSizePolicy::Fixed );
+        if ( m_data->scaleDraw->orientation() == Qt::Vertical )
             policy.transpose();
 
@@ -231,5 +232,5 @@
     \return position
     \sa setPosition()
-*/
+ */
 QwtScaleDraw::Alignment QwtScaleWidget::alignment() const
 {
@@ -241,17 +242,17 @@
 
 /*!
-  Specify distances of the scale's endpoints from the
-  widget's borders. The actual borders will never be less
-  than minimum border distance.
-  \param dist1 Left or top Distance
-  \param dist2 Right or bottom distance
-  \sa borderDist()
-*/
+   Specify distances of the scale's endpoints from the
+   widget's borders. The actual borders will never be less
+   than minimum border distance.
+   \param dist1 Left or top Distance
+   \param dist2 Right or bottom distance
+   \sa borderDist()
+ */
 void QwtScaleWidget::setBorderDist( int dist1, int dist2 )
 {
-    if ( dist1 != d_data->borderDist[0] || dist2 != d_data->borderDist[1] )
-    {
-        d_data->borderDist[0] = dist1;
-        d_data->borderDist[1] = dist2;
+    if ( dist1 != m_data->borderDist[0] || dist2 != m_data->borderDist[1] )
+    {
+        m_data->borderDist[0] = dist1;
+        m_data->borderDist[1] = dist2;
         layoutScale();
     }
@@ -259,14 +260,14 @@
 
 /*!
-  \brief Specify the margin to the colorBar/base line.
-  \param margin Margin
-  \sa margin()
-*/
+   \brief Specify the margin to the colorBar/base line.
+   \param margin Margin
+   \sa margin()
+ */
 void QwtScaleWidget::setMargin( int margin )
 {
     margin = qMax( 0, margin );
-    if ( margin != d_data->margin )
-    {
-        d_data->margin = margin;
+    if ( margin != m_data->margin )
+    {
+        m_data->margin = margin;
         layoutScale();
     }
@@ -274,14 +275,14 @@
 
 /*!
-  \brief Specify the distance between color bar, scale and title
-  \param spacing Spacing
-  \sa spacing()
-*/
+   \brief Specify the distance between color bar, scale and title
+   \param spacing Spacing
+   \sa spacing()
+ */
 void QwtScaleWidget::setSpacing( int spacing )
 {
     spacing = qMax( 0, spacing );
-    if ( spacing != d_data->spacing )
-    {
-        d_data->spacing = spacing;
+    if ( spacing != m_data->spacing )
+    {
+        m_data->spacing = spacing;
         layoutScale();
     }
@@ -289,44 +290,44 @@
 
 /*!
-  \brief Change the alignment for the labels.
-
-  \sa QwtScaleDraw::setLabelAlignment(), setLabelRotation()
-*/
+   \brief Change the alignment for the labels.
+
+   \sa QwtScaleDraw::setLabelAlignment(), setLabelRotation()
+ */
 void QwtScaleWidget::setLabelAlignment( Qt::Alignment alignment )
 {
-    d_data->scaleDraw->setLabelAlignment( alignment );
+    m_data->scaleDraw->setLabelAlignment( alignment );
     layoutScale();
 }
 
 /*!
-  \brief Change the rotation for the labels.
-  See QwtScaleDraw::setLabelRotation().
-
-  \param rotation Rotation
-  \sa QwtScaleDraw::setLabelRotation(), setLabelFlags()
-*/
+   \brief Change the rotation for the labels.
+   See QwtScaleDraw::setLabelRotation().
+
+   \param rotation Rotation
+   \sa QwtScaleDraw::setLabelRotation(), setLabelFlags()
+ */
 void QwtScaleWidget::setLabelRotation( double rotation )
 {
-    d_data->scaleDraw->setLabelRotation( rotation );
+    m_data->scaleDraw->setLabelRotation( rotation );
     layoutScale();
 }
 
 /*!
-  Set a scale draw
-
-  scaleDraw has to be created with new and will be deleted in
-  ~QwtScaleWidget() or the next call of setScaleDraw().
-  scaleDraw will be initialized with the attributes of
-  the previous scaleDraw object.
-
-  \param scaleDraw ScaleDraw object
-  \sa scaleDraw()
-*/
-void QwtScaleWidget::setScaleDraw( QwtScaleDraw *scaleDraw )
-{
-    if ( ( scaleDraw == NULL ) || ( scaleDraw == d_data->scaleDraw ) )
+   Set a scale draw
+
+   scaleDraw has to be created with new and will be deleted in
+   ~QwtScaleWidget() or the next call of setScaleDraw().
+   scaleDraw will be initialized with the attributes of
+   the previous scaleDraw object.
+
+   \param scaleDraw ScaleDraw object
+   \sa scaleDraw()
+ */
+void QwtScaleWidget::setScaleDraw( QwtScaleDraw* scaleDraw )
+{
+    if ( ( scaleDraw == NULL ) || ( scaleDraw == m_data->scaleDraw ) )
         return;
 
-    const QwtScaleDraw* sd = d_data->scaleDraw;
+    const QwtScaleDraw* sd = m_data->scaleDraw;
     if ( sd )
     {
@@ -334,5 +335,5 @@
         scaleDraw->setScaleDiv( sd->scaleDiv() );
 
-        QwtTransform *transform = NULL;
+        QwtTransform* transform = NULL;
         if ( sd->scaleMap().transformation() )
             transform = sd->scaleMap().transformation()->copy();
@@ -341,6 +342,6 @@
     }
 
-    delete d_data->scaleDraw;
-    d_data->scaleDraw = scaleDraw;
+    delete m_data->scaleDraw;
+    m_data->scaleDraw = scaleDraw;
 
     layoutScale();
@@ -350,8 +351,8 @@
     \return scaleDraw of this scale
     \sa setScaleDraw(), QwtScaleDraw::setScaleDraw()
-*/
-const QwtScaleDraw *QwtScaleWidget::scaleDraw() const
-{
-    return d_data->scaleDraw;
+ */
+const QwtScaleDraw* QwtScaleWidget::scaleDraw() const
+{
+    return m_data->scaleDraw;
 }
 
@@ -359,8 +360,8 @@
     \return scaleDraw of this scale
     \sa QwtScaleDraw::setScaleDraw()
-*/
-QwtScaleDraw *QwtScaleWidget::scaleDraw()
-{
-    return d_data->scaleDraw;
+ */
+QwtScaleDraw* QwtScaleWidget::scaleDraw()
+{
+    return m_data->scaleDraw;
 }
 
@@ -368,8 +369,8 @@
     \return title
     \sa setTitle()
-*/
+ */
 QwtText QwtScaleWidget::title() const
 {
-    return d_data->title;
+    return m_data->title;
 }
 
@@ -377,8 +378,8 @@
     \return start border distance
     \sa setBorderDist()
-*/
+ */
 int QwtScaleWidget::startBorderDist() const
 {
-    return d_data->borderDist[0];
+    return m_data->borderDist[0];
 }
 
@@ -386,8 +387,8 @@
     \return end border distance
     \sa setBorderDist()
-*/
+ */
 int QwtScaleWidget::endBorderDist() const
 {
-    return d_data->borderDist[1];
+    return m_data->borderDist[1];
 }
 
@@ -395,8 +396,8 @@
     \return margin
     \sa setMargin()
-*/
+ */
 int QwtScaleWidget::margin() const
 {
-    return d_data->margin;
+    return m_data->margin;
 }
 
@@ -404,14 +405,14 @@
     \return distance between scale and title
     \sa setMargin()
-*/
+ */
 int QwtScaleWidget::spacing() const
 {
-    return d_data->spacing;
-}
-
-/*!
-  \brief paintEvent
-*/
-void QwtScaleWidget::paintEvent( QPaintEvent *event )
+    return m_data->spacing;
+}
+
+/*!
+   \brief paintEvent
+ */
+void QwtScaleWidget::paintEvent( QPaintEvent* event )
 {
     QPainter painter( this );
@@ -419,5 +420,5 @@
 
     QStyleOption opt;
-    opt.init(this);
+    opt.initFrom(this);
     style()->drawPrimitive(QStyle::PE_Widget, &opt, &painter, this);
 
@@ -426,12 +427,12 @@
 
 /*!
-  \brief draw the scale
-*/
-void QwtScaleWidget::draw( QPainter *painter ) const
-{
-    d_data->scaleDraw->draw( painter, palette() );
-
-    if ( d_data->colorBar.isEnabled && d_data->colorBar.width > 0 &&
-        d_data->colorBar.interval.isValid() )
+   \brief draw the scale
+ */
+void QwtScaleWidget::draw( QPainter* painter ) const
+{
+    m_data->scaleDraw->draw( painter, palette() );
+
+    if ( m_data->colorBar.isEnabled && m_data->colorBar.width > 0 &&
+        m_data->colorBar.interval.isValid() )
     {
         drawColorBar( painter, colorBarRect( contentsRect() ) );
@@ -439,47 +440,47 @@
 
     QRect r = contentsRect();
-    if ( d_data->scaleDraw->orientation() == Qt::Horizontal )
-    {
-        r.setLeft( r.left() + d_data->borderDist[0] );
-        r.setWidth( r.width() - d_data->borderDist[1] );
+    if ( m_data->scaleDraw->orientation() == Qt::Horizontal )
+    {
+        r.setLeft( r.left() + m_data->borderDist[0] );
+        r.setWidth( r.width() - m_data->borderDist[1] );
     }
     else
     {
-        r.setTop( r.top() + d_data->borderDist[0] );
-        r.setHeight( r.height() - d_data->borderDist[1] );
-    }
-
-    if ( !d_data->title.isEmpty() )
-        drawTitle( painter, d_data->scaleDraw->alignment(), r );
-}
-
-/*!
-  Calculate the the rectangle for the color bar
-
-  \param rect Bounding rectangle for all components of the scale
-  \return Rectangle for the color bar
-*/
+        r.setTop( r.top() + m_data->borderDist[0] );
+        r.setHeight( r.height() - m_data->borderDist[1] );
+    }
+
+    if ( !m_data->title.isEmpty() )
+        drawTitle( painter, m_data->scaleDraw->alignment(), r );
+}
+
+/*!
+   Calculate the the rectangle for the color bar
+
+   \param rect Bounding rectangle for all components of the scale
+   \return Rectangle for the color bar
+ */
 QRectF QwtScaleWidget::colorBarRect( const QRectF& rect ) const
 {
     QRectF cr = rect;
 
-    if ( d_data->scaleDraw->orientation() == Qt::Horizontal )
-    {
-        cr.setLeft( cr.left() + d_data->borderDist[0] );
-        cr.setWidth( cr.width() - d_data->borderDist[1] + 1 );
+    if ( m_data->scaleDraw->orientation() == Qt::Horizontal )
+    {
+        cr.setLeft( cr.left() + m_data->borderDist[0] );
+        cr.setWidth( cr.width() - m_data->borderDist[1] + 1 );
     }
     else
     {
-        cr.setTop( cr.top() + d_data->borderDist[0] );
-        cr.setHeight( cr.height() - d_data->borderDist[1] + 1 );
-    }
-
-    switch ( d_data->scaleDraw->alignment() )
+        cr.setTop( cr.top() + m_data->borderDist[0] );
+        cr.setHeight( cr.height() - m_data->borderDist[1] + 1 );
+    }
+
+    switch ( m_data->scaleDraw->alignment() )
     {
         case QwtScaleDraw::LeftScale:
         {
-            cr.setLeft( cr.right() - d_data->margin
-                - d_data->colorBar.width );
-            cr.setWidth( d_data->colorBar.width );
+            cr.setLeft( cr.right() - m_data->margin
+                - m_data->colorBar.width );
+            cr.setWidth( m_data->colorBar.width );
             break;
         }
@@ -487,6 +488,6 @@
         case QwtScaleDraw::RightScale:
         {
-            cr.setLeft( cr.left() + d_data->margin );
-            cr.setWidth( d_data->colorBar.width );
+            cr.setLeft( cr.left() + m_data->margin );
+            cr.setWidth( m_data->colorBar.width );
             break;
         }
@@ -494,6 +495,6 @@
         case QwtScaleDraw::BottomScale:
         {
-            cr.setTop( cr.top() + d_data->margin );
-            cr.setHeight( d_data->colorBar.width );
+            cr.setTop( cr.top() + m_data->margin );
+            cr.setHeight( m_data->colorBar.width );
             break;
         }
@@ -501,7 +502,7 @@
         case QwtScaleDraw::TopScale:
         {
-            cr.setTop( cr.bottom() - d_data->margin
-                - d_data->colorBar.width );
-            cr.setHeight( d_data->colorBar.width );
+            cr.setTop( cr.bottom() - m_data->margin
+                - m_data->colorBar.width );
+            cr.setHeight( m_data->colorBar.width );
             break;
         }
@@ -512,8 +513,24 @@
 
 /*!
-  Event handler for resize events
-  \param event Resize event
-*/
-void QwtScaleWidget::resizeEvent( QResizeEvent *event )
+   Change Event handler
+   \param event Change event
+
+   Invalidates internal caches if necessary
+ */
+void QwtScaleWidget::changeEvent( QEvent* event )
+{
+    if ( event->type() == QEvent::LocaleChange )
+    {
+        m_data->scaleDraw->invalidateCache();
+    }
+
+    QWidget::changeEvent( event );
+}
+
+/*!
+   Event handler for resize events
+   \param event Resize event
+ */
+void QwtScaleWidget::resizeEvent( QResizeEvent* event )
 {
     Q_UNUSED( event );
@@ -522,10 +539,10 @@
 
 /*!
-  Recalculate the scale's geometry and layout based on
-  the current geometry and fonts.
-
-  \param update_geometry Notify the layout system and call update
+   Recalculate the scale's geometry and layout based on
+   the current geometry and fonts.
+
+   \param update_geometry Notify the layout system and call update
                          to redraw the scale
-*/
+ */
 
 void QwtScaleWidget::layoutScale( bool update_geometry )
@@ -533,25 +550,25 @@
     int bd0, bd1;
     getBorderDistHint( bd0, bd1 );
-    if ( d_data->borderDist[0] > bd0 )
-        bd0 = d_data->borderDist[0];
-    if ( d_data->borderDist[1] > bd1 )
-        bd1 = d_data->borderDist[1];
+    if ( m_data->borderDist[0] > bd0 )
+        bd0 = m_data->borderDist[0];
+    if ( m_data->borderDist[1] > bd1 )
+        bd1 = m_data->borderDist[1];
 
     int colorBarWidth = 0;
-    if ( d_data->colorBar.isEnabled && d_data->colorBar.interval.isValid() )
-        colorBarWidth = d_data->colorBar.width + d_data->spacing;
+    if ( m_data->colorBar.isEnabled && m_data->colorBar.interval.isValid() )
+        colorBarWidth = m_data->colorBar.width + m_data->spacing;
 
     const QRectF r = contentsRect();
     double x, y, length;
 
-    if ( d_data->scaleDraw->orientation() == Qt::Vertical )
+    if ( m_data->scaleDraw->orientation() == Qt::Vertical )
     {
         y = r.top() + bd0;
         length = r.height() - ( bd0 + bd1 );
 
-        if ( d_data->scaleDraw->alignment() == QwtScaleDraw::LeftScale )
-            x = r.right() - 1.0 - d_data->margin - colorBarWidth;
+        if ( m_data->scaleDraw->alignment() == QwtScaleDraw::LeftScale )
+            x = r.right() - 1.0 - m_data->margin - colorBarWidth;
         else
-            x = r.left() + d_data->margin + colorBarWidth;
+            x = r.left() + m_data->margin + colorBarWidth;
     }
     else
@@ -560,17 +577,17 @@
         length = r.width() - ( bd0 + bd1 );
 
-        if ( d_data->scaleDraw->alignment() == QwtScaleDraw::BottomScale )
-            y = r.top() + d_data->margin + colorBarWidth;
+        if ( m_data->scaleDraw->alignment() == QwtScaleDraw::BottomScale )
+            y = r.top() + m_data->margin + colorBarWidth;
         else
-            y = r.bottom() - 1.0 - d_data->margin - colorBarWidth;
-    }
-
-    d_data->scaleDraw->move( x, y );
-    d_data->scaleDraw->setLength( length );
-
-    const int extent = qCeil( d_data->scaleDraw->extent( font() ) );
-
-    d_data->titleOffset =
-        d_data->margin + d_data->spacing + colorBarWidth + extent;
+            y = r.bottom() - 1.0 - m_data->margin - colorBarWidth;
+    }
+
+    m_data->scaleDraw->move( x, y );
+    m_data->scaleDraw->setLength( length );
+
+    const int extent = qwtCeil( m_data->scaleDraw->extent( font() ) );
+
+    m_data->titleOffset =
+        m_data->margin + m_data->spacing + colorBarWidth + extent;
 
     if ( update_geometry )
@@ -599,37 +616,37 @@
 
 /*!
-  Draw the color bar of the scale widget
-
-  \param painter Painter
-  \param rect Bounding rectangle for the color bar
-
-  \sa setColorBarEnabled()
-*/
-void QwtScaleWidget::drawColorBar( QPainter *painter, const QRectF& rect ) const
-{
-    if ( !d_data->colorBar.interval.isValid() )
+   Draw the color bar of the scale widget
+
+   \param painter Painter
+   \param rect Bounding rectangle for the color bar
+
+   \sa setColorBarEnabled()
+ */
+void QwtScaleWidget::drawColorBar( QPainter* painter, const QRectF& rect ) const
+{
+    if ( !m_data->colorBar.interval.isValid() )
         return;
 
-    const QwtScaleDraw* sd = d_data->scaleDraw;
-
-    QwtPainter::drawColorBar( painter, *d_data->colorBar.colorMap,
-        d_data->colorBar.interval.normalized(), sd->scaleMap(),
+    const QwtScaleDraw* sd = m_data->scaleDraw;
+
+    QwtPainter::drawColorBar( painter, *m_data->colorBar.colorMap,
+        m_data->colorBar.interval.normalized(), sd->scaleMap(),
         sd->orientation(), rect );
 }
 
 /*!
-  Rotate and paint a title according to its position into a given rectangle.
-
-  \param painter Painter
-  \param align Alignment
-  \param rect Bounding rectangle
-*/
-
-void QwtScaleWidget::drawTitle( QPainter *painter,
-    QwtScaleDraw::Alignment align, const QRectF &rect ) const
+   Rotate and paint a title according to its position into a given rectangle.
+
+   \param painter Painter
+   \param align Alignment
+   \param rect Bounding rectangle
+ */
+
+void QwtScaleWidget::drawTitle( QPainter* painter,
+    QwtScaleDraw::Alignment align, const QRectF& rect ) const
 {
     QRectF r = rect;
     double angle;
-    int flags = d_data->title.renderFlags() &
+    int flags = m_data->title.renderFlags() &
         ~( Qt::AlignTop | Qt::AlignBottom | Qt::AlignVCenter );
 
@@ -640,5 +657,5 @@
             flags |= Qt::AlignTop;
             r.setRect( r.left(), r.bottom(),
-                r.height(), r.width() - d_data->titleOffset );
+                r.height(), r.width() - m_data->titleOffset );
             break;
 
@@ -646,6 +663,6 @@
             angle = -90.0;
             flags |= Qt::AlignTop;
-            r.setRect( r.left() + d_data->titleOffset, r.bottom(),
-                r.height(), r.width() - d_data->titleOffset );
+            r.setRect( r.left() + m_data->titleOffset, r.bottom(),
+                r.height(), r.width() - m_data->titleOffset );
             break;
 
@@ -653,5 +670,5 @@
             angle = 0.0;
             flags |= Qt::AlignBottom;
-            r.setTop( r.top() + d_data->titleOffset );
+            r.setTop( r.top() + m_data->titleOffset );
             break;
 
@@ -660,9 +677,9 @@
             angle = 0.0;
             flags |= Qt::AlignTop;
-            r.setBottom( r.bottom() - d_data->titleOffset );
+            r.setBottom( r.bottom() - m_data->titleOffset );
             break;
     }
 
-    if ( d_data->layoutFlags & TitleInverted )
+    if ( m_data->layoutFlags & TitleInverted )
     {
         if ( align == QwtScaleDraw::LeftScale
@@ -683,5 +700,5 @@
         painter->rotate( angle );
 
-    QwtText title = d_data->title;
+    QwtText title = m_data->title;
     title.setRenderFlags( flags );
     title.draw( painter, QRectF( 0.0, 0.0, r.width(), r.height() ) );
@@ -691,10 +708,10 @@
 
 /*!
-  \brief Notify a change of the scale
-
-  This virtual function can be overloaded by derived
-  classes. The default implementation updates the geometry
-  and repaints the widget.
-*/
+   \brief Notify a change of the scale
+
+   This virtual function can be overloaded by derived
+   classes. The default implementation updates the geometry
+   and repaints the widget.
+ */
 
 void QwtScaleWidget::scaleChange()
@@ -704,6 +721,6 @@
 
 /*!
-  \return a size hint
-*/
+   \return a size hint
+ */
 QSize QwtScaleWidget::sizeHint() const
 {
@@ -712,9 +729,9 @@
 
 /*!
-  \return a minimum size hint
-*/
+   \return a minimum size hint
+ */
 QSize QwtScaleWidget::minimumSizeHint() const
 {
-    const Qt::Orientation o = d_data->scaleDraw->orientation();
+    const Qt::Orientation o = m_data->scaleDraw->orientation();
 
     // Border Distance cannot be less than the scale borderDistHint
@@ -723,7 +740,7 @@
     int mbd1, mbd2;
     getBorderDistHint( mbd1, mbd2 );
-    length += qMax( 0, d_data->borderDist[0] - mbd1 );
-    length += qMax( 0, d_data->borderDist[1] - mbd2 );
-    length += d_data->scaleDraw->minLength( font() );
+    length += qMax( 0, m_data->borderDist[0] - mbd1 );
+    length += qMax( 0, m_data->borderDist[1] - mbd2 );
+    length += m_data->scaleDraw->minLength( font() );
 
     int dim = dimForLength( length, font() );
@@ -739,40 +756,39 @@
         size.transpose();
 
-    int left, right, top, bottom;
-    getContentsMargins( &left, &top, &right, &bottom );
-    return size + QSize( left + right, top + bottom );
-}
-
-/*!
-  \brief Find the height of the title for a given width.
-  \param width Width
-  \return height Height
+    const QMargins m = contentsMargins();
+    return size + QSize( m.left() + m.right(), m.top() + m.bottom() );
+}
+
+/*!
+   \brief Find the height of the title for a given width.
+   \param width Width
+   \return height Height
  */
 
 int QwtScaleWidget::titleHeightForWidth( int width ) const
 {
-    return qCeil( d_data->title.heightForWidth( width, font() ) );
-}
-
-/*!
-  \brief Find the minimum dimension for a given length.
+    return qwtCeil( m_data->title.heightForWidth( width, font() ) );
+}
+
+/*!
+   \brief Find the minimum dimension for a given length.
          dim is the height, length the width seen in
          direction of the title.
-  \param length width for horizontal, height for vertical scales
-  \param scaleFont Font of the scale
-  \return height for horizontal, width for vertical scales
-*/
-
-int QwtScaleWidget::dimForLength( int length, const QFont &scaleFont ) const
-{
-    const int extent = qCeil( d_data->scaleDraw->extent( scaleFont ) );
-
-    int dim = d_data->margin + extent + 1;
-
-    if ( !d_data->title.isEmpty() )
-        dim += titleHeightForWidth( length ) + d_data->spacing;
-
-    if ( d_data->colorBar.isEnabled && d_data->colorBar.interval.isValid() )
-        dim += d_data->colorBar.width + d_data->spacing;
+   \param length width for horizontal, height for vertical scales
+   \param scaleFont Font of the scale
+   \return height for horizontal, width for vertical scales
+ */
+
+int QwtScaleWidget::dimForLength( int length, const QFont& scaleFont ) const
+{
+    const int extent = qwtCeil( m_data->scaleDraw->extent( scaleFont ) );
+
+    int dim = m_data->margin + extent + 1;
+
+    if ( !m_data->title.isEmpty() )
+        dim += titleHeightForWidth( length ) + m_data->spacing;
+
+    if ( m_data->colorBar.isEnabled && m_data->colorBar.interval.isValid() )
+        dim += m_data->colorBar.width + m_data->spacing;
 
     return dim;
@@ -780,76 +796,76 @@
 
 /*!
-  \brief Calculate a hint for the border distances.
-
-  This member function calculates the distance
-  of the scale's endpoints from the widget borders which
-  is required for the mark labels to fit into the widget.
-  The maximum of this distance an the minimum border distance
-  is returned.
-
-  \param start Return parameter for the border width at
+   \brief Calculate a hint for the border distances.
+
+   This member function calculates the distance
+   of the scale's endpoints from the widget borders which
+   is required for the mark labels to fit into the widget.
+   The maximum of this distance an the minimum border distance
+   is returned.
+
+   \param start Return parameter for the border width at
                the beginning of the scale
-  \param end Return parameter for the border width at the
+   \param end Return parameter for the border width at the
              end of the scale
 
-  \warning
-  <ul> <li>The minimum border distance depends on the font.</ul>
-  \sa setMinBorderDist(), getMinBorderDist(), setBorderDist()
-*/
-void QwtScaleWidget::getBorderDistHint( int &start, int &end ) const
-{
-    d_data->scaleDraw->getBorderDistHint( font(), start, end );
-
-    if ( start < d_data->minBorderDist[0] )
-        start = d_data->minBorderDist[0];
-
-    if ( end < d_data->minBorderDist[1] )
-        end = d_data->minBorderDist[1];
-}
-
-/*!
-  Set a minimum value for the distances of the scale's endpoints from
-  the widget borders. This is useful to avoid that the scales
-  are "jumping", when the tick labels or their positions change
-  often.
-
-  \param start Minimum for the start border
-  \param end Minimum for the end border
-  \sa getMinBorderDist(), getBorderDistHint()
-*/
+   \warning
+   <ul> <li>The minimum border distance depends on the font.</ul>
+   \sa setMinBorderDist(), getMinBorderDist(), setBorderDist()
+ */
+void QwtScaleWidget::getBorderDistHint( int& start, int& end ) const
+{
+    m_data->scaleDraw->getBorderDistHint( font(), start, end );
+
+    if ( start < m_data->minBorderDist[0] )
+        start = m_data->minBorderDist[0];
+
+    if ( end < m_data->minBorderDist[1] )
+        end = m_data->minBorderDist[1];
+}
+
+/*!
+   Set a minimum value for the distances of the scale's endpoints from
+   the widget borders. This is useful to avoid that the scales
+   are "jumping", when the tick labels or their positions change
+   often.
+
+   \param start Minimum for the start border
+   \param end Minimum for the end border
+   \sa getMinBorderDist(), getBorderDistHint()
+ */
 void QwtScaleWidget::setMinBorderDist( int start, int end )
 {
-    d_data->minBorderDist[0] = start;
-    d_data->minBorderDist[1] = end;
-}
-
-/*!
-  Get the minimum value for the distances of the scale's endpoints from
-  the widget borders.
-
-  \param start Return parameter for the border width at
+    m_data->minBorderDist[0] = start;
+    m_data->minBorderDist[1] = end;
+}
+
+/*!
+   Get the minimum value for the distances of the scale's endpoints from
+   the widget borders.
+
+   \param start Return parameter for the border width at
                the beginning of the scale
-  \param end Return parameter for the border width at the
+   \param end Return parameter for the border width at the
              end of the scale
 
-  \sa setMinBorderDist(), getBorderDistHint()
-*/
-void QwtScaleWidget::getMinBorderDist( int &start, int &end ) const
-{
-    start = d_data->minBorderDist[0];
-    end = d_data->minBorderDist[1];
-}
-
-/*!
-  \brief Assign a scale division
-
-  The scale division determines where to set the tick marks.
-
-  \param scaleDiv Scale Division
-  \sa For more information about scale divisions, see QwtScaleDiv.
-*/
-void QwtScaleWidget::setScaleDiv( const QwtScaleDiv &scaleDiv )
-{
-    QwtScaleDraw *sd = d_data->scaleDraw;
+   \sa setMinBorderDist(), getBorderDistHint()
+ */
+void QwtScaleWidget::getMinBorderDist( int& start, int& end ) const
+{
+    start = m_data->minBorderDist[0];
+    end = m_data->minBorderDist[1];
+}
+
+/*!
+   \brief Assign a scale division
+
+   The scale division determines where to set the tick marks.
+
+   \param scaleDiv Scale Division
+   \sa For more information about scale divisions, see QwtScaleDiv.
+ */
+void QwtScaleWidget::setScaleDiv( const QwtScaleDiv& scaleDiv )
+{
+    QwtScaleDraw* sd = m_data->scaleDraw;
     if ( sd->scaleDiv() != scaleDiv )
     {
@@ -862,24 +878,24 @@
 
 /*!
-  Set the transformation
-
-  \param transformation Transformation
-  \sa QwtAbstractScaleDraw::scaleDraw(), QwtScaleMap
- */
-void QwtScaleWidget::setTransformation( QwtTransform *transformation )
-{
-    d_data->scaleDraw->setTransformation( transformation );
+   Set the transformation
+
+   \param transformation Transformation
+   \sa QwtAbstractScaleDraw::scaleDraw(), QwtScaleMap
+ */
+void QwtScaleWidget::setTransformation( QwtTransform* transformation )
+{
+    m_data->scaleDraw->setTransformation( transformation );
     layoutScale();
 }
 
 /*!
-  En/disable a color bar associated to the scale
-  \sa isColorBarEnabled(), setColorBarWidth()
-*/
+   En/disable a color bar associated to the scale
+   \sa isColorBarEnabled(), setColorBarWidth()
+ */
 void QwtScaleWidget::setColorBarEnabled( bool on )
 {
-    if ( on != d_data->colorBar.isEnabled )
-    {
-        d_data->colorBar.isEnabled = on;
+    if ( on != m_data->colorBar.isEnabled )
+    {
+        m_data->colorBar.isEnabled = on;
         layoutScale();
     }
@@ -887,23 +903,23 @@
 
 /*!
-  \return true, when the color bar is enabled
-  \sa setColorBarEnabled(), setColorBarWidth()
-*/
+   \return true, when the color bar is enabled
+   \sa setColorBarEnabled(), setColorBarWidth()
+ */
 bool QwtScaleWidget::isColorBarEnabled() const
 {
-    return d_data->colorBar.isEnabled;
-}
-
-/*!
-  Set the width of the color bar
-
-  \param width Width
-  \sa colorBarWidth(), setColorBarEnabled()
-*/
+    return m_data->colorBar.isEnabled;
+}
+
+/*!
+   Set the width of the color bar
+
+   \param width Width
+   \sa colorBarWidth(), setColorBarEnabled()
+ */
 void QwtScaleWidget::setColorBarWidth( int width )
 {
-    if ( width != d_data->colorBar.width )
-    {
-        d_data->colorBar.width = width;
+    if ( width != m_data->colorBar.width )
+    {
+        m_data->colorBar.width = width;
         if ( isColorBarEnabled() )
             layoutScale();
@@ -912,39 +928,39 @@
 
 /*!
-  \return Width of the color bar
-  \sa setColorBarEnabled(), setColorBarEnabled()
-*/
+   \return Width of the color bar
+   \sa setColorBarEnabled(), setColorBarEnabled()
+ */
 int QwtScaleWidget::colorBarWidth() const
 {
-    return d_data->colorBar.width;
-}
-
-/*!
-  \return Value interval for the color bar
-  \sa setColorMap(), colorMap()
-*/
+    return m_data->colorBar.width;
+}
+
+/*!
+   \return Value interval for the color bar
+   \sa setColorMap(), colorMap()
+ */
 QwtInterval QwtScaleWidget::colorBarInterval() const
 {
-    return d_data->colorBar.interval;
-}
-
-/*!
-  Set the color map and value interval, that are used for displaying
-  the color bar.
-
-  \param interval Value interval
-  \param colorMap Color map
-
-  \sa colorMap(), colorBarInterval()
-*/
+    return m_data->colorBar.interval;
+}
+
+/*!
+   Set the color map and value interval, that are used for displaying
+   the color bar.
+
+   \param interval Value interval
+   \param colorMap Color map
+
+   \sa colorMap(), colorBarInterval()
+ */
 void QwtScaleWidget::setColorMap(
-    const QwtInterval &interval, QwtColorMap *colorMap )
-{
-    d_data->colorBar.interval = interval;
-
-    if ( colorMap != d_data->colorBar.colorMap )
-    {
-        delete d_data->colorBar.colorMap;
-        d_data->colorBar.colorMap = colorMap;
+    const QwtInterval& interval, QwtColorMap* colorMap )
+{
+    m_data->colorBar.interval = interval;
+
+    if ( colorMap != m_data->colorBar.colorMap )
+    {
+        delete m_data->colorBar.colorMap;
+        m_data->colorBar.colorMap = colorMap;
     }
 
@@ -954,9 +970,11 @@
 
 /*!
-  \return Color map
-  \sa setColorMap(), colorBarInterval()
-*/
-const QwtColorMap *QwtScaleWidget::colorMap() const
-{
-    return d_data->colorBar.colorMap;
-}
+   \return Color map
+   \sa setColorMap(), colorBarInterval()
+ */
+const QwtColorMap* QwtScaleWidget::colorMap() const
+{
+    return m_data->colorBar.colorMap;
+}
+
+#include "moc_qwt_scale_widget.cpp"
