1 /**********************************************************************
2 ** $Id: qttableview.h,v 1.1 2001/12/01 02:24:27 levon Exp $
4 ** Definition of QtTableView class
8 ** Copyright (C) 1992-2000 Trolltech AS. All rights reserved.
10 ** This file contains a class moved out of the Qt GUI Toolkit API. It
11 ** may be used, distributed and modified without limitation.
13 **********************************************************************/
22 #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;
94 void horSbValue( int );
95 void horSbSliding( int );
96 void horSbSlidingDone();
97 void verSbValue( int );
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 & );
179 const uint Tbl_vScrollBar = 0x00000001;
180 const uint Tbl_hScrollBar = 0x00000002;
181 const uint Tbl_autoVScrollBar = 0x00000004;
182 const uint Tbl_autoHScrollBar = 0x00000008;
183 const uint Tbl_autoScrollBars = 0x0000000C;
185 const uint Tbl_clipCellPainting = 0x00000100;
186 const uint Tbl_cutCellsV = 0x00000200;
187 const uint Tbl_cutCellsH = 0x00000400;
188 const uint Tbl_cutCells = 0x00000600;
190 const uint Tbl_scrollLastHCell = 0x00000800;
191 const uint Tbl_scrollLastVCell = 0x00001000;
192 const uint Tbl_scrollLastCell = 0x00001800;
194 const uint Tbl_smoothHScrolling = 0x00002000;
195 const uint Tbl_smoothVScrolling = 0x00004000;
196 const uint Tbl_smoothScrolling = 0x00006000;
198 const uint Tbl_snapToHGrid = 0x00008000;
199 const uint Tbl_snapToVGrid = 0x00010000;
200 const uint Tbl_snapToGrid = 0x00018000;
203 inline int QtTableView::numRows() const
206 inline int QtTableView::numCols() const
209 inline int QtTableView::topCell() const
210 { return yCellOffs; }
212 inline int QtTableView::leftCell() const
213 { return xCellOffs; }
215 inline int QtTableView::xOffset() const
218 inline int QtTableView::yOffset() const
221 inline int QtTableView::cellHeight() const
224 inline int QtTableView::cellWidth() const
227 inline uint QtTableView::tableFlags() const
230 inline bool QtTableView::testTableFlags( uint f ) const
231 { return (tFlags & f) != 0; }
233 inline QRect QtTableView::cellUpdateRect() const
234 { return cellUpdateR; }
236 inline bool QtTableView::autoUpdate() const
237 { return isUpdatesEnabled(); }
239 inline void QtTableView::repaint( bool erase )
240 { repaint( 0, 0, width(), height(), erase ); }
242 inline void QtTableView::repaint( const QRect &r, bool erase )
243 { repaint( r.x(), r.y(), r.width(), r.height(), erase ); }
245 inline void QtTableView::updateScrollBars()
246 { updateScrollBars( 0 ); }
249 #endif // QT_NO_QTTABLEVIEW
251 #endif // QTTABLEVIEW_H