KoMo2  1.0.0
A modern ARM emulator GUI.
Model.cpp
Go to the documentation of this file.
1 
10 #include "Model.h"
11 #include <gtkmm/button.h>
12 #include <gtkmm/image.h>
13 #include <string>
14 
15 // Sets the static jimulatorState to its initial value
16 JimulatorState Model::jimulatorState = JimulatorState::INITIAL;
17 
22 Model::Model(KoMo2Model* const parent) : parent(parent) {}
23 
37 void Model::setButtonState(Gtk::Button* const button,
38  const bool state,
39  Gtk::Image* const img,
40  const std::string newTooltip,
41  const std::string newLabelText) const {
42  button->set_sensitive(state);
43  button->set_has_tooltip(state);
44 
45  // If newToolTip isn't the default parameter, update the tooltip text
46  if (newTooltip != "") {
47  button->set_tooltip_text(newTooltip);
48  }
49 
50  // If img isn't the default parameter, update the button image
51  if (img != nullptr) {
52  button->set_image(*img);
53  }
54 
55  // If newLabelText isn't the default parameter, update the button label
56  if (newLabelText != "") {
57  button->set_label(newLabelText);
58  }
59 }
60 
61 // ! Getters and setters
62 
67 KoMo2Model* const Model::getParent() const {
68  return parent;
69 }
70 
76  return Model::jimulatorState;
77 }
78 
85 }
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...
Definition: Model.cpp:37
A file containing the declaration of the class Model and the enumerable type JimulatorState.
KoMo2Model *const getParent() const
Returns the parent pointer.
Definition: Model.cpp:67
JimulatorState getJimulatorState() const
Return the jimulatorState member object.
Definition: Model.cpp:75
KoMo2Model *const parent
All models have a parent model - KoMo2Model, the most senior model in the hierarchy, sets its parent to self.
Definition: Model.h:87
JimulatorState
Describe the 5 states of Jimulator.
Definition: Model.h:19
void setJimulatorState(const JimulatorState val)
set the JimulatorState member object.
Definition: Model.cpp:83
The logical model of the entire application. All other models should be member variables of this mode...
Definition: KoMo2Model.h:34
Model(KoMo2Model *const parent)
Constructs a new Model object - just assigns the parent variable.
Definition: Model.cpp:22
static JimulatorState jimulatorState
JimulatorState reflects the state in which Jimulator is operating, which in turn affects the model of...
Definition: Model.h:95