1 /**********************************************************************
2 ** $NHDT-Branch$:$NHDT-Revision$ $NHDT-Date$
3 ** $Id: qttableview.h,v 1.2 2002/03/09 03:13:13 jwalz Exp $
5 ** Definition of QtTableView class
9 ** Copyright (C) 1992-2000 Trolltech AS. All rights reserved.
11 ** This file contains a class moved out of the Qt GUI Toolkit API. It
12 ** may be used, distributed and modified without limitation.
14 **********************************************************************/
23 #ifndef QT_NO_QTTABLEVIEW
28 class QtTableView
: public QFrame
32 virtual void setBackgroundColor(const QColor
&);
33 virtual void setPalette(const QPalette
&);
36 void repaint(bool erase
= TRUE
);
37 void repaint(int x
, int y
, int w
, int h
, bool erase
= TRUE
);
38 void repaint(const QRect
&, bool erase
= TRUE
);
41 QtTableView(QWidget
*parent
= 0, const char *name
= 0, WFlags f
= 0);
45 virtual void setNumRows(int);
47 virtual void setNumCols(int);
50 virtual void setTopCell(int row
);
52 virtual void setLeftCell(int col
);
53 virtual void setTopLeftCell(int row
, int col
);
56 virtual void setXOffset(int);
58 virtual void setYOffset(int);
59 virtual void setOffset(int x
, int y
, bool updateScrBars
= TRUE
);
61 virtual int cellWidth(int col
);
62 virtual int cellHeight(int row
);
63 int cellWidth() const;
64 int cellHeight() const;
65 virtual void setCellWidth(int);
66 virtual void setCellHeight(int);
68 virtual int totalWidth();
69 virtual int totalHeight();
71 uint
tableFlags() const;
72 bool testTableFlags(uint f
) const;
73 virtual void setTableFlags(uint f
);
74 void clearTableFlags(uint f
= ~0);
76 bool autoUpdate() const;
77 virtual void setAutoUpdate(bool);
79 void updateCell(int row
, int column
, bool erase
= TRUE
);
81 QRect
cellUpdateRect() const;
82 QRect
viewRect() const;
84 int lastRowVisible() const;
85 int lastColVisible() const;
87 bool rowIsVisible(int row
) const;
88 bool colIsVisible(int col
) const;
90 QScrollBar
*verticalScrollBar() const;
91 QScrollBar
*horizontalScrollBar() const;
95 void horSbSliding(int);
96 void horSbSlidingDone();
98 void verSbSliding(int);
99 void verSbSlidingDone();
102 virtual void paintCell(QPainter
*, int row
, int col
) = 0;
103 virtual void setupPainter(QPainter
*);
105 void paintEvent(QPaintEvent
*);
106 void resizeEvent(QResizeEvent
*);
108 int findRow(int yPos
) const;
109 int findCol(int xPos
) const;
111 bool rowYPos(int row
, int *yPos
) const;
112 bool colXPos(int col
, int *xPos
) const;
119 int minViewX() const;
120 int minViewY() const;
121 int maxViewX() const;
122 int maxViewY() const;
123 int viewWidth() const;
124 int viewHeight() const;
126 void scroll(int xPixels
, int yPixels
);
127 void updateScrollBars();
128 void updateTableSize();
131 void coverCornerSquare(bool);
132 void snapToGrid(bool horizontal
, bool vertical
);
133 virtual void setHorScrollBar(bool on
, bool update
= TRUE
);
134 virtual void setVerScrollBar(bool on
, bool update
= TRUE
);
136 int findRawRow(int yPos
, int *cellMaxY
, int *cellMinY
= 0,
137 bool goOutsideView
= FALSE
) const;
138 int findRawCol(int xPos
, int *cellMaxX
, int *cellMinX
= 0,
139 bool goOutsideView
= FALSE
) const;
140 int maxColsVisible() const;
142 void updateScrollBars(uint
);
143 void updateFrameSize();
145 void doAutoScrollBars();
146 void showOrHideScrollBars();
151 int xCellOffs
, yCellOffs
;
152 short xCellDelta
, yCellDelta
;
155 uint eraseInPaint
: 1;
157 uint verSnappingOff
: 1;
159 uint horSnappingOff
: 1;
160 uint coveringCornerSquare
: 1;
167 QScrollBar
*vScrollBar
;
168 QScrollBar
*hScrollBar
;
169 QCornerSquare
*cornerSquare
;
171 private: // Disabled copy constructor and operator=
172 #if defined(Q_DISABLE_COPY)
173 QtTableView(const QtTableView
&);
174 QtTableView
&operator=(const QtTableView
&);
178 const uint Tbl_vScrollBar
= 0x00000001;
179 const uint Tbl_hScrollBar
= 0x00000002;
180 const uint Tbl_autoVScrollBar
= 0x00000004;
181 const uint Tbl_autoHScrollBar
= 0x00000008;
182 const uint Tbl_autoScrollBars
= 0x0000000C;
184 const uint Tbl_clipCellPainting
= 0x00000100;
185 const uint Tbl_cutCellsV
= 0x00000200;
186 const uint Tbl_cutCellsH
= 0x00000400;
187 const uint Tbl_cutCells
= 0x00000600;
189 const uint Tbl_scrollLastHCell
= 0x00000800;
190 const uint Tbl_scrollLastVCell
= 0x00001000;
191 const uint Tbl_scrollLastCell
= 0x00001800;
193 const uint Tbl_smoothHScrolling
= 0x00002000;
194 const uint Tbl_smoothVScrolling
= 0x00004000;
195 const uint Tbl_smoothScrolling
= 0x00006000;
197 const uint Tbl_snapToHGrid
= 0x00008000;
198 const uint Tbl_snapToVGrid
= 0x00010000;
199 const uint Tbl_snapToGrid
= 0x00018000;
202 QtTableView::numRows() const
208 QtTableView::numCols() const
214 QtTableView::topCell() const
220 QtTableView::leftCell() const
226 QtTableView::xOffset() const
232 QtTableView::yOffset() const
238 QtTableView::cellHeight() const
244 QtTableView::cellWidth() const
250 QtTableView::tableFlags() const
256 QtTableView::testTableFlags(uint f
) const
258 return (tFlags
& f
) != 0;
262 QtTableView::cellUpdateRect() const
268 QtTableView::autoUpdate() const
270 return isUpdatesEnabled();
274 QtTableView::repaint(bool erase
)
276 repaint(0, 0, width(), height(), erase
);
280 QtTableView::repaint(const QRect
&r
, bool erase
)
282 repaint(r
.x(), r
.y(), r
.width(), r
.height(), erase
);
286 QtTableView::updateScrollBars()
291 #endif // QT_NO_QTTABLEVIEW
293 #endif // QTTABLEVIEW_H