-rw-r--r-- | qtcompat/qgridview.h | 138 |
1 files changed, 138 insertions, 0 deletions
diff --git a/qtcompat/qgridview.h b/qtcompat/qgridview.h new file mode 100644 index 0000000..e9d6ca1 --- a/dev/null +++ b/qtcompat/qgridview.h | |||
@@ -0,0 +1,138 @@ | |||
1 | /********************************************************************** | ||
2 | ** $Id$ | ||
3 | ** | ||
4 | ** Definition of QGridView class | ||
5 | ** | ||
6 | ** Created: 2001.05.23 | ||
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 | void repaintContents( bool erase=TRUE ); | ||
83 | |||
84 | protected: | ||
85 | virtual void paintCell( QPainter *, int row, int col ) = 0; | ||
86 | virtual void paintEmptyArea( QPainter *p, int cx, int cy, int cw, int ch ); | ||
87 | |||
88 | void drawContents( QPainter *p, int cx, int cy, int cw, int ch ); | ||
89 | |||
90 | virtual void dimensionChange( int, int ); | ||
91 | |||
92 | private: | ||
93 | void drawContents( QPainter* ); | ||
94 | void updateGrid(); | ||
95 | |||
96 | int nrows; | ||
97 | int ncols; | ||
98 | int cellw; | ||
99 | int cellh; | ||
100 | QGridViewPrivate* d; | ||
101 | |||
102 | private:// Disabled copy constructor and operator= | ||
103 | #if defined(Q_DISABLE_COPY) | ||
104 | QGridView( const QGridView & ); | ||
105 | QGridView &operator=( const QGridView & ); | ||
106 | #endif | ||
107 | }; | ||
108 | |||
109 | inline int QGridView::cellWidth() const | ||
110 | { return cellw; } | ||
111 | |||
112 | inline int QGridView::cellHeight() const | ||
113 | { return cellh; } | ||
114 | |||
115 | inline int QGridView::rowAt( int y ) const | ||
116 | { return y / cellh; } | ||
117 | |||
118 | inline int QGridView::columnAt( int x ) const | ||
119 | { return x / cellw; } | ||
120 | |||
121 | inline int QGridView::numRows() const | ||
122 | { return nrows; } | ||
123 | |||
124 | inline int QGridView::numCols() const | ||
125 | {return ncols; } | ||
126 | |||
127 | inline QRect QGridView::cellRect() const | ||
128 | { return QRect( 0, 0, cellw, cellh ); } | ||
129 | |||
130 | inline QSize QGridView::gridSize() const | ||
131 | { return QSize( ncols * cellw, nrows * cellh ); } | ||
132 | |||
133 | |||
134 | |||
135 | #endif // QT_NO_GRIDVIEW | ||
136 | |||
137 | |||
138 | #endif // QTABLEVIEW_H | ||