added sizes for packages

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14235 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Jérôme Duval 2005-09-24 16:58:17 +00:00
parent 8d71ca3e25
commit f66f06160a
3 changed files with 25 additions and 2 deletions

View File

@ -48,7 +48,7 @@ InstallerWindow::InstallerWindow(BRect frame_rect)
BScrollView *scroll = new BScrollView("statusScroll", fStatusView, B_FOLLOW_LEFT|B_FOLLOW_TOP, B_WILL_DRAW|B_FRAME_EVENTS); BScrollView *scroll = new BScrollView("statusScroll", fStatusView, B_FOLLOW_LEFT|B_FOLLOW_TOP, B_WILL_DRAW|B_FRAME_EVENTS);
fBackBox->AddChild(scroll); fBackBox->AddChild(scroll);
fBeginButton = new BButton(BRect(bounds.right-90, bounds.bottom-35, bounds.right-10, bounds.bottom-11), 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); "begin_button", "Begin", new BMessage(BEGIN_MESSAGE), B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM);
fBeginButton->MakeDefault(true); fBeginButton->MakeDefault(true);
fBackBox->AddChild(fBeginButton); fBackBox->AddChild(fBeginButton);

View File

@ -6,6 +6,7 @@
#include <Directory.h> #include <Directory.h>
#include <ScrollBar.h> #include <ScrollBar.h>
#include <String.h> #include <String.h>
#include <stdio.h>
#include <View.h> #include <View.h>
#include "PackageViews.h" #include "PackageViews.h"
@ -66,6 +67,24 @@ err:
} }
void
Package::GetSizeAsString(char *string)
{
float kb = fSize / 1024.0;
if (kb < 1.0) {
sprintf(string, "%ld B", fSize);
return;
}
float mb = kb / 1024.0;
if (mb < 1.0) {
sprintf(string, "%3.1f KB", kb);
return;
}
sprintf(string, "%3.1f MB", mb);
}
Group::Group() Group::Group()
: fGroup(NULL) : fGroup(NULL)
{ {
@ -94,9 +113,12 @@ void
PackageCheckBox::Draw(BRect update) PackageCheckBox::Draw(BRect update)
{ {
BCheckBox::Draw(update); BCheckBox::Draw(update);
char string[255];
fPackage.GetSizeAsString(string);
float width = StringWidth(string);
DrawString(string, BPoint(Bounds().right - width - 8, 11));
} }
GroupView::GroupView(BRect rect, Group &group) GroupView::GroupView(BRect rect, Group &group)
: BStringView(rect, "group", group.GroupName()), : BStringView(rect, "group", group.GroupName()),
fGroup(group) fGroup(group)

View File

@ -36,6 +36,7 @@ public:
const char * Name() const { return fName; }; const char * Name() const { return fName; };
const char * Description() const { return fDescription; }; const char * Description() const { return fDescription; };
const int32 Size() const { return fSize; }; const int32 Size() const { return fSize; };
void GetSizeAsString(char *string);
const BBitmap * Icon() const { return fIcon; }; const BBitmap * Icon() const { return fIcon; };
bool OnByDefault() const { return fOnByDefault; }; bool OnByDefault() const { return fOnByDefault; };
bool AlwaysOn() const { return fAlwaysOn; }; bool AlwaysOn() const { return fAlwaysOn; };