xref: /haiku/src/apps/bootmanager/BootManagerWindow.cpp (revision e1c4049fed1047bdb957b0529e1921e97ef94770)
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 <ControlLook.h>
15 #include <LayoutBuilder.h>
16 #include <Roster.h>
17 #include <Screen.h>
18 
19 #include <tracker_private.h>
20 
21 #include "DefaultPartitionPage.h"
22 #include "PartitionsPage.h"
23 #include "WizardView.h"
24 
25 
26 #undef B_TRANSLATION_CONTEXT
27 #define B_TRANSLATION_CONTEXT "BootManagerWindow"
28 
29 
30 BootManagerWindow::BootManagerWindow()
31 	:
32 	BWindow(BRect(100, 100, 500, 400), B_TRANSLATE_SYSTEM_NAME("BootManager"),
33 		B_TITLED_WINDOW, B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE)
34 {
35 	float minWidth, maxWidth, minHeight, maxHeight;
36 	GetSizeLimits(&minWidth, &maxWidth, &minHeight, &maxHeight);
37 
38 	minWidth = be_control_look->DefaultLabelSpacing() * 67.0f;
39 	minHeight = be_control_look->DefaultLabelSpacing() * 52.0f;
40 	SetSizeLimits(minWidth, maxWidth, minHeight, maxHeight);
41 
42 	fWizardView = new WizardView("wizard");
43 	BLayoutBuilder::Group<>(this)
44 		.Add(fWizardView);
45 
46 	fController.Initialize(fWizardView);
47 	CenterOnScreen();
48 
49 	// Prevent minimizing this window if the user would have no way to
50 	// get back to it. (For example when only the Installer runs.)
51 	if (!be_roster->IsRunning(kDeskbarSignature))
52 		SetFlags(Flags() | B_NOT_MINIMIZABLE);
53 }
54 
55 
56 BootManagerWindow::~BootManagerWindow()
57 {
58 }
59 
60 
61 void
62 BootManagerWindow::MessageReceived(BMessage* msg)
63 {
64 	switch (msg->what) {
65 		case kMessageNext:
66 			fController.Next(fWizardView);
67 			break;
68 
69 		case kMessagePrevious:
70 			fController.Previous(fWizardView);
71 			break;
72 
73 		default:
74 			BWindow::MessageReceived(msg);
75 	}
76 }
77 
78 
79 bool
80 BootManagerWindow::QuitRequested()
81 {
82 	be_app->PostMessage(B_QUIT_REQUESTED);
83 	return true;
84 }
85 
86