2 * Copyright 2008-2011, Haiku, Inc. All rights reserved.
3 * Distributed under the terms of the MIT License.
6 * Michael Pfeiffer <laplace@users.sourceforge.net>
7 * Axel Dörfler, axeld@pinc-software.de
11 #include "WizardView.h"
13 #include <LayoutBuilder.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),
33 SetPreviousButtonHidden(true);
37 WizardView::~WizardView()
43 WizardView::SetPage(WizardPageView
* page
)
49 fPageContainer
->RemoveChild(fPage
);
57 fPageContainer
->AddChild(page
);
62 WizardView::PageCompleted()
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);
77 WizardView::SetPreviousButtonEnabled(bool enabled
)
79 fPrevious
->SetEnabled(enabled
);
84 WizardView::SetNextButtonEnabled(bool enabled
)
86 fNext
->SetEnabled(enabled
);
91 WizardView::SetPreviousButtonLabel(const char* text
)
93 fPrevious
->SetLabel(text
);
98 WizardView::SetNextButtonLabel(const char* text
)
100 fNext
->SetLabel(text
);
105 WizardView::SetPreviousButtonHidden(bool hide
)
108 if (!fPrevious
->IsHidden())
111 if (fPrevious
->IsHidden())
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)
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
)