1 | #include <stdio.h>
|
---|
2 |
|
---|
3 | #include <Application.h>
|
---|
4 | #include <Window.h>
|
---|
5 | #include <View.h>
|
---|
6 | #include <Rect.h>
|
---|
7 |
|
---|
8 |
|
---|
9 | class TestView: public BView
|
---|
10 | {
|
---|
11 | public:
|
---|
12 | TestView(BRect frame, const char *name): BView(frame, name, B_FOLLOW_NONE, B_FULL_UPDATE_ON_RESIZE | B_WILL_DRAW | B_SUBPIXEL_PRECISE)
|
---|
13 | {
|
---|
14 | SetViewColor(0xff - 0x44, 0xff - 0x44, 0xff - 0x44);
|
---|
15 | }
|
---|
16 |
|
---|
17 | void Draw(BRect dirty)
|
---|
18 | {
|
---|
19 | BRect rect = Frame().OffsetToCopy(B_ORIGIN);
|
---|
20 | rect.left += 1; rect.top += 1;
|
---|
21 | SetHighColor(0x44, 0x44, 0x44);
|
---|
22 | SetPenSize(2);
|
---|
23 | StrokeRect(rect, B_SOLID_HIGH);
|
---|
24 | SetPenSize(1);
|
---|
25 | StrokeLine(rect.LeftTop(), rect.RightBottom());
|
---|
26 | StrokeLine(rect.RightTop(), rect.LeftBottom());
|
---|
27 | }
|
---|
28 |
|
---|
29 | };
|
---|
30 |
|
---|
31 | class TestWindow: public BWindow
|
---|
32 | {
|
---|
33 | private:
|
---|
34 | TestView *fView;
|
---|
35 | public:
|
---|
36 | TestWindow(BRect frame): BWindow(frame, "TestApp", B_TITLED_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL, B_AVOID_FOCUS | B_ASYNCHRONOUS_CONTROLS)
|
---|
37 | {
|
---|
38 | fView = new TestView(frame.OffsetToCopy(B_ORIGIN), "view");
|
---|
39 | fView->SetResizingMode(B_FOLLOW_ALL);
|
---|
40 | AddChild(fView, NULL);
|
---|
41 | }
|
---|
42 |
|
---|
43 | };
|
---|
44 |
|
---|
45 | class TestApplication: public BApplication
|
---|
46 | {
|
---|
47 | private:
|
---|
48 | TestWindow *fWnd;
|
---|
49 | public:
|
---|
50 | TestApplication(): BApplication("application/x-vnd.Test-App")
|
---|
51 | {
|
---|
52 | }
|
---|
53 |
|
---|
54 | void ReadyToRun() {
|
---|
55 | for (;;) {
|
---|
56 | fWnd = new TestWindow(BRect(0, 0, 256, 256).OffsetByCopy(64, 64));
|
---|
57 | fWnd->Show();
|
---|
58 | fWnd->Lock(); fWnd->Quit(); fWnd = NULL;
|
---|
59 | }
|
---|
60 | }
|
---|
61 | };
|
---|
62 |
|
---|
63 |
|
---|
64 | int main()
|
---|
65 | {
|
---|
66 | TestApplication app;
|
---|
67 | app.Run();
|
---|
68 | return 0;
|
---|
69 | }
|
---|