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