10 #include <gtkmm/filechooserdialog.h> 16 #include "../views/MainWindowView.h" 26 :
Model(parent), view(view) {
56 (
getParent()->getAbsolutePathToProjectRoot() +
"/bin/aasm").c_str(),
78 std::cout <<
"Error loading file into KoMo2." << std::endl;
92 Gtk::FileChooserDialog dialog(
"File explorer", Gtk::FILE_CHOOSER_ACTION_OPEN);
95 dialog.set_transient_for(*
getParent()->getMainWindow());
98 dialog.add_button(
"_Cancel", Gtk::RESPONSE_CANCEL);
99 dialog.add_button(
"_Open", Gtk::RESPONSE_OK);
102 auto assemblyFilter = Gtk::FileFilter::create();
103 assemblyFilter->set_name(
"ARM assembly files");
104 assemblyFilter->add_pattern(
"*.s");
105 dialog.add_filter(assemblyFilter);
121 const Gtk::FileChooserDialog*
const dialog) {
124 case (Gtk::RESPONSE_OK): {
131 case (Gtk::RESPONSE_CANCEL): {
153 const std::string absolutePath)
const {
154 return absolutePath.substr(0, absolutePath.size() - 1).append(
"kmd");
172 case JimulatorState::UNLOADED:
177 case JimulatorState::LOADED:
183 case JimulatorState::RUNNING:
189 case JimulatorState::PAUSED:
206 if ((e->state & (GDK_SHIFT_MASK | GDK_CONTROL_MASK | GDK_MOD1_MASK)) !=
245 std::string filename =
254 case CompileLoadInnerState::FILE_SELECTED:
258 case CompileLoadInnerState::NO_FILE:
const std::string getAbsolutePathToSelectedFile() const
Gets the absolutePathToSelectedFile member variable.
void setButtonState(Gtk::Button *const button, const bool state, Gtk::Image *const img=nullptr, const std::string newTooltip="", const std::string newLabelText="") const
Sets the state of a button to some boolean - the assumption is that if a button is not meant to be se...
void resetJimulator()
Reset the emulators running.
void onCompileLoadClick() const
Compiles a .s file into a .kmd file: Forks a child process, executes aasm on the child, and then load it into Jimulator, if a valid file path is given.
CompileLoadInnerState
An enum indicating the state of the specific compile and load section of the GUI - specifically...
void compileJimulator(std::string pathToBin, const char *const pathToS, const char *const pathToKMD)
Runs pathToS through the associated compiler binary, and outputs a .kmd file at pathToKMD.
KoMo2Model *const getParent() const
Returns the parent pointer.
void setInnerState(const CompileLoadInnerState newState)
Handles changing the inner state of this model (whether a file is selected or not) ...
JimulatorState getJimulatorState() const
Return the jimulatorState member object.
CompileLoadModel(CompileLoadView *const view, KoMo2Model *const parent)
Construct a new CompileLoadModel::CompileLoadModel object.
const CompileLoadInnerState getInnerState() const
Get the Inner State object.
void setModel(CompileLoadModel *const val)
Set the model pointer.
JimulatorState
Describe the 5 states of Jimulator.
void setButtonListener(Gtk::Button *const button, const T1 b, const T2 c)
Connect any button to any member function of.
MainWindowView *const getMainWindow() const
Gets the mainWindow member variable.
virtual void changeJimulatorState(const JimulatorState newState) override
Handles a change in JimulatorState for this model.
A file containing the definition of the KoMo2Model class.
The superclass for all other Model classes. Uses a pure virtual function, so is abastract. Keeps KoMo2Model as a friend so it alone can call setJimulatorState. This class provides basic data that are needed by all other.
const std::string makeKmdPath(const std::string absolutePath) const
Takes an ARM assembly file, removes it's current s extension, and appends kmd. For example...
const bool loadJimulator(const char *const pathToKMD)
Clears the existing source object and loads the file at pathToKMD into Jimulator. ...
CompileLoadInnerState innerState
Stores the state of the compile and load section of the GUI.
The logical model of the entire application. All other models should be member variables of this mode...
void onBrowseClick()
Opens a file selection dialog upon the BrowseButtonView being clicked.
std::string absolutePathToSelectedFile
State - stores the value of the absolute file path to a .s file, as chosen by the file browser compon...
CompileLoadView *const view
A pointer to the view that this model represents.
Gtk::Button *const getCompileAndLoadButton()
Gets the compileAndLoadButton member variable.
Gtk::Button *const getBrowseButton()
Gets the browseButton member variable.
void setAbsolutePathToSelectedFile(const std::string val)
Sets the absolutePathToSelectedFile member variable.
virtual const bool handleKeyPress(const GdkEventKey *const e) override
Handles a key press event for this model.
virtual void changeJimulatorState(const JimulatorState newState) override
Changes the Jimulator state and calls each child models own changeJimulatorState function.
void setSelectedFileLabelText(const std::string val)
Sets the text displayed by the selectedFileLabel member variable.
This class represents the visual aspects that make up the compile & load section of the KoMo2 GUI...
void handleResultFromFileBrowser(const int result, const Gtk::FileChooserDialog *const dialog)
Handles the result of the file browser dialog box being closed.