6 Copyright (c) 1991-2000, Be Incorporated. All rights reserved.
8 Permission is hereby granted, free of charge, to any person obtaining a copy of
9 this software and associated documentation files (the "Software"), to deal in
10 the Software without restriction, including without limitation the rights to
11 use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
12 of the Software, and to permit persons to whom the Software is furnished to do
13 so, subject to the following conditions:
15 The above copyright notice and this permission notice applies to all licensees
16 and shall be included in all copies or substantial portions of the Software.
18 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF TITLE, MERCHANTABILITY,
20 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
21 BE INCORPORATED BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
22 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF, OR IN CONNECTION
23 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 Except as contained in this notice, the name of Be Incorporated shall not be
26 used in advertising or otherwise to promote the sale, use or other dealings in
27 this Software without prior written authorization from Be Incorporated.
29 Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered trademarks
30 of Be Incorporated in the United States and other countries. Other brand product
31 names are registered trademarks or trademarks of their respective holders.
34 #ifndef _STATUS_WINDOW_H
35 #define _STATUS_WINDOW_H
39 #include <ObjectList.h>
40 #include <StatusBar.h>
49 enum StatusWindowState
{
56 kRestoreFromTrashState
62 class BStatusWindow
: public BWindow
{
65 virtual ~BStatusWindow();
67 void CreateStatusItem(thread_id
,
69 void InitStatusItem(thread_id
, int32 totalItems
,
71 const entry_ref
* destDir
= NULL
,
72 bool showCount
= true);
73 void UpdateStatus(thread_id
, const char* curItem
,
74 off_t itemSize
, bool optional
= false);
75 // If true is passed in <optional> status
76 // will only be updated if 0.2 seconds
77 // elapsed since the last update
78 void RemoveStatusItem(thread_id
);
80 bool CheckCanceledOrPaused(thread_id
);
83 // Called by the tracker app during quit
84 // time, before inherited QuitRequested;
85 // kills all the copy/move/empty trash
86 // threads in a clean way by issuing a
89 virtual void WindowActivated(bool state
);
92 BObjectList
<BStatusView
> fViewList
;
93 BMessageFilter
* fMouseDownFilter
;
95 bool fRetainDesktopFocus
;
97 typedef BWindow _inherited
;
101 class BStatusView
: public BView
{
103 BStatusView(BRect frame
, thread_id
,
104 StatusWindowState state
);
105 virtual ~BStatusView();
109 void InitStatus(int32 totalItems
, off_t totalSize
,
110 const entry_ref
* destDir
, bool showCount
);
113 virtual void Draw(BRect updateRect
);
114 virtual void AttachedToWindow();
115 virtual void MessageReceived(BMessage
* message
);
117 void UpdateStatus(const char* currentItem
,
118 off_t itemSize
, bool optional
= false);
119 // If true is passed in <optional> status
120 // will only be updated if 0.2 seconds
121 // elapsed since the last update.
123 bool WasCanceled() const;
124 bool IsPaused() const;
125 thread_id
Thread() const;
127 void SetWasCanceled();
128 // called by AboutToQuit
131 BString
_DestinationString(float* _width
);
132 BString
_StatusString(float availableSpace
,
133 float fontSize
, float* _width
);
135 BString
_SpeedStatusString(float availableSpace
,
137 BString
_FullSpeedString();
138 BString
_ShortSpeedString();
140 BString
_TimeStatusString(float availableSpace
,
142 BString
_ShortTimeRemainingString(const char* timeText
);
143 BString
_FullTimeRemainingString(time_t now
,
144 time_t finishTime
, const char* timeText
);
146 BStatusBar
* fStatusBar
;
149 off_t fSizeProcessed
;
150 off_t fLastSpeedReferenceSize
;
151 off_t fEstimatedFinishReferenceSize
;
155 BButton
* fStopButton
;
156 BButton
* fPauseButton
;
158 bigtime_t fLastUpdateTime
;
159 bigtime_t fLastSpeedReferenceTime
;
160 bigtime_t fProcessStartTime
;
161 bigtime_t fLastSpeedUpdateTime
;
162 bigtime_t fEstimatedFinishReferenceTime
;
163 static const size_t kBytesPerSecondSlots
= 10;
164 size_t fCurrentBytesPerSecondSlot
;
165 double fBytesPerSecondSlot
[kBytesPerSecondSlots
];
166 double fBytesPerSecond
;
171 char fPendingStatusString
[128];
173 typedef BView _inherited
;
178 BStatusView::IsPaused() const
185 BStatusView::WasCanceled() const
192 BStatusView::Thread() const
198 extern BStatusWindow
* gStatusWindow
;
201 } // namespace BPrivate
203 using namespace BPrivate
;
206 #endif // _STATUS_WINDOW_H