Preparation for using layout-management, improvements to absolute layout for

the time being.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30354 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stephan Aßmus
2009-04-23 20:04:31 +00:00
parent b9068dbf95
commit 2384ec2866
3 changed files with 88 additions and 26 deletions
+63 -26
View File
@@ -33,26 +33,36 @@ const uint32 SETUP_MESSAGE = 'iSEP';
const uint32 START_SCAN = 'iSSC'; const uint32 START_SCAN = 'iSSC';
const uint32 PACKAGE_CHECKBOX = 'iPCB'; const uint32 PACKAGE_CHECKBOX = 'iPCB';
class LogoView : public BBox { class LogoView : public BView {
public: public:
LogoView(const BRect &r); LogoView(const BRect& frame);
~LogoView(void); LogoView();
virtual void Draw(BRect update); virtual ~LogoView();
private:
BBitmap *fLogo; virtual void Draw(BRect update);
BPoint fDrawPoint;
virtual void GetPreferredSize(float* _width, float* _height);
private:
void _Init();
BBitmap* fLogo;
}; };
LogoView::LogoView(const BRect &r) LogoView::LogoView(const BRect& frame)
: BBox(r, "logoview", B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW, :
B_NO_BORDER) BView(frame, "logoview", B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW)
{ {
fLogo = BTranslationUtils::GetBitmap(B_PNG_FORMAT, "haikulogo.png"); _Init();
if (fLogo) { }
fDrawPoint.x = (r.Width() - fLogo->Bounds().Width()) / 2;
fDrawPoint.y = 0;
} LogoView::LogoView()
:
BView("logoview", B_WILL_DRAW)
{
_Init();
} }
@@ -65,8 +75,38 @@ LogoView::~LogoView(void)
void void
LogoView::Draw(BRect update) LogoView::Draw(BRect update)
{ {
if (fLogo) if (fLogo == NULL)
DrawBitmap(fLogo, fDrawPoint); return;
BRect bounds(Bounds());
BPoint placement;
placement.x = (bounds.left + bounds.right - fLogo->Bounds().Width()) / 2;
placement.y = (bounds.top + bounds.bottom - fLogo->Bounds().Height()) / 2;
DrawBitmap(fLogo, placement);
}
void
LogoView::GetPreferredSize(float* _width, float* _height)
{
float width = 0.0;
float height = 0.0;
if (fLogo) {
width = fLogo->Bounds().Width();
height = fLogo->Bounds().Height();
}
if (_width)
*_width = width;
if (_height)
*_height = height;
}
void
LogoView::_Init()
{
fLogo = BTranslationUtils::GetBitmap(B_PNG_FORMAT, "haikulogo.png");
} }
@@ -84,22 +124,19 @@ InstallerWindow::InstallerWindow(BRect frame_rect)
fCopyEngine = new CopyEngine(this); fCopyEngine = new CopyEngine(this);
BRect bounds = Bounds(); BRect bounds = Bounds();
bounds.bottom += 1;
bounds.right += 1;
fBackBox = new BBox(bounds, NULL, B_FOLLOW_ALL, fBackBox = new BBox(bounds, NULL, B_FOLLOW_ALL,
B_WILL_DRAW | B_FRAME_EVENTS, B_NO_BORDER); B_WILL_DRAW | B_FRAME_EVENTS, B_NO_BORDER);
AddChild(fBackBox); AddChild(fBackBox);
BRect logoRect = fBackBox->Bounds(); BRect logoRect = fBackBox->Bounds();
logoRect.left += 1; logoRect.left += 12;
logoRect.top = 12; logoRect.top += 12;
logoRect.right -= 226;
logoRect.bottom = logoRect.top + 46 + B_H_SCROLL_BAR_HEIGHT;
LogoView *logoView = new LogoView(logoRect); LogoView *logoView = new LogoView(logoRect);
logoView->ResizeToPreferred();
fBackBox->AddChild(logoView); fBackBox->AddChild(logoView);
BRect statusRect(bounds.right - 222, logoRect.top + 2, bounds.right - 14, BRect statusRect(logoView->Frame().right + 14, logoRect.top + 2,
logoRect.bottom - B_H_SCROLL_BAR_HEIGHT + 4); bounds.right - 14, logoView->Frame().bottom - 2);
BRect textRect(statusRect); BRect textRect(statusRect);
textRect.OffsetTo(B_ORIGIN); textRect.OffsetTo(B_ORIGIN);
textRect.InsetBy(2, 2); textRect.InsetBy(2, 2);
+22
View File
@@ -194,12 +194,21 @@ GroupView::~GroupView()
} }
// #pragma mark -
PackagesView::PackagesView(BRect rect, const char* name) PackagesView::PackagesView(BRect rect, const char* name)
: BView(rect, name, B_FOLLOW_ALL_SIDES, B_WILL_DRAW | B_FRAME_EVENTS) : BView(rect, name, B_FOLLOW_ALL_SIDES, B_WILL_DRAW | B_FRAME_EVENTS)
{ {
} }
PackagesView::PackagesView(const char* name)
: BView(name, B_WILL_DRAW | B_FRAME_EVENTS)
{
}
PackagesView::~PackagesView() PackagesView::~PackagesView()
{ {
@@ -298,3 +307,16 @@ PackagesView::GetPackagesToInstall(BList *list, int32 *size)
} }
} }
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;
if (_height != NULL)
*_height = 150.0;
}
+3
View File
@@ -105,6 +105,7 @@ private:
class PackagesView : public BView { class PackagesView : public BView {
public: public:
PackagesView(BRect rect, const char* name); PackagesView(BRect rect, const char* name);
PackagesView(const char* name);
virtual ~PackagesView(); virtual ~PackagesView();
void Clean(); void Clean();
@@ -112,6 +113,8 @@ public:
void GetTotalSizeAsString(char* string); void GetTotalSizeAsString(char* string);
void GetPackagesToInstall(BList* list, int32* size); void GetPackagesToInstall(BList* list, int32* size);
virtual void GetPreferredSize(float* _width, float* _height);
private: private:
BList fViews; BList fViews;
}; };