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 BARVIEW_H 37 #define BARVIEW_H 38 39 #include <Deskbar.h> 40 #include <View.h> 41 42 #include "NavMenu.h" 43 #include "ObjectList.h" 44 45 enum DeskbarShelf { 46 B_DESKBAR_ANY_SHELF = 0, 47 B_DESKBAR_TRAY = 1 48 }; 49 50 enum { 51 kMiniState = 0, 52 kExpandoState = 1, 53 kFullState = 2 54 }; 55 56 const float kMiniHeight = 46.0f; 57 const float kHModeHeight = 21.0f; 58 const float kMenuBarHeight = 21.0f; 59 const float kStatusHeight = 22.0f; 60 const float kHModeHiddenHeight = 1.0f; 61 const float kMaxPreventHidingDist = 80.0f; 62 63 class BShelf; 64 class TBarMenuBar; 65 class TExpandoMenuBar; 66 class TReplicantTray; 67 class TDragRegion; 68 class TTeamMenuItem; 69 70 71 class TBarView : public BView { 72 public: 73 TBarView(BRect frame, bool vertical, bool left, bool top, 74 bool ampmMode, uint32 state, float width, bool showClock); 75 ~TBarView(); 76 77 virtual void AttachedToWindow(); 78 virtual void DetachedFromWindow(); 79 virtual void Draw(BRect updateRect); 80 virtual void MessageReceived(BMessage* message); 81 virtual void MouseMoved(BPoint where, uint32 transit, 82 const BMessage* dragMessage); 83 virtual void MouseDown(BPoint where); 84 85 void SaveSettings(); 86 void UpdateEventMask(); 87 void UpdatePlacement(); 88 void ChangeState(int32 state, bool vertical, bool left, bool top); 89 void RaiseDeskbar(bool raise); 90 void HideDeskbar(bool hide); 91 92 bool Vertical() const; 93 bool Left() const; 94 bool Top() const; 95 bool AcrossTop() const; 96 bool AcrossBottom() const; 97 bool Expando() const; 98 int32 State() const; 99 100 bool MilTime() const; 101 void ShowClock(bool); 102 bool ShowingClock() const; 103 104 void CacheDragData(const BMessage* incoming); 105 status_t DragStart(); 106 static bool MenuTrackingHook(BMenu* menu, void* castToThis); 107 void DragStop(bool full = false); 108 TrackingHookData* GetTrackingHookData(); 109 bool Dragging() const; 110 const BMessage* DragMessage() const; 111 BObjectList<BString>*CachedTypesList() const; 112 bool AppCanHandleTypes(const char* signature); 113 void SetDragOverride(bool); 114 bool DragOverride(); 115 bool InvokeItem(const char* signature); 116 117 void HandleBeMenu(BMessage* targetmessage); 118 119 status_t ItemInfo(int32 id, const char** name, DeskbarShelf* shelf); 120 status_t ItemInfo(const char* name, int32* id, DeskbarShelf* shelf); 121 122 bool ItemExists(int32 id, DeskbarShelf shelf); 123 bool ItemExists(const char* name, DeskbarShelf shelf); 124 125 int32 CountItems(DeskbarShelf shelf); 126 127 status_t AddItem(BMessage* archive, DeskbarShelf shelf, int32* id); 128 status_t AddItem(BEntry* entry, DeskbarShelf shelf, int32* id); 129 130 void RemoveItem(int32 id); 131 void RemoveItem(const char* name, DeskbarShelf shelf); 132 133 BRect OffsetIconFrame(BRect rect) const; 134 BRect IconFrame(int32 id) const; 135 BRect IconFrame(const char* name) const; 136 137 void GetPreferredWindowSize(BRect screenFrame, float* width, 138 float* height); 139 void SizeWindow(BRect screenFrame); 140 void PositionWindow(BRect screenFrame); 141 142 TExpandoMenuBar* ExpandoMenuBar() const; 143 TBarMenuBar* BarMenuBar() const; 144 TDragRegion* DragRegion() const { return fDragRegion; } 145 146 private: 147 friend class TBeMenu; 148 friend class PreferencesWindow; 149 150 status_t SendDragMessage(const char* signature, entry_ref* ref = NULL); 151 152 void PlaceBeMenu(); 153 void PlaceTray(bool vertSwap, bool leftSwap, BRect screenFrame); 154 void PlaceApplicationBar(BRect screenFrame); 155 156 TBarMenuBar* fBarMenuBar; 157 TExpandoMenuBar* fExpando; 158 159 int32 fTrayLocation; 160 TDragRegion* fDragRegion; 161 TReplicantTray* fReplicantTray; 162 163 bool fShowInterval : 1; 164 bool fShowClock : 1; 165 bool fVertical : 1; 166 bool fTop : 1; 167 bool fLeft : 1; 168 169 int32 fState; 170 171 bigtime_t fPulseRate; 172 bool fRefsRcvdOnly; 173 BMessage* fDragMessage; 174 BObjectList<BString>*fCachedTypesList; 175 TrackingHookData fTrackingHookData; 176 177 uint32 fMaxRecentDocs; 178 uint32 fMaxRecentApps; 179 180 TTeamMenuItem* fLastDragItem; 181 }; 182 183 184 inline TExpandoMenuBar* 185 TBarView::ExpandoMenuBar() const 186 { 187 return fExpando; 188 } 189 190 191 inline TBarMenuBar* 192 TBarView::BarMenuBar() const 193 { 194 return fBarMenuBar; 195 } 196 197 198 inline bool 199 TBarView::Dragging() const 200 { 201 return (fCachedTypesList && fDragMessage); 202 } 203 204 205 inline const BMessage* 206 TBarView::DragMessage() const 207 { 208 return fDragMessage; 209 } 210 211 212 inline BObjectList<BString>* 213 TBarView::CachedTypesList() const 214 { 215 return fCachedTypesList; 216 } 217 218 #endif /* BARVIEW_H */ 219 220