| 1 | // File: objectcodepane.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 OBJECTCODEPANE_H |
| 23 | #define OBJECTCODEPANE_H |
| 24 | |
| 25 | #include <QWidget> |
| 26 | #include "enu.h" |
| 27 | |
| 28 | namespace Ui { |
| 29 | class ObjectCodePane; |
| 30 | } |
| 31 | |
| 32 | class ObjectCodePane : public QWidget { |
| 33 | Q_OBJECT |
| 34 | Q_DISABLE_COPY(ObjectCodePane) |
| 35 | public: |
| 36 | explicit ObjectCodePane(QWidget *parent = 0); |
| 37 | virtual ~ObjectCodePane(); |
| 38 | |
| 39 | void setObjectCode(QList<int> objectCode); |
| 40 | // Post Sets text in source code pane. |
| 41 | |
| 42 | void setObjectCodePaneText(QString string); |
| 43 | // Post: Sets text in source code pane to string. |
| 44 | |
| 45 | bool getObjectCode(QList<int> &objectCodeList); |
| 46 | // Pre: The object code pane contains object code |
| 47 | // Post: If the object code is syntactically correct, true is returned, and |
| 48 | // &objectCodeList contains the object code, one byte per integer. |
| 49 | // Otherwise, false is returned. |
| 50 | |
| 51 | void clearObjectCode(); |
| 52 | // Post: Clears the source code pane |
| 53 | |
| 54 | bool isModified(); |
| 55 | // Post: Returns true if the source code pane has been modified |
| 56 | |
| 57 | void setModifiedFalse(); |
| 58 | // Post: Sets isModified of the source code pane to false |
| 59 | |
| 60 | QString toPlainText(); |
| 61 | // Post: Contents of the source code pane are returned |
| 62 | |
| 63 | void setCurrentFile(QString string); |
| 64 | // Post: Title bar of the window is set to "Object Code - 'string'" |
| 65 | |
| 66 | void highlightOnFocus(); |
| 67 | // Post: Highlights the label based on the label window color saved in the UI file |
| 68 | |
| 69 | bool hasFocus(); |
| 70 | // Post: returns if the pane has focus |
| 71 | |
| 72 | void undo(); |
| 73 | // Post: the last action in the text edit is undone |
| 74 | |
| 75 | void redo(); |
| 76 | // Post: the last undo in the text edit is redone |
| 77 | |
| 78 | bool isUndoable(); |
| 79 | // Returns the undoability of the text edit |
| 80 | |
| 81 | bool isRedoable(); |
| 82 | // Returns the redoability of the text edit |
| 83 | |
| 84 | void cut(); |
| 85 | // Post: selected text in the text edit is cut to the clipboard |
| 86 | |
| 87 | void copy(); |
| 88 | // Post: selected text in the text edit is copied to the clipboard |
| 89 | |
| 90 | void paste(); |
| 91 | // Post: selected text in the clipboard is pasted to the text edit |
| 92 | |
| 93 | void setReadOnly(bool b); |
| 94 | // Post: the text edit's read only attribute is set to b |
| 95 | |
| 96 | public slots: |
| 97 | void onFontChanged(QFont font); |
| 98 | |
| 99 | private: |
| 100 | Ui::ObjectCodePane *ui; |
| 101 | |
| 102 | void mouseReleaseEvent(QMouseEvent *); |
| 103 | |
| 104 | void mouseDoubleClickEvent(QMouseEvent *); |
| 105 | |
| 106 | private slots: |
| 107 | void setLabelToModified(bool modified); |
| 108 | |
| 109 | signals: |
| 110 | void undoAvailable(bool); |
| 111 | void redoAvailable(bool); |
| 112 | |
| 113 | void labelDoubleClicked(Enu::EPane pane); |
| 114 | }; |
| 115 | |
| 116 | #endif // OBJECTCODEPANE_H |