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