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 42 43 /* ------------------------------------ */ 44 // Private app_server defines that I need to use 45 46 #define _DESKTOP_W_TYPE_ 1024 47 #define _FLOATER_W_TYPE_ 4 48 #define _STD_W_TYPE_ 0 49 50 51 class BarTeamInfo { 52 public: 53 BarTeamInfo(BList *teams, uint32 flags, char *sig, BBitmap *icon, 54 char *name); 55 ~BarTeamInfo(); 56 57 BList *teams; 58 uint32 flags; 59 char *sig; 60 BBitmap *icon; 61 char *name; 62 }; 63 64 const uint32 msg_Win95 = 'Bill'; 65 const uint32 msg_Amiga = 'Ncro'; 66 const uint32 msg_Mac = 'WcOS'; 67 const uint32 msg_Be = 'Tabs'; 68 const uint32 msg_AlwaysTop = 'TTop'; 69 const uint32 msg_ToggleDraggers = 'TDra'; 70 const uint32 msg_config_db = 'cnfg'; 71 const uint32 msg_Unsubscribe = 'Unsb'; 72 const uint32 msg_AddTeam = 'AdTm'; 73 const uint32 msg_RemoveTeam = 'RmTm'; 74 const uint32 msg_Restart = 'Rtrt'; 75 const uint32 msg_ShutDown = 'ShDn'; 76 const uint32 msg_trackerFirst = 'TkFt'; 77 const uint32 msg_sortRunningApps = 'SAps'; 78 const uint32 msg_superExpando = 'SprE'; 79 const uint32 msg_expandNewTeams = 'ExTm'; 80 81 // from roster_private.h 82 const uint32 CMD_SHUTDOWN_SYSTEM = 301; 83 const uint32 CMD_REBOOT_SYSTEM = 302; 84 const uint32 CMD_SUSPEND_SYSTEM = 304; 85 86 /* --------------------------------------------- */ 87 88 // if you want to extend this structure, maintain the 89 // constants below (used in TBarApp::InitSettings()) 90 91 struct desk_settings { 92 bool vertical; // version 1 93 bool left; 94 bool top; 95 bool ampmMode; 96 bool showTime; 97 uint32 state; 98 float width; 99 BPoint switcherLoc; // version 2 100 int32 recentAppsCount; // version 3 101 int32 recentDocsCount; 102 bool timeShowSeconds; // version 4 103 bool timeShowMil; 104 int32 recentFoldersCount; // version 5 105 bool timeShowEuro; // version 6 106 bool alwaysOnTop; 107 bool timeFullDate; // version 7 108 bool trackerAlwaysFirst; // version 8 109 bool sortRunningApps; 110 bool superExpando; // version 9 111 bool expandNewTeams; 112 }; 113 114 // the following structures are defined to compute 115 // valid sizes for "struct desk_settings" 116 117 const uint32 kValidSettingsSize1 = 5 * sizeof(bool) + sizeof(uint32) + sizeof(float); 118 const uint32 kValidSettingsSize2 = sizeof(BPoint) + kValidSettingsSize1; 119 const uint32 kValidSettingsSize3 = 2 * sizeof(int32) + kValidSettingsSize2; 120 const uint32 kValidSettingsSize4 = 2 * sizeof(bool) + kValidSettingsSize3; 121 const uint32 kValidSettingsSize5 = sizeof(int32) + kValidSettingsSize4; 122 const uint32 kValidSettingsSize6 = 2 * sizeof(bool) + kValidSettingsSize5; 123 const uint32 kValidSettingsSize7 = sizeof(bool) + kValidSettingsSize6; 124 const uint32 kValidSettingsSize8 = 2 * sizeof(bool) + kValidSettingsSize7; 125 const uint32 kValidSettingsSize9 = 2 * sizeof(bool) + kValidSettingsSize8; 126 127 class TBarView; 128 class BFile; 129 130 namespace BPrivate { 131 class TFavoritesConfigWindow; 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 *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 ShowConfigWindow(); 163 164 TBarWindow *fBarWindow; 165 BMessenger fSwitcherMessenger; 166 BMessenger fStatusViewMessenger; 167 BFile *fSettingsFile; 168 desk_settings fSettings; 169 170 TFavoritesConfigWindow *fConfigWindow; 171 172 static BLocker sSubscriberLock; 173 static BList sBarTeamInfoList; 174 static BList sSubscribers; 175 }; 176 177 #endif // BAR_APP_H 178