xref: /haiku/src/apps/deskbar/BarApp.h (revision 3be9edf8da228afd9fec0390f408c964766122aa)
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 kWin95 = 'Bill';
67 const uint32 kAmiga = 'Ncro';
68 const uint32 kMac = 'WcOS';
69 const uint32 kBe = 'Tabs';
70 const uint32 kAlwaysTop = 'TTop';
71 const uint32 kToggleDraggers = 'TDra';
72 const uint32 kUnsubscribe = 'Unsb';
73 const uint32 kAddTeam = 'AdTm';
74 const uint32 kRemoveTeam = 'RmTm';
75 const uint32 kRestart = 'Rtrt';
76 const uint32 kShutDown = 'ShDn';
77 const uint32 kTrackerFirst = 'TkFt';
78 const uint32 kSortRunningApps = 'SAps';
79 const uint32 kSuperExpando = 'SprE';
80 const uint32 kExpandNewTeams = 'ExTm';
81 const uint32 kAutoRaise = 'AtRs';
82 
83 // from roster_private.h
84 const uint32 kShutdownSystem = 301;
85 const uint32 kRebootSystem = 302;
86 const uint32 kSuspendSystem = 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)
121 	+ sizeof(float);
122 const uint32 kValidSettingsSize2 = sizeof(BPoint) + kValidSettingsSize1;
123 const uint32 kValidSettingsSize3 = 2 * sizeof(int32) + kValidSettingsSize2;
124 const uint32 kValidSettingsSize4 = 2 * sizeof(bool) + kValidSettingsSize3;
125 const uint32 kValidSettingsSize5 = sizeof(int32) + kValidSettingsSize4;
126 const uint32 kValidSettingsSize6 = 2 * sizeof(bool) + kValidSettingsSize5;
127 const uint32 kValidSettingsSize7 = sizeof(bool) + kValidSettingsSize6;
128 const uint32 kValidSettingsSize8 = 2 * sizeof(bool) + kValidSettingsSize7;
129 const uint32 kValidSettingsSize9 = 2 * sizeof(bool) + kValidSettingsSize8;
130 const uint32 kValidSettingsSize10 = sizeof(bool) + kValidSettingsSize9;
131 
132 class TBarView;
133 class BFile;
134 
135 using namespace BPrivate;
136 
137 class TBarApp : public BApplication {
138 	public:
139 		TBarApp();
140 		virtual ~TBarApp();
141 
142 		virtual	bool QuitRequested();
143 		virtual void MessageReceived(BMessage* message);
144 		virtual void RefsReceived(BMessage* refs);
145 
146 		desk_settings* Settings()
147 			{ return &fSettings; }
148 		TBarView* BarView() const
149 			{ return fBarWindow->BarView(); }
150 		TBarWindow* BarWindow() const
151 			{ return fBarWindow; }
152 
153 		static void Subscribe(const BMessenger &subscriber, BList*);
154 		static void Unsubscribe(const BMessenger &subscriber);
155 
156 	private:
157 		void AddTeam(team_id team, uint32 flags, const char	*sig, entry_ref	*);
158 		void RemoveTeam(team_id);
159 
160 		void InitSettings();
161 		void SaveSettings();
162 
163 		void ShowPreferencesWindow();
164 
165 		TBarWindow* fBarWindow;
166 		BMessenger fSwitcherMessenger;
167 		BMessenger fStatusViewMessenger;
168 		BFile* fSettingsFile;
169 		desk_settings fSettings;
170 
171 		PreferencesWindow* fPreferencesWindow;
172 
173 		static BLocker sSubscriberLock;
174 		static BList sBarTeamInfoList;
175 		static BList sSubscribers;
176 };
177 
178 #endif	// BAR_APP_H
179 
180