2 * Copyright 2008, Stephan Aßmus <superstippi@gmx.de>
3 * Distributed under the terms of the MIT License.
7 #include <Application.h>
14 class View
: public BView
{
16 View(BRect rect
, const char* name
, uint32 followMode
,
17 uint8 red
, uint8 green
, uint8 blue
)
18 : BView(rect
, name
, followMode
, 0)
20 SetViewColor(red
, green
, blue
);
25 class TestView
: public View
{
27 TestView(BRect rect
, const char* name
, uint32 followMode
,
28 uint8 red
, uint8 green
, uint8 blue
)
29 : View(rect
, name
, followMode
, red
, green
, blue
)
31 SetEventMask(B_POINTER_EVENTS
, B_NO_POINTER_HISTORY
);
34 virtual void MouseMoved(BPoint where
, uint32 transit
,
35 const BMessage
* dragMessage
)
37 ConvertToScreen(&where
);
38 where
-= Window()->Frame().LeftTop();
39 BView
* view
= Window()->FindView(where
);
40 printf("View at (%.1f, %.1f): %s\n", where
.x
, where
.y
,
41 view
? view
->Name() : "NULL");
50 main(int argc
, char **argv
)
52 BApplication
app("application/x-vnd.haiku-find_view");
54 BWindow
* window
= new BWindow(BRect(100, 100, 400, 400),
55 "ViewTransit-Test", B_TITLED_WINDOW
,
56 B_ASYNCHRONOUS_CONTROLS
| B_QUIT_ON_WINDOW_CLOSE
);
59 BRect frame
= window
->Bounds();
60 View
* testView
= new TestView(frame
, "Test View", B_FOLLOW_ALL
, 255, 0, 0);
61 window
->AddChild(testView
);
64 frame
.InsetBy(20, 20);
66 View
* view1
= new View(frame
, "View 1",
67 B_FOLLOW_TOP_BOTTOM
| B_FOLLOW_RIGHT
, 0, 255, 0);
68 testView
->AddChild(view1
);
71 frame
.left
= frame
.right
+ 1;
72 frame
.right
= window
->Bounds().right
- 20;
73 View
* view2
= new View(frame
, "View 2",
74 B_FOLLOW_TOP_BOTTOM
| B_FOLLOW_RIGHT
, 0, 0, 255);
75 testView
->AddChild(view2
);