Program Arguments dialog: Make the Help button invoke the help page.
[kdbg.git] / kdbg / sourcewnd.h
blob300f1b8f7856961a476564aab688e8a345563446
1 // $Id$
3 // Copyright by Johannes Sixt
4 // This file is under GPL, the GNU General Public Licence
6 #ifndef SOURCEWND_H
7 #define SOURCEWND_H
9 #include <qpixmap.h>
10 #include "textvw.h"
11 #include "dbgdriver.h"
13 // forward declarations
14 class KDebugger;
15 struct DbgAddr;
17 class SourceWindow : public KTextView
19 Q_OBJECT
20 public:
21 SourceWindow(const char* fileName, QWidget* parent, const char* name);
22 ~SourceWindow();
24 bool loadFile();
25 void reloadFile();
26 bool fileNameMatches(const QString& other);
27 void scrollTo(int lineNo, const DbgAddr& address);
28 const QString& fileName() const { return m_fileName; }
29 void updateLineItems(const KDebugger* dbg);
30 void setPC(bool set, int lineNo, const DbgAddr& address, int frameNo);
31 enum FindDirection { findForward = 1, findBackward = -1 };
32 void find(const QString& text, bool caseSensitive, FindDirection dir);
33 bool wordAtPoint(const QPoint& p, QString& word, QRect& r);
34 /**
35 * Translates row number (zero-based) to zero-based source line number.
36 * If sourceRow is non-zero, it is filled with the source code row
37 * belonging to the line number.
39 int rowToLine(int row, int* sourceRow = 0);
40 /** Translates zero-based source line number to row number (zero-based) */
41 int lineToRow(int line);
42 /** Is the row disassembled? */
43 bool isRowExpanded(int row);
44 /** Does the row show disassembled code? */
45 bool isRowDisassCode(int row);
47 /** lineNo is zero-based */
48 void disassembled(int lineNo, const QList<DisassembledCode>& disass);
50 void activeLine(int& lineNo, DbgAddr& address);
52 protected:
53 virtual int textCol() const;
54 virtual int cellWidth(int col) const;
55 virtual void paintCell(QPainter* p, int row, int col);
56 virtual void mousePressEvent(QMouseEvent* ev);
57 virtual void keyPressEvent(QKeyEvent* ev);
58 virtual void paletteChange(const QPalette&);
59 void updateLineItem(int i);
60 void expandRow(int row);
61 void collapseRow(int row);
62 void scrollToRow(int row);
63 /** translates (0-based) line number plus a code address into a row number */
64 int lineToRow(int row, const DbgAddr& address);
66 void actionExpandRow(int row);
67 void actionCollapseRow(int row);
69 signals:
70 void clickedLeft(const QString&, int, const DbgAddr& address, bool);
71 void clickedMid(const QString&, int, const DbgAddr& address);
72 void clickedRight(const QPoint &);
73 void disassemble(const QString&, int);
74 void expanded(int lineNo); /* source lineNo has been expanded */
75 void collapsed(int lineNo); /* source lineNo has been collapsed */
77 protected:
78 QString m_fileName;
79 enum LineItem { liPC = 1, liPCup = 2,
80 liBP = 4, liBPdisabled = 8, liBPtemporary = 16,
81 liBPconditional = 32, liBPorphan = 64,
82 liBPany = liBP|liBPdisabled|liBPtemporary|liBPconditional|liBPorphan
85 struct SourceLine {
86 QString code; /* a line of text */
87 ValArray<QString> disass; /* its disassembled code */
88 ValArray<DbgAddr> disassAddr; /* the addresses thereof */
89 bool canDisass; /* if line can be disassembled */
90 SourceLine() : canDisass(true) { }
91 int findAddressRowOffset(const DbgAddr& address) const;
93 ValArray<SourceLine> m_sourceCode;
95 ValArray<int> m_rowToLine; /* source line number for each row */
96 ValArray<uchar> m_lineItems;
97 QPixmap m_pcinner; /* PC at innermost frame */
98 QPixmap m_pcup; /* PC at frame up the stack */
99 QPixmap m_brkena; /* enabled breakpoint */
100 QPixmap m_brkdis; /* disabled breakpoint */
101 QPixmap m_brktmp; /* temporary breakpoint marker */
102 QPixmap m_brkcond; /* conditional breakpoint marker */
103 QPixmap m_brkorph; /* orphaned breakpoint marker */
106 #endif // SOURCEWND_H