Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

# qwt_scale.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 // vim: expandtab
    00011
    00012 #ifndef QWT_SCALE_H
    00013 #define QWT_SCALE_H
    00014
    00015 #include <qwidget.h>
    00016 #include <qfont.h>
    00017 #include <qcolor.h>
    00018 #include <qstring.h>
    00019
    00020 #include "qwt_global.h"
    00021 #include "qwt_scldiv.h"
    00022 #include "qwt_scldraw.h"
    00023
    00024 class QPainter;
    00025 class QwtText;
    00026
    00034 class QWT_EXPORT QwtScale : public QWidget
    00035 {
    00036     Q_OBJECT
    00037     Q_ENUMS(Position)
    00038     Q_PROPERTY( Position position READ position WRITE setPosition )
    00039     Q_PROPERTY( QString title READ title WRITE setTitle )
    00040     Q_PROPERTY( QFont titleFont READ titleFont WRITE setTitleFont )
    00041     Q_PROPERTY( QColor titleColor READ titleColor WRITE setTitleColor )
    00042
    00043 public:
    00049     enum Position { Left, Right, Top, Bottom };
    00050
    00051     QwtScale(QWidget *parent = 0, const char *name = 0);
    00052     QwtScale(Position, QWidget *parent = 0, const char *name = 0);
    00053     virtual ~QwtScale();
    00054
    00055     void setTitle(const QString &title);
    00056     const QString title() const;
    00057
    00058     void setTitleColor(const QColor &c);
    00059     const QColor titleColor() const;
    00060
    00061     void setTitleFont(const QFont &f);
    00062     const QFont titleFont() const;
    00063
    00064     void setTitleAlignment(int flags);
    00065     int titleAlignment() const;
    00066
    00067     void setBorderDist(int start, int end);
    00068     int startBorderDist() const;
    00069     int endBorderDist() const;
    00070     void minBorderDist(int &start, int &end) const;
    00071
    00072     void setBaselineDist(int bd);
    00073     int baseLineDist() const;
    00074
    00075     void setTitleDist(int td);
    00076     int titleDist() const;
    00077
    00078     void setScaleDiv(const QwtScaleDiv &sd);
    00079     void setScaleDraw(QwtScaleDraw *);
    00080     const QwtScaleDraw *scaleDraw() const;
    00081
    00082     void setLabelFormat(char f, int prec, int fieldWidth);
    00083     void labelFormat(char &f, int &prec, int &fieldWidth) const;
    00084
    00085     void setLabelAlignment(int align);
    00086     void setLabelRotation(double rotation);
    00087
    00088     virtual QSize sizeHint() const;
    00089     virtual QSize minimumSizeHint() const;
    00090     virtual QSizePolicy sizePolicy() const;
    00091
    00092     int titleHeightForWidth(int width) const;
    00093     int dimForLength(int length, const QFontMetrics &scaleFontMetrics ) const;
    00094
    00095     void drawTitle(QPainter *painter, QwtScaleDraw::Orientation o,
    00096         const QRect &rect) const;
    00097
    00098     void setPosition(Position o);
    00099     Position position() const;
    00100
    00101 protected:
    00102     void draw(QPainter *p) const;
    00103     void paintEvent(QPaintEvent *e);
    00104     void resizeEvent(QResizeEvent *e);
    00105     void scaleChange();
    00106     void fontChange(const QFont &oldfont);
    00107     void layoutScale( bool update = TRUE );
    00108
    00109 private:
    00110     void initScale(Position);
    00111
    00112     QwtScaleDraw *d_scaleDraw;
    00113
    00114     int d_borderDist[2];
    00115     int d_scaleLength;
    00116     int d_baseDist;
    00117
    00118     int d_titleOffset;
    00119     int d_titleDist;
    00120     QwtText *d_title;
    00121 };
    00122
    00123 #endif