xref: /haiku/src/tests/servers/app/draw_string_offsets/main.cpp (revision 02354704729d38c3b078c696adc1bbbd33cbcf72)
1 #include <stdio.h>
2 #include <string.h>
3 
4 #include <Application.h>
5 #include <Message.h>
6 #include <Shape.h>
7 #include <View.h>
8 #include <Window.h>
9 
10 
11 static const char* kAppSignature = "application/x.vnd-Haiku.DrawStringOffsets";
12 
13 
14 class TestView : public BView {
15 public:
16 								TestView(BRect frame, const char* name,
17 									uint32 resizeFlags, uint32 flags);
18 
19 	virtual	void				Draw(BRect updateRect);
20 };
21 
22 
23 TestView::TestView(BRect frame, const char* name, uint32 resizeFlags,
24 		uint32 flags)
25 	:
26 	BView(frame, name, resizeFlags, flags)
27 {
28 }
29 
30 
31 void
32 TestView::Draw(BRect updateRect)
33 {
34 	BPoint offsets[5];
35 	offsets[0].x = 10;
36 	offsets[0].y = 10;
37 	offsets[1].x = 15;
38 	offsets[1].y = 10;
39 	offsets[2].x = 20;
40 	offsets[2].y = 18;
41 	offsets[3].x = 23;
42 	offsets[3].y = 12;
43 	offsets[4].x = 30;
44 	offsets[4].y = 10;
45 
46 	DrawString("Hello", offsets, 5);
47 }
48 
49 
50 // #pragma mark -
51 
52 
53 int
54 main(int argc, char** argv)
55 {
56 	BApplication app(kAppSignature);
57 
58 	BWindow* window = new BWindow(BRect(50.0, 50.0, 300.0, 250.0),
59 		"DrawString() with offsets", B_TITLED_WINDOW,
60 		B_ASYNCHRONOUS_CONTROLS | B_QUIT_ON_WINDOW_CLOSE);
61 
62 	BView* view = new TestView(window->Bounds(), "test", B_FOLLOW_ALL,
63 		B_WILL_DRAW);
64 	window->AddChild(view);
65 
66 	window->Show();
67 
68 	app.Run();
69 	return 0;
70 }
71