2015-05-06 01:27:59 -04:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "Types.h"
|
|
|
|
#include "win32/CustomDrawn.h"
|
|
|
|
#include "win32/DeviceContext.h"
|
|
|
|
#include "win32/GdiObj.h"
|
|
|
|
#include <boost/signals2.hpp>
|
|
|
|
|
|
|
|
class CMemoryView : public Framework::Win32::CCustomDrawn
|
|
|
|
{
|
|
|
|
public:
|
2018-04-30 21:01:23 +01:00
|
|
|
CMemoryView(HWND, const RECT&);
|
|
|
|
virtual ~CMemoryView() = default;
|
2015-05-06 01:27:59 -04:00
|
|
|
|
2018-04-30 21:01:23 +01:00
|
|
|
void SetMemorySize(uint32);
|
2015-05-06 01:27:59 -04:00
|
|
|
|
2018-04-30 21:01:23 +01:00
|
|
|
uint32 GetBytesPerLine() const;
|
|
|
|
void SetBytesPerLine(uint32);
|
2018-01-30 12:58:11 -05:00
|
|
|
|
2018-04-30 21:01:23 +01:00
|
|
|
void SetDisplayUnit(uint32);
|
2015-05-06 01:27:59 -04:00
|
|
|
|
2018-04-30 21:01:23 +01:00
|
|
|
uint32 GetSelection();
|
|
|
|
void SetSelectionStart(unsigned int);
|
|
|
|
|
|
|
|
boost::signals2::signal<void(uint32)> OnSelectionChange;
|
2015-05-06 01:27:59 -04:00
|
|
|
|
|
|
|
protected:
|
|
|
|
enum
|
|
|
|
{
|
2018-01-30 12:58:11 -05:00
|
|
|
MAX_UNITS = 10,
|
2015-05-06 01:27:59 -04:00
|
|
|
ID_MEMORYVIEW_COLUMNS_AUTO = 40001,
|
|
|
|
ID_MEMORYVIEW_COLUMNS_16BYTES,
|
|
|
|
ID_MEMORYVIEW_COLUMNS_32BYTES,
|
2018-01-30 12:58:11 -05:00
|
|
|
ID_MEMORYVIEW_UNIT_BASE,
|
|
|
|
ID_MEMORYVIEW_UNIT_MAX = ID_MEMORYVIEW_UNIT_BASE + MAX_UNITS,
|
2015-05-06 01:27:59 -04:00
|
|
|
ID_MEMORYVIEW_MENU_MAX
|
|
|
|
};
|
|
|
|
|
2018-04-30 21:01:23 +01:00
|
|
|
virtual uint8 GetByte(uint32) = 0;
|
|
|
|
virtual HMENU CreateContextualMenu();
|
2015-05-06 01:27:59 -04:00
|
|
|
|
2018-04-30 21:01:23 +01:00
|
|
|
void Paint(HDC) override;
|
2015-05-06 01:27:59 -04:00
|
|
|
|
2018-04-30 21:01:23 +01:00
|
|
|
long OnCommand(unsigned short, unsigned short, HWND) override;
|
|
|
|
long OnSize(unsigned int, unsigned int, unsigned int) override;
|
|
|
|
long OnVScroll(unsigned int, unsigned int) override;
|
|
|
|
long OnSetFocus() override;
|
|
|
|
long OnKillFocus() override;
|
|
|
|
long OnMouseWheel(int, int, short) override;
|
|
|
|
long OnLeftButtonDown(int, int) override;
|
|
|
|
long OnLeftButtonUp(int, int) override;
|
|
|
|
long OnRightButtonUp(int, int) override;
|
|
|
|
long OnKeyDown(WPARAM, LPARAM) override;
|
2015-05-06 01:27:59 -04:00
|
|
|
|
2018-04-30 21:01:23 +01:00
|
|
|
Framework::Win32::CFont m_font;
|
2015-05-06 01:27:59 -04:00
|
|
|
|
|
|
|
private:
|
2018-01-30 12:58:11 -05:00
|
|
|
typedef std::tstring (CMemoryView::*UnitRenderer)(uint32);
|
|
|
|
|
|
|
|
struct UNITINFO
|
|
|
|
{
|
|
|
|
unsigned int bytesPerUnit = 0;
|
|
|
|
unsigned int charsPerUnit = 0;
|
|
|
|
UnitRenderer renderer = nullptr;
|
|
|
|
const TCHAR* description = nullptr;
|
|
|
|
};
|
|
|
|
|
2015-05-06 01:27:59 -04:00
|
|
|
struct RENDERMETRICS
|
|
|
|
{
|
2018-04-30 21:01:23 +01:00
|
|
|
unsigned int xmargin = 0;
|
|
|
|
unsigned int ymargin = 0;
|
|
|
|
unsigned int yspace = 0;
|
|
|
|
unsigned int unitSpacing = 0;
|
|
|
|
unsigned int lineSectionSpacing = 0;
|
2015-05-06 01:27:59 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
struct RENDERPARAMS
|
|
|
|
{
|
2018-04-30 21:01:23 +01:00
|
|
|
unsigned int lines = 0;
|
|
|
|
unsigned int totallyVisibleLines = 0;
|
|
|
|
unsigned int bytesPerLine = 0;
|
|
|
|
const UNITINFO* unit = nullptr;
|
|
|
|
uint32 address = 0;
|
2015-05-06 01:27:59 -04:00
|
|
|
};
|
|
|
|
|
2018-04-30 21:01:23 +01:00
|
|
|
void UpdateScrollRange();
|
|
|
|
unsigned int GetScrollOffset();
|
|
|
|
unsigned int GetScrollThumbPosition();
|
|
|
|
void UpdateCaretPosition();
|
|
|
|
void EnsureSelectionVisible();
|
|
|
|
RENDERPARAMS GetRenderParams();
|
|
|
|
|
|
|
|
std::tstring RenderByteUnit(uint32);
|
|
|
|
std::tstring RenderWordUnit(uint32);
|
|
|
|
std::tstring RenderSingleUnit(uint32);
|
|
|
|
|
|
|
|
static const UNITINFO g_units[];
|
|
|
|
uint32 m_selectionStart = 0;
|
|
|
|
uint32 m_size = 0;
|
|
|
|
uint32 m_bytesPerLine = 0;
|
|
|
|
uint32 m_selectedUnit = 0;
|
|
|
|
RENDERMETRICS m_renderMetrics;
|
2015-05-06 01:27:59 -04:00
|
|
|
};
|