* Use Layout API.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39197 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Michael Pfeiffer 2010-10-30 08:40:04 +00:00
parent 42c36e9fd3
commit 54336e821e
2 changed files with 26 additions and 23 deletions

View File

@ -26,7 +26,6 @@ public:
void SetPageCopies(uint32 copies);
private:
BView* fStatusView;
BStatusBar* fStatusBar;
BButton* fCancelButton;
BButton* fHideButton;

View File

@ -7,10 +7,13 @@
*/
#include "StatusWindow.h"
#include <Button.h>
#include <GroupLayout.h>
#include <GroupLayoutBuilder.h>
#include <Message.h>
#include <View.h>
#include <StatusBar.h>
#include <Button.h>
#include <stdio.h>
#include <StringView.h>
@ -22,9 +25,11 @@
StatusWindow::StatusWindow(bool oddPages, bool evenPages, uint32 firstPage,
uint32 numPages, uint32 numCopies, uint32 nup)
:
BWindow(BRect(200, 200, 650, 270),
BWindow(BRect(200, 200, 250, 250),
"Print Status",
B_DOCUMENT_WINDOW, B_NOT_RESIZABLE | B_NOT_CLOSABLE | B_NOT_ZOOMABLE)
B_TITLED_WINDOW,
B_NOT_RESIZABLE | B_NOT_CLOSABLE | B_NOT_ZOOMABLE
| B_AUTO_UPDATE_SIZE_LIMITS)
{
// oddPages - if true, only print odd numbered pages
// evenPages - if true, only print even numbered pages
@ -33,30 +38,25 @@ StatusWindow::StatusWindow(bool oddPages, bool evenPages, uint32 firstPage,
// used)
// numCopies - total number of document copies
BRect frame = Frame();
// the status view
frame.OffsetTo(B_ORIGIN);
fStatusView = new BView(frame, "Status View", B_FOLLOW_ALL, B_WILL_DRAW);
fStatusView->SetViewColor(216, 216, 216);
AddChild(fStatusView);
// the status bar
fStatusBar = new BStatusBar(BRect(10, 15, 245, 50), "Status Bar", "Page: ");
fStatusView->AddChild(fStatusBar);
fStatusBar = new BStatusBar("statusBar", "Page: ");
// the cancel button
fHideButton = new BButton(BRect(260, 25, 330, 50), "Hide Button",
"Hide Status", new BMessage(HIDE_MSG));
fHideButton->ResizeToPreferred();
fStatusView->AddChild(fHideButton);
fHideButton = new BButton("hideButton", "Hide Status",
new BMessage(HIDE_MSG));
fCancelButton = new BButton(BRect(260, 25, 330,50), "Cancel Button",
"Cancel", new BMessage(CANCEL_MSG));
fCancelButton->ResizeToPreferred();
fCancelButton->MoveBy(90,0);
fStatusView->AddChild(fCancelButton);
fCancelButton = new BButton("cancelButton", "Cancel",
new BMessage(CANCEL_MSG));
SetLayout(new BGroupLayout(B_VERTICAL));
AddChild(BGroupLayoutBuilder(B_HORIZONTAL, 10)
.Add(fStatusBar)
.Add(fHideButton)
.Add(fCancelButton)
.SetInsets(10, 10, 10, 10)
);
fCancelled = false;
// calculate the real number of pages
@ -114,6 +114,7 @@ StatusWindow::ResetStatusBar(void)
{
Lock();
fStatusBar->Reset("Page: ");
InvalidateLayout(true);
Unlock();
}
@ -151,6 +152,8 @@ StatusWindow::UpdateStatusBar(uint32 page, uint32 copy)
string1.String(), string3.String());
if (fStatusBar->MaxValue() == fStatusBar->CurrentValue())
fCancelButton->SetEnabled(false);
InvalidateLayout(true);
Unlock();
return fCancelled;
}
@ -175,6 +178,7 @@ StatusWindow::MessageReceived(BMessage *message)
fCancelled = true;
fCancelButton->SetEnabled(false);
fCancelButton->SetLabel("Job cancelled");
InvalidateLayout(true);
break;
case HIDE_MSG: // 'HideButton' is pressed...