/// Intercept cell data change event. void ctPropertyEditor::OnChangeCell(wxGridEvent& event) { int row = event.GetRow(); int col = event.GetCol(); ApplyCellValueToProperty(row, col); }
void CPropertyGridEditor::OnConfirmBtnClicked(wxCommandEvent& /*event*/) { CListPropertyDescription* pListProperty = (CListPropertyDescription*)m_pGridProperty->GetClientData(); pListProperty->DeleteAllChild(); size_t uGridRows = m_pGrid->GetRows(); for (size_t i = 0; i < uGridRows; ++i) { CWxwidgetsPropertyBase* pNewProperty = down_cast<CWxwidgetsPropertyBase*>(pListProperty->AddChild(NULL)); pNewProperty->Initialize(); BEATS_ASSERT(m_cols.size() > 0 && pNewProperty != NULL); if (pNewProperty->GetType() == eRPT_Ptr) { CPtrPropertyDescription* pPtrProperty = down_cast<CPtrPropertyDescription*>(pNewProperty); BEATS_ASSERT(pPtrProperty != NULL && pPtrProperty->GetInstanceComponent() == NULL); pPtrProperty->CreateInstance(); const std::vector<CPropertyDescriptionBase*>* pProperties = pPtrProperty->GetInstanceComponent()->GetPropertyPool(); BEATS_ASSERT(pProperties->size() == m_cols.size()); for (size_t j = 0; j < pProperties->size(); ++j) { CPropertyDescriptionBase* pProperty = pProperties->at(j); ApplyCellValueToProperty(pProperty, i, j); } } else { BEATS_ASSERT(m_cols.size() == 1); ApplyCellValueToProperty(pNewProperty, i, 0); } } char valueStr[256]; pListProperty->GetValueAsChar(eVT_CurrentValue, valueStr); m_pGridProperty->SetValue(valueStr); m_pGridProperty->SetModifiedStatus(pListProperty->GetChildrenCount() > 0); m_pGridProperty->RecreateEditor(); CloseDialog(); }
/// Edit the details of this cell appropriately. bool ctPropertyEditor::EditDetails(wxWindow* WXUNUSED(parent)) { if (CanEditDetails()) { int row; ctProperty* prop = FindSelectedProperty(row); if (!prop) return false; wxString type(prop->GetEditorType()); wxString value = m_attributeEditorGrid->GetCellValue(row, 1); if (type == _T("multiline")) { value = ctConvertToMultilineText(value); wxString msg; msg.Printf(wxT("Edit %s:"), (const wxChar*) prop->GetName()); ctMultiLineTextEditor dialog(wxTheApp->GetTopWindow(), wxID_ANY, wxT("Edit Text Property"), msg, value); if (dialog.ShowModal() == wxID_OK) { value = ctConvertToSingleText(dialog.GetText()); m_attributeEditorGrid->SetCellValue(row, 1, value); ApplyCellValueToProperty(row, 1); return true; } else return false; } else if (type == _T("filename")) { wxString fullPath = value; wxString defaultDir ; wxString defaultFilename = wxFileNameFromPath(fullPath); defaultDir = wxPathOnly(value); wxString msg = wxT("Choose a filename"); wxFileDialog dialog(wxTheApp->GetTopWindow(), msg, defaultDir, defaultFilename, wxT("*.*")); if (dialog.ShowModal() == wxID_OK) { fullPath = dialog.GetPath(); value = fullPath; m_attributeEditorGrid->SetCellValue(row, 1, value); ApplyCellValueToProperty(row, 1); return true; } else return false; } else if (type == _T("configitems")) { wxArrayString items; ctConfigItem::StringToArray(value, items); ctConfigItemsSelector dialog(wxTheApp->GetTopWindow(), wxID_ANY, wxT("Select Configuration Items")); dialog.SetConfigList(items); if (dialog.ShowModal() == wxID_OK) { wxString newValue; items = dialog.GetConfigList(); ctConfigItem::ArrayToString(items, newValue); m_attributeEditorGrid->SetCellValue(row, 1, newValue); ApplyCellValueToProperty(row, 1); return true; } else return false; } } return false; }