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