btrfs: Attempt to fix GCC2 build.
[haiku.git] / src / apps / terminal / TermScrollView.cpp
blob7115ccd9d2b5908427b8cda94036dfd04ffbc1ae
1 /*
2 * Copyright 2008, Ingo Weinhold, ingo_weinhold@gmx.de.
3 * Distributed under the terms of the MIT License.
4 */
7 // NOTE: Nasty hack to get access to BScrollView's private parts.
8 #include <ScrollBar.h>
9 #define private protected
10 #include <ScrollView.h>
11 #undef private
13 #include "TermScrollView.h"
15 #include <Message.h>
18 class TermScrollBar : public BScrollBar {
19 public:
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.
50 if (overlapTop)
51 frame.top--;
53 TermScrollBar* scrollBar = new TermScrollBar(frame, "_VSB_", target, 0,
54 1000, B_VERTICAL);
55 AddChild(scrollBar);
56 fVerticalScrollBar = scrollBar;
59 target->TargetedByScrollView(this);
63 TermScrollView::~TermScrollView()