1/*
2Open Tracker License
3
4Terms and Conditions
5
6Copyright (c) 1991-2000, Be Incorporated. All rights reserved.
7
8Permission is hereby granted, free of charge, to any person obtaining a copy of
9this software and associated documentation files (the "Software"), to deal in
10the Software without restriction, including without limitation the rights to
11use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
12of the Software, and to permit persons to whom the Software is furnished to do
13so, subject to the following conditions:
14
15The above copyright notice and this permission notice applies to all licensees
16and shall be included in all copies or substantial portions of the Software.
17
18THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF TITLE, MERCHANTABILITY,
20FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
21BE INCORPORATED BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
22AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF, OR IN CONNECTION
23WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24
25Except as contained in this notice, the name of Be Incorporated shall not be
26used in advertising or otherwise to promote the sale, use or other dealings in
27this Software without prior written authorization from Be Incorporated.
28
29Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered
30trademarks of Be Incorporated in the United States and other countries. Other
31brand product names are registered trademarks or trademarks of their respective
32holders.
33All 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
46const uint32 kStateChanged = 'stch';
47
48
49enum DeskbarShelf {
50	B_DESKBAR_ANY_SHELF = 0,
51	B_DESKBAR_TRAY = 1
52};
53
54enum {
55	kMiniState = 0,
56	kExpandoState = 1,
57	kFullState = 2
58};
59
60const float kHModeHeight = 21.0f;
61const float kMenuBarHeight = 21.0f;
62const float kStatusHeight = 22.0f;
63const float kHiddenDimension = 1.0f;
64const float kMaxPreventHidingDist = 80.0f;
65
66
67class BShelf;
68class TBarApp;
69class TBarMenuBar;
70class TBarWindow;
71class TExpandoMenuBar;
72class TReplicantTray;
73class TDragRegion;
74class TResizeControl;
75class TInlineScrollView;
76class TTeamMenuItem;
77
78class TBarView : public BView {
79public:
80							TBarView(BRect frame, bool vertical, bool left,
81								bool top, int32 state, float width);
82							~TBarView();
83
84	virtual	void			AttachedToWindow();
85	virtual	void			DetachedFromWindow();
86
87	virtual	void			Draw(BRect updateRect);
88
89	virtual	void			MessageReceived(BMessage* message);
90
91	virtual	void			MouseDown(BPoint where);
92	virtual	void			MouseMoved(BPoint where, uint32 transit,
93								const BMessage* dragMessage);
94	virtual	void			MouseUp(BPoint where);
95
96			void			SaveSettings();
97
98			void			UpdatePlacement();
99			void			ChangeState(int32 state, bool vertical, bool left,
100								bool top, bool aSync = false);
101
102			void			RaiseDeskbar(bool raise);
103			void			HideDeskbar(bool hide);
104
105	// window placement methods
106			bool			Vertical() const { return fVertical; };
107			bool			Left() const { return fLeft; };
108			bool			Top() const { return fTop; };
109			bool			AcrossTop() const { return fTop && !fVertical
110								&& fState != kMiniState; };
111			bool			AcrossBottom() const { return !fTop && !fVertical
112								&& fState != kMiniState; };
113
114	// window state methods
115			bool			ExpandoState() const
116								{ return fState == kExpandoState; };
117			bool			FullState() const { return fState == kFullState; };
118			bool			MiniState() const { return fState == kMiniState; };
119			int32			State() const { return fState; };
120
121	// drag and drop methods
122			void			CacheDragData(const BMessage* incoming);
123			status_t		DragStart();
124	static	bool			MenuTrackingHook(BMenu* menu, void* castToThis);
125			void			DragStop(bool full = false);
126			TrackingHookData*	GetTrackingHookData();
127			bool			Dragging() const;
128			const			BMessage* DragMessage() const;
129			BObjectList<BString>*	CachedTypesList() const;
130			bool			AppCanHandleTypes(const char* signature);
131			void			SetDragOverride(bool);
132			bool			DragOverride();
133			bool			InvokeItem(const char* signature);
134
135			void			HandleDeskbarMenu(BMessage* targetmessage);
136
137			status_t		ItemInfo(int32 id, const char** name,
138								DeskbarShelf* shelf);
139			status_t		ItemInfo(const char* name, int32* id,
140								DeskbarShelf* shelf);
141
142			bool			ItemExists(int32 id, DeskbarShelf shelf);
143			bool			ItemExists(const char* name, DeskbarShelf shelf);
144
145			int32			CountItems(DeskbarShelf shelf);
146
147			BSize			MaxItemSize(DeskbarShelf shelf);
148
149			status_t		AddItem(BMessage* archive, DeskbarShelf shelf,
150								int32* id);
151			status_t		AddItem(BEntry* entry, DeskbarShelf shelf,
152								int32* id);
153
154			void			RemoveItem(int32 id);
155			void			RemoveItem(const char* name, DeskbarShelf shelf);
156
157			BRect			OffsetIconFrame(BRect rect) const;
158			BRect			IconFrame(int32 id) const;
159			BRect			IconFrame(const char* name) const;
160
161			void			GetPreferredWindowSize(BRect screenFrame,
162								float* width, float* height);
163			void			SizeWindow(BRect screenFrame);
164			void			PositionWindow(BRect screenFrame);
165
166			void			CheckForScrolling();
167
168			TExpandoMenuBar*	ExpandoMenuBar() const;
169			TBarMenuBar*		BarMenuBar() const;
170			TDragRegion*		DragRegion() const { return fDragRegion; }
171			TReplicantTray*		ReplicantTray() const { return fReplicantTray; }
172
173			float			TeamMenuItemHeight() const;
174			float			TabHeight() const { return fTabHeight; };
175
176private:
177	friend class TBarApp;
178	friend class TDeskbarMenu;
179	friend class PreferencesWindow;
180
181			status_t		SendDragMessage(const char* signature,
182								entry_ref* ref = NULL);
183
184			void			PlaceDeskbarMenu();
185			void			PlaceTray(bool vertSwap, bool leftSwap);
186			void			PlaceApplicationBar();
187
188			void			_ChangeState(BMessage* message);
189
190			TBarApp*			fBarApp;
191			TBarWindow*			fBarWindow;
192			TInlineScrollView*	fInlineScrollView;
193			TBarMenuBar*		fBarMenuBar;
194			TExpandoMenuBar*	fExpandoMenuBar;
195
196			int32			fTrayLocation;
197			TDragRegion*	fDragRegion;
198			TResizeControl*	fResizeControl;
199			TReplicantTray*	fReplicantTray;
200
201			bool			fIsRaised : 1;
202			bool			fMouseDownOutside : 1;
203
204			bool			fVertical : 1;
205			bool			fTop : 1;
206			bool			fLeft : 1;
207			int32			fState;
208
209			bigtime_t		fPulseRate;
210			bool			fRefsRcvdOnly;
211			BMessage*		fDragMessage;
212			BObjectList<BString>*	fCachedTypesList;
213			TrackingHookData		fTrackingHookData;
214
215			uint32			fMaxRecentDocs;
216			uint32			fMaxRecentApps;
217
218			TTeamMenuItem*	fLastDragItem;
219			BMessageFilter*	fMouseFilter;
220
221			float			fTabHeight;
222};
223
224
225inline TExpandoMenuBar*
226TBarView::ExpandoMenuBar() const
227{
228	return fExpandoMenuBar;
229}
230
231
232inline TBarMenuBar*
233TBarView::BarMenuBar() const
234{
235	return fBarMenuBar;
236}
237
238
239inline bool
240TBarView::Dragging() const
241{
242	return (fCachedTypesList && fDragMessage);
243}
244
245
246inline const BMessage*
247TBarView::DragMessage() const
248{
249	return fDragMessage;
250}
251
252
253inline BObjectList<BString>*
254TBarView::CachedTypesList() const
255{
256	return fCachedTypesList;
257}
258
259
260#endif	// BARVIEW_H
261