1 | #include <stdio.h>
|
---|
2 |
|
---|
3 | #include <Application.h>
|
---|
4 | #include <InterfaceDefs.h>
|
---|
5 | #include <Rect.h>
|
---|
6 | #include <View.h>
|
---|
7 | #include <Window.h>
|
---|
8 |
|
---|
9 |
|
---|
10 | static const rgb_color red = (rgb_color){ 255, 0, 0 };
|
---|
11 | static const rgb_color green = (rgb_color){ 0, 255, 0 };
|
---|
12 | static const rgb_color blue = (rgb_color){ 0, 0, 255 };
|
---|
13 |
|
---|
14 |
|
---|
15 | class View : public BView {
|
---|
16 | public:
|
---|
17 | View();
|
---|
18 | virtual ~View();
|
---|
19 |
|
---|
20 | virtual void FrameResized(float width, float height);
|
---|
21 | virtual void Draw(BRect updateRect);
|
---|
22 | };
|
---|
23 |
|
---|
24 |
|
---|
25 | View::View()
|
---|
26 | :
|
---|
27 | BView(BRect(0, 0, 400, 200), "bwah", B_FOLLOW_ALL_SIDES,
|
---|
28 | B_FRAME_EVENTS | B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE)
|
---|
29 | {
|
---|
30 | SetViewColor(green);
|
---|
31 | }
|
---|
32 |
|
---|
33 |
|
---|
34 | View::~View()
|
---|
35 | {
|
---|
36 | }
|
---|
37 |
|
---|
38 |
|
---|
39 | void
|
---|
40 | View::FrameResized(float width, float height)
|
---|
41 | {
|
---|
42 | puts("FrameResized");
|
---|
43 | SetViewColor(blue);
|
---|
44 | }
|
---|
45 |
|
---|
46 |
|
---|
47 | void
|
---|
48 | View::Draw(BRect updateRect)
|
---|
49 | {
|
---|
50 | puts("Draw");
|
---|
51 | SetViewColor(red);
|
---|
52 | }
|
---|
53 |
|
---|
54 |
|
---|
55 | class App : public BApplication {
|
---|
56 | public:
|
---|
57 | App();
|
---|
58 | ~App();
|
---|
59 |
|
---|
60 | protected:
|
---|
61 | void ReadyToRun();
|
---|
62 | };
|
---|
63 |
|
---|
64 |
|
---|
65 | App::App()
|
---|
66 | :
|
---|
67 | BApplication("application/x-vnd.Haiku-ResizeTester")
|
---|
68 | {
|
---|
69 | }
|
---|
70 |
|
---|
71 |
|
---|
72 | App::~App(void)
|
---|
73 | {
|
---|
74 | }
|
---|
75 |
|
---|
76 |
|
---|
77 | void
|
---|
78 | App::ReadyToRun()
|
---|
79 | {
|
---|
80 | BWindow* window = new BWindow(BRect(100, 100, 400, 200), "resize tester window",
|
---|
81 | B_TITLED_WINDOW, B_NOT_ZOOMABLE);
|
---|
82 |
|
---|
83 | View* view = new View();
|
---|
84 | window->AddChild(view);
|
---|
85 |
|
---|
86 | window->Show();
|
---|
87 | }
|
---|
88 |
|
---|
89 |
|
---|
90 | int
|
---|
91 | main(void)
|
---|
92 | {
|
---|
93 | App app;
|
---|
94 | app.Run();
|
---|
95 |
|
---|
96 | return 0;
|
---|
97 | }
|
---|