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