2 * Copyright 2008, Ingo Weinhold, ingo_weinhold@gmx.de.
3 * Distributed under the terms of the MIT License.
7 // NOTE: Nasty hack to get access to BScrollView's private parts.
9 #define private protected
10 #include <ScrollView.h>
13 #include "TermScrollView.h"
18 class TermScrollBar
: public BScrollBar
{
20 TermScrollBar(BRect frame
, const char *name
, BView
*target
,
21 float min
, float max
, orientation direction
)
23 BScrollBar(frame
, name
, target
, min
, max
, direction
)
27 virtual void ValueChanged(float newValue
)
29 if (BView
* target
= Target())
30 target
->ScrollTo(0, newValue
);
35 TermScrollView::TermScrollView(const char* name
, BView
* child
, BView
* target
,
36 bool overlapTop
, uint32 resizingMode
)
38 BScrollView(name
, child
, resizingMode
, 0, false, true, B_NO_BORDER
)
40 child
->TargetedByScrollView(NULL
);
42 // replace the vertical scroll bar with our own
43 if (fVerticalScrollBar
!= NULL
) {
44 BRect
frame(fVerticalScrollBar
->Frame());
45 RemoveChild(fVerticalScrollBar
);
46 delete fVerticalScrollBar
;
48 // Overlap one pixel at the top (if required) with the menu for
49 // aesthetical reasons.
53 TermScrollBar
* scrollBar
= new TermScrollBar(frame
, "_VSB_", target
, 0,
56 fVerticalScrollBar
= scrollBar
;
59 target
->TargetedByScrollView(this);
63 TermScrollView::~TermScrollView()