]> git.lyx.org Git - lyx.git/blob - src/frontends/qt2/qgridview.h
better selection and scrolling behaviour
[lyx.git] / src / frontends / qt2 / qgridview.h
1 /**********************************************************************
2 ** $Id: qgridview.h,v 1.2 2002/12/01 22:59:19 larsbj Exp $
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 #include <qscrollview.h>
42
43 #ifndef QT_NO_GRIDVIEW
44
45 class QGridViewPrivate;
46
47 class Q_EXPORT QGridView : public QScrollView
48 {
49     Q_OBJECT
50     Q_PROPERTY( int numRows READ numRows WRITE setNumRows )
51     Q_PROPERTY( int numCols READ numCols WRITE setNumCols )
52     Q_PROPERTY( int cellWidth READ cellWidth WRITE setCellWidth )
53     Q_PROPERTY( int cellHeight READ cellHeight WRITE setCellHeight )
54 public:
55
56     QGridView( QWidget *parent=0, const char *name=0, WFlags f=0 );
57    ~QGridView();
58
59     int numRows() const;
60     virtual void setNumRows( int );
61     int numCols() const;
62     virtual void setNumCols( int );
63
64     int cellWidth() const;
65     virtual void setCellWidth( int );
66     int cellHeight() const;
67     virtual void setCellHeight( int );
68
69     QRect cellRect() const;
70     QRect cellGeometry( int row, int column );
71     QSize gridSize() const;
72
73     int rowAt( int y ) const;
74     int columnAt( int x ) const;
75
76     void repaintCell( int row, int column, bool erase=TRUE );
77     void updateCell( int row, int column );
78     void ensureCellVisible( int row, int column );
79
80 protected:
81     virtual void paintCell( QPainter *, int row, int col ) = 0;
82     virtual void paintEmptyArea( QPainter *p, int cx, int cy, int cw, int ch );
83
84     void drawContents( QPainter *p, int cx, int cy, int cw, int ch );
85
86     virtual void dimensionChange( int, int );
87
88 private:
89     void drawContents( QPainter* );
90     void updateGrid();
91
92     int nrows;
93     int ncols;
94     int cellw;
95     int cellh;
96     QGridViewPrivate* d;
97
98 private:        // Disabled copy constructor and operator=
99 #if defined(Q_DISABLE_COPY)
100     QGridView( const QGridView & );
101     QGridView &operator=( const QGridView & );
102 #endif
103 };
104
105 inline int QGridView::cellWidth() const
106 { return cellw; }
107
108 inline int QGridView::cellHeight() const
109 { return cellh; }
110
111 inline int QGridView::rowAt( int y ) const
112 { return y / cellh; }
113
114 inline int QGridView::columnAt( int x ) const
115 { return x / cellw; }
116
117 inline int QGridView::numRows() const
118 { return nrows; }
119
120 inline int QGridView::numCols() const
121 {return ncols; }
122
123 inline QRect QGridView::cellRect() const
124 { return QRect( 0, 0, cellw, cellh ); }
125
126 inline QSize QGridView::gridSize() const
127 { return QSize( ncols * cellw, nrows * cellh ); }
128
129
130
131 #endif // QT_NO_GRIDVIEW
132
133
134 #endif // QTABLEVIEW_H