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 36 #ifndef __STATUS_VIEW__ 37 #define __STATUS_VIEW__ 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 const float kMaxReplicantHeight = 16.0f; 49 const float kMaxReplicantWidth = 16.0f; 50 const int32 kMinimumReplicantCount = 6; 51 const int32 kIconGap = 2; 52 const int32 kGutter = 1; 53 const int32 kDragRegionWidth = 6; 54 55 // 1 pixel left gutter 56 // space for replicant tray (6 items) 57 // 6 pixel drag region 58 const float kMinimumTrayWidth = kIconGap + (kMinimumReplicantCount * kIconGap) 59 + (kMinimumReplicantCount * kMaxReplicantWidth) + kGutter; 60 const float kMinimumTrayHeight = kGutter + kMaxReplicantHeight + kGutter; 61 62 extern float sMinimumWindowWidth; 63 64 #ifdef DB_ADDONS 65 struct DeskbarItemInfo { 66 bool isAddOn; // attribute tagged item 67 int32 id; // id given to replicant 68 entry_ref entryRef; // entry_ref to item tagged 69 node_ref nodeRef; // node_ref to boot vol item 70 }; 71 #endif 72 73 class TReplicantShelf; 74 75 class TReplicantTray : public BView { 76 public: 77 TReplicantTray(TBarView* bv, bool vertical); 78 virtual ~TReplicantTray(); 79 80 virtual void AttachedToWindow(); 81 virtual void DetachedFromWindow(); 82 virtual void MouseDown(BPoint point); 83 virtual void MessageReceived(BMessage*); 84 virtual void GetPreferredSize(float*, float*); 85 86 void AdjustPlacement(); 87 88 void ShowReplicantMenu(BPoint); 89 90 void SetMultiRow(bool state); 91 bool IsMultiRow() const { return fMultiRowMode; } 92 93 status_t ItemInfo(int32 target, const char** name); 94 status_t ItemInfo(const char* name, int32* id); 95 status_t ItemInfo(int32 index, const char** name, int32* id); 96 97 bool IconExists(int32 target, bool byIndex = false); 98 bool IconExists(const char* name); 99 100 int32 IconCount() const; 101 102 status_t AddIcon(BMessage*, int32* id, const entry_ref* = NULL); 103 104 void RemoveIcon(int32 target, bool byIndex = false); 105 void RemoveIcon(const char* name); 106 107 BRect IconFrame(int32 target, bool byIndex = false); 108 BRect IconFrame(const char* name); 109 110 bool AcceptAddon(BRect frame, BMessage* message); 111 void RealignReplicants(int32 startIndex = -1); 112 113 bool ShowingSeconds(void); 114 bool ShowingMiltime(void); 115 116 void RememberClockSettings(); 117 void DealWithClock(bool); 118 119 #ifdef DB_ADDONS 120 status_t LoadAddOn(BEntry* entry, int32* id, bool force = false); 121 #endif 122 123 private: 124 BView* ViewAt(int32* index, int32* id, int32 target, bool byIndex = false); 125 BView* ViewAt(int32* index, int32* id, const char* name); 126 127 void RealReplicantAdjustment(int32 startindex); 128 129 #ifdef DB_ADDONS 130 void InitAddOnSupport(); 131 void DeleteAddOnSupport(); 132 void RunAddOnQuery(BVolume* volume, const char* predicated); 133 134 bool IsAddOn(entry_ref &ref); 135 DeskbarItemInfo* DeskbarItemFor(node_ref &nodeRef); 136 DeskbarItemInfo* DeskbarItemFor(int32 id); 137 bool NodeExists(node_ref &nodeRef); 138 139 void HandleEntryUpdate(BMessage*); 140 status_t AddItem(int32 id, node_ref nodeRef, BEntry &entry, bool isAddon); 141 142 void UnloadAddOn(node_ref*, dev_t*, bool which, bool removeAll); 143 void RemoveItem(int32 id); 144 145 void MoveItem(entry_ref*, ino_t toDirectory); 146 #endif 147 148 BPoint LocationForReplicant(int32 index, float width); 149 BShelf* Shelf() const; 150 151 friend class TReplicantShelf; 152 153 TTimeView* fClock; 154 TBarView* fBarView; 155 TReplicantShelf* fShelf; 156 BRect fRightBottomReplicant; 157 int32 fLastReplicant; 158 159 bool fMultiRowMode; 160 float fMinimumTrayWidth; 161 162 bool fAlignmentSupport; 163 #ifdef DB_ADDONS 164 BList* fItemList; 165 uint64 fDeskbarSecurityCode; 166 #endif 167 168 }; 169 170 enum { 171 kNoDragRegion, 172 kDontDrawDragRegion, 173 kAutoPlaceDragRegion, 174 kDragRegionLeft, 175 kDragRegionRight, 176 kDragRegionTop, 177 kDragRegionBottom 178 }; 179 180 class TDragRegion : public BControl { 181 public: 182 TDragRegion(TBarView*, BView*); 183 184 virtual void AttachedToWindow(); 185 virtual void GetPreferredSize(float*, float*); 186 virtual void Draw(BRect); 187 virtual void FrameMoved(BPoint); 188 virtual void MouseDown(BPoint ); 189 virtual void MouseUp(BPoint ); 190 virtual void MouseMoved(BPoint , uint32 , const BMessage*); 191 192 void DrawDragRegion(); 193 BRect DragRegion() const; 194 195 bool SwitchModeForRect(BPoint mouse, BRect rect, 196 bool newVertical, bool newLeft, bool newTop, int32 newState); 197 198 int32 DragRegionLocation() const; 199 void SetDragRegionLocation(int32); 200 201 private: 202 TBarView* fBarView; 203 BView* fChild; 204 BPoint fPreviousPosition; 205 int32 fDragLocation; 206 }; 207 208 #endif 209 210