xref: /haiku/src/apps/deskbar/BarApp.h (revision cb42238603639d60d3775a92b765715ef41edb97)
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 <Application.h>
40 
41 /* ------------------------------------ */
42 // Private app_server defines that I need to use
43 
44 #define _DESKTOP_W_TYPE_ 1024
45 #define _FLOATER_W_TYPE_ 4
46 #define _STD_W_TYPE_ 0
47 
48 
49 const uint32 kWin95 = 'Bill';
50 const uint32 kAmiga = 'Ncro';
51 const uint32 kMac = 'WcOS';
52 const uint32 kBe = 'Tabs';
53 const uint32 kAlwaysTop = 'TTop';
54 const uint32 kToggleDraggers = 'TDra';
55 const uint32 kUnsubscribe = 'Unsb';
56 const uint32 kAddTeam = 'AdTm';
57 const uint32 kRemoveTeam = 'RmTm';
58 const uint32 kRestart = 'Rtrt';
59 const uint32 kShutDown = 'ShDn';
60 const uint32 kRestartTracker = 'Trak';
61 
62 // from roster_private.h
63 const uint32 kShutdownSystem = 301;
64 const uint32 kRebootSystem = 302;
65 const uint32 kSuspendSystem = 304;
66 
67 // icon size constants
68 const int32 kMinimumIconSize = 16;
69 const int32 kMaximumIconSize = 96;
70 const int32 kIconSizeInterval = 8;
71 
72 // update preferences message constant
73 const uint32 kUpdatePreferences = 'Pref';
74 
75 /* --------------------------------------------- */
76 
77 struct desk_settings {
78 	bool vertical;
79 	bool left;
80 	bool top;
81 	uint32 state;
82 	float width;
83 	bool showClock;
84 	BPoint switcherLoc;
85 	int32 recentAppsCount;
86 	int32 recentDocsCount;
87 	bool timeShowSeconds;
88 	int32 recentFoldersCount;
89 	bool alwaysOnTop;
90 	bool timeFullDate;
91 	bool trackerAlwaysFirst;
92 	bool sortRunningApps;
93 	bool superExpando;
94 	bool expandNewTeams;
95 	bool hideLabels;
96 	int32 iconSize;
97 	bool autoRaise;
98 	bool autoHide;
99 	bool recentAppsEnabled;
100 	bool recentDocsEnabled;
101 	bool recentFoldersEnabled;
102 };
103 
104 struct clock_settings {
105 	bool showSeconds;
106 	bool showDayOfWeek;
107 	bool showTimeZone;
108 };
109 
110 
111 class BFile;
112 class BList;
113 class BBitmap;
114 class PreferencesWindow;
115 class TBarView;
116 class TBarWindow;
117 
118 class BarTeamInfo {
119 public:
120 									BarTeamInfo(BList* teams, uint32 flags,
121 										char* sig, BBitmap* icon, char* name);
122 									BarTeamInfo(const BarTeamInfo &info);
123 									~BarTeamInfo();
124 
125 			BList*					teams;
126 			uint32					flags;
127 			char*					sig;
128 			BBitmap*				icon;
129 			char*					name;
130 };
131 
132 class TBarApp : public BApplication {
133 public:
134 									TBarApp();
135 	virtual							~TBarApp();
136 
137 	virtual	bool					QuitRequested();
138 	virtual	void					MessageReceived(BMessage* message);
139 	virtual	void					RefsReceived(BMessage* refs);
140 
141 			desk_settings*			Settings() { return &fSettings; }
142 			clock_settings*			ClockSettings() { return &fClockSettings; }
143 
144 			TBarView*				BarView() const { return fBarView; }
145 			TBarWindow*				BarWindow() const { return fBarWindow; }
146 
147 	static	void					Subscribe(const BMessenger &subscriber,
148 										BList*);
149 	static	void					Unsubscribe(const BMessenger &subscriber);
150 
151 			int32					IconSize();
152 
153 private:
154 			void					AddTeam(team_id team, uint32 flags,
155 										const char* sig, entry_ref*);
156 			void					RemoveTeam(team_id);
157 
158 			void					InitSettings();
159 			void					SaveSettings();
160 
161 			void					ShowPreferencesWindow();
162 			void					QuitPreferencesWindow();
163 
164 			void					ResizeTeamIcons();
165 			void					FetchAppIcon(const char* signature,
166 										BBitmap* icon);
167 
168 			BRect					IconRect();
169 			TBarWindow*				fBarWindow;
170 			TBarView*				fBarView;
171 			BMessenger				fSwitcherMessenger;
172 			BMessenger				fStatusViewMessenger;
173 			BFile*					fSettingsFile;
174 			BFile*					fClockSettingsFile;
175 			desk_settings			fSettings;
176 			clock_settings			fClockSettings;
177 			PreferencesWindow*		fPreferencesWindow;
178 
179 	static	BLocker					sSubscriberLock;
180 	static	BList					sBarTeamInfoList;
181 	static	BList					sSubscribers;
182 };
183 
184 
185 #endif	/* BAR_APP_H */
186