// PropertyChanged void IconObjectListView::PropertyChanged(const Property* previous, const Property* current) { if (!fCommandStack || !fObject) return; PropertyObject* oldObject = new (nothrow) PropertyObject(); if (oldObject) oldObject->AddProperty(previous->Clone()); PropertyObject* newObject = new (nothrow) PropertyObject(); if (newObject) newObject->AddProperty(current->Clone()); IconObject** objects = new (nothrow) IconObject*[1]; if (objects) objects[0] = fObject; Command* command = new (nothrow) SetPropertiesCommand(objects, 1, oldObject, newObject); fIgnoreObjectChange = true; fCommandStack->Perform(command); fIgnoreObjectChange = false; }
// MakePropertyObject PropertyObject* IconObject::MakePropertyObject() const { PropertyObject* object = new PropertyObject(); object->AddProperty(new StringProperty(PROPERTY_NAME, fName.String())); return object; }
// MakePropertyObject PropertyObject* Shape::MakePropertyObject() const { PropertyObject* object = IconObject::MakePropertyObject(); if (!object) return NULL; // object->AddProperty(new BoolProperty(PROPERTY_HINTING, fHinting)); object->AddProperty(new FloatProperty(PROPERTY_MIN_VISIBILITY_SCALE, fMinVisibilityScale, 0, 4)); object->AddProperty(new FloatProperty(PROPERTY_MAX_VISIBILITY_SCALE, fMaxVisibilityScale, 0, 4)); return object; }
PropertyObject* VectorPath::MakePropertyObject() const { PropertyObject* object = IconObject::MakePropertyObject(); if (!object) return NULL; // closed object->AddProperty(new BoolProperty(PROPERTY_CLOSED, fClosed)); // archived path BMessage* archive = new BMessage(); if (Archive(archive) == B_OK) { object->AddProperty(new IconProperty(PROPERTY_PATH, kPathPropertyIconBits, kPathPropertyIconWidth, kPathPropertyIconHeight, kPathPropertyIconFormat, archive)); } return object; }
// MakePropertyObject PropertyObject* StrokeTransformer::MakePropertyObject() const { PropertyObject* object = Transformer::MakePropertyObject(); if (!object) return NULL; // width object->AddProperty(new FloatProperty(PROPERTY_WIDTH, width())); // cap mode OptionProperty* property = new OptionProperty(PROPERTY_CAP_MODE); property->AddOption(agg::butt_cap, "Butt"); property->AddOption(agg::square_cap, "Square"); property->AddOption(agg::round_cap, "Round"); property->SetCurrentOptionID(line_cap()); object->AddProperty(property); // join mode property = new OptionProperty(PROPERTY_JOIN_MODE); property->AddOption(agg::miter_join, "Miter"); property->AddOption(agg::round_join, "Round"); property->AddOption(agg::bevel_join, "Bevel"); property->SetCurrentOptionID(line_join()); object->AddProperty(property); // miter limit if (line_join() == agg::miter_join) { object->AddProperty(new FloatProperty(PROPERTY_MITER_LIMIT, miter_limit())); } // // shorten // object->AddProperty(new FloatProperty(PROPERTY_STROKE_SHORTEN, // shorten())); return object; }
// MessageReceived void PropertyListView::MessageReceived(BMessage* message) { switch (message->what) { case MSG_PASTE_PROPERTIES: { if (!fPropertyObject || !fClipboard->Lock()) break; BMessage* data = fClipboard->Data(); if (!data) { fClipboard->Unlock(); break; } PropertyObject propertyObject; BMessage archive; for (int32 i = 0; data->FindMessage("property", i, &archive) >= B_OK; i++) { BArchivable* archivable = instantiate_object(&archive); if (!archivable) continue; // see if this is actually a property Property* property = dynamic_cast<Property*>(archivable); if (property == NULL || !propertyObject.AddProperty(property)) delete archivable; } if (propertyObject.CountProperties() > 0) PasteProperties(&propertyObject); fClipboard->Unlock(); break; } case MSG_COPY_PROPERTIES: { if (!fPropertyObject || !fClipboard->Lock()) break; BMessage* data = fClipboard->Data(); if (!data) { fClipboard->Unlock(); break; } fClipboard->Clear(); for (int32 i = 0; PropertyItemView* item = _ItemAt(i); i++) { if (!item->IsSelected()) continue; const Property* property = item->GetProperty(); if (property) { BMessage archive; if (property->Archive(&archive) >= B_OK) { data->AddMessage("property", &archive); } } } fClipboard->Commit(); fClipboard->Unlock(); _CheckMenuStatus(); break; } // property selection case MSG_SELECT_ALL: for (int32 i = 0; PropertyItemView* item = _ItemAt(i); i++) { item->SetSelected(true); } _CheckMenuStatus(); break; case MSG_SELECT_NONE: for (int32 i = 0; PropertyItemView* item = _ItemAt(i); i++) { item->SetSelected(false); } _CheckMenuStatus(); break; case MSG_INVERT_SELECTION: for (int32 i = 0; PropertyItemView* item = _ItemAt(i); i++) { item->SetSelected(!item->IsSelected()); } _CheckMenuStatus(); break; default: BView::MessageReceived(message); } }