summaryrefslogtreecommitdiffstats
path: root/kdbg/mainwndbase.h
blob: 8dc919b14b58d371bd4f6da6ba77feff8123ab65 (plain)
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
/*
 * Copyright Johannes Sixt
 * This file is licensed under the GNU General Public License Version 2.
 * See the file COPYING in the toplevel directory of the source directory.
 */

#ifndef MAINWNDBASE_H
#define MAINWNDBASE_H

#include <ntqlineedit.h>
#include <ntqlayout.h>
#include <ntqpushbutton.h>
#include <ntqcstring.h>
#include "exprwnd.h"
#include "sys/types.h"			/* pid_t */

// forward declarations
class KDebugger;
class TTYWindow;
class UpdateUI;
class TDEToolBar;
class KStatusBar;
class TDEProcess;
class DebuggerDriver;

class WatchWindow : public TQWidget
{
    Q_OBJECT
public:
    WatchWindow(TQWidget* parent, const char* name, WFlags f = 0);
    ~WatchWindow();
    ExprWnd* watchVariables() { return &m_watchVariables; }
    TQString watchText() const { return m_watchEdit.text(); }
    int columnWidth(int i) const { return m_watchVariables.columnWidth(i); }
    void setColumnWidth(int i, int w) { m_watchVariables.setColumnWidth(i, w); }

protected:
    TQLineEdit m_watchEdit;
    TQPushButton m_watchAdd;
    TQPushButton m_watchDelete;
    ExprWnd m_watchVariables;
    TQVBoxLayout m_watchV;
    TQHBoxLayout m_watchH;

    virtual bool eventFilter(TQObject* ob, TQEvent* ev);
    virtual void dragEnterEvent(TQDragEnterEvent* event);
    virtual void dropEvent(TQDropEvent* event);

signals:
    void addWatch();
    void deleteWatch();
    void textDropped(const TQString& text);

protected slots:
    void slotWatchHighlighted();
};


class DebuggerMainWndBase
{
public:
    DebuggerMainWndBase();
    virtual ~DebuggerMainWndBase();

    /**
     * Sets the command to invoke the terminal that displays the program
     * output. If cmd is the empty string, the default is substituted.
     */
    void setTerminalCmd(const TQString& cmd);
    /**
     * Sets the command to invoke the debugger.
     */
    void setDebuggerCmdStr(const TQString& cmd);
    /**
     * Specifies the file where to write the transcript.
     */
    void setTranscript(const TQString& name);
    /**
     * Starts to debug the specified program using the specified language
     * driver.
     */
    bool debugProgram(const TQString& executable, TQString lang, TQWidget* parent);
    /**
     * Specifies the process to attach to after the program is loaded.
     */
    void setAttachPid(const TQString& pid);

    // the following are needed to handle program arguments
    void setCoreFile(const TQString& corefile);
    void setRemoteDevice(const TQString &remoteDevice);
    void overrideProgramArguments(const TQString& args);
    /** helper around KFileDialog */
    static TQString myGetFileName(TQString caption,
				 TQString dir, TQString filter,
				 TQWidget* parent);
    /** invokes the global options dialog */
    virtual void doGlobalOptions(TQWidget* parent);

protected:
    // settings
    virtual void saveSettings(TDEConfig*);
    virtual void restoreSettings(TDEConfig*);

    // override must return the integrated output window
    virtual TTYWindow* ttyWindow() = 0;

    // statusbar texts
    TQString m_statusActive;

    // output window
    TQString m_outputTermCmdStr;
    TQString m_outputTermKeepScript;
    TDEProcess* m_outputTermProc;
    int m_ttyLevel;
    virtual TQString createOutputWindow();	/* returns terminal name */
    void shutdownTermWindow();

    TQString m_lastDirectory;		/* the dir of the most recently opened file */

    TQString m_transcriptFile;		/* where gdb dialog is logged */

    bool m_popForeground;		/* whether main wnd raises when prog stops */
    int m_backTimeout;			/* when wnd goes back */
    int m_tabWidth;			/* tab width in characters (can be 0) */
    TQString m_sourceFilter;
    TQString m_headerFilter;

    // the debugger proper
    TQString m_debuggerCmdStr;
    KDebugger* m_debugger;
    void setupDebugger(TQWidget* parent,
		       ExprWnd* localVars,
		       ExprWnd* watchVars,
		       TQListBox* backtrace);
    DebuggerDriver* driverFromLang(TQString lang);
    /**
     * This function derives a driver name from the contents of the named
     * file.
     */
    TQString driverNameFromFile(const TQString& exe);

public:
    /*
     * Important! The following functions must be overridden in derived
     * classes and be declared as slots! Note: These must not be declared
     * virtual here since TQt signal mechanism fails miserably (because this
     * class will not be the left-most base class!).
     */
    void newStatusMsg(KStatusBar* statusbar);
    void slotDebuggerStarting();
};

#endif // MAINWNDBASE_H