2 * Copyright 2005-2009, Haiku Inc.
3 * Distributed under the terms of the MIT License.
6 * Axel Dörfler, axeld@pinc-software.de
12 #include <Application.h>
13 #include <MessageRunner.h>
18 static const uint32 kMsgToggleShow
= 'tgsh';
20 class Window
: public BWindow
{
25 virtual void MessageReceived(BMessage
* message
);
26 virtual void FrameResized(float width
, float height
);
27 virtual bool QuitRequested();
30 BMessageRunner
* fRunner
;
35 : BWindow(BRect(100, 100, 400, 400), "HideAndShow-Test",
36 B_TITLED_WINDOW
, B_ASYNCHRONOUS_CONTROLS
)
43 BTextView
* view
= new BTextView(Bounds(), "", rect
, B_FOLLOW_ALL
,
44 B_FRAME_EVENTS
| B_WILL_DRAW
);
45 view
->MakeEditable(false);
46 view
->SetAlignment(B_ALIGN_CENTER
);
47 view
->SetViewUIColor(B_PANEL_BACKGROUND_COLOR
);
48 view
->SetText("The window will be hidden and shown every 2 seconds.");
51 BMessage
showAndHide(kMsgToggleShow
);
52 fRunner
= new BMessageRunner(this, &showAndHide
, 2000000);
62 Window::MessageReceived(BMessage
* message
)
64 switch (message
->what
) {
73 BWindow::MessageReceived(message
);
80 Window::FrameResized(float width
, float height
)
82 BTextView
* view
= dynamic_cast<BTextView
*>(ChildAt(0));
86 BRect rect
= Bounds();
91 view
->SetTextRect(rect
);
96 Window::QuitRequested()
98 be_app
->PostMessage(B_QUIT_REQUESTED
);
106 class Application
: public BApplication
{
110 virtual void ReadyToRun();
114 Application::Application()
115 : BApplication("application/x-vnd.haiku-hide_and_show")
121 Application::ReadyToRun(void)
123 Window
* window
= new Window();
132 main(int argc
, char** argv
)