headers/bsd: Add sys/queue.h.
[haiku.git] / src / tests / servers / app / benchmark / TestWindow.cpp
blob1fec00d5d1a087945e74b4cecb3784b874b64aa2
1 /*
2 * Copyright (C) 2008 Stephan Aßmus <superstippi@gmx.de>
3 * All rights reserved. Distributed under the terms of the MIT license.
4 */
5 #include "TestWindow.h"
7 #include "Test.h"
10 TestView::TestView(BRect frame, Test* test, drawing_mode mode,
11 bool useClipping, const BMessenger& target)
13 BView(frame, "test view", B_FOLLOW_ALL, B_WILL_DRAW),
14 fTest(test),
15 fTarget(target),
16 fUseClipping(useClipping)
18 SetDrawingMode(mode);
22 void
23 TestView::AttachedToWindow()
25 fTest->Prepare(this);
26 if (fUseClipping)
27 fTest->SetupClipping(this);
31 void
32 TestView::Draw(BRect updateRect)
34 if (fTest->RunIteration(this)) {
35 Invalidate();
36 return;
39 fTarget.SendMessage(MSG_TEST_FINISHED);
43 TestWindow::TestWindow(BRect frame, Test* test, drawing_mode mode,
44 bool useClipping, const BMessenger& target)
45 : BWindow(frame, "Test Window", B_TITLED_WINDOW_LOOK,
46 B_FLOATING_ALL_WINDOW_FEEL, B_NOT_ZOOMABLE | B_NOT_RESIZABLE),
47 fTarget(target),
48 fAllowedToQuit(false)
50 fTestView = new TestView(Bounds(), test, mode, useClipping, target);
51 AddChild(fTestView);
52 Show();
56 bool
57 TestWindow::QuitRequested()
59 if (fAllowedToQuit)
60 return true;
62 fTarget.SendMessage(MSG_TEST_CANCELED);
63 return false;
67 void
68 TestWindow::SetAllowedToQuit(bool allowed)
70 fAllowedToQuit = allowed;