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

# qwt_knob.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_KNOB_H
    00011 #define QWT_KNOB_H
    00012
    00013 #include "qwt_global.h"
    00014 #include "qwt_sldbase.h"
    00015 #include "qwt_sclif.h"
    00016
    00032 class QWT_EXPORT QwtKnob : public QwtSliderBase, public QwtScaleIf
    00033 {
    00034     Q_OBJECT
    00035     Q_ENUMS (Symbol)
    00036     Q_PROPERTY( int knobWidth READ knobWidth WRITE setKnobWidth )
    00037     Q_PROPERTY( int borderWidth READ borderWidth WRITE setBorderWidth )
    00038     Q_PROPERTY( double totalAngle READ totalAngle WRITE setTotalAngle )
    00039     Q_PROPERTY( Symbol symbol READ symbol WRITE setSymbol )
    00040
    00041 public:
    00047     enum Symbol { Line, Dot };
    00048
    00049     QwtKnob(QWidget* parent = 0, const char *name = 0);
    00050     virtual ~QwtKnob();
    00051
    00052     void setKnobWidth(int w);
    00053     void setTotalAngle (double angle);
    00054     void setBorderWidth(int bw);
    00055
    00057     int knobWidth() const {return d_knobWidth;};
    00059     double totalAngle() const {return d_totalAngle;};
    00061     int borderWidth() const {return d_borderWidth;};
    00062
    00063     void setSymbol(Symbol);
    00064     Symbol symbol() const;
    00065
    00066     virtual QSize sizeHint() const;
    00067     virtual QSize minimumSizeHint() const;
    00068
    00069 protected:
    00070     virtual void paintEvent(QPaintEvent *e);
    00071     virtual void resizeEvent(QResizeEvent *e);
    00072
    00073     void draw(QPainter *p, const QRect& ur);
    00074     void drawKnob(QPainter *p, const QRect &r);
    00075     void drawMarker(QPainter *p, double arc, const QColor &c);
    00076
    00077 private:
    00078     void layoutKnob( bool update = TRUE );
    00079     double getValue(const QPoint &p);
    00080     void getScrollMode( const QPoint &p, int &scrollMode, int &direction );
    00081     void recalcAngle();
    00082
    00083     virtual void valueChange();
    00084     virtual void rangeChange();
    00085     virtual void scaleChange();
    00086     virtual void fontChange(const QFont &oldFont);
    00087
    00088     int d_borderWidth;
    00089     int d_borderDist;
    00090     int d_hasScale;
    00091     int d_scaleDist;
    00092     int d_maxScaleTicks;
    00093     int d_knobWidth;
    00094     int d_dotWidth;
    00095
    00096     Symbol d_symbol;
    00097     double d_angle;
    00098     double d_oldAngle;
    00099     double d_totalAngle;
    00100     double d_nTurns;
    00101
    00102     QRect d_kRect;
    00103 };
    00104
    00105 #endif
    00106
    00107 // Local Variables:
    00108 // mode: C++
    00109 // c-file-style: "stroustrup"
    00110 // indent-tabs-mode: nil
    00111 // End: