Rewrite SourceWindow to be derived from a QTextEdit.
[kdbg.git] / kdbg / textvw.h
blobf992022f4d344b01317a8413c859ab875e3c16e3
1 // $Id$
3 // Copyright by Johannes Sixt
4 // This file is under GPL, the GNU General Public Licence
6 #ifndef TEXTVW_H
7 #define TEXTVW_H
9 #include "tableview.h"
10 #include <vector>
12 class KTextView : public TableView
14 Q_OBJECT
15 public:
16 KTextView(QWidget* parent = 0, const char* name = 0, WFlags f = 0);
17 ~KTextView();
18 void insertLine(const QString& text);
19 void replaceLine(int line, const QString& text);
20 virtual void setCursorPosition(int row, int col);
21 virtual void cursorPosition(int* row, int* col);
22 void setText(const QString& t);
23 const QString& text(int i) const { return m_texts[i]; }
24 int paragraphs() const { return m_texts.size(); }
25 void insertParagraph(const QString& text, int row);
26 void removeParagraph(int row);
27 int charAt(const QPoint& p, int* para);
28 protected:
29 virtual int cellWidth(int col) const;
30 virtual int cellHeight(int row) const;
31 virtual void paintCell(QPainter* p, int row, int col);
32 virtual void activateLine(int row);
33 virtual int textCol() const;
34 virtual bool updateCellSize(const QString& text);
35 virtual void setupPainter(QPainter* p);
37 signals:
38 void lineChanged();
40 public slots:
41 void setTabWidth(int numChars);
43 // event handling
44 protected:
45 virtual void keyPressEvent(QKeyEvent* ev);
46 virtual void mousePressEvent(QMouseEvent* ev);
47 virtual void focusInEvent(QFocusEvent* ev);
48 virtual void focusOutEvent(QFocusEvent* ev);
50 void paletteChange(const QPalette& oldPal);
52 int m_width;
53 int m_height; /* line height */
54 int m_tabWidth; /* in pixels */
56 int m_curRow; /* cursor position */
57 private:
58 std::vector<QString> m_texts;
61 #endif // TEXTVW_H