* Copyright 2008, Ingo Weinhold, ingo_weinhold@gmx.de.
* Distributed under the terms of the MIT License.
*/
#include <ScrollBar.h>
#define private protected
#include <ScrollView.h>
#undef private
#include "TermScrollView.h"
#include <Message.h>
class TermScrollBar : public BScrollBar {
public:
TermScrollBar(BRect frame, const char *name, BView *target,
float min, float max, orientation direction)
:
BScrollBar(frame, name, target, min, max, direction)
{
}
virtual void ValueChanged(float newValue)
{
if (BView* target = Target())
target->ScrollTo(0, newValue);
}
};
TermScrollView::TermScrollView(const char* name, BView* child, BView* target,
bool overlapTop, uint32 resizingMode)
:
BScrollView(name, child, resizingMode, 0, false, true, B_NO_BORDER)
{
child->TargetedByScrollView(NULL);
if (fVerticalScrollBar != NULL) {
BRect frame(fVerticalScrollBar->Frame());
RemoveChild(fVerticalScrollBar);
delete fVerticalScrollBar;
if (overlapTop)
frame.top--;
TermScrollBar* scrollBar = new TermScrollBar(frame, "_VSB_", target, 0,
1000, B_VERTICAL);
AddChild(scrollBar);
fVerticalScrollBar = scrollBar;
}
target->TargetedByScrollView(this);
}
TermScrollView::~TermScrollView()
{
}