This example is similar to Example 1, but uses a property form view to edit a property sheet using a predefined dialog box.
void RegisterValidators(void) { myFormValidatorRegistry.RegisterValidator((wxString)"real", new wxRealFormValidator); myFormValidatorRegistry.RegisterValidator((wxString)"string", new wxStringFormValidator); myFormValidatorRegistry.RegisterValidator((wxString)"integer", new wxIntegerFormValidator); myFormValidatorRegistry.RegisterValidator((wxString)"bool", new wxBoolFormValidator); } void PropertyFormTest(Bool useDialog) { wxPropertySheet *sheet = new wxPropertySheet; sheet->AddProperty(new wxProperty("fred", 25.0, "real", new wxRealFormValidator(0.0, 100.0))); sheet->AddProperty(new wxProperty("tough choice", (Bool)TRUE, "bool")); sheet->AddProperty(new wxProperty("ian", (long)45, "integer", new wxIntegerFormValidator(-50, 50))); sheet->AddProperty(new wxProperty("julian", "one", "string")); wxStringList *strings = new wxStringList("one", "two", "three", NULL); sheet->AddProperty(new wxProperty("constrained", "one", "string", new wxStringFormValidator(strings))); wxPropertyFormView *view = new wxPropertyFormView(NULL); wxDialogBox *propDialog = NULL; wxPropertyFormFrame *propFrame = NULL; if (useDialog) { propDialog = new wxPropertyFormDialog(view, NULL, "Property Form Test", TRUE, -1, -1, 400, 300); } else { propFrame = new wxPropertyFormFrame(view, NULL, "Property Form Test", -1, -1, 400, 300); propFrame->Initialize(); } wxPanel *panel = propDialog ? propDialog : propFrame->GetPropertyPanel(); panel->SetLabelPosition(wxVERTICAL); // Add items to the panel (void) new wxButton(panel, (wxFunction)NULL, "OK", -1, -1, -1, -1, 0, "ok"); (void) new wxButton(panel, (wxFunction)NULL, "Cancel", -1, -1, 80, -1, 0, "cancel"); (void) new wxButton(panel, (wxFunction)NULL, "Update", -1, -1, 80, -1, 0, "update"); (void) new wxButton(panel, (wxFunction)NULL, "Revert", -1, -1, -1, -1, 0, "revert"); panel->NewLine(); // The name of this text item matches the "fred" property (void) new wxText(panel, (wxFunction)NULL, "Fred", "", -1, -1, 90, -1, 0, "fred"); (void) new wxCheckBox(panel, (wxFunction)NULL, "Yes or no", -1, -1, -1, -1, 0, "tough choice"); (void) new wxSlider(panel, (wxFunction)NULL, "Sliding scale", 0, -50, 50, 100, -1, -1, wxHORIZONTAL, "ian"); panel->NewLine(); (void) new wxListBox(panel, (wxFunction)NULL, "Constrained", wxSINGLE, -1, -1, 100, 90, 0, NULL, 0, "constrained"); view->AddRegistry(&myFormValidatorRegistry); if (useDialog) { view->ShowView(sheet, propDialog); view->AssociateNames(); view->TransferToDialog(); propDialog->Centre(wxBOTH); propDialog->Show(TRUE); } else { view->ShowView(sheet, propFrame->GetPropertyPanel()); view->AssociateNames(); view->TransferToDialog(); propFrame->Centre(wxBOTH); propFrame->Show(TRUE); } }