diff --git a/src/tests/servers/app/Jamfile b/src/tests/servers/app/Jamfile index ca9d932337..345b8f36f1 100644 --- a/src/tests/servers/app/Jamfile +++ b/src/tests/servers/app/Jamfile @@ -202,6 +202,7 @@ SubInclude HAIKU_TOP src tests servers app benchmark ; SubInclude HAIKU_TOP src tests servers app bitmap_bounds ; SubInclude HAIKU_TOP src tests servers app bitmap_drawing ; SubInclude HAIKU_TOP src tests servers app code_to_name ; +SubInclude HAIKU_TOP src tests servers app clip_to_picture ; SubInclude HAIKU_TOP src tests servers app constrain_clipping_region ; SubInclude HAIKU_TOP src tests servers app copy_bits ; SubInclude HAIKU_TOP src tests servers app cursor_test ; diff --git a/src/tests/servers/app/clip_to_picture/Jamfile b/src/tests/servers/app/clip_to_picture/Jamfile new file mode 100644 index 0000000000..9bc04416a3 --- /dev/null +++ b/src/tests/servers/app/clip_to_picture/Jamfile @@ -0,0 +1,17 @@ +SubDir HAIKU_TOP src tests servers app clip_to_picture ; + +SetSubDirSupportedPlatformsBeOSCompatible ; +AddSubDirSupportedPlatforms libbe_test ; + +UseHeaders [ FDirName os app ] ; +UseHeaders [ FDirName os interface ] ; + +SimpleTest ClipToPicture : + main.cpp + : be $(TARGET_LIBSUPC++) + ; + +if ( $(TARGET_PLATFORM) = libbe_test ) { + HaikuInstall install-test-apps : $(HAIKU_APP_TEST_DIR) : ClipToPicture + : tests!apps ; +} diff --git a/src/tests/servers/app/clip_to_picture/main.cpp b/src/tests/servers/app/clip_to_picture/main.cpp new file mode 100644 index 0000000000..96dc54a8be --- /dev/null +++ b/src/tests/servers/app/clip_to_picture/main.cpp @@ -0,0 +1,76 @@ +#include +#include + +#include +#include +#include +#include +#include + + +static const char* kAppSignature = "application/x.vnd-Haiku.ShapeTest"; + + +class TestView : public BView { +public: + TestView(BRect frame, const char* name, + uint32 resizeFlags, uint32 flags); + void AttachedToWindow(); + + virtual void Draw(BRect updateRect); +}; + + +TestView::TestView(BRect frame, const char* name, uint32 resizeFlags, + uint32 flags) + : + BView(frame, name, resizeFlags, flags) +{ +} + + +void +TestView::AttachedToWindow() +{ + BPicture picture; + + BeginPicture(&picture); + DrawString("Hello World! - Clipping", BPoint(10, 10)); + + FillRect(BRect(0, 20, 400, 40)); + EndPicture(); + + ClipToPicture(&picture); +} + + +void +TestView::Draw(BRect updateRect) +{ + SetHighColor(ui_color(B_MENU_ITEM_TEXT_COLOR)); // opaque black. + DrawString("Hello World! - Clipped", BPoint(10, 30)); + FillRect(BRect(0, 0, 200, 20)); +} + + +// #pragma mark - + + +int +main(int argc, char** argv) +{ + BApplication app(kAppSignature); + + BWindow* window = new BWindow(BRect(50.0, 50.0, 300.0, 250.0), + "ClipToPicture Test", B_TITLED_WINDOW, + B_ASYNCHRONOUS_CONTROLS | B_QUIT_ON_WINDOW_CLOSE); + + BView* view = new TestView(window->Bounds(), "test", B_FOLLOW_ALL, + B_WILL_DRAW); + window->AddChild(view); + + window->Show(); + + app.Run(); + return 0; +}