From c11cfe37f862a9182bfb6a789342805be83edbde Mon Sep 17 00:00:00 2001 From: dl471 Date: Sun, 21 Oct 2018 06:07:31 +0100 Subject: [PATCH] Implement saner making space for offsets -Adjust the y coordinates of the rows as they are drawn -Adjust visible rows -Adjust clicks --- Windows/Debugger/CtrlMemView.cpp | 21 +++++++++------------ Windows/Debugger/CtrlMemView.h | 2 ++ 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/Windows/Debugger/CtrlMemView.cpp b/Windows/Debugger/CtrlMemView.cpp index 2ef1dc4c28..79c9912801 100644 --- a/Windows/Debugger/CtrlMemView.cpp +++ b/Windows/Debugger/CtrlMemView.cpp @@ -203,6 +203,10 @@ void CtrlMemView::onPaint(WPARAM wParam, LPARAM lParam) unsigned int address=windowStart + i*rowSize; int rowY = rowHeight*i; + + if (writeOffsets) + rowY += rowHeight * 2; // skip the first two rows to make space for the offets + sprintf(temp,"%08X",address); SetTextColor(hdc,0x600000); @@ -277,14 +281,7 @@ void CtrlMemView::onPaint(WPARAM wParam, LPARAM lParam) SelectObject(hdc,oldBrush); // copy bitmap to the actual hdc - if (writeOffsets) - { - BitBlt(actualHdc, 0, rowHeight*2, rect.right, rect.bottom, hdc, 0, 0, SRCCOPY); - } - else - { - BitBlt(actualHdc, 0, 0, rect.right, rect.bottom, hdc, 0, 0, SRCCOPY); - } + BitBlt(actualHdc, 0, 0, rect.right, rect.bottom, hdc, 0, 0, SRCCOPY); DeleteObject(hBM); DeleteDC(hdc); @@ -417,7 +414,7 @@ void CtrlMemView::redraw() visibleRows = (rect.bottom/rowHeight); if (writeOffsets) { - visibleRows -= 2; + visibleRows -= 2; // visibleRows is calculated based on the size of the control, but 2 of the rows have already been used for the offsets and are not longer usable } InvalidateRect(wnd, NULL, FALSE); @@ -528,9 +525,9 @@ void CtrlMemView::gotoPoint(int x, int y) int line = y/rowHeight; int lineAddress = windowStart+line*rowSize; - if (writeOffsets) { - lineAddress -= (rowSize * 2); - } + if (writeOffsets) + lineAddress -= (rowSize * 2); // since each row has been written 2 rows down from where the window expected it to be written the target of the clicks must be adjusted + if (x >= asciiStart) { diff --git a/Windows/Debugger/CtrlMemView.h b/Windows/Debugger/CtrlMemView.h index 1948322733..c0a0b39018 100644 --- a/Windows/Debugger/CtrlMemView.h +++ b/Windows/Debugger/CtrlMemView.h @@ -38,6 +38,8 @@ class CtrlMemView bool asciiSelected; int selectedNibble; + bool writeOffsets = true; + int visibleRows; std::string searchQuery;