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

# qwt_slider.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_SLIDER_H
    00013 #define QWT_SLIDER_H
    00014
    00015 #include "qwt_global.h"
    00016 #include "qwt_sclif.h"
    00017 #include "qwt_sldbase.h"
    00018
    00029 class QWT_EXPORT QwtSlider : public QwtSliderBase, public QwtScaleIf
    00030 {
    00031     Q_OBJECT
    00032     Q_ENUMS( ScalePos )
    00033     Q_ENUMS( BGSTYLE )
    00034     Q_PROPERTY( ScalePos scalePosition READ scalePosition
    00035     WRITE setScalePosition )
    00036     Q_PROPERTY( BGSTYLE bgStyle READ bgStyle WRITE setBgStyle )
    00037     Q_PROPERTY( int thumbLength READ thumbLength WRITE setThumbLength )
    00038     Q_PROPERTY( int thumbWidth READ thumbWidth WRITE setThumbWidth )
    00039     Q_PROPERTY( int borderWidth READ borderWidth WRITE setBorderWidth )
    00040
    00041 public:
    00042
    00051     enum ScalePos { None, Left, Right, Top, Bottom };
    00052
    00057     enum BGSTYLE { BgTrough = 0x1, BgSlot = 0x2, BgBoth = BgTrough | BgSlot};
    00058
    00059     QwtSlider(QWidget *parent, const char *name = 0,
    00060           Qt::Orientation = Qt::Horizontal,
    00061           ScalePos = None, BGSTYLE bgStyle = BgTrough);
    00062
    00063     virtual void setOrientation(Qt::Orientation);
    00064
    00068     void setBgStyle(BGSTYLE st) {d_bgStyle = st; layoutSlider();}
    00072     BGSTYLE bgStyle() const { return d_bgStyle; }
    00073
    00077     void setScalePos(ScalePos s) { setScalePosition(s); }
    00081     ScalePos scalePos() const { return d_scalePos; }
    00082
    00083     void setScalePosition(ScalePos s);
    00084     ScalePos scalePosition() const;
    00085
    00089     int thumbLength() const {return d_thumbLength;}
    00093     int thumbWidth() const {return d_thumbWidth;}
    00097     int borderWidth() const {return d_borderWidth;}
    00098
    00099     void setThumbLength(int l);
    00100     void setThumbWidth(int w);
    00101     void setBorderWidth(int bw);
    00102     void setMargins(int x, int y);
    00103
    00104     virtual QSize sizeHint() const;
    00105     virtual QSize minimumSizeHint() const;
    00106     virtual QSizePolicy sizePolicy() const;
    00107
    00108 protected:
    00109     virtual double getValue(const QPoint &p);
    00110     virtual void getScrollMode(const QPoint &p,
    00111         int &scrollMode, int &direction);
    00112
    00113     void draw(QPainter *p, const QRect& update_rect);
    00114     virtual void drawSlider (QPainter *p, const QRect &r);
    00115     virtual void drawThumb(QPainter *p, const QRect &, int pos);
    00116
    00117     virtual void resizeEvent(QResizeEvent *e);
    00118     virtual void paintEvent (QPaintEvent *e);
    00119
    00120     virtual void valueChange();
    00121     virtual void rangeChange();
    00122     virtual void scaleChange();
    00123     virtual void fontChange(const QFont &oldFont);
    00124
    00125     void layoutSlider( bool update = TRUE );
    00126     int xyPosition(double v) const;
    00127
    00128 private:
    00129     QRect d_sliderRect;
    00130
    00131     int d_thumbLength;
    00132     int d_thumbWidth;
    00133     int d_borderWidth;
    00134     int d_scaleDist;
    00135     int d_xMargin;
    00136     int d_yMargin;
    00137
    00138     ScalePos d_scalePos;
    00139     BGSTYLE d_bgStyle;
    00140 };
    00141
    00142 #endif
    00143
    00144 // Local Variables:
    00145 // mode: C++
    00146 // c-file-style: "stroustrup"
    00147 // indent-tabs-mode: nil
    00148 // End: