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 <Region.h> 42 #include <Query.h> 43 #include <Shelf.h> 44 #include <View.h> 45 46 #include "BarView.h" 47 #include "TimeView.h" 48 49 50 //#define FULL_MODE 51 52 const int32 kMinimumReplicantCount = 6; 53 const int32 kGutter = 1; 54 const int32 kTrayPadding = B_USE_HALF_ITEM_SPACING; 55 56 extern float sIconGap; 57 extern float gDragWidth, gDragRegionWidth; 58 extern float gMinReplicantHeight, gMinReplicantWidth; 59 extern float gMinimumTrayWidth, gMinimumWindowWidth, gMaximumWindowWidth; 60 61 #ifdef DB_ADDONS 62 struct DeskbarItemInfo { 63 bool isAddOn; // attribute tagged item 64 int32 id; // id given to replicant 65 entry_ref entryRef; // entry_ref to item tagged 66 node_ref nodeRef; // node_ref to boot vol item 67 }; 68 #endif 69 70 class TReplicantShelf; 71 72 class TReplicantTray : public BView { 73 public: 74 TReplicantTray(TBarView* barView); 75 virtual ~TReplicantTray(); 76 77 virtual void AttachedToWindow(); 78 virtual void DetachedFromWindow(); 79 virtual void MouseDown(BPoint point); 80 virtual void MessageReceived(BMessage*); 81 virtual void GetPreferredSize(float*, float*); 82 83 void AdjustPlacement(); 84 void ShowReplicantMenu(BPoint); 85 86 TTimeView* Time() const { return fTime; } 87 void ShowHideTime(); 88 89 status_t ItemInfo(int32 target, const char** name); 90 status_t ItemInfo(const char* name, int32* id); 91 status_t ItemInfo(int32 index, const char** name, 92 int32* id); 93 94 bool IconExists(int32 target, bool byIndex = false); 95 bool IconExists(const char* name); 96 97 int32 ReplicantCount() const; 98 float MaxReplicantWidth() const 99 { return fMaxReplicantWidth; } 100 float MaxReplicantHeight() const 101 { return fMaxReplicantHeight; } 102 103 status_t AddIcon(BMessage*, int32* id, 104 const entry_ref* = NULL); 105 106 void RemoveIcon(int32 target, 107 bool byIndex = false); 108 void RemoveIcon(const char* name); 109 110 BRect IconFrame(int32 target, 111 bool byIndex = false); 112 BRect IconFrame(const char* name); 113 114 bool AcceptAddon(BRect frame, 115 BMessage* message); 116 void RealignReplicants(int32 startIndex = -1); 117 118 void SaveTimeSettings(); 119 120 #ifdef DB_ADDONS 121 status_t LoadAddOn(BEntry* entry, int32* id, 122 bool addToSettings = true); 123 #endif 124 125 private: 126 BView* ViewAt(int32* index, int32* id, 127 int32 target, 128 bool byIndex = false); 129 BView* ViewAt(int32* index, int32* id, 130 const char* name); 131 132 void RealReplicantAdjustment(int32 startindex); 133 134 #ifdef DB_ADDONS 135 void InitAddOnSupport(); 136 void DeleteAddOnSupport(); 137 138 DeskbarItemInfo* DeskbarItemFor(node_ref &nodeRef); 139 DeskbarItemInfo* DeskbarItemFor(int32 id); 140 bool NodeExists(node_ref &nodeRef); 141 142 void HandleEntryUpdate(BMessage*); 143 status_t AddItem(int32 id, node_ref nodeRef, 144 BEntry &entry, bool isAddon); 145 146 void UnloadAddOn(node_ref*, dev_t*, bool which, 147 bool removeAll); 148 void RemoveItem(int32 id); 149 150 void MoveItem(entry_ref*, ino_t toDirectory); 151 #endif 152 153 BPoint LocationForReplicant(int32 index, 154 float replicantWidth); 155 BShelf* Shelf() const; 156 157 status_t _SaveSettings(); 158 159 friend class TReplicantShelf; 160 friend class TBarView; 161 162 TTimeView* fTime; 163 TBarView* fBarView; 164 TReplicantShelf* fShelf; 165 BRect fRightBottomReplicant; 166 int32 fLastReplicant; 167 float fMaxReplicantWidth; 168 float fMaxReplicantHeight; 169 float fMinTrayHeight; 170 171 float fMinimumTrayWidth; 172 float fTrayPadding; 173 float fClockMargin; 174 175 bool fAlignmentSupport; 176 #ifdef DB_ADDONS 177 BList* fItemList; 178 BMessage fAddOnSettings; 179 #endif 180 181 }; 182 183 enum { 184 kNoDragRegion, 185 kDontDrawDragRegion, 186 kAutoPlaceDragRegion, 187 kDragRegionLeft, 188 kDragRegionRight, 189 kDragRegionTop, 190 kDragRegionBottom 191 }; 192 193 class TDragRegion : public BControl { 194 public: 195 TDragRegion(TBarView* barView, BView* replicantTray); 196 197 virtual void AttachedToWindow(); 198 virtual void GetPreferredSize(float*, float*); 199 virtual void Draw(BRect); 200 virtual void DrawAfterChildren(BRect); 201 virtual void MouseDown(BPoint); 202 virtual void MouseUp(BPoint); 203 virtual void MouseMoved(BPoint, uint32, const BMessage*); 204 205 BRect DragRegion() const; 206 207 bool SwitchModeForRegion(BPoint where, BRegion region, 208 bool newVertical, bool newLeft, bool newTop, int32 newState); 209 void CalculateRegions(); 210 211 int32 DragRegionLocation() const; 212 void SetDragRegionLocation(int32); 213 214 bool IsDragging() { return IsTracking(); }; 215 216 private: 217 void DrawDragger(); 218 219 private: 220 TBarView* fBarView; 221 BView* fReplicantTray; 222 BPoint fPreviousPosition; 223 int32 fDragLocation; 224 225 BRegion fTopLeftVertical; 226 BRegion fTopRightVertical; 227 BRegion fBottomLeftVertical; 228 BRegion fBottomRightVertical; 229 230 BRegion fTopLeftHorizontal; 231 BRegion fTopRightHorizontal; 232 BRegion fBottomLeftHorizontal; 233 BRegion fBottomRightHorizontal; 234 235 BRegion fMiddleLeft; 236 BRegion fMiddleRight; 237 #ifdef FULL_MODE 238 BRegion fLeftSide; 239 BRegion fRightSide; 240 #endif 241 BRegion fTopHalf; 242 BRegion fBottomHalf; 243 }; 244 245 class TResizeControl : public BControl { 246 public: 247 TResizeControl(TBarView* barView); 248 virtual ~TResizeControl(); 249 250 virtual void AttachedToWindow(); 251 virtual void Draw(BRect); 252 virtual void MouseDown(BPoint); 253 virtual void MouseUp(BPoint); 254 virtual void MouseMoved(BPoint, uint32, const BMessage*); 255 256 bool IsResizing() { return IsTracking(); }; 257 258 private: 259 TBarView* fBarView; 260 }; 261 262 263 #endif /* __STATUS_VIEW__ */ 264