xref: /haiku/src/apps/bootmanager/BootManagerWindow.cpp (revision cbe0a0c436162d78cc3f92a305b64918c839d079)
1 /*
2  * Copyright 2008-2010, Haiku, Inc. All rights reserved.
3  * Distributed under the terms of the MIT License.
4  *
5  * Authors:
6  *		Michael Pfeiffer <laplace@users.sourceforge.net>
7  */
8 
9 
10 #include "BootManagerWindow.h"
11 
12 #include <Application.h>
13 #include <Catalog.h>
14 #include <LayoutBuilder.h>
15 #include <Roster.h>
16 #include <Screen.h>
17 
18 #include <tracker_private.h>
19 
20 #include "DefaultPartitionPage.h"
21 #include "PartitionsPage.h"
22 #include "WizardView.h"
23 
24 
25 #undef B_TRANSLATION_CONTEXT
26 #define B_TRANSLATION_CONTEXT "BootManagerWindow"
27 
28 
29 BootManagerWindow::BootManagerWindow()
30 	:
31 	BWindow(BRect(100, 100, 500, 400), B_TRANSLATE_SYSTEM_NAME("BootManager"),
32 		B_TITLED_WINDOW, B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE
33 		| B_AUTO_UPDATE_SIZE_LIMITS)
34 {
35 	float minWidth, maxWidth, minHeight, maxHeight;
36 	GetSizeLimits(&minWidth, &maxWidth, &minHeight, &maxHeight);
37 
38 	// Use font to determine necessary size of window:
39 	const BFont* font = be_plain_font;
40 	minWidth = 400 * (double)font->Size() / 12.0f;
41 	minHeight = 250 * (double)font->Size() / 12.0f;
42 
43 	SetSizeLimits(minWidth, maxWidth, minHeight, maxHeight);
44 
45 	fWizardView = new WizardView("wizard");
46 	BLayoutBuilder::Group<>(this)
47 		.Add(fWizardView);
48 
49 	fController.Initialize(fWizardView);
50 
51 	CenterOnScreen();
52 
53 	// Prevent minimizing this window if the user would have no way to
54 	// get back to it. (For example when only the Installer runs.)
55 	if (!be_roster->IsRunning(kDeskbarSignature))
56 		SetFlags(Flags() | B_NOT_MINIMIZABLE);
57 }
58 
59 
60 BootManagerWindow::~BootManagerWindow()
61 {
62 }
63 
64 
65 void
66 BootManagerWindow::MessageReceived(BMessage* msg)
67 {
68 	switch (msg->what) {
69 		case kMessageNext:
70 			fController.Next(fWizardView);
71 			break;
72 
73 		case kMessagePrevious:
74 			fController.Previous(fWizardView);
75 			break;
76 
77 		default:
78 			BWindow::MessageReceived(msg);
79 	}
80 }
81 
82 
83 bool
84 BootManagerWindow::QuitRequested()
85 {
86 	be_app->PostMessage(B_QUIT_REQUESTED);
87 	return true;
88 }
89 
90