3 #include <Application.h>
5 #include <ScrollView.h>
8 class View
: public BView
{
11 : BView(frame
, "target view", B_FOLLOW_ALL
,
12 B_WILL_DRAW
| B_FRAME_EVENTS
)
16 virtual void Draw(BRect updateRect
)
18 BRect b
= Bounds().OffsetToCopy(B_ORIGIN
);
19 b
.bottom
= b
.bottom
* 2.0;
20 StrokeLine(b
.LeftTop(), b
.RightBottom());
23 virtual void AttachedToWindow()
25 UpdateScrollbar(Bounds().Height());
28 virtual void FrameResized(float width
, float height
)
30 UpdateScrollbar(height
);
33 void UpdateScrollbar(float height
)
35 BScrollBar
* scrollBar
= ScrollBar(B_VERTICAL
);
37 printf("no vertical scroll bar\n");
40 float smallStep
, bigStep
;
41 scrollBar
->GetSteps(&smallStep
, &bigStep
);
42 printf("scrollbar steps: %.1f, %.1f, proportion: %.1f\n",
43 smallStep
, bigStep
, scrollBar
->Proportion());
45 scrollBar
->SetRange(0.0, height
);
46 scrollBar
->SetSteps(5.0, height
/ 2);
48 scrollBar
->GetSteps(&smallStep
, &bigStep
);
49 printf("scrollbar steps: %.1f, %.1f, proportion: %.1f, "
51 smallStep
, bigStep
, scrollBar
->Proportion(),
58 main(int argc
, char* argv
[])
60 BApplication
app("application/x-vnd.stippi.scrollbar_test");
62 BRect
frame(50, 50, 350, 350);
63 BWindow
* window
= new BWindow(frame
, "BScrollBar Test",
64 B_TITLED_WINDOW_LOOK
, B_NORMAL_WINDOW_FEEL
,
65 B_ASYNCHRONOUS_CONTROLS
| B_QUIT_ON_WINDOW_CLOSE
);
67 frame
= window
->Bounds();
68 frame
.right
-= B_V_SCROLL_BAR_WIDTH
;
69 View
* view
= new View(frame
);
71 BScrollView
* scrollView
= new BScrollView("scroll view", view
,
72 B_FOLLOW_ALL
, 0, false, true, B_NO_BORDER
);
74 window
->AddChild(scrollView
);