xref: /haiku/src/apps/deskbar/BarApp.h (revision 1b8f7f13a3dc70e0e903cb94248220b40b732204)
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 #ifndef BAR_APP_H
35 #define BAR_APP_H
36 
37 
38 #include <Application.h>
39 #include <List.h>
40 #include "BarWindow.h"
41 
42 
43 /* ------------------------------------ */
44 // Private app_server defines that I need to use
45 
46 #define _DESKTOP_W_TYPE_ 1024
47 #define _FLOATER_W_TYPE_ 4
48 #define _STD_W_TYPE_ 0
49 
50 
51 class BarTeamInfo {
52 public:
53 	BarTeamInfo(BList *teams, uint32 flags, char *sig, BBitmap *icon,
54 				char *name);
55 	~BarTeamInfo();
56 
57 	BList *teams;
58 	uint32 flags;
59 	char *sig;
60 	BBitmap *icon;
61 	char *name;
62 };
63 
64 const uint32 msg_Win95 = 'Bill';
65 const uint32 msg_Amiga = 'Ncro';
66 const uint32 msg_Mac = 'WcOS';
67 const uint32 msg_Be = 'Tabs';
68 const uint32 msg_AlwaysTop = 'TTop';
69 const uint32 msg_ToggleDraggers = 'TDra';
70 const uint32 msg_config_db = 'cnfg';
71 const uint32 msg_Unsubscribe = 'Unsb';
72 const uint32 msg_AddTeam = 'AdTm';
73 const uint32 msg_RemoveTeam = 'RmTm';
74 const uint32 msg_Restart = 'Rtrt';
75 const uint32 msg_ShutDown = 'ShDn';
76 const uint32 msg_trackerFirst = 'TkFt';
77 const uint32 msg_sortRunningApps = 'SAps';
78 const uint32 msg_superExpando = 'SprE';
79 const uint32 msg_expandNewTeams = 'ExTm';
80 const uint32 msg_AutoRaise = 'AtRs';
81 
82 // from roster_private.h
83 const uint32 CMD_SHUTDOWN_SYSTEM = 301;
84 const uint32 CMD_REBOOT_SYSTEM = 302;
85 const uint32 CMD_SUSPEND_SYSTEM = 304;
86 
87 /* --------------------------------------------- */
88 
89 // if you want to extend this structure, maintain the
90 // constants below (used in TBarApp::InitSettings())
91 
92 struct desk_settings {
93 	bool vertical;				// version 1
94 	bool left;
95 	bool top;
96 	bool ampmMode;
97 	bool showTime;
98 	uint32 state;
99 	float width;
100 	BPoint switcherLoc;			// version 2
101 	int32 recentAppsCount;		// version 3
102 	int32 recentDocsCount;
103 	bool timeShowSeconds;		// version 4
104 	bool timeShowMil;
105 	int32 recentFoldersCount;	// version 5
106 	bool timeShowEuro;			// version 6
107 	bool alwaysOnTop;
108 	bool timeFullDate;			// version 7
109 	bool trackerAlwaysFirst;	// version 8
110 	bool sortRunningApps;
111 	bool superExpando;			// version 9
112 	bool expandNewTeams;
113 	bool autoRaise;				// version 10
114 };
115 
116 // the following structures are defined to compute
117 // valid sizes for "struct desk_settings"
118 
119 const uint32 kValidSettingsSize1 = 5 * sizeof(bool) + sizeof(uint32) + sizeof(float);
120 const uint32 kValidSettingsSize2 = sizeof(BPoint) + kValidSettingsSize1;
121 const uint32 kValidSettingsSize3 = 2 * sizeof(int32) + kValidSettingsSize2;
122 const uint32 kValidSettingsSize4 = 2 * sizeof(bool) + kValidSettingsSize3;
123 const uint32 kValidSettingsSize5 = sizeof(int32) + kValidSettingsSize4;
124 const uint32 kValidSettingsSize6 = 2 * sizeof(bool) + kValidSettingsSize5;
125 const uint32 kValidSettingsSize7 = sizeof(bool) + kValidSettingsSize6;
126 const uint32 kValidSettingsSize8 = 2 * sizeof(bool) + kValidSettingsSize7;
127 const uint32 kValidSettingsSize9 = 2 * sizeof(bool) + kValidSettingsSize8;
128 const uint32 kValidSettingsSize10 = sizeof(bool) + kValidSettingsSize9;
129 
130 class TBarView;
131 class BFile;
132 
133 namespace BPrivate {
134 	class TFavoritesConfigWindow;
135 }
136 
137 using namespace BPrivate;
138 
139 class TBarApp : public BApplication {
140 	public:
141 		TBarApp();
142 		virtual ~TBarApp();
143 
144 		virtual	bool QuitRequested();
145 		virtual void MessageReceived(BMessage *message);
146 		virtual void RefsReceived(BMessage *refs);
147 
148 		desk_settings *Settings()
149 			{ return &fSettings; }
150 		TBarView *BarView() const
151 			{ return fBarWindow->BarView(); }
152 		TBarWindow *BarWindow() const
153 			{ return fBarWindow; }
154 
155 		static void Subscribe(const BMessenger &subscriber, BList *);
156 		static void Unsubscribe(const BMessenger &subscriber);
157 
158 	private:
159 		void AddTeam(team_id team, uint32 flags, const char	*sig, entry_ref	*);
160 		void RemoveTeam(team_id);
161 
162 		void InitSettings();
163 		void SaveSettings();
164 
165 		void ShowConfigWindow();
166 
167 		TBarWindow *fBarWindow;
168 		BMessenger fSwitcherMessenger;
169 		BMessenger fStatusViewMessenger;
170 		BFile *fSettingsFile;
171 		desk_settings fSettings;
172 
173 		TFavoritesConfigWindow *fConfigWindow;
174 
175 		static BLocker sSubscriberLock;
176 		static BList sBarTeamInfoList;
177 		static BList sSubscribers;
178 };
179 
180 #endif	// BAR_APP_H
181