| 1 | /**********************************************************************
|
|---|
| 2 | ** $Id: qgridview.h 2 2005-11-16 15:49:26Z dmik $
|
|---|
| 3 | **
|
|---|
| 4 | ** Definition of QGridView class
|
|---|
| 5 | **
|
|---|
| 6 | ** Created : 010523
|
|---|
| 7 | **
|
|---|
| 8 | ** Copyright (C) 1992-2001 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 QGRIDVIEW_H
|
|---|
| 39 | #define QGRIDVIEW_H
|
|---|
| 40 |
|
|---|
| 41 | #ifndef QT_H
|
|---|
| 42 | #include "qscrollview.h"
|
|---|
| 43 | #endif // QT_H
|
|---|
| 44 |
|
|---|
| 45 | #ifndef QT_NO_GRIDVIEW
|
|---|
| 46 |
|
|---|
| 47 | class QGridViewPrivate;
|
|---|
| 48 |
|
|---|
| 49 | class Q_EXPORT QGridView : public QScrollView
|
|---|
| 50 | {
|
|---|
| 51 | Q_OBJECT
|
|---|
| 52 | Q_PROPERTY( int numRows READ numRows WRITE setNumRows )
|
|---|
| 53 | Q_PROPERTY( int numCols READ numCols WRITE setNumCols )
|
|---|
| 54 | Q_PROPERTY( int cellWidth READ cellWidth WRITE setCellWidth )
|
|---|
| 55 | Q_PROPERTY( int cellHeight READ cellHeight WRITE setCellHeight )
|
|---|
| 56 | public:
|
|---|
| 57 |
|
|---|
| 58 | QGridView( QWidget *parent=0, const char *name=0, WFlags f=0 );
|
|---|
| 59 | ~QGridView();
|
|---|
| 60 |
|
|---|
| 61 | int numRows() const;
|
|---|
| 62 | virtual void setNumRows( int );
|
|---|
| 63 | int numCols() const;
|
|---|
| 64 | virtual void setNumCols( int );
|
|---|
| 65 |
|
|---|
| 66 | int cellWidth() const;
|
|---|
| 67 | virtual void setCellWidth( int );
|
|---|
| 68 | int cellHeight() const;
|
|---|
| 69 | virtual void setCellHeight( int );
|
|---|
| 70 |
|
|---|
| 71 | QRect cellRect() const;
|
|---|
| 72 | QRect cellGeometry( int row, int column );
|
|---|
| 73 | QSize gridSize() const;
|
|---|
| 74 |
|
|---|
| 75 | int rowAt( int y ) const;
|
|---|
| 76 | int columnAt( int x ) const;
|
|---|
| 77 |
|
|---|
| 78 | void repaintCell( int row, int column, bool erase=TRUE );
|
|---|
| 79 | void updateCell( int row, int column );
|
|---|
| 80 | void ensureCellVisible( int row, int column );
|
|---|
| 81 |
|
|---|
| 82 | protected:
|
|---|
| 83 | virtual void paintCell( QPainter *, int row, int col ) = 0;
|
|---|
| 84 | virtual void paintEmptyArea( QPainter *p, int cx, int cy, int cw, int ch );
|
|---|
| 85 |
|
|---|
| 86 | void drawContents( QPainter *p, int cx, int cy, int cw, int ch );
|
|---|
| 87 |
|
|---|
| 88 | virtual void dimensionChange( int, int );
|
|---|
| 89 |
|
|---|
| 90 | private:
|
|---|
| 91 | void drawContents( QPainter* );
|
|---|
| 92 | void updateGrid();
|
|---|
| 93 |
|
|---|
| 94 | int nrows;
|
|---|
| 95 | int ncols;
|
|---|
| 96 | int cellw;
|
|---|
| 97 | int cellh;
|
|---|
| 98 | QGridViewPrivate* d;
|
|---|
| 99 |
|
|---|
| 100 | private: // Disabled copy constructor and operator=
|
|---|
| 101 | #if defined(Q_DISABLE_COPY)
|
|---|
| 102 | QGridView( const QGridView & );
|
|---|
| 103 | QGridView &operator=( const QGridView & );
|
|---|
| 104 | #endif
|
|---|
| 105 | };
|
|---|
| 106 |
|
|---|
| 107 | inline int QGridView::cellWidth() const
|
|---|
| 108 | { return cellw; }
|
|---|
| 109 |
|
|---|
| 110 | inline int QGridView::cellHeight() const
|
|---|
| 111 | { return cellh; }
|
|---|
| 112 |
|
|---|
| 113 | inline int QGridView::rowAt( int y ) const
|
|---|
| 114 | { return y / cellh; }
|
|---|
| 115 |
|
|---|
| 116 | inline int QGridView::columnAt( int x ) const
|
|---|
| 117 | { return x / cellw; }
|
|---|
| 118 |
|
|---|
| 119 | inline int QGridView::numRows() const
|
|---|
| 120 | { return nrows; }
|
|---|
| 121 |
|
|---|
| 122 | inline int QGridView::numCols() const
|
|---|
| 123 | {return ncols; }
|
|---|
| 124 |
|
|---|
| 125 | inline QRect QGridView::cellRect() const
|
|---|
| 126 | { return QRect( 0, 0, cellw, cellh ); }
|
|---|
| 127 |
|
|---|
| 128 | inline QSize QGridView::gridSize() const
|
|---|
| 129 | { return QSize( ncols * cellw, nrows * cellh ); }
|
|---|
| 130 |
|
|---|
| 131 |
|
|---|
| 132 |
|
|---|
| 133 | #endif // QT_NO_GRIDVIEW
|
|---|
| 134 |
|
|---|
| 135 |
|
|---|
| 136 | #endif // QTABLEVIEW_H
|
|---|