btrfs: Attempt to fix GCC2 build.
[haiku.git] / src / apps / webpositive / DownloadProgressView.h
blob72c4953270b06205d1bc117f957d6391a6dd2b0b
1 /*
2 * Copyright (C) 2010 Stephan Aßmus <superstippi@gmx.de>
4 * All rights reserved. Distributed under the terms of the MIT License.
5 */
6 #ifndef DOWNLOAD_PROGRESS_VIEW_H
7 #define DOWNLOAD_PROGRESS_VIEW_H
10 #include <GroupView.h>
11 #include <Path.h>
12 #include <String.h>
14 class BEntry;
15 class BStatusBar;
16 class BStringView;
17 class BWebDownload;
18 class IconView;
19 class SmallButton;
22 enum {
23 SAVE_SETTINGS = 'svst'
27 class DownloadProgressView : public BGroupView {
28 public:
29 DownloadProgressView(BWebDownload* download);
30 DownloadProgressView(const BMessage* archive);
32 bool Init(BMessage* archive = NULL);
34 status_t SaveSettings(BMessage* archive);
35 virtual void AttachedToWindow();
36 virtual void DetachedFromWindow();
37 virtual void AllAttached();
39 virtual void Draw(BRect updateRect);
41 virtual void MessageReceived(BMessage* message);
43 void ShowContextMenu(BPoint screenWhere);
45 BWebDownload* Download() const;
46 const BString& URL() const;
47 bool IsMissing() const;
48 bool IsFinished() const;
50 void DownloadFinished();
51 void CancelDownload();
53 static void SpeedVersusEstimatedFinishTogglePulse();
55 private:
56 void _UpdateStatus(off_t currentSize,
57 off_t expectedSize);
58 void _UpdateStatusText();
59 void _StartNodeMonitor(const BEntry& entry);
60 void _StopNodeMonitor();
62 private:
63 IconView* fIconView;
64 BStatusBar* fStatusBar;
65 BStringView* fInfoView;
66 SmallButton* fTopButton;
67 SmallButton* fBottomButton;
68 BWebDownload* fDownload;
69 BString fURL;
70 BPath fPath;
72 off_t fCurrentSize;
73 off_t fExpectedSize;
74 off_t fLastSpeedReferenceSize;
75 off_t fEstimatedFinishReferenceSize;
76 bigtime_t fLastUpdateTime;
77 bigtime_t fLastSpeedReferenceTime;
78 bigtime_t fProcessStartTime;
79 bigtime_t fLastSpeedUpdateTime;
80 bigtime_t fEstimatedFinishReferenceTime;
81 static const size_t kBytesPerSecondSlots = 10;
82 size_t fCurrentBytesPerSecondSlot;
83 double fBytesPerSecondSlot[kBytesPerSecondSlots];
84 double fBytesPerSecond;
86 static bigtime_t sLastEstimatedFinishSpeedToggleTime;
87 static bool sShowSpeed;
90 #endif // DOWNLOAD_PROGRESS_VIEW_H