diff --git a/src/apps/diskprobe/DataView.cpp b/src/apps/diskprobe/DataView.cpp index 9109401924..3f0c33e2a5 100644 --- a/src/apps/diskprobe/DataView.cpp +++ b/src/apps/diskprobe/DataView.cpp @@ -7,8 +7,9 @@ #include "DataView.h" #include "DataEditor.h" -#include +//#include #include +#include static const uint32 kBlockSize = 16; @@ -158,6 +159,9 @@ DataView::Draw(BRect updateRect) int32 DataView::PositionAt(view_focus focus, BPoint point, view_focus *_newFocus) { + if (!Bounds().Contains(point)) + return -1; + float left = fCharWidth * (fPositionLength + kBlockSpace) + kHorizontalSpace; float hexWidth = fCharWidth * kBlockSize * kHexByteWidth; float width = fCharWidth; @@ -478,6 +482,41 @@ DataView::WindowActivated(bool active) } +void +DataView::UpdateScroller() +{ + float width, height; + GetPreferredSize(&width, &height); + + BScrollBar *bar; + if ((bar = ScrollBar(B_HORIZONTAL)) != NULL) { + float delta = width - Bounds().Width(); + if (delta < 0) + delta = 0; + + bar->SetRange(0, delta); + bar->SetSteps(fCharWidth, Bounds().Width()); + bar->SetProportion(Bounds().Width() / width); + } + if ((bar = ScrollBar(B_VERTICAL)) != NULL) { + float delta = height - Bounds().Height(); + if (delta < 0) + delta = 0; + + bar->SetRange(0, delta); + bar->SetSteps(fFontHeight, Bounds().Height()); + bar->SetProportion(Bounds().Height() / height); + } +} + + +void +DataView::FrameResized(float width, float height) +{ + UpdateScroller(); +} + + void DataView::MouseDown(BPoint where) { diff --git a/src/apps/diskprobe/DataView.h b/src/apps/diskprobe/DataView.h index cb7b18a7f8..952b4c6494 100644 --- a/src/apps/diskprobe/DataView.h +++ b/src/apps/diskprobe/DataView.h @@ -34,10 +34,12 @@ class DataView : public BView { virtual void MouseUp(BPoint where); virtual void WindowActivated(bool active); + virtual void FrameResized(float width, float height); virtual void SetFont(const BFont *font, uint32 properties = B_FONT_ALL); virtual void GetPreferredSize(float *_width, float *_height); void SetFontSize(float point); + void UpdateScroller(); void SetSelection(int32 start, int32 end, view_focus focus = kNoFocus); void GetSelection(int32 &start, int32 &end); diff --git a/src/apps/diskprobe/ProbeView.cpp b/src/apps/diskprobe/ProbeView.cpp index dea5371e8e..4df62fa602 100644 --- a/src/apps/diskprobe/ProbeView.cpp +++ b/src/apps/diskprobe/ProbeView.cpp @@ -365,6 +365,8 @@ ProbeView::ProbeView(BRect rect, entry_ref *ref, const char *attribute) fScrollView = new BScrollView("scroller", fDataView, B_FOLLOW_ALL, B_WILL_DRAW, true, true); AddChild(fScrollView); + + fDataView->UpdateScroller(); } @@ -383,7 +385,7 @@ ProbeView::UpdateSizeLimits() fDataView->GetPreferredSize(&width, &height); Window()->SetSizeLimits(200, width + B_V_SCROLL_BAR_WIDTH, - 200, height + fHeaderView->Frame().bottom + 1 + B_H_SCROLL_BAR_HEIGHT + Frame().top); + 200, height + fHeaderView->Frame().bottom + 4 + B_H_SCROLL_BAR_HEIGHT + Frame().top); } diff --git a/src/apps/diskprobe/ProbeWindow.cpp b/src/apps/diskprobe/ProbeWindow.cpp index e4b9c807c2..6ba8025db0 100644 --- a/src/apps/diskprobe/ProbeWindow.cpp +++ b/src/apps/diskprobe/ProbeWindow.cpp @@ -83,7 +83,14 @@ ProbeWindow::~ProbeWindow() void ProbeWindow::MessageReceived(BMessage *message) { - BWindow::MessageReceived(message); + switch (message->what) { + case B_MOUSE_WHEEL_CHANGED: + if (BView *view = FindView("dataView")) + view->MessageReceived(message); + break; + default: + BWindow::MessageReceived(message); + } }