KoMo2  1.0.0
A modern ARM emulator GUI.
DisassemblyView.cpp
Go to the documentation of this file.
1 
10 #include "DisassemblyView.h"
11 #include <sstream>
12 #include "../models/DisassemblyModel.h"
13 
19  : parent(parent) {
22 }
23 
29  disassemblyContainer.set_layout(Gtk::BUTTONBOX_START);
30  get_style_context()->add_class("disassemblyContainer");
32  show();
33  show_all_children();
34 }
35 
41  for (long unsigned int i = 0; i < rows.size(); i++) {
42  disassemblyContainer.pack_start(rows[i], false, false);
43  rows[i].setModel(model);
44  }
45 }
46 
47 // !!!!!!!!!!!!!!!!!!!!!!!
48 // ! Getters and setters !
49 // !!!!!!!!!!!!!!!!!!!!!!!
50 
55 std::vector<DisassemblyRows>* const DisassemblyView::getRows() {
56  return &rows;
57 }
63  model = val;
64 }
70  return model;
71 }
77  return parent;
78 }
79 
80 // !!!!!!!!!!!!!!!!!!!!!!
81 // ! Nested class stuff !
82 // !!!!!!!!!!!!!!!!!!!!!!
83 
88  : Box(Gtk::Orientation::ORIENTATION_HORIZONTAL, 0) {
90  initAddress();
91  initHex();
93 
94  set_spacing(0);
95 
96  buttonSizer.set_size_request(5, 5);
97  buttonSizer.pack_start(breakpoint, false, false);
98  add(buttonSizer);
99  add(address);
100  add(hex);
101  add(disassembly);
102  get_style_context()->add_class("disassemblyRows");
103  set_can_focus(true);
104  set_focus_on_click(true);
105  show();
106  show_all_children();
107 }
108 
113  breakpoint.set_size_request(5, 5);
114  breakpoint.get_style_context()->add_class("breakpointButtons");
115  breakpoint.set_tooltip_text("Toggle breakpoint");
116  breakpoint.set_can_focus(false);
117 }
122  address.get_style_context()->add_class("disassemblyLabels");
123  address.set_size_request(100, 10);
124  address.set_xalign(0.0);
125 }
130  hex.get_style_context()->add_class("disassemblyLabels");
131  hex.set_size_request(100, 10);
132  hex.set_xalign(0.0);
133 }
138  disassembly.get_style_context()->add_class("disassemblyLabels");
139  disassembly.set_size_request(500, 10);
140  disassembly.set_xalign(0.0);
141 }
142 
143 // ! Getters and setters
144 
151 void DisassemblyRows::setBreakpoint(const bool state) {
152  if (state) {
153  breakpoint.set_state_flags(Gtk::STATE_FLAG_CHECKED);
154  } else {
155  breakpoint.set_state_flags(Gtk::STATE_FLAG_NORMAL);
156  }
157 }
162 void DisassemblyRows::setAddress(const std::string text) {
163  address.set_text(text);
164 }
169 void DisassemblyRows::setHex(const std::string text) {
170  hex.set_text(text);
171 }
176 void DisassemblyRows::setDisassembly(const std::string text) {
177  disassembly.set_text(text);
178 }
184 Gtk::ToggleButton* const DisassemblyRows::getButton() {
185  return &breakpoint;
186 }
192  model = val;
193 }
198 const std::string DisassemblyRows::getAddress() const {
199  return address.get_text();
200 }
205 const uint32_t DisassemblyRows::getAddressVal() const {
206  return addressVal;
207 }
212 void DisassemblyRows::setAddressVal(const uint32_t val) {
213  addressVal = val;
214 }
221  return breakpoint.get_state_flags() ==
222  (Gtk::STATE_FLAG_CHECKED | Gtk::STATE_FLAG_DIR_LTR);
223 }
228 const std::string DisassemblyRows::getDisassembly() {
229  return disassembly.get_text();
230 }
void setAddressVal(const uint32_t val)
Set the value of addressVal member.
void setModel(DisassemblyModel *const val)
Sets the value of the model member.
DisassemblyView(MainWindowView *const parent)
Construct a new DisassemblyView::DisassemblyView object.
The declaration of the DisassemblyModel class.
DisassemblyModel * model
A pointer to the related model.
uint32_t addressVal
The address pointed to, as an integer.
DisassemblyRows()
Construct a new DisassemblyRows::DisassemblyRows object.
void initDisassemblyRows()
Packs the 13 disassemblyRows into their container and gives them a pointer to the DisassemblyModel ob...
const std::string getAddress() const
Get the text in the address box.
Gtk::Label address
Displays the address of the current memory value.
void initDisassemblyContainer()
Initialises the containers & their children - packs children into containers, sets sizes and layouts...
std::vector< DisassemblyRows > *const getRows()
Gets a pointer to the rows of views.
void setDisassembly(const std::string text)
Set the text of disassembly label.
void initHex()
Initialises the hex label.
Gtk::Label disassembly
Displays the current disassembly value of the memory.
const bool getBreakpoint()
Returns if a breakpoint is set or not.
void setBreakpoint(const bool text)
Set the state of the breakpoint button. This is a little unusual - it sets the state in terms of CSS ...
The class definition of the main window of the program. This main window is the mater view of the pro...
DisassemblyModel * model
A pointer to the model.
Gtk::HBox buttonSizer
Setting exact size of widgets is hard; this container is needed to set the size of the button...
MainWindowView *const getParent() const
Return a constant pointer to the parent member.
void initAddress()
Initialises the address label.
void setAddress(const std::string text)
Set the text of the address label.
void initBreakpoint()
Initialises the breakpoint button.
MainWindowView *const parent
A pointer to the parent view.
DisassemblyModel *const getModel() const
Gets a constant pointer to the model member.
Gtk::ToggleButton *const getButton()
Gets a constant pointer to the breakpoint button member.
std::vector< DisassemblyRows > rows
An array of row views. Each array entry represents a row of memory values within the memory window...
void initDisassembly()
Initialises the disassembly label.
Gtk::Label hex
Displays the current hexadecimal value of the memory.
void setModel(DisassemblyModel *const val)
Sets the value of the model pointer.
This file contains the header file for the DisassemblyRows and DisassemblyView classes.
Gtk::VButtonBox disassemblyContainer
A container for the disassembly rows.
const std::string getDisassembly()
Gets the disassembly text for the breakpoint row.
void setHex(const std::string text)
Set the text of the hex label.
Gtk::ToggleButton breakpoint
The debugging breakpoint button.
const uint32_t getAddressVal() const
Get the addressVal member.