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