xref: /haiku/src/tests/apps/terminal_replicant/main.cpp (revision 0562493379cd52eb7103531f895f10bb8e77c085)
1 #include <Application.h>
2 #include <Archivable.h>
3 #include <Box.h>
4 #include <Dragger.h>
5 #include <Message.h>
6 #include <Path.h>
7 #include <Shelf.h>
8 #include <Window.h>
9 
10 #include <stdio.h>
11 
12 #include "TermConst.h"
13 	// for the Terminal's signature
14 
15 class App : public BApplication {
16 public:
17 	App();
18 };
19 
20 
21 class Window : public BWindow {
22 public:
23 	Window();
24 	void AttachTermView();
25 private:
26 	BShelf *fShelf;
27 };
28 
29 
30 int main()
31 {
32 	App app;
33 	app.Run();
34 	return 0;
35 }
36 
37 
38 // App
39 App::App()
40 	:BApplication("application/x-vnd-terminal-replicant")
41 {
42 	Window *window = new Window();
43 	window->Show();
44 }
45 
46 
47 // Window
48 Window::Window()
49 	:BWindow(BRect(100, 100, 400, 360), "RepliTerminal",
50 			B_TITLED_WINDOW, B_ASYNCHRONOUS_CONTROLS|B_QUIT_ON_WINDOW_CLOSE)
51 {
52 	AttachTermView();
53 }
54 
55 
56 void
57 Window::AttachTermView()
58 {
59 	// BMessage containing the class name and the app_signature
60 	// for Terminal and TermView
61 	BMessage message;
62 	message.AddString("class", "TermView");
63 	message.AddString("add_on", TERM_SIGNATURE);
64 
65 	BView *termView = dynamic_cast<BView *>(instantiate_object(&message));
66 
67 	if (termView != NULL) {
68 		termView->SetResizingMode(B_FOLLOW_ALL);
69 		AddChild(termView);
70 
71 		termView->ResizeToPreferred();
72 	}
73 }
74