* Work in progress of using the layout API.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@40122 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -224,7 +224,7 @@ WizardPageView*
|
|||||||
BootManagerController::CreatePage(int32 state, WizardView* wizard)
|
BootManagerController::CreatePage(int32 state, WizardView* wizard)
|
||||||
{
|
{
|
||||||
WizardPageView* page = NULL;
|
WizardPageView* page = NULL;
|
||||||
BRect frame = wizard->PageFrame();
|
BRect frame(0, 0, 300, 300);
|
||||||
|
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case kStateEntry:
|
case kStateEntry:
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
#include <Application.h>
|
#include <Application.h>
|
||||||
#include <Catalog.h>
|
#include <Catalog.h>
|
||||||
|
#include <LayoutBuilder.h>
|
||||||
#include <Roster.h>
|
#include <Roster.h>
|
||||||
#include <Screen.h>
|
#include <Screen.h>
|
||||||
|
|
||||||
@@ -29,16 +30,16 @@
|
|||||||
BootManagerWindow::BootManagerWindow()
|
BootManagerWindow::BootManagerWindow()
|
||||||
:
|
:
|
||||||
BWindow(BRect(100, 100, 500, 400), B_TRANSLATE_COMMENT("BootManager",
|
BWindow(BRect(100, 100, 500, 400), B_TRANSLATE_COMMENT("BootManager",
|
||||||
"Window Title"),
|
"Window Title"), B_TITLED_WINDOW,
|
||||||
B_TITLED_WINDOW,
|
B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE | B_AUTO_UPDATE_SIZE_LIMITS)
|
||||||
B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE)
|
|
||||||
{
|
{
|
||||||
float minWidth, maxWidth, minHeight, maxHeight;
|
float minWidth, maxWidth, minHeight, maxHeight;
|
||||||
GetSizeLimits(&minWidth, &maxWidth, &minHeight, &maxHeight);
|
GetSizeLimits(&minWidth, &maxWidth, &minHeight, &maxHeight);
|
||||||
SetSizeLimits(250, maxWidth, 250, maxHeight);
|
SetSizeLimits(250, maxWidth, 250, maxHeight);
|
||||||
|
|
||||||
fWizardView = new WizardView(Bounds(), "wizard", B_FOLLOW_ALL);
|
fWizardView = new WizardView("wizard");
|
||||||
AddChild(fWizardView);
|
BLayoutBuilder::Group<>(this)
|
||||||
|
.Add(fWizardView);
|
||||||
|
|
||||||
fController.Initialize(fWizardView);
|
fController.Initialize(fWizardView);
|
||||||
|
|
||||||
|
|||||||
@@ -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.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
* Michael Pfeiffer <[email protected]>
|
* Michael Pfeiffer <[email protected]>
|
||||||
|
* Axel Dörfler, [email protected]
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include "WizardView.h"
|
#include "WizardView.h"
|
||||||
|
|
||||||
#include <Box.h>
|
#include <LayoutBuilder.h>
|
||||||
|
#include <Button.h>
|
||||||
#include <Catalog.h>
|
#include <Catalog.h>
|
||||||
|
#include <SeparatorView.h>
|
||||||
|
|
||||||
#include "WizardPageView.h"
|
#include "WizardPageView.h"
|
||||||
|
|
||||||
@@ -19,16 +22,9 @@
|
|||||||
#define B_TRANSLATE_CONTEXT "WizardView"
|
#define B_TRANSLATE_CONTEXT "WizardView"
|
||||||
|
|
||||||
|
|
||||||
static const float kSeparatorHeight = 2;
|
WizardView::WizardView(const char* name)
|
||||||
static const float kSeparatorDistance = 5;
|
|
||||||
static const float kBorderWidth = 10;
|
|
||||||
static const float kBorderHeight = 5;
|
|
||||||
|
|
||||||
|
|
||||||
WizardView::WizardView(BRect frame, const char* name, uint32 resizingMode)
|
|
||||||
:
|
:
|
||||||
BView(frame, name, resizingMode, 0),
|
BGroupView(name, B_VERTICAL),
|
||||||
fSeparator(NULL),
|
|
||||||
fPrevious(NULL),
|
fPrevious(NULL),
|
||||||
fNext(NULL),
|
fNext(NULL),
|
||||||
fPage(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
|
void
|
||||||
WizardView::SetPage(WizardPageView* page)
|
WizardView::SetPage(WizardPageView* page)
|
||||||
{
|
{
|
||||||
@@ -61,7 +46,7 @@ WizardView::SetPage(WizardPageView* page)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
if (fPage != NULL) {
|
if (fPage != NULL) {
|
||||||
RemoveChild(fPage);
|
fPageContainer->RemoveChild(fPage);
|
||||||
delete fPage;
|
delete fPage;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -69,10 +54,7 @@ WizardView::SetPage(WizardPageView* page)
|
|||||||
if (page == NULL)
|
if (page == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
BRect frame = PageFrame();
|
fPageContainer->AddChild(page);
|
||||||
page->MoveTo(frame.left, frame.top);
|
|
||||||
page->ResizeTo(frame.Width()+1, frame.Height()+1);
|
|
||||||
AddChild(page);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -102,19 +84,13 @@ void
|
|||||||
WizardView::SetPreviousButtonLabel(const char* text)
|
WizardView::SetPreviousButtonLabel(const char* text)
|
||||||
{
|
{
|
||||||
fPrevious->SetLabel(text);
|
fPrevious->SetLabel(text);
|
||||||
fPrevious->ResizeToPreferred();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
WizardView::SetNextButtonLabel(const char* text)
|
WizardView::SetNextButtonLabel(const char* text)
|
||||||
{
|
{
|
||||||
BRect frame = fNext->Frame();
|
|
||||||
fNext->SetLabel(text);
|
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
|
void
|
||||||
WizardView::_BuildUI()
|
WizardView::_BuildUI()
|
||||||
{
|
{
|
||||||
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
fPageContainer = new BGroupView("page container");
|
||||||
|
fPageContainer->GroupLayout()->SetInsets(B_USE_DEFAULT_SPACING,
|
||||||
float width = Bounds().Width();
|
B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING);
|
||||||
float height = Bounds().Height();
|
fPrevious = new BButton("previous",
|
||||||
|
|
||||||
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",
|
|
||||||
B_TRANSLATE_COMMENT("Previous", "Button"),
|
B_TRANSLATE_COMMENT("Previous", "Button"),
|
||||||
new BMessage(kMessagePrevious),
|
new BMessage(kMessagePrevious));
|
||||||
B_FOLLOW_LEFT | B_FOLLOW_BOTTOM);
|
fNext = new BButton("next", B_TRANSLATE_COMMENT("Next", "Button"),
|
||||||
AddChild(fPrevious);
|
new BMessage(kMessageNext));
|
||||||
fPrevious->ResizeToPreferred();
|
|
||||||
|
|
||||||
fNext = new BButton(BRect(0, 0, 100, 20), "next",
|
BLayoutBuilder::Group<>(this)
|
||||||
B_TRANSLATE_COMMENT("Next", "Button"),
|
.Add(fPageContainer)
|
||||||
new BMessage(kMessageNext),
|
.Add(new BSeparatorView(B_HORIZONTAL))
|
||||||
B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM);
|
.AddGroup(B_HORIZONTAL)
|
||||||
AddChild(fNext);
|
.SetInsets(B_USE_DEFAULT_SPACING, 0,
|
||||||
fNext->ResizeToPreferred();
|
B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING)
|
||||||
|
.AddGlue()
|
||||||
// layout views
|
.Add(fPrevious)
|
||||||
float buttonHeight = fPrevious->Bounds().Height();
|
.Add(fNext)
|
||||||
float buttonTop = height - 1 - buttonHeight - kBorderHeight;
|
.End()
|
||||||
fPrevious->MoveTo(kBorderWidth, buttonTop);
|
.End();
|
||||||
|
|
||||||
fSeparator->MoveTo(kBorderWidth,
|
|
||||||
buttonTop - kSeparatorDistance - kSeparatorHeight);
|
|
||||||
|
|
||||||
fNext->MoveTo(width - fNext->Bounds().Width() - kBorderWidth - 1,
|
|
||||||
buttonTop);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,12 +9,10 @@
|
|||||||
#define WIZARD_VIEW_H
|
#define WIZARD_VIEW_H
|
||||||
|
|
||||||
|
|
||||||
#include <Box.h>
|
#include <GroupView.h>
|
||||||
#include <Button.h>
|
|
||||||
#include <View.h>
|
|
||||||
|
|
||||||
|
|
||||||
class BTextView;
|
class BButton;
|
||||||
class WizardPageView;
|
class WizardPageView;
|
||||||
|
|
||||||
|
|
||||||
@@ -22,14 +20,11 @@ const uint32 kMessageNext = 'next';
|
|||||||
const uint32 kMessagePrevious = 'prev';
|
const uint32 kMessagePrevious = 'prev';
|
||||||
|
|
||||||
|
|
||||||
class WizardView : public BView {
|
class WizardView : public BGroupView {
|
||||||
public:
|
public:
|
||||||
WizardView(BRect frame, const char* name,
|
WizardView(const char* name);
|
||||||
uint32 resizingMode);
|
|
||||||
virtual ~WizardView();
|
virtual ~WizardView();
|
||||||
|
|
||||||
virtual BRect PageFrame();
|
|
||||||
|
|
||||||
virtual void SetPage(WizardPageView* page);
|
virtual void SetPage(WizardPageView* page);
|
||||||
|
|
||||||
virtual void PageCompleted();
|
virtual void PageCompleted();
|
||||||
@@ -44,7 +39,7 @@ private:
|
|||||||
void _BuildUI();
|
void _BuildUI();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BBox* fSeparator;
|
BGroupView* fPageContainer;
|
||||||
BButton* fPrevious;
|
BButton* fPrevious;
|
||||||
BButton* fNext;
|
BButton* fNext;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user