btrfs: Attempt to fix GCC2 build.
[haiku.git] / src / apps / bootmanager / WizardView.cpp
blobd565f7e22646f6562fff8a7eaa106f2c65b42156
1 /*
2 * Copyright 2008-2011, Haiku, Inc. All rights reserved.
3 * Distributed under the terms of the MIT License.
5 * Authors:
6 * Michael Pfeiffer <laplace@users.sourceforge.net>
7 * Axel Dörfler, axeld@pinc-software.de
8 */
11 #include "WizardView.h"
13 #include <LayoutBuilder.h>
14 #include <Button.h>
15 #include <Catalog.h>
16 #include <SeparatorView.h>
18 #include "WizardPageView.h"
21 #undef B_TRANSLATION_CONTEXT
22 #define B_TRANSLATION_CONTEXT "WizardView"
25 WizardView::WizardView(const char* name)
27 BGroupView(name, B_VERTICAL, 0),
28 fPrevious(NULL),
29 fNext(NULL),
30 fPage(NULL)
32 _BuildUI();
33 SetPreviousButtonHidden(true);
37 WizardView::~WizardView()
42 void
43 WizardView::SetPage(WizardPageView* page)
45 if (fPage == page)
46 return;
48 if (fPage != NULL) {
49 fPageContainer->RemoveChild(fPage);
50 delete fPage;
53 fPage = page;
54 if (page == NULL)
55 return;
57 fPageContainer->AddChild(page);
61 void
62 WizardView::PageCompleted()
64 if (fPage != NULL)
65 fPage->PageCompleted();
67 // Restore initial state
68 SetNextButtonLabel(B_TRANSLATE_COMMENT("Next", "Button"));
69 SetPreviousButtonLabel(B_TRANSLATE_COMMENT("Previous", "Button"));
70 SetNextButtonEnabled(true);
71 SetPreviousButtonEnabled(true);
72 SetPreviousButtonHidden(false);
76 void
77 WizardView::SetPreviousButtonEnabled(bool enabled)
79 fPrevious->SetEnabled(enabled);
83 void
84 WizardView::SetNextButtonEnabled(bool enabled)
86 fNext->SetEnabled(enabled);
90 void
91 WizardView::SetPreviousButtonLabel(const char* text)
93 fPrevious->SetLabel(text);
97 void
98 WizardView::SetNextButtonLabel(const char* text)
100 fNext->SetLabel(text);
104 void
105 WizardView::SetPreviousButtonHidden(bool hide)
107 if (hide) {
108 if (!fPrevious->IsHidden())
109 fPrevious->Hide();
110 } else {
111 if (fPrevious->IsHidden())
112 fPrevious->Show();
117 void
118 WizardView::_BuildUI()
120 fPageContainer = new BGroupView("page container");
121 fPageContainer->GroupLayout()->SetInsets(B_USE_WINDOW_SPACING,
122 B_USE_WINDOW_SPACING, B_USE_WINDOW_SPACING, B_USE_DEFAULT_SPACING);
123 fPrevious = new BButton("previous",
124 B_TRANSLATE_COMMENT("Previous", "Button"),
125 new BMessage(kMessagePrevious));
126 fNext = new BButton("next", B_TRANSLATE_COMMENT("Next", "Button"),
127 new BMessage(kMessageNext));
128 BButton* quit = new BButton("quit", B_TRANSLATE_COMMENT("Quit", "Button"),
129 new BMessage(B_QUIT_REQUESTED));
131 BLayoutBuilder::Group<>(this)
132 .Add(fPageContainer)
133 .Add(new BSeparatorView(B_HORIZONTAL))
134 .AddGroup(B_HORIZONTAL)
135 .SetInsets(B_USE_WINDOW_SPACING, B_USE_DEFAULT_SPACING,
136 B_USE_WINDOW_SPACING, B_USE_WINDOW_SPACING)
137 .Add(quit)
138 .AddGlue()
139 .Add(fPrevious)
140 .Add(fNext)
141 .End()
142 .End();