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:
@@ -7,7 +7,6 @@
|
|||||||
#include "DataView.h"
|
#include "DataView.h"
|
||||||
#include "DataEditor.h"
|
#include "DataEditor.h"
|
||||||
|
|
||||||
//#include <Messenger.h>
|
|
||||||
#include <Looper.h>
|
#include <Looper.h>
|
||||||
#include <ScrollBar.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),
|
: BView(rect, "dataView", B_FOLLOW_ALL, B_WILL_DRAW | B_NAVIGABLE | B_FRAME_EVENTS),
|
||||||
fEditor(editor),
|
fEditor(editor),
|
||||||
fFocus(kHexFocus),
|
fFocus(kHexFocus),
|
||||||
|
fBase(kHexBase),
|
||||||
fIsActive(true)
|
fIsActive(true)
|
||||||
{
|
{
|
||||||
fPositionLength = 4;
|
fPositionLength = 4;
|
||||||
@@ -95,6 +95,16 @@ DataView::MessageReceived(BMessage *message)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case kMsgBaseType:
|
||||||
|
{
|
||||||
|
int32 type;
|
||||||
|
if (message->FindInt32("base", &type) != B_OK)
|
||||||
|
break;
|
||||||
|
|
||||||
|
SetBase((base_type)type);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
BView::MessageReceived(message);
|
BView::MessageReceived(message);
|
||||||
}
|
}
|
||||||
@@ -104,7 +114,8 @@ DataView::MessageReceived(BMessage *message)
|
|||||||
void
|
void
|
||||||
DataView::ConvertLine(char *line, off_t offset, const uint8 *buffer, size_t size)
|
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++) {
|
for (uint32 i = 0; i < kBlockSize; i++) {
|
||||||
if (i >= size) {
|
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
|
void
|
||||||
DataView::SetFocus(view_focus which)
|
DataView::SetFocus(view_focus which)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -13,6 +13,13 @@
|
|||||||
|
|
||||||
class DataEditor;
|
class DataEditor;
|
||||||
|
|
||||||
|
static const uint32 kMsgBaseType = 'base';
|
||||||
|
|
||||||
|
enum base_type {
|
||||||
|
kHexBase,
|
||||||
|
kDecimalBase
|
||||||
|
};
|
||||||
|
|
||||||
enum view_focus {
|
enum view_focus {
|
||||||
kNoFocus,
|
kNoFocus,
|
||||||
kHexFocus,
|
kHexFocus,
|
||||||
@@ -45,6 +52,9 @@ class DataView : public BView {
|
|||||||
void GetSelection(int32 &start, int32 &end);
|
void GetSelection(int32 &start, int32 &end);
|
||||||
void InvalidateRange(int32 start, int32 end);
|
void InvalidateRange(int32 start, int32 end);
|
||||||
|
|
||||||
|
base_type Base() const { return fBase; }
|
||||||
|
void SetBase(base_type type);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BRect SelectionFrame(view_focus which, int32 start, int32 end);
|
BRect SelectionFrame(view_focus which, int32 start, int32 end);
|
||||||
int32 PositionAt(view_focus focus, BPoint point, view_focus *_newFocus = NULL);
|
int32 PositionAt(view_focus focus, BPoint point, view_focus *_newFocus = NULL);
|
||||||
@@ -66,6 +76,7 @@ class DataView : public BView {
|
|||||||
int32 fFontHeight;
|
int32 fFontHeight;
|
||||||
float fCharWidth;
|
float fCharWidth;
|
||||||
view_focus fFocus;
|
view_focus fFocus;
|
||||||
|
base_type fBase;
|
||||||
bool fIsActive;
|
bool fIsActive;
|
||||||
int32 fStart, fEnd;
|
int32 fStart, fEnd;
|
||||||
int32 fMouseSelectionStart;
|
int32 fMouseSelectionStart;
|
||||||
|
|||||||
Reference in New Issue
Block a user