MCPcopy Create free account
hub / github.com/CE-Programming/CEmu / adjust

Method adjust

gui/qt/debugger/hexwidget.cpp:197–254  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

195}
196
197void HexWidget::adjust() {
198 m_size = m_data.size();
199 m_maxOffset = m_size - 1;
200
201#if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0)
202 m_charWidth = fontMetrics().horizontalAdvance(QLatin1Char('D'));
203#else
204 m_charWidth = fontMetrics().width(QLatin1Char('D'));
205#endif
206 m_charHeight = fontMetrics().height();
207 m_cursorHeight = m_charHeight / 7;
208 m_margin = m_charHeight / 5;
209 m_gap = m_charWidth / 2;
210 m_addrLoc = m_gap;
211
212 m_dataLine = m_addrLoc + (6 * m_charWidth) + m_charWidth;
213 m_dataLoc = m_dataLine + m_charWidth;
214
215 int xWidth = m_dataLoc + (m_bytesPerLine * 3 * m_charWidth);
216 m_asciiLine = xWidth + m_gap;
217 m_asciiLoc = m_asciiLine + m_gap;
218 if (m_asciiArea) {
219 xWidth = m_asciiLoc + (m_bytesPerLine * m_charWidth) + m_gap;
220 }
221 horizontalScrollBar()->setRange(0, xWidth - viewport()->width());
222 horizontalScrollBar()->setPageStep(viewport()->width());
223
224 int rows = m_size / m_bytesPerLine;
225 int visibleHeight = viewport()->height() - m_gap;
226 if (horizontalScrollBar()->isVisible()) {
227 visibleHeight -= horizontalScrollBar()->height();
228 }
229 m_visibleRows = visibleHeight / m_charHeight;
230 verticalScrollBar()->setRange(0, rows - m_visibleRows);
231 verticalScrollBar()->setPageStep(m_visibleRows);
232
233 int lines = verticalScrollBar()->value();
234 m_lineStart = lines * m_bytesPerLine;
235 m_lineEnd = m_lineStart + m_visibleRows * m_bytesPerLine - 1;
236 if (m_lineEnd >= m_size) {
237 m_lineEnd = m_maxOffset;
238 }
239
240 int x, y = (((m_cursorOffset / 2) - m_lineStart) / m_bytesPerLine + 1) * m_charHeight;
241 if (!m_asciiEdit) {
242 y = (((m_cursorOffset / 2) - m_lineStart) / m_bytesPerLine + 1) * m_charHeight;
243 x = m_cursorOffset % (m_bytesPerLine * 2);
244 x = (((x / 2) * 3) + (x % 2)) * m_charWidth + m_dataLoc;
245 } else {
246 y = (((m_cursorOffset / 2) - m_lineStart) / m_bytesPerLine + 1) * m_charHeight;
247 x = (m_cursorOffset % (m_bytesPerLine * 2)) / 2;
248 x = x * m_charWidth + m_asciiLoc;
249 }
250 m_cursor = QRect(x - horizontalScrollBar()->value(), y + m_cursorHeight, m_charWidth, m_cursorHeight);
251
252 update();
253 viewport()->update();
254}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected