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) == B_OK) { 78 const char* str; 79 if (repspec.FindString("property", &str) == B_OK) { 80 if (strcmp(str, "Replicant") == 0) { 81 int32 index; 82 if (repspec.FindInt32("index", &index) == B_OK) { 83 int32 id; 84 const char* name; 85 if (fParent->ItemInfo(index, &name, &id) == B_OK) 86 fParent->RemoveIcon(id); 87 break; 88 } else if (repspec.FindString("name", &str) == B_OK) { 89 fParent->RemoveIcon(str); 90 break; 91 } 92 } 93 } 94 } 95 break; 96 } 97 98 default: 99 BShelf::MessageReceived(message); 100 break; 101 } 102 } 103 104 105 bool 106 TReplicantShelf::CanAcceptReplicantView(BRect frame, BView* view, 107 BMessage* message) const 108 { 109 if (view->ResizingMode() != B_FOLLOW_NONE) 110 view->SetResizingMode(B_FOLLOW_NONE); 111 112 // determine placement and whether the new replicant will 'fit' 113 return fParent->AcceptAddon(frame, message); 114 } 115 116 117 BPoint 118 TReplicantShelf::AdjustReplicantBy(BRect frame, BMessage *message) const 119 { 120 // added in AcceptAddon, from TReplicantTray 121 BPoint point; 122 message->FindPoint("_pjp_loc", &point); 123 message->RemoveName("_pjp_loc"); 124 125 return point - frame.LeftTop(); 126 } 127 128 129 // the virtual BShelf::ReplicantDeleted is called before the 130 // replicant is actually removed from BShelf's internal list 131 // thus, this returns the wrong number of replicants. 132 133 void 134 TReplicantShelf::ReplicantDeleted(int32, const BMessage*, const BView*) 135 { 136 } 137