From 4ac1c030e23d25aca2f1e08215d42d9d91c3d26f Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Fri, 8 Jun 2007 23:46:25 +0000 Subject: [PATCH] New helper class TestView. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21360 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- .../layout/widget_layout_test/Jamfile | 1 + .../layout/widget_layout_test/TestView.cpp | 48 +++++++++++++++++++ .../layout/widget_layout_test/TestView.h | 30 ++++++++++++ 3 files changed, 79 insertions(+) create mode 100644 src/tests/kits/interface/layout/widget_layout_test/TestView.cpp create mode 100644 src/tests/kits/interface/layout/widget_layout_test/TestView.h diff --git a/src/tests/kits/interface/layout/widget_layout_test/Jamfile b/src/tests/kits/interface/layout/widget_layout_test/Jamfile index e7341e1ae4..c2f72fc9f2 100644 --- a/src/tests/kits/interface/layout/widget_layout_test/Jamfile +++ b/src/tests/kits/interface/layout/widget_layout_test/Jamfile @@ -13,6 +13,7 @@ SimpleTest WidgetLayoutTest : RadioButton.cpp StringView.cpp Test.cpp + TestView.cpp TwoDimensionalSliderView.cpp View.cpp ViewContainer.cpp diff --git a/src/tests/kits/interface/layout/widget_layout_test/TestView.cpp b/src/tests/kits/interface/layout/widget_layout_test/TestView.cpp new file mode 100644 index 0000000000..863802d4e5 --- /dev/null +++ b/src/tests/kits/interface/layout/widget_layout_test/TestView.cpp @@ -0,0 +1,48 @@ +/* + * Copyright 2007, Ingo Weinhold . + * All rights reserved. Distributed under the terms of the MIT License. + */ + +#include "TestView.h" + + +TestView::TestView(BSize minSize, BSize maxSize, BSize preferredSize) + : BView("test view", B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE), + fMinSize(minSize), + fMaxSize(maxSize), + fPreferredSize(preferredSize) +{ + SetViewColor((rgb_color){150, 220, 150, 255}); + SetHighColor((rgb_color){0, 80, 0, 255}); +} + + +BSize +TestView::MinSize() +{ + return fMinSize; +} + + +BSize +TestView::MaxSize() +{ + return fMaxSize; +} + + +BSize +TestView::PreferredSize() +{ + return fPreferredSize; +} + + +void +TestView::Draw(BRect updateRect) +{ + BRect bounds(Bounds()); + StrokeRect(bounds); + StrokeLine(bounds.LeftTop(), bounds.RightBottom()); + StrokeLine(bounds.LeftBottom(), bounds.RightTop()); +} diff --git a/src/tests/kits/interface/layout/widget_layout_test/TestView.h b/src/tests/kits/interface/layout/widget_layout_test/TestView.h new file mode 100644 index 0000000000..fd028704a4 --- /dev/null +++ b/src/tests/kits/interface/layout/widget_layout_test/TestView.h @@ -0,0 +1,30 @@ +/* + * Copyright 2007, Ingo Weinhold . + * All rights reserved. Distributed under the terms of the MIT License. + */ +#ifndef WIDGET_LAYOUT_TEST_TEST_VIEW_H +#define WIDGET_LAYOUT_TEST_TEST_VIEW_H + + +#include + + +class TestView : public BView { +public: + TestView(BSize minSize, BSize maxSize, + BSize preferredSize); + + virtual BSize MinSize(); + virtual BSize MaxSize(); + virtual BSize PreferredSize(); + + virtual void Draw(BRect updateRect); + +private: + BSize fMinSize; + BSize fMaxSize; + BSize fPreferredSize; +}; + + +#endif // WIDGET_LAYOUT_TEST_TEST_VIEW_H