xref: /haiku/src/apps/deskbar/BarApp.h (revision e36a1b58e6daf3efeec46621114691ef499faafc)
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 #include "PreferencesWindow.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 class BarTeamInfo {
53 public:
54 	BarTeamInfo(BList *teams, uint32 flags, char *sig, BBitmap *icon,
55 				char *name);
56 	BarTeamInfo(const BarTeamInfo &info);
57 	~BarTeamInfo();
58 
59 	BList *teams;
60 	uint32 flags;
61 	char *sig;
62 	BBitmap *icon;
63 	char *name;
64 };
65 
66 const uint32 msg_Win95 = 'Bill';
67 const uint32 msg_Amiga = 'Ncro';
68 const uint32 msg_Mac = 'WcOS';
69 const uint32 msg_Be = 'Tabs';
70 const uint32 msg_AlwaysTop = 'TTop';
71 const uint32 msg_ToggleDraggers = 'TDra';
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 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 *message);
143 		virtual void RefsReceived(BMessage *refs);
144 
145 		desk_settings *Settings()
146 			{ return &fSettings; }
147 		TBarView *BarView() const
148 			{ return fBarWindow->BarView(); }
149 		TBarWindow *BarWindow() const
150 			{ return fBarWindow; }
151 
152 		static void Subscribe(const BMessenger &subscriber, BList *);
153 		static void Unsubscribe(const BMessenger &subscriber);
154 
155 	private:
156 		void AddTeam(team_id team, uint32 flags, const char	*sig, entry_ref	*);
157 		void RemoveTeam(team_id);
158 
159 		void InitSettings();
160 		void SaveSettings();
161 
162 		void ShowPreferencesWindow();
163 
164 		TBarWindow *fBarWindow;
165 		BMessenger fSwitcherMessenger;
166 		BMessenger fStatusViewMessenger;
167 		BFile *fSettingsFile;
168 		desk_settings fSettings;
169 
170 		PreferencesWindow* fPreferencesWindow;
171 
172 		static BLocker sSubscriberLock;
173 		static BList sBarTeamInfoList;
174 		static BList sSubscribers;
175 };
176 
177 #endif	// BAR_APP_H
178 
179