xref: /haiku/src/apps/deskbar/BarApp.h (revision 4d978eea2f9530892046f3344341ed85c9e0b1cf)
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
30 trademarks of Be Incorporated in the United States and other countries. Other
31 brand product names are registered trademarks or trademarks of their respective
32 holders.
33 All rights reserved.
34 */
35 #ifndef BAR_APP_H
36 #define BAR_APP_H
37 
38 
39 #include <Application.h>
40 #include <Catalog.h>
41 #include <List.h>
42 #include "BarWindow.h"
43 #include "PreferencesWindow.h"
44 
45 
46 /* ------------------------------------ */
47 // Private app_server defines that I need to use
48 
49 #define _DESKTOP_W_TYPE_ 1024
50 #define _FLOATER_W_TYPE_ 4
51 #define _STD_W_TYPE_ 0
52 
53 
54 class BarTeamInfo {
55 public:
56 	BarTeamInfo(BList* teams, uint32 flags, char* sig, BBitmap* icon,
57 				char* name);
58 	BarTeamInfo(const BarTeamInfo &info);
59 	~BarTeamInfo();
60 
61 	BList* teams;
62 	uint32 flags;
63 	char* sig;
64 	BBitmap* icon;
65 	char* name;
66 };
67 
68 const uint32 kWin95 = 'Bill';
69 const uint32 kAmiga = 'Ncro';
70 const uint32 kMac = 'WcOS';
71 const uint32 kBe = 'Tabs';
72 const uint32 kAlwaysTop = 'TTop';
73 const uint32 kToggleDraggers = 'TDra';
74 const uint32 kUnsubscribe = 'Unsb';
75 const uint32 kAddTeam = 'AdTm';
76 const uint32 kRemoveTeam = 'RmTm';
77 const uint32 kRestart = 'Rtrt';
78 const uint32 kShutDown = 'ShDn';
79 const uint32 kTrackerFirst = 'TkFt';
80 const uint32 kSortRunningApps = 'SAps';
81 const uint32 kSuperExpando = 'SprE';
82 const uint32 kExpandNewTeams = 'ExTm';
83 const uint32 kAutoRaise = 'AtRs';
84 const uint32 kRestartTracker = 'Trak';
85 
86 // from roster_private.h
87 const uint32 kShutdownSystem = 301;
88 const uint32 kRebootSystem = 302;
89 const uint32 kSuspendSystem = 304;
90 
91 /* --------------------------------------------- */
92 
93 struct desk_settings {
94 	bool vertical;
95 	bool left;
96 	bool top;
97 	bool ampmMode;
98 	bool showTime;
99 	uint32 state;
100 	float width;
101 	BPoint switcherLoc;
102 	int32 recentAppsCount;
103 	int32 recentDocsCount;
104 	bool timeShowSeconds;
105 	int32 recentFoldersCount;
106 	bool alwaysOnTop;
107 	bool timeFullDate;
108 	bool trackerAlwaysFirst;
109 	bool sortRunningApps;
110 	bool superExpando;
111 	bool expandNewTeams;
112 	bool autoRaise;
113 	bool recentAppsEnabled;
114 	bool recentDocsEnabled;
115 	bool recentFoldersEnabled;
116 };
117 
118 
119 class TBarView;
120 class BFile;
121 
122 using namespace BPrivate;
123 
124 class TBarApp : public BApplication {
125 	public:
126 		TBarApp();
127 		virtual ~TBarApp();
128 
129 		virtual	bool QuitRequested();
130 		virtual void MessageReceived(BMessage* message);
131 		virtual void RefsReceived(BMessage* refs);
132 
133 		desk_settings* Settings()
134 			{ return &fSettings; }
135 		TBarView* BarView() const
136 			{ return fBarWindow->BarView(); }
137 		TBarWindow* BarWindow() const
138 			{ return fBarWindow; }
139 
140 		static void Subscribe(const BMessenger &subscriber, BList*);
141 		static void Unsubscribe(const BMessenger &subscriber);
142 
143 	private:
144 		void AddTeam(team_id team, uint32 flags, const char	*sig, entry_ref	*);
145 		void RemoveTeam(team_id);
146 
147 		void InitSettings();
148 		void SaveSettings();
149 
150 		void ShowPreferencesWindow();
151 
152 		TBarWindow* fBarWindow;
153 		BMessenger fSwitcherMessenger;
154 		BMessenger fStatusViewMessenger;
155 		BFile* fSettingsFile;
156 		desk_settings fSettings;
157 
158 		PreferencesWindow* fPreferencesWindow;
159 
160 		static BLocker sSubscriberLock;
161 		static BList sBarTeamInfoList;
162 		static BList sSubscribers;
163 };
164 
165 #endif	// BAR_APP_H
166 
167