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

  1. /****************************************************************************
  2. ** $Id:  qt/qscrollview.h   3.0.0   edited Sep 21 17:17 $
  3. **
  4. ** Definition of QScrollView class
  5. **
  6. ** Created : 970523
  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. #ifndef QSCROLLVIEW_H
  38. #define QSCROLLVIEW_H
  39.  
  40. #ifndef QT_H
  41. #include "qframe.h"
  42. #include "qscrollbar.h"
  43. #endif // QT_H
  44.  
  45. #ifndef QT_NO_SCROLLVIEW
  46.  
  47. class QScrollViewData;
  48.  
  49. class Q_EXPORT QScrollView : public QFrame
  50. {
  51.     Q_OBJECT
  52.     Q_ENUMS( ResizePolicy ScrollBarMode )
  53.     Q_PROPERTY( ResizePolicy resizePolicy READ resizePolicy WRITE setResizePolicy )
  54.     Q_PROPERTY( ScrollBarMode vScrollBarMode READ vScrollBarMode WRITE setVScrollBarMode )
  55.     Q_PROPERTY( ScrollBarMode hScrollBarMode READ hScrollBarMode WRITE setHScrollBarMode )
  56.     Q_PROPERTY( int visibleWidth READ visibleWidth )
  57.     Q_PROPERTY( int visibleHeight READ visibleHeight )
  58.     Q_PROPERTY( int contentsWidth READ contentsWidth )
  59.     Q_PROPERTY( int contentsHeight READ contentsHeight )
  60.     Q_PROPERTY( int contentsX READ contentsX )
  61.     Q_PROPERTY( int contentsY READ contentsY )
  62. #ifndef QT_NO_DRAGANDDROP
  63.     Q_PROPERTY( bool dragAutoScroll READ dragAutoScroll WRITE setDragAutoScroll )
  64. #endif
  65.  
  66. public:
  67.     QScrollView(QWidget* parent=0, const char* name=0, WFlags f=0);
  68.     ~QScrollView();
  69.  
  70.     enum ResizePolicy { Default, Manual, AutoOne, AutoOneFit };
  71.     virtual void setResizePolicy( ResizePolicy );
  72.     ResizePolicy resizePolicy() const;
  73.  
  74.     void styleChange(QStyle&);
  75.     void removeChild(QWidget* child);
  76.     virtual void addChild( QWidget* child, int x=0, int y=0 );
  77.     virtual void moveChild( QWidget* child, int x, int y );
  78.     int childX(QWidget* child);
  79.     int childY(QWidget* child);
  80.     bool childIsVisible(QWidget* child) { return child->isVisible(); } // obsolete functions
  81.     void showChild(QWidget* child, bool yes=TRUE) {
  82.     if ( yes )
  83.         child->show();
  84.     else
  85.         child->hide();
  86.     }
  87.  
  88.     enum ScrollBarMode { Auto, AlwaysOff, AlwaysOn };
  89.  
  90.     ScrollBarMode vScrollBarMode() const;
  91.     virtual void  setVScrollBarMode( ScrollBarMode );
  92.  
  93.     ScrollBarMode hScrollBarMode() const;
  94.     virtual void  setHScrollBarMode( ScrollBarMode );
  95.  
  96.     QWidget*     cornerWidget() const;
  97.     virtual void setCornerWidget(QWidget*);
  98.  
  99.     QScrollBar*  horizontalScrollBar() const;
  100.     QScrollBar*  verticalScrollBar() const;
  101.     QWidget*     viewport() const;
  102.     QWidget*     clipper() const;
  103.  
  104.     int        visibleWidth() const;
  105.     int        visibleHeight() const;
  106.  
  107.     int        contentsWidth() const;
  108.     int        contentsHeight() const;
  109.     int        contentsX() const;
  110.     int        contentsY() const;
  111.  
  112.     void    resize( int w, int h );
  113.     void    resize( const QSize& );
  114.     void    show();
  115.  
  116.     void    updateContents( int x, int y, int w, int h );
  117.     void    updateContents( const QRect& r );
  118.     void     updateContents();
  119.     void    repaintContents( int x, int y, int w, int h, bool erase=TRUE );
  120.     void    repaintContents( const QRect& r, bool erase=TRUE );
  121.     void     repaintContents( bool erase=TRUE );
  122.     void    contentsToViewport( int x, int y, int& vx, int& vy ) const;
  123.     void    viewportToContents( int vx, int vy, int& x, int& y ) const;
  124.     QPoint    contentsToViewport( const QPoint& ) const;
  125.     QPoint    viewportToContents( const QPoint& ) const;
  126.     void    enableClipper( bool y );
  127.  
  128.     void    setStaticBackground( bool y );
  129.     bool    hasStaticBackground() const;
  130.  
  131.     QSize    viewportSize( int, int ) const;
  132.     QSize    sizeHint() const;
  133.     QSize    minimumSizeHint() const;
  134.  
  135.     void    removeChild(QObject* child);
  136.  
  137. #ifndef QT_NO_DRAGANDDROP
  138.     virtual void setDragAutoScroll( bool b );
  139.     bool     dragAutoScroll() const;
  140. #endif
  141.  
  142. signals:
  143.     void    contentsMoving(int x, int y);
  144.  
  145. public slots:
  146.     virtual void resizeContents( int w, int h );
  147.     void    scrollBy( int dx, int dy );
  148.     virtual void setContentsPos( int x, int y );
  149.     void    ensureVisible(int x, int y);
  150.     void    ensureVisible(int x, int y, int xmargin, int ymargin);
  151.     void    center(int x, int y);
  152.     void    center(int x, int y, float xmargin, float ymargin);
  153.  
  154.     void    updateScrollBars();
  155.     void    setEnabled( bool enable );
  156.  
  157. protected:
  158.     virtual void drawContents(QPainter*, int cx, int cy, int cw, int ch);
  159.     virtual void drawContentsOffset(QPainter*, int ox, int oy,
  160.             int cx, int cy, int cw, int ch);
  161.  
  162.  
  163.     virtual void contentsMousePressEvent( QMouseEvent* );
  164.     virtual void contentsMouseReleaseEvent( QMouseEvent* );
  165.     virtual void contentsMouseDoubleClickEvent( QMouseEvent* );
  166.     virtual void contentsMouseMoveEvent( QMouseEvent* );
  167. #ifndef QT_NO_DRAGANDDROP
  168.     virtual void contentsDragEnterEvent( QDragEnterEvent * );
  169.     virtual void contentsDragMoveEvent( QDragMoveEvent * );
  170.     virtual void contentsDragLeaveEvent( QDragLeaveEvent * );
  171.     virtual void contentsDropEvent( QDropEvent * );
  172. #endif
  173.     virtual void contentsWheelEvent( QWheelEvent * );
  174.     virtual void contentsContextMenuEvent( QContextMenuEvent * );
  175.  
  176.  
  177.     virtual void viewportPaintEvent( QPaintEvent* );
  178.     virtual void viewportResizeEvent( QResizeEvent* );
  179.     virtual void viewportMousePressEvent( QMouseEvent* );
  180.     virtual void viewportMouseReleaseEvent( QMouseEvent* );
  181.     virtual void viewportMouseDoubleClickEvent( QMouseEvent* );
  182.     virtual void viewportMouseMoveEvent( QMouseEvent* );
  183. #ifndef QT_NO_DRAGANDDROP
  184.     virtual void viewportDragEnterEvent( QDragEnterEvent * );
  185.     virtual void viewportDragMoveEvent( QDragMoveEvent * );
  186.     virtual void viewportDragLeaveEvent( QDragLeaveEvent * );
  187.     virtual void viewportDropEvent( QDropEvent * );
  188. #endif
  189.     virtual void viewportWheelEvent( QWheelEvent * );
  190.     virtual void viewportContextMenuEvent( QContextMenuEvent * );
  191.  
  192.     void    frameChanged();
  193.  
  194.     virtual void setMargins(int left, int top, int right, int bottom);
  195.     int leftMargin() const;
  196.     int topMargin() const;
  197.     int rightMargin() const;
  198.     int bottomMargin() const;
  199.  
  200.     bool focusNextPrevChild( bool next );
  201.  
  202.     virtual void setHBarGeometry(QScrollBar& hbar, int x, int y, int w, int h);
  203.     virtual void setVBarGeometry(QScrollBar& vbar, int x, int y, int w, int h);
  204.  
  205.     void    resizeEvent(QResizeEvent*);
  206.     void     mousePressEvent( QMouseEvent * );
  207.     void     mouseReleaseEvent( QMouseEvent * );
  208.     void     mouseDoubleClickEvent( QMouseEvent * );
  209.     void     mouseMoveEvent( QMouseEvent * );
  210.     void     wheelEvent( QWheelEvent * );
  211.     void    contextMenuEvent( QContextMenuEvent * );
  212.     bool    eventFilter( QObject *, QEvent *e );
  213.  
  214.  
  215. private:
  216.     void drawContents( QPainter* );
  217.     void moveContents(int x, int y);
  218.  
  219.     QScrollViewData* d;
  220.  
  221. private slots:
  222.     void hslide(int);
  223.     void vslide(int);
  224. #ifndef QT_NO_DRAGANDDROP
  225.     void doDragAutoScroll();
  226.     void startDragAutoScroll();
  227.     void stopDragAutoScroll();
  228. #endif
  229.  
  230. private:    // Disabled copy constructor and operator=
  231. #if defined(Q_DISABLE_COPY)
  232.     QScrollView( const QScrollView & );
  233.     QScrollView &operator=( const QScrollView & );
  234. #endif
  235.     void changeFrameRect(const QRect&);
  236. };
  237.  
  238. #endif // QT_NO_SCROLLVIEW
  239.  
  240. #endif // QSCROLLVIEW_H
  241.