KoMo2  1.0.0
A modern ARM emulator GUI.
RegistersView.cpp
Go to the documentation of this file.
1 
12 #include "RegistersView.h"
13 #include <iostream>
14 #include <string>
15 #include "../models/KoMo2Model.h"
16 
22  : grid(), parent(parent) {
24 }
25 
30  // Sets up each member of the array
31  for (long unsigned int i = 0; i < labelArray.size(); i++) {
32  for (long unsigned int j = 0; j < labelArray[i].size(); j++) {
33  if (i == 0) {
35  } else {
37  }
38 
39  initAllLabels(i, j);
40  }
41  }
42 
43  initGrid();
44 }
45 
51  labelArray[0][j].set_size_request(70, 22);
52 
53  // Get some text for the left hand label
54  const auto s = j != 15 ? "R" + std::to_string(j) : "PC";
55  labelArray[0][j].set_text(s);
56  labelArray[0][j].get_accessible()->set_name(s);
57 }
58 
64  labelArray[1][j].set_size_request(120, 22);
65  labelArray[1][j].set_xalign(0.1);
66 }
67 
73 void RegistersView::initAllLabels(const int i, const int j) {
74  labelArray[i][j].set_yalign(1);
75  labelArray[i][j].get_style_context()->add_class("tableLabels");
76  grid.attach(labelArray[i][j], i, j, 1, 1);
77 }
78 
83  grid.set_column_homogeneous(false);
84  grid.set_column_spacing(3);
85  grid.set_row_spacing(3);
86  grid.get_style_context()->add_class("registerTable");
87  pack_start(grid, true, true);
88  show_all_children();
89 }
90 
91 // ! Getters and setters
92 
98  model = val;
99 }
105  return model;
106 }
112 std::array<std::array<Gtk::Label, 16>, 2>* const RegistersView::getLabels() {
113  return &labelArray;
114 }
std::array< std::array< Gtk::Label, 16 >, 2 > *const getLabels()
Return a reference to the member array of labels, labelArray.
void initAllLabels(const int i, const int j)
Initialisations that have to happen for both sides of the table.
RegistersModel *const getModel() const
gets the model for this view.
RegistersModel * model
A pointer to the related model.
Definition: RegistersView.h:61
std::array< std::array< Gtk::Label, 16 >, 2 > labelArray
An array of labels, with the left side representing the registers name and the right side representin...
Definition: RegistersView.h:51
RegistersView(MainWindowView *const parent)
Constructs a new RegisterView object.
Gtk::Grid grid
The layout that stores all of the labelArray members.
Definition: RegistersView.h:46
The class definition of the main window of the program. This main window is the mater view of the pro...
void initGrid()
Initialisation instructions for the grid.
void initRightHandLabel(const int j)
Initialises the right hand labels within the array.
void initRegisterViewContainer()
Initialises the register view.
void setModel(RegistersModel *const val)
Sets the model for this view.
Stores data and functions relating to the tracking and manipulation of data within the RegistersView ...
This file declares the class RegistersView, which represents the viewable GUI element that displays i...
void initLeftHandLabel(const int j)
Initialises the left hand labels within the array.