void Properties::onPropertyChanging(wxPropertyGridEvent& event, Object* object) { if (object) { if (event.GetPropertyName() == "Name") { object->setName(event.GetValue().GetString().c_str()); } else if (event.GetPropertyName() == "Description") { object->setDescription(event.GetValue().GetString().c_str()); } switch (object->getType()) { case OT_BUILDING: onPropertyChanging(event, static_cast<Building*>(object)); break; case OT_JUNCTION: onPropertyChanging(event, static_cast<Junction*>(object)); break; case OT_PLANT: onPropertyChanging(event, static_cast<Plant*>(object)); break; case OT_ROUTE: onPropertyChanging(event, static_cast<Route*>(object)); break; case OT_WATER_OBJECT: onPropertyChanging(event, static_cast<WaterObject*>(object)); break; } City::getSingleton().updateViews(object); } }
void Properties::onPropertyChanging(wxPropertyGridEvent& event, Map* map) { if (event.GetPropertyName() == "Name") { map->setName(event.GetValue().GetString().c_str()); } else if (event.GetPropertyName() == "Texture") { map->setTexture(wxFileNameFromPath(event.GetValue().GetString()).c_str()); } City::getSingleton().updateViews(map); }
void Properties::onPropertyChanging(wxPropertyGridEvent& event, Building* object) { if (event.GetPropertyName() == "Height") { object->setHeight(event.GetValue().GetDouble()); } else if (event.GetPropertyName() == "Number") { object->setNumber(event.GetValue().GetLong()); } else if (event.GetPropertyName() == "Texture") { object->setTexture(wxFileNameFromPath(event.GetValue().GetString()).c_str()); } }
//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ void PropertiesView::onPropertyGridChanging(wxPropertyGridEvent& _event) { wxPGProperty* const pWXProperty = _event.GetProperty(); // TODO Don't assume this is a string. std::string newValue = wx2std(_event.GetValue().GetString()); if (pWXProperty->GetClientData() != NULL) { I_Property* pProperty = static_cast<I_Property*>(pWXProperty->GetClientData()); assert(pProperty != NULL); if (!pProperty->getPublisher().getController().canChangeProperty(*pProperty, newValue)) { // Veto the event. _event.Veto(); // Set the validation failure behavior. _event.SetValidationFailureBehavior(wxPG_VFB_STAY_IN_PROPERTY //| wxPG_VFB_BEEP //| wxPG_VFB_SHOW_MESSAGE ); } } }
int ArchesModel::OnPropertyGridChange(wxPropertyGridInterface *grid, wxPropertyGridEvent& event) { if ("ArchesCount" == event.GetPropertyName()) { ModelXml->DeleteAttribute("parm1"); ModelXml->AddAttribute("parm1", wxString::Format("%d", event.GetPropertyValue().GetLong())); SetFromXml(ModelXml, zeroBased); AdjustStringProperties(grid, parm1); return 3; } else if ("ArchesNodes" == event.GetPropertyName()) { ModelXml->DeleteAttribute("parm2"); ModelXml->AddAttribute("parm2", wxString::Format("%d", event.GetPropertyValue().GetLong())); SetFromXml(ModelXml, zeroBased); return 3; } else if ("ArchesLights" == event.GetPropertyName()) { ModelXml->DeleteAttribute("parm3"); ModelXml->AddAttribute("parm3", wxString::Format("%d", event.GetPropertyValue().GetLong())); SetFromXml(ModelXml, zeroBased); return 3; } else if ("ArchesArc" == event.GetPropertyName()) { ModelXml->DeleteAttribute("arc"); ModelXml->AddAttribute("arc", wxString::Format("%d", event.GetPropertyValue().GetLong())); SetFromXml(ModelXml, zeroBased); return 3; } else if ("ArchesStart" == event.GetPropertyName()) { ModelXml->DeleteAttribute("Dir"); ModelXml->AddAttribute("Dir", event.GetValue().GetLong() == 0 ? "L" : "R"); SetFromXml(ModelXml, zeroBased); return 3; } return Model::OnPropertyGridChange(grid, event); }
void Properties::onPropertyChanging(wxPropertyGridEvent& event, Database* database) { if (event.GetPropertyName() == "Name") { database->setName(event.GetValue().GetString().c_str()); } }
void Properties::onPropertyChanging(wxPropertyGridEvent& event, RouteView* view) { if (event.GetPropertyName() == "Segments") { unsigned short value = (unsigned short)event.GetValue().GetLong(); if (value < view->getRoute()->getPointCount()) { value = view->getRoute()->getPointCount(); } view->setSegments(value); } }
void Properties::onPropertyChanging(wxPropertyGridEvent& event, MapView* mapView) { if (event.GetPropertyName() == "Orthographic") { mapView->setIsOrthographic(event.GetValue().GetBool()); } else if (event.GetPropertyName() == "Scale") { double scale = event.GetValue().GetDouble(); if (scale < 0.1) { scale = 0.1; } else if (scale > 10.0) { scale = 10.0; } mapView->setScale(scale); mapView->update(); } }
void ChannelInspectorT::OnPropertyGridChanging(wxPropertyGridEvent& Event) { if (m_ModelDoc==NULL) return; const ArrayT<unsigned int>& Selection=m_ModelDoc->GetSelection(CHAN); if (Selection.Size()!=1) return; // Changing a property by pressing ENTER doesn't change the selection. In consequence the property refresh below does not result in // any change since selected properties are not updated (because the user could be in the process of editing a value). // Since the user is definitely finished editing this property we can safely clear the selection. // ClearSelection(); const unsigned int ChanNr =Selection[0]; const wxString PropName=Event.GetPropertyName(); m_IsRecursiveSelfNotify=true; bool ok=true; if (PropName=="Name") { ok=m_Parent->SubmitCommand(new CommandRenameT(m_ModelDoc, CHAN, ChanNr, Event.GetValue().GetString())); } else if (PropName.StartsWith("Joints.")) { ok=m_Parent->SubmitCommand(new CommandUpdateChannelT(m_ModelDoc, ChanNr, Event.GetProperty()->GetIndexInParent(), Event.GetValue().GetBool())); } else { // Changing child properties (e.g. "Pos.x" to "5") also generates events for the composite parent (e.g. "Pos" to "(5, 0, 0)")! // That is, if the following line is uncommented, it produces false warnings as well: // wxMessageBox("Unknown property label \""+Name+"\".", "Warning", wxOK | wxICON_ERROR); } wxASSERT(Event.CanVeto()); // EVT_PG_CHANGING events can be vetoed (as opposed to EVT_PG_CHANGED events). if (!ok) Event.Veto(); m_IsRecursiveSelfNotify=false; }
void InitialInstancesPropgridHelper::OnPropertyChanged(const std::vector<gd::InitialInstance*> & selectedInitialInstances, wxPropertyGridEvent& event) { if ( grid == NULL ) return; if ( selectedInitialInstances.empty() ) return; if ( event.GetPropertyName() == "INSTANCE_CUSTOM_SIZE" ) { bool hasCustomSize = grid->GetProperty("INSTANCE_CUSTOM_SIZE")->GetValue().GetBool(); grid->EnableProperty("INSTANCE_CUSTOM_SIZE.INSTANCE_SIZE_WIDTH", hasCustomSize); grid->EnableProperty("INSTANCE_CUSTOM_SIZE.INSTANCE_SIZE_HEIGHT", hasCustomSize); for (std::size_t i = 0;i<selectedInitialInstances.size();++i) selectedInitialInstances[i]->SetHasCustomSize(hasCustomSize); } else if ( event.GetPropertyName() == "INSTANCE_CUSTOM_SIZE.INSTANCE_SIZE_WIDTH" ) { for (std::size_t i = 0;i<selectedInitialInstances.size();++i) selectedInitialInstances[i]->SetCustomWidth(event.GetValue().GetReal()); } else if ( event.GetPropertyName() == "INSTANCE_CUSTOM_SIZE.INSTANCE_SIZE_HEIGHT" ) { for (std::size_t i = 0;i<selectedInitialInstances.size();++i) selectedInitialInstances[i]->SetCustomHeight(event.GetValue().GetReal()); } else if ( event.GetPropertyName() == "INSTANCE_X" ) { for (std::size_t i = 0;i<selectedInitialInstances.size();++i) selectedInitialInstances[i]->SetX(event.GetValue().GetReal()); } else if ( event.GetPropertyName() == "INSTANCE_Y" ) { for (std::size_t i = 0;i<selectedInitialInstances.size();++i) selectedInitialInstances[i]->SetY(event.GetValue().GetReal()); } else if ( event.GetPropertyName() == "INSTANCE_ANGLE" ) { for (std::size_t i = 0;i<selectedInitialInstances.size();++i) selectedInitialInstances[i]->SetAngle(event.GetValue().GetReal()); } else if ( event.GetPropertyName() == "INSTANCE_Z" ) { for (std::size_t i = 0;i<selectedInitialInstances.size();++i) selectedInitialInstances[i]->SetZOrder(event.GetValue().GetInteger()); } else if ( event.GetPropertyName() == "INSTANCE_LAYER" ) { for (std::size_t i = 0;i<selectedInitialInstances.size();++i) selectedInitialInstances[i]->SetLayer(event.GetValue().GetString()); } else if ( event.GetPropertyName() == "INSTANCE_LOCKED" ) { for (std::size_t i = 0;i<selectedInitialInstances.size();++i) selectedInitialInstances[i]->SetLocked(event.GetValue().GetBool()); } else { for (std::size_t i = 0;i<selectedInitialInstances.size();++i) { selectedInitialInstances[i]->UpdateCustomProperty(event.GetPropertyName(), event.GetValue().GetString(), project, layout); } } }
void PropertyPane::OnPropertyChanging(wxPropertyGridEvent &event) { wxPGProperty *prop = event.GetProperty(); wxVariant value = event.GetValue(); wxString sqlQuery, sqlUpdate, type, format, minStr, maxStr; long min, max, requestedValue; // event.GetValue() is always numeric base wxVariant. // Use wxPGProperty::ValueToString(wxVariant& value, int argFlags = 0) to // retrieve the string based property value for any kind of wxYYYProperty. if (prop && _propDB) { wxLogVerbose(wxT("OnPropertyChanging %s"), prop->ValueToString(value)); sqlQuery << wxT("SELECT PropertyType, PropertyFormat FROM PropTbl WHERE DisplayedName = '") << prop->GetLabel() << wxT("'"); wxSQLite3ResultSet set = _propDB->ExecuteQuery(sqlQuery); if (set.NextRow()) { type = set.GetAsString(wxT("PropertyType")); format = set.GetAsString(wxT("PropertyFormat")); } set.Finalize(); /* property format checker */ if (type == wxT("Numeric")) { wxStringTokenizer tokenizer(format, wxT(";")); minStr = tokenizer.GetNextToken(); maxStr = tokenizer.GetNextToken(); if (minStr.ToLong(&min) && maxStr.ToLong(&max)) { requestedValue = value.GetLong(); if ((requestedValue < min) || (requestedValue > max)) { event.Veto(); wxLogError(_("Input number out of range! Max = %s, Min = %s"), maxStr, minStr); return; } } } else if (type == wxT("List")) { /* no check item now. */ } else if (type == wxT("String")) { // TODO: check for max length } /* update database record */ _pgUpdatedFromUI = true; sqlUpdate << wxT("UPDATE PropTbl SET CurrentValue = '") << prop->ValueToString(value) << wxT("' WHERE DisplayedName = '") << prop->GetLabel() << wxT("'"); if (_propDB->ExecuteUpdate(sqlUpdate) != 1) { wxLogError(_("Failed to update property %s"), prop->GetLabel()); event.Veto(); } } }