diff --git a/src/tests/kits/interface/Jamfile b/src/tests/kits/interface/Jamfile index f053deef39..6ba39ae22b 100644 --- a/src/tests/kits/interface/Jamfile +++ b/src/tests/kits/interface/Jamfile @@ -91,6 +91,11 @@ SimpleTest CheckBoxTest : : be [ TargetLibsupc++ ] ; +SimpleTest ListViewTest : + ListViewTest.cpp + : be [ TargetLibsupc++ ] + ; + SimpleTest ScreenTest : ScreenTest.cpp : be diff --git a/src/tests/kits/interface/ListViewTest.cpp b/src/tests/kits/interface/ListViewTest.cpp new file mode 100644 index 0000000000..6c82ef26f8 --- /dev/null +++ b/src/tests/kits/interface/ListViewTest.cpp @@ -0,0 +1,114 @@ +/* + * Copyright 2005, Axel Dörfler, axeld@pinc-software.de. All rights reserved. + * Copyright 2014 Haiku, Inc. + * Distributed under the terms of the MIT License. + */ + + +#include +#include +#include +#include + +#include + + +class ColorfulItem: public BStringItem +{ + public: + ColorfulItem(const char* label, rgb_color color); + virtual void DrawItem(BView* owner, BRect frame, + bool complete = false); + + private: + rgb_color fColor; +}; + + +ColorfulItem::ColorfulItem(const char* label, rgb_color color) + : + BStringItem(label), + fColor(color) +{ +} + + +void +ColorfulItem::DrawItem(BView* owner, BRect frame, bool complete) +{ + owner->SetHighColor(fColor); + BStringItem::DrawItem(owner, frame, complete); +} + + +// #pragma mark - + + +class Window : public BWindow { + public: + Window(); + + virtual bool QuitRequested(); +}; + + +Window::Window() + : BWindow(BRect(100, 100, 520, 430), "ListView-Test", + B_TITLED_WINDOW, B_ASYNCHRONOUS_CONTROLS) +{ + BRect rect(20, 10, 200, 300); + BListView *listView = new BListView(rect, "list"); + + listView->AddItem(new BStringItem("normal item")); + listView->AddItem(new ColorfulItem("green item", make_color(0, 255, 0))); + listView->AddItem(new BStringItem("normal item")); + + AddChild(listView); +} + + +bool +Window::QuitRequested() +{ + be_app->PostMessage(B_QUIT_REQUESTED); + return true; +} + + +// #pragma mark - + + +class Application : public BApplication { + public: + Application(); + + virtual void ReadyToRun(void); +}; + + +Application::Application() + : BApplication("application/x-vnd.obos-test") +{ +} + + +void +Application::ReadyToRun(void) +{ + BWindow *window = new Window(); + window->Show(); +} + + +// #pragma mark - + + +int +main(int argc, char **argv) +{ + Application app; + + app.Run(); + return 0; +} +