xref: /haiku/src/tests/servers/app/desktop_window/DesktopWindow.cpp (revision e81a954787e50e56a7f06f72705b7859b6ab06d1)
1 /*
2  * Copyright 2005, Haiku Inc.
3  * Distributed under the terms of the MIT License.
4  *
5  * Authors:
6  *		Axel Dörfler, axeld@pinc-software.de
7  */
8 
9 
10 #include <Application.h>
11 #include <Window.h>
12 #include <View.h>
13 
14 #include <WindowPrivate.h>
15 
16 #include <stdio.h>
17 
18 
19 class View : public BView {
20 	public:
21 		View(BRect rect);
22 		virtual ~View();
23 
24 		virtual void Draw(BRect updateRect);
25 };
26 
27 
28 View::View(BRect rect)
29 	: BView(rect, "desktop view", B_FOLLOW_ALL, B_WILL_DRAW)
30 {
31 	SetViewColor(100, 100, 100);
32 	SetHighColor(0, 0, 0);
33 	SetLowColor(ViewColor());
34 }
35 
36 
37 View::~View()
38 {
39 }
40 
41 
42 void
43 View::Draw(BRect updateRect)
44 {
45 	MovePenTo(20, 30);
46 	DrawString("Desktop Window");
47 }
48 
49 
50 //	#pragma mark -
51 
52 
53 class Window : public BWindow {
54 	public:
55 		Window();
56 		virtual ~Window();
57 
58 		virtual bool QuitRequested();
59 };
60 
61 
62 Window::Window()
63 	: BWindow(BRect(100, 100, 400, 400), "DesktopWindow-Test",
64 			(window_look)kDesktopWindowLook, (window_feel)kDesktopWindowFeel,
65 			B_ASYNCHRONOUS_CONTROLS)
66 {
67 	BView *view = new View(Bounds());
68 	AddChild(view);
69 }
70 
71 
72 Window::~Window()
73 {
74 }
75 
76 
77 bool
78 Window::QuitRequested()
79 {
80 	be_app->PostMessage(B_QUIT_REQUESTED);
81 	return true;
82 }
83 
84 
85 //	#pragma mark -
86 
87 
88 class Application : public BApplication {
89 	public:
90 		Application();
91 
92 		virtual void ReadyToRun();
93 };
94 
95 
96 Application::Application()
97 	: BApplication("application/x-vnd.haiku-desktop_window")
98 {
99 }
100 
101 
102 void
103 Application::ReadyToRun()
104 {
105 	Window *window = new Window();
106 	window->Show();
107 }
108 
109 
110 //	#pragma mark -
111 
112 
113 int
114 main(int argc, char **argv)
115 {
116 	Application app;// app;
117 
118 	app.Run();
119 	return 0;
120 }
121