1 /* 2 Open Tracker License 3 4 Terms and Conditions 5 6 Copyright (c) 1991-2000, Be Incorporated. All rights reserved. 7 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: 14 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. 17 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. 24 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. 28 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. 32 All rights reserved. 33 */ 34 35 #ifndef STATUS_WINDOW_H 36 #define STATUS_WINDOW_H 37 38 #include <Window.h> 39 #include <View.h> 40 #include <Bitmap.h> 41 #include <StatusBar.h> 42 #include <String.h> 43 44 #include "ObjectList.h" 45 46 namespace BPrivate { 47 48 enum StatusWindowState { 49 kCopyState, 50 kMoveState, 51 kDeleteState, 52 kTrashState, 53 kVolumeState, 54 kCreateLinkState, 55 kRestoreFromTrashState 56 }; 57 58 class BStatusView; 59 60 class BStatusWindow : public BWindow { 61 public: 62 BStatusWindow(); 63 ~BStatusWindow(); 64 void CreateStatusItem(thread_id, StatusWindowState); 65 void InitStatusItem(thread_id, int32 totalItems, off_t totalSize, 66 const entry_ref *destDir = NULL, bool showCount = true); 67 void UpdateStatus(thread_id, const char *curItem, off_t itemSize, bool optional = false); 68 // if true is passed in <optional> status will only 69 // be updated if 0.2 seconds elapsed since the last update 70 void RemoveStatusItem(thread_id); 71 bool HasStatus(thread_id); 72 bool CheckCanceledOrPaused(thread_id); 73 void UpdateButtonState(); 74 75 bool AttemptToQuit(); 76 // called by the tracker app during quit time, before 77 // inherited QuitRequested; kills all the copy/move/empty trash 78 // threads in a clean way by issuing a cancel 79 protected: 80 virtual void WindowActivated(bool state); 81 82 private: 83 BObjectList<BStatusView> fViewList; 84 BMessageFilter *fMouseDownFilter; 85 86 bool fRetainDesktopFocus; 87 88 typedef BWindow _inherited; 89 }; 90 91 class BStatusView : public BView { 92 public: 93 BStatusView(BRect, thread_id, StatusWindowState); 94 virtual ~BStatusView(); 95 96 void Init(); 97 98 void InitStatus(int32 totalItems, off_t totalSize, const entry_ref *destDir, 99 bool showCount); 100 101 // BView overrides 102 virtual void Draw(BRect); 103 virtual void AttachedToWindow(); 104 virtual void MessageReceived(BMessage *); 105 void UpdateStatus(const char *curItem, off_t itemSize, bool optional = false); 106 // if true is passed in <optional> status will only 107 // be updated if 0.2 seconds elapsed since the last update 108 109 bool WasCanceled() const; 110 bool IsPaused() const; 111 thread_id Thread() const; 112 113 void ForceQuit(); 114 void SetWasCanceled(); 115 // called by AboutToQuit 116 117 private: 118 BStatusBar *fStatusBar; 119 off_t fTotalSize; 120 off_t fItemSize; 121 int32 fCurItem; 122 int32 fType; 123 BBitmap *fBitmap; 124 BButton *fStopButton; 125 BButton *fPauseButton; 126 thread_id fThread; 127 float fLastUpdateTime; 128 bool fShowCount; 129 bool fWasCanceled; 130 bool fIsPaused; 131 BString fDestDir; 132 char fPendingStatusString[128]; 133 134 typedef BView _inherited; 135 }; 136 137 inline bool 138 BStatusView::IsPaused() const 139 { 140 return fIsPaused; 141 } 142 143 inline bool 144 BStatusView::WasCanceled() const 145 { 146 return fWasCanceled; 147 } 148 149 inline thread_id 150 BStatusView::Thread() const 151 { 152 return fThread; 153 } 154 155 extern BStatusWindow *gStatusWindow; 156 157 } // namespace BPrivate 158 159 using namespace BPrivate; 160 161 #endif 162