1 | #include <Application.h>
|
---|
2 | #include <Window.h>
|
---|
3 | #include <View.h>
|
---|
4 |
|
---|
5 | /*
|
---|
6 | Pe commands
|
---|
7 |
|
---|
8 | gcc fontHang.cpp -lbe -o fontHang
|
---|
9 | fontHang
|
---|
10 | */
|
---|
11 |
|
---|
12 | class TestView : public BView
|
---|
13 | {
|
---|
14 | public:
|
---|
15 |
|
---|
16 | TestView(BRect frame, char* name, uint32 flags): BView(frame, name, flags, B_WILL_DRAW)
|
---|
17 | {
|
---|
18 | }
|
---|
19 | virtual ~TestView()
|
---|
20 | {
|
---|
21 | }
|
---|
22 |
|
---|
23 | virtual void Draw(BRect updateRect)
|
---|
24 | {
|
---|
25 | BFont f;
|
---|
26 | f.SetSize(-1);
|
---|
27 | SetFont(&f);
|
---|
28 | DrawString("String", BPoint(16, 16));
|
---|
29 | }
|
---|
30 | };
|
---|
31 |
|
---|
32 | /*
|
---|
33 | * Window
|
---|
34 | */
|
---|
35 |
|
---|
36 | class TestWindow : public BWindow
|
---|
37 | {
|
---|
38 | private:
|
---|
39 | TestView* view;
|
---|
40 |
|
---|
41 | public:
|
---|
42 | TestWindow(BRect frame)
|
---|
43 | : BWindow(frame, "Test", B_TITLED_WINDOW, B_NOT_ZOOMABLE | B_NOT_RESIZABLE)
|
---|
44 | {
|
---|
45 | view = new TestView(BRect(Bounds()), "Test", B_FOLLOW_ALL);
|
---|
46 | AddChild(view);
|
---|
47 | }
|
---|
48 |
|
---|
49 | virtual bool QuitRequested()
|
---|
50 | {
|
---|
51 | be_app->PostMessage(B_QUIT_REQUESTED);
|
---|
52 | return BWindow::QuitRequested();
|
---|
53 | }
|
---|
54 | };
|
---|
55 |
|
---|
56 | /*
|
---|
57 | Application
|
---|
58 | */
|
---|
59 |
|
---|
60 | class TestApplication : public BApplication
|
---|
61 | {
|
---|
62 | private:
|
---|
63 | TestWindow* wnd;
|
---|
64 |
|
---|
65 | public:
|
---|
66 | TestApplication() : BApplication ("application/x-vnd.Be-Test"){}
|
---|
67 | virtual void ReadyToRun()
|
---|
68 | {
|
---|
69 | BRect rect(32, 32, 32+128+8, 32+24+8);
|
---|
70 | wnd = new TestWindow(rect);
|
---|
71 | wnd->Show();
|
---|
72 | }
|
---|
73 | };
|
---|
74 |
|
---|
75 | TestApplication* app;
|
---|
76 |
|
---|
77 | int main()
|
---|
78 | {
|
---|
79 | app = new TestApplication();
|
---|
80 | app->Run();
|
---|
81 | return 0;
|
---|
82 | }
|
---|