The scroll bars now work correctly.
Mouse wheel support added. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@6572 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -7,8 +7,9 @@
|
|||||||
#include "DataView.h"
|
#include "DataView.h"
|
||||||
#include "DataEditor.h"
|
#include "DataEditor.h"
|
||||||
|
|
||||||
#include <Messenger.h>
|
//#include <Messenger.h>
|
||||||
#include <Looper.h>
|
#include <Looper.h>
|
||||||
|
#include <ScrollBar.h>
|
||||||
|
|
||||||
|
|
||||||
static const uint32 kBlockSize = 16;
|
static const uint32 kBlockSize = 16;
|
||||||
@@ -158,6 +159,9 @@ DataView::Draw(BRect updateRect)
|
|||||||
int32
|
int32
|
||||||
DataView::PositionAt(view_focus focus, BPoint point, view_focus *_newFocus)
|
DataView::PositionAt(view_focus focus, BPoint point, view_focus *_newFocus)
|
||||||
{
|
{
|
||||||
|
if (!Bounds().Contains(point))
|
||||||
|
return -1;
|
||||||
|
|
||||||
float left = fCharWidth * (fPositionLength + kBlockSpace) + kHorizontalSpace;
|
float left = fCharWidth * (fPositionLength + kBlockSpace) + kHorizontalSpace;
|
||||||
float hexWidth = fCharWidth * kBlockSize * kHexByteWidth;
|
float hexWidth = fCharWidth * kBlockSize * kHexByteWidth;
|
||||||
float width = fCharWidth;
|
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
|
void
|
||||||
DataView::MouseDown(BPoint where)
|
DataView::MouseDown(BPoint where)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -34,10 +34,12 @@ class DataView : public BView {
|
|||||||
virtual void MouseUp(BPoint where);
|
virtual void MouseUp(BPoint where);
|
||||||
|
|
||||||
virtual void WindowActivated(bool active);
|
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 SetFont(const BFont *font, uint32 properties = B_FONT_ALL);
|
||||||
virtual void GetPreferredSize(float *_width, float *_height);
|
virtual void GetPreferredSize(float *_width, float *_height);
|
||||||
|
|
||||||
void SetFontSize(float point);
|
void SetFontSize(float point);
|
||||||
|
void UpdateScroller();
|
||||||
|
|
||||||
void SetSelection(int32 start, int32 end, view_focus focus = kNoFocus);
|
void SetSelection(int32 start, int32 end, view_focus focus = kNoFocus);
|
||||||
void GetSelection(int32 &start, int32 &end);
|
void GetSelection(int32 &start, int32 &end);
|
||||||
|
|||||||
@@ -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);
|
fScrollView = new BScrollView("scroller", fDataView, B_FOLLOW_ALL, B_WILL_DRAW, true, true);
|
||||||
AddChild(fScrollView);
|
AddChild(fScrollView);
|
||||||
|
|
||||||
|
fDataView->UpdateScroller();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -383,7 +385,7 @@ ProbeView::UpdateSizeLimits()
|
|||||||
fDataView->GetPreferredSize(&width, &height);
|
fDataView->GetPreferredSize(&width, &height);
|
||||||
|
|
||||||
Window()->SetSizeLimits(200, width + B_V_SCROLL_BAR_WIDTH,
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -83,7 +83,14 @@ ProbeWindow::~ProbeWindow()
|
|||||||
void
|
void
|
||||||
ProbeWindow::MessageReceived(BMessage *message)
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user