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

qwt_thermo.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_THERMO_H
00011 #define QWT_THERMO_H
00012 
00013 #include <qwidget.h>
00014 #include <qcolor.h>
00015 #include <qfont.h>
00016 #include <qrect.h>
00017 #include "qwt_global.h"
00018 #include "qwt_dimap.h"
00019 #include "qwt_scldraw.h"
00020 #include "qwt_sclif.h"
00021 
00022 
00033 class QWT_EXPORT QwtThermo: public QWidget, public QwtScaleIf
00034 {
00035     Q_OBJECT
00036 
00037     Q_ENUMS( ScalePos )
00038 
00039     Q_PROPERTY( QColor alarmColor READ alarmColor WRITE setAlarmColor )
00040     Q_PROPERTY( bool alarmEnabled READ alarmEnabled WRITE setAlarmEnabled )
00041     Q_PROPERTY( double alarmLevel READ alarmLevel WRITE setAlarmLevel )
00042     Q_PROPERTY( ScalePos scalePosition READ scalePosition
00043         WRITE setScalePosition )
00044     Q_PROPERTY( int borderWidth READ borderWidth WRITE setBorderWidth )
00045     Q_PROPERTY( QColor fillColor READ fillColor WRITE setFillColor )
00046     Q_PROPERTY( double maxValue READ maxValue WRITE setMaxValue )
00047     Q_PROPERTY( double minValue READ minValue WRITE setMinValue )
00048     Q_PROPERTY( int pipeWidth READ pipeWidth WRITE setPipeWidth )
00049     Q_PROPERTY( double value READ value WRITE setValue )
00050 
00051 public:
00052     /*
00053       Scale position. QwtSlider tries to enforce valid combinations of its
00054       orientation and scale position:
00055       - Qt::Horizonal combines with None, Top and Bottom
00056       - Qt::Vertical combines with None, Left and Right
00057       
00058       \sa QwtThermo::setOrientation, QwtThermo::setScalePosition
00059     */
00060     enum ScalePos {None, Left, Right, Top, Bottom};
00061 
00062     QwtThermo(QWidget *parent = 0, const char *name = 0);
00063     virtual ~QwtThermo();
00064 
00065     void setOrientation(Qt::Orientation o, ScalePos s);
00066 
00067     void setScalePosition(ScalePos s);
00068     ScalePos scalePosition() const;
00069 
00070     void setBorderWidth(int w);
00071     int borderWidth() const;
00072 
00073     void setFillColor(const QColor &c);
00074     const QColor &fillColor() const;
00075  
00076     void setAlarmColor(const QColor &c);
00077     const QColor &alarmColor() const;
00078 
00079     void setAlarmLevel(double v);
00080     double alarmLevel() const;
00081 
00082     void setAlarmEnabled(bool tf);
00083     bool alarmEnabled() const;
00084 
00085     void setPipeWidth(int w);
00086     int pipeWidth() const;
00087 
00089     void setMaxValue(double v) { setRange(d_minValue, v); }
00091     double maxValue() const { return d_maxValue; }
00092 
00094     void setMinValue(double v) { setRange(v, d_maxValue); }
00096     double minValue() const { return d_minValue; }
00097 
00099     double value() const { return d_value; }
00100 
00101     void setRange(double vmin, double vmax);
00102     void setMargin(int m);
00103 
00104     virtual QSize sizeHint() const;
00105     virtual QSize minimumSizeHint() const;
00106     virtual QSizePolicy sizePolicy() const;
00107 
00108 public slots:
00109     void setValue(double val);
00110     
00111 protected:
00112     void draw(QPainter *p, const QRect& update_rect);
00113     void drawThermo(QPainter *p);
00114     void layoutThermo( bool update = TRUE );
00115     virtual void scaleChange();
00116     virtual void fontChange(const QFont &oldFont);
00117 
00118     virtual void paintEvent(QPaintEvent *e);
00119     virtual void resizeEvent(QResizeEvent *e);
00120 
00121 private:
00122     void init();
00123     
00124     QwtDiMap d_map;
00125     QRect d_thermoRect;
00126     QColor d_fillColor;
00127     QColor d_alarmColor;
00128     
00129     Qt::Orientation d_orient;
00130     ScalePos d_scalePos;
00131     int d_borderWidth;
00132     int d_scaleDist;
00133     int d_thermoWidth;
00134 
00135     double d_minValue;
00136     double d_maxValue;
00137     double d_value;
00138     double d_alarmLevel;
00139     bool d_alarmEnabled;
00140 };
00141 
00142 #endif
00143 
00144 // Local Variables:
00145 // mode: C++
00146 // c-file-style: "stroustrup"
00147 // indent-tabs-mode: nil
00148 // End:

Generated on Sun Sep 26 23:24:38 2004 for Qwt User's Guide by doxygen 1.3.6