Mercurial > jwe > qt-gui-with-push-parser
annotate gui-main.h @ 2:b97ffa8e4019
multiple inclusion guards in .h files
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Wed, 22 May 2019 16:20:52 -0400 |
parents | 08df60a01bc1 |
children | 0e154787183d |
rev | line source |
---|---|
2
b97ffa8e4019
multiple inclusion guards in .h files
John W. Eaton <jwe@octave.org>
parents:
1
diff
changeset
|
1 #if ! defined (calc_gui_main_h) |
b97ffa8e4019
multiple inclusion guards in .h files
John W. Eaton <jwe@octave.org>
parents:
1
diff
changeset
|
2 #define calc_gui_main_h 1 |
0 | 3 |
4 #include <iostream> | |
5 #include <sstream> | |
6 #include <string> | |
7 | |
8 #include <cstdlib> | |
9 #include <cstring> | |
10 | |
11 #include <QApplication> | |
12 #include <QTextDocument> | |
13 #include <QTextEdit> | |
14 | |
15 namespace gui | |
16 { | |
17 class command_window : public QTextEdit | |
18 { | |
19 Q_OBJECT | |
20 | |
21 public: | |
22 | |
23 command_window (QWidget *p = nullptr); | |
24 | |
25 virtual ~command_window (void) = default; | |
26 | |
27 // Accept an input line, parse and possibly execute it. | |
28 | |
29 void accept (const std::string& line); | |
30 | |
31 // Redisplay current command line. | |
32 | |
33 void redisplay (void); | |
34 | |
35 void insert_at_end (const std::string& text); | |
36 | |
1
08df60a01bc1
debug flag, handle input with signal
John W. Eaton <jwe@octave.org>
parents:
0
diff
changeset
|
37 void emit_error (const std::string& msg); |
08df60a01bc1
debug flag, handle input with signal
John W. Eaton <jwe@octave.org>
parents:
0
diff
changeset
|
38 |
0 | 39 void emit_result (double value); |
40 | |
41 signals: | |
42 | |
1
08df60a01bc1
debug flag, handle input with signal
John W. Eaton <jwe@octave.org>
parents:
0
diff
changeset
|
43 void input_char_available (int key); |
08df60a01bc1
debug flag, handle input with signal
John W. Eaton <jwe@octave.org>
parents:
0
diff
changeset
|
44 |
0 | 45 void result_available (double value); |
46 | |
47 public slots: | |
48 | |
1
08df60a01bc1
debug flag, handle input with signal
John W. Eaton <jwe@octave.org>
parents:
0
diff
changeset
|
49 void handle_input_char (int key); |
08df60a01bc1
debug flag, handle input with signal
John W. Eaton <jwe@octave.org>
parents:
0
diff
changeset
|
50 |
0 | 51 void handle_result (double value); |
52 | |
53 protected: | |
54 | |
55 void keyPressEvent (QKeyEvent *event); | |
56 | |
57 int do_arrow_key (int arrow_key); | |
58 | |
59 // Retrieve a command from the history list and insert it on the | |
60 // current command. | |
61 | |
62 void history (bool up); | |
63 | |
64 void erase_line (void); | |
65 | |
66 void insert_at_cursor (const std::string& text); | |
67 | |
68 void insert_line (const std::string& prompt, const std::string& line); | |
69 | |
70 int set_mark (void); | |
71 | |
72 void insert_result (double value); | |
73 | |
74 void scroll_to_bottom (void); | |
75 | |
76 // Child widgets: | |
77 | |
78 QTextDocument *m_buffer; | |
79 | |
80 int beg_mark; | |
81 int prompt_mark; | |
82 }; | |
83 | |
84 extern int main (int argc, char **argv); | |
85 | |
1
08df60a01bc1
debug flag, handle input with signal
John W. Eaton <jwe@octave.org>
parents:
0
diff
changeset
|
86 extern void emit_error (const std::string& msg); |
08df60a01bc1
debug flag, handle input with signal
John W. Eaton <jwe@octave.org>
parents:
0
diff
changeset
|
87 |
0 | 88 extern void emit_result (double value); |
89 } | |
90 | |
91 #endif |