Implement scrolling to the target address.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42213 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Rene Gollent 2011-06-16 21:57:41 +00:00
parent 98a61309e7
commit 0215c110a5
2 changed files with 19 additions and 3 deletions

View File

@ -73,6 +73,23 @@ MemoryView::SetTargetAddress(TeamMemoryBlock* block, target_addr_t address)
}
void
MemoryView::ScrollToSelection()
{
if (fTargetBlock != NULL) {
target_addr_t offset = fTargetAddress - fTargetBlock->BaseAddress();
int32 lineNumber = 0;
if (fHexBlocksPerLine > 0)
lineNumber = offset / (fHexBlocksPerLine * (1 << (fHexMode - 1)));
else if (fTextCharsPerLine > 0)
lineNumber = offset / fTextCharsPerLine;
float y = lineNumber * fLineHeight;
if (!Bounds().Contains(BPoint(0.0, y)))
ScrollTo(0.0, y);
}
}
void
MemoryView::TargetedByScrollView(BScrollView* scrollView)
{
@ -231,6 +248,7 @@ MemoryView::MessageReceived(BMessage* message)
case MSG_TARGET_ADDRESS_CHANGED:
{
_RecalcScrollBars();
ScrollToSelection();
Invalidate();
break;
}

View File

@ -45,9 +45,7 @@ public:
void SetTargetAddress(TeamMemoryBlock* block,
target_addr_t address);
void TargetAddressChanged(target_addr_t address);
void ScrollToSelection();
virtual void TargetedByScrollView(BScrollView* scrollView);