5 #include <Application.h>
9 class TestView
: public BView
{
12 TestView(BRect frame
, const char* name
,
13 uint32 resizeFlags
, uint32 flags
);
15 virtual void Draw(BRect updateRect
);
16 virtual void MouseDown(BPoint where
);
23 TestView::TestView(BRect frame
, const char* name
,
24 uint32 resizeFlags
, uint32 flags
)
25 : BView(frame
, name
, resizeFlags
, flags
),
32 TestView::Draw(BRect updateRect
)
34 int32 count
= fMouseSamples
.CountItems();
36 BPoint
* p
= (BPoint
*)fMouseSamples
.ItemAtFast(0);
40 for (int32 i
= 0; i
< count
; i
++) {
41 BPoint
* p
= (BPoint
*)fMouseSamples
.ItemAtFast(i
);
48 TestView::MouseDown(BPoint where
)
50 // clear previous stroke
51 int32 count
= fMouseSamples
.CountItems();
52 for (int32 i
= 0; i
< count
; i
++)
53 delete (BPoint
*)fMouseSamples
.ItemAtFast(i
);
54 fMouseSamples
.MakeEmpty();
55 FillRect(Bounds(), B_SOLID_LOW
);
59 GetMouse(&where
, &buttons
);
64 fMouseSamples
.AddItem(new BPoint(where
));
67 GetMouse(&where
, &buttons
);
74 main(int argc
, char** argv
)
76 BApplication
app("application/x.vnd-Haiku.BitmapBounds");
78 BRect
frame(50.0, 50.0, 300.0, 250.0);
79 BWindow
* window
= new BWindow(frame
, "Bitmap Bounds", B_TITLED_WINDOW
,
80 B_ASYNCHRONOUS_CONTROLS
| B_QUIT_ON_WINDOW_CLOSE
);
82 BView
* view
= new TestView(window
->Bounds(), "test",
83 B_FOLLOW_ALL
, B_WILL_DRAW
);
84 window
->AddChild(view
);