File: MainWindow.h

package info (click to toggle)
basic256 2.0.0.11-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 15,076 kB
  • sloc: cpp: 16,791; yacc: 3,979; lex: 1,446; makefile: 25
file content (234 lines) | stat: -rwxr-xr-x 6,066 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
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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
/** Copyright (C) 2006, Ian Paul Larsen.
 **
 **  This program is free software; you can redistribute it and/or modify
 **  it under the terms of the GNU General Public License as published by
 **  the Free Software Foundation; either version 2 of the License, or
 **  (at your option) any later version.
 **
 **  This program is distributed in the hope that it will be useful,
 **  but WITHOUT ANY WARRANTY; without even the implied warranty of
 **  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 **  GNU General Public License for more details.
 **
 **  You should have received a copy of the GNU General Public License along
 **  with this program; if not, write to the Free Software Foundation, Inc.,
 **  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 **/


#ifndef __MAINWINDOW_H
#define __MAINWINDOW_H

#include <qglobal.h>


#include <QNetworkAccessManager>
#include <QNetworkReply>
#include <QUrl>
#include <QJsonDocument>
#include <QJsonObject>
#include <QJsonArray>



#include <QtWidgets/QMainWindow>
#include <QtWidgets/QGridLayout>
#include <QtWidgets/QAction>
#include <QtWidgets/QMessageBox>
#include <QtWidgets/QShortcut>
#include <QtWidgets/QScrollArea>
#include <QtWidgets/QFontDialog>
#include <QtWidgets/QFileDialog>
#include <QClipboard>
#include <QFileSystemWatcher>

#include "BasicDock.h"
#include "BasicWidget.h"
#include "BasicOutput.h"
#include "BasicEdit.h"
#include "BasicGraph.h"
#include "VariableWin.h"
#include "PreferencesWin.h"
#include "RunController.h"
#include "EditSyntaxHighlighter.h"
#include "Settings.h"


class MainWindow : public QMainWindow
{
    Q_OBJECT
public:
  	MainWindow(QWidget * parent, Qt::WindowFlags f, QString localestring, int guistate);
	~MainWindow();
	void ifGuiStateRun();
    void ifGuiStateClose(bool ok);
	void closeEvent(QCloseEvent *);
    void setRunState(int);
    void dropEvent(QDropEvent *event);
    void dragEnterEvent(QDragEnterEvent *event);
    bool loadFile(QString);

    

	// Main IU Widgets
	BasicWidget * editwin_widget;
	BasicWidget * outwin_widget;
	BasicWidget * graphwin_widget;
	BasicWidget * varwin_widget;

	// file menu and choices
	QMenu * filemenu;
    QMenu * filemenu_recentfiles;
    QAction * filemenu_new_act;
	QAction * filemenu_open_act;
	QAction * filemenu_save_act;
    QAction * filemenu_saveas_act;
    QAction * filemenu_saveall_act;
    QAction * filemenu_print_act;
    QAction * filemenu_exit_act;
    QAction * filemenu_close_act;
    QAction * filemenu_closeall_act;

    // recent files submenu
    QAction * recentfiles_act[SETTINGSGROUPHISTN];
    QAction * recentfiles_empty_act;

	// edit menu and choices
	QMenu * editmenu;
	QAction *undoact;
	QAction *redoact;
	QAction *cutact;
	QAction *copyact;
	QAction *pasteact;
	QAction *selectallact;
	QAction *findact;
	QAction *findagain;
	QAction *replaceact;
	QAction *beautifyact;
	QAction *prefact;

	// view menu
	QMenu *viewmenu;
	QAction *editwin_visible_act;
	QAction *outwin_visible_act;
	QAction *graphwin_visible_act;
	QAction *varwin_visible_act;
	QAction *edit_whitespace_act;
	QAction *graph_grid_visible_act;
	QAction *fontact;
	QAction *main_toolbar_visible_act;
	QAction *outwin_toolbar_visible_act;
	QAction *graphwin_toolbar_visible_act;
    QMenu * viewmenu_zoom;
    QActionGroup *viewmenu_zoom_group;
    QAction *viewmenu_zoom_1_4;
    QAction *viewmenu_zoom_1_2;
    QAction *viewmenu_zoom_1_1;
    QAction *viewmenu_zoom_2_1;
    QAction *viewmenu_zoom_3_1;
    QAction *viewmenu_zoom_4_1;

	// run menu
	QMenu *runmenu;
	QAction * runact;
	QAction * debugact;
	QAction * stepact;
	QAction * bpact;
    QAction * stopact;
    QAction * clearbreakpointsact;

    // window menu
    QMenu *windowmenu;

    // help menu
    QAction * onlinehact;
    QAction * docact;
    QAction * helpthis;
    QAction * checkupdate;

    RunController *rc;
    EditSyntaxHighlighter * editsyntax;
    QFont editorFont;


	QString localecode;
	QLocale *locale;
	
signals:
    void setEditorRunState(int);
    void saveAllStep(int);

public slots:
  void updateStatusBar(QString);
  void updateWindowTitle(BasicEdit *);
  void newProgram();
  void updateEditorButtons();
#ifndef ANDROID
  void checkForUpdate(void);
#endif

private:
	BasicDock * outwin_dock;
	BasicDock * graphwin_dock;
	QScrollArea * graph_scroll;
	BasicDock * varwin_dock;
    QTabWidget *editwintabs;


	QToolBar *main_toolbar;
    
	// SEE GUISTATE* Constants
	void configureGuiState();
    bool autoCheckForUpdate;
	
	void loadCustomizations();
	void saveCustomizations();
    BasicEdit* newEditor(QString title);
    int untitledNumber;
    int runState;
    QFileSystemWatcher *fileSystemWatcher;

#ifndef ANDROID
    QNetworkRequest request;
    QNetworkAccessManager *manager;
#endif

	// void pointer to the run controller
	// can't specify type because of circular reference
	//void *rcvoidpointer;		

private slots:
    void updateRecent();
    void updateWindowMenu();
    void emptyRecent();
    void addFileToRecentList(QString);
    void about();
    void openRecent();
    void dialogFontSelect();
    void activeEditorPrint();
    void activeEditorSaveProgram();
    void activeEditorSaveAsProgram();
    void activeEditorUndo();
    void activeEditorRedo();
    void activeEditorCut();
    void activeEditorCopy();
    void activeEditorPaste();
    void activeEditorSelectAll();
    void activeEditorBeautifyProgram();
    void activeEditorClearBreakPoints();
    void currentEditorTabChanged(int);
    void closeEditorTab(int);
    void loadProgram();
    void activeEditorCloseTab();
    bool closeAllPrograms();
    void setCurrentEditorTab(BasicEdit*);
    void saveAll();
    void updateBreakPointsAction();
    void zoomGroupActionEvent(QAction*);

#ifndef ANDROID
    void sourceforgeReplyFinished(QNetworkReply* reply);
#endif
};

#endif