# qwt_scale_widget.h

    00001 /* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
    00002  * Qwt Widget Library
    00003  * Copyright (C) 1997   Josef Wilgen
    00004  * Copyright (C) 2002   Uwe Rathmann
    00005  *
    00006  * This library is free software; you can redistribute it and/or
    00007  * modify it under the terms of the Qwt License, Version 1.0
    00008  *****************************************************************************/
    00009
    00010 #ifndef QWT_SCALE_WIDGET_H
    00011 #define QWT_SCALE_WIDGET_H
    00012
    00013 #include "qwt_global.h"
    00014 #include "qwt_text.h"
    00015 #include "qwt_scale_draw.h"
    00016 #include <qwidget.h>
    00017 #include <qfont.h>
    00018 #include <qcolor.h>
    00019 #include <qstring.h>
    00020
    00021 class QPainter;
    00022 class QwtScaleTransformation;
    00023 class QwtScaleDiv;
    00024 class QwtColorMap;
    00025
    00033 class QWT_EXPORT QwtScaleWidget : public QWidget
    00034 {
    00035     Q_OBJECT
    00036
    00037 public:
    00039     enum LayoutFlag
    00040     {
    00045         TitleInverted = 1
    00046     };
    00047
    00049     typedef QFlags<LayoutFlag> LayoutFlags;
    00050
    00051     explicit QwtScaleWidget( QWidget *parent = NULL );
    00052     explicit QwtScaleWidget( QwtScaleDraw::Alignment, QWidget *parent = NULL );
    00053     virtual ~QwtScaleWidget();
    00054
    00055 Q_SIGNALS:
    00057     void scaleDivChanged();
    00058
    00059 public:
    00060     void setTitle( const QString &title );
    00061     void setTitle( const QwtText &title );
    00062     QwtText title() const;
    00063
    00064     void setLayoutFlag( LayoutFlag, bool on );
    00065     bool testLayoutFlag( LayoutFlag ) const;
    00066
    00067     void setBorderDist( int start, int end );
    00068     int startBorderDist() const;
    00069     int endBorderDist() const;
    00070
    00071     void getBorderDistHint( int &start, int &end ) const;
    00072
    00073     void getMinBorderDist( int &start, int &end ) const;
    00074     void setMinBorderDist( int start, int end );
    00075
    00076     void setMargin( int );
    00077     int margin() const;
    00078
    00079     void setSpacing( int td );
    00080     int spacing() const;
    00081
    00082     void setScaleDiv( QwtScaleTransformation *, const QwtScaleDiv &sd );
    00083
    00084     void setScaleDraw( QwtScaleDraw * );
    00085     const QwtScaleDraw *scaleDraw() const;
    00086     QwtScaleDraw *scaleDraw();
    00087
    00088     void setLabelAlignment( Qt::Alignment );
    00089     void setLabelRotation( double rotation );
    00090
    00091     void setColorBarEnabled( bool );
    00092     bool isColorBarEnabled() const;
    00093
    00094     void setColorBarWidth( int );
    00095     int colorBarWidth() const;
    00096
    00097     void setColorMap( const QwtInterval &, QwtColorMap * );
    00098
    00099     QwtInterval colorBarInterval() const;
    00100     const QwtColorMap *colorMap() const;
    00101
    00102     virtual QSize sizeHint() const;
    00103     virtual QSize minimumSizeHint() const;
    00104
    00105     int titleHeightForWidth( int width ) const;
    00106     int dimForLength( int length, const QFont &scaleFont ) const;
    00107
    00108     void drawColorBar( QPainter *painter, const QRectF & ) const;
    00109     void drawTitle( QPainter *painter, QwtScaleDraw::Alignment,
    00110         const QRectF &rect ) const;
    00111
    00112     void setAlignment( QwtScaleDraw::Alignment );
    00113     QwtScaleDraw::Alignment alignment() const;
    00114
    00115     QRectF colorBarRect( const QRectF& ) const;
    00116
    00117 protected:
    00118     virtual void paintEvent( QPaintEvent * );
    00119     virtual void resizeEvent( QResizeEvent * );
    00120
    00121     void draw( QPainter *p ) const;
    00122
    00123     void scaleChange();
    00124     void layoutScale( bool update = true );
    00125
    00126 private:
    00127     void initScale( QwtScaleDraw::Alignment );
    00128
    00129     class PrivateData;
    00130     PrivateData *d_data;
    00131 };
    00132
    00133 Q_DECLARE_OPERATORS_FOR_FLAGS( QwtScaleWidget::LayoutFlags )
    00134
    00135 #endif