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