Code cleanup, no functional change except for changing BWindow::Run() into

a BWindow::Hide()-BWindow::Show() combo.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34095 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stephan Aßmus
2009-11-17 16:10:18 +00:00
parent dcf71e1cae
commit 9d6405b724
2 changed files with 357 additions and 319 deletions
+303 -285
View File
@@ -32,8 +32,10 @@ names are registered trademarks or trademarks of their respective holders.
All rights reserved. All rights reserved.
*/ */
// A subclass of BWindow that is used to display /*! A subclass of BWindow that is used to display the status of the Tracker
// the status of the tracker (Copying, Deleting, etc.). operations (copying, deleting, etc.).
*/
#include <Application.h> #include <Application.h>
#include <Button.h> #include <Button.h>
@@ -58,20 +60,18 @@ const BRect kStatusRect(200, 200, 550, 200);
class TCustomButton : public BButton { class TCustomButton : public BButton {
public: public:
TCustomButton(BRect frame, uint32 command); TCustomButton(BRect frame, uint32 command);
virtual void Draw(BRect); virtual void Draw(BRect updateRect);
private: private:
typedef BButton _inherited; typedef BButton _inherited;
}; };
class BStatusMouseFilter : public BMessageFilter {
public:
BStatusMouseFilter()
: BMessageFilter(B_ANY_DELIVERY, B_ANY_SOURCE, B_MOUSE_DOWN)
{}
virtual filter_result Filter(BMessage *message, BHandler **target); class BStatusMouseFilter : public BMessageFilter {
public:
BStatusMouseFilter();
virtual filter_result Filter(BMessage* message, BHandler** target);
}; };
@@ -80,15 +80,24 @@ BStatusWindow *gStatusWindow = NULL;
} }
filter_result BStatusMouseFilter::BStatusMouseFilter()
BStatusMouseFilter::Filter(BMessage *, BHandler **target) :
BMessageFilter(B_ANY_DELIVERY, B_ANY_SOURCE, B_MOUSE_DOWN)
{ {
if ((*target)->Name() }
filter_result
BStatusMouseFilter::Filter(BMessage* message, BHandler** target)
{
// If the target is the status bar, make sure the message goes to the
// parent view instead.
if ((*target)->Name() != NULL
&& strcmp((*target)->Name(), "StatusBar") == 0) { && strcmp((*target)->Name(), "StatusBar") == 0) {
BView *view = dynamic_cast<BView *>(*target); BView* view = dynamic_cast<BView*>(*target);
if (view) if (view != NULL)
view = view->Parent(); view = view->Parent();
if (view) if (view != NULL)
*target = view; *target = view;
} }
@@ -97,8 +106,9 @@ BStatusMouseFilter::Filter(BMessage *, BHandler **target)
TCustomButton::TCustomButton(BRect frame, uint32 what) TCustomButton::TCustomButton(BRect frame, uint32 what)
: BButton(frame, "", "", new BMessage(what), B_FOLLOW_LEFT | B_FOLLOW_TOP, :
B_WILL_DRAW) BButton(frame, "", "", new BMessage(what), B_FOLLOW_LEFT | B_FOLLOW_TOP,
B_WILL_DRAW)
{ {
} }
@@ -135,10 +145,11 @@ TCustomButton::Draw(BRect updateRect)
BStatusWindow::BStatusWindow() BStatusWindow::BStatusWindow()
: BWindow(kStatusRect, "Tracker Status", B_TITLED_WINDOW, :
B_NOT_CLOSABLE | B_NOT_RESIZABLE | B_NOT_ZOOMABLE, BWindow(kStatusRect, "Tracker Status", B_TITLED_WINDOW,
B_ALL_WORKSPACES), B_NOT_CLOSABLE | B_NOT_RESIZABLE | B_NOT_ZOOMABLE,
fRetainDesktopFocus(false) B_ALL_WORKSPACES),
fRetainDesktopFocus(false)
{ {
SetSizeLimits(0, 100000, 0, 100000); SetSizeLimits(0, 100000, 0, 100000);
fMouseDownFilter = new BStatusMouseFilter(); fMouseDownFilter = new BStatusMouseFilter();
@@ -146,11 +157,12 @@ BStatusWindow::BStatusWindow()
BRect bounds(Bounds()); BRect bounds(Bounds());
BView *view = new BView(bounds, "BackView", B_FOLLOW_ALL, B_WILL_DRAW); BView* view = new BView(bounds, "BackView", B_FOLLOW_ALL, B_WILL_DRAW);
view->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); view->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
AddChild(view); AddChild(view);
Run(); Hide();
Show();
} }
@@ -159,13 +171,160 @@ BStatusWindow::~BStatusWindow()
} }
void
BStatusWindow::CreateStatusItem(thread_id thread, StatusWindowState type)
{
AutoLock<BWindow> lock(this);
BRect rect(Bounds());
if (BStatusView* lastView = fViewList.LastItem())
rect.top = lastView->Frame().bottom + 1;
rect.bottom = rect.top + kDefaultStatusViewHeight - 1;
BStatusView* view = new BStatusView(rect, thread, type);
// the BStatusView will resize itself if needed in its constructor
ChildAt(0)->AddChild(view);
fViewList.AddItem(view);
ResizeTo(Bounds().Width(), view->Frame().bottom);
// find out if the desktop is the active window
// if the status window is the only thing to take over active state and
// desktop was active to begin with, return focus back to desktop
// when we are done
bool desktopActive = false;
{
AutoLock<BLooper> lock(be_app);
int32 count = be_app->CountWindows();
for (int32 index = 0; index < count; index++) {
if (dynamic_cast<BDeskWindow *>(be_app->WindowAt(index))
&& be_app->WindowAt(index)->IsActive()) {
desktopActive = true;
break;
}
}
}
if (IsHidden()) {
fRetainDesktopFocus = desktopActive;
Minimize(false);
Show();
} else
fRetainDesktopFocus &= desktopActive;
}
void
BStatusWindow::InitStatusItem(thread_id thread, int32 totalItems,
off_t totalSize, const entry_ref* destDir, bool showCount)
{
AutoLock<BWindow> lock(this);
int32 numItems = fViewList.CountItems();
for (int32 index = 0; index < numItems; index++) {
BStatusView* view = fViewList.ItemAt(index);
if (view->Thread() == thread) {
view->InitStatus(totalItems, totalSize, destDir, showCount);
break;
}
}
}
void
BStatusWindow::UpdateStatus(thread_id thread, const char* curItem,
off_t itemSize, bool optional)
{
AutoLock<BWindow> lock(this);
int32 numItems = fViewList.CountItems();
for (int32 index = 0; index < numItems; index++) {
BStatusView* view = fViewList.ItemAt(index);
if (view->Thread() == thread) {
view->UpdateStatus(curItem, itemSize, optional);
break;
}
}
}
void
BStatusWindow::RemoveStatusItem(thread_id thread)
{
AutoLock<BWindow> lock(this);
BStatusView* winner = NULL;
int32 numItems = fViewList.CountItems();
int32 index;
for (index = 0; index < numItems; index++) {
BStatusView* view = fViewList.ItemAt(index);
if (view->Thread() == thread) {
winner = view;
break;
}
}
if (winner != NULL) {
// The height by which the other views will have to be moved (in pixel
// count).
float height = winner->Bounds().Height() + 1;
fViewList.RemoveItem(winner);
winner->RemoveSelf();
delete winner;
if (--numItems == 0 && !IsHidden()) {
BDeskWindow* desktop = NULL;
if (fRetainDesktopFocus) {
AutoLock<BLooper> lock(be_app);
int32 count = be_app->CountWindows();
for (int32 index = 0; index < count; index++) {
desktop = dynamic_cast<BDeskWindow*>(
be_app->WindowAt(index));
if (desktop != NULL)
break;
}
}
Hide();
if (desktop != NULL) {
// desktop was active when we first started,
// make it active again
desktop->Activate();
}
}
for (; index < numItems; index++)
fViewList.ItemAt(index)->MoveBy(0, -height);
ResizeTo(Bounds().Width(), Bounds().Height() - height);
}
}
bool
BStatusWindow::HasStatus(thread_id thread)
{
AutoLock<BWindow> lock(this);
int32 numItems = fViewList.CountItems();
for (int32 index = 0; index < numItems; index++) {
BStatusView* view = fViewList.ItemAt(index);
if (view->Thread() == thread)
return true;
}
return false;
}
bool bool
BStatusWindow::CheckCanceledOrPaused(thread_id thread) BStatusWindow::CheckCanceledOrPaused(thread_id thread)
{ {
bool wasCanceled = false; bool wasCanceled = false;
bool isPaused = false; bool isPaused = false;
BStatusView *view = NULL; BStatusView* view = NULL;
for (;;) { for (;;) {
@@ -185,7 +344,7 @@ BStatusWindow::CheckCanceledOrPaused(thread_id thread)
if (wasCanceled || !isPaused) if (wasCanceled || !isPaused)
break; break;
if (isPaused && view) { if (isPaused && view != NULL) {
AutoLock<BWindow> lock(this); AutoLock<BWindow> lock(this);
// say we are paused // say we are paused
view->Invalidate(); view->Invalidate();
@@ -224,49 +383,6 @@ BStatusWindow::AttemptToQuit()
} }
void
BStatusWindow::CreateStatusItem(thread_id thread, StatusWindowState type)
{
AutoLock<BWindow> lock(this);
BRect rect(Bounds());
if (BStatusView* lastView = fViewList.LastItem())
rect.top = lastView->Frame().bottom + 1;
rect.bottom = rect.top + kDefaultStatusViewHeight - 1;
BStatusView *view = new BStatusView(rect, thread, type);
// the BStatusView will resize itself if needed in its constructor
ChildAt(0)->AddChild(view);
fViewList.AddItem(view);
ResizeTo(Bounds().Width(), view->Frame().bottom);
// find out if the desktop is the active window
// if the status window is the only thing to take over active state and
// desktop was active to begin with, return focus back to desktop
// when we are done
bool desktopActive = false;
{
AutoLock<BLooper> lock(be_app);
int32 count = be_app->CountWindows();
for (int32 index = 0; index < count; index++) {
if (dynamic_cast<BDeskWindow *>(be_app->WindowAt(index))
&& be_app->WindowAt(index)->IsActive()) {
desktopActive = true;
break;
}
}
}
if (IsHidden()) {
fRetainDesktopFocus = desktopActive;
Minimize(false);
Show();
} else
fRetainDesktopFocus &= desktopActive;
}
void void
BStatusWindow::WindowActivated(bool state) BStatusWindow::WindowActivated(bool state)
{ {
@@ -277,118 +393,19 @@ BStatusWindow::WindowActivated(bool state)
} }
void // #pragma mark - BStatusView
BStatusWindow::RemoveStatusItem(thread_id thread)
{
AutoLock<BWindow> lock(this);
BStatusView *winner = NULL;
int32 numItems = fViewList.CountItems();
int32 index;
for (index = 0; index < numItems; index++) {
BStatusView *view = fViewList.ItemAt(index);
if (view->Thread() == thread) {
winner = view;
break;
}
}
if (winner) {
// the height by which the other views will have to be moved (in pixel count)
float height = winner->Bounds().Height() + 1;
fViewList.RemoveItem(winner);
winner->RemoveSelf();
delete winner;
if (--numItems == 0 && !IsHidden()) {
BDeskWindow *desktop = NULL;
if (fRetainDesktopFocus) {
AutoLock<BLooper> lock(be_app);
int32 count = be_app->CountWindows();
for (int32 index = 0; index < count; index++) {
desktop = dynamic_cast<BDeskWindow *>(be_app->WindowAt(index));
if (desktop)
break;
}
}
Hide();
if (desktop)
// desktop was active when we first started,
// make it active again
desktop->Activate();
}
for (; index < numItems; index++)
fViewList.ItemAt(index)->MoveBy(0, -height);
ResizeTo(Bounds().Width(), Bounds().Height() - height);
}
}
bool BStatusView::BStatusView(BRect bounds, thread_id thread,
BStatusWindow::HasStatus(thread_id thread) StatusWindowState type)
{ :
AutoLock<BWindow> lock(this); BView(bounds, "StatusView", B_FOLLOW_NONE, B_WILL_DRAW),
fType(type),
int32 numItems = fViewList.CountItems(); fBitmap(NULL),
for (int32 index = 0; index < numItems; index++) { fThread(thread)
BStatusView *view = fViewList.ItemAt(index);
if (view->Thread() == thread)
return true;
}
return false;
}
void
BStatusWindow::UpdateStatus(thread_id thread, const char *curItem, off_t itemSize,
bool optional)
{
AutoLock<BWindow> lock(this);
int32 numItems = fViewList.CountItems();
for (int32 index = 0; index < numItems; index++) {
BStatusView *view = fViewList.ItemAt(index);
if (view->Thread() == thread) {
view->UpdateStatus(curItem, itemSize, optional);
break;
}
}
}
void
BStatusWindow::InitStatusItem(thread_id thread, int32 totalItems, off_t totalSize,
const entry_ref *destDir, bool showCount)
{
AutoLock<BWindow> lock(this);
int32 numItems = fViewList.CountItems();
for (int32 index = 0; index < numItems; index++) {
BStatusView *view = fViewList.ItemAt(index);
if (view->Thread() == thread) {
view->InitStatus(totalItems, totalSize, destDir, showCount);
break;
}
}
}
BStatusView::BStatusView(BRect bounds, thread_id thread, StatusWindowState type)
: BView(bounds, "StatusView", B_FOLLOW_NONE, B_WILL_DRAW),
fBitmap(NULL)
{ {
Init(); Init();
fThread = thread;
fType = type;
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
SetLowColor(ViewColor()); SetLowColor(ViewColor());
SetHighColor(20, 20, 20); SetHighColor(20, 20, 20);
@@ -404,8 +421,7 @@ BStatusView::BStatusView(BRect bounds, thread_id thread, StatusWindowState type)
rect.top += 6; rect.top += 6;
rect.bottom = rect.top + 15; rect.bottom = rect.top + 15;
const char* caption = NULL;
const char *caption = NULL;
int32 id = 0; int32 id = 0;
switch (type) { switch (type) {
@@ -429,7 +445,6 @@ BStatusView::BStatusView(BRect bounds, thread_id thread, StatusWindowState type)
id = kResTrashStatusBitmap; id = kResTrashStatusBitmap;
break; break;
case kVolumeState: case kVolumeState:
caption = "Searching for disks to mount" B_UTF8_ELLIPSIS; caption = "Searching for disks to mount" B_UTF8_ELLIPSIS;
break; break;
@@ -448,7 +463,7 @@ BStatusView::BStatusView(BRect bounds, thread_id thread, StatusWindowState type)
break; break;
} }
if (caption) { if (caption != NULL) {
fStatusBar = new BStatusBar(rect, "StatusBar", caption); fStatusBar = new BStatusBar(rect, "StatusBar", caption);
fStatusBar->SetBarHeight(12); fStatusBar->SetBarHeight(12);
float width, height; float width, height;
@@ -456,16 +471,18 @@ BStatusView::BStatusView(BRect bounds, thread_id thread, StatusWindowState type)
fStatusBar->ResizeTo(fStatusBar->Frame().Width(), height); fStatusBar->ResizeTo(fStatusBar->Frame().Width(), height);
AddChild(fStatusBar); AddChild(fStatusBar);
// figure out how much room we need to display // Figure out how much room we need to display the additional status
// the additional status message below the bar // message below the bar
font_height fh; font_height fh;
GetFontHeight(&fh); GetFontHeight(&fh);
BRect f = fStatusBar->Frame(); BRect f = fStatusBar->Frame();
// height is 3 x the "room from the top" + bar height + room for string // Height is 3 x the "room from the top" + bar height + room for
ResizeTo(Bounds().Width(), f.top + f.Height() + fh.leading + fh.ascent + fh.descent + f.top); // string.
ResizeTo(Bounds().Width(), f.top + f.Height() + fh.leading + fh.ascent
+ fh.descent + f.top);
} }
if (id) if (id != 0)
GetTrackerResources()->GetBitmapResource(B_MESSAGE_TYPE, id, &fBitmap); GetTrackerResources()->GetBitmapResource(B_MESSAGE_TYPE, id, &fBitmap);
rect = Bounds(); rect = Bounds();
@@ -504,17 +521,9 @@ BStatusView::Init()
} }
void
BStatusView::AttachedToWindow()
{
fPauseButton->SetTarget(this);
fStopButton->SetTarget(this);
}
void void
BStatusView::InitStatus(int32 totalItems, off_t totalSize, BStatusView::InitStatus(int32 totalItems, off_t totalSize,
const entry_ref *destDir, bool showCount) const entry_ref* destDir, bool showCount)
{ {
Init(); Init();
fTotalSize = totalSize; fTotalSize = totalSize;
@@ -545,7 +554,8 @@ BStatusView::InitStatus(int32 totalItems, off_t totalSize,
break; break;
case kTrashState: case kTrashState:
fStatusBar->Reset("Emptying Trash" B_UTF8_ELLIPSIS " ", buffer.String()); fStatusBar->Reset("Emptying Trash" B_UTF8_ELLIPSIS " ",
buffer.String());
break; break;
case kDeleteState: case kDeleteState:
@@ -566,93 +576,6 @@ BStatusView::InitStatus(int32 totalItems, off_t totalSize,
} }
void
BStatusView::UpdateStatus(const char *curItem, off_t itemSize, bool optional)
{
float currentTime = system_time();
if (fShowCount) {
if (curItem)
fCurItem++;
fItemSize += itemSize;
if (!optional || ((currentTime - fLastUpdateTime) > kUpdateGrain)) {
if (curItem != NULL || fPendingStatusString[0]) {
// forced update or past update time
BString buffer;
buffer << fCurItem << " ";
// if we don't have curItem, take the one from the stash
const char *statusItem = curItem != NULL
? curItem : fPendingStatusString;
fStatusBar->Update((float)fItemSize / fTotalSize, statusItem,
buffer.String());
// we already displayed this item, clear the stash
fPendingStatusString[0] = '\0';
fLastUpdateTime = currentTime;
}
else
// don't have a file to show, just update the bar
fStatusBar->Update((float)fItemSize / fTotalSize);
fItemSize = 0;
} else if (curItem != NULL) {
// stash away the name of the item we are currently processing
// so we can show it when the time comes
strncpy(fPendingStatusString, curItem, 127);
fPendingStatusString[127] = '0';
}
} else {
fStatusBar->Update((float)fItemSize / fTotalSize);
fItemSize = 0;
}
}
void
BStatusView::MessageReceived(BMessage *message)
{
switch (message->what) {
case kPauseButton:
fIsPaused = !fIsPaused;
fPauseButton->SetValue(fIsPaused ? B_CONTROL_ON : B_CONTROL_OFF);
if (!fIsPaused) {
// force window update
Invalidate();
// let 'er rip
resume_thread(Thread());
}
break;
case kStopButton:
fWasCanceled = true;
if (fIsPaused) {
// resume so that the copy loop gets a chance to finish up
fIsPaused = false;
// force window update
Invalidate();
// let 'er rip
resume_thread(Thread());
}
break;
default:
_inherited::MessageReceived(message);
break;
}
}
void void
BStatusView::Draw(BRect updateRect) BStatusView::Draw(BRect updateRect)
{ {
@@ -702,6 +625,101 @@ BStatusView::Draw(BRect updateRect)
} }
void
BStatusView::AttachedToWindow()
{
fPauseButton->SetTarget(this);
fStopButton->SetTarget(this);
}
void
BStatusView::MessageReceived(BMessage *message)
{
switch (message->what) {
case kPauseButton:
fIsPaused = !fIsPaused;
fPauseButton->SetValue(fIsPaused ? B_CONTROL_ON : B_CONTROL_OFF);
if (!fIsPaused) {
// force window update
Invalidate();
// let 'er rip
resume_thread(Thread());
}
break;
case kStopButton:
fWasCanceled = true;
if (fIsPaused) {
// resume so that the copy loop gets a chance to finish up
fIsPaused = false;
// force window update
Invalidate();
// let 'er rip
resume_thread(Thread());
}
break;
default:
_inherited::MessageReceived(message);
break;
}
}
void
BStatusView::UpdateStatus(const char *curItem, off_t itemSize, bool optional)
{
float currentTime = system_time();
if (fShowCount) {
if (curItem)
fCurItem++;
fItemSize += itemSize;
if (!optional || ((currentTime - fLastUpdateTime) > kUpdateGrain)) {
if (curItem != NULL || fPendingStatusString[0]) {
// forced update or past update time
BString buffer;
buffer << fCurItem << " ";
// if we don't have curItem, take the one from the stash
const char *statusItem = curItem != NULL
? curItem : fPendingStatusString;
fStatusBar->Update((float)fItemSize / fTotalSize, statusItem,
buffer.String());
// we already displayed this item, clear the stash
fPendingStatusString[0] = '\0';
fLastUpdateTime = currentTime;
}
else
// don't have a file to show, just update the bar
fStatusBar->Update((float)fItemSize / fTotalSize);
fItemSize = 0;
} else if (curItem != NULL) {
// stash away the name of the item we are currently processing
// so we can show it when the time comes
strncpy(fPendingStatusString, curItem, 127);
fPendingStatusString[127] = '0';
}
} else {
fStatusBar->Update((float)fItemSize / fTotalSize);
fItemSize = 0;
}
}
void void
BStatusView::SetWasCanceled() BStatusView::SetWasCanceled()
{ {
+76 -56
View File
@@ -31,10 +31,10 @@ of Be Incorporated in the United States and other countries. Other brand product
names are registered trademarks or trademarks of their respective holders. names are registered trademarks or trademarks of their respective holders.
All rights reserved. All rights reserved.
*/ */
#ifndef STATUS_WINDOW_H #ifndef STATUS_WINDOW_H
#define STATUS_WINDOW_H #define STATUS_WINDOW_H
#include <Window.h> #include <Window.h>
#include <View.h> #include <View.h>
#include <Bitmap.h> #include <Bitmap.h>
@@ -43,8 +43,10 @@ All rights reserved.
#include "ObjectList.h" #include "ObjectList.h"
namespace BPrivate { namespace BPrivate {
enum StatusWindowState { enum StatusWindowState {
kCopyState, kCopyState,
kMoveState, kMoveState,
@@ -57,105 +59,123 @@ enum StatusWindowState {
class BStatusView; class BStatusView;
class BStatusWindow : public BWindow { class BStatusWindow : public BWindow {
public: public:
BStatusWindow(); BStatusWindow();
~BStatusWindow(); virtual ~BStatusWindow();
void CreateStatusItem(thread_id, StatusWindowState);
void InitStatusItem(thread_id, int32 totalItems, off_t totalSize,
const entry_ref *destDir = NULL, bool showCount = true);
void UpdateStatus(thread_id, const char *curItem, off_t itemSize, bool optional = false);
// if true is passed in <optional> status will only
// be updated if 0.2 seconds elapsed since the last update
void RemoveStatusItem(thread_id);
bool HasStatus(thread_id);
bool CheckCanceledOrPaused(thread_id);
void UpdateButtonState();
bool AttemptToQuit(); void CreateStatusItem(thread_id,
// called by the tracker app during quit time, before StatusWindowState);
// inherited QuitRequested; kills all the copy/move/empty trash void InitStatusItem(thread_id, int32 totalItems,
// threads in a clean way by issuing a cancel off_t totalSize,
const entry_ref* destDir = NULL,
bool showCount = true);
void UpdateStatus(thread_id, const char* curItem,
off_t itemSize, bool optional = false);
// If true is passed in <optional> status
// will only be updated if 0.2 seconds
// elapsed since the last update
void RemoveStatusItem(thread_id);
bool HasStatus(thread_id);
bool CheckCanceledOrPaused(thread_id);
bool AttemptToQuit();
// Called by the tracker app during quit
// time, before inherited QuitRequested;
// kills all the copy/move/empty trash
// threads in a clean way by issuing a
// cancel.
protected: protected:
virtual void WindowActivated(bool state); virtual void WindowActivated(bool state);
private: private:
BObjectList<BStatusView> fViewList; BObjectList<BStatusView> fViewList;
BMessageFilter *fMouseDownFilter; BMessageFilter* fMouseDownFilter;
bool fRetainDesktopFocus; bool fRetainDesktopFocus;
typedef BWindow _inherited; typedef BWindow _inherited;
}; };
class BStatusView : public BView { class BStatusView : public BView {
public: public:
BStatusView(BRect, thread_id, StatusWindowState); BStatusView(BRect frame, thread_id,
virtual ~BStatusView(); StatusWindowState state);
virtual ~BStatusView();
void Init(); void Init();
void InitStatus(int32 totalItems, off_t totalSize, const entry_ref *destDir, void InitStatus(int32 totalItems, off_t totalSize,
bool showCount); const entry_ref* destDir, bool showCount);
// BView overrides // BView overrides
virtual void Draw(BRect); virtual void Draw(BRect updateRect);
virtual void AttachedToWindow(); virtual void AttachedToWindow();
virtual void MessageReceived(BMessage *); virtual void MessageReceived(BMessage* message);
void UpdateStatus(const char *curItem, off_t itemSize, bool optional = false);
// if true is passed in <optional> status will only
// be updated if 0.2 seconds elapsed since the last update
bool WasCanceled() const; void UpdateStatus(const char* currentItem,
bool IsPaused() const; off_t itemSize, bool optional = false);
thread_id Thread() const; // If true is passed in <optional> status
// will only be updated if 0.2 seconds
// elapsed since the last update.
void ForceQuit(); bool WasCanceled() const;
void SetWasCanceled(); bool IsPaused() const;
// called by AboutToQuit thread_id Thread() const;
void SetWasCanceled();
// called by AboutToQuit
private: private:
BStatusBar *fStatusBar; BStatusBar* fStatusBar;
off_t fTotalSize; off_t fTotalSize;
off_t fItemSize; off_t fItemSize;
int32 fCurItem; int32 fCurItem;
int32 fType; int32 fType;
BBitmap *fBitmap; BBitmap* fBitmap;
BButton *fStopButton; BButton* fStopButton;
BButton *fPauseButton; BButton* fPauseButton;
thread_id fThread; thread_id fThread;
float fLastUpdateTime; float fLastUpdateTime;
bool fShowCount; bool fShowCount;
bool fWasCanceled; bool fWasCanceled;
bool fIsPaused; bool fIsPaused;
BString fDestDir; BString fDestDir;
char fPendingStatusString[128]; char fPendingStatusString[128];
typedef BView _inherited; typedef BView _inherited;
}; };
inline bool inline bool
BStatusView::IsPaused() const BStatusView::IsPaused() const
{ {
return fIsPaused; return fIsPaused;
} }
inline bool inline bool
BStatusView::WasCanceled() const BStatusView::WasCanceled() const
{ {
return fWasCanceled; return fWasCanceled;
} }
inline thread_id inline thread_id
BStatusView::Thread() const BStatusView::Thread() const
{ {
return fThread; return fThread;
} }
extern BStatusWindow *gStatusWindow; extern BStatusWindow *gStatusWindow;
} // namespace BPrivate } // namespace BPrivate
using namespace BPrivate; using namespace BPrivate;
#endif #endif // STATUS_WINDOW_H