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 bool ShowingEuroDate(void); 117 bool ShowingFullDate(void); 118 bool CanShowFullDate(void); 119 120 void RememberClockSettings(); 121 void DealWithClock(bool); 122 123 #ifdef DB_ADDONS 124 status_t LoadAddOn(BEntry* entry, int32* id, bool force = false); 125 #endif 126 127 private: 128 BView* ViewAt(int32* index, int32* id, int32 target, bool byIndex = false); 129 BView* ViewAt(int32* index, int32* id, const char* name); 130 131 void RealReplicantAdjustment(int32 startindex); 132 133 #ifdef DB_ADDONS 134 void InitAddOnSupport(); 135 void DeleteAddOnSupport(); 136 void RunAddOnQuery(BVolume* volume, const char* predicated); 137 138 bool IsAddOn(entry_ref &ref); 139 DeskbarItemInfo* DeskbarItemFor(node_ref &nodeRef); 140 DeskbarItemInfo* DeskbarItemFor(int32 id); 141 bool NodeExists(node_ref &nodeRef); 142 143 void HandleEntryUpdate(BMessage*); 144 status_t AddItem(int32 id, node_ref nodeRef, BEntry &entry, bool isAddon); 145 146 void UnloadAddOn(node_ref*, dev_t*, bool which, bool removeAll); 147 void RemoveItem(int32 id); 148 149 void MoveItem(entry_ref*, ino_t toDirectory); 150 #endif 151 152 BPoint LocationForReplicant(int32 index, float width); 153 BShelf* Shelf() const; 154 155 friend class TReplicantShelf; 156 157 TTimeView* fClock; 158 TBarView* fBarView; 159 TReplicantShelf* fShelf; 160 BRect fRightBottomReplicant; 161 int32 fLastReplicant; 162 163 bool fMultiRowMode; 164 float fMinimumTrayWidth; 165 166 bool fAlignmentSupport; 167 #ifdef DB_ADDONS 168 BList* fItemList; 169 uint64 fDeskbarSecurityCode; 170 #endif 171 172 }; 173 174 enum { 175 kNoDragRegion, 176 kDontDrawDragRegion, 177 kAutoPlaceDragRegion, 178 kDragRegionLeft, 179 kDragRegionRight, 180 kDragRegionTop, 181 kDragRegionBottom 182 }; 183 184 class TDragRegion : public BControl { 185 public: 186 TDragRegion(TBarView*, BView*); 187 188 virtual void AttachedToWindow(); 189 virtual void GetPreferredSize(float*, float*); 190 virtual void Draw(BRect); 191 virtual void FrameMoved(BPoint); 192 virtual void MouseDown(BPoint ); 193 virtual void MouseUp(BPoint ); 194 virtual void MouseMoved(BPoint , uint32 , const BMessage*); 195 196 void DrawDragRegion(); 197 BRect DragRegion() const; 198 199 bool SwitchModeForRect(BPoint mouse, BRect rect, 200 bool newVertical, bool newLeft, bool newTop, int32 newState); 201 202 int32 DragRegionLocation() const; 203 void SetDragRegionLocation(int32); 204 205 private: 206 TBarView* fBarView; 207 BView* fChild; 208 BPoint fPreviousPosition; 209 int32 fDragLocation; 210 }; 211 212 #endif 213 214