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 <Server.h> 40 41 #include "BarSettings.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 const uint32 kWin95 = 'Bill'; 53 const uint32 kAmiga = 'Ncro'; 54 const uint32 kMac = 'WcOS'; 55 const uint32 kBe = 'Tabs'; 56 const uint32 kAlwaysTop = 'TTop'; 57 const uint32 kToggleDraggers = 'TDra'; 58 const uint32 kUnsubscribe = 'Unsb'; 59 const uint32 kAddTeam = 'AdTm'; 60 const uint32 kRemoveTeam = 'RmTm'; 61 const uint32 kRestart = 'Rtrt'; 62 const uint32 kShutDown = 'ShDn'; 63 64 // from roster_private.h 65 const uint32 kShutdownSystem = 301; 66 const uint32 kRebootSystem = 302; 67 const uint32 kSuspendSystem = 304; 68 69 // icon size constants 70 const int32 kMinimumIconSize = 16; 71 const int32 kMaximumIconSize = 96; 72 const int32 kIconSizeInterval = 8; 73 const int32 kIconCacheCount = (kMaximumIconSize - kMinimumIconSize) 74 / kIconSizeInterval + 1; 75 76 // update preferences message constant 77 const uint32 kUpdatePreferences = 'Pref'; 78 79 // realign replicants message constant 80 const uint32 kRealignReplicants = 'Algn'; 81 82 // BDeskbar message constants 83 static const uint32 kMsgIsAlwaysOnTop = 'gtop'; 84 static const uint32 kMsgAlwaysOnTop = 'stop'; 85 static const uint32 kMsgIsAutoRaise = 'grse'; 86 static const uint32 kMsgAutoRaise = 'srse'; 87 static const uint32 kMsgIsAutoHide = 'ghid'; 88 static const uint32 kMsgAutoHide = 'shid'; 89 90 static const uint32 kMsgAddView = 'icon'; 91 static const uint32 kMsgAddAddOn = 'adon'; 92 static const uint32 kMsgHasItem = 'exst'; 93 static const uint32 kMsgGetItemInfo = 'info'; 94 static const uint32 kMsgCountItems = 'cwnt'; 95 static const uint32 kMsgRemoveItem = 'remv'; 96 static const uint32 kMsgLocation = 'gloc'; 97 static const uint32 kMsgIsExpanded = 'gexp'; 98 static const uint32 kMsgSetLocation = 'sloc'; 99 static const uint32 kMsgExpand = 'sexp'; 100 101 /* --------------------------------------------- */ 102 103 class BBitmap; 104 class BFile; 105 class BList; 106 class PreferencesWindow; 107 class TBarView; 108 class TBarWindow; 109 110 class BarTeamInfo { 111 public: 112 BarTeamInfo(BList* teams, uint32 flags, 113 char* sig, BBitmap* icon, char* name); 114 BarTeamInfo(const BarTeamInfo &info); 115 ~BarTeamInfo(); 116 117 private: 118 void _Init(); 119 120 public: 121 BList* teams; 122 uint32 flags; 123 char* sig; 124 BBitmap* icon; 125 char* name; 126 BBitmap* iconCache[kIconCacheCount]; 127 }; 128 129 class TBarApp : public BServer { 130 public: 131 TBarApp(); 132 virtual ~TBarApp(); 133 134 virtual bool QuitRequested(); 135 virtual void MessageReceived(BMessage* message); 136 virtual void RefsReceived(BMessage* refs); 137 138 desk_settings* Settings() { return &fSettings; } 139 desk_settings* DefaultSettings() 140 { return &fDefaultSettings; } 141 clock_settings* ClockSettings() { return &fClockSettings; } 142 143 TBarView* BarView() const { return fBarView; } 144 TBarWindow* BarWindow() const { return fBarWindow; } 145 146 static void Subscribe(const BMessenger &subscriber, 147 BList*); 148 static void Unsubscribe(const BMessenger &subscriber); 149 150 int32 IconSize(); 151 152 private: 153 void AddTeam(team_id team, uint32 flags, 154 const char* sig, entry_ref*); 155 void RemoveTeam(team_id); 156 157 void InitSettings(); 158 void SaveSettings(); 159 160 void ShowPreferencesWindow(); 161 void QuitPreferencesWindow(); 162 163 void ResizeTeamIcons(); 164 void FetchAppIcon(BarTeamInfo* barInfo); 165 166 BRect IconRect(); 167 168 private: 169 TBarWindow* fBarWindow; 170 TBarView* fBarView; 171 BMessenger fSwitcherMessenger; 172 BMessenger fStatusViewMessenger; 173 BFile* fSettingsFile; 174 BFile* fClockSettingsFile; 175 desk_settings fSettings; 176 desk_settings fDefaultSettings; 177 clock_settings fClockSettings; 178 PreferencesWindow* fPreferencesWindow; 179 180 static BLocker sSubscriberLock; 181 static BList sBarTeamInfoList; 182 static BList sSubscribers; 183 }; 184 185 186 #endif // BAR_APP_H 187