* Cleanup.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@40113 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
0341cc7868
commit
5b788d58b7
@ -1,18 +1,19 @@
|
||||
/*
|
||||
* Copyright 2008, Haiku, Inc. All rights reserved.
|
||||
* Copyright 2008-2010, Haiku, Inc. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
*
|
||||
* Authors:
|
||||
* Michael Pfeiffer <laplace@users.sourceforge.net>
|
||||
*/
|
||||
#ifndef BOOT_DRIVE_H
|
||||
#define BOOT_DRIVE_H
|
||||
|
||||
|
||||
#include <File.h>
|
||||
#include <Message.h>
|
||||
|
||||
/*
|
||||
Setting BMessage Format:
|
||||
|
||||
/* Setting BMessage Format:
|
||||
|
||||
"disk" String (path to boot disk)
|
||||
|
||||
@ -22,27 +23,33 @@
|
||||
"type" String (short name of file system: bfs, dos)
|
||||
"path" String (path to partition in /dev/...)
|
||||
"size" long (size of partition in bytes)
|
||||
*/
|
||||
*/
|
||||
|
||||
|
||||
enum {
|
||||
// Not enough space free before first partition for boot loader
|
||||
kErrorBootSectorTooSmall = B_ERRORS_END + 1,
|
||||
};
|
||||
|
||||
class BootDrive
|
||||
{
|
||||
public:
|
||||
BootDrive() {}
|
||||
virtual ~BootDrive() {}
|
||||
|
||||
virtual bool IsBootMenuInstalled(BMessage* settings) = 0;
|
||||
virtual status_t ReadPartitions(BMessage* settings) = 0;
|
||||
virtual status_t WriteBootMenu(BMessage* settings) = 0;
|
||||
virtual status_t SaveMasterBootRecord(BMessage* settings, BFile* file) = 0;
|
||||
virtual status_t RestoreMasterBootRecord(BMessage* settings, BFile* file) = 0;
|
||||
class BootDrive {
|
||||
public:
|
||||
BootDrive() {}
|
||||
virtual ~BootDrive() {}
|
||||
|
||||
virtual bool IsBootMenuInstalled(BMessage* settings) = 0;
|
||||
virtual status_t ReadPartitions(BMessage* settings) = 0;
|
||||
virtual status_t WriteBootMenu(BMessage* settings) = 0;
|
||||
virtual status_t SaveMasterBootRecord(BMessage* settings,
|
||||
BFile* file) = 0;
|
||||
virtual status_t RestoreMasterBootRecord(BMessage* settings,
|
||||
BFile* file) = 0;
|
||||
|
||||
// Converts the specified text into a text as it will be shown
|
||||
// in the boot menu.
|
||||
virtual status_t GetDisplayText(const char* text, BString& displayText) = 0;
|
||||
virtual status_t GetDisplayText(const char* text,
|
||||
BString& displayText) = 0;
|
||||
};
|
||||
|
||||
|
||||
#endif // BOOT_DRIVE_H
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008, Haiku, Inc. All rights reserved.
|
||||
* Copyright 2008-2010, Haiku, Inc. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
@ -9,28 +9,23 @@
|
||||
|
||||
#include "BootManagerWindow.h"
|
||||
|
||||
#include "WizardView.h"
|
||||
|
||||
#include "EntryPage.h"
|
||||
#include "PartitionsPage.h"
|
||||
#include "DefaultPartitionPage.h"
|
||||
|
||||
#include <Application.h>
|
||||
#include <Catalog.h>
|
||||
#include <Locale.h>
|
||||
#include <Roster.h>
|
||||
#include <Screen.h>
|
||||
|
||||
#include <math.h>
|
||||
#include <tracker_private.h>
|
||||
|
||||
#include "tracker_private.h"
|
||||
#include "DefaultPartitionPage.h"
|
||||
#include "EntryPage.h"
|
||||
#include "PartitionsPage.h"
|
||||
#include "WizardView.h"
|
||||
|
||||
|
||||
#undef B_TRANSLATE_CONTEXT
|
||||
#define B_TRANSLATE_CONTEXT "BootManagerWindow"
|
||||
|
||||
|
||||
|
||||
BootManagerWindow::BootManagerWindow()
|
||||
:
|
||||
BWindow(BRect(100, 100, 500, 400), B_TRANSLATE_COMMENT("BootManager",
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008, Haiku, Inc. All rights reserved.
|
||||
* Copyright 2008-2010, Haiku, Inc. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
@ -39,13 +39,12 @@ enum {
|
||||
const int32 kTimeoutIndefinitely = -1;
|
||||
const int32 kDefaultTimeout = kTimeoutIndefinitely;
|
||||
|
||||
typedef struct {
|
||||
struct TimeoutOption {
|
||||
int32 timeout;
|
||||
const char* label;
|
||||
} TimeoutOption;
|
||||
};
|
||||
|
||||
static const TimeoutOption gTimeoutOptions[] =
|
||||
{
|
||||
static const TimeoutOption gTimeoutOptions[] = {
|
||||
{ 0, B_TRANSLATE_MARK("Immediately")},
|
||||
{ 1, B_TRANSLATE_MARK("After one second")},
|
||||
{ 2, B_TRANSLATE_MARK("After two seconds")},
|
||||
@ -95,8 +94,13 @@ get_label_for_timeout(int32 timeout)
|
||||
}
|
||||
|
||||
|
||||
DefaultPartitionPage::DefaultPartitionPage(BMessage* settings, BRect frame, const char* name)
|
||||
: WizardPageView(settings, frame, name, B_FOLLOW_ALL,
|
||||
// #pragma mark -
|
||||
|
||||
|
||||
DefaultPartitionPage::DefaultPartitionPage(BMessage* settings, BRect frame,
|
||||
const char* name)
|
||||
:
|
||||
WizardPageView(settings, frame, name, B_FOLLOW_ALL,
|
||||
B_WILL_DRAW | B_FRAME_EVENTS | B_FULL_UPDATE_ON_RESIZE)
|
||||
{
|
||||
_BuildUI();
|
||||
@ -129,34 +133,34 @@ DefaultPartitionPage::MessageReceived(BMessage* msg)
|
||||
{
|
||||
switch (msg->what) {
|
||||
case kMsgPartition:
|
||||
{
|
||||
int32 index;
|
||||
msg->FindInt32("index", &index);
|
||||
fSettings->ReplaceInt32("defaultPartition", index);
|
||||
}
|
||||
{
|
||||
int32 index;
|
||||
msg->FindInt32("index", &index);
|
||||
fSettings->ReplaceInt32("defaultPartition", index);
|
||||
break;
|
||||
}
|
||||
case kMsgTimeout:
|
||||
{
|
||||
int32 sliderValue = fTimeoutSlider->Value();
|
||||
int32 timeout = get_timeout_for_index(sliderValue);
|
||||
fSettings->ReplaceInt32("timeout", timeout);
|
||||
{
|
||||
int32 sliderValue = fTimeoutSlider->Value();
|
||||
int32 timeout = get_timeout_for_index(sliderValue);
|
||||
fSettings->ReplaceInt32("timeout", timeout);
|
||||
|
||||
BString label;
|
||||
_GetTimeoutLabel(timeout, label);
|
||||
fTimeoutSlider->SetLabel(label.String());
|
||||
}
|
||||
BString label;
|
||||
_GetTimeoutLabel(timeout, label);
|
||||
fTimeoutSlider->SetLabel(label.String());
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
WizardPageView::MessageReceived(msg);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#define kTextDistance be_control_look->DefaultItemSpacing();
|
||||
|
||||
void
|
||||
DefaultPartitionPage::_BuildUI()
|
||||
{
|
||||
const float kTextDistance = be_control_look->DefaultItemSpacing();
|
||||
BRect rect(Bounds());
|
||||
|
||||
BString text;
|
||||
@ -223,8 +227,7 @@ DefaultPartitionPage::_CreatePopUpMenu()
|
||||
"Pop up menu title"));
|
||||
BMessage message;
|
||||
for (int32 i = 0; fSettings->FindMessage("partition", i, &message) == B_OK;
|
||||
i ++) {
|
||||
|
||||
i++) {
|
||||
bool show;
|
||||
if (message.FindBool("show", &show) != B_OK || !show)
|
||||
continue;
|
||||
@ -261,6 +264,7 @@ DefaultPartitionPage::_Layout()
|
||||
{
|
||||
LayoutDescriptionVertically(fDescription);
|
||||
|
||||
const float kTextDistance = be_control_look->DefaultItemSpacing();
|
||||
float left = fDefaultPartition->Frame().left;
|
||||
float top = fDescription->Frame().bottom + kTextDistance;
|
||||
|
||||
@ -269,4 +273,3 @@ DefaultPartitionPage::_Layout()
|
||||
|
||||
fTimeoutSlider->MoveTo(left, top);
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* Copyright 2008, Haiku, Inc. All rights reserved.
|
||||
* Copyright 2008-2010, Haiku, Inc. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
*
|
||||
* Authors:
|
||||
* Michael Pfeiffer <laplace@users.sourceforge.net>
|
||||
*/
|
||||
@ -20,27 +20,28 @@ class BSlider;
|
||||
class BTextView;
|
||||
|
||||
|
||||
class DefaultPartitionPage : public WizardPageView
|
||||
{
|
||||
class DefaultPartitionPage : public WizardPageView {
|
||||
public:
|
||||
DefaultPartitionPage(BMessage* settings, BRect frame, const char* name);
|
||||
virtual ~DefaultPartitionPage();
|
||||
|
||||
virtual void FrameResized(float width, float height);
|
||||
DefaultPartitionPage(BMessage* settings,
|
||||
BRect frame, const char* name);
|
||||
virtual ~DefaultPartitionPage();
|
||||
|
||||
virtual void AttachedToWindow();
|
||||
virtual void MessageReceived(BMessage* msg);
|
||||
virtual void FrameResized(float width, float height);
|
||||
|
||||
virtual void AttachedToWindow();
|
||||
virtual void MessageReceived(BMessage* msg);
|
||||
|
||||
private:
|
||||
void _BuildUI();
|
||||
BPopUpMenu* _CreatePopUpMenu();
|
||||
void _GetTimeoutLabel(int32 timeout, BString& label);
|
||||
void _Layout();
|
||||
|
||||
void _BuildUI();
|
||||
BPopUpMenu* _CreatePopUpMenu();
|
||||
void _GetTimeoutLabel(int32 timeout, BString& label);
|
||||
void _Layout();
|
||||
|
||||
BTextView* fDescription;
|
||||
BMenuField* fDefaultPartition;
|
||||
BSlider* fTimeoutSlider;
|
||||
private:
|
||||
BTextView* fDescription;
|
||||
BMenuField* fDefaultPartition;
|
||||
BSlider* fTimeoutSlider;
|
||||
};
|
||||
|
||||
|
||||
#endif // DEFAULT_PARTITON_PAGE_H
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* Copyright 2008, Haiku, Inc. All rights reserved.
|
||||
* Copyright 2008-2010, Haiku, Inc. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
*
|
||||
* Authors:
|
||||
* Michael Pfeiffer <laplace@users.sourceforge.net>
|
||||
*/
|
||||
@ -9,16 +9,16 @@
|
||||
|
||||
#include "DescriptionPage.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include <RadioButton.h>
|
||||
#include <TextView.h>
|
||||
|
||||
#include <string.h>
|
||||
|
||||
|
||||
DescriptionPage::DescriptionPage(BRect frame, const char* name,
|
||||
const char* description, bool hasHeading)
|
||||
: WizardPageView(NULL, frame, name, B_FOLLOW_ALL,
|
||||
:
|
||||
WizardPageView(NULL, frame, name, B_FOLLOW_ALL,
|
||||
B_WILL_DRAW | B_FRAME_EVENTS | B_FULL_UPDATE_ON_RESIZE)
|
||||
{
|
||||
_BuildUI(description, hasHeading);
|
||||
@ -38,19 +38,17 @@ DescriptionPage::FrameResized(float width, float height)
|
||||
}
|
||||
|
||||
|
||||
static const float kTextDistance = 10;
|
||||
|
||||
void
|
||||
DescriptionPage::_BuildUI(const char* description, bool hasHeading)
|
||||
{
|
||||
BRect rect(Bounds());
|
||||
|
||||
|
||||
fDescription = CreateDescription(rect, "description", description);
|
||||
if (hasHeading)
|
||||
MakeHeading(fDescription);
|
||||
fDescription->SetTabWidth(85);
|
||||
AddChild(fDescription);
|
||||
|
||||
|
||||
_Layout();
|
||||
}
|
||||
|
||||
@ -58,6 +56,6 @@ DescriptionPage::_BuildUI(const char* description, bool hasHeading)
|
||||
void
|
||||
DescriptionPage::_Layout()
|
||||
{
|
||||
LayoutDescriptionVertically(fDescription);
|
||||
LayoutDescriptionVertically(fDescription);
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* Copyright 2008, Haiku, Inc. All rights reserved.
|
||||
* Copyright 2008-2010, Haiku, Inc. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
*
|
||||
* Authors:
|
||||
* Michael Pfeiffer <laplace@users.sourceforge.net>
|
||||
*/
|
||||
@ -14,20 +14,22 @@
|
||||
|
||||
class BTextView;
|
||||
|
||||
class DescriptionPage : public WizardPageView
|
||||
{
|
||||
class DescriptionPage : public WizardPageView {
|
||||
public:
|
||||
DescriptionPage(BRect frame, const char* name, const char* description, bool hasHeading);
|
||||
virtual ~DescriptionPage();
|
||||
|
||||
virtual void FrameResized(float width, float height);
|
||||
DescriptionPage(BRect frame, const char* name,
|
||||
const char* description, bool hasHeading);
|
||||
virtual ~DescriptionPage();
|
||||
|
||||
virtual void FrameResized(float width, float height);
|
||||
|
||||
private:
|
||||
void _BuildUI(const char* description,
|
||||
bool hasHeading);
|
||||
void _Layout();
|
||||
|
||||
void _BuildUI(const char* description, bool hasHeading);
|
||||
void _Layout();
|
||||
|
||||
BTextView* fDescription;
|
||||
private:
|
||||
BTextView* fDescription;
|
||||
};
|
||||
|
||||
|
||||
#endif // DESCRIPTION_PAGE_H
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008-2009, Haiku, Inc. All rights reserved.
|
||||
* Copyright 2008-2010, Haiku, Inc. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
@ -9,21 +9,21 @@
|
||||
|
||||
#include "EntryPage.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include <Catalog.h>
|
||||
#include <Locale.h>
|
||||
#include <ControlLook.h>
|
||||
#include <RadioButton.h>
|
||||
#include <TextView.h>
|
||||
|
||||
#include <string.h>
|
||||
|
||||
|
||||
#undef B_TRANSLATE_CONTEXT
|
||||
#define B_TRANSLATE_CONTEXT "EntryPage"
|
||||
|
||||
|
||||
EntryPage::EntryPage(BMessage* settings, BRect frame, const char* name)
|
||||
: WizardPageView(settings, frame, name, B_FOLLOW_ALL,
|
||||
:
|
||||
WizardPageView(settings, frame, name, B_FOLLOW_ALL,
|
||||
B_WILL_DRAW | B_FRAME_EVENTS | B_FULL_UPDATE_ON_RESIZE)
|
||||
{
|
||||
_BuildUI();
|
||||
@ -49,7 +49,6 @@ EntryPage::PageCompleted()
|
||||
fSettings->ReplaceBool("install", fInstall->Value() != 0);
|
||||
}
|
||||
|
||||
static const float kTextDistance = 10;
|
||||
|
||||
void
|
||||
EntryPage::_BuildUI()
|
||||
@ -63,7 +62,8 @@ EntryPage::_BuildUI()
|
||||
fInstall->ResizeToPreferred();
|
||||
|
||||
BRect textRect(rect);
|
||||
textRect.left = fInstall->Frame().right + kTextDistance;
|
||||
textRect.left = fInstall->Frame().right
|
||||
+ be_control_look->DefaultItemSpacing();
|
||||
|
||||
BString text;
|
||||
text <<
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* Copyright 2008, Haiku, Inc. All rights reserved.
|
||||
* Copyright 2008-2010, Haiku, Inc. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
*
|
||||
* Authors:
|
||||
* Michael Pfeiffer <laplace@users.sourceforge.net>
|
||||
*/
|
||||
@ -15,25 +15,27 @@
|
||||
class BRadioButton;
|
||||
class BTextView;
|
||||
|
||||
class EntryPage : public WizardPageView
|
||||
{
|
||||
|
||||
class EntryPage : public WizardPageView {
|
||||
public:
|
||||
EntryPage(BMessage* settings, BRect frame, const char* name);
|
||||
virtual ~EntryPage();
|
||||
|
||||
virtual void FrameResized(float width, float height);
|
||||
|
||||
virtual void PageCompleted();
|
||||
EntryPage(BMessage* settings, BRect frame,
|
||||
const char* name);
|
||||
virtual ~EntryPage();
|
||||
|
||||
virtual void FrameResized(float width, float height);
|
||||
|
||||
virtual void PageCompleted();
|
||||
|
||||
private:
|
||||
void _BuildUI();
|
||||
void _Layout();
|
||||
|
||||
void _BuildUI();
|
||||
void _Layout();
|
||||
|
||||
BRadioButton* fInstall;
|
||||
BTextView* fInstallText;
|
||||
BRadioButton* fUninstall;
|
||||
BTextView* fUninstallText;
|
||||
private:
|
||||
BRadioButton* fInstall;
|
||||
BTextView* fInstallText;
|
||||
BRadioButton* fUninstall;
|
||||
BTextView* fUninstallText;
|
||||
};
|
||||
|
||||
|
||||
#endif // ENTRY_PAGE_H
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008, Haiku, Inc. All rights reserved.
|
||||
* Copyright 2008-2010, Haiku, Inc. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
@ -9,18 +9,16 @@
|
||||
|
||||
#include "FileSelectionPage.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include <Button.h>
|
||||
#include <Catalog.h>
|
||||
#include <Locale.h>
|
||||
#include <ControlLook.h>
|
||||
#include <Path.h>
|
||||
#include <RadioButton.h>
|
||||
#include <TextControl.h>
|
||||
#include <TextView.h>
|
||||
|
||||
#include <string.h>
|
||||
#include <String.h>
|
||||
|
||||
|
||||
#undef B_TRANSLATE_CONTEXT
|
||||
#define B_TRANSLATE_CONTEXT "FileSelectionPage"
|
||||
@ -29,12 +27,13 @@
|
||||
const uint32 kMsgOpenFilePanel = 'open';
|
||||
|
||||
|
||||
FileSelectionPage::FileSelectionPage(BMessage* settings, BRect frame, const char* name,
|
||||
const char* description, file_panel_mode mode)
|
||||
: WizardPageView(settings, frame, name, B_FOLLOW_ALL,
|
||||
B_WILL_DRAW | B_FRAME_EVENTS | B_FULL_UPDATE_ON_RESIZE)
|
||||
, fMode(mode)
|
||||
, fFilePanel(NULL)
|
||||
FileSelectionPage::FileSelectionPage(BMessage* settings, BRect frame,
|
||||
const char* name, const char* description, file_panel_mode mode)
|
||||
:
|
||||
WizardPageView(settings, frame, name, B_FOLLOW_ALL,
|
||||
B_WILL_DRAW | B_FRAME_EVENTS | B_FULL_UPDATE_ON_RESIZE),
|
||||
fMode(mode),
|
||||
fFilePanel(NULL)
|
||||
{
|
||||
_BuildUI(description);
|
||||
}
|
||||
@ -87,12 +86,12 @@ FileSelectionPage::PageCompleted()
|
||||
}
|
||||
|
||||
|
||||
const float kTextDistance = 10;
|
||||
const float kFileButtonDistance = 10;
|
||||
|
||||
void
|
||||
FileSelectionPage::_BuildUI(const char* description)
|
||||
{
|
||||
const float kSpacing = be_control_look->DefaultItemSpacing();
|
||||
BRect rect(Bounds());
|
||||
|
||||
fDescription = CreateDescription(rect, "description", description);
|
||||
@ -110,7 +109,7 @@ FileSelectionPage::_BuildUI(const char* description)
|
||||
fSelect->ResizeToPreferred();
|
||||
|
||||
float selectLeft = rect.right - fSelect->Bounds().Width();
|
||||
rect.right = selectLeft - kFileButtonDistance;
|
||||
rect.right = selectLeft - kSpacing;
|
||||
fFile = new BTextControl(rect, "file",
|
||||
B_TRANSLATE_COMMENT("File:", "Text control label"),
|
||||
file.String(), new BMessage());
|
||||
@ -127,10 +126,11 @@ FileSelectionPage::_BuildUI(const char* description)
|
||||
void
|
||||
FileSelectionPage::_Layout()
|
||||
{
|
||||
const float kSpacing = be_control_look->DefaultItemSpacing();
|
||||
LayoutDescriptionVertically(fDescription);
|
||||
|
||||
float left = fFile->Frame().left;
|
||||
float top = fDescription->Frame().bottom + kTextDistance;
|
||||
float top = fDescription->Frame().bottom + kSpacing;
|
||||
|
||||
// center "file" text field and "select" button vertically
|
||||
float selectTop = top;
|
||||
@ -147,7 +147,7 @@ FileSelectionPage::_Layout()
|
||||
|
||||
fFile->MoveTo(left, fileTop);
|
||||
|
||||
float width = fSelect->Frame().left - kFileButtonDistance - left;
|
||||
float width = fSelect->Frame().left - kSpacing - left;
|
||||
fFile->ResizeTo(width, fileHeight);
|
||||
|
||||
left = fSelect->Frame().left;
|
||||
@ -172,11 +172,7 @@ FileSelectionPage::_OpenFilePanel()
|
||||
|
||||
BMessenger messenger(this);
|
||||
fFilePanel = new BFilePanel(fMode, &messenger, directory,
|
||||
B_FILE_NODE,
|
||||
false,
|
||||
NULL,
|
||||
NULL,
|
||||
true);
|
||||
B_FILE_NODE, false, NULL, NULL, true);
|
||||
if (fMode == B_SAVE_PANEL && file.Leaf() != NULL)
|
||||
fFilePanel->SetSaveText(file.Leaf());
|
||||
fFilePanel->Show();
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* Copyright 2008, Haiku, Inc. All rights reserved.
|
||||
* Copyright 2008-2010, Haiku, Inc. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
*
|
||||
* Authors:
|
||||
* Michael Pfeiffer <laplace@users.sourceforge.net>
|
||||
*/
|
||||
@ -18,33 +18,36 @@ class BButton;
|
||||
class BTextControl;
|
||||
class BTextView;
|
||||
|
||||
class FileSelectionPage : public WizardPageView
|
||||
{
|
||||
|
||||
class FileSelectionPage : public WizardPageView {
|
||||
public:
|
||||
FileSelectionPage(BMessage* settings, BRect frame, const char* name, const char* description,
|
||||
file_panel_mode mode);
|
||||
virtual ~FileSelectionPage();
|
||||
|
||||
virtual void FrameResized(float width, float height);
|
||||
virtual void AttachedToWindow();
|
||||
virtual void MessageReceived(BMessage* message);
|
||||
|
||||
virtual void PageCompleted();
|
||||
FileSelectionPage(BMessage* settings,
|
||||
BRect frame, const char* name,
|
||||
const char* description,
|
||||
file_panel_mode mode);
|
||||
virtual ~FileSelectionPage();
|
||||
|
||||
virtual void FrameResized(float width, float height);
|
||||
virtual void AttachedToWindow();
|
||||
virtual void MessageReceived(BMessage* message);
|
||||
|
||||
virtual void PageCompleted();
|
||||
|
||||
private:
|
||||
void _BuildUI(const char* description);
|
||||
void _Layout();
|
||||
void _OpenFilePanel();
|
||||
void _SetFileFromFilePanelMessage(BMessage* message);
|
||||
void _FilePanelCanceled();
|
||||
|
||||
void _BuildUI(const char* description);
|
||||
void _Layout();
|
||||
void _OpenFilePanel();
|
||||
void _SetFileFromFilePanelMessage(BMessage* message);
|
||||
void _FilePanelCanceled();
|
||||
|
||||
file_panel_mode fMode;
|
||||
BFilePanel* fFilePanel;
|
||||
private:
|
||||
file_panel_mode fMode;
|
||||
BFilePanel* fFilePanel;
|
||||
|
||||
BTextView* fDescription;
|
||||
BTextControl* fFile;
|
||||
BButton* fSelect;
|
||||
BTextView* fDescription;
|
||||
BTextControl* fFile;
|
||||
BButton* fSelect;
|
||||
};
|
||||
|
||||
|
||||
#endif // FILE_SELECTION_PAGE_H
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008, Haiku, Inc. All rights reserved.
|
||||
* Copyright 2008-2010, Haiku, Inc. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
@ -9,30 +9,18 @@
|
||||
|
||||
#include "LegacyBootDrive.h"
|
||||
|
||||
#include <new>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <Catalog.h>
|
||||
#include <Drivers.h>
|
||||
#include <DataIO.h>
|
||||
#include <DiskDevice.h>
|
||||
#include <DiskDeviceRoster.h>
|
||||
#include <DiskDeviceVisitor.h>
|
||||
#include <Locale.h>
|
||||
#include <File.h>
|
||||
#include <Partition.h>
|
||||
#include <Path.h>
|
||||
#include <String.h>
|
||||
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <memory>
|
||||
#include <new>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <ByteOrder.h>
|
||||
#include <DataIO.h>
|
||||
#include <File.h>
|
||||
#include <String.h>
|
||||
#include <UTF8.h>
|
||||
|
||||
#include "BootLoader.h"
|
||||
@ -44,29 +32,68 @@
|
||||
#define GET_FIRST_BIOS_DRIVE 1
|
||||
|
||||
|
||||
class Buffer : public BMallocIO
|
||||
{
|
||||
public:
|
||||
Buffer() : BMallocIO() {}
|
||||
bool WriteInt8(int8 value);
|
||||
bool WriteInt16(int16 value);
|
||||
bool WriteInt32(int32 value);
|
||||
bool WriteInt64(int64 value);
|
||||
bool WriteString(const char* value);
|
||||
bool Align(int16 alignment);
|
||||
bool Fill(int16 size, int8 fillByte);
|
||||
struct MasterBootRecord {
|
||||
uint8 bootLoader[440];
|
||||
uint8 diskSignature[4];
|
||||
uint8 reserved[2];
|
||||
uint8 partition[64];
|
||||
uint8 signature[2];
|
||||
};
|
||||
|
||||
|
||||
class LittleEndianMallocIO : public BMallocIO {
|
||||
public:
|
||||
bool WriteInt8(int8 value);
|
||||
bool WriteInt16(int16 value);
|
||||
bool WriteInt32(int32 value);
|
||||
bool WriteInt64(int64 value);
|
||||
bool WriteString(const char* value);
|
||||
bool Align(int16 alignment);
|
||||
bool Fill(int16 size, int8 fillByte);
|
||||
};
|
||||
|
||||
|
||||
class PartitionRecorder : public BDiskDeviceVisitor {
|
||||
public:
|
||||
PartitionRecorder(BMessage* settings,
|
||||
int8 drive);
|
||||
|
||||
virtual bool Visit(BDiskDevice* device);
|
||||
virtual bool Visit(BPartition* partition, int32 level);
|
||||
|
||||
bool HasPartitions() const;
|
||||
off_t FirstOffset() const;
|
||||
|
||||
private:
|
||||
bool _Record(BPartition* partition);
|
||||
|
||||
private:
|
||||
BMessage* fSettings;
|
||||
int8 fDrive;
|
||||
int32 fIndex;
|
||||
off_t fFirstOffset;
|
||||
};
|
||||
|
||||
|
||||
static const uint32 kBlockSize = 512;
|
||||
static const uint32 kNumberOfBootLoaderBlocks = 4;
|
||||
// The number of blocks required to store the
|
||||
// MBR including the Haiku boot loader.
|
||||
|
||||
static const uint32 kMBRSignature = 0xAA55;
|
||||
|
||||
static const int32 kMaxBootMenuItemLength = 70;
|
||||
|
||||
|
||||
bool
|
||||
Buffer::WriteInt8(int8 value)
|
||||
LittleEndianMallocIO::WriteInt8(int8 value)
|
||||
{
|
||||
return Write(&value, sizeof(value)) == sizeof(value);
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
Buffer::WriteInt16(int16 value)
|
||||
LittleEndianMallocIO::WriteInt16(int16 value)
|
||||
{
|
||||
return WriteInt8(value & 0xff)
|
||||
&& WriteInt8(value >> 8);
|
||||
@ -74,7 +101,7 @@ Buffer::WriteInt16(int16 value)
|
||||
|
||||
|
||||
bool
|
||||
Buffer::WriteInt32(int32 value)
|
||||
LittleEndianMallocIO::WriteInt32(int32 value)
|
||||
{
|
||||
return WriteInt8(value & 0xff)
|
||||
&& WriteInt8(value >> 8)
|
||||
@ -84,14 +111,14 @@ Buffer::WriteInt32(int32 value)
|
||||
|
||||
|
||||
bool
|
||||
Buffer::WriteInt64(int64 value)
|
||||
LittleEndianMallocIO::WriteInt64(int64 value)
|
||||
{
|
||||
return WriteInt32(value) && WriteInt32(value >> 32);
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
Buffer::WriteString(const char* value)
|
||||
LittleEndianMallocIO::WriteString(const char* value)
|
||||
{
|
||||
int len = strlen(value) + 1;
|
||||
return WriteInt8(len)
|
||||
@ -100,7 +127,7 @@ Buffer::WriteString(const char* value)
|
||||
|
||||
|
||||
bool
|
||||
Buffer::Align(int16 alignment)
|
||||
LittleEndianMallocIO::Align(int16 alignment)
|
||||
{
|
||||
if ((Position() % alignment) == 0)
|
||||
return true;
|
||||
@ -109,7 +136,7 @@ Buffer::Align(int16 alignment)
|
||||
|
||||
|
||||
bool
|
||||
Buffer::Fill(int16 size, int8 fillByte)
|
||||
LittleEndianMallocIO::Fill(int16 size, int8 fillByte)
|
||||
{
|
||||
for (int i = 0; i < size; i ++) {
|
||||
if (!WriteInt8(fillByte))
|
||||
@ -119,32 +146,15 @@ Buffer::Fill(int16 size, int8 fillByte)
|
||||
}
|
||||
|
||||
|
||||
class PartitionRecorder : public BDiskDeviceVisitor
|
||||
{
|
||||
public:
|
||||
PartitionRecorder(BMessage* settings, int8 drive);
|
||||
|
||||
virtual bool Visit(BDiskDevice* device);
|
||||
virtual bool Visit(BPartition* partition, int32 level);
|
||||
|
||||
bool HasPartitions() const;
|
||||
off_t FirstOffset() const;
|
||||
|
||||
private:
|
||||
bool _Record(BPartition* partition);
|
||||
|
||||
BMessage* fSettings;
|
||||
int8 fDrive;
|
||||
int32 fIndex;
|
||||
off_t fFirstOffset;
|
||||
};
|
||||
// #pragma mark -
|
||||
|
||||
|
||||
PartitionRecorder::PartitionRecorder(BMessage* settings, int8 drive)
|
||||
: fSettings(settings)
|
||||
, fDrive(drive)
|
||||
, fIndex(0)
|
||||
, fFirstOffset(LONGLONG_MAX)
|
||||
:
|
||||
fSettings(settings),
|
||||
fDrive(drive),
|
||||
fIndex(0),
|
||||
fFirstOffset(LONGLONG_MAX)
|
||||
{
|
||||
}
|
||||
|
||||
@ -225,6 +235,9 @@ PartitionRecorder::_Record(BPartition* partition)
|
||||
}
|
||||
|
||||
|
||||
// #pragma mark -
|
||||
|
||||
|
||||
LegacyBootDrive::LegacyBootDrive()
|
||||
{
|
||||
}
|
||||
@ -323,21 +336,22 @@ LegacyBootDrive::WriteBootMenu(BMessage *settings)
|
||||
return B_BAD_VALUE;
|
||||
}
|
||||
|
||||
Buffer newBootLoader;
|
||||
LittleEndianMallocIO newBootLoader;
|
||||
ssize_t size = sizeof(kBootLoader);
|
||||
if (newBootLoader.Write(kBootLoader, size) != size) {
|
||||
close(fd);
|
||||
return B_NO_MEMORY;
|
||||
}
|
||||
|
||||
MasterBootRecord* newMBR = (MasterBootRecord*)newBootLoader.BMallocIO::Buffer();
|
||||
MasterBootRecord* newMBR = (MasterBootRecord*)newBootLoader.Buffer();
|
||||
_CopyPartitionTable(newMBR, &oldMBR);
|
||||
|
||||
int menuEntries = 0;
|
||||
int defaultMenuEntry = 0;
|
||||
BMessage partition;
|
||||
int32 index;
|
||||
for (index = 0; settings->FindMessage("partition", index, &partition) == B_OK; index ++) {
|
||||
for (index = 0; settings->FindMessage("partition", index,
|
||||
&partition) == B_OK; index ++) {
|
||||
bool show;
|
||||
partition.FindBool("show", &show);
|
||||
if (!show)
|
||||
@ -351,8 +365,8 @@ LegacyBootDrive::WriteBootMenu(BMessage *settings)
|
||||
newBootLoader.WriteInt16(defaultMenuEntry);
|
||||
newBootLoader.WriteInt16(timeout);
|
||||
|
||||
|
||||
for (index = 0; settings->FindMessage("partition", index, &partition) == B_OK; index ++) {
|
||||
for (index = 0; settings->FindMessage("partition", index,
|
||||
&partition) == B_OK; index ++) {
|
||||
bool show;
|
||||
BString name;
|
||||
BString path;
|
||||
@ -381,7 +395,7 @@ LegacyBootDrive::WriteBootMenu(BMessage *settings)
|
||||
}
|
||||
|
||||
lseek(fd, 0, SEEK_SET);
|
||||
const uint8* buffer = (uint8*)newBootLoader.BMallocIO::Buffer();
|
||||
const uint8* buffer = (const uint8*)newBootLoader.Buffer();
|
||||
status_t status = _WriteBlocks(fd, buffer, newBootLoader.Position());
|
||||
close(fd);
|
||||
return status;
|
||||
@ -593,14 +607,14 @@ LegacyBootDrive::_CopyPartitionTable(MasterBootRecord* destination,
|
||||
const MasterBootRecord* source)
|
||||
{
|
||||
memcpy(destination->diskSignature, source->diskSignature,
|
||||
sizeof(source->diskSignature) + sizeof(source->reserved) +
|
||||
sizeof(source->partition));
|
||||
sizeof(source->diskSignature) + sizeof(source->reserved)
|
||||
+ sizeof(source->partition));
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
LegacyBootDrive::_IsValid(const MasterBootRecord* mbr)
|
||||
{
|
||||
return mbr->signature[0] == (kMBRSignature & 0xff) &&
|
||||
mbr->signature[1] == (kMBRSignature >> 8);
|
||||
return mbr->signature[0] == (kMBRSignature & 0xff)
|
||||
&& mbr->signature[1] == (kMBRSignature >> 8);
|
||||
}
|
||||
|
@ -1,55 +1,49 @@
|
||||
/*
|
||||
* Copyright 2008, Haiku, Inc. All rights reserved.
|
||||
* Copyright 2008-2010, Haiku, Inc. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
*
|
||||
* Authors:
|
||||
* Michael Pfeiffer <laplace@users.sourceforge.net>
|
||||
*/
|
||||
#ifndef LEGACY_BOOT_DRIVE_H
|
||||
#define LEGACY_BOOT_DRIVE_H
|
||||
|
||||
|
||||
#include "BootDrive.h"
|
||||
|
||||
#include <SupportDefs.h>
|
||||
|
||||
const uint32 kBlockSize = 512;
|
||||
// The number of blocks required to store the
|
||||
// MBR including the Haiku boot loader.
|
||||
const uint32 kNumberOfBootLoaderBlocks = 4;
|
||||
|
||||
const uint32 kMBRSignature = 0xAA55;
|
||||
struct MasterBootRecord;
|
||||
|
||||
const int32 kMaxBootMenuItemLength = 70;
|
||||
|
||||
typedef struct {
|
||||
uint8 bootLoader[440];
|
||||
uint8 diskSignature[4];
|
||||
uint8 reserved[2];
|
||||
uint8 partition[64];
|
||||
uint8 signature[2];
|
||||
} MasterBootRecord;
|
||||
|
||||
class LegacyBootDrive : public BootDrive
|
||||
{
|
||||
class LegacyBootDrive : public BootDrive {
|
||||
public:
|
||||
LegacyBootDrive();
|
||||
~LegacyBootDrive();
|
||||
LegacyBootDrive();
|
||||
virtual ~LegacyBootDrive();
|
||||
|
||||
bool IsBootMenuInstalled(BMessage* settings);
|
||||
status_t ReadPartitions(BMessage* settings);
|
||||
status_t WriteBootMenu(BMessage* settings);
|
||||
status_t SaveMasterBootRecord(BMessage* settings, BFile* file);
|
||||
status_t RestoreMasterBootRecord(BMessage* settings, BFile* file);
|
||||
status_t GetDisplayText(const char* text, BString& displayText);
|
||||
virtual bool IsBootMenuInstalled(BMessage* settings);
|
||||
virtual status_t ReadPartitions(BMessage* settings);
|
||||
virtual status_t WriteBootMenu(BMessage* settings);
|
||||
virtual status_t SaveMasterBootRecord(BMessage* settings,
|
||||
BFile* file);
|
||||
virtual status_t RestoreMasterBootRecord(BMessage* settings,
|
||||
BFile* file);
|
||||
virtual status_t GetDisplayText(const char* text,
|
||||
BString& displayText);
|
||||
|
||||
private:
|
||||
bool _ConvertToBIOSText(const char* text, BString& biosText);
|
||||
bool _GetBiosDrive(const char* device, int8* drive);
|
||||
status_t _ReadBlocks(int fd, uint8* buffer, size_t size);
|
||||
status_t _WriteBlocks(int fd, const uint8* buffer, size_t size);
|
||||
void _CopyPartitionTable(MasterBootRecord* destination,
|
||||
const MasterBootRecord* source);
|
||||
bool _IsValid(const MasterBootRecord* mbr);
|
||||
bool _ConvertToBIOSText(const char* text,
|
||||
BString& biosText);
|
||||
bool _GetBiosDrive(const char* device, int8* drive);
|
||||
status_t _ReadBlocks(int fd, uint8* buffer, size_t size);
|
||||
status_t _WriteBlocks(int fd, const uint8* buffer,
|
||||
size_t size);
|
||||
void _CopyPartitionTable(
|
||||
MasterBootRecord* destination,
|
||||
const MasterBootRecord* source);
|
||||
bool _IsValid(const MasterBootRecord* mbr);
|
||||
};
|
||||
|
||||
|
||||
#endif // LEGACY_BOOT_DRIVE_H
|
||||
|
@ -1,8 +1,10 @@
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
|
||||
int
|
||||
main(int argc, char* argv[])
|
||||
{
|
||||
const char* application = argv[0];
|
||||
if (argc != 3) {
|
||||
@ -11,13 +13,14 @@ int main(int argc, char* argv[])
|
||||
}
|
||||
const char* variableName = argv[1];
|
||||
const char* fileName = argv[2];
|
||||
|
||||
|
||||
int fd = open(fileName, 0);
|
||||
if (fd < 0) {
|
||||
fprintf(stderr, "%s: Error opening file '%s'!\n", application, fileName);
|
||||
fprintf(stderr, "%s: Error opening file '%s'!\n", application,
|
||||
fileName);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
const int kSize = 1024;
|
||||
unsigned char buffer[kSize];
|
||||
int size = read(fd, buffer, kSize);
|
||||
@ -43,6 +46,6 @@ int main(int argc, char* argv[])
|
||||
size = read(fd, buffer, kSize);
|
||||
}
|
||||
printf("\n};\n");
|
||||
|
||||
|
||||
close(fd);
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008, Haiku, Inc. All rights reserved.
|
||||
* Copyright 2008-2010, Haiku, Inc. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
@ -10,20 +10,18 @@
|
||||
|
||||
#include "PartitionsPage.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <Catalog.h>
|
||||
#include <CheckBox.h>
|
||||
#include <Locale.h>
|
||||
#include <ControlLook.h>
|
||||
#include <RadioButton.h>
|
||||
#include <ScrollView.h>
|
||||
#include <StringView.h>
|
||||
#include <TextControl.h>
|
||||
#include <TextView.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <String.h>
|
||||
|
||||
|
||||
#undef B_TRANSLATE_CONTEXT
|
||||
#define B_TRANSLATE_CONTEXT "PartitionsPage"
|
||||
@ -33,8 +31,10 @@ const uint32 kMessageShow = 'show';
|
||||
const uint32 kMessageName = 'name';
|
||||
|
||||
|
||||
PartitionsPage::PartitionsPage(BMessage* settings, BRect frame, const char* name)
|
||||
: WizardPageView(settings, frame, name, B_FOLLOW_ALL,
|
||||
PartitionsPage::PartitionsPage(BMessage* settings, BRect frame,
|
||||
const char* name)
|
||||
:
|
||||
WizardPageView(settings, frame, name, B_FOLLOW_ALL,
|
||||
B_WILL_DRAW | B_FRAME_EVENTS | B_FULL_UPDATE_ON_RESIZE)
|
||||
{
|
||||
_BuildUI();
|
||||
@ -91,21 +91,19 @@ PartitionsPage::FrameResized(float width, float height)
|
||||
}
|
||||
|
||||
|
||||
static const float kTextDistance = 10;
|
||||
|
||||
void
|
||||
PartitionsPage::_BuildUI()
|
||||
{
|
||||
const float kTextDistance = be_control_look->DefaultItemSpacing();
|
||||
BRect rect(Bounds());
|
||||
|
||||
BString text;
|
||||
text <<
|
||||
B_TRANSLATE_COMMENT("Partitions", "Title") << "\n\n" <<
|
||||
B_TRANSLATE("The following partitions were detected. Please "
|
||||
"check the box next to the partitions to be included "
|
||||
"in the boot menu. You can also set the names of the "
|
||||
"partitions as you would like them to appear in the "
|
||||
"boot menu.");
|
||||
text << B_TRANSLATE_COMMENT("Partitions", "Title") << "\n\n"
|
||||
<< B_TRANSLATE("The following partitions were detected. Please "
|
||||
"check the box next to the partitions to be included "
|
||||
"in the boot menu. You can also set the names of the "
|
||||
"partitions as you would like them to appear in the "
|
||||
"boot menu.");
|
||||
fDescription = CreateDescription(rect, "description", text);
|
||||
MakeHeading(fDescription);
|
||||
AddChild(fDescription);
|
||||
@ -116,13 +114,10 @@ PartitionsPage::_BuildUI()
|
||||
rect.right -= B_V_SCROLL_BAR_WIDTH;
|
||||
rect.bottom -= B_H_SCROLL_BAR_HEIGHT + 3;
|
||||
|
||||
fPartitions = new BView(rect, "partitions", B_FOLLOW_ALL,
|
||||
B_WILL_DRAW);
|
||||
fPartitions = new BView(rect, "partitions", B_FOLLOW_ALL, B_WILL_DRAW);
|
||||
|
||||
fPartitionsScrollView = new BScrollView("scrollView", fPartitions,
|
||||
B_FOLLOW_ALL,
|
||||
0,
|
||||
true, true);
|
||||
B_FOLLOW_ALL, 0, true, true);
|
||||
fPartitionsScrollView->SetViewColor(ViewColor());
|
||||
AddChild(fPartitionsScrollView);
|
||||
|
||||
@ -137,6 +132,7 @@ PartitionsPage::_Layout()
|
||||
{
|
||||
LayoutDescriptionVertically(fDescription);
|
||||
|
||||
const float kTextDistance = be_control_look->DefaultItemSpacing();
|
||||
float left = fPartitionsScrollView->Frame().left;
|
||||
float top = fDescription->Frame().bottom + kTextDistance;
|
||||
fPartitionsScrollView->MoveTo(left, top);
|
||||
@ -173,10 +169,6 @@ PartitionsPage::_Layout()
|
||||
}
|
||||
|
||||
|
||||
const rgb_color kOddRowColor = {224, 255, 224};
|
||||
const rgb_color kEvenRowColor = {224, 224, 255};
|
||||
|
||||
|
||||
void
|
||||
PartitionsPage::_FillPartitionsView(BView* view)
|
||||
{
|
||||
@ -215,7 +207,8 @@ PartitionsPage::_FillPartitionsView(BView* view)
|
||||
frame.right = frame.left + 65000;
|
||||
|
||||
BMessage message;
|
||||
for (int32 i = 0; fSettings->FindMessage("partition", i, &message) == B_OK; i ++, rowNumber ++) {
|
||||
for (int32 i = 0; fSettings->FindMessage("partition", i, &message) == B_OK;
|
||||
i++, rowNumber++) {
|
||||
// get partition data
|
||||
bool show;
|
||||
BString name;
|
||||
@ -230,7 +223,6 @@ PartitionsPage::_FillPartitionsView(BView* view)
|
||||
|
||||
// create row for partition data
|
||||
BView* row = new BView(frame, "row", B_FOLLOW_TOP | B_FOLLOW_LEFT, 0);
|
||||
row->SetViewColor(((rowNumber % 2) == 0) ? kEvenRowColor : kOddRowColor);
|
||||
view->AddChild(row);
|
||||
frame.OffsetBy(0, height + 1);
|
||||
|
||||
@ -252,8 +244,8 @@ PartitionsPage::_FillPartitionsView(BView* view)
|
||||
|
||||
// name
|
||||
rect.right = rect.left + nameWidth;
|
||||
BTextControl* nameControl = new BTextControl(rect, "name", "", name.String(),
|
||||
_CreateControlMessage(kMessageName, i));
|
||||
BTextControl* nameControl = new BTextControl(rect, "name", "",
|
||||
name.String(), _CreateControlMessage(kMessageName, i));
|
||||
nameControl->SetDivider(0);
|
||||
row->AddChild(nameControl);
|
||||
rect.OffsetBy(nameWidth + kDistance, 0);
|
||||
@ -268,7 +260,8 @@ PartitionsPage::_FillPartitionsView(BView* view)
|
||||
BString sizeText;
|
||||
_CreateSizeText(size, &sizeText);
|
||||
rect.right = rect.left + sizeWidth;
|
||||
BStringView* sizeView = new BStringView(rect, "type", sizeText.String());
|
||||
BStringView* sizeView = new BStringView(rect, "type",
|
||||
sizeText.String());
|
||||
sizeView->SetAlignment(B_ALIGN_RIGHT);
|
||||
row->AddChild(sizeView);
|
||||
rect.OffsetBy(sizeWidth + kDistance, 0);
|
||||
@ -279,7 +272,6 @@ PartitionsPage::_FillPartitionsView(BView* view)
|
||||
row->AddChild(pathView);
|
||||
}
|
||||
|
||||
|
||||
fPartitionsWidth = totalWidth;
|
||||
fPartitionsHeight = frame.top;
|
||||
}
|
||||
@ -287,7 +279,7 @@ PartitionsPage::_FillPartitionsView(BView* view)
|
||||
|
||||
void
|
||||
PartitionsPage::_ComputeColumnWidths(int32& showWidth, int32& nameWidth,
|
||||
int32& typeWidth, int32& sizeWidth, int32& pathWidth)
|
||||
int32& typeWidth, int32& sizeWidth, int32& pathWidth)
|
||||
{
|
||||
BCheckBox checkBox(BRect(0, 0, 100, 100), "show", "", new BMessage());
|
||||
checkBox.ResizeToPreferred();
|
||||
@ -298,7 +290,8 @@ PartitionsPage::_ComputeColumnWidths(int32& showWidth, int32& nameWidth,
|
||||
const int32 kStringViewInsets = 2;
|
||||
|
||||
BMessage message;
|
||||
for (int32 i = 0; fSettings->FindMessage("partition", i, &message) == B_OK; i ++) {
|
||||
for (int32 i = 0; fSettings->FindMessage("partition", i, &message) == B_OK;
|
||||
i++) {
|
||||
// get partition data
|
||||
BString type;
|
||||
BString path;
|
||||
@ -309,18 +302,18 @@ PartitionsPage::_ComputeColumnWidths(int32& showWidth, int32& nameWidth,
|
||||
BString sizeText;
|
||||
_CreateSizeText(size, &sizeText);
|
||||
|
||||
int32 width = (int32)ceil(be_plain_font->StringWidth(type.String())) +
|
||||
kStringViewInsets;
|
||||
int32 width = (int32)ceil(be_plain_font->StringWidth(type.String()))
|
||||
+ kStringViewInsets;
|
||||
if (typeWidth < width)
|
||||
typeWidth = width;
|
||||
|
||||
width = (int32)ceil(be_plain_font->StringWidth(path.String())) +
|
||||
kStringViewInsets;
|
||||
width = (int32)ceil(be_plain_font->StringWidth(path.String()))
|
||||
+ kStringViewInsets;
|
||||
if (pathWidth < width)
|
||||
pathWidth = width;
|
||||
|
||||
width = (int32)ceil(be_plain_font->StringWidth(sizeText.String())) +
|
||||
kStringViewInsets;
|
||||
width = (int32)ceil(be_plain_font->StringWidth(sizeText.String()))
|
||||
+ kStringViewInsets;
|
||||
if (sizeWidth < width)
|
||||
sizeWidth = width;
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* Copyright 2008, Haiku, Inc. All rights reserved.
|
||||
* Copyright 2008-2010, Haiku, Inc. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
*
|
||||
* Authors:
|
||||
* Michael Pfeiffer <laplace@users.sourceforge.net>
|
||||
*/
|
||||
@ -15,31 +15,35 @@
|
||||
class BTextView;
|
||||
class BScrollView;
|
||||
|
||||
class PartitionsPage : public WizardPageView
|
||||
{
|
||||
|
||||
class PartitionsPage : public WizardPageView {
|
||||
public:
|
||||
PartitionsPage(BMessage* settings, BRect frame, const char* name);
|
||||
virtual ~PartitionsPage();
|
||||
|
||||
virtual void PageCompleted();
|
||||
|
||||
virtual void FrameResized(float width, float height);
|
||||
PartitionsPage(BMessage* settings, BRect frame,
|
||||
const char* name);
|
||||
virtual ~PartitionsPage();
|
||||
|
||||
virtual void PageCompleted();
|
||||
|
||||
virtual void FrameResized(float width, float height);
|
||||
|
||||
private:
|
||||
void _BuildUI();
|
||||
void _Layout();
|
||||
void _FillPartitionsView(BView* view);
|
||||
void _CreateSizeText(int64 size, BString* text);
|
||||
BMessage* _CreateControlMessage(uint32 what,
|
||||
int32 partitionIndex);
|
||||
void _ComputeColumnWidths(int32& showWidth,
|
||||
int32& nameWidth, int32& typeWidth,
|
||||
int32& sizeWidth, int32& pathWidth);
|
||||
|
||||
void _BuildUI();
|
||||
void _Layout();
|
||||
void _FillPartitionsView(BView* view);
|
||||
void _CreateSizeText(int64 size, BString* text);
|
||||
BMessage* _CreateControlMessage(uint32 what, int32 partitionIndex);
|
||||
void _ComputeColumnWidths(int32& showWidth, int32& nameWidth, int32& typeWidth,
|
||||
int32& sizeWidth, int32& pathWidth);
|
||||
|
||||
BTextView* fDescription;
|
||||
BView* fPartitions;
|
||||
BScrollView* fPartitionsScrollView;
|
||||
float fPartitionsWidth;
|
||||
float fPartitionsHeight;
|
||||
private:
|
||||
BTextView* fDescription;
|
||||
BView* fPartitions;
|
||||
BScrollView* fPartitionsScrollView;
|
||||
float fPartitionsWidth;
|
||||
float fPartitionsHeight;
|
||||
};
|
||||
|
||||
|
||||
#endif // PARTITONS_PAGE_H
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* Copyright 2008, Haiku, Inc. All rights reserved.
|
||||
* Copyright 2008-2010, Haiku, Inc. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
*
|
||||
* Authors:
|
||||
* Michael Pfeiffer <laplace@users.sourceforge.net>
|
||||
*/
|
||||
@ -9,20 +9,6 @@
|
||||
|
||||
#include "TestBootDrive.h"
|
||||
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <ByteOrder.h>
|
||||
#include <DataIO.h>
|
||||
#include <File.h>
|
||||
#include <String.h>
|
||||
|
||||
#include "BootLoader.h"
|
||||
|
||||
|
||||
TestBootDrive::TestBootDrive()
|
||||
{
|
||||
@ -45,20 +31,20 @@ status_t
|
||||
TestBootDrive::ReadPartitions(BMessage *settings)
|
||||
{
|
||||
settings->AddString("disk", "bootcylinder");
|
||||
|
||||
|
||||
BMessage partition;
|
||||
|
||||
|
||||
partition.AddBool("show", true);
|
||||
partition.AddString("name", "Haiku");
|
||||
partition.AddString("name", "TEST Haiku");
|
||||
partition.AddString("type", "bfs");
|
||||
partition.AddString("path", "/dev/disk/ide/ata/0/master/0/0_0");
|
||||
partition.AddInt64("size", 3 * (int64)1024 * 1024 * 1024);
|
||||
partition.AddInt64("size", 3 * (int64)1024 * 1024 * 1024);
|
||||
settings->AddMessage("partition", &partition);
|
||||
|
||||
|
||||
partition.MakeEmpty();
|
||||
|
||||
partition.MakeEmpty();
|
||||
partition.AddBool("show", true);
|
||||
partition.AddString("name", "no name");
|
||||
partition.AddString("name", "TEST no name");
|
||||
partition.AddString("type", "dos");
|
||||
partition.AddString("path", "/dev/disk/ide/ata/0/slave/0/0_0");
|
||||
partition.AddInt64("size", 10 * (int64)1024 * 1024 * 1024);
|
||||
@ -66,12 +52,12 @@ TestBootDrive::ReadPartitions(BMessage *settings)
|
||||
|
||||
partition.MakeEmpty();
|
||||
partition.AddBool("show", true);
|
||||
partition.AddString("name", "Data");
|
||||
partition.AddString("name", "TEST Data");
|
||||
partition.AddString("type", "unknown");
|
||||
partition.AddString("path", "/dev/disk/ide/ata/0/slave/0/0_1");
|
||||
partition.AddInt64("size", 250 * (int64)1024 * 1024 * 1024);
|
||||
partition.AddInt64("size", 250 * (int64)1024 * 1024 * 1024);
|
||||
settings->AddMessage("partition", &partition);
|
||||
|
||||
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
@ -81,21 +67,22 @@ TestBootDrive::WriteBootMenu(BMessage *settings)
|
||||
{
|
||||
printf("WriteBootMenu:\n");
|
||||
settings->PrintToStream();
|
||||
|
||||
|
||||
BMessage partition;
|
||||
int32 index = 0;
|
||||
for (; settings->FindMessage("partition", index, &partition) == B_OK; index ++) {
|
||||
for (; settings->FindMessage("partition", index, &partition) == B_OK;
|
||||
index++) {
|
||||
printf("Partition %d:\n", (int)index);
|
||||
partition.PrintToStream();
|
||||
}
|
||||
|
||||
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
TestBootDrive::SaveMasterBootRecord(BMessage* settings, BFile* file)
|
||||
{
|
||||
{
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
@ -112,5 +99,3 @@ TestBootDrive::GetDisplayText(const char* text, BString& displayText)
|
||||
{
|
||||
displayText = text;
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,27 +1,32 @@
|
||||
/*
|
||||
* Copyright 2008, Haiku, Inc. All rights reserved.
|
||||
* Copyright 2008-2010, Haiku, Inc. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
*
|
||||
* Authors:
|
||||
* Michael Pfeiffer <laplace@users.sourceforge.net>
|
||||
*/
|
||||
#ifndef TEST_BOOT_DRIVE_H
|
||||
#define TEST_BOOT_DRIVE_H
|
||||
|
||||
|
||||
#include "BootDrive.h"
|
||||
|
||||
class TestBootDrive : public BootDrive
|
||||
{
|
||||
public:
|
||||
TestBootDrive();
|
||||
~TestBootDrive();
|
||||
|
||||
bool IsBootMenuInstalled(BMessage* settings);
|
||||
status_t ReadPartitions(BMessage* settings);
|
||||
status_t WriteBootMenu(BMessage* settings);
|
||||
status_t SaveMasterBootRecord(BMessage* settings, BFile* file);
|
||||
status_t RestoreMasterBootRecord(BMessage* settings, BFile* file);
|
||||
status_t GetDisplayText(const char* text, BString& displayText);
|
||||
class TestBootDrive : public BootDrive {
|
||||
public:
|
||||
TestBootDrive();
|
||||
virtual ~TestBootDrive();
|
||||
|
||||
virtual bool IsBootMenuInstalled(BMessage* settings);
|
||||
virtual status_t ReadPartitions(BMessage* settings);
|
||||
virtual status_t WriteBootMenu(BMessage* settings);
|
||||
virtual status_t SaveMasterBootRecord(BMessage* settings,
|
||||
BFile* file);
|
||||
virtual status_t RestoreMasterBootRecord(BMessage* settings,
|
||||
BFile* file);
|
||||
virtual status_t GetDisplayText(const char* text,
|
||||
BString& displayText);
|
||||
};
|
||||
|
||||
|
||||
#endif // TEST_BOOT_DRIVE_H
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008, Haiku, Inc. All rights reserved.
|
||||
* Copyright 2008-2010, Haiku, Inc. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
@ -9,21 +9,23 @@
|
||||
|
||||
#include "UninstallPage.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include <Catalog.h>
|
||||
#include <Locale.h>
|
||||
#include <RadioButton.h>
|
||||
#include <TextView.h>
|
||||
|
||||
#include <string.h>
|
||||
|
||||
|
||||
#undef B_TRANSLATE_CONTEXT
|
||||
#define B_TRANSLATE_CONTEXT "UninstallPage"
|
||||
|
||||
|
||||
static const float kTextDistance = 10;
|
||||
|
||||
|
||||
UninstallPage::UninstallPage(BMessage* settings, BRect frame, const char* name)
|
||||
: WizardPageView(settings, frame, name, B_FOLLOW_ALL,
|
||||
:
|
||||
WizardPageView(settings, frame, name, B_FOLLOW_ALL,
|
||||
B_WILL_DRAW | B_FRAME_EVENTS | B_FULL_UPDATE_ON_RESIZE)
|
||||
{
|
||||
_BuildUI();
|
||||
@ -43,19 +45,16 @@ UninstallPage::FrameResized(float width, float height)
|
||||
}
|
||||
|
||||
|
||||
static const float kTextDistance = 10;
|
||||
|
||||
void
|
||||
UninstallPage::_BuildUI()
|
||||
{
|
||||
BRect rect(Bounds());
|
||||
|
||||
BString text;
|
||||
text <<
|
||||
B_TRANSLATE_COMMENT("Uninstall Boot Manager", "Title") << "\n\n" <<
|
||||
B_TRANSLATE("Please locate the Master Boot Record (MBR) save file to "
|
||||
"restore from. This is the file that was created when the "
|
||||
"boot manager was first installed.");
|
||||
text << B_TRANSLATE_COMMENT("Uninstall Boot Manager", "Title") << "\n\n"
|
||||
<< B_TRANSLATE("Please locate the Master Boot Record (MBR) save file "
|
||||
"to restore from. This is the file that was created when the "
|
||||
"boot manager was first installed.");
|
||||
fDescription = CreateDescription(rect, "description", text);
|
||||
|
||||
MakeHeading(fDescription);
|
||||
@ -70,4 +69,3 @@ UninstallPage::_Layout()
|
||||
{
|
||||
LayoutDescriptionVertically(fDescription);
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* Copyright 2008, Haiku, Inc. All rights reserved.
|
||||
* Copyright 2008-2010, Haiku, Inc. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
*
|
||||
* Authors:
|
||||
* Michael Pfeiffer <laplace@users.sourceforge.net>
|
||||
*/
|
||||
@ -14,20 +14,22 @@
|
||||
|
||||
class BTextView;
|
||||
|
||||
class UninstallPage : public WizardPageView
|
||||
{
|
||||
|
||||
class UninstallPage : public WizardPageView {
|
||||
public:
|
||||
UninstallPage(BMessage* settings, BRect frame, const char* name);
|
||||
virtual ~UninstallPage();
|
||||
|
||||
virtual void FrameResized(float width, float height);
|
||||
UninstallPage(BMessage* settings, BRect frame,
|
||||
const char* name);
|
||||
virtual ~UninstallPage();
|
||||
|
||||
virtual void FrameResized(float width, float height);
|
||||
|
||||
private:
|
||||
void _BuildUI();
|
||||
void _Layout();
|
||||
|
||||
void _BuildUI();
|
||||
void _Layout();
|
||||
|
||||
BTextView* fDescription;
|
||||
private:
|
||||
BTextView* fDescription;
|
||||
};
|
||||
|
||||
|
||||
#endif // UNINSTALL_PAGE_H
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* Copyright 2008, Haiku, Inc. All rights reserved.
|
||||
* Copyright 2008-2010, Haiku, Inc. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
*
|
||||
* Authors:
|
||||
* Michael Pfeiffer <laplace@users.sourceforge.net>
|
||||
*/
|
||||
@ -12,21 +12,23 @@
|
||||
#include "WizardView.h"
|
||||
#include "WizardPageView.h"
|
||||
|
||||
|
||||
void
|
||||
WizardController::StateStack::MakeEmpty()
|
||||
{
|
||||
StateStack* stack = this;
|
||||
StateStack* next;
|
||||
do {
|
||||
next = stack->Next();
|
||||
delete stack;
|
||||
stack = next;
|
||||
} while (next != NULL);
|
||||
StateStack* stack = this;
|
||||
StateStack* next;
|
||||
do {
|
||||
next = stack->Next();
|
||||
delete stack;
|
||||
stack = next;
|
||||
} while (next != NULL);
|
||||
}
|
||||
|
||||
|
||||
WizardController::WizardController()
|
||||
: fStack(NULL)
|
||||
:
|
||||
fStack(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
@ -53,14 +55,14 @@ void
|
||||
WizardController::Next(WizardView* wizard)
|
||||
{
|
||||
wizard->PageCompleted();
|
||||
|
||||
|
||||
if (fStack == NULL)
|
||||
return;
|
||||
|
||||
|
||||
int state = NextState(fStack->State());
|
||||
if (state < 0)
|
||||
return;
|
||||
|
||||
|
||||
_PushState(state);
|
||||
_ShowPage(wizard);
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* Copyright 2008, Haiku, Inc. All rights reserved.
|
||||
* Copyright 2008-2010, Haiku, Inc. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
*
|
||||
* Authors:
|
||||
* Michael Pfeiffer <laplace@users.sourceforge.net>
|
||||
*/
|
||||
@ -11,56 +11,57 @@
|
||||
|
||||
#include <SupportDefs.h>
|
||||
|
||||
|
||||
class WizardView;
|
||||
class WizardPageView;
|
||||
|
||||
|
||||
class WizardController
|
||||
{
|
||||
class WizardController {
|
||||
public:
|
||||
WizardController();
|
||||
virtual ~WizardController();
|
||||
|
||||
virtual void Initialize(WizardView* wizard);
|
||||
virtual void Next(WizardView* wizard);
|
||||
virtual void Previous(WizardView* wizard);
|
||||
WizardController();
|
||||
virtual ~WizardController();
|
||||
|
||||
virtual void Initialize(WizardView* wizard);
|
||||
virtual void Next(WizardView* wizard);
|
||||
virtual void Previous(WizardView* wizard);
|
||||
|
||||
protected:
|
||||
virtual int32 InitialState() = 0;
|
||||
virtual int32 NextState(int32 state) = 0;
|
||||
virtual WizardPageView* CreatePage(int32 state, WizardView* wizard) = 0;
|
||||
|
||||
virtual int32 InitialState() = 0;
|
||||
virtual int32 NextState(int32 state) = 0;
|
||||
virtual WizardPageView* CreatePage(int32 state, WizardView* wizard) = 0;
|
||||
|
||||
private:
|
||||
|
||||
class StateStack {
|
||||
public:
|
||||
StateStack(int32 state, StateStack* next)
|
||||
: fState(state)
|
||||
, fNext(next)
|
||||
{
|
||||
}
|
||||
|
||||
int32 State() {
|
||||
return fState;
|
||||
}
|
||||
|
||||
StateStack* Next() {
|
||||
return fNext;
|
||||
}
|
||||
|
||||
void MakeEmpty();
|
||||
|
||||
private:
|
||||
int32 fState;
|
||||
StateStack* fNext;
|
||||
public:
|
||||
StateStack(int32 state, StateStack* next)
|
||||
:
|
||||
fState(state),
|
||||
fNext(next)
|
||||
{
|
||||
}
|
||||
|
||||
int32 State()
|
||||
{
|
||||
return fState;
|
||||
}
|
||||
|
||||
StateStack* Next()
|
||||
{
|
||||
return fNext;
|
||||
}
|
||||
|
||||
void MakeEmpty();
|
||||
|
||||
private:
|
||||
int32 fState;
|
||||
StateStack* fNext;
|
||||
};
|
||||
|
||||
void _PushState(int32 state);
|
||||
void _ShowPage(WizardView* wizard);
|
||||
|
||||
StateStack* fStack;
|
||||
void _PushState(int32 state);
|
||||
void _ShowPage(WizardView* wizard);
|
||||
|
||||
private:
|
||||
StateStack* fStack;
|
||||
};
|
||||
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* Copyright 2008, Haiku, Inc. All rights reserved.
|
||||
* Copyright 2008-2010, Haiku, Inc. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
*
|
||||
* Authors:
|
||||
* Michael Pfeiffer <laplace@users.sourceforge.net>
|
||||
*/
|
||||
@ -9,17 +9,17 @@
|
||||
|
||||
#include "WizardPageView.h"
|
||||
|
||||
|
||||
#include <TextView.h>
|
||||
|
||||
#include <math.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <TextView.h>
|
||||
|
||||
WizardPageView::WizardPageView(BMessage* settings, BRect frame, const char* name,
|
||||
uint32 resizingMode, uint32 flags)
|
||||
: BView(frame, name, resizingMode, flags)
|
||||
, fSettings(settings)
|
||||
|
||||
WizardPageView::WizardPageView(BMessage* settings, BRect frame,
|
||||
const char* name, uint32 resizingMode, uint32 flags)
|
||||
:
|
||||
BView(frame, name, resizingMode, flags),
|
||||
fSettings(settings)
|
||||
{
|
||||
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
||||
}
|
||||
@ -40,7 +40,7 @@ BTextView*
|
||||
WizardPageView::CreateDescription(BRect frame, const char* name,
|
||||
const char* description)
|
||||
{
|
||||
BTextView* view = new BTextView(frame, "text",
|
||||
BTextView* view = new BTextView(frame, "text",
|
||||
frame.OffsetToCopy(0, 0),
|
||||
B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP,
|
||||
B_WILL_DRAW | B_PULSE_NEEDED | B_FRAME_EVENTS);
|
||||
@ -72,10 +72,10 @@ void
|
||||
WizardPageView::LayoutDescriptionVertically(BTextView* view)
|
||||
{
|
||||
view->SetTextRect(view->Bounds());
|
||||
|
||||
|
||||
float height = view->TextHeight(0, 32000);
|
||||
float width = view->Bounds().Width();
|
||||
|
||||
|
||||
view->ResizeTo(width, height);
|
||||
view->SetTextRect(view->Bounds());
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* Copyright 2008, Haiku, Inc. All rights reserved.
|
||||
* Copyright 2008-2010, Haiku, Inc. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
*
|
||||
* Authors:
|
||||
* Michael Pfeiffer <laplace@users.sourceforge.net>
|
||||
*/
|
||||
@ -15,26 +15,28 @@
|
||||
#include <View.h>
|
||||
|
||||
|
||||
class WizardPageView : public BView
|
||||
{
|
||||
class WizardPageView : public BView {
|
||||
public:
|
||||
WizardPageView(BMessage* settings, BRect frame, const char* name,
|
||||
uint32 resizingMode = B_FOLLOW_ALL, uint32 flags = B_WILL_DRAW);
|
||||
virtual ~WizardPageView();
|
||||
|
||||
virtual void PageCompleted();
|
||||
WizardPageView(BMessage* settings, BRect frame,
|
||||
const char* name,
|
||||
uint32 resizingMode = B_FOLLOW_ALL,
|
||||
uint32 flags = B_WILL_DRAW);
|
||||
virtual ~WizardPageView();
|
||||
|
||||
virtual BTextView* CreateDescription(BRect frame, const char* name,
|
||||
const char* description);
|
||||
|
||||
virtual void MakeHeading(BTextView* view);
|
||||
virtual void LayoutDescriptionVertically(BTextView* view);
|
||||
virtual void PageCompleted();
|
||||
|
||||
protected:
|
||||
BMessage* fSettings;
|
||||
virtual BTextView* CreateDescription(BRect frame, const char* name,
|
||||
const char* description);
|
||||
|
||||
virtual void MakeHeading(BTextView* view);
|
||||
virtual void LayoutDescriptionVertically(BTextView* view);
|
||||
|
||||
private:
|
||||
void _BuildUI();
|
||||
void _BuildUI();
|
||||
|
||||
protected:
|
||||
BMessage* fSettings;
|
||||
};
|
||||
|
||||
|
||||
#endif // WIZARD_PAGE_VIEW_H
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008, Haiku, Inc. All rights reserved.
|
||||
* Copyright 2008-2010, Haiku, Inc. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
@ -9,11 +9,10 @@
|
||||
|
||||
#include "WizardView.h"
|
||||
|
||||
#include "WizardPageView.h"
|
||||
|
||||
#include <Box.h>
|
||||
#include <Catalog.h>
|
||||
#include <Locale.h>
|
||||
|
||||
#include "WizardPageView.h"
|
||||
|
||||
|
||||
#undef B_TRANSLATE_CONTEXT
|
||||
@ -27,11 +26,12 @@ static const float kBorderHeight = 5;
|
||||
|
||||
|
||||
WizardView::WizardView(BRect frame, const char* name, uint32 resizingMode)
|
||||
: BView(frame, name, resizingMode, 0)
|
||||
, fSeparator(NULL)
|
||||
, fPrevious(NULL)
|
||||
, fNext(NULL)
|
||||
, fPage(NULL)
|
||||
:
|
||||
BView(frame, name, resizingMode, 0),
|
||||
fSeparator(NULL),
|
||||
fPrevious(NULL),
|
||||
fNext(NULL),
|
||||
fPage(NULL)
|
||||
{
|
||||
_BuildUI();
|
||||
SetPreviousButtonHidden(true);
|
||||
@ -164,7 +164,9 @@ WizardView::_BuildUI()
|
||||
float buttonTop = height - 1 - buttonHeight - kBorderHeight;
|
||||
fPrevious->MoveTo(kBorderWidth, buttonTop);
|
||||
|
||||
fSeparator->MoveTo(kBorderWidth, buttonTop - kSeparatorDistance - kSeparatorHeight);
|
||||
fSeparator->MoveTo(kBorderWidth,
|
||||
buttonTop - kSeparatorDistance - kSeparatorHeight);
|
||||
|
||||
fNext->MoveTo(width - fNext->Bounds().Width() - kBorderWidth - 1, buttonTop);
|
||||
fNext->MoveTo(width - fNext->Bounds().Width() - kBorderWidth - 1,
|
||||
buttonTop);
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* Copyright 2008, Haiku, Inc. All rights reserved.
|
||||
* Copyright 2008-2010, Haiku, Inc. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
*
|
||||
* Authors:
|
||||
* Michael Pfeiffer <laplace@users.sourceforge.net>
|
||||
*/
|
||||
@ -22,32 +22,34 @@ const uint32 kMessageNext = 'next';
|
||||
const uint32 kMessagePrevious = 'prev';
|
||||
|
||||
|
||||
class WizardView : public BView
|
||||
{
|
||||
class WizardView : public BView {
|
||||
public:
|
||||
WizardView(BRect frame, const char* name, uint32 resizingMode);
|
||||
virtual ~WizardView();
|
||||
WizardView(BRect frame, const char* name,
|
||||
uint32 resizingMode);
|
||||
virtual ~WizardView();
|
||||
|
||||
virtual BRect PageFrame();
|
||||
virtual BRect PageFrame();
|
||||
|
||||
virtual void SetPage(WizardPageView* page);
|
||||
|
||||
virtual void PageCompleted();
|
||||
virtual void SetPage(WizardPageView* page);
|
||||
|
||||
virtual void SetPreviousButtonEnabled(bool enabled);
|
||||
virtual void SetNextButtonEnabled(bool enabled);
|
||||
virtual void SetPreviousButtonLabel(const char* text);
|
||||
virtual void SetNextButtonLabel(const char* text);
|
||||
virtual void SetPreviousButtonHidden(bool hide);
|
||||
virtual void PageCompleted();
|
||||
|
||||
virtual void SetPreviousButtonEnabled(bool enabled);
|
||||
virtual void SetNextButtonEnabled(bool enabled);
|
||||
virtual void SetPreviousButtonLabel(const char* text);
|
||||
virtual void SetNextButtonLabel(const char* text);
|
||||
virtual void SetPreviousButtonHidden(bool hide);
|
||||
|
||||
private:
|
||||
void _BuildUI();
|
||||
void _BuildUI();
|
||||
|
||||
BBox* fSeparator;
|
||||
BButton* fPrevious;
|
||||
BButton* fNext;
|
||||
|
||||
WizardPageView* fPage;
|
||||
private:
|
||||
BBox* fSeparator;
|
||||
BButton* fPrevious;
|
||||
BButton* fNext;
|
||||
|
||||
WizardPageView* fPage;
|
||||
};
|
||||
|
||||
|
||||
#endif // WIZARD_VIEW_H
|
||||
|
Loading…
Reference in New Issue
Block a user