Qwt User's Guide
|
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_abstract_slider.h" 00015 00016 class QwtScaleDraw; 00017 00030 class QWT_EXPORT QwtSlider: public QwtAbstractSlider 00031 { 00032 Q_OBJECT 00033 00034 Q_ENUMS( ScalePosition BackgroundStyle ) 00035 00036 Q_PROPERTY( Qt::Orientation orientation 00037 READ orientation WRITE setOrientation ) 00038 Q_PROPERTY( ScalePosition scalePosition READ scalePosition 00039 WRITE setScalePosition ) 00040 00041 Q_PROPERTY( bool trough READ hasTrough WRITE setTrough ) 00042 Q_PROPERTY( bool groove READ hasGroove WRITE setGroove ) 00043 00044 Q_PROPERTY( QSize handleSize READ handleSize WRITE setHandleSize ) 00045 Q_PROPERTY( int borderWidth READ borderWidth WRITE setBorderWidth ) 00046 Q_PROPERTY( int spacing READ spacing WRITE setSpacing ) 00047 00048 public: 00049 00054 enum ScalePosition 00055 { 00057 NoScale, 00058 00060 LeadingScale, 00061 00063 TrailingScale 00064 }; 00065 00066 explicit QwtSlider( QWidget *parent = NULL ); 00067 explicit QwtSlider( Qt::Orientation, QWidget *parent = NULL ); 00068 00069 virtual ~QwtSlider(); 00070 00071 void setOrientation( Qt::Orientation ); 00072 Qt::Orientation orientation() const; 00073 00074 void setScalePosition( ScalePosition ); 00075 ScalePosition scalePosition() const; 00076 00077 void setTrough( bool ); 00078 bool hasTrough() const; 00079 00080 void setGroove( bool ); 00081 bool hasGroove() const; 00082 00083 void setHandleSize( const QSize & ); 00084 QSize handleSize() const; 00085 00086 void setBorderWidth( int bw ); 00087 int borderWidth() const; 00088 00089 void setSpacing( int ); 00090 int spacing() const; 00091 00092 virtual QSize sizeHint() const; 00093 virtual QSize minimumSizeHint() const; 00094 00095 void setScaleDraw( QwtScaleDraw * ); 00096 const QwtScaleDraw *scaleDraw() const; 00097 00098 void setUpdateInterval( int ); 00099 int updateInterval() const; 00100 00101 protected: 00102 virtual double scrolledTo( const QPoint & ) const; 00103 virtual bool isScrollPosition( const QPoint & ) const; 00104 00105 virtual void drawSlider ( QPainter *, const QRect & ) const; 00106 virtual void drawHandle( QPainter *, const QRect &, int pos ) const; 00107 00108 virtual void mousePressEvent( QMouseEvent * ); 00109 virtual void mouseReleaseEvent( QMouseEvent * ); 00110 virtual void resizeEvent( QResizeEvent * ); 00111 virtual void paintEvent ( QPaintEvent * ); 00112 virtual void changeEvent( QEvent * ); 00113 virtual void timerEvent( QTimerEvent * ); 00114 00115 virtual void scaleChange(); 00116 00117 QRect sliderRect() const; 00118 QRect handleRect() const; 00119 00120 private: 00121 QwtScaleDraw *scaleDraw(); 00122 00123 void layoutSlider( bool ); 00124 void initSlider( Qt::Orientation ); 00125 00126 class PrivateData; 00127 PrivateData *d_data; 00128 }; 00129 00130 #endif