Add listener interface to MemoryView.
- When the target address of the memory view changes, an attached listener is now notified. This lets the inspector window's text input keep in sync with the current address when keyboard navigating the memory view.
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2011, Rene Gollent, [email protected]. All rights reserved.
|
* Copyright 2011-2013, Rene Gollent, [email protected]. All rights reserved.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -156,7 +156,7 @@ InspectorWindow::_Init()
|
|||||||
int32 targetEndian = fTeam->GetArchitecture()->IsBigEndian()
|
int32 targetEndian = fTeam->GetArchitecture()->IsBigEndian()
|
||||||
? EndianModeBigEndian : EndianModeLittleEndian;
|
? EndianModeBigEndian : EndianModeLittleEndian;
|
||||||
|
|
||||||
scrollView->SetTarget(fMemoryView = MemoryView::Create(fTeam));
|
scrollView->SetTarget(fMemoryView = MemoryView::Create(fTeam, this));
|
||||||
|
|
||||||
fAddressInput->SetTarget(this);
|
fAddressInput->SetTarget(this);
|
||||||
fPreviousBlockButton->SetTarget(this);
|
fPreviousBlockButton->SetTarget(this);
|
||||||
@@ -221,6 +221,7 @@ InspectorWindow::MessageReceived(BMessage* msg)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (addressValid) {
|
if (addressValid) {
|
||||||
|
fCurrentAddress = address;
|
||||||
if (fCurrentBlock != NULL
|
if (fCurrentBlock != NULL
|
||||||
&& !fCurrentBlock->Contains(address)) {
|
&& !fCurrentBlock->Contains(address)) {
|
||||||
fCurrentBlock->ReleaseReference();
|
fCurrentBlock->ReleaseReference();
|
||||||
@@ -231,11 +232,6 @@ InspectorWindow::MessageReceived(BMessage* msg)
|
|||||||
fListener->InspectRequested(address, this);
|
fListener->InspectRequested(address, this);
|
||||||
else
|
else
|
||||||
fMemoryView->SetTargetAddress(fCurrentBlock, address);
|
fMemoryView->SetTargetAddress(fCurrentBlock, address);
|
||||||
|
|
||||||
fCurrentAddress = address;
|
|
||||||
BString computedAddress;
|
|
||||||
computedAddress.SetToFormat("0x%" B_PRIx64, address);
|
|
||||||
fAddressInput->SetText(computedAddress.String());
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -289,6 +285,19 @@ InspectorWindow::MemoryBlockRetrieved(TeamMemoryBlock* block)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
InspectorWindow::TargetAddressChanged(target_addr_t address)
|
||||||
|
{
|
||||||
|
AutoLocker<BLooper> lock(this);
|
||||||
|
if (lock.IsLocked()) {
|
||||||
|
fCurrentAddress = address;
|
||||||
|
BString computedAddress;
|
||||||
|
computedAddress.SetToFormat("0x%" B_PRIx64, address);
|
||||||
|
fAddressInput->SetText(computedAddress.String());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
InspectorWindow::LoadSettings(const GuiTeamUiSettings& settings)
|
InspectorWindow::LoadSettings(const GuiTeamUiSettings& settings)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2011, Rene Gollent, [email protected]. All rights reserved.
|
* Copyright 2011-2013, Rene Gollent, [email protected]. All rights reserved.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
#ifndef INSPECTOR_WINDOW_H
|
#ifndef INSPECTOR_WINDOW_H
|
||||||
@@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
#include <Window.h>
|
#include <Window.h>
|
||||||
|
|
||||||
|
#include "MemoryView.h"
|
||||||
#include "TeamMemoryBlock.h"
|
#include "TeamMemoryBlock.h"
|
||||||
#include "Types.h"
|
#include "Types.h"
|
||||||
|
|
||||||
@@ -17,13 +18,13 @@ class BMenuField;
|
|||||||
class BMessenger;
|
class BMessenger;
|
||||||
class BTextControl;
|
class BTextControl;
|
||||||
class GuiTeamUiSettings;
|
class GuiTeamUiSettings;
|
||||||
class MemoryView;
|
|
||||||
class Team;
|
class Team;
|
||||||
class UserInterfaceListener;
|
class UserInterfaceListener;
|
||||||
|
|
||||||
|
|
||||||
class InspectorWindow : public BWindow,
|
class InspectorWindow : public BWindow,
|
||||||
public TeamMemoryBlock::Listener {
|
public TeamMemoryBlock::Listener,
|
||||||
|
public MemoryView::Listener {
|
||||||
public:
|
public:
|
||||||
InspectorWindow(::Team* team,
|
InspectorWindow(::Team* team,
|
||||||
UserInterfaceListener* listener,
|
UserInterfaceListener* listener,
|
||||||
@@ -38,8 +39,12 @@ public:
|
|||||||
virtual void MessageReceived(BMessage* message);
|
virtual void MessageReceived(BMessage* message);
|
||||||
virtual bool QuitRequested();
|
virtual bool QuitRequested();
|
||||||
|
|
||||||
|
// TeamMemoryBlock::Listener
|
||||||
virtual void MemoryBlockRetrieved(TeamMemoryBlock* block);
|
virtual void MemoryBlockRetrieved(TeamMemoryBlock* block);
|
||||||
|
|
||||||
|
// MemoryView::Listener
|
||||||
|
virtual void TargetAddressChanged(target_addr_t address);
|
||||||
|
|
||||||
status_t LoadSettings(
|
status_t LoadSettings(
|
||||||
const GuiTeamUiSettings& settings);
|
const GuiTeamUiSettings& settings);
|
||||||
status_t SaveSettings(
|
status_t SaveSettings(
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2011, Rene Gollent, rene@gollent.com. All rights reserved.
|
* Copyright 2011-2013, Rene Gollent, rene@gollent.com. All rights reserved.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -26,7 +26,7 @@ enum {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
MemoryView::MemoryView(::Team* team)
|
MemoryView::MemoryView(::Team* team, Listener* listener)
|
||||||
:
|
:
|
||||||
BView("memoryView", B_WILL_DRAW | B_FRAME_EVENTS | B_NAVIGABLE
|
BView("memoryView", B_WILL_DRAW | B_FRAME_EVENTS | B_NAVIGABLE
|
||||||
| B_SUBPIXEL_PRECISE),
|
| B_SUBPIXEL_PRECISE),
|
||||||
@@ -38,7 +38,8 @@ MemoryView::MemoryView(::Team* team)
|
|||||||
fTextCharsPerLine(0),
|
fTextCharsPerLine(0),
|
||||||
fHexBlocksPerLine(0),
|
fHexBlocksPerLine(0),
|
||||||
fHexMode(HexMode8BitInt),
|
fHexMode(HexMode8BitInt),
|
||||||
fTextMode(TextModeASCII)
|
fTextMode(TextModeASCII),
|
||||||
|
fListener(listener)
|
||||||
{
|
{
|
||||||
Architecture* architecture = team->GetArchitecture();
|
Architecture* architecture = team->GetArchitecture();
|
||||||
fTargetAddressSize = architecture->AddressSize() * 2;
|
fTargetAddressSize = architecture->AddressSize() * 2;
|
||||||
@@ -56,9 +57,9 @@ MemoryView::~MemoryView()
|
|||||||
|
|
||||||
|
|
||||||
/*static */ MemoryView*
|
/*static */ MemoryView*
|
||||||
MemoryView::Create(::Team* team)
|
MemoryView::Create(::Team* team, Listener* listener)
|
||||||
{
|
{
|
||||||
MemoryView* self = new MemoryView(team);
|
MemoryView* self = new MemoryView(team, listener);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
self->_Init();
|
self->_Init();
|
||||||
@@ -85,6 +86,13 @@ MemoryView::SetTargetAddress(TeamMemoryBlock* block, target_addr_t address)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
MemoryView::UnsetListener()
|
||||||
|
{
|
||||||
|
fListener = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
MemoryView::AttachedToWindow()
|
MemoryView::AttachedToWindow()
|
||||||
{
|
{
|
||||||
@@ -329,6 +337,8 @@ MemoryView::MessageReceived(BMessage* message)
|
|||||||
_RecalcScrollBars();
|
_RecalcScrollBars();
|
||||||
ScrollToSelection();
|
ScrollToSelection();
|
||||||
Invalidate();
|
Invalidate();
|
||||||
|
if (fListener != NULL)
|
||||||
|
fListener->TargetAddressChanged(fTargetAddress);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case MSG_SET_HEX_MODE:
|
case MSG_SET_HEX_MODE:
|
||||||
@@ -546,3 +556,11 @@ MemoryView::_GetNextHexBlock(char* buffer, int32 bufferSize,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//#pragma mark - Listener
|
||||||
|
|
||||||
|
|
||||||
|
MemoryView::Listener::~Listener()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2011, Rene Gollent, rene@gollent.com. All rights reserved.
|
* Copyright 2011-2013, Rene Gollent, rene@gollent.com. All rights reserved.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -46,15 +46,19 @@ class TeamMemoryBlock;
|
|||||||
|
|
||||||
class MemoryView : public BView {
|
class MemoryView : public BView {
|
||||||
public:
|
public:
|
||||||
MemoryView(::Team* team);
|
class Listener;
|
||||||
|
|
||||||
|
MemoryView(::Team* team, Listener* listener);
|
||||||
virtual ~MemoryView();
|
virtual ~MemoryView();
|
||||||
|
|
||||||
static MemoryView* Create(::Team* team);
|
static MemoryView* Create(::Team* team, Listener* listener);
|
||||||
// throws
|
// throws
|
||||||
|
|
||||||
void SetTargetAddress(TeamMemoryBlock* block,
|
void SetTargetAddress(TeamMemoryBlock* block,
|
||||||
target_addr_t address);
|
target_addr_t address);
|
||||||
|
|
||||||
|
void UnsetListener();
|
||||||
|
|
||||||
virtual void AttachedToWindow();
|
virtual void AttachedToWindow();
|
||||||
virtual void Draw(BRect rect);
|
virtual void Draw(BRect rect);
|
||||||
virtual void FrameResized(float width, float height);
|
virtual void FrameResized(float width, float height);
|
||||||
@@ -83,6 +87,17 @@ private:
|
|||||||
int32 fCurrentEndianMode;
|
int32 fCurrentEndianMode;
|
||||||
int32 fHexMode;
|
int32 fHexMode;
|
||||||
int32 fTextMode;
|
int32 fTextMode;
|
||||||
|
Listener* fListener;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class MemoryView::Listener {
|
||||||
|
public:
|
||||||
|
virtual ~Listener();
|
||||||
|
|
||||||
|
virtual void TargetAddressChanged(target_addr_t address)
|
||||||
|
= 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif // MEMORY_VIEW_H
|
#endif // MEMORY_VIEW_H
|
||||||
|
|||||||
Reference in New Issue
Block a user