Ticket #16845: MinApp.cpp

File MinApp.cpp, 1.4 KB (added by X512, 3 years ago)
Line 
1#include <stdio.h>
2
3#include <Application.h>
4#include <Window.h>
5#include <View.h>
6#include <Rect.h>
7
8
9class TestView: public BView
10{
11public:
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
31class TestWindow: public BWindow
32{
33private:
34 TestView *fView;
35public:
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
45class TestApplication: public BApplication
46{
47private:
48 TestWindow *fWnd;
49public:
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
64int main()
65{
66 TestApplication app;
67 app.Run();
68 return 0;
69}