1 | #include <iostream>
|
---|
2 |
|
---|
3 | #include <Application.h>
|
---|
4 | #include <Message.h>
|
---|
5 | #include <View.h>
|
---|
6 | #include <Window.h>
|
---|
7 |
|
---|
8 |
|
---|
9 | class SimpleView : public BView {
|
---|
10 | public:
|
---|
11 | SimpleView(const char* name) : BView(BRect(0, 0, 400, 400), name, B_FOLLOW_ALL_SIDES, 0) {
|
---|
12 | }
|
---|
13 |
|
---|
14 | virtual void MouseDown(BPoint point) {
|
---|
15 | Window()->CurrentMessage()->PrintToStream();
|
---|
16 | }
|
---|
17 |
|
---|
18 | virtual void MouseUp(BPoint point) {
|
---|
19 | Window()->CurrentMessage()->PrintToStream();
|
---|
20 | }
|
---|
21 | };
|
---|
22 |
|
---|
23 |
|
---|
24 | class SimpleWindow : public BWindow {
|
---|
25 | public:
|
---|
26 | SimpleWindow() : BWindow(BRect(100, 100, 500, 500), "Hello", B_TITLED_WINDOW, 0) {
|
---|
27 | fView = new SimpleView("fView");
|
---|
28 | AddChild(fView);
|
---|
29 | }
|
---|
30 |
|
---|
31 | bool QuitRequested() {
|
---|
32 | be_app->PostMessage(B_QUIT_REQUESTED);
|
---|
33 | return true;
|
---|
34 | }
|
---|
35 | private:
|
---|
36 | SimpleView* fView;
|
---|
37 | };
|
---|
38 |
|
---|
39 |
|
---|
40 | class MouseTest : public BApplication {
|
---|
41 | public:
|
---|
42 | MouseTest(): BApplication("application/x-vnd.MouseTest") {
|
---|
43 | fWindow = new SimpleWindow();
|
---|
44 | fWindow->Show();
|
---|
45 | }
|
---|
46 | private:
|
---|
47 | SimpleWindow* fWindow;
|
---|
48 | };
|
---|
49 |
|
---|
50 | int main(int argc, char** argv) {
|
---|
51 | MouseTest* app = new MouseTest();
|
---|
52 | app->Run();
|
---|
53 | delete app;
|
---|
54 | return B_OK;
|
---|
55 | }
|
---|