xref: /haiku/src/apps/bootmanager/BootManagerWindow.cpp (revision 3af8011358bd4c624a0979336d48dabb466171ed)
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() * 42.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 
48 	CenterOnScreen();
49 
50 	// Prevent minimizing this window if the user would have no way to
51 	// get back to it. (For example when only the Installer runs.)
52 	if (!be_roster->IsRunning(kDeskbarSignature))
53 		SetFlags(Flags() | B_NOT_MINIMIZABLE);
54 }
55 
56 
57 BootManagerWindow::~BootManagerWindow()
58 {
59 }
60 
61 
62 void
63 BootManagerWindow::MessageReceived(BMessage* msg)
64 {
65 	switch (msg->what) {
66 		case kMessageNext:
67 			fController.Next(fWizardView);
68 			break;
69 
70 		case kMessagePrevious:
71 			fController.Previous(fWizardView);
72 			break;
73 
74 		default:
75 			BWindow::MessageReceived(msg);
76 	}
77 }
78 
79 
80 bool
81 BootManagerWindow::QuitRequested()
82 {
83 	be_app->PostMessage(B_QUIT_REQUESTED);
84 	return true;
85 }
86 
87