the BViews in the test windows draw something

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@12044 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stephan Aßmus
2005-03-26 22:00:50 +00:00
parent ffc01863ba
commit b1456ac915
+27 -1
View File
@@ -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);