File: tableview.h

package info (click to toggle)
kdbg 1.2.4-2
  • links: PTS
  • area: main
  • in suites: woody
  • size: 2,504 kB
  • ctags: 1,945
  • sloc: cpp: 15,961; sh: 8,183; makefile: 481; perl: 71; ansic: 16
file content (74 lines) | stat: -rw-r--r-- 2,151 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
// $Id: tableview.h,v 1.1.2.1 2001/12/28 21:10:28 jsixt Exp $

// Copyright by Johannes Sixt
// This file is under GPL, the GNU General Public Licence

#ifndef TABLEVIEW_H
#define TABLEVIEW_H

#include <qwidget.h>

class QScrollBar;

class TableView : public QWidget
{
    Q_OBJECT
public:
    TableView(QWidget* parent, const char* name, WFlags f);
    ~TableView();

    void setNumCols(int cols);
    int numCols() const { return m_numCols; }
    void setNumRows(int rows);
    int numRows() const { return m_numRows; }
    void setAutoUpdate(bool update) { m_autoUpdate = update; }
    bool autoUpdate() const { return m_autoUpdate; }
    void updateTableSize();
    int totalWidth() const { return m_totalSize.width(); }
    int totalHeight() const { return m_totalSize.height(); }
    int lastRowVisible() const;
    void setTopCell(int row);
    int topCell() const;
    int leftCell() const;
    void setXOffset(int x) { setOffset(x, yOffset()); }
    int xOffset() const { return m_xOffset; }
    int maxXOffset() const;
    void setYOffset(int y) { setOffset(xOffset(), y); }
    int yOffset() const { return m_yOffset; }
    int maxYOffset() const;
    void setOffset(int x, int y);
    int viewWidth() const;
    int viewHeight() const;
    bool rowIsVisible(int row) const;
    int findRow(int y) const;
    bool rowYPos(int row, int* top) const;
    int findCol(int x) const;
    bool colXPos(int col, int* left) const;
    void updateCell(int row, int col, bool erase = true);

    // override in derived classes
    virtual int cellWidth(int col) const = 0;
    virtual int cellHeight(int row) const = 0;
    virtual void paintCell(QPainter* p, int row, int col) = 0;
    virtual void setupPainter(QPainter* p);

    // overrides
    virtual void resizeEvent(QResizeEvent* ev);
    virtual void paintEvent(QPaintEvent* ev);

public slots:
    void sbVer(int value);
    void sbHor(int value);

private:
    int m_numRows, m_numCols;
    int m_xOffset, m_yOffset;
    QSize m_totalSize;
    bool m_autoUpdate;
    QScrollBar* m_sbV;
    QScrollBar* m_sbH;
    QWidget* m_sbCorner;
    void updateScrollBars();
};

#endif // TABLEVIEW_H