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

qwt_slider.h

Go to the documentation of this file.
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_SLIDER_H
00011 #define QWT_SLIDER_H
00012 
00013 #include "qwt_global.h"
00014 #include "qwt_sclif.h"
00015 #include "qwt_sldbase.h"
00016 
00027 class QWT_EXPORT QwtSlider : public QwtSliderBase, public QwtScaleIf
00028 {
00029     Q_OBJECT
00030     Q_ENUMS( ScalePos )
00031     Q_ENUMS( BGSTYLE )
00032     Q_PROPERTY( int thumbLength READ thumbLength WRITE setThumbLength )
00033     Q_PROPERTY( int thumbWidth READ thumbWidth WRITE setThumbWidth )
00034     Q_PROPERTY( int borderWidth READ borderWidth WRITE setBorderWidth )
00035     Q_PROPERTY( BGSTYLE bgStyle READ bgStyle WRITE setBgStyle )
00036     Q_PROPERTY( ScalePos scalePos READ scalePos WRITE setScalePos )
00037 
00038  
00039 public:
00040 
00045     enum ScalePos { None, Left, Right, Top, Bottom };
00046 
00051     enum BGSTYLE { BgTrough = 0x1, BgSlot = 0x2, BgBoth = BgTrough | BgSlot};
00052 
00053     QwtSlider(QWidget *parent, const char *name = 0,
00054           Qt::Orientation = Horizontal,
00055           ScalePos = None, int bgStyle = BgTrough);
00056     
00057     virtual void setOrientation(Qt::Orientation); 
00058 
00059     void setBgStyle(BGSTYLE st) {d_bgStyle = st; layoutSlider();}
00060     BGSTYLE bgStyle() const {return BGSTYLE(d_bgStyle);}
00061         
00062     void setScalePos(ScalePos st) {d_scalePos = st; layoutSlider();}
00063     ScalePos scalePos() const {return ScalePos(d_scalePos);}
00064 
00065     int thumbLength() const {return d_thumbLength;}
00066     int thumbWidth() const {return d_thumbWidth;}
00067     int borderWidth() const {return d_borderWidth;}
00068 
00069     void setThumbLength(int l);
00070     void setThumbWidth(int w);
00071     void setBorderWidth(int bw);
00072     void setMargins(int x, int y);
00073 
00074     virtual QSize sizeHint() const;
00075     virtual QSize minimumSizeHint() const;
00076     virtual QSizePolicy sizePolicy() const;
00077     
00078 protected:
00079     virtual double getValue(const QPoint &p);
00080     virtual void getScrollMode(const QPoint &p, 
00081         int &scrollMode, int &direction);
00082 
00083     void draw(QPainter *p, const QRect& update_rect);
00084     virtual void drawSlider (QPainter *p, const QRect &r);
00085     virtual void drawThumb(QPainter *p, const QRect &, int pos);
00086 
00087     virtual void resizeEvent(QResizeEvent *e);
00088     virtual void paintEvent (QPaintEvent *e);
00089 
00090     virtual void valueChange();
00091     virtual void rangeChange();
00092     virtual void scaleChange();
00093     virtual void fontChange(const QFont &oldFont);
00094 
00095     void layoutSlider( bool update = TRUE );
00096     int xyPosition(double v) const;
00097 
00098 private:
00099     QRect d_sliderRect;
00100 
00101     int d_thumbLength;
00102     int d_thumbWidth;
00103     int d_borderWidth;
00104     int d_scaleDist;
00105     int d_xMargin;
00106     int d_yMargin;
00107     
00108     ScalePos d_scalePos;
00109     int d_bgStyle;
00110 };
00111 
00112 #endif

Generated on Fri Nov 7 14:11:46 2003 for Qwt Developer's Guide by doxygen 1.3.2