* Converted to use layout-management.

* New logo specific to R1 Alpha/1.
* "Setup Partitions" is now always visible, since it will most likely be
  required to prepare a partition for installation anyways.
* The optional packages are still in the GUI, but are collapsed by default as
  before. As there are currently no optional packages, a message will be
  displayed if no optional packages are found on the source partition.
* The default label for the "Onto" popup is now "Please choose target" instead
  of the first partition found, even though it is not actually selected yet.
* The EULA window is still shown, but it's not based on a BAlert anymore.
* Only make main window non-minimizable if the Deskbar is not running
  (untested).
* Style cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30368 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stephan Aßmus
2009-04-24 12:24:25 +00:00
parent 8c8c904aca
commit 7ff74a7b9b
9 changed files with 417 additions and 212 deletions
+1 -1
View File
@@ -10,7 +10,7 @@ resource app_version {
internal = 0,
short_info = "Installer",
long_info = "Installer ©2005-2007 Haiku, Inc."
long_info = "Installer ©2005-2009 Haiku, Inc."
};
resource app_flags B_EXCLUSIVE_LAUNCH;
+97 -43
View File
@@ -1,22 +1,45 @@
/*
* Copyright 2005, Jérôme DUVAL. All rights reserved.
* Distributed under the terms of the MIT License.
* Copyright 2009, Stephan Aßmus <[email protected]>
* Copyright 2005, Jérôme DUVAL.
* All rights reserved. Distributed under the terms of the MIT License.
*/
#include "InstallerApp.h"
#include <Alert.h>
#include <Button.h>
#include <GroupLayoutBuilder.h>
#include <Screen.h>
#include <ScrollView.h>
#include <TextView.h>
#include "InstallerApp.h"
const char *APP_SIG = "application/x-vnd.Haiku-Installer";
#define EULA_TEXT "HAIKU INC - END USER LICENSE AGREEMENT\n\n\
NOTICE: READ THIS BEFORE INSTALLING OR USING Haiku\n\
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\
THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\
"
static const uint32 kMsgAgree = 'agre';
static const char* kEULAText =
"NOTICE: READ THIS BEFORE INSTALLING OR USING HAIKU\n\n"
"Copyright " B_UTF8_COPYRIGHT " 2001-2009 The Haiku Project. All rights "
"reserved. The copyright to the Haiku code is property of Haiku, Inc. or of "
"the respective authors where expressly noted in the source.\n\n"
"Permission is hereby granted, free of charge, to any person obtaining a "
"copy of this software and associated documentation files (the \"Software\"), "
"to deal in the Software without restriction, including without limitation "
"the rights to use, copy, modify, merge, publish, distribute, sublicense, "
"and/or sell copies of the Software, and to permit persons to whom the "
"Software is furnished to do so, subject to the following conditions:\n\n"
"The above copyright notice and this permission notice shall be included in "
"all copies or substantial portions of the Software.\n\n"
"THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS "
"OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, "
"FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE "
"AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER "
"LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING "
"FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS "
"IN THE SOFTWARE.";
int main(int, char **)
{
@@ -25,42 +48,29 @@ int main(int, char **)
return 0;
}
InstallerApp::InstallerApp()
: BApplication(APP_SIG)
: BApplication("application/x-vnd.Haiku-Installer")
{
BRect frame = BScreen().Frame();
// show the EULA
BAlert *alert = new BAlert("", EULA_TEXT, " Disagree ", " Agree ", NULL,
B_WIDTH_FROM_WIDEST, B_EMPTY_ALERT);
BTextView *alertView = alert->TextView();
alertView->SetViewColor(255, 255, 255);
BView *parent = alertView->Parent();
alertView->RemoveSelf();
alertView->MoveBy(3, 7);
alertView->ResizeTo(500, 288);
alertView->SetText(EULA_TEXT);
alertView->SetTextRect(alertView->Bounds().InsetBySelf(2, 2));
alert->ResizeTo(525, 350);
BBox *box = new BBox(alertView->Frame().InsetBySelf(-2,-2));
alertView->MoveTo(2, 2);
box->AddChild(alertView);
parent->AddChild(box);
BRect alertFrame = alert->Frame();
alertFrame.OffsetTo((frame.Width() - alertFrame.Width()) / 2,
(frame.Height() - alertFrame.Height()) / 2);
alert->MoveTo(alertFrame.LeftTop());
if (alert->Go() != 1) {
PostMessage(B_QUIT_REQUESTED);
return;
}
BRect windowFrame(0, 0, INSTALLER_RIGHT, 160);
windowFrame.OffsetBy((frame.Width() - windowFrame.Width()) / 2,
frame.Height() / 2 - windowFrame.Height() / 4 - 113);
fWindow = new InstallerWindow(windowFrame);
}
void
InstallerApp::MessageReceived(BMessage* message)
{
switch (message->what) {
case kMsgAgree:
fEULAWindow->Lock();
fEULAWindow->Quit();
new InstallerWindow();
break;
default:
BApplication::MessageReceived(message);
}
}
void
InstallerApp::AboutRequested()
{
@@ -78,13 +88,57 @@ InstallerApp::AboutRequested()
view->SetFontAndColor(0, 14, &font);
alert->Go();
}
void
InstallerApp::ReadyToRun()
{
#if 1
// Show the EULA first.
BTextView* textView = new BTextView("eula", be_plain_font, NULL,
B_WILL_DRAW);
textView->SetInsets(10, 10, 10, 10);
textView->MakeEditable(false);
textView->MakeSelectable(false);
textView->SetText(kEULAText);
BScrollView* scrollView = new BScrollView("eulaScroll",
textView, B_WILL_DRAW, false, true);
BButton* disagreeButton = new BButton("Disagree",
new BMessage(B_QUIT_REQUESTED));
disagreeButton->SetTarget(this);
BButton* agreeButton = new BButton("Agree",
new BMessage(kMsgAgree));
agreeButton->SetTarget(this);
agreeButton->MakeDefault(true);
BRect eulaFrame = BRect(0, 0, 600, 450);
fEULAWindow = new BWindow(eulaFrame, "EULA",
B_MODAL_WINDOW, B_NOT_ZOOMABLE | B_NOT_MINIMIZABLE
| B_AUTO_UPDATE_SIZE_LIMITS);
fEULAWindow->SetLayout(new BGroupLayout(B_HORIZONTAL));
fEULAWindow->AddChild(BGroupLayoutBuilder(B_VERTICAL, 10)
.Add(scrollView)
.Add(BGroupLayoutBuilder(B_HORIZONTAL, 10)
.AddGlue()
.Add(disagreeButton)
.Add(agreeButton)
)
.SetInsets(10, 10, 10, 10)
);
BRect frame = BScreen().Frame();
fEULAWindow->MoveTo(frame.left + (frame.Width() - eulaFrame.Width()) / 2,
frame.top + (frame.Height() - eulaFrame.Height()) / 2);
fEULAWindow->Show();
#else
// Show the installer window without EULA.
new InstallerWindow();
#endif
}
+11 -11
View File
@@ -2,23 +2,23 @@
* Copyright 2005, Jérôme DUVAL. All rights reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef _InstallerApp_h
#define _InstallerApp_h
#ifndef INSTALLER_APP_H
#define INSTALLER_APP_H
#include <Application.h>
#include "InstallerWindow.h"
class InstallerApp : public BApplication {
public:
InstallerApp();
public:
InstallerApp();
public:
virtual void AboutRequested();
virtual void ReadyToRun();
virtual void MessageReceived(BMessage* message);
virtual void AboutRequested();
virtual void ReadyToRun();
private:
InstallerWindow *fWindow;
private:
BWindow* fEULAWindow;
};
#endif /* _InstallerApp_h */
#endif // INSTALLER_APP_H
+193 -96
View File
@@ -1,6 +1,7 @@
/*
* Copyright 2005-2008, Jérôme DUVAL. All rights reserved.
* Distributed under the terms of the MIT License.
* Copyright 2009, Stephan Aßmus <[email protected]>
* Copyright 2005-2008, Jérôme DUVAL.
* All rights reserved. Distributed under the terms of the MIT License.
*/
#include "InstallerWindow.h"
@@ -14,13 +15,21 @@
#include <Box.h>
#include <ClassInfo.h>
#include <Directory.h>
#include <GridLayoutBuilder.h>
#include <GroupLayoutBuilder.h>
#include <LayoutUtils.h>
#include <MenuBar.h>
#include <Path.h>
#include <PopUpMenu.h>
#include <Roster.h>
#include <Screen.h>
#include <SpaceLayoutItem.h>
#include <String.h>
#include <TranslationUtils.h>
#include <TranslatorFormats.h>
#include "tracker_private.h"
#include "DialogPane.h"
#include "PartitionMenuItem.h"
@@ -52,7 +61,8 @@ private:
LogoView::LogoView(const BRect& frame)
:
BView(frame, "logoview", B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW)
BView(frame, "logoview", B_FOLLOW_LEFT | B_FOLLOW_TOP,
B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE)
{
_Init();
}
@@ -60,7 +70,7 @@ LogoView::LogoView(const BRect& frame)
LogoView::LogoView()
:
BView("logoview", B_WILL_DRAW)
BView("logoview", B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE)
{
_Init();
}
@@ -113,119 +123,220 @@ LogoView::_Init()
// #pragma mark -
InstallerWindow::InstallerWindow(BRect frame_rect)
: BWindow(frame_rect, "Installer", B_TITLED_WINDOW,
B_NOT_ZOOMABLE | B_NOT_MINIMIZABLE | B_NOT_RESIZABLE),
class SeparatorView : public BView {
public:
SeparatorView(enum orientation orientation);
virtual ~SeparatorView();
virtual BSize MinSize();
virtual BSize PreferredSize();
virtual BSize MaxSize();
private:
enum orientation fOrientation;
};
SeparatorView::SeparatorView(enum orientation orientation)
:
BView("separator", 0),
fOrientation(orientation)
{
SetViewColor(tint_color(ui_color(B_PANEL_BACKGROUND_COLOR),
B_DARKEN_2_TINT));
}
SeparatorView::~SeparatorView()
{
}
BSize
SeparatorView::MinSize()
{
return BLayoutUtils::ComposeSize(ExplicitMinSize(), BSize(0, 0));
}
BSize
SeparatorView::MaxSize()
{
BSize size(0, 0);
if (fOrientation == B_VERTICAL)
size.height = B_SIZE_UNLIMITED;
else
size.width = B_SIZE_UNLIMITED;
return BLayoutUtils::ComposeSize(ExplicitMaxSize(), size);
}
BSize
SeparatorView::PreferredSize()
{
BSize size(0, 0);
if (fOrientation == B_VERTICAL)
size.height = 10;
else
size.width = 10;
return BLayoutUtils::ComposeSize(ExplicitPreferredSize(), size);
}
// #pragma mark -
InstallerWindow::InstallerWindow()
: BWindow(BRect(-2000, -2000, -1800, -1800), "Installer", B_TITLED_WINDOW,
B_NOT_ZOOMABLE | B_AUTO_UPDATE_SIZE_LIMITS),
fNeedsToCenterOnScreen(true),
fDriveSetupLaunched(false),
fInstallStatus(kReadyForInstall),
fPackagesLayoutItem(NULL),
fSizeViewLayoutItem(NULL),
fLastSrcItem(NULL),
fLastTargetItem(NULL)
{
fCopyEngine = new CopyEngine(this);
BRect bounds = Bounds();
fBackBox = new BBox(bounds, NULL, B_FOLLOW_ALL,
B_WILL_DRAW | B_FRAME_EVENTS, B_NO_BORDER);
AddChild(fBackBox);
LogoView* logoView = new LogoView();
BRect logoRect = fBackBox->Bounds();
logoRect.left += 12;
logoRect.top += 12;
LogoView *logoView = new LogoView(logoRect);
logoView->ResizeToPreferred();
fBackBox->AddChild(logoView);
BRect statusRect(logoView->Frame().right + 14, logoRect.top + 2,
bounds.right - 14, logoView->Frame().bottom - 2);
BRect textRect(statusRect);
textRect.OffsetTo(B_ORIGIN);
textRect.InsetBy(2, 2);
fStatusView = new BTextView(statusRect, "statusView", textRect,
be_plain_font, NULL, B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW);
fStatusView = new BTextView("statusView", be_plain_font, NULL, B_WILL_DRAW);
fStatusView->SetInsets(10, 10, 10, 10);
fStatusView->MakeEditable(false);
fStatusView->MakeSelectable(false);
BScrollView *scroll = new BScrollView("statusScroll", fStatusView,
B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW | B_FRAME_EVENTS);
fBackBox->AddChild(scroll);
BSize logoSize = logoView->MinSize();
fStatusView->SetExplicitMinSize(BSize(logoSize.width * 0.66, B_SIZE_UNSET));
fBeginButton = new BButton(BRect(bounds.right - 90, bounds.bottom - 35,
bounds.right - 11, bounds.bottom - 11),
"begin_button", "Begin", new BMessage(BEGIN_MESSAGE),
B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM);
fBeginButton = new BButton("begin_button", "Begin",
new BMessage(BEGIN_MESSAGE));
fBeginButton->MakeDefault(true);
fBeginButton->SetEnabled(false);
fBackBox->AddChild(fBeginButton);
fSetupButton = new BButton(BRect(bounds.left + 11, bounds.bottom - 35,
bounds.left + be_plain_font->StringWidth("Setup partitions") + 36,
bounds.bottom - 22), "setup_button", "Setup partitions" B_UTF8_ELLIPSIS,
new BMessage(SETUP_MESSAGE), B_FOLLOW_LEFT | B_FOLLOW_BOTTOM);
fBackBox->AddChild(fSetupButton);
fSetupButton->Hide();
fSetupButton = new BButton("setup_button",
"Setup partitions" B_UTF8_ELLIPSIS, new BMessage(SETUP_MESSAGE));
fPackagesView = new PackagesView(BRect(bounds.left + 12, bounds.top + 4,
bounds.right - 15 - B_V_SCROLL_BAR_WIDTH, bounds.bottom - 61),
"packages_view");
fPackagesScrollView = new BScrollView("packagesScroll", fPackagesView,
B_FOLLOW_LEFT | B_FOLLOW_BOTTOM, B_WILL_DRAW, false, true);
fBackBox->AddChild(fPackagesScrollView);
fPackagesScrollView->Hide();
fPackagesView = new PackagesView("packages_view");
BScrollView* packagesScrollView = new BScrollView("packagesScroll",
fPackagesView, B_WILL_DRAW, false, true);
fDrawButton = new PaneSwitch(BRect(bounds.left + 12, bounds.bottom - 33,
bounds.left + 120, bounds.bottom - 20), "options_button");
fDrawButton->SetLabels("Fewer options", "More options");
fDrawButton = new PaneSwitch("options_button");
fDrawButton->SetLabels("Hide Optional Packages", "Show Optional Packages");
fDrawButton->SetMessage(new BMessage(SHOW_BOTTOM_MESSAGE));
fBackBox->AddChild(fDrawButton);
fDrawButton->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNLIMITED));
fDrawButton->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT, B_ALIGN_TOP));
fDestMenu = new BPopUpMenu("scanning" B_UTF8_ELLIPSIS, true, false);
fSrcMenu = new BPopUpMenu("scanning" B_UTF8_ELLIPSIS, true, false);
BRect fieldRect(bounds.left + 13, bounds.top + 70, bounds.right - 13,
bounds.top + 90);
fSrcMenuField = new BMenuField(fieldRect, "srcMenuField",
"Install from: ", fSrcMenu);
fSrcMenuField->SetDivider(bounds.right - 300);
fSrcMenuField = new BMenuField("srcMenuField", "Install from: ", fSrcMenu,
NULL);
fSrcMenuField->SetAlignment(B_ALIGN_RIGHT);
fBackBox->AddChild(fSrcMenuField);
fieldRect.OffsetBy(0, 23);
fDestMenuField = new BMenuField(fieldRect, "destMenuField",
"Onto: ", fDestMenu);
fDestMenuField->SetDivider(bounds.right - 300);
fDestMenuField = new BMenuField("destMenuField", "Onto: ", fDestMenu,
NULL);
fDestMenuField->SetAlignment(B_ALIGN_RIGHT);
fBackBox->AddChild(fDestMenuField);
BRect sizeRect = fBackBox->Bounds();
sizeRect.top = 105;
sizeRect.bottom = sizeRect.top + 15;
sizeRect.right -= 12;
const char* requiredDiskSpaceString = "Disk space required: 0.0 KB";
sizeRect.left = sizeRect.right - be_plain_font->StringWidth(
requiredDiskSpaceString) - 40;
fSizeView = new BStringView(sizeRect, "size_view",
requiredDiskSpaceString, B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM);
const char* requiredDiskSpaceString
= "Additional disk space required: 0.0 KB";
fSizeView = new BStringView("size_view", requiredDiskSpaceString);
fSizeView->SetAlignment(B_ALIGN_RIGHT);
fBackBox->AddChild(fSizeView);
fSizeView->Hide();
fSizeView->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNLIMITED));
fSizeView->SetExplicitAlignment(
BAlignment(B_ALIGN_RIGHT, B_ALIGN_MIDDLE));
SetLayout(new BGroupLayout(B_HORIZONTAL));
AddChild(BGroupLayoutBuilder(B_VERTICAL)
.Add(BGroupLayoutBuilder(B_HORIZONTAL)
.Add(logoView)
.Add(fStatusView)
)
.Add(new SeparatorView(B_HORIZONTAL))
.Add(BGroupLayoutBuilder(B_VERTICAL, 10)
.Add(BGridLayoutBuilder(0, 10)
.Add(fSrcMenuField->CreateLabelLayoutItem(), 0, 0)
.Add(fSrcMenuField->CreateMenuBarLayoutItem(), 1, 0)
.Add(fDestMenuField->CreateLabelLayoutItem(), 0, 1)
.Add(fDestMenuField->CreateMenuBarLayoutItem(), 1, 1)
.Add(BSpaceLayoutItem::CreateVerticalStrut(5), 0, 2, 2)
.Add(fDrawButton, 0, 3, 2)
.Add(packagesScrollView, 0, 4, 2)
.Add(fSizeView, 0, 5, 2)
)
.AddStrut(5)
.Add(BGroupLayoutBuilder(B_HORIZONTAL)
.Add(fSetupButton)
.AddGlue()
.Add(fBeginButton)
)
.SetInsets(10, 10, 10, 10)
)
);
// Make the optional packages invisible on start
BLayout* layout = packagesScrollView->Parent()->GetLayout();
int32 index = layout->IndexOfView(packagesScrollView);
fPackagesLayoutItem = layout->ItemAt(index);
layout = fSizeView->Parent()->GetLayout();
index = layout->IndexOfView(fSizeView);
fSizeViewLayoutItem = layout->ItemAt(index);
fPackagesLayoutItem->SetVisible(false);
fSizeViewLayoutItem->SetVisible(false);
// finish creating window
if (!be_roster->IsRunning(kDeskbarSignature))
SetFlags(Flags() | B_NOT_MINIMIZABLE);
Show();
fDriveSetupLaunched = be_roster->IsRunning(DRIVESETUP_SIG);
if (Lock()) {
fSetupButton->SetEnabled(!fDriveSetupLaunched);
Unlock();
}
be_roster->StartWatching(this);
PostMessage(START_SCAN);
}
InstallerWindow::~InstallerWindow()
{
be_roster->StopWatching(this);
}
void
InstallerWindow::FrameResized(float width, float height)
{
BWindow::FrameResized(width, height);
if (fNeedsToCenterOnScreen) {
// We have created ourselves off-screen, since the size adoption
// because of the layout management may happen after Show(). We
// assume that the first frame event is because of this adoption and
// move ourselves to the screen center...
fNeedsToCenterOnScreen = false;
BRect frame = BScreen(this).Frame();
MoveTo(frame.left + (frame.Width() - Frame().Width()) / 2,
frame.top + (frame.Height() - Frame().Height()) / 2);
}
}
void
InstallerWindow::MessageReceived(BMessage *msg)
{
@@ -290,7 +401,7 @@ InstallerWindow::MessageReceived(BMessage *msg)
char buffer[15];
fPackagesView->GetTotalSizeAsString(buffer);
char string[255];
sprintf(string, "Disk space required: %s", buffer);
sprintf(string, "Additional disk space required: %s", buffer);
fSizeView->SetText(string);
break;
}
@@ -335,6 +446,7 @@ InstallerWindow::MessageReceived(BMessage *msg)
}
}
bool
InstallerWindow::QuitRequested()
{
@@ -353,22 +465,9 @@ InstallerWindow::QuitRequested()
void
InstallerWindow::ShowBottom()
{
if (fDrawButton->Value()) {
ResizeTo(INSTALLER_RIGHT, 306);
if (fSetupButton->IsHidden())
fSetupButton->Show();
if (fPackagesScrollView->IsHidden())
fPackagesScrollView->Show();
if (fSizeView->IsHidden())
fSizeView->Show();
} else {
if (!fSetupButton->IsHidden())
fSetupButton->Hide();
if (!fPackagesScrollView->IsHidden())
fPackagesScrollView->Hide();
if (!fSizeView->IsHidden())
fSizeView->Hide();
ResizeTo(INSTALLER_RIGHT, 160);
if (fPackagesLayoutItem && fSizeViewLayoutItem) {
fPackagesLayoutItem->SetVisible(fDrawButton->Value());
fSizeViewLayoutItem->SetVisible(fDrawButton->Value());
}
}
@@ -438,9 +537,8 @@ InstallerWindow::AdjustMenus()
} else {
if (fSrcMenu->CountItems() == 0)
label = "<none>";
else {
else
label = ((PartitionMenuItem *)fSrcMenu->ItemAt(0))->MenuLabel();
}
}
fSrcMenuField->TruncateString(&label, B_TRUNCATE_END, 260);
fSrcMenuField->MenuItem()->SetLabel(label.String());
@@ -451,9 +549,8 @@ InstallerWindow::AdjustMenus()
} else {
if (fDestMenu->CountItems() == 0)
label = "<none>";
else {
label = ((PartitionMenuItem *)fDestMenu->ItemAt(0))->MenuLabel();
}
else
label = "Please Choose Target";
}
fDestMenuField->TruncateString(&label, B_TRUNCATE_END, 260);
fDestMenuField->MenuItem()->SetLabel(label.String());
+49 -37
View File
@@ -2,8 +2,8 @@
* Copyright 2005, Jérôme DUVAL. All rights reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef _InstallerWindow_h
#define _InstallerWindow_h
#ifndef INSTALLER_WINDOW_H
#define INSTALLER_WINDOW_H
#include <Box.h>
#include <Button.h>
@@ -17,12 +17,12 @@
#include "CopyEngine.h"
#include "PackageViews.h"
#define INSTALLER_RIGHT 402
namespace BPrivate {
class PaneSwitch;
};
class BLayoutItem;
enum InstallStatus {
kReadyForInstall,
kInstalling,
@@ -37,40 +37,52 @@ const char PACKAGES_DIRECTORY[] = "_packages_";
const char VAR_DIRECTORY[] = "var";
class InstallerWindow : public BWindow {
public:
InstallerWindow(BRect frameRect);
virtual ~InstallerWindow();
public:
InstallerWindow();
virtual ~InstallerWindow();
virtual void MessageReceived(BMessage *msg);
virtual bool QuitRequested();
BMenu *GetSourceMenu() { return fSrcMenu; };
BMenu *GetTargetMenu() { return fDestMenu; };
private:
void DisableInterface(bool disable);
void LaunchDriveSetup();
void PublishPackages();
void ShowBottom();
void StartScan();
void AdjustMenus();
void SetStatusMessage(const char *text);
static int ComparePackages(const void *firstArg, const void *secondArg);
BBox *fBackBox;
BButton *fBeginButton, *fSetupButton;
PaneSwitch *fDrawButton;
bool fDriveSetupLaunched;
InstallStatus fInstallStatus;
BTextView *fStatusView;
BMenu* fSrcMenu, *fDestMenu;
BMenuField* fSrcMenuField, *fDestMenuField;
PackagesView *fPackagesView;
BScrollView *fPackagesScrollView;
BStringView *fSizeView;
virtual void FrameResized(float width, float height);
virtual void MessageReceived(BMessage* message);
virtual bool QuitRequested();
BBitmap *fLogo;
BPoint fDrawPoint;
CopyEngine *fCopyEngine;
BString fLastStatus;
BMenuItem *fLastSrcItem, *fLastTargetItem;
BMenu* GetSourceMenu() { return fSrcMenu; };
BMenu* GetTargetMenu() { return fDestMenu; };
private:
void DisableInterface(bool disable);
void LaunchDriveSetup();
void PublishPackages();
void ShowBottom();
void StartScan();
void AdjustMenus();
void SetStatusMessage(const char* text);
static int ComparePackages(const void* firstArg,
const void* secondArg);
BButton* fBeginButton;
BButton* fSetupButton;
PaneSwitch* fDrawButton;
bool fNeedsToCenterOnScreen;
bool fDriveSetupLaunched;
InstallStatus fInstallStatus;
BTextView* fStatusView;
BMenu* fSrcMenu;
BMenu* fDestMenu;
BMenuField* fSrcMenuField;
BMenuField* fDestMenuField;
PackagesView* fPackagesView;
BStringView* fSizeView;
BLayoutItem* fPackagesLayoutItem;
BLayoutItem* fSizeViewLayoutItem;
CopyEngine* fCopyEngine;
BString fLastStatus;
BMenuItem* fLastSrcItem;
BMenuItem* fLastTargetItem;
};
#endif /* _InstallerWindow_h */
#endif // INSTALLER_WINDOW_H
+1 -3
View File
@@ -1,8 +1,6 @@
SubDir HAIKU_TOP src apps installer ;
UsePrivateHeaders shared ;
UsePrivateHeaders storage ;
UsePrivateHeaders tracker ;
UsePrivateHeaders shared storage tracker ;
SubDirHdrs [ FDirName $(HAIKU_TOP) src kits tracker ] ;
Application Installer :
+62 -21
View File
@@ -1,23 +1,31 @@
/*
* Copyright 2005, Jérôme DUVAL. All rights reserved.
* Distributed under the terms of the MIT License.
* Copyright 2009, Stephan Aßmus <superstippi@gmx.de>
* Copyright 2005, Jérôme DUVAL.
* All rights reserved. Distributed under the terms of the MIT License.
*/
#include <fs_attr.h>
#include "PackageViews.h"
#include <stdio.h>
#include <ControlLook.h>
#include <Directory.h>
#include <Entry.h>
#include <fs_attr.h>
#include <LayoutUtils.h>
#include <Messenger.h>
#include <ScrollBar.h>
#include <String.h>
#include <stdio.h>
#include <View.h>
#include "PackageViews.h"
#include "InstallerWindow.h"
#define ICON_ATTRIBUTE "INSTALLER PACKAGE: ICON"
void SizeAsString(off_t size, char *string);
void
SizeAsString(off_t size, char *string)
{
@@ -261,20 +269,6 @@ PackagesView::AddPackages(BList &packages, BMessage *msg)
rect.OffsetBy(0, 20);
}
ResizeTo(bounds.Width(), rect.top);
BScrollBar *vertScroller = ScrollBar(B_VERTICAL);
if (vertScroller->Bounds().Height() > rect.top) {
vertScroller->SetRange(0.0f, 0.0f);
vertScroller->SetValue(0.0f);
} else {
vertScroller->SetRange(0.0f, rect.top
- vertScroller->Bounds().Height());
vertScroller->SetProportion(vertScroller->Bounds().Height() / rect.top);
}
vertScroller->SetSteps(15, vertScroller->Bounds().Height());
Invalidate();
}
@@ -308,15 +302,62 @@ PackagesView::GetPackagesToInstall(BList *list, int32 *size)
}
void
PackagesView::FrameResized(float width, float height)
{
BScrollBar* scrollBar = ScrollBar(B_VERTICAL);
if (scrollBar == NULL)
return;
float virtualHeight = 0.0;
int32 count = CountChildren();
if (count > 0) {
BView* child = ChildAt(count - 1);
virtualHeight = child->Frame().bottom;
}
if (height > virtualHeight) {
scrollBar->SetRange(0.0f, 0.0f);
scrollBar->SetValue(0.0f);
} else {
scrollBar->SetRange(0.0f, virtualHeight - height);
scrollBar->SetProportion(height / virtualHeight);
}
scrollBar->SetSteps(15, height);
}
void
PackagesView::Draw(BRect updateRect)
{
if (CountChildren() > 0)
return;
be_control_look->DrawLabel(this, "No optional packages available.",
Bounds(), updateRect, ViewColor(), BControlLook::B_DISABLED,
BAlignment(B_ALIGN_CENTER, B_ALIGN_MIDDLE));
}
void
PackagesView::GetPreferredSize(float* _width, float* _height)
{
// TODO: Something more nice as default? I need to see how this looks
// when there are actually any packages...
if (_width != NULL)
*_width = 200.0;
*_width = 400.0;
if (_height != NULL)
*_height = 150.0;
*_height = 80.0;
}
BSize
PackagesView::MaxSize()
{
return BLayoutUtils::ComposeSize(ExplicitMaxSize(),
BSize(B_SIZE_UNLIMITED, B_SIZE_UNLIMITED));
}
+3
View File
@@ -113,7 +113,10 @@ public:
void GetTotalSizeAsString(char* string);
void GetPackagesToInstall(BList* list, int32* size);
virtual void FrameResized(float width, float height);
virtual void Draw(BRect updateRect);
virtual void GetPreferredSize(float* _width, float* _height);
virtual BSize MaxSize();
private:
BList fViews;
Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.7 KiB

After

Width:  |  Height:  |  Size: 18 KiB