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 36 37 #include "StatusViewShelf.h" 38 39 #include <stdio.h> 40 #include <string.h> 41 42 #include <Debug.h> 43 #include <InterfaceDefs.h> 44 45 #include "StatusView.h" 46 47 48 TReplicantShelf::TReplicantShelf(TReplicantTray* parent) 49 : BShelf(parent, false, "DeskbarShelf") 50 { 51 fParent = parent; 52 SetAllowsZombies(false); 53 } 54 55 56 TReplicantShelf::~TReplicantShelf() 57 { 58 } 59 60 61 void 62 TReplicantShelf::MessageReceived(BMessage* message) 63 { 64 switch (message->what) { 65 case B_DELETE_PROPERTY: 66 { 67 BMessage repspec; 68 int32 index = 0; 69 70 // this should only occur via scripting 71 // since we can't use ReplicantDeleted 72 // catch the message and find the id or name specifier 73 // then delete the rep vi the api, 74 75 // this will fix the problem of realigning the reps 76 // after a remove when done through scripting 77 78 // note: if specified by index its the index not the id! 79 80 while (message->FindMessage("specifiers", index++, &repspec) 81 == B_OK) { 82 const char* str; 83 84 if (repspec.FindString("property", &str) == B_OK) { 85 if (strcmp(str, "Replicant") == 0) { 86 int32 index; 87 if (repspec.FindInt32("index", &index) == B_OK) { 88 int32 id; 89 const char* name; 90 if (fParent->ItemInfo(index, &name, &id) == B_OK) 91 fParent->RemoveIcon(id); 92 break; 93 } else if (repspec.FindString("name", &str) == B_OK) { 94 fParent->RemoveIcon(str); 95 break; 96 } 97 } 98 } 99 } 100 break; 101 } 102 103 default: 104 BShelf::MessageReceived(message); 105 break; 106 } 107 } 108 109 110 bool 111 TReplicantShelf::CanAcceptReplicantView(BRect frame, BView* view, 112 BMessage* message) const 113 { 114 if (view->ResizingMode() != B_FOLLOW_NONE) 115 view->SetResizingMode(B_FOLLOW_NONE); 116 117 // determine placement and whether the new replicant will 'fit' 118 return fParent->AcceptAddon(frame, message); 119 } 120 121 122 BPoint 123 TReplicantShelf::AdjustReplicantBy(BRect frame, BMessage* message) const 124 { 125 // added in AcceptAddon, from TReplicantTray 126 BPoint point; 127 message->FindPoint("_pjp_loc", &point); 128 message->RemoveName("_pjp_loc"); 129 130 return point - frame.LeftTop(); 131 } 132 133 134 // the virtual BShelf::ReplicantDeleted is called before the 135 // replicant is actually removed from BShelf's internal list 136 // thus, this returns the wrong number of replicants. 137 138 void 139 TReplicantShelf::ReplicantDeleted(int32, const BMessage*, const BView*) 140 { 141 } 142