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 class BShelf; 69 class TBarMenuBar; 70 class TExpandoMenuBar; 71 class TReplicantTray; 72 class TDragRegion; 73 class TInlineScrollView; 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 bool aSync = false); 95 void RaiseDeskbar(bool raise); 96 void HideDeskbar(bool hide); 97 98 // window placement methods 99 bool Vertical() const { return fVertical; }; 100 bool Left() const { return fLeft; }; 101 bool Top() const { return fTop; }; 102 bool AcrossTop() const { return fTop && !fVertical; }; 103 bool AcrossBottom() const { return !fTop && !fVertical; }; 104 105 // window state methods 106 bool ExpandoState() const { return fState == kExpandoState; }; 107 bool FullState() const { return fState == kFullState; }; 108 bool MiniState() const { return fState == kMiniState; }; 109 int32 State() const { return fState; }; 110 111 // drag and drop methods 112 void CacheDragData(const BMessage* incoming); 113 status_t DragStart(); 114 static bool MenuTrackingHook(BMenu* menu, void* castToThis); 115 void DragStop(bool full = false); 116 TrackingHookData* GetTrackingHookData(); 117 bool Dragging() const; 118 const BMessage* DragMessage() const; 119 BObjectList<BString>*CachedTypesList() const; 120 bool AppCanHandleTypes(const char* signature); 121 void SetDragOverride(bool); 122 bool DragOverride(); 123 bool InvokeItem(const char* signature); 124 125 void HandleDeskbarMenu(BMessage* targetmessage); 126 127 status_t ItemInfo(int32 id, const char** name, DeskbarShelf* shelf); 128 status_t ItemInfo(const char* name, int32* id, DeskbarShelf* shelf); 129 130 bool ItemExists(int32 id, DeskbarShelf shelf); 131 bool ItemExists(const char* name, DeskbarShelf shelf); 132 133 int32 CountItems(DeskbarShelf shelf); 134 135 status_t AddItem(BMessage* archive, DeskbarShelf shelf, int32* id); 136 status_t AddItem(BEntry* entry, DeskbarShelf shelf, int32* id); 137 138 void RemoveItem(int32 id); 139 void RemoveItem(const char* name, DeskbarShelf shelf); 140 141 BRect OffsetIconFrame(BRect rect) const; 142 BRect IconFrame(int32 id) const; 143 BRect IconFrame(const char* name) const; 144 145 void GetPreferredWindowSize(BRect screenFrame, float* width, 146 float* height); 147 void SizeWindow(BRect screenFrame); 148 void PositionWindow(BRect screenFrame); 149 void AddExpandedItem(const char* signature); 150 151 void CheckForScrolling(); 152 153 TExpandoMenuBar* ExpandoMenuBar() const; 154 TBarMenuBar* BarMenuBar() const; 155 TDragRegion* DragRegion() const { return fDragRegion; } 156 TReplicantTray* ReplicantTray() const { return fReplicantTray; } 157 158 private: 159 friend class TBarApp; 160 friend class TDeskbarMenu; 161 friend class PreferencesWindow; 162 163 status_t SendDragMessage(const char* signature, entry_ref* ref = NULL); 164 165 void PlaceDeskbarMenu(); 166 void PlaceTray(bool vertSwap, bool leftSwap); 167 void PlaceApplicationBar(); 168 void SaveExpandedItems(); 169 void RemoveExpandedItems(); 170 void ExpandItems(); 171 void _ChangeState(BMessage* message); 172 173 TInlineScrollView* fInlineScrollView; 174 TBarMenuBar* fBarMenuBar; 175 TExpandoMenuBar* fExpando; 176 177 int32 fTrayLocation; 178 TDragRegion* fDragRegion; 179 TReplicantTray* fReplicantTray; 180 181 bool fVertical : 1; 182 bool fTop : 1; 183 bool fLeft : 1; 184 185 int32 fState; 186 187 bigtime_t fPulseRate; 188 bool fRefsRcvdOnly; 189 BMessage* fDragMessage; 190 BObjectList<BString>*fCachedTypesList; 191 TrackingHookData fTrackingHookData; 192 193 uint32 fMaxRecentDocs; 194 uint32 fMaxRecentApps; 195 196 TTeamMenuItem* fLastDragItem; 197 BList fExpandedItems; 198 BMessageFilter* fMouseFilter; 199 }; 200 201 202 inline TExpandoMenuBar* 203 TBarView::ExpandoMenuBar() const 204 { 205 return fExpando; 206 } 207 208 209 inline TBarMenuBar* 210 TBarView::BarMenuBar() const 211 { 212 return fBarMenuBar; 213 } 214 215 216 inline bool 217 TBarView::Dragging() const 218 { 219 return (fCachedTypesList && fDragMessage); 220 } 221 222 223 inline const BMessage* 224 TBarView::DragMessage() const 225 { 226 return fDragMessage; 227 } 228 229 230 inline BObjectList<BString>* 231 TBarView::CachedTypesList() const 232 { 233 return fCachedTypesList; 234 } 235 236 237 #endif /* BARVIEW_H */ 238