[89] | 1 | /* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
|
---|
| 2 | * Qwt Widget Library
|
---|
| 3 | * Copyright (C) 1997 Josef Wilgen
|
---|
| 4 | * Copyright (C) 2002 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 | #ifndef QWT_SCALE_WIDGET_H
|
---|
| 11 | #define QWT_SCALE_WIDGET_H
|
---|
| 12 |
|
---|
| 13 | #include <qwidget.h>
|
---|
| 14 | #include <qfont.h>
|
---|
| 15 | #include <qcolor.h>
|
---|
| 16 | #include <qstring.h>
|
---|
| 17 |
|
---|
| 18 | #include "qwt_global.h"
|
---|
| 19 | #include "qwt_text.h"
|
---|
| 20 | #include "qwt_scale_draw.h"
|
---|
| 21 |
|
---|
| 22 | class QPainter;
|
---|
| 23 | class QwtScaleTransformation;
|
---|
| 24 | class QwtScaleDiv;
|
---|
| 25 | class QwtColorMap;
|
---|
| 26 |
|
---|
| 27 | /*!
|
---|
| 28 | \brief A Widget which contains a scale
|
---|
| 29 |
|
---|
| 30 | This Widget can be used to decorate composite widgets with
|
---|
| 31 | a scale.
|
---|
| 32 | */
|
---|
| 33 |
|
---|
| 34 | class QWT_EXPORT QwtScaleWidget : public QWidget
|
---|
| 35 | {
|
---|
| 36 | Q_OBJECT
|
---|
| 37 |
|
---|
| 38 | public:
|
---|
| 39 | explicit QwtScaleWidget(QWidget *parent = NULL);
|
---|
| 40 | #if QT_VERSION < 0x040000
|
---|
| 41 | explicit QwtScaleWidget(QWidget *parent, const char *name);
|
---|
| 42 | #endif
|
---|
| 43 | explicit QwtScaleWidget(QwtScaleDraw::Alignment, QWidget *parent = NULL);
|
---|
| 44 | virtual ~QwtScaleWidget();
|
---|
| 45 |
|
---|
| 46 | signals:
|
---|
| 47 | //! Signal emitted, whenever the scale divison changes
|
---|
| 48 | void scaleDivChanged();
|
---|
| 49 |
|
---|
| 50 | public:
|
---|
| 51 | void setTitle(const QString &title);
|
---|
| 52 | void setTitle(const QwtText &title);
|
---|
| 53 | QwtText title() const;
|
---|
| 54 |
|
---|
| 55 | void setBorderDist(int start, int end);
|
---|
| 56 | int startBorderDist() const;
|
---|
| 57 | int endBorderDist() const;
|
---|
| 58 |
|
---|
| 59 | void getBorderDistHint(int &start, int &end) const;
|
---|
| 60 |
|
---|
| 61 | void getMinBorderDist(int &start, int &end) const;
|
---|
| 62 | void setMinBorderDist(int start, int end);
|
---|
| 63 |
|
---|
| 64 | void setMargin(int);
|
---|
| 65 | int margin() const;
|
---|
| 66 |
|
---|
| 67 | void setSpacing(int td);
|
---|
| 68 | int spacing() const;
|
---|
| 69 |
|
---|
| 70 | void setPenWidth(int);
|
---|
| 71 | int penWidth() const;
|
---|
| 72 |
|
---|
| 73 | void setScaleDiv(QwtScaleTransformation *, const QwtScaleDiv &sd);
|
---|
| 74 |
|
---|
| 75 | void setScaleDraw(QwtScaleDraw *);
|
---|
| 76 | const QwtScaleDraw *scaleDraw() const;
|
---|
| 77 | QwtScaleDraw *scaleDraw();
|
---|
| 78 |
|
---|
| 79 | #if QT_VERSION < 0x040000
|
---|
| 80 | void setLabelAlignment(int);
|
---|
| 81 | #else
|
---|
| 82 | void setLabelAlignment(Qt::Alignment);
|
---|
| 83 | #endif
|
---|
| 84 | void setLabelRotation(double rotation);
|
---|
| 85 |
|
---|
| 86 | void setColorBarEnabled(bool);
|
---|
| 87 | bool isColorBarEnabled() const;
|
---|
| 88 |
|
---|
| 89 | void setColorBarWidth(int);
|
---|
| 90 | int colorBarWidth() const;
|
---|
| 91 |
|
---|
| 92 | void setColorMap(const QwtDoubleInterval &, const QwtColorMap &);
|
---|
| 93 |
|
---|
| 94 | QwtDoubleInterval colorBarInterval() const;
|
---|
| 95 | const QwtColorMap &colorMap() const;
|
---|
| 96 |
|
---|
| 97 | virtual QSize sizeHint() const;
|
---|
| 98 | virtual QSize minimumSizeHint() const;
|
---|
| 99 |
|
---|
| 100 | int titleHeightForWidth(int width) const;
|
---|
| 101 | int dimForLength(int length, const QFont &scaleFont) const;
|
---|
| 102 |
|
---|
| 103 | void drawColorBar(QPainter *painter, const QRect &rect) const;
|
---|
| 104 | void drawTitle(QPainter *painter, QwtScaleDraw::Alignment,
|
---|
| 105 | const QRect &rect) const;
|
---|
| 106 |
|
---|
| 107 | void setAlignment(QwtScaleDraw::Alignment);
|
---|
| 108 | QwtScaleDraw::Alignment alignment() const;
|
---|
| 109 |
|
---|
| 110 | QRect colorBarRect(const QRect&) const;
|
---|
| 111 |
|
---|
| 112 | protected:
|
---|
| 113 | virtual void paintEvent(QPaintEvent *e);
|
---|
| 114 | virtual void resizeEvent(QResizeEvent *e);
|
---|
| 115 |
|
---|
| 116 | #if QT_VERSION < 0x040000
|
---|
| 117 | virtual void fontChange(const QFont &oldfont);
|
---|
| 118 | #endif
|
---|
| 119 |
|
---|
| 120 | void draw(QPainter *p) const;
|
---|
| 121 |
|
---|
| 122 | void scaleChange();
|
---|
| 123 | void layoutScale( bool update = true );
|
---|
| 124 |
|
---|
| 125 | private:
|
---|
| 126 | void initScale(QwtScaleDraw::Alignment);
|
---|
| 127 |
|
---|
| 128 | class PrivateData;
|
---|
| 129 | PrivateData *d_data;
|
---|
| 130 | };
|
---|
| 131 |
|
---|
| 132 | #endif
|
---|