From b1456ac9159a1a680c0746f35fd4eed788424537 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20A=C3=9Fmus?= Date: Sat, 26 Mar 2005 22:00:50 +0000 Subject: [PATCH] the BViews in the test windows draw something git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@12044 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/tests/servers/app/windows/main.cpp | 28 +++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/src/tests/servers/app/windows/main.cpp b/src/tests/servers/app/windows/main.cpp index 78a4683963..b5b3826294 100644 --- a/src/tests/servers/app/windows/main.cpp +++ b/src/tests/servers/app/windows/main.cpp @@ -6,6 +6,31 @@ #include "View.h" #include "Window.h" +class HelloView : public BView { + public: + HelloView(BRect frame, const char* name, + uint32 resizeFlags, uint32 flags) + : BView(frame, name, resizeFlags, flags) + { } + + virtual void Draw(BRect updateRect) + { + SetHighColor(ui_color(B_PANEL_BACKGROUND_COLOR)); + FillRect(updateRect); + BRect r(Bounds()); + + const char* message = "Hello World!"; + float width = StringWidth(message); + BPoint p(r.left + r.Width() / 2.0 - width / 2.0, + r.top + r.Height() / 2.0); + + SetHighColor(255, 0, 0, 128); + DrawString(message, p); + } +}; + + +// show_window void show_window(BRect frame, const char* name) { @@ -13,7 +38,8 @@ show_window(BRect frame, const char* name) B_TITLED_WINDOW, B_ASYNCHRONOUS_CONTROLS | B_QUIT_ON_WINDOW_CLOSE); - BView* view = new BView(window->Bounds(), "test", B_FOLLOW_ALL, B_WILL_DRAW); + BView* view = new HelloView(window->Bounds(), "test", B_FOLLOW_ALL, + B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE); window->AddChild(view);