1 | #include <Window.h>
|
---|
2 | #include <Application.h>
|
---|
3 | #include <stdlib.h>
|
---|
4 |
|
---|
5 |
|
---|
6 | class SimpleWindow : public BWindow {
|
---|
7 | public:
|
---|
8 | SimpleWindow(BRect frame);
|
---|
9 | virtual bool QuitRequested();
|
---|
10 | };
|
---|
11 |
|
---|
12 |
|
---|
13 | SimpleWindow::SimpleWindow(BRect frame)
|
---|
14 | : BWindow(frame, "A Simple Window", B_TITLED_WINDOW, B_NOT_RESIZABLE)
|
---|
15 | {
|
---|
16 | }
|
---|
17 |
|
---|
18 |
|
---|
19 | bool
|
---|
20 | SimpleWindow::QuitRequested()
|
---|
21 | {
|
---|
22 | be_app->PostMessage(B_QUIT_REQUESTED);
|
---|
23 | return true;
|
---|
24 | }
|
---|
25 |
|
---|
26 |
|
---|
27 | class SimpleApplication : public BApplication {
|
---|
28 | public:
|
---|
29 | SimpleApplication();
|
---|
30 | };
|
---|
31 |
|
---|
32 |
|
---|
33 | SimpleApplication::SimpleApplication()
|
---|
34 | : BApplication("application/x-vnd.dps-simpleapp")
|
---|
35 | {
|
---|
36 | SimpleWindow *aWindow;
|
---|
37 | SimpleWindow *aWindow2;
|
---|
38 | BRect aRect;
|
---|
39 | BRect aRect2;
|
---|
40 | float x = 320;
|
---|
41 | float y = 220;
|
---|
42 |
|
---|
43 | aRect.Set(x, y, x + 180, y + 30); //left, top, right, bottom
|
---|
44 | aRect2.Set(y, x, y + 180, x + 30);
|
---|
45 |
|
---|
46 | aWindow = new SimpleWindow(aRect);
|
---|
47 | aWindow2 = new SimpleWindow(aRect2);
|
---|
48 |
|
---|
49 | aWindow->Show();
|
---|
50 | aWindow2->Show();
|
---|
51 | system("sleep 1");
|
---|
52 |
|
---|
53 | aWindow->SetTitle("and now it will move...");
|
---|
54 | aWindow2->SetTitle("and now it will move...");
|
---|
55 | system("sleep 1");
|
---|
56 |
|
---|
57 | aWindow->SetTitle("my moving window1");
|
---|
58 | aWindow2->SetTitle("my moving window2");
|
---|
59 |
|
---|
60 | for (; x > 0; x--, y -= ((float)220 / (float)320)) {
|
---|
61 | aWindow->MoveTo(x, y);
|
---|
62 | aWindow2->MoveTo(y, x);
|
---|
63 | }
|
---|
64 | //x=0; y=0;
|
---|
65 | for (; (x <= 320); x++, y += ((float)220 / (float)320)) {
|
---|
66 | aWindow->MoveTo(x, y);
|
---|
67 | aWindow2->MoveTo(y, x);
|
---|
68 | }
|
---|
69 | system("sleep 1");
|
---|
70 | for (; y <= 800; y *= 1.009) {
|
---|
71 | aWindow->MoveTo(x, y);
|
---|
72 | aWindow2->MoveTo(y, x);
|
---|
73 | }
|
---|
74 |
|
---|
75 | be_app->PostMessage(B_QUIT_REQUESTED);
|
---|
76 | }
|
---|
77 |
|
---|
78 |
|
---|
79 | int main()
|
---|
80 | {
|
---|
81 |
|
---|
82 | SimpleApplication myApplication;
|
---|
83 | myApplication.Run();
|
---|
84 |
|
---|
85 | return 0;
|
---|
86 | }
|
---|
87 |
|
---|
88 |
|
---|