Prepare for QTextEdit transition: Add KTextEdit::charAt() for wordAtPoint().
[kdbg.git] / kdbg / tableview.h
blob2757d393935b8fb105b2eea541faff274e7106ba
1 // $Id$
3 // Copyright by Johannes Sixt
4 // This file is under GPL, the GNU General Public Licence
6 #ifndef TABLEVIEW_H
7 #define TABLEVIEW_H
9 #include <qwidget.h>
11 class QScrollBar;
13 class TableView : public QWidget
15 Q_OBJECT
16 public:
17 TableView(QWidget* parent, const char* name, WFlags f);
18 ~TableView();
20 void setNumCols(int cols);
21 int numCols() const { return m_numCols; }
22 void setNumRows(int rows);
23 int numRows() const { return m_numRows; }
24 void setAutoUpdate(bool update) { m_autoUpdate = update; }
25 bool autoUpdate() const { return m_autoUpdate; }
26 void updateTableSize();
27 int totalWidth() const { return m_totalSize.width(); }
28 int totalHeight() const { return m_totalSize.height(); }
29 int lastRowVisible() const;
30 void setTopCell(int row);
31 int topCell() const;
32 int leftCell() const;
33 void setXOffset(int x) { setOffset(x, yOffset()); }
34 int xOffset() const { return m_xOffset; }
35 int maxXOffset() const;
36 void setYOffset(int y) { setOffset(xOffset(), y); }
37 int yOffset() const { return m_yOffset; }
38 int maxYOffset() const;
39 void setOffset(int x, int y);
40 int viewWidth() const;
41 int viewHeight() const;
42 bool rowIsVisible(int row) const;
43 int findRow(int y) const;
44 bool rowYPos(int row, int* top) const;
45 int findCol(int x) const;
46 bool colXPos(int col, int* left) const;
47 void updateCell(int row, int col, bool erase = true);
49 // override in derived classes
50 virtual int cellWidth(int col) const = 0;
51 virtual int cellHeight(int row) const = 0;
52 virtual void paintCell(QPainter* p, int row, int col) = 0;
53 virtual void setupPainter(QPainter* p);
55 protected:
56 // overrides
57 virtual void resizeEvent(QResizeEvent* ev);
58 virtual void paintEvent(QPaintEvent* ev);
59 virtual void wheelEvent(QWheelEvent* ev);
61 public slots:
62 void sbVer(int value);
63 void sbHor(int value);
65 private:
66 int m_numRows, m_numCols;
67 int m_xOffset, m_yOffset;
68 QSize m_totalSize;
69 bool m_autoUpdate;
70 QScrollBar* m_sbV;
71 QScrollBar* m_sbH;
72 QWidget* m_sbCorner;
73 void updateScrollBars();
76 #endif // TABLEVIEW_H