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 HandleDeskbarMenu(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 129 void RemoveItem(int32 id); 130 void RemoveItem(const char* name, DeskbarShelf shelf); 131 132 BRect OffsetIconFrame(BRect rect) const; 133 BRect IconFrame(int32 id) const; 134 BRect IconFrame(const char* name) const; 135 136 void GetPreferredWindowSize(BRect screenFrame, float* width, 137 float* height); 138 void SizeWindow(BRect screenFrame); 139 void PositionWindow(BRect screenFrame); 140 141 TExpandoMenuBar* ExpandoMenuBar() const; 142 TBarMenuBar* BarMenuBar() const; 143 TDragRegion* DragRegion() const { return fDragRegion; } 144 145 private: 146 friend class TDeskbarMenu; 147 friend class PreferencesWindow; 148 149 status_t SendDragMessage(const char* signature, entry_ref* ref = NULL); 150 151 void PlaceDeskbarMenu(); 152 void PlaceTray(bool vertSwap, bool leftSwap, BRect screenFrame); 153 void PlaceApplicationBar(BRect screenFrame); 154 155 TBarMenuBar* fBarMenuBar; 156 TExpandoMenuBar* fExpando; 157 158 int32 fTrayLocation; 159 TDragRegion* fDragRegion; 160 TReplicantTray* fReplicantTray; 161 162 bool fShowInterval : 1; 163 bool fShowClock : 1; 164 bool fVertical : 1; 165 bool fTop : 1; 166 bool fLeft : 1; 167 168 int32 fState; 169 170 bigtime_t fPulseRate; 171 bool fRefsRcvdOnly; 172 BMessage* fDragMessage; 173 BObjectList<BString>*fCachedTypesList; 174 TrackingHookData fTrackingHookData; 175 176 uint32 fMaxRecentDocs; 177 uint32 fMaxRecentApps; 178 179 TTeamMenuItem* fLastDragItem; 180 }; 181 182 183 inline TExpandoMenuBar* 184 TBarView::ExpandoMenuBar() const 185 { 186 return fExpando; 187 } 188 189 190 inline TBarMenuBar* 191 TBarView::BarMenuBar() const 192 { 193 return fBarMenuBar; 194 } 195 196 197 inline bool 198 TBarView::Dragging() const 199 { 200 return (fCachedTypesList && fDragMessage); 201 } 202 203 204 inline const BMessage* 205 TBarView::DragMessage() const 206 { 207 return fDragMessage; 208 } 209 210 211 inline BObjectList<BString>* 212 TBarView::CachedTypesList() const 213 { 214 return fCachedTypesList; 215 } 216 217 #endif /* BARVIEW_H */ 218 219