Debian Codegraph @

src/StackViewer.cpp

raw symbols SCIP
1 #cxx . . $ `<file>/src/StackViewer.cpp`/include "StackViewer.h"cxx . . $ `<file>/src/StackViewer.h`/
2 #include "OpenMSXConnection.h"cxx . . $ `<file>/src/OpenMSXConnection.h`/
3 #include "CommClient.h"cxx . . $ `<file>/src/CommClient.h`/
4 #include "Settings.h"cxx . . $ `<file>/src/Settings.h`/
5 #include <QScrollBar>
6 #include <QPaintEvent>
7 #include <QPainter>
8 #include <cmath>
9
10 class StackRequestcxx . . $ StackRequest# : public ReadDebugBlockCommandcxx . . $ ReadDebugBlockCommand#
11 {
12 public:
13 StackRequestcxx . . $ StackRequest#StackRequest(9dd9ccbe0c59dced).(unsigned offset_, unsigned size,
14 unsigned char* target, StackViewercxx . . $ StackViewer#& viewer_)
15 : ReadDebugBlockCommandcxx . . $ ReadDebugBlockCommand#("memory"cxx . . $ QString#QString(85c52e162fed56f9)., offset_, size, target)
16 , offsetcxx . . $ StackRequest#offset.(offset_)
17 , viewercxx . . $ StackRequest#viewer.(viewer_)
18 {
19 }
20
21 void replyOkcxx . . $ StackRequest#replyOk(3520e46b33348bf6).(const QStringcxx . . $ QString#& message) override
22 {
23 copyDatacxx . . $ ReadDebugBlockCommand#copyData(3520e46b33348bf6).(message);
24 viewercxx . . $ StackRequest#viewer..memDataTransferredcxx . . $ StackViewer#memDataTransferred(5bd84308568d0510).(this);
25 }
26
27 void cancelcxx . . $ StackRequest#cancel(49f6e7a06ebc5aa8).() override
28 {
29 viewercxx . . $ StackRequest#viewer..transferCancelledcxx . . $ StackViewer#transferCancelled(5bd84308568d0510).(this);
30 }
31
32 // TODO public members are ugly!!
33 unsigned offsetcxx . . $ StackRequest#offset.;
34
35 private:
36 StackViewercxx . . $ StackViewer#& viewercxx . . $ StackRequest#viewer.;
37 };
38
39
40 StackViewercxx . . $ StackViewer#::StackViewercxx . . $ StackViewer#StackViewer(108f35f7aa7f3cf9).(QWidgetcxx . . $ QWidget#* parent)
41 : QFramecxx . . $ QFrame#(parent)
42 , wheelRemaindercxx . . $ StackViewer#wheelRemainder.(0)
43 {
44 setFrameStylecxx . . $ QFrame#setFrameStyle(d4f767463ce0a6b3).(WinPanelcxx . . $ QFrame#WinPanel. |cxx . . $ `operator|`(44af6e16e9fc6bb). Sunkencxx . . $ QFrame#Sunken.);
45 setFocusPolicycxx . . $ QWidget#setFocusPolicy(84f385f4ea7c1696).(Qtcxx . . $ Qt/::StrongFocuscxx . . $ Qt/StrongFocus.);
46 setBackgroundRolecxx . . $ QWidget#setBackgroundRole(656661f550a99654).(QPalettecxx . . $ QPalette#::Basecxx . . $ QPalette#Base.);
47 setSizePolicycxx . . $ QWidget#setSizePolicy(41340f53ecd443dd).(QSizePolicycxx . . $ QSizePolicy#QSizePolicy(dc90913e2b9d0ddb).( QSizePolicycxx . . $ QSizePolicy#::Fixedcxx . . $ QSizePolicy#Fixed., QSizePolicycxx . . $ QSizePolicy#::Preferredcxx . . $ QSizePolicy#Preferred.));
48
49 setFontcxx . . $ QWidget#setFont(d0a4bd0c8524b912).(Settingscxx . . $ Settings#::getcxx . . $ Settings#get(493e506a9691bc24).().fontcxx . . $ Settings#font(feb6b15adc4fed84).(Settingscxx . . $ Settings#::HEX_FONTcxx . . $ Settings#HEX_FONT.));
50
51 stackPointercxx . . $ StackViewer#stackPointer. = 0;
52 topAddresscxx . . $ StackViewer#topAddress. = 0;
53 waitingForDatacxx . . $ StackViewer#waitingForData. = false;
54
55 vertScrollBarcxx . . $ StackViewer#vertScrollBar. = new QScrollBarcxx . . $ QScrollBar#QScrollBar(370ffd1f04771b4e).(Qtcxx . . $ Qt/::Verticalcxx . . $ Qt/Vertical., this);
56 vertScrollBarcxx . . $ StackViewer#vertScrollBar.->hidecxx . . $ QWidget#hide(49f6e7a06ebc5aa8).();
57
58 frameLcxx . . $ StackViewer#frameL. = frameTcxx . . $ StackViewer#frameT. = frameBcxx . . $ StackViewer#frameB. = frameWidthcxx . . $ QFrame#frameWidth(455f465bc33b4cdf).();
59 frameRcxx . . $ StackViewer#frameR. = frameLcxx . . $ StackViewer#frameL. + vertScrollBarcxx . . $ StackViewer#vertScrollBar.->sizeHintcxx . . $ QScrollBar#sizeHint(4b3b776e5ee2b367).().widthcxx . . $ QSize#width(ea6fe5115c70a13f).();
60
61 setMinimumHeightcxx . . $ QWidget#setMinimumHeight(d4f767463ce0a6b3).(frameTcxx . . $ StackViewer#frameT.+frameBcxx . . $ StackViewer#frameB.+fontMetricscxx . . $ QWidget#fontMetrics(ee264e9e8967f9a7).().heightcxx . . $ QFontMetrics#height(455f465bc33b4cdf).());
62
63 connectcxx . . $ QObject#connect(835f87066c895669).(vertScrollBarcxx . . $ StackViewer#vertScrollBar., &QScrollBarcxx . . $ QScrollBar#::valueChangedcxx . . $ QAbstractSlider#valueChanged(d4f767463ce0a6b3).,
64 this, &StackViewercxx . . $ StackViewer#::setLocationcxx . . $ StackViewer#setLocation(d4f767463ce0a6b3).);
65 }
66
67 QSizecxx . . $ QSize# StackViewercxx . . $ StackViewer#::sizeHintcxx . . $ StackViewer#sizeHint(4b3b776e5ee2b367).() const
68 {
69 return {cxx . . $ QSize#QSize(c0d38f4800714fae).frameLcxx . . $ StackViewer#frameL. + 4 + fontMetricscxx . . $ QWidget#fontMetrics(ee264e9e8967f9a7).().horizontalAdvancecxx . . $ QFontMetrics#horizontalAdvance(91f46685ef4c12b5).("FFFFWFFFF "cxx . . $ QString#QString(85c52e162fed56f9).) + 4 + frameRcxx . . $ StackViewer#frameR.,
70 frameTcxx . . $ StackViewer#frameT. + 8 * fontMetricscxx . . $ QWidget#fontMetrics(ee264e9e8967f9a7).().heightcxx . . $ QFontMetrics#height(455f465bc33b4cdf).() + frameBcxx . . $ StackViewer#frameB.};
71 }
72
73 void StackViewercxx . . $ StackViewer#::setScrollBarValuescxx . . $ StackViewer#setScrollBarValues(49f6e7a06ebc5aa8).()
74 {
75 vertScrollBarcxx . . $ StackViewer#vertScrollBar.->setMinimumcxx . . $ QAbstractSlider#setMinimum(d4f767463ce0a6b3).(stackPointercxx . . $ StackViewer#stackPointer.);
76
77 visibleLinescxx . . $ StackViewer#visibleLines. = double(heightcxx . . $ QWidget#height(455f465bc33b4cdf).() - frameTcxx . . $ StackViewer#frameT. - frameBcxx . . $ StackViewer#frameB.) / fontMetricscxx . . $ QWidget#fontMetrics(ee264e9e8967f9a7).().heightcxx . . $ QFontMetrics#height(455f465bc33b4cdf).();
78
79 int lines = (memoryLengthcxx . . $ StackViewer#memoryLength. - stackPointercxx . . $ StackViewer#stackPointer.) / 2;
80 vertScrollBarcxx . . $ StackViewer#vertScrollBar.->setMaximumcxx . . $ QAbstractSlider#setMaximum(d4f767463ce0a6b3).(stackPointercxx . . $ StackViewer#stackPointer. + 2 * (lines - int(visibleLinescxx . . $ StackViewer#visibleLines.)));
81 vertScrollBarcxx . . $ StackViewer#vertScrollBar.->setSingleStepcxx . . $ QAbstractSlider#setSingleStep(d4f767463ce0a6b3).(2);
82 vertScrollBarcxx . . $ StackViewer#vertScrollBar.->setPageStepcxx . . $ QAbstractSlider#setPageStep(d4f767463ce0a6b3).(2 * int(visibleLinescxx . . $ StackViewer#visibleLines.));
83 }
84
85 void StackViewercxx . . $ StackViewer#::wheelEventcxx . . $ StackViewer#wheelEvent(92d40974398e4832).(QWheelEventcxx . . $ QWheelEvent#* e)
86 {
87 wheelRemaindercxx . . $ StackViewer#wheelRemainder. += e->angleDeltacxx . . $ QWheelEvent#angleDelta(75d69cfbd3c4b2dd).().ycxx . . $ QPoint#y(455f465bc33b4cdf).();
88 const int delta = wheelRemaindercxx . . $ StackViewer#wheelRemainder. / 40;
89 wheelRemaindercxx . . $ StackViewer#wheelRemainder. %= 40;
90 if (delta) {
91 int v = vertScrollBarcxx . . $ StackViewer#vertScrollBar.->valuecxx . . $ QAbstractSlider#value(455f465bc33b4cdf).() - delta;
92 vertScrollBarcxx . . $ StackViewer#vertScrollBar.->setValuecxx . . $ QAbstractSlider#setValue(d4f767463ce0a6b3).(v);
93 }
94 e->acceptcxx . . $ QEvent#accept(49f6e7a06ebc5aa8).();
95 }
96
97 void StackViewercxx . . $ StackViewer#::resizeEventcxx . . $ StackViewer#resizeEvent(eeeec21cf8dc0387).(QResizeEventcxx . . $ QResizeEvent#* e)
98 {
99 QFramecxx . . $ QFrame#::resizeEventcxx . . $ QWidget#resizeEvent(eeeec21cf8dc0387).(e);
100
101 setScrollBarValuescxx . . $ StackViewer#setScrollBarValues(49f6e7a06ebc5aa8).();
102 vertScrollBarcxx . . $ StackViewer#vertScrollBar.->setGeometrycxx . . $ QWidget#setGeometry(748afa4755bc9595).(widthcxx . . $ QWidget#width(455f465bc33b4cdf).() - frameRcxx . . $ StackViewer#frameR., frameTcxx . . $ StackViewer#frameT.,
103 vertScrollBarcxx . . $ StackViewer#vertScrollBar.->sizeHintcxx . . $ QScrollBar#sizeHint(4b3b776e5ee2b367).().widthcxx . . $ QSize#width(ea6fe5115c70a13f).(),
104 heightcxx . . $ QWidget#height(455f465bc33b4cdf).() - frameTcxx . . $ StackViewer#frameT. - frameBcxx . . $ StackViewer#frameB.);
105 vertScrollBarcxx . . $ StackViewer#vertScrollBar.->showcxx . . $ QWidget#show(49f6e7a06ebc5aa8).();
106 // calc the number of lines that can be displayed
107 // partial lines count as a whole
108 }
109
110 void StackViewercxx . . $ StackViewer#::paintEventcxx . . $ StackViewer#paintEvent(f239c9e85d61a220).(QPaintEventcxx . . $ QPaintEvent#* e)
111 {
112 // call parent for drawing the actual frame
113 QFramecxx . . $ QFrame#::paintEventcxx . . $ QFrame#paintEvent(f239c9e85d61a220).(e);
114
115 QPaintercxx . . $ QPainter# pcxx . . $ QPainter#QPainter(dd2eedc069b0ab5f).(this);
116 int h = fontMetricscxx . . $ QWidget#fontMetrics(ee264e9e8967f9a7).().heightcxx . . $ QFontMetrics#height(455f465bc33b4cdf).();
117 int d = fontMetricscxx . . $ QWidget#fontMetrics(ee264e9e8967f9a7).().descentcxx . . $ QFontMetrics#descent(455f465bc33b4cdf).();
118
119 // set font
120 p.setPencxx . . $ QPainter#setPen(129a55e114526ad3).(Qtcxx . . $ QColor#QColor(408ec4d5924bfb00).::blackcxx . . $ Qt/black.);
121
122 // calc and set drawing bounds
123 QRectcxx . . $ QRect# r(e->rectcxx . . $ QPaintEvent#rect(f4023511c62cad66).());
124 if (r.leftcxx . . $ QRect#left(ea6fe5115c70a13f).() < frameLcxx . . $ StackViewer#frameL.) r.setLeftcxx . . $ QRect#setLeft(f349c77f591a7878).(frameLcxx . . $ StackViewer#frameL.);
125 if (r.topcxx . . $ QRect#top(ea6fe5115c70a13f).() < frameTcxx . . $ StackViewer#frameT.) r.setTopcxx . . $ QRect#setTop(f349c77f591a7878). (frameTcxx . . $ StackViewer#frameT.);
126 if (r.rightcxx . . $ QRect#right(ea6fe5115c70a13f).() > widthcxx . . $ QWidget#width(455f465bc33b4cdf).() - frameRcxx . . $ StackViewer#frameR. - 1) r.setRightcxx . . $ QRect#setRight(f349c77f591a7878). (widthcxx . . $ QWidget#width(455f465bc33b4cdf).() - frameRcxx . . $ StackViewer#frameR. - 1);
127 if (r.bottomcxx . . $ QRect#bottom(ea6fe5115c70a13f).() > heightcxx . . $ QWidget#height(455f465bc33b4cdf).() - frameBcxx . . $ StackViewer#frameB. - 1) r.setBottomcxx . . $ QRect#setBottom(f349c77f591a7878).(heightcxx . . $ QWidget#height(455f465bc33b4cdf).() - frameBcxx . . $ StackViewer#frameB. - 1);
128 p.setClipRectcxx . . $ QPainter#setClipRect(2f5004bd5eb598d2).(r);
129
130 // redraw background
131 p.fillRectcxx . . $ QPainter#fillRect(b5c43933f089f858).(r, palettecxx . . $ QWidget#palette(a7bd6a16d2c88209).().colorcxx . . $ QPalette#color(a08a5ea14130e12).(QPalettecxx . . $ QPalette#::Basecxx . . $ QPalette#Base.));
132
133 // calc layout (not optimal)
134 int xAddr = frameLcxx . . $ StackViewer#frameL. + 8;
135 int xStack = xAddr + fontMetricscxx . . $ QWidget#fontMetrics(ee264e9e8967f9a7).().horizontalAdvancecxx . . $ QFontMetrics#horizontalAdvance(91f46685ef4c12b5).("FFFFF"cxx . . $ QString#QString(85c52e162fed56f9).);
136 int y = frameTcxx . . $ StackViewer#frameT. + h - 1;
137 int address = topAddresscxx . . $ StackViewer#topAddress.;
138
139 for (int i = 0; i < int(ceil(visibleLinescxx . . $ StackViewer#visibleLines.)); ++i) {
140 // print address
141 QStringcxx . . $ QString# hexStrcxx . . $ QString#QString(ced63f7c635d850d).;
142 hexStr =cxx . . $ QString#`operator=`(4f35bf974e7f8568). QStringcxx . . $ QString#QString(85c52e162fed56f9).("%1").argcxx . . $ QString#arg(64ab2ed17cc11715).(address, 4, 16, QCharcxx . . $ QChar#('0')).toUppercxx . . $ QString#toUpper(30b3b70527b1c61a).();
143 p.drawTextcxx . . $ QPainter#drawText(c89d651b24440698).(xAddr, y - d, hexStr);
144 hexStr =cxx . . $ QString#`operator=`(4f35bf974e7f8568). QStringcxx . . $ QString#QString(85c52e162fed56f9).("%1").argcxx . . $ QString#arg(64ab2ed17cc11715).(memorycxx . . $ StackViewer#memory.[address + 1] << 8 | memorycxx . . $ StackViewer#memory.[address], 4, 16, QCharcxx . . $ QChar#('0')).toUppercxx . . $ QString#toUpper(30b3b70527b1c61a).();
145 p.drawTextcxx . . $ QPainter#drawText(c89d651b24440698).(xStack, y - d, hexStr);
146 y += h;
147 address += 2;
148 if (address >= memoryLengthcxx . . $ StackViewer#memoryLength. - 1) break;
149 }
150 }
151
152 void StackViewercxx . . $ StackViewer#::setDatacxx . . $ StackViewer#setData(fc0f0e1646c32816).(unsigned char* memPtr, int memLength)
153 {
154 memorycxx . . $ StackViewer#memory. = memPtr;
155 memoryLengthcxx . . $ StackViewer#memoryLength. = memLength;
156 setScrollBarValuescxx . . $ StackViewer#setScrollBarValues(49f6e7a06ebc5aa8).();
157 }
158
159 void StackViewercxx . . $ StackViewer#::setLocationcxx . . $ StackViewer#setLocation(d4f767463ce0a6b3).(int addr)
160 {
161 if (waitingForDatacxx . . $ StackViewer#waitingForData.) {
162 return; // ignore
163 }
164 int start = (addr & ~1) | (stackPointercxx . . $ StackViewer#stackPointer. & 1);
165 int size = 2 * int(ceil(visibleLinescxx . . $ StackViewer#visibleLines.));
166
167 if (start + size >= memoryLengthcxx . . $ StackViewer#memoryLength.) {
168 size = memoryLengthcxx . . $ StackViewer#memoryLength. - start;
169 }
170 auto* req = new StackRequestcxx . . $ StackRequest#StackRequest(9dd9ccbe0c59dced).(start, size, &memorycxx . . $ StackViewer#memory.[start], *this);
171 CommClientcxx . . $ CommClient#::instancecxx . . $ CommClient#instance(8cca9d0b1334f685).().sendCommandcxx . . $ CommClient#sendCommand(6fe5d9dff2ed3a64).(req);
172 waitingForDatacxx . . $ StackViewer#waitingForData. = true;
173 }
174
175 void StackViewercxx . . $ StackViewer#::setStackPointercxx . . $ StackViewer#setStackPointer(ed53e3bbd3fa2f69).(quint16cxx . . $ quint16# addr)
176 {
177 stackPointercxx . . $ StackViewer#stackPointer. = addr;
178 setScrollBarValuescxx . . $ StackViewer#setScrollBarValues(49f6e7a06ebc5aa8).();
179 vertScrollBarcxx . . $ StackViewer#vertScrollBar.->setValuecxx . . $ QAbstractSlider#setValue(d4f767463ce0a6b3).(addr);
180 setLocationcxx . . $ StackViewer#setLocation(d4f767463ce0a6b3).(addr);
181 }
182
183 void StackViewercxx . . $ StackViewer#::memDataTransferredcxx . . $ StackViewer#memDataTransferred(5bd84308568d0510).(StackRequestcxx . . $ StackRequest#* r)
184 {
185 topAddresscxx . . $ StackViewer#topAddress. = r->offsetcxx . . $ StackRequest#offset.;
186 updatecxx . . $ QWidget#update(49f6e7a06ebc5aa8).();
187
188 waitingForDatacxx . . $ StackViewer#waitingForData. = false;
189 delete r;
190
191 // check whether a new value is available
192 if ((topAddresscxx . . $ StackViewer#topAddress. & ~1) != (vertScrollBarcxx . . $ StackViewer#vertScrollBar.->valuecxx . . $ QAbstractSlider#value(455f465bc33b4cdf).() & ~1)) {
193 setLocationcxx . . $ StackViewer#setLocation(d4f767463ce0a6b3).(vertScrollBarcxx . . $ StackViewer#vertScrollBar.->valuecxx . . $ QAbstractSlider#value(455f465bc33b4cdf).());
194 }
195 }
196
197 void StackViewercxx . . $ StackViewer#::transferCancelledcxx . . $ StackViewer#transferCancelled(5bd84308568d0510).(StackRequestcxx . . $ StackRequest#* r)
198 {
199 waitingForDatacxx . . $ StackViewer#waitingForData. = false;
200 delete r;
201 }