| 1 | // File: mainwindow.h |
| 2 | /* |
| 3 | Pep8-1 is a virtual machine for writing machine language and assembly |
| 4 | language programs. |
| 5 | |
| 6 | Copyright (C) 2009 J. Stanley Warford, Pepperdine University |
| 7 | |
| 8 | This program is free software: you can redistribute it and/or modify |
| 9 | it under the terms of the GNU General Public License as published by |
| 10 | the Free Software Foundation, either version 3 of the License, or |
| 11 | (at your option) any later version. |
| 12 | |
| 13 | This program is distributed in the hope that it will be useful, |
| 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | GNU General Public License for more details. |
| 17 | |
| 18 | You should have received a copy of the GNU General Public License |
| 19 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 20 | */ |
| 21 | |
| 22 | #ifndef MAINWINDOW_H |
| 23 | #define MAINWINDOW_H |
| 24 | |
| 25 | #include <QtWidgets/QMainWindow> |
| 26 | #include "byteconverterdec.h" |
| 27 | #include "byteconverterhex.h" |
| 28 | #include "byteconverterbin.h" |
| 29 | #include "byteconverterchar.h" |
| 30 | #include "byteconverterinstr.h" |
| 31 | |
| 32 | // Left pane |
| 33 | #include "sourcecodepane.h" |
| 34 | #include "objectcodepane.h" |
| 35 | #include "assemblerlistingpane.h" |
| 36 | #include "listingtracepane.h" |
| 37 | #include "memorytracepane.h" |
| 38 | |
| 39 | // Middle pane |
| 40 | #include "cpupane.h" |
| 41 | #include "inputpane.h" |
| 42 | #include "outputpane.h" |
| 43 | #include "terminalpane.h" |
| 44 | |
| 45 | // Right pane |
| 46 | #include "memorydumppane.h" |
| 47 | |
| 48 | // Dialog boxes |
| 49 | #include "redefinemnemonicsdialog.h" |
| 50 | #include "helpdialog.h" |
| 51 | #include "aboutpep.h" |
| 52 | |
| 53 | namespace Ui |
| 54 | { |
| 55 | class MainWindowClass; |
| 56 | } |
| 57 | |
| 58 | class MainWindow : public QMainWindow |
| 59 | { |
| 60 | Q_OBJECT |
| 61 | |
| 62 | public: |
| 63 | MainWindow(QWidget *parent = 0); |
| 64 | ~MainWindow(); |
| 65 | |
| 66 | protected: |
| 67 | void closeEvent(QCloseEvent *event); |
| 68 | |
| 69 | private: |
| 70 | Ui::MainWindowClass *ui; |
| 71 | QFont codeFont; |
| 72 | // Left pane |
| 73 | SourceCodePane *sourceCodePane; |
| 74 | ObjectCodePane *objectCodePane; |
| 75 | AssemblerListingPane *assemblerListingPane; |
| 76 | ListingTracePane *listingTracePane; |
| 77 | MemoryTracePane *memoryTracePane; |
| 78 | |
| 79 | // Middle pane |
| 80 | CpuPane *cpuPane; |
| 81 | InputPane *inputPane; |
| 82 | OutputPane *outputPane; |
| 83 | TerminalPane *terminalPane; |
| 84 | |
| 85 | // Right pane |
| 86 | MemoryDumpPane *memoryDumpPane; |
| 87 | |
| 88 | // Dialog boxes |
| 89 | RedefineMnemonicsDialog *redefineMnemonicsDialog; |
| 90 | HelpDialog *helpDialog; |
| 91 | AboutPep *aboutPepDialog; |
| 92 | |
| 93 | // Byte converter |
| 94 | ByteConverterDec *byteConverterDec; |
| 95 | ByteConverterHex *byteConverterHex; |
| 96 | ByteConverterBin *byteConverterBin; |
| 97 | ByteConverterChar *byteConverterChar; |
| 98 | ByteConverterInstr *byteConverterInstr; |
| 99 | |
| 100 | // Save methods |
| 101 | bool saveSource(); |
| 102 | bool saveObject(); |
| 103 | bool saveListing(); |
| 104 | void readSettings(); |
| 105 | void writeSettings(); |
| 106 | bool maybeSaveSource(); |
| 107 | bool maybeSaveObject(); |
| 108 | void loadFile(const QString &fileName); |
| 109 | bool saveFileSource(const QString &fileName); |
| 110 | bool saveFileObject(const QString &fileName); |
| 111 | bool saveFileListing(const QString &fileName); |
| 112 | void setCurrentFile(const QString &fileName, Enu::EPane pane); |
| 113 | QString strippedName(const QString &fullFileName); |
| 114 | |
| 115 | QString curSourceFile; |
| 116 | QString curObjectFile; |
| 117 | QString curListingFile; |
| 118 | QString curPath; |
| 119 | |
| 120 | // Recent Files methods |
| 121 | void updateRecentFileActions(); |
| 122 | enum { MaxRecentFiles = 5}; |
| 123 | QAction *recentFileActs[MaxRecentFiles]; |
| 124 | QAction *separatorAct; |
| 125 | |
| 126 | bool assemble(); |
| 127 | bool load(); |
| 128 | |
| 129 | void setDebugState(bool b); |
| 130 | |
| 131 | bool eventFilter(QObject *, QEvent *event); |
| 132 | |
| 133 | private slots: |
| 134 | // File |
| 135 | void on_actionFile_New_triggered(); |
| 136 | void on_actionFile_Open_triggered(); |
| 137 | bool on_actionFile_Save_Source_triggered(); |
| 138 | bool on_actionFile_Save_Source_As_triggered(); |
| 139 | bool on_actionFile_Save_Object_As_triggered(); |
| 140 | bool on_actionFile_Save_Listing_As_triggered(); |
| 141 | void on_actionFile_Print_Source_triggered(); |
| 142 | void on_actionFile_Print_Object_triggered(); |
| 143 | void on_actionFile_Print_Listing_triggered(); |
| 144 | |
| 145 | // Edit |
| 146 | void on_actionEdit_Undo_triggered(); |
| 147 | void on_actionEdit_Redo_triggered(); |
| 148 | void on_actionEdit_Cut_triggered(); |
| 149 | void on_actionEdit_Copy_triggered(); |
| 150 | void on_actionEdit_Paste_triggered(); |
| 151 | void on_actionEdit_Format_From_Listing_triggered(); |
| 152 | void on_actionEdit_Font_triggered(); |
| 153 | void on_actionReset_Fonts_to_Defaults_triggered(); |
| 154 | void on_actionEdit_Remove_Error_Messages_triggered(); |
| 155 | |
| 156 | // Build |
| 157 | void on_actionBuild_Assemble_triggered(); |
| 158 | void on_actionBuild_Load_triggered(); |
| 159 | void on_actionBuild_Execute_triggered(); |
| 160 | void on_actionBuild_Run_Source_triggered(); |
| 161 | void on_actionBuild_Start_Debugging_Source_triggered(); |
| 162 | void on_actionBuild_Run_Object_triggered(); |
| 163 | void on_actionBuild_Start_Debugging_Object_triggered(); |
| 164 | void on_actionBuild_Start_Debugging_Loader_triggered(); |
| 165 | void on_actionBuild_Stop_Debugging_triggered(); |
| 166 | void on_actionBuild_Interrupt_Execution_triggered(); |
| 167 | |
| 168 | // View |
| 169 | void on_actionView_Code_Only_triggered(); |
| 170 | void on_actionView_Code_CPU_triggered(); |
| 171 | void on_actionView_Code_CPU_Memory_triggered(); |
| 172 | void on_actionView_Code_Tab_triggered(); |
| 173 | void on_actionView_Trace_Tab_triggered(); |
| 174 | void on_actionView_Batch_I_O_Tab_triggered(); |
| 175 | void on_actionView_Terminal_Tab_triggered(); |
| 176 | |
| 177 | // System |
| 178 | void on_actionSystem_Clear_Memory_triggered(); |
| 179 | void on_actionSystem_Redefine_Mnemonics_triggered(); |
| 180 | void on_actionSystem_Assemble_Install_New_OS_triggered(); |
| 181 | void on_actionSystem_Reinstall_Default_OS_triggered(); |
| 182 | |
| 183 | // Help |
| 184 | void on_actionHelp_triggered(); |
| 185 | void on_actionHelp_Check_for_updates_triggered(); |
| 186 | void on_actionHelp_Machine_Language_triggered(); |
| 187 | void on_actionHelp_Assembly_Language_triggered(); |
| 188 | void on_actionHelp_Debugging_Programs_triggered(); |
| 189 | void on_actionHelp_Writing_Trap_Handlers_triggered(); |
| 190 | void on_actionHelp_Pep_8_Reference_triggered(); |
| 191 | void on_actionHelp_Examples_triggered(); |
| 192 | void on_actionHelp_Pep_8_Operating_System_triggered(); |
| 193 | void on_actionAbout_Pep8_triggered(); |
| 194 | void on_actionAbout_Qt_triggered(); |
| 195 | |
| 196 | void helpCopyToSourceButtonClicked(); |
| 197 | |
| 198 | // Byte converter |
| 199 | void slotByteConverterDecEdited(const QString &); |
| 200 | void slotByteConverterHexEdited(const QString &); |
| 201 | void slotByteConverterBinEdited(const QString &); |
| 202 | void slotByteConverterCharEdited(const QString &); |
| 203 | |
| 204 | // Focus coloring Undo/Redo/Cut/Copy/Paste activate/deactivate |
| 205 | void mainWindowUtilities(QWidget *, QWidget *); |
| 206 | void setUndoability(bool b); |
| 207 | void setRedoability(bool b); |
| 208 | |
| 209 | void doubleClickedCodeLabel(Enu::EPane pane); |
| 210 | // void resizeDocWidth(int, int); |
| 211 | |
| 212 | // For updating the CPU and Memory trace from listing trace pane |
| 213 | void updateSimulationView(); |
| 214 | void vonNeumannStepped(); |
| 215 | void appendOutput(QString str); |
| 216 | |
| 217 | // Terminal IO: |
| 218 | void waitingForInput(); |
| 219 | void inputReceived(); |
| 220 | |
| 221 | void resumeButtonClicked(); |
| 222 | void singleStepButtonClicked(); |
| 223 | |
| 224 | // Recent files |
| 225 | void openRecentFile(); |
| 226 | |
| 227 | /* |
| 228 | These belong in the other panes |
| 229 | // Trace |
| 230 | void on_pepMemSingleStepPushButton_clicked(); |
| 231 | void on_pepMemResumePushButton_clicked(); |
| 232 | void pepResumePushButtonClicked(); |
| 233 | |
| 234 | // Memory pane |
| 235 | void on_pepMemRefreshPushButton_clicked(); |
| 236 | |
| 237 | // CPU stats |
| 238 | void slotSaveTraceProgram(int); |
| 239 | void slotSaveTraceTraps(int); |
| 240 | void slotSaveTraceLoader(int); |
| 241 | */ |
| 242 | signals: |
| 243 | void fontChanged(QFont font); |
| 244 | }; |
| 245 | |
| 246 | #endif // MAINWINDOW_H |