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