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