]>
git.saurik.com Git - wxWidgets.git/blob - docs/doxygen/overviews/propgrid.h
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: topic overview
4 // Author: wxWidgets team
6 // Licence: wxWindows license
7 /////////////////////////////////////////////////////////////////////////////
11 @page overview_propgrid wxPropertyGrid Overview
16 @li wxPropertyGridEvent
17 @li wxPropertyGridManager
18 @li wxPropertyGridPage
20 wxPropertyGrid is a specialized grid for editing properties - in other
21 words name = value pairs. List of ready-to-use property classes include
22 strings, numbers, flag sets, fonts, colours and many others. It is possible,
23 for example, to categorize properties, set up a complete tree-hierarchy,
24 add more than two columns, and set arbitrary per-property attributes.
26 @li @ref propgrid_basics
27 @li @ref propgrid_categories
28 @li @ref propgrid_parentprops
29 @li @ref propgrid_enumandflags
30 @li @ref propgrid_advprops
31 @li @ref propgrid_processingvalues
32 @li @ref propgrid_iterating
33 @li @ref propgrid_events
34 @li @ref propgrid_validating
35 @li @ref propgrid_populating
36 @li @ref propgrid_cellrender
37 @li @ref propgrid_customizing
38 @li @ref propgrid_usage2
39 @li @ref propgrid_subclassing
40 @li @ref propgrid_misc
41 @li @ref propgrid_proplist
43 @section propgrid_basics Creating and Populating wxPropertyGrid
45 As seen here, wxPropertyGrid is constructed in the same way as
46 other wxWidgets controls:
50 // Necessary header file
51 #include <wx/propgrid/propgrid.h>
55 // Assumes code is in frame/dialog constructor
57 // Construct wxPropertyGrid control
58 wxPropertyGrid* pg = new wxPropertyGrid(
61 wxDefaultPosition, // position
62 wxDefaultSize, // size
63 // Here are just some of the supported window styles
64 wxPG_AUTO_SORT | // Automatic sorting after items added
65 wxPG_SPLITTER_AUTO_CENTER | // Automatically center splitter until user manually adjusts it
69 // Window style flags are at premium, so some less often needed ones are
70 // available as extra window styles (wxPG_EX_xxx) which must be set using
71 // SetExtraStyle member function. wxPG_EX_HELP_AS_TOOLTIPS, for instance,
72 // allows displaying help strings as tool tips.
73 pg->SetExtraStyle( wxPG_EX_HELP_AS_TOOLTIPS );
77 (for complete list of new window styles, see @ref propgrid_window_styles)
79 wxPropertyGrid is usually populated with lines like this:
82 pg->Append( new wxStringProperty(wxT("Label"),wxT("Name"),wxT("Initial Value")) );
85 Naturally, wxStringProperty is a property class. Only the first function argument (label)
86 is mandatory. Second one, name, defaults to label and, third, the initial value, to
87 default value. If constant wxPG_LABEL is used as the name argument, then the label is
88 automatically used as a name as well (this is more efficient than manually defining both
89 as the same). Use of empty name is discouraged and will sometimes result in run-time error.
90 Note that all property class constructors have quite similar constructor argument list.
92 To demonstrate other common property classes, here's another code snippet:
97 pg->Append( new wxIntProperty(wxT("IntProperty"), wxPG_LABEL, 12345678) );
99 // Add float property (value type is actually double)
100 pg->Append( new wxFloatProperty(wxT("FloatProperty"), wxPG_LABEL, 12345.678) );
102 // Add a bool property
103 pg->Append( new wxBoolProperty(wxT("BoolProperty"), wxPG_LABEL, false) );
105 // A string property that can be edited in a separate editor dialog.
106 pg->Append( new wxLongStringProperty(wxT("LongStringProperty"),
108 wxT("This is much longer string than the ")
109 wxT("first one. Edit it by clicking the button.")));
111 // String editor with dir selector button.
112 pg->Append( new wxDirProperty(wxT("DirProperty"), wxPG_LABEL, ::wxGetUserHome()) );
114 // wxArrayStringProperty embeds a wxArrayString.
115 pg->Append( new wxArrayStringProperty(wxT("Label of ArrayStringProperty"),
116 wxT("NameOfArrayStringProp")));
118 // A file selector property.
119 pg->Append( new wxFileProperty(wxT("FileProperty"), wxPG_LABEL, wxEmptyString) );
121 // Extra: set wild card for file property (format same as in wxFileDialog).
122 pg->SetPropertyAttribute( wxT("FileProperty"),
124 wxT("All files (*.*)|*.*") );
128 Operations on properties are usually done by directly calling wxPGProperty's
129 or wxPropertyGridInterface's member functions. wxPropertyGridInterface is an
130 abstract base class for property containers such as wxPropertyGrid,
131 wxPropertyGridManager, and wxPropertyGridPage. Note however that wxPGProperty's
132 member functions generally do not refresh the grid.
134 wxPropertyGridInterface's property operation member functions , such as
135 SetPropertyValue() and DisableProperty(), all accept a special wxPGPropArg id
136 argument, using which you can refer to properties either by their pointer
137 (for performance) or by their name (for convenience). For instance:
140 // Add a file selector property.
141 wxPGPropety* prop = pg->Append( new wxFileProperty(wxT("FileProperty"),
145 // Valid: Set wild card by name
146 pg->SetPropertyAttribute( wxT("FileProperty"),
148 wxT("All files (*.*)|*.*") );
150 // Also Valid: Set wild card by property pointer
151 pg->SetPropertyAttribute( prop,
153 wxT("All files (*.*)|*.*") );
156 Using pointer is faster, since it doesn't require hash map lookup. Anyway,
157 you can always get property pointer (wxPGProperty*) as return value from Append()
158 or Insert(), or by calling wxPropertyGridInterface::GetPropertyByName() or
159 just plain GetProperty().
161 @section propgrid_categories Categories
163 wxPropertyGrid has a hierarchic property storage and display model, which
164 allows property categories to hold child properties and even other
165 categories. Other than that, from the programmer's point of view, categories
166 can be treated exactly the same as "other" properties. For example, despite
167 its name, GetPropertyByName() also returns a category by name. Note however
168 that sometimes the label of a property category may be referred as caption
169 (for example, there is wxPropertyGrid::SetCaptionTextColour() method
170 that sets text colour of property category labels).
172 When category is added at the top (i.e. root) level of the hierarchy,
173 it becomes a *current category*. This means that all other (non-category)
174 properties after it are automatically appended to it. You may add
175 properties to specific categories by using wxPropertyGridInterface::Insert
176 or wxPropertyGridInterface::AppendIn.
178 Category code sample:
182 // One way to add category (similar to how other properties are added)
183 pg->Append( new wxPropertyCategory(wxT("Main")) );
185 // All these are added to "Main" category
186 pg->Append( new wxStringProperty(wxT("Name")) );
187 pg->Append( new wxIntProperty(wxT("Age"),wxPG_LABEL,25) );
188 pg->Append( new wxIntProperty(wxT("Height"),wxPG_LABEL,180) );
189 pg->Append( new wxIntProperty(wxT("Weight")) );
192 pg->Append( new wxPropertyCategory(wxT("Attributes")) );
194 // All these are added to "Attributes" category
195 pg->Append( new wxIntProperty(wxT("Intelligence")) );
196 pg->Append( new wxIntProperty(wxT("Agility")) );
197 pg->Append( new wxIntProperty(wxT("Strength")) );
202 @section propgrid_parentprops Tree-like Property Structure
204 Basically any property can have children. There are few limitations, however.
207 - Names of properties with non-category, non-root parents are not stored in global
208 hash map. Instead, they can be accessed with strings like "Parent.Child".
209 For instance, in the sample below, child property named "Max. Speed (mph)"
210 can be accessed by global name "Car.Speeds.Max Speed (mph)".
211 - If you want to property's value to be a string composed of the child property values,
212 you must use wxStringProperty as parent and use magic string "<composed>" as its
214 - Events (eg. change of value) that occur in parent do not propagate to children. Events
215 that occur in children will propagate to parents, but only if they are wxStringProperties
216 with "<composed>" value.
221 wxPGProperty* carProp = pg->Append(new wxStringProperty(wxT("Car"),
225 pg->AppendIn(carProp, new wxStringProperty(wxT("Model"),
227 wxT("Lamborghini Diablo SV")));
229 pg->AppendIn(carProp, new wxIntProperty(wxT("Engine Size (cc)"),
233 wxPGProperty* speedsProp = pg->AppendIn(carProp,
234 new wxStringProperty(wxT("Speeds"),
238 pg->AppendIn( speedsProp, new wxIntProperty(wxT("Max. Speed (mph)"),
240 pg->AppendIn( speedsProp, new wxFloatProperty(wxT("0-100 mph (sec)"),
242 pg->AppendIn( speedsProp, new wxFloatProperty(wxT("1/4 mile (sec)"),
245 // This is how child property can be referred to by name
246 pg->SetPropertyValue( wxT("Car.Speeds.Max. Speed (mph)"), 300 );
248 pg->AppendIn(carProp, new wxIntProperty(wxT("Price ($)"),
252 // Displayed value of "Car" property is now very close to this:
253 // "Lamborghini Diablo SV; 5707 [300; 3.9; 8.6] 300000"
257 @section propgrid_enumandflags wxEnumProperty and wxFlagsProperty
259 wxEnumProperty is used when you want property's (integer or string) value
260 to be selected from a popup list of choices.
262 Creating wxEnumProperty is slightly more complex than those described
263 earlier. You have to provide list of constant labels, and optionally relevant
264 values (if label indexes are not sufficient).
268 - Value wxPG_INVALID_VALUE (equals INT_MAX) is not allowed as list
271 A very simple example:
276 // Using wxArrayString
278 wxArrayString arrDiet;
279 arr.Add(wxT("Herbivore"));
280 arr.Add(wxT("Carnivore"));
281 arr.Add(wxT("Omnivore"));
283 pg->Append( new wxEnumProperty(wxT("Diet"),
288 // Using wxChar* array
290 const wxChar* arrayDiet[] =
291 { wxT("Herbivore"), wxT("Carnivore"), wxT("Omnivore"), NULL };
293 pg->Append( new wxEnumProperty(wxT("Diet"),
299 Here's extended example using values as well:
304 // Using wxArrayString and wxArrayInt
306 wxArrayString arrDiet;
307 arr.Add(wxT("Herbivore"));
308 arr.Add(wxT("Carnivore"));
309 arr.Add(wxT("Omnivore"));
316 // Note that the initial value (the last argument) is the actual value,
317 // not index or anything like that. Thus, our value selects "Omnivore".
318 pg->Append( new wxEnumProperty(wxT("Diet"),
326 wxPGChoices is a class where wxEnumProperty, and other properties which
327 require storage for list of items, actually stores strings and values. It is
328 used to facilitate reference counting, and therefore recommended way of
329 adding items when multiple properties share the same set.
331 You can use wxPGChoices directly as well, filling it and then passing it
332 to the constructor. In fact, if you wish to display bitmaps next to labels,
333 your best choice is to use this approach.
338 chs.Add(wxT("Herbivore"), 40);
339 chs.Add(wxT("Carnivore"), 45);
340 chs.Add(wxT("Omnivore"), 50);
342 // Let's add an item with bitmap, too
343 chs.Add(wxT("None of the above"), wxBitmap(), 60);
345 pg->Append( new wxEnumProperty(wxT("Primary Diet"),
349 // Add same choices to another property as well - this is efficient due
350 // to reference counting
351 pg->Append( new wxEnumProperty(wxT("Secondary Diet"),
356 You can later change choices of property by using wxPGProperty::AddChoice(),
357 wxPGProperty::InsertChoice(), wxPGProperty::DeleteChoice(), and
358 wxPGProperty::SetChoices().
360 <b>wxEditEnumProperty</b> works exactly like wxEnumProperty, except
361 is uses non-read-only combo box as default editor, and value is stored as
362 string when it is not any of the choices.
364 wxFlagsProperty has similar construction:
368 const wxChar* flags_prop_labels[] = { wxT("wxICONIZE"),
369 wxT("wxCAPTION"), wxT("wxMINIMIZE_BOX"), wxT("wxMAXIMIZE_BOX"), NULL };
371 // this value array would be optional if values matched string indexes
372 long flags_prop_values[] = { wxICONIZE, wxCAPTION, wxMINIMIZE_BOX,
375 pg->Append( new wxFlagsProperty(wxT("Window Style"),
379 wxDEFAULT_FRAME_STYLE) );
383 wxFlagsProperty can use wxPGChoices just the same way as wxEnumProperty
384 <b>Note:</b> When changing "choices" (ie. flag labels) of wxFlagsProperty,
385 you will need to use wxPGProperty::SetChoices() to replace all choices
386 at once - otherwise implicit child properties will not get updated properly.
388 @section propgrid_advprops Specialized Properties
390 This section describes the use of less often needed property classes.
391 To use them, you have to include <wx/propgrid/advprops.h>.
395 // Necessary extra header file
396 #include <wx/propgrid/advprops.h>
401 pg->Append( new wxDateProperty(wxT("MyDateProperty"),
403 wxDateTime::Now()) );
405 // Image file property. Wild card is auto-generated from available
406 // image handlers, so it is not set this time.
407 pg->Append( new wxImageFileProperty(wxT("Label of ImageFileProperty"),
408 wxT("NameOfImageFileProp")) );
410 // Font property has sub-properties. Note that we give window's font as
412 pg->Append( new wxFontProperty(wxT("Font"),
416 // Colour property with arbitrary colour.
417 pg->Append( new wxColourProperty(wxT("My Colour 1"),
419 wxColour(242,109,0) ) );
421 // System colour property.
422 pg->Append( new wxSystemColourProperty(wxT("My SysColour 1"),
424 wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW)) );
426 // System colour property with custom colour.
427 pg->Append( new wxSystemColourProperty(wxT("My SysColour 2"),
429 wxColour(0,200,160) ) );
432 pg->Append( new wxCursorProperty(wxT("My Cursor"),
439 @section propgrid_processingvalues Processing Property Values
441 Properties store their values internally in wxVariant. You can obtain
442 this value using wxPGProperty::GetValue() or wxPropertyGridInterface::
445 If you wish to obtain property value in specific data type, you can
446 call various getter functions, such as wxPropertyGridInterface::
447 GetPropertyValueAsString(), which, as name might say, returns property
448 value's string representation. While this particular function is very
449 safe to use for any kind of property, some might display error message
450 if property value is not in compatible enough format. For instance,
451 wxPropertyGridInterface::GetPropertyValueAsLongLong() will support
452 long as well as wxLongLong, but GetPropertyValueAsArrayString() only
453 supports wxArrayString and nothing else.
455 In any case, you will need to take extra care when dealing with
456 raw wxVariant values. For instance, wxIntProperty and wxUIntProperty,
457 store value internally as wx(U)LongLong when number doesn't fit into
458 standard long type. Using << operator to get wx(U)LongLong from wxVariant
459 is customized to work quite safely with various types of variant data.
461 You may have noticed that properties store, in wxVariant, values of many
462 types which are not natively supported by it. Custom wxVariantDatas
463 are therefore implemented and << and >> operators implemented to
464 convert data from and to wxVariant.
466 Note that in some cases property value can be Null variant, which means
467 that property value is unspecified. This usually occurs only when
468 wxPG_EX_AUTO_UNSPECIFIED_VALUES extra window style is defined or when you
469 manually set property value to Null (or unspecified).
472 @section propgrid_iterating Iterating through a property container
474 You can use somewhat STL'ish iterator classes to iterate through the grid.
475 Here is a simple example of forward iterating through all individual
476 properties (not categories nor private child properties that are normally
477 'transparent' to application code):
481 wxPropertyGridIterator it;
483 for ( it = pg->GetIterator();
487 wxPGProperty* p = *it;
488 // Do something with the property
493 As expected there is also a const iterator:
497 wxPropertyGridConstIterator it;
499 for ( it = pg->GetIterator();
503 const wxPGProperty* p = *it;
504 // Do something with the property
509 You can give some arguments to GetIterator to determine which properties
510 get automatically filtered out. For complete list of options, see
511 @ref propgrid_iterator_flags. GetIterator() also accepts other arguments.
512 See wxPropertyGridInterface::GetIterator() for details.
514 This example reverse-iterates through all visible items:
518 wxPropertyGridIterator it;
520 for ( it = pg->GetIterator(wxPG_ITERATE_VISIBLE, wxBOTTOM);
524 wxPGProperty* p = *it;
525 // Do something with the property
530 <b>wxPython Note:</b> Instead of ++ operator, use Next() method, and instead of
531 * operator, use GetProperty() method.
533 GetIterator() only works with wxPropertyGrid and the individual pages
534 of wxPropertyGridManager. In order to iterate through an arbitrary
535 property container (such as entire wxPropertyGridManager), you need to use
536 wxPropertyGridInterface::GetVIterator(). Note however that this virtual
537 iterator is limited to forward iteration.
543 for ( it = manager->GetVIterator();
547 wxPGProperty* p = it.GetProperty();
548 // Do something with the property
553 @section propgrid_populating Populating wxPropertyGrid Automatically
555 @subsection propgrid_fromvariants Populating from List of wxVariants
557 Example of populating an empty wxPropertyGrid from a values stored
558 in an arbitrary list of wxVariants.
562 // This is a static method that initializes *all* built-in type handlers
563 // available, including those for wxColour and wxFont. Refers to *all*
564 // included properties, so when compiling with static library, this
565 // method may increase the executable size noticeably.
566 pg->InitAllTypeHandlers();
568 // Get contents of the grid as a wxVariant list
569 wxVariant all_values = pg->GetPropertyValues();
571 // Populate the list with values. If a property with appropriate
572 // name is not found, it is created according to the type of variant.
573 pg->SetPropertyValues( my_list_variant );
577 @subsection propgrid_fromfile Loading Population from a Text-based Storage
579 Class wxPropertyGridPopulator may be helpful when writing code that
580 loads properties from a text-source. In fact, the wxPropertyGrid xrc-handler
581 (which may not be currently included in wxWidgets, but probably will be in
582 near future) uses it.
584 @subsection editablestate Saving and Restoring User-Editable State
586 You can use wxPropertyGridInterface::SaveEditableState() and
587 wxPropertyGridInterface::RestoreEditableState() to save and restore
588 user-editable state (selected property, expanded/collapsed properties,
589 selected page, scrolled position, and splitter positions).
591 @section propgrid_events Event Handling
593 Probably the most important event is the Changed event which occurs when
594 value of any property is changed by the user. Use EVT_PG_CHANGED(id,func)
595 in your event table to use it.
597 For complete list of event types, see wxPropertyGrid class reference.
599 However, one type of event that might need focused attention is EVT_PG_CHANGING,
600 which occurs just prior property value is being changed by user. You can
601 acquire pending value using wxPropertyGridEvent::GetValue(), and if it is
602 not acceptable, call wxPropertyGridEvent::Veto() to prevent the value change
607 void MyForm::OnPropertyGridChanging( wxPropertyGridEvent& event )
609 wxPGProperty* property = event.GetProperty();
611 if ( property == m_pWatchThisProperty )
613 // GetValue() returns the pending value, but is only
614 // supported by wxEVT_PG_CHANGING.
615 if ( event.GetValue().GetString() == g_pThisTextIsNotAllowed )
625 @remarks On Child Property Event Handling
626 - For properties which have private, implicit children (wxFontProperty and
627 wxFlagsProperty), events occur for the main parent property only.
628 For other properties events occur for the children themselves. See
629 @ref propgrid_parentprops.
631 - When property's child gets changed, you can use wxPropertyGridEvent::GetMainParent()
632 to obtain its topmost non-category parent (useful, if you have deeply nested
636 @section propgrid_validating Validating Property Values
638 There are various ways to make sure user enters only correct values. First, you
639 can use wxValidators similar to as you would with ordinary controls. Use
640 wxPropertyGridInterface::SetPropertyValidator() to assign wxValidator to
643 Second, you can subclass a property and override wxPGProperty::ValidateValue(),
644 or handle wxEVT_PG_CHANGING for the same effect. Both of these ways do not
645 actually prevent user from temporarily entering invalid text, but they do give
646 you an opportunity to warn the user and block changed value from being committed
649 Various validation failure options can be controlled globally with
650 wxPropertyGrid::SetValidationFailureBehavior(), or on an event basis by
651 calling wxEvent::SetValidationFailureBehavior(). Here's a code snippet of
652 how to handle wxEVT_PG_CHANGING, and to set custom failure behaviour and
656 void MyFrame::OnPropertyGridChanging(wxPropertyGridEvent& event)
658 wxPGProperty* property = event.GetProperty();
660 // You must use wxPropertyGridEvent::GetValue() to access
661 // the value to be validated.
662 wxVariant pendingValue = event.GetValue();
664 if ( property->GetName() == wxT("Font") )
666 // Make sure value is not unspecified
667 if ( !pendingValue.IsNull() )
670 font << pendingValue;
672 // Let's just allow Arial font
673 if ( font.GetFaceName() != wxT("Arial") )
676 event.SetValidationFailureBehavior(wxPG_VFB_STAY_IN_PROPERTY |
678 wxPG_VFB_SHOW_MESSAGE);
686 @section propgrid_cellrender Customizing Individual Cell Appearance
688 You can control text colour, background colour, and attached image of
689 each cell in the property grid. Use wxPropertyGridInterface::SetPropertyCell() or
690 wxPGProperty::SetCell() for this purpose.
692 In addition, it is possible to control these characteristics for
693 wxPGChoices list items. See wxPGChoices class reference for more info.
696 @section propgrid_customizing Customizing Properties (without sub-classing)
698 In this section are presented miscellaneous ways to have custom appearance
699 and behavior for your properties without all the necessary hassle
700 of sub-classing a property class etc.
702 @subsection propgrid_customimage Setting Value Image
704 Every property can have a small value image placed in front of the
705 actual value text. Built-in example of this can be seen with
706 wxColourProperty and wxImageFileProperty, but for others it can
707 be set using wxPropertyGrid::SetPropertyImage method.
709 @subsection propgrid_customeditor Setting Property's Editor Control(s)
711 You can set editor control (or controls, in case of a control and button),
712 of any property using wxPropertyGrid::SetPropertyEditor. Editors are passed
713 as wxPGEditor_EditorName, and valid built-in EditorNames are
714 TextCtrl, Choice, ComboBox, CheckBox, TextCtrlAndButton, ChoiceAndButton,
715 SpinCtrl, and DatePickerCtrl. Two last mentioned ones require call to
716 static member function wxPropertyGrid::RegisterAdditionalEditors().
718 Following example changes wxColourProperty's editor from default Choice
719 to TextCtrlAndButton. wxColourProperty has its internal event handling set
720 up so that button click events of the button will be used to trigger
721 colour selection dialog.
725 wxPGProperty* colProp = new wxColourProperty(wxT("Text Colour"));
727 pg->SetPropertyEditor(colProp, wxPGEditor_TextCtrlAndButton);
731 Naturally, creating and setting custom editor classes is a possibility as
732 well. For more information, see wxPGEditor class reference.
734 @subsection propgrid_editorattrs Property Attributes Recognized by Editors
736 <b>SpinCtrl</b> editor can make use of property's "Min", "Max", "Step" and
739 @subsection propgrid_multiplebuttons Adding Multiple Buttons Next to an Editor
741 See wxPGMultiButton class reference.
743 @subsection propgrid_customeventhandling Handling Events Passed from Properties
745 <b>wxEVT_COMMAND_BUTTON_CLICKED </b>(corresponds to event table macro EVT_BUTTON):
746 Occurs when editor button click is not handled by the property itself
747 (as is the case, for example, if you set property's editor to TextCtrlAndButton
748 from the original TextCtrl).
750 @subsection propgrid_attributes Property Attributes
752 Miscellaneous values, often specific to a property type, can be set
753 using wxPropertyGridInterface::SetPropertyAttribute() and
754 wxPropertyGridInterface::SetPropertyAttributeAll() methods.
756 Attribute names are strings and values wxVariant. Arbitrary names are allowed
757 in order to store values that are relevant to application only and not
758 property grid. Constant equivalents of all attribute string names are
759 provided. Some of them are defined as cached strings, so using these constants
760 can provide for smaller binary size.
762 For complete list of attributes, see @ref propgrid_property_attributes.
765 @section propgrid_usage2 Using wxPropertyGridManager
767 wxPropertyGridManager is an efficient multi-page version of wxPropertyGrid,
768 which can optionally have tool bar for mode and page selection, and a help text
769 box. For more information, see wxPropertyGridManager class reference.
771 @subsection propgrid_propgridpage wxPropertyGridPage
773 wxPropertyGridPage is holder of properties for one page in manager. It is derived from
774 wxEvtHandler, so you can subclass it to process page-specific property grid events. Hand
775 over your page instance in wxPropertyGridManager::AddPage().
777 Please note that the wxPropertyGridPage itself only sports subset of wxPropertyGrid API
778 (but unlike manager, this include item iteration). Naturally it inherits from
779 wxPropertyGridInterface.
781 For more information, see wxPropertyGridPage class reference.
784 @section propgrid_subclassing Sub-classing wxPropertyGrid and wxPropertyGridManager
788 - Only a small percentage of member functions are virtual. If you need more,
789 just e-mail to wx-dev mailing list.
791 - Data manipulation is done in wxPropertyGridPageState class. So, instead of
792 overriding wxPropertyGrid::Insert(), you'll probably want to override
793 wxPropertyGridPageState::DoInsert(). See header file for details.
795 - Override wxPropertyGrid::CreateState() to instantiate your derivate
796 wxPropertyGridPageState. For wxPropertyGridManager, you'll need to subclass
797 wxPropertyGridPage instead (since it is derived from wxPropertyGridPageState),
798 and hand over instances in wxPropertyGridManager::AddPage() calls.
800 - You can use a derivate wxPropertyGrid with manager by overriding
801 wxPropertyGridManager::CreatePropertyGrid() member function.
804 @section propgrid_misc Miscellaneous Topics
806 @subsection propgrid_namescope Property Name Scope
808 All properties which parent is category or root can be accessed
809 directly by their base name (ie. name given for property in its constructor).
810 Other properties can be accessed via "ParentsName.BaseName" notation,
811 Naturally, all property names should be unique.
813 @subsection propgrid_nonuniquelabels Non-unique Labels
815 It is possible to have properties with identical label under same parent.
816 However, care must be taken to ensure that each property still has
819 @subsection propgrid_boolproperty wxBoolProperty
821 There are few points about wxBoolProperty that require further discussion:
822 - wxBoolProperty can be shown as either normal combo box or as a check box.
823 Property attribute wxPG_BOOL_USE_CHECKBOX is used to change this.
824 For example, if you have a wxFlagsProperty, you can
825 set its all items to use check box using the following:
827 pg->SetPropertyAttribute(wxT("MyFlagsProperty"),wxPG_BOOL_USE_CHECKBOX,true,wxPG_RECURSE);
830 Following will set all individual bool properties in your control to
834 pg->SetPropertyAttributeAll(wxPG_BOOL_USE_CHECKBOX, true);
837 - Default item names for wxBoolProperty are ["False", "True"]. This can be
838 changed using static function wxPropertyGrid::SetBoolChoices(trueChoice,
841 @subsection propgrid_textctrlupdates Updates from wxTextCtrl Based Editor
843 Changes from wxTextCtrl based property editors are committed (ie.
844 wxEVT_PG_CHANGED is sent etc.) *only* when (1) user presser enter, (2)
845 user moves to edit another property, or (3) when focus leaves
848 Because of this, you may find it useful, in some apps, to call
849 wxPropertyGrid::CommitChangesFromEditor() just before you need to do any
850 computations based on property grid values. Note that CommitChangesFromEditor()
851 will dispatch wxEVT_PG_CHANGED with ProcessEvent, so any of your event handlers
852 will be called immediately.
854 @subsection propgrid_splittercentering Centering the Splitter
856 If you need to center the splitter, but only once when the program starts,
857 then do <b>not</b> use the wxPG_SPLITTER_AUTO_CENTER window style, but the
858 wxPropertyGrid::CenterSplitter() method. <b>However, be sure to call it after
859 the sizer setup and SetSize calls!</b> (ie. usually at the end of the
860 frame/dialog constructor)
862 @subsection propgrid_splittersetting Setting Splitter Position When Creating Property Grid
864 Splitter position cannot exceed grid size, and therefore setting it during
865 form creation may fail as initial grid size is often smaller than desired
866 splitter position, especially when sizers are being used.
868 @subsection propgrid_colourproperty wxColourProperty and wxSystemColourProperty
870 Through sub-classing, these two property classes provide substantial customization
871 features. Subclass wxSystemColourProperty if you want to use wxColourPropertyValue
872 (which features colour type in addition to wxColour), and wxColourProperty if plain
875 Override wxSystemColourProperty::ColourToString() to redefine how colours are
878 Override wxSystemColourProperty::GetCustomColourIndex() to redefine location of
879 the item that triggers colour picker dialog (default is last).
881 Override wxSystemColourProperty::GetColour() to determine which colour matches
884 @section propgrid_proplist Property Class Descriptions
886 See @ref pgproperty_properties