The following code fragment shows the essentials of creating a registry of standard validators, a property sheet containing some properties, and a property list view and dialog or frame. RegisterValidators will be called on program start, and PropertySheetTest is called in response to a menu command.
Note how some properties are created with an explicit reference to a validator, and others are provided with a "role'' which can be matched against a validator in the registry.
The interface generated by this test program is shown in the section Appearance and behaviour of a property list view.
void RegisterValidators(void) { myListValidatorRegistry.RegisterValidator((wxString)"real", new wxRealListValidator); myListValidatorRegistry.RegisterValidator((wxString)"string", new wxStringListValidator); myListValidatorRegistry.RegisterValidator((wxString)"integer", new wxIntegerListValidator); myListValidatorRegistry.RegisterValidator((wxString)"bool", new wxBoolListValidator); } void PropertyListTest(Bool useDialog) { wxPropertySheet *sheet = new wxPropertySheet; sheet->AddProperty(new wxProperty("fred", 1.0, "real")); sheet->AddProperty(new wxProperty("tough choice", (Bool)TRUE, "bool")); sheet->AddProperty(new wxProperty("ian", (long)45, "integer", new wxIntegerListValidator(-50, 50))); sheet->AddProperty(new wxProperty("bill", 25.0, "real", new wxRealListValidator(0.0, 100.0))); sheet->AddProperty(new wxProperty("julian", "one", "string")); sheet->AddProperty(new wxProperty("bitmap", "none", "string", new wxFilenameListValidator("Select a bitmap file", "*.bmp"))); wxStringList *strings = new wxStringList("one", "two", "three", NULL); sheet->AddProperty(new wxProperty("constrained", "one", "string", new wxStringListValidator(strings))); wxPropertyListView *view = new wxPropertyListView(NULL, wxPROP_BUTTON_CHECK_CROSS|wxPROP_DYNAMIC_VALUE_FIELD|wxPROP_PULLDOWN); wxDialogBox *propDialog = NULL; wxPropertyListFrame *propFrame = NULL; if (useDialog) { propDialog = new wxPropertyListDialog(view, NULL, "Property Sheet Test", TRUE, -1, -1, 400, 500); } else { propFrame = new wxPropertyListFrame(view, NULL, "Property Sheet Test", -1, -1, 400, 500); } view->AddRegistry(&myListValidatorRegistry); if (useDialog) { view->ShowView(sheet, propDialog); propDialog->Centre(wxBOTH); propDialog->Show(TRUE); } else { propFrame->Initialize(); view->ShowView(sheet, propFrame->GetPropertyPanel()); propFrame->Centre(wxBOTH); propFrame->Show(TRUE); } }