PObject * PObjectBroker::FindObject(const uint64 &id) { // 0 is a NULL object id if (!id) return NULL; for (int32 i = 0; i < fObjectList->CountItems(); i++) { PObject *obj = fObjectList->ItemAt(i); if (obj && obj->GetID() == id) return obj; } return NULL; }
void PropEnumEditor::HandleEdit(int32 value) { PObject *obj = GetObject(); PProperty *prop = obj->FindProperty(fPropName->String()); obj->SetIntProperty(fPropName->String(),value); BMessage *editMsg = new BMessage(M_PROPERTY_EDITED); if (obj && prop) { editMsg->AddPointer("object",obj); editMsg->AddPointer("property",prop); editMsg->AddInt64("objectid",obj->GetID()); editMsg->AddString("name",prop->GetName()); *fPropName = prop->GetName(); } fMsgr->SendMessage(editMsg); }
void MainWindow::UpdateProperties(void) { int32 selection = fListView->FullListCurrentSelection(); BMessenger msgr(fPropertyWin); BMessage msg(M_SET_OBJECT); if (selection < 0) { // If there is no selection, we empty the property window. 0 is a built-in invalid // object handle, just like NULL is an invalid pointer. msg.AddInt64("id",0); } else { ObjectItem *item = dynamic_cast<ObjectItem*>(fListView->FullListItemAt(selection)); PObject *obj = item->GetObject(); msg.AddInt64("id",obj->GetID()); } msgr.SendMessage(&msg); }