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 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 TExpandoMenuBar* ExpandoMenuBar() const; 152 TBarMenuBar* BarMenuBar() const; 153 TDragRegion* DragRegion() const { return fDragRegion; } 154 TReplicantTray* ReplicantTray() const { return fReplicantTray; } 155 156 private: 157 friend class TBarApp; 158 friend class TDeskbarMenu; 159 friend class PreferencesWindow; 160 161 status_t SendDragMessage(const char* signature, entry_ref* ref = NULL); 162 163 void PlaceDeskbarMenu(); 164 void PlaceTray(bool vertSwap, bool leftSwap); 165 void PlaceApplicationBar(); 166 void SaveExpandedItems(); 167 void RemoveExpandedItems(); 168 void ExpandItems(); 169 void _ChangeState(BMessage* message); 170 171 TBarMenuBar* fBarMenuBar; 172 TExpandoMenuBar* fExpando; 173 174 int32 fTrayLocation; 175 TDragRegion* fDragRegion; 176 TReplicantTray* fReplicantTray; 177 178 bool fVertical : 1; 179 bool fTop : 1; 180 bool fLeft : 1; 181 182 int32 fState; 183 184 bigtime_t fPulseRate; 185 bool fRefsRcvdOnly; 186 BMessage* fDragMessage; 187 BObjectList<BString>*fCachedTypesList; 188 TrackingHookData fTrackingHookData; 189 190 uint32 fMaxRecentDocs; 191 uint32 fMaxRecentApps; 192 193 TTeamMenuItem* fLastDragItem; 194 BList fExpandedItems; 195 BMessageFilter* fMouseFilter; 196 }; 197 198 199 inline TExpandoMenuBar* 200 TBarView::ExpandoMenuBar() const 201 { 202 return fExpando; 203 } 204 205 206 inline TBarMenuBar* 207 TBarView::BarMenuBar() const 208 { 209 return fBarMenuBar; 210 } 211 212 213 inline bool 214 TBarView::Dragging() const 215 { 216 return (fCachedTypesList && fDragMessage); 217 } 218 219 220 inline const BMessage* 221 TBarView::DragMessage() const 222 { 223 return fDragMessage; 224 } 225 226 227 inline BObjectList<BString>* 228 TBarView::CachedTypesList() const 229 { 230 return fCachedTypesList; 231 } 232 233 234 #endif /* BARVIEW_H */ 235