xref: /haiku/src/apps/deskbar/BarApp.h (revision a5a3b2d9a3d95cbae71eaf371708c73a1780ac0d)
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 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 
52 const uint32 kWin95 = 'Bill';
53 const uint32 kAmiga = 'Ncro';
54 const uint32 kMac = 'WcOS';
55 const uint32 kBe = 'Tabs';
56 const uint32 kAlwaysTop = 'TTop';
57 const uint32 kToggleDraggers = 'TDra';
58 const uint32 kUnsubscribe = 'Unsb';
59 const uint32 kAddTeam = 'AdTm';
60 const uint32 kRemoveTeam = 'RmTm';
61 const uint32 kRestart = 'Rtrt';
62 const uint32 kShutDown = 'ShDn';
63 
64 // from roster_private.h
65 const uint32 kShutdownSystem = 301;
66 const uint32 kRebootSystem = 302;
67 const uint32 kSuspendSystem = 304;
68 
69 // icon size constants
70 const int32 kMinimumIconSize = 16;
71 const int32 kMaximumIconSize = 96;
72 const int32 kIconSizeInterval = 8;
73 const int32 kIconCacheCount = (kMaximumIconSize - kMinimumIconSize)
74 	/ kIconSizeInterval + 1;
75 
76 // update preferences message constant
77 const uint32 kUpdatePreferences = 'Pref';
78 
79 /* --------------------------------------------- */
80 
81 class BBitmap;
82 class BFile;
83 class BList;
84 class PreferencesWindow;
85 class TBarView;
86 class TBarWindow;
87 
88 class BarTeamInfo {
89 public:
90 									BarTeamInfo(BList* teams, uint32 flags,
91 										char* sig, BBitmap* icon, char* name);
92 									BarTeamInfo(const BarTeamInfo &info);
93 									~BarTeamInfo();
94 
95 private:
96 			void					_Init();
97 
98 public:
99 			BList*					teams;
100 			uint32					flags;
101 			char*					sig;
102 			BBitmap*				icon;
103 			char*					name;
104 			BBitmap*				iconCache[kIconCacheCount];
105 };
106 
107 class TBarApp : public BServer {
108 public:
109 									TBarApp();
110 	virtual							~TBarApp();
111 
112 	virtual	bool					QuitRequested();
113 	virtual	void					MessageReceived(BMessage* message);
114 	virtual	void					RefsReceived(BMessage* refs);
115 
116 			desk_settings*			Settings() { return &fSettings; }
117 			desk_settings*			DefaultSettings()
118 										{ return &fDefaultSettings; }
119 			clock_settings*			ClockSettings() { return &fClockSettings; }
120 
121 			TBarView*				BarView() const { return fBarView; }
122 			TBarWindow*				BarWindow() const { return fBarWindow; }
123 
124 	static	void					Subscribe(const BMessenger &subscriber,
125 										BList*);
126 	static	void					Unsubscribe(const BMessenger &subscriber);
127 
128 			int32					IconSize();
129 
130 private:
131 			void					AddTeam(team_id team, uint32 flags,
132 										const char* sig, entry_ref*);
133 			void					RemoveTeam(team_id);
134 
135 			void					InitSettings();
136 			void					SaveSettings();
137 
138 			void					ShowPreferencesWindow();
139 			void					QuitPreferencesWindow();
140 
141 			void					ResizeTeamIcons();
142 			void					FetchAppIcon(BarTeamInfo* barInfo);
143 
144 			BRect					IconRect();
145 
146 private:
147 			TBarWindow*				fBarWindow;
148 			TBarView*				fBarView;
149 			BMessenger				fSwitcherMessenger;
150 			BMessenger				fStatusViewMessenger;
151 			BFile*					fSettingsFile;
152 			BFile*					fClockSettingsFile;
153 			desk_settings			fSettings;
154 			desk_settings			fDefaultSettings;
155 			clock_settings			fClockSettings;
156 			PreferencesWindow*		fPreferencesWindow;
157 
158 	static	BLocker					sSubscriberLock;
159 	static	BList					sBarTeamInfoList;
160 	static	BList					sSubscribers;
161 };
162 
163 
164 #endif	// BAR_APP_H
165