Added support for different number bases in the offset column.
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@6622 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
f7efc8f447
commit
e805d89711
@ -7,7 +7,6 @@
|
||||
#include "DataView.h"
|
||||
#include "DataEditor.h"
|
||||
|
||||
//#include <Messenger.h>
|
||||
#include <Looper.h>
|
||||
#include <ScrollBar.h>
|
||||
|
||||
@ -25,6 +24,7 @@ DataView::DataView(BRect rect, DataEditor &editor)
|
||||
: BView(rect, "dataView", B_FOLLOW_ALL, B_WILL_DRAW | B_NAVIGABLE | B_FRAME_EVENTS),
|
||||
fEditor(editor),
|
||||
fFocus(kHexFocus),
|
||||
fBase(kHexBase),
|
||||
fIsActive(true)
|
||||
{
|
||||
fPositionLength = 4;
|
||||
@ -95,6 +95,16 @@ DataView::MessageReceived(BMessage *message)
|
||||
break;
|
||||
}
|
||||
|
||||
case kMsgBaseType:
|
||||
{
|
||||
int32 type;
|
||||
if (message->FindInt32("base", &type) != B_OK)
|
||||
break;
|
||||
|
||||
SetBase((base_type)type);
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
BView::MessageReceived(message);
|
||||
}
|
||||
@ -104,7 +114,8 @@ DataView::MessageReceived(BMessage *message)
|
||||
void
|
||||
DataView::ConvertLine(char *line, off_t offset, const uint8 *buffer, size_t size)
|
||||
{
|
||||
line += sprintf(line, "%0*Lx: ", (int)fPositionLength, offset);
|
||||
line += sprintf(line, fBase == kHexBase ? "%0*Lx: " : "%0*Ld: ",
|
||||
(int)fPositionLength, offset);
|
||||
|
||||
for (uint32 i = 0; i < kBlockSize; i++) {
|
||||
if (i >= size) {
|
||||
@ -453,6 +464,17 @@ DataView::InvalidateRange(int32 start, int32 end)
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DataView::SetBase(base_type type)
|
||||
{
|
||||
if (fBase == type)
|
||||
return;
|
||||
|
||||
fBase = type;
|
||||
Invalidate();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DataView::SetFocus(view_focus which)
|
||||
{
|
||||
|
@ -13,6 +13,13 @@
|
||||
|
||||
class DataEditor;
|
||||
|
||||
static const uint32 kMsgBaseType = 'base';
|
||||
|
||||
enum base_type {
|
||||
kHexBase,
|
||||
kDecimalBase
|
||||
};
|
||||
|
||||
enum view_focus {
|
||||
kNoFocus,
|
||||
kHexFocus,
|
||||
@ -45,6 +52,9 @@ class DataView : public BView {
|
||||
void GetSelection(int32 &start, int32 &end);
|
||||
void InvalidateRange(int32 start, int32 end);
|
||||
|
||||
base_type Base() const { return fBase; }
|
||||
void SetBase(base_type type);
|
||||
|
||||
private:
|
||||
BRect SelectionFrame(view_focus which, int32 start, int32 end);
|
||||
int32 PositionAt(view_focus focus, BPoint point, view_focus *_newFocus = NULL);
|
||||
@ -66,6 +76,7 @@ class DataView : public BView {
|
||||
int32 fFontHeight;
|
||||
float fCharWidth;
|
||||
view_focus fFocus;
|
||||
base_type fBase;
|
||||
bool fIsActive;
|
||||
int32 fStart, fEnd;
|
||||
int32 fMouseSelectionStart;
|
||||
|
Loading…
Reference in New Issue
Block a user