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 30 trademarks of Be Incorporated in the United States and other countries. Other 31 brand product names are registered trademarks or trademarks of their respective 32 holders. 33 All rights reserved. 34 */ 35 #ifndef __STATUS_VIEW__ 36 #define __STATUS_VIEW__ 37 38 39 #include <Control.h> 40 #include <Node.h> 41 #include <Query.h> 42 #include <Shelf.h> 43 #include <View.h> 44 45 #include "BarView.h" 46 #include "TimeView.h" 47 48 49 const float kDragWidth = 4.0f; 50 const float kMinReplicantHeight = 16.0f; 51 const float kMinReplicantWidth = 16.0f; 52 const int32 kMinimumReplicantCount = 6; 53 const int32 kIconGap = 2; 54 const int32 kGutter = 1; 55 const int32 kDragRegionWidth = 6; 56 const int32 kTrayPadding = 3; 57 const int32 kClockMargin = 12; 58 59 // 1 pixel for left gutter 60 // space for replicant tray (6 items) 61 // 6 pixel drag region 62 const float kMinimumTrayWidth = kIconGap + kMinReplicantWidth 63 + (kMinimumReplicantCount * kIconGap) 64 + (kMinimumReplicantCount * kMinReplicantWidth) + kGutter; 65 66 extern float gMinimumWindowWidth; 67 extern float gMaximumWindowWidth; 68 69 #ifdef DB_ADDONS 70 struct DeskbarItemInfo { 71 bool isAddOn; // attribute tagged item 72 int32 id; // id given to replicant 73 entry_ref entryRef; // entry_ref to item tagged 74 node_ref nodeRef; // node_ref to boot vol item 75 }; 76 #endif 77 78 class TReplicantShelf; 79 80 class TReplicantTray : public BView { 81 public: 82 TReplicantTray(TBarView* barView, 83 bool vertical); 84 virtual ~TReplicantTray(); 85 86 virtual void AttachedToWindow(); 87 virtual void DetachedFromWindow(); 88 virtual void MouseDown(BPoint point); 89 virtual void MessageReceived(BMessage*); 90 virtual void GetPreferredSize(float*, float*); 91 92 void AdjustPlacement(); 93 void ShowReplicantMenu(BPoint); 94 95 void SetMultiRow(bool state); 96 bool IsMultiRow() const 97 { return fMultiRowMode; } 98 99 TTimeView* Time() const { return fTime; } 100 void ShowHideTime(); 101 102 status_t ItemInfo(int32 target, const char** name); 103 status_t ItemInfo(const char* name, int32* id); 104 status_t ItemInfo(int32 index, const char** name, 105 int32* id); 106 107 bool IconExists(int32 target, bool byIndex = false); 108 bool IconExists(const char* name); 109 110 int32 ReplicantCount() const; 111 float MaxReplicantWidth() const 112 { return fMaxReplicantWidth; } 113 float MaxReplicantHeight() const 114 { return fMaxReplicantHeight; } 115 116 status_t AddIcon(BMessage*, int32* id, 117 const entry_ref* = NULL); 118 119 void RemoveIcon(int32 target, 120 bool byIndex = false); 121 void RemoveIcon(const char* name); 122 123 BRect IconFrame(int32 target, 124 bool byIndex = false); 125 BRect IconFrame(const char* name); 126 127 bool AcceptAddon(BRect frame, 128 BMessage* message); 129 void RealignReplicants(int32 startIndex = -1); 130 131 void SaveTimeSettings(); 132 133 #ifdef DB_ADDONS 134 status_t LoadAddOn(BEntry* entry, int32* id, 135 bool addToSettings = true); 136 #endif 137 138 private: 139 BView* ViewAt(int32* index, int32* id, 140 int32 target, 141 bool byIndex = false); 142 BView* ViewAt(int32* index, int32* id, 143 const char* name); 144 145 void RealReplicantAdjustment(int32 startindex); 146 147 #ifdef DB_ADDONS 148 void InitAddOnSupport(); 149 void DeleteAddOnSupport(); 150 151 DeskbarItemInfo* DeskbarItemFor(node_ref &nodeRef); 152 DeskbarItemInfo* DeskbarItemFor(int32 id); 153 bool NodeExists(node_ref &nodeRef); 154 155 void HandleEntryUpdate(BMessage*); 156 status_t AddItem(int32 id, node_ref nodeRef, 157 BEntry &entry, bool isAddon); 158 159 void UnloadAddOn(node_ref*, dev_t*, bool which, 160 bool removeAll); 161 void RemoveItem(int32 id); 162 163 void MoveItem(entry_ref*, ino_t toDirectory); 164 #endif 165 166 BPoint LocationForReplicant(int32 index, 167 float replicantWidth); 168 BShelf* Shelf() const; 169 170 status_t _SaveSettings(); 171 172 friend class TReplicantShelf; 173 friend class TBarView; 174 175 TTimeView* fTime; 176 TBarView* fBarView; 177 TReplicantShelf* fShelf; 178 BRect fRightBottomReplicant; 179 int32 fLastReplicant; 180 float fMaxReplicantWidth; 181 float fMaxReplicantHeight; 182 float fMinTrayHeight; 183 184 bool fMultiRowMode; 185 float fMinimumTrayWidth; 186 187 bool fAlignmentSupport; 188 #ifdef DB_ADDONS 189 BList* fItemList; 190 BMessage fAddOnSettings; 191 #endif 192 193 }; 194 195 enum { 196 kNoDragRegion, 197 kDontDrawDragRegion, 198 kAutoPlaceDragRegion, 199 kDragRegionLeft, 200 kDragRegionRight, 201 kDragRegionTop, 202 kDragRegionBottom 203 }; 204 205 class TDragRegion : public BControl { 206 public: 207 TDragRegion(TBarView* barView, BView* replicantTray); 208 209 virtual void AttachedToWindow(); 210 virtual void GetPreferredSize(float*, float*); 211 virtual void Draw(BRect); 212 virtual void MouseDown(BPoint); 213 virtual void MouseUp(BPoint); 214 virtual void MouseMoved(BPoint, uint32, const BMessage*); 215 216 void DrawDragRegion(); 217 BRect DragRegion() const; 218 219 bool SwitchModeForRect(BPoint mouse, BRect rect, 220 bool newVertical, bool newLeft, bool newTop, int32 newState); 221 222 int32 DragRegionLocation() const; 223 void SetDragRegionLocation(int32); 224 225 bool IsDragging() { return IsTracking(); }; 226 227 private: 228 TBarView* fBarView; 229 BView* fReplicantTray; 230 BPoint fPreviousPosition; 231 int32 fDragLocation; 232 }; 233 234 class TResizeControl : public BControl { 235 public: 236 TResizeControl(TBarView* barView); 237 virtual ~TResizeControl(); 238 239 virtual void AttachedToWindow(); 240 virtual void Draw(BRect); 241 virtual void MouseDown(BPoint); 242 virtual void MouseUp(BPoint); 243 virtual void MouseMoved(BPoint, uint32, const BMessage*); 244 245 bool IsResizing() { return IsTracking(); }; 246 247 private: 248 TBarView* fBarView; 249 }; 250 251 252 #endif /* __STATUS_VIEW__ */ 253