home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / qt3_emx.zip / include / qslider.h < prev    next >
C/C++ Source or Header  |  2001-10-11  |  5KB  |  185 lines

  1. /****************************************************************************
  2. ** $Id$
  3. **
  4. ** Definition of QSlider class
  5. **
  6. ** Created : 961019
  7. **
  8. ** Copyright (C) 1992-2000 Trolltech AS.  All rights reserved.
  9. **
  10. ** This file is part of the widgets module of the Qt GUI Toolkit.
  11. **
  12. ** This file may be distributed under the terms of the Q Public License
  13. ** as defined by Trolltech AS of Norway and appearing in the file
  14. ** LICENSE.QPL included in the packaging of this file.
  15. **
  16. ** This file may be distributed and/or modified under the terms of the
  17. ** GNU General Public License version 2 as published by the Free Software
  18. ** Foundation and appearing in the file LICENSE.GPL included in the
  19. ** packaging of this file.
  20. **
  21. ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
  22. ** licenses may use this file in accordance with the Qt Commercial License
  23. ** Agreement provided with the Software.
  24. **
  25. ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
  26. ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  27. **
  28. ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
  29. **   information about Qt Commercial License Agreements.
  30. ** See http://www.trolltech.com/qpl/ for QPL licensing information.
  31. ** See http://www.trolltech.com/gpl/ for GPL licensing information.
  32. **
  33. ** Contact info@trolltech.com if any conditions of this licensing are
  34. ** not clear to you.
  35. **
  36. **********************************************************************/
  37.  
  38. #ifndef QSLIDER_H
  39. #define QSLIDER_H
  40.  
  41. #ifndef QT_H
  42. #include "qwidget.h"
  43. #include "qrangecontrol.h"
  44. #endif // QT_H
  45.  
  46. #ifndef QT_NO_SLIDER
  47.  
  48.  
  49. struct QSliderPrivate;
  50.  
  51. class QTimer;
  52.  
  53. class Q_EXPORT QSlider : public QWidget, public QRangeControl
  54. {
  55.     Q_OBJECT
  56.     Q_ENUMS( TickSetting )
  57.     Q_PROPERTY( int minValue READ minValue WRITE setMinValue )
  58.     Q_PROPERTY( int maxValue READ maxValue WRITE setMaxValue )
  59.     Q_PROPERTY( int lineStep READ lineStep WRITE setLineStep )
  60.     Q_PROPERTY( int pageStep READ pageStep WRITE setPageStep )
  61.     Q_PROPERTY( int value READ value WRITE setValue )
  62.     Q_PROPERTY( bool tracking READ tracking WRITE setTracking )
  63.     Q_PROPERTY( Orientation orientation READ orientation WRITE setOrientation )
  64.     Q_PROPERTY( TickSetting tickmarks READ tickmarks WRITE setTickmarks )
  65.     Q_PROPERTY( int tickInterval READ tickInterval WRITE setTickInterval )
  66.     
  67. public:
  68.     enum TickSetting { NoMarks = 0, Above = 1, Left = Above,
  69.                Below = 2, Right = Below, Both = 3 };
  70.  
  71.     QSlider( QWidget *parent, const char* name=0 );
  72.     QSlider( Orientation, QWidget *parent, const char* name=0 );
  73.     QSlider( int minValue, int maxValue, int pageStep, int value, Orientation,
  74.          QWidget *parent, const char* name=0 );
  75.  
  76.     virtual void    setOrientation( Orientation );
  77.     Orientation orientation() const;
  78.     virtual void    setTracking( bool enable );
  79.     bool    tracking() const;
  80.     virtual void     setPalette( const QPalette & );
  81.  
  82.     int        sliderStart() const;
  83.     QRect    sliderRect() const;
  84.     QSize    sizeHint() const;
  85.     QSizePolicy sizePolicy() const;
  86.     QSize    minimumSizeHint() const;
  87.  
  88.     virtual void setTickmarks( TickSetting );
  89.     TickSetting tickmarks() const { return ticks; }
  90.  
  91.     virtual void setTickInterval( int );
  92.     int     tickInterval() const { return tickInt; }
  93.  
  94.     int     minValue() const;
  95.     int     maxValue() const;
  96.     void setMinValue( int );
  97.     void setMaxValue( int );
  98.     int     lineStep() const;
  99.     int     pageStep() const;
  100.     void setLineStep( int );
  101.     void setPageStep( int );
  102.     int  value() const;
  103.  
  104. public slots:
  105.     virtual void    setValue( int );
  106.     void    addStep();
  107.     void    subtractStep();
  108.  
  109. signals:
  110.     void    valueChanged( int value );
  111.     void    sliderPressed();
  112.     void    sliderMoved( int value );
  113.     void    sliderReleased();
  114.  
  115. protected:
  116.     void    resizeEvent( QResizeEvent * );
  117.     void    paintEvent( QPaintEvent * );
  118.  
  119.     void    keyPressEvent( QKeyEvent * );
  120.     void    mousePressEvent( QMouseEvent * );
  121.     void    mouseReleaseEvent( QMouseEvent * );
  122.     void    mouseMoveEvent( QMouseEvent * );
  123.     void    wheelEvent( QWheelEvent * );
  124.     void    focusInEvent( QFocusEvent *e );
  125.     void    focusOutEvent( QFocusEvent *e );
  126.  
  127.     void    styleChange( QStyle& );
  128.  
  129.     void    valueChange();
  130.     void    rangeChange();
  131.  
  132. private slots:
  133.     void    repeatTimeout();
  134.  
  135. private:
  136.     enum State { Idle, Dragging, TimingUp, TimingDown };
  137.  
  138.     void    init();
  139.     int        positionFromValue( int ) const;
  140.     int        valueFromPosition( int ) const;
  141.     void    moveSlider( int );
  142.     void    reallyMoveSlider( int );
  143.     void    resetState();
  144.     int        available() const;
  145.     int        goodPart( const QPoint& ) const;
  146.     void    initTicks();
  147.  
  148.     QSliderPrivate *extra;
  149.     QTimer    *timer;
  150.     QCOORD    sliderPos;
  151.     int        sliderVal;
  152.     QCOORD    clickOffset;
  153.     State    state;
  154.     bool    track;
  155.     QCOORD    tickOffset;
  156.     TickSetting    ticks;
  157.     int        tickInt;
  158.     Orientation orient;
  159.  
  160. private:    // Disabled copy constructor and operator=
  161. #if defined(Q_DISABLE_COPY)
  162.     QSlider( const QSlider & );
  163.     QSlider &operator=( const QSlider & );
  164. #endif
  165. };
  166.  
  167. inline bool QSlider::tracking() const
  168. {
  169.     return track;
  170. }
  171.  
  172. inline QSlider::Orientation QSlider::orientation() const
  173. {
  174.     return orient;
  175. }
  176.  
  177. inline int QSlider::sliderStart() const
  178. {
  179.     return sliderPos;
  180. }
  181.  
  182. #endif // QT_NO_SLIDER
  183.  
  184. #endif // QSLIDER_H
  185.