xref: /haiku/src/apps/bootmanager/BootManagerWindow.cpp (revision 11c7ff531a01b64773d8a8f0e02c1c7c9f27ca29)
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_TRANSLATE_CONTEXT
26 #define B_TRANSLATE_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 	SetSizeLimits(250, maxWidth, 250, maxHeight);
38 
39 	fWizardView = new WizardView("wizard");
40 	BLayoutBuilder::Group<>(this)
41 		.Add(fWizardView);
42 
43 	fController.Initialize(fWizardView);
44 
45 	CenterOnScreen();
46 
47 	// Prevent minimizing this window if the user would have no way to
48 	// get back to it. (For example when only the Installer runs.)
49 	if (!be_roster->IsRunning(kDeskbarSignature))
50 		SetFlags(Flags() | B_NOT_MINIMIZABLE);
51 }
52 
53 
54 BootManagerWindow::~BootManagerWindow()
55 {
56 }
57 
58 
59 void
60 BootManagerWindow::MessageReceived(BMessage* msg)
61 {
62 	switch (msg->what) {
63 		case kMessageNext:
64 			fController.Next(fWizardView);
65 			break;
66 
67 		case kMessagePrevious:
68 			fController.Previous(fWizardView);
69 			break;
70 
71 		default:
72 			BWindow::MessageReceived(msg);
73 	}
74 }
75 
76 
77 bool
78 BootManagerWindow::QuitRequested()
79 {
80 	be_app->PostMessage(B_QUIT_REQUESTED);
81 	return true;
82 }
83 
84