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

  1. /****************************************************************************
  2. ** $Id:  qt/qscrollbar.h   3.0.0   edited Sep 21 17:17 $
  3. **
  4. ** Definition of QScrollBar class
  5. **
  6. ** Created : 940427
  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 QSCROLLBAR_H
  39. #define QSCROLLBAR_H
  40.  
  41. class QTimer;
  42.  
  43. #ifndef QT_H
  44. #include "qwidget.h"
  45. #include "qrangecontrol.h"
  46. #endif // QT_H
  47.  
  48. #ifndef QT_NO_SCROLLBAR
  49.  
  50.  
  51. class Q_EXPORT QScrollBar : public QWidget, public QRangeControl
  52. {
  53.     Q_OBJECT
  54.     Q_PROPERTY( int minValue READ minValue WRITE setMinValue )
  55.     Q_PROPERTY( int maxValue READ maxValue WRITE setMaxValue )
  56.     Q_PROPERTY( int lineStep READ lineStep WRITE setLineStep )
  57.     Q_PROPERTY( int pageStep READ pageStep WRITE setPageStep )
  58.     Q_PROPERTY( int value READ value WRITE setValue )
  59.     Q_PROPERTY( bool tracking READ tracking WRITE setTracking )
  60.     Q_PROPERTY( bool draggingSlider READ draggingSlider )
  61.     Q_PROPERTY( Orientation orientation READ orientation WRITE setOrientation )
  62.  
  63. public:
  64.     QScrollBar( QWidget *parent, const char* name=0 );
  65.     QScrollBar( Orientation, QWidget *parent, const char* name=0 );
  66.     QScrollBar( int minValue, int maxValue, int LineStep, int PageStep,
  67.         int value, Orientation,
  68.         QWidget *parent, const char* name=0 );
  69.  
  70.     virtual void setOrientation( Orientation );
  71.     Orientation orientation() const;
  72.     virtual void setTracking( bool enable );
  73.     bool    tracking() const;
  74.     bool    draggingSlider() const;
  75.  
  76.     virtual void setPalette( const QPalette & );
  77.     QSize    sizeHint() const;
  78.  
  79.     int     minValue() const;
  80.     int     maxValue() const;
  81.     void setMinValue( int );
  82.     void setMaxValue( int );
  83.     int     lineStep() const;
  84.     int     pageStep() const;
  85.     void setLineStep( int );
  86.     void setPageStep( int );
  87.     int  value() const;
  88.  
  89.     int        sliderStart() const;
  90.     QRect    sliderRect() const;
  91.  
  92. public slots:
  93.     void setValue( int );
  94.  
  95. signals:
  96.     void    valueChanged( int value );
  97.     void    sliderPressed();
  98.     void    sliderMoved( int value );
  99.     void    sliderReleased();
  100.     void    nextLine();
  101.     void    prevLine();
  102.     void    nextPage();
  103.     void    prevPage();
  104.  
  105. protected:
  106.     void     wheelEvent( QWheelEvent * );
  107.     void    keyPressEvent( QKeyEvent * );
  108.     void    resizeEvent( QResizeEvent * );
  109.     void    paintEvent( QPaintEvent * );
  110.  
  111.     void    mousePressEvent( QMouseEvent * );
  112.     void    mouseReleaseEvent( QMouseEvent * );
  113.     void    mouseMoveEvent( QMouseEvent * );
  114.     void        contextMenuEvent( QContextMenuEvent * );
  115.  
  116.     void    valueChange();
  117.     void    stepChange();
  118.     void    rangeChange();
  119.  
  120.     void    styleChange( QStyle& );
  121.  
  122. private slots:
  123.     void doAutoRepeat();
  124.  
  125. private:
  126.     void init();
  127.     void positionSliderFromValue();
  128.     int calculateValueFromSlider() const;
  129.  
  130.     void startAutoRepeat();
  131.     void stopAutoRepeat();
  132.  
  133.     int rangeValueToSliderPos( int val ) const;
  134.     int sliderPosToRangeValue( int  val ) const;
  135.  
  136.     void action( int control );
  137.  
  138.     void drawControls( uint controls, uint activeControl ) const;
  139.     void drawControls( uint controls, uint activeControl,
  140.                 QPainter *p ) const;
  141.  
  142.     uint pressedControl;
  143.     bool track;
  144.     bool clickedAt;
  145.     Orientation orient;
  146.  
  147.     int slidePrevVal;
  148.     QCOORD sliderPos;
  149.     QCOORD clickOffset;
  150.  
  151.     QTimer * repeater;
  152.     void * d;
  153.  
  154. private:    // Disabled copy constructor and operator=
  155. #if defined(Q_DISABLE_COPY)
  156.     QScrollBar( const QScrollBar & );
  157.     QScrollBar &operator=( const QScrollBar & );
  158. #endif
  159. };
  160.  
  161.  
  162. inline void QScrollBar::setTracking( bool t )
  163. {
  164.     track = t;
  165. }
  166.  
  167. inline bool QScrollBar::tracking() const
  168. {
  169.     return track;
  170. }
  171.  
  172. inline QScrollBar::Orientation QScrollBar::orientation() const
  173. {
  174.     return orient;
  175. }
  176.  
  177. inline int QScrollBar::sliderStart() const
  178. {
  179.     return sliderPos;
  180. }
  181.  
  182.  
  183. #endif // QT_NO_SCROLLBAR
  184.  
  185. #endif // QSCROLLBAR_H
  186.