diff --git a/src/apps/bootmanager/BootManagerController.cpp b/src/apps/bootmanager/BootManagerController.cpp index 8e395f81a5..4501f418a9 100644 --- a/src/apps/bootmanager/BootManagerController.cpp +++ b/src/apps/bootmanager/BootManagerController.cpp @@ -224,7 +224,7 @@ WizardPageView* BootManagerController::CreatePage(int32 state, WizardView* wizard) { WizardPageView* page = NULL; - BRect frame = wizard->PageFrame(); + BRect frame(0, 0, 300, 300); switch (state) { case kStateEntry: diff --git a/src/apps/bootmanager/BootManagerWindow.cpp b/src/apps/bootmanager/BootManagerWindow.cpp index 45bb91c1cc..9661866da1 100644 --- a/src/apps/bootmanager/BootManagerWindow.cpp +++ b/src/apps/bootmanager/BootManagerWindow.cpp @@ -11,6 +11,7 @@ #include #include +#include #include #include @@ -29,16 +30,16 @@ BootManagerWindow::BootManagerWindow() : BWindow(BRect(100, 100, 500, 400), B_TRANSLATE_COMMENT("BootManager", - "Window Title"), - B_TITLED_WINDOW, - B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE) + "Window Title"), B_TITLED_WINDOW, + B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE | B_AUTO_UPDATE_SIZE_LIMITS) { float minWidth, maxWidth, minHeight, maxHeight; GetSizeLimits(&minWidth, &maxWidth, &minHeight, &maxHeight); SetSizeLimits(250, maxWidth, 250, maxHeight); - fWizardView = new WizardView(Bounds(), "wizard", B_FOLLOW_ALL); - AddChild(fWizardView); + fWizardView = new WizardView("wizard"); + BLayoutBuilder::Group<>(this) + .Add(fWizardView); fController.Initialize(fWizardView); diff --git a/src/apps/bootmanager/WizardView.cpp b/src/apps/bootmanager/WizardView.cpp index b2d40a2076..cd3f901eb4 100644 --- a/src/apps/bootmanager/WizardView.cpp +++ b/src/apps/bootmanager/WizardView.cpp @@ -1,16 +1,19 @@ /* - * Copyright 2008-2010, Haiku, Inc. All rights reserved. + * Copyright 2008-2011, Haiku, Inc. All rights reserved. * Distributed under the terms of the MIT License. * * Authors: * Michael Pfeiffer + * Axel Dörfler, axeld@pinc-software.de */ #include "WizardView.h" -#include +#include +#include #include +#include #include "WizardPageView.h" @@ -19,16 +22,9 @@ #define B_TRANSLATE_CONTEXT "WizardView" -static const float kSeparatorHeight = 2; -static const float kSeparatorDistance = 5; -static const float kBorderWidth = 10; -static const float kBorderHeight = 5; - - -WizardView::WizardView(BRect frame, const char* name, uint32 resizingMode) +WizardView::WizardView(const char* name) : - BView(frame, name, resizingMode, 0), - fSeparator(NULL), + BGroupView(name, B_VERTICAL), fPrevious(NULL), fNext(NULL), fPage(NULL) @@ -43,17 +39,6 @@ WizardView::~WizardView() } -BRect -WizardView::PageFrame() -{ - float left = kBorderWidth; - float right = Bounds().right - kBorderWidth; - float top = kBorderHeight; - float bottom = fSeparator->Frame().top - kSeparatorDistance - 1; - return BRect(left, top, right, bottom); -} - - void WizardView::SetPage(WizardPageView* page) { @@ -61,7 +46,7 @@ WizardView::SetPage(WizardPageView* page) return; if (fPage != NULL) { - RemoveChild(fPage); + fPageContainer->RemoveChild(fPage); delete fPage; } @@ -69,10 +54,7 @@ WizardView::SetPage(WizardPageView* page) if (page == NULL) return; - BRect frame = PageFrame(); - page->MoveTo(frame.left, frame.top); - page->ResizeTo(frame.Width()+1, frame.Height()+1); - AddChild(page); + fPageContainer->AddChild(page); } @@ -102,19 +84,13 @@ void WizardView::SetPreviousButtonLabel(const char* text) { fPrevious->SetLabel(text); - fPrevious->ResizeToPreferred(); } void WizardView::SetNextButtonLabel(const char* text) { - BRect frame = fNext->Frame(); fNext->SetLabel(text); - fNext->ResizeToPreferred(); - BRect newFrame = fNext->Frame(); - fNext->MoveBy(frame.Width() - newFrame.Width(), - frame.Height() - newFrame.Height()); } @@ -134,39 +110,24 @@ WizardView::SetPreviousButtonHidden(bool hide) void WizardView::_BuildUI() { - SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); - - float width = Bounds().Width(); - float height = Bounds().Height(); - - fSeparator = new BBox(BRect(kBorderWidth, 0, - width - 1 - kBorderWidth, kSeparatorHeight - 1), - "separator", - B_FOLLOW_LEFT_RIGHT | B_FOLLOW_BOTTOM); - AddChild(fSeparator); - - fPrevious = new BButton(BRect(0, 0, 100, 20), "previous", + fPageContainer = new BGroupView("page container"); + fPageContainer->GroupLayout()->SetInsets(B_USE_DEFAULT_SPACING, + B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING); + fPrevious = new BButton("previous", B_TRANSLATE_COMMENT("Previous", "Button"), - new BMessage(kMessagePrevious), - B_FOLLOW_LEFT | B_FOLLOW_BOTTOM); - AddChild(fPrevious); - fPrevious->ResizeToPreferred(); + new BMessage(kMessagePrevious)); + fNext = new BButton("next", B_TRANSLATE_COMMENT("Next", "Button"), + new BMessage(kMessageNext)); - fNext = new BButton(BRect(0, 0, 100, 20), "next", - B_TRANSLATE_COMMENT("Next", "Button"), - new BMessage(kMessageNext), - B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM); - AddChild(fNext); - fNext->ResizeToPreferred(); - - // layout views - float buttonHeight = fPrevious->Bounds().Height(); - float buttonTop = height - 1 - buttonHeight - kBorderHeight; - fPrevious->MoveTo(kBorderWidth, buttonTop); - - fSeparator->MoveTo(kBorderWidth, - buttonTop - kSeparatorDistance - kSeparatorHeight); - - fNext->MoveTo(width - fNext->Bounds().Width() - kBorderWidth - 1, - buttonTop); + BLayoutBuilder::Group<>(this) + .Add(fPageContainer) + .Add(new BSeparatorView(B_HORIZONTAL)) + .AddGroup(B_HORIZONTAL) + .SetInsets(B_USE_DEFAULT_SPACING, 0, + B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING) + .AddGlue() + .Add(fPrevious) + .Add(fNext) + .End() + .End(); } diff --git a/src/apps/bootmanager/WizardView.h b/src/apps/bootmanager/WizardView.h index 2525268184..7a58b8c944 100644 --- a/src/apps/bootmanager/WizardView.h +++ b/src/apps/bootmanager/WizardView.h @@ -9,12 +9,10 @@ #define WIZARD_VIEW_H -#include -#include -#include +#include -class BTextView; +class BButton; class WizardPageView; @@ -22,14 +20,11 @@ const uint32 kMessageNext = 'next'; const uint32 kMessagePrevious = 'prev'; -class WizardView : public BView { +class WizardView : public BGroupView { public: - WizardView(BRect frame, const char* name, - uint32 resizingMode); + WizardView(const char* name); virtual ~WizardView(); - virtual BRect PageFrame(); - virtual void SetPage(WizardPageView* page); virtual void PageCompleted(); @@ -44,7 +39,7 @@ private: void _BuildUI(); private: - BBox* fSeparator; + BGroupView* fPageContainer; BButton* fPrevious; BButton* fNext;