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 BAR_APP_H
36#define BAR_APP_H
37
38
39#include <Server.h>
40
41#include "BarSettings.h"
42
43
44/* ------------------------------------ */
45// Private app_server defines that I need to use
46
47#define _DESKTOP_W_TYPE_ 1024
48#define _FLOATER_W_TYPE_ 4
49#define _STD_W_TYPE_ 0
50
51
52const uint32 kWin95 = 'Bill';
53const uint32 kAmiga = 'Ncro';
54const uint32 kMac = 'WcOS';
55const uint32 kBe = 'Tabs';
56const uint32 kAlwaysTop = 'TTop';
57const uint32 kToggleDraggers = 'TDra';
58const uint32 kUnsubscribe = 'Unsb';
59const uint32 kAddTeam = 'AdTm';
60const uint32 kRemoveTeam = 'RmTm';
61const uint32 kRestart = 'Rtrt';
62const uint32 kShutDown = 'ShDn';
63
64// from roster_private.h
65const uint32 kShutdownSystem = 301;
66const uint32 kRebootSystem = 302;
67const uint32 kSuspendSystem = 304;
68
69// icon size constants
70const int32 kIconPadding = B_USE_SMALL_SPACING;
71const int32 kMinimumIconSize = 16;
72const int32 kMaximumIconSize = 96;
73const int32 kIconSizeInterval = 8;
74const int32 kIconCacheCount = (kMaximumIconSize - kMinimumIconSize)
75	/ kIconSizeInterval + 1;
76
77// font size constants
78const int32 kMinimumFontSize = 8;
79const int32 kMaximumFontSize = 72;
80const int32 kFontSizeInterval = 1;
81const int32 kWindowIconCacheCount = (kMaximumFontSize - kMinimumFontSize)
82	/ kFontSizeInterval + 1;
83
84// update preferences message constant
85const uint32 kUpdatePreferences = 'Pref';
86
87// realign replicants message constant
88const uint32 kRealignReplicants = 'Algn';
89
90/* --------------------------------------------- */
91
92class BBitmap;
93class BFile;
94class BList;
95class PreferencesWindow;
96class TBarView;
97class TBarWindow;
98
99
100class BarTeamInfo {
101public:
102									BarTeamInfo(BList* teams, uint32 flags,
103										char* sig, char* name, BBitmap* icon = NULL);
104									BarTeamInfo(const BarTeamInfo &info);
105									~BarTeamInfo();
106
107private:
108			void					_Init();
109
110public:
111			BList*					teams;
112			uint32					flags;
113			char*					sig;
114			char*					name;
115			BBitmap*				icon;
116			BBitmap*				iconCache[kIconCacheCount];
117};
118
119
120class WindowIconCache {
121public:
122									WindowIconCache(int32 id, BBitmap* icon = NULL);
123									WindowIconCache(const WindowIconCache &cache);
124									~WindowIconCache();
125
126private:
127			void					_Init();
128
129public:
130			int32					id;
131			BBitmap*				icon;
132			BBitmap*				iconCache[kWindowIconCacheCount];
133};
134
135
136class TBarApp : public BServer {
137public:
138									TBarApp();
139	virtual							~TBarApp();
140
141	virtual	bool					QuitRequested();
142	virtual	void					MessageReceived(BMessage* message);
143	virtual	void					RefsReceived(BMessage* refs);
144
145			desk_settings*			Settings() { return &fSettings; }
146			desk_settings*			DefaultSettings()
147										{ return &fDefaultSettings; }
148			clock_settings*			ClockSettings() { return &fClockSettings; }
149
150			TBarView*				BarView() const { return fBarView; }
151			TBarWindow*				BarWindow() const { return fBarWindow; }
152
153	static	void					Subscribe(const BMessenger &subscriber,
154										BList*);
155	static	void					Unsubscribe(const BMessenger &subscriber);
156
157			int32					TeamIconSize();
158
159			BBitmap*				FetchTeamIcon(team_id team, int32 size);
160			BBitmap*				FetchWindowIcon(bool local = true,
161										bool minimized = false);
162
163private:
164			void					AddTeam(team_id team, uint32 flags,
165										const char* sig, entry_ref*);
166			void					RemoveTeam(team_id);
167
168			void					InitSettings();
169			void					SaveSettings();
170
171			void					ShowPreferencesWindow();
172			void					QuitPreferencesWindow();
173
174			void					ResizeTeamIcons();
175			status_t				_CacheTeamIcon(BarTeamInfo* barInfo);
176			status_t				_CacheTeamIcon(BarTeamInfo* barInfo, int32 size);
177			status_t				_CacheWindowIcon(WindowIconCache* winCache);
178
179private:
180			TBarWindow*				fBarWindow;
181			TBarView*				fBarView;
182			BMessenger				fSwitcherMessenger;
183			BMessenger				fStatusViewMessenger;
184			BFile*					fSettingsFile;
185			BFile*					fClockSettingsFile;
186			desk_settings			fSettings;
187			desk_settings			fDefaultSettings;
188			clock_settings			fClockSettings;
189			PreferencesWindow*		fPreferencesWindow;
190
191	static	BLocker					sSubscriberLock;
192	static	BList					sBarTeamInfoList;
193	static	BList					sWindowIconCache;
194	static	BList					sSubscribers;
195};
196
197
198#endif	// BAR_APP_H
199