1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: interface of wxPGProperty
4 // Author: wxWidgets team
6 // Licence: wxWindows license
7 /////////////////////////////////////////////////////////////////////////////
9 // -----------------------------------------------------------------------
11 /** @class wxPropertyGridInterface
13 Most of the shared property manipulation interface shared by wxPropertyGrid,
14 wxPropertyGridPage, and wxPropertyGridManager is defined in this class.
17 - In separate wxPropertyGrid component this class was known as wxPropertyContainerMethods.
22 class WXDLLIMPEXP_PROPGRID wxPropertyGridInterface
27 virtual ~wxPropertyGridInterface() { }
29 /** Adds choice to a property that can accept one.
31 - If you need to make sure that you modify only the set of choices of
32 a single property (and not also choices of other properties with initially
33 identical set), call wxPropertyGrid::SetPropertyChoicesPrivate.
34 - This usually only works for wxEnumProperty and derivatives (wxFlagsProperty
35 can get accept new items but its items may not get updated).
37 void AddPropertyChoice( wxPGPropArg id
, const wxString
& label
, int value
= wxPG_INVALID_VALUE
);
39 /** Appends property to the list. wxPropertyGrid assumes ownership of the object.
40 Becomes child of most recently added category.
42 - wxPropertyGrid takes the ownership of the property pointer.
43 - If appending a category with name identical to a category already in the
44 wxPropertyGrid, then newly created category is deleted, and most recently
45 added category (under which properties are appended) is set to the one with
46 same name. This allows easier adding of items to same categories in multiple
48 - Does not automatically redraw the control, so you may need to call Refresh
49 when calling this function after control has been shown for the first time.
51 wxPGProperty
* Append( wxPGProperty
* property
);
53 wxPGProperty
* AppendIn( wxPGPropArg id
, wxPGProperty
* newproperty
);
55 /** Inorder to add new items into a property with fixed children (for instance, wxFlagsProperty),
56 you need to call this method. After populating has been finished, you need to call EndAddChildren.
58 void BeginAddChildren( wxPGPropArg id
);
60 /** Deletes all properties.
62 virtual void Clear() = 0;
64 /** Deselect current selection, if any. Returns true if success
65 (ie. validator did not intercept). */
66 bool ClearSelection();
68 /** Resets modified status of all properties.
70 void ClearModifiedStatus()
72 SetPropertyModifiedStatus(m_pState
->m_properties
, false);
73 m_pState
->m_anyModified
= false;
76 /** Collapses given category or property with children.
77 Returns true if actually collapses.
79 bool Collapse( wxPGPropArg id
);
81 /** Collapses all items that can be collapsed.
84 Return false if failed (may fail if editor value cannot be validated).
86 bool CollapseAll() { return ExpandAll(false); }
88 /** Changes value of a property, as if from an editor. Use this instead of SetPropertyValue()
89 if you need the value to run through validation process, and also send the property
93 Returns true if value was successfully changed.
95 bool ChangePropertyValue( wxPGPropArg id
, wxVariant newValue
);
97 /** Resets value of a property to its default. */
98 bool ClearPropertyValue( wxPGPropArg id
)
100 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(false)
101 p
->SetValue(p
->GetDefaultValue());
106 /** Deletes a property by id. If category is deleted, all children are automatically deleted as well. */
107 void DeleteProperty( wxPGPropArg id
);
109 /** Deletes choice from a property.
111 If selected item is deleted, then the value is set to unspecified.
113 See AddPropertyChoice for more details.
115 void DeletePropertyChoice( wxPGPropArg id
, int index
);
117 /** Disables property. */
118 bool DisableProperty( wxPGPropArg id
) { return EnableProperty(id
,false); }
120 /** Returns true if all property grid data changes have been committed. Usually
121 only returns false if value in active editor has been invalidated by a
124 bool EditorValidate();
126 /** Enables or disables property, depending on whether enable is true or false. */
127 bool EnableProperty( wxPGPropArg id
, bool enable
= true );
129 /** Called after population of property with fixed children has finished.
131 void EndAddChildren( wxPGPropArg id
);
133 /** Expands given category or property with children.
134 Returns true if actually expands.
136 bool Expand( wxPGPropArg id
);
138 /** Expands all items that can be expanded.
140 bool ExpandAll( bool expand
= true );
142 /** Returns list of expanded properties.
144 wxArrayPGProperty
GetExpandedProperties() const
146 wxArrayPGProperty array
;
147 GetPropertiesWithFlag(&array
, wxPG_PROP_COLLAPSED
, true,
148 wxPG_ITERATE_ALL_PARENTS_RECURSIVELY
|wxPG_ITERATE_HIDDEN
);
152 /** Returns id of first child of given property.
154 Does not return sub-properties!
156 wxPGProperty
* GetFirstChild( wxPGPropArg id
)
158 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(wxNullProperty
)
160 if ( !p
->GetChildCount() || p
->HasFlag(wxPG_PROP_AGGREGATE
) )
161 return wxNullProperty
;
167 /** Returns iterator class instance.
169 See @ref propgrid_iterator_flags. Value wxPG_ITERATE_DEFAULT causes
170 iteration over everything except private child properties.
172 Property to start iteration from. If NULL, then first child of root is used.
174 Either wxTOP or wxBOTTOM. wxTOP will indicate that iterations start from
175 the first property from the top, and wxBOTTOM means that the iteration will
176 instead begin from bottommost valid item.
178 wxPropertyGridIterator
GetIterator( int flags
= wxPG_ITERATE_DEFAULT
, wxPGProperty
* firstProp
= NULL
)
180 return wxPropertyGridIterator( m_pState
, flags
, firstProp
);
183 wxPropertyGridConstIterator
GetIterator( int flags
= wxPG_ITERATE_DEFAULT
, wxPGProperty
* firstProp
= NULL
) const
185 return wxPropertyGridConstIterator( m_pState
, flags
, firstProp
);
188 wxPropertyGridIterator
GetIterator( int flags
, int startPos
)
190 return wxPropertyGridIterator( m_pState
, flags
, startPos
);
193 wxPropertyGridConstIterator
GetIterator( int flags
, int startPos
) const
195 return wxPropertyGridConstIterator( m_pState
, flags
, startPos
);
199 /** Returns id of first item, whether it is a category or property.
201 @link iteratorflags List of iterator flags@endlink
203 wxPGProperty
* GetFirst( int flags
= wxPG_ITERATE_ALL
)
205 wxPropertyGridIterator
it( m_pState
, flags
, wxNullProperty
, 1 );
209 const wxPGProperty
* GetFirst( int flags
= wxPG_ITERATE_ALL
) const
211 return ((wxPropertyGridInterface
*)this)->GetFirst(flags
);
214 /** Returns id of property with given name (case-sensitive). If there is no
215 property with such name, returned property id is invalid ( i.e. it will return
216 false with IsOk method).
218 - Sub-properties (i.e. properties which have parent that is not category or
219 root) can not be accessed globally by their name. Instead, use
220 "<property>.<subproperty>" in place of "<subproperty>".
222 wxPGProperty
* GetProperty( const wxString
& name
) const
224 return GetPropertyByName(name
);
227 /** Returns map-like storage of property's attributes.
229 Note that if extra style wxPG_EX_WRITEONLY_BUILTIN_ATTRIBUTES is set,
230 then builtin-attributes are not included in the storage.
232 const wxPGAttributeStorage
& GetPropertyAttributes( wxPGPropArg id
) const
234 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(*((const wxPGAttributeStorage
*)NULL
));
235 return p
->GetAttributes();
238 /** Adds to 'targetArr' pointers to properties that have given
239 flags 'flags' set. However, if 'inverse' is set to true, then
240 only properties without given flags are stored.
242 Property flags to use.
244 Iterator flags to use. Default is everything expect private children.
246 void GetPropertiesWithFlag( wxArrayPGProperty
* targetArr
,
247 wxPGProperty::FlagType flags
,
248 bool inverse
= false,
249 int iterFlags
= (wxPG_ITERATE_PROPERTIES
|wxPG_ITERATE_HIDDEN
|wxPG_ITERATE_CATEGORIES
) ) const;
251 /** Returns value of given attribute. If none found, returns NULL-variant.
253 wxVariant
GetPropertyAttribute( wxPGPropArg id
, const wxString
& attrName
) const
255 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(wxNullVariant
)
256 return p
->GetAttribute(attrName
);
259 /** Returns pointer of property's nearest parent category. If no category
262 wxPropertyCategory
* GetPropertyCategory( wxPGPropArg id
) const
264 wxPG_PROP_ID_CONST_CALL_PROLOG_RETVAL(NULL
)
265 return m_pState
->GetPropertyCategory(p
);
268 /** Returns client data (void*) of a property. */
269 void* GetPropertyClientData( wxPGPropArg id
) const
271 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(NULL
)
272 return p
->GetClientData();
275 /** Returns first property which label matches given string. NULL if none found.
276 Note that this operation is extremely slow when compared to GetPropertyByName().
278 wxPGProperty
* GetPropertyByLabel( const wxString
& label
) const;
280 /** Returns property with given name. NULL if none found.
282 wxPGProperty
* GetPropertyByName( const wxString
& name
) const;
284 /** Returns child property 'subname' of property 'name'. Same as
285 calling GetPropertyByName("name.subname"), albeit slightly faster.
287 wxPGProperty
* GetPropertyByName( const wxString
& name
, const wxString
& subname
) const;
289 /** Returns writable reference to property's list of choices (and relevant
290 values). If property does not have any choices, will return reference
291 to an invalid set of choices that will return false on IsOk call.
293 wxPGChoices
& GetPropertyChoices( wxPGPropArg id
);
295 /** Returns property's editor. */
296 const wxPGEditor
* GetPropertyEditor( wxPGPropArg id
) const
298 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(NULL
)
299 return p
->GetEditorClass();
302 /** Returns help string associated with a property. */
303 wxString
GetPropertyHelpString( wxPGPropArg id
) const
305 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(m_emptyString
)
306 return p
->GetHelpString();
309 /** Returns property's custom value image (NULL of none). */
310 wxBitmap
* GetPropertyImage( wxPGPropArg id
) const
312 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(NULL
)
313 return p
->GetValueImage();
316 /** Returns property's position under its parent. */
317 unsigned int GetPropertyIndex( wxPGPropArg id
)
319 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(INT_MAX
)
320 return p
->GetIndexInParent();
323 /** Returns label of a property. */
324 const wxString
& GetPropertyLabel( wxPGPropArg id
)
326 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(m_emptyString
)
327 return p
->GetLabel();
330 /** Returns name of a property, by which it is globally accessible. */
331 wxString
GetPropertyName( wxPGPropArg id
)
333 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(m_emptyString
)
337 /** Returns parent item of a property. */
338 wxPGProperty
* GetPropertyParent( wxPGPropArg id
)
340 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(wxNullProperty
)
341 return p
->GetParent();
344 /** Returns validator of a property as a reference, which you
345 can pass to any number of SetPropertyValidator.
347 wxValidator
* GetPropertyValidator( wxPGPropArg id
)
349 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(NULL
)
350 return p
->GetValidator();
353 /** Returns value as wxVariant. To get wxObject pointer from it,
354 you will have to use WX_PG_VARIANT_TO_WXOBJECT(VARIANT,CLASSNAME) macro.
356 If property value is unspecified, Null variant is returned.
358 wxVariant
GetPropertyValue( wxPGPropArg id
)
360 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(wxVariant())
361 return p
->GetValue();
364 wxString
GetPropertyValueAsString( wxPGPropArg id
) const;
365 long GetPropertyValueAsLong( wxPGPropArg id
) const;
366 unsigned long GetPropertyValueAsULong( wxPGPropArg id
) const
368 return (unsigned long) GetPropertyValueAsLong(id
);
370 int GetPropertyValueAsInt( wxPGPropArg id
) const { return (int)GetPropertyValueAsLong(id
); }
371 bool GetPropertyValueAsBool( wxPGPropArg id
) const;
372 double GetPropertyValueAsDouble( wxPGPropArg id
) const;
373 wxObject
* GetPropertyValueAsWxObjectPtr( wxPGPropArg id
) const;
374 void* GetPropertyValueAsVoidPtr( wxPGPropArg id
) const;
376 wxArrayString
GetPropertyValueAsArrayString( wxPGPropArg id
) const
378 wxPG_PROP_ID_GETPROPVAL_CALL_PROLOG_RETVAL(wxT("arrstring"), wxArrayString())
379 return p
->m_value
.GetArrayString();
382 wxPoint
GetPropertyValueAsPoint( wxPGPropArg id
) const
384 wxPG_PROP_ID_GETPROPVAL_CALL_PROLOG_RETVAL(wxT("wxPoint"), wxPoint())
385 return WX_PG_VARIANT_GETVALUEREF(p
->GetValue(), wxPoint
);
388 wxSize
GetPropertyValueAsSize( wxPGPropArg id
) const
390 wxPG_PROP_ID_GETPROPVAL_CALL_PROLOG_RETVAL(wxT("wxSize"), wxSize())
391 return WX_PG_VARIANT_GETVALUEREF(p
->GetValue(), wxSize
);
394 wxLongLong_t
GetPropertyValueAsLongLong( wxPGPropArg id
) const
396 wxPG_PROP_ID_GETPROPVAL_CALL_PROLOG_RETVAL_WFALLBACK(wxT("wxLongLong"), (long) GetPropertyValueAsLong(id
))
397 return WX_PG_VARIANT_GETVALUEREF(p
->GetValue(), wxLongLong
).GetValue();
400 wxULongLong_t
GetPropertyValueAsULongLong( wxPGPropArg id
) const
402 wxPG_PROP_ID_GETPROPVAL_CALL_PROLOG_RETVAL_WFALLBACK(wxT("wxULongLong"), (unsigned long) GetPropertyValueAsULong(id
))
403 return WX_PG_VARIANT_GETVALUEREF(p
->GetValue(), wxULongLong
).GetValue();
406 wxArrayInt
GetPropertyValueAsArrayInt( wxPGPropArg id
) const
408 wxPG_PROP_ID_GETPROPVAL_CALL_PROLOG_RETVAL(wxT("wxArrayInt"), wxArrayInt())
409 wxArrayInt arr
= WX_PG_VARIANT_GETVALUEREF(p
->GetValue(), wxArrayInt
);
413 wxDateTime
GetPropertyValueAsDateTime( wxPGPropArg id
) const
415 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(wxDateTime())
417 if ( wxStrcmp(p
->m_value
.GetType(), wxT("datetime")) != 0 )
419 wxPGGetFailed(p
, wxT("datetime"));
422 return p
->m_value
.GetDateTime();
425 /** Returns a wxVariant list containing wxVariant versions of all
426 property values. Order is not guaranteed.
428 Use wxPG_KEEP_STRUCTURE to retain category structure; each sub
429 category will be its own wxVariantList of wxVariant.
430 Use wxPG_INC_ATTRIBUTES to include property attributes as well.
431 Each attribute will be stored as list variant named "@@<propname>@@attr."
434 wxVariant
GetPropertyValues( const wxString
& listname
= wxEmptyString
,
435 wxPGProperty
* baseparent
= NULL
, long flags
= 0 ) const
437 return m_pState
->DoGetPropertyValues(listname
, baseparent
, flags
);
440 wxString
GetPropertyValueType( wxPGPropArg id
)
442 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(m_emptyString
)
443 return p
->GetValueType();
446 /** Returns currently selected property. */
447 wxPGProperty
* GetSelection() const
449 return m_pState
->GetSelection();
452 /** Similar to GetIterator(), but instead returns wxPGVIterator instance,
453 which can be useful for forward-iterating through arbitrary property
457 See @ref propgrid_iterator_flags.
459 virtual wxPGVIterator
GetVIterator( int flags
) const;
461 /** Hides or reveals a property.
463 If true, hides property, otherwise reveals it.
465 By default changes are applied recursively. Set this paramter wxPG_DONT_RECURSE to prevent this.
467 bool HideProperty( wxPGPropArg id
, bool hide
= true, int flags
= wxPG_RECURSE
);
469 /** Initializes *all* property types. Causes references to most object
470 files in the library, so calling this may cause significant increase
471 in executable size when linking with static library.
473 static void InitAllTypeHandlers();
476 /** Inserts property to the property container.
479 New property is inserted just prior to this. Available only
480 in the first variant. There are two versions of this function
481 to allow this parameter to be either an id or name to
485 Pointer to the inserted property. wxPropertyGrid will take
486 ownership of this object.
489 New property is inserted under this category. Available only
490 in the second variant. There are two versions of this function
491 to allow this parameter to be either an id or name to
495 Index under category. Available only in the second variant.
496 If index is < 0, property is appended in category.
499 Returns id for the property,
503 - wxPropertyGrid takes the ownership of the property pointer.
505 - While Append may be faster way to add items, make note that when
506 both types of data storage (categoric and
507 non-categoric) are active, Insert becomes even more slow. This is
508 especially true if current mode is non-categoric.
515 wxPGProperty* my_cat_id = propertygrid->Append( new wxPropertyCategory("My Category") );
519 // insert into category - using second variant
520 wxPGProperty* my_item_id_1 = propertygrid->Insert( my_cat_id, 0, new wxStringProperty("My String 1") );
522 // insert before to first item - using first variant
523 wxPGProperty* my_item_id_2 = propertygrid->Insert( my_item_id, new wxStringProperty("My String 2") );
528 wxPGProperty
* Insert( wxPGPropArg priorThis
, wxPGProperty
* newproperty
);
529 wxPGProperty
* Insert( wxPGPropArg parent
, int index
, wxPGProperty
* newproperty
);
532 /** Returns true if property is a category. */
533 bool IsPropertyCategory( wxPGPropArg id
) const
535 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(false)
536 return p
->IsCategory();
539 /** Inserts choice to a property that can accept one.
541 See AddPropertyChoice for more details.
543 void InsertPropertyChoice( wxPGPropArg id
, const wxString
& label
, int index
, int value
= wxPG_INVALID_VALUE
);
545 /** Returns true if property is enabled. */
546 bool IsPropertyEnabled( wxPGPropArg id
) const
548 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(false)
549 return (!(p
->GetFlags() & wxPG_PROP_DISABLED
))?true:false;
552 /** Returns true if given property is expanded. Naturally, always returns false
553 for properties that cannot be expanded.
555 bool IsPropertyExpanded( wxPGPropArg id
) const;
557 /** Returns true if property has been modified after value set or modify flag
560 bool IsPropertyModified( wxPGPropArg id
) const
562 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(false)
563 return ( (p
->GetFlags() & wxPG_PROP_MODIFIED
) ? true : false );
566 /** Returns true if property is shown (ie. hideproperty with true not called for it). */
567 bool IsPropertyShown( wxPGPropArg id
) const
569 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(false)
570 return (!(p
->GetFlags() & wxPG_PROP_HIDDEN
))?true:false;
573 /** Returns true if property value is set to unspecified.
575 bool IsPropertyValueUnspecified( wxPGPropArg id
) const
577 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(false)
578 return p
->IsValueUnspecified();
581 /** Disables (limit = true) or enables (limit = false) wxTextCtrl editor of a property,
582 if it is not the sole mean to edit the value.
584 void LimitPropertyEditing( wxPGPropArg id
, bool limit
= true );
586 /** If state is shown in it's grid, refresh it now.
588 virtual void RefreshGrid();
590 /** Initializes additional property editors (SpinCtrl etc.). Causes references
591 to most object files in the library, so calling this may cause significant increase
592 in executable size when linking with static library.
594 static void RegisterAdditionalEditors();
596 /** Replaces property with id with newly created property. For example,
597 this code replaces existing property named "Flags" with one that
598 will have different set of items:
600 pg->ReplaceProperty("Flags",
601 wxFlagsProperty("Flags", wxPG_LABEL, newItems))
603 For more info, see wxPropertyGrid::Insert.
605 wxPGProperty
* ReplaceProperty( wxPGPropArg id
, wxPGProperty
* property
);
608 /** @anchor propgridinterface_editablestate_flags
610 Flags for wxPropertyGridInterface::SaveEditableState() and
611 wxPropertyGridInterface::RestoreEditableState().
613 enum EditableStateFlags
615 /** Include selected property. */
616 SelectionState
= 0x01,
617 /** Include expanded/collapsed property information. */
618 ExpandedState
= 0x02,
619 /** Include scrolled position. */
620 ScrollPosState
= 0x04,
621 /** Include selected page information. Only applies to wxPropertyGridManager. */
623 /** Include splitter position. Stored for each page. */
624 SplitterPosState
= 0x10,
626 /** Include all supported user editable state information. This is usually the default value. */
627 AllStates
= SelectionState
| ExpandedState
| ScrollPosState
| PageState
| SplitterPosState
630 /** Restores user-editable state. See also wxPropertyGridInterface::SaveEditableState().
633 String generated by SaveEditableState.
636 Which parts to restore from source string. See @ref propgridinterface_editablestate_flags
637 "list of editable state flags".
640 False if there was problem reading the string.
643 If some parts of state (such as scrolled or splitter position) fail to restore correctly,
644 please make sure that you call this function after wxPropertyGrid size has been set
645 (this may sometimes be tricky when sizers are used).
647 bool RestoreEditableState( const wxString
& src
,
648 int restoreStates
= AllStates
);
650 /** Used to acquire user-editable state (selected property, expanded properties, scrolled position,
653 @param includedStates
654 Which parts of state to include. See @ref propgridinterface_editablestate_flags
655 "list of editable state flags".
657 wxString
SaveEditableState( int includedStates
= AllStates
) const;
659 /** Lets user to set the strings listed in the choice dropdown of a wxBoolProperty.
660 Defaults are "True" and "False", so changing them to, say, "Yes" and "No" may
661 be useful in some less technical applications.
663 static void SetBoolChoices( const wxString
& trueChoice
, const wxString
& falseChoice
);
665 /** Sets or clears flag(s) of all properties in given array.
667 Property flags to set or clear.
669 Set to true if you want to clear flag instead of setting them.
671 void SetPropertiesFlag( const wxArrayPGProperty
& srcArr
, wxPGProperty::FlagType flags
,
672 bool inverse
= false );
674 /** Sets an attribute for this property.
676 Text identifier of attribute. See @ref propgrid_property_attributes.
680 Optional. Use wxPG_RECURSE to set the attribute to child properties recursively.
682 void SetPropertyAttribute( wxPGPropArg id
, const wxString
& attrName
, wxVariant value
, long argFlags
= 0 )
684 DoSetPropertyAttribute(id
,attrName
,value
,argFlags
);
687 /** Sets attributes from a wxPGAttributeStorage.
689 void SetPropertyAttributes( wxPGPropArg id
, const wxPGAttributeStorage
& attributes
)
691 wxPG_PROP_ARG_CALL_PROLOG()
692 p
->SetAttributes(attributes
);
695 /** Sets text, bitmap, and colours for given column's cell.
698 - You can set label cell by setting column to 0.
699 - You can use wxPG_LABEL as text to use default text for column.
701 void SetPropertyCell( wxPGPropArg id
,
703 const wxString
& text
= wxEmptyString
,
704 const wxBitmap
& bitmap
= wxNullBitmap
,
705 const wxColour
& fgCol
= wxNullColour
,
706 const wxColour
& bgCol
= wxNullColour
)
708 wxPG_PROP_ARG_CALL_PROLOG()
709 p
->SetCell( column
, new wxPGCell(text
, bitmap
, fgCol
, bgCol
) );
712 /** Set choices of a property to specified set of labels and values.
715 This operation clears the property value.
717 void SetPropertyChoices( wxPGPropArg id
, wxPGChoices
& choices
)
719 wxPG_PROP_ARG_CALL_PROLOG()
720 p
->SetChoices(choices
);
724 /** If property's set of choices is shared, then calling this method converts
727 void SetPropertyChoicesExclusive( wxPGPropArg id
)
729 wxPG_PROP_ARG_CALL_PROLOG()
730 p
->SetChoicesExclusive();
733 /** Sets client data (void*) of a property.
735 This untyped client data has to be deleted manually.
737 void SetPropertyClientData( wxPGPropArg id
, void* clientData
)
739 wxPG_PROP_ARG_CALL_PROLOG()
740 p
->SetClientData(clientData
);
743 /** Sets editor for a property.
746 For builtin editors, use wxPGEditor_X, where X is builtin editor's
747 name (TextCtrl, Choice, etc. see wxPGEditor documentation for full list).
749 For custom editors, use pointer you received from wxPropertyGrid::RegisterEditorClass().
751 void SetPropertyEditor( wxPGPropArg id
, const wxPGEditor
* editor
)
753 wxPG_PROP_ARG_CALL_PROLOG()
754 wxCHECK_RET( editor
, wxT("unknown/NULL editor") );
755 p
->SetEditor(editor
);
759 /** Sets editor control of a property. As editor argument, use
760 editor name string, such as "TextCtrl" or "Choice".
762 void SetPropertyEditor( wxPGPropArg id
, const wxString
& editorName
)
764 SetPropertyEditor(id
,GetEditorByName(editorName
));
767 /** Sets label of a property.
770 - Properties under same parent may have same labels. However,
771 property names must still remain unique.
773 void SetPropertyLabel( wxPGPropArg id
, const wxString
& newproplabel
);
775 /** Set modified status of a property and all its children.
777 void SetPropertyModifiedStatus( wxPGPropArg id
, bool modified
)
779 wxPG_PROP_ARG_CALL_PROLOG()
780 p
->SetModifiedStatus(modified
);
783 /** Sets property (and, recursively, its children) to have read-only value. In other words,
784 user cannot change the value in the editor, but they can still copy it.
786 This is mainly for use with textctrl editor. Not all other editors fully
789 By default changes are applied recursively. Set this paramter wxPG_DONT_RECURSE to prevent this.
791 void SetPropertyReadOnly( wxPGPropArg id
, bool set
= true, int flags
= wxPG_RECURSE
)
793 wxPG_PROP_ARG_CALL_PROLOG()
794 if ( flags
& wxPG_RECURSE
)
795 p
->SetFlagRecursively(wxPG_PROP_READONLY
, set
);
797 p
->SetFlag(wxPG_PROP_READONLY
);
800 /** Sets property's value to unspecified. If it has children (it may be category),
801 then the same thing is done to them.
803 void SetPropertyValueUnspecified( wxPGPropArg id
);
805 /** Sets various property values from a list of wxVariants. If property with
806 name is missing from the grid, new property is created under given default
807 category (or root if omitted).
809 void SetPropertyValues( const wxVariantList
& list
, wxPGPropArg defaultCategory
= wxNullProperty
)
812 if ( defaultCategory
.HasName() ) p
= defaultCategory
.GetPtr(this);
813 else p
= defaultCategory
.GetPtr0();
814 m_pState
->DoSetPropertyValues(list
, p
);
817 void SetPropertyValues( const wxVariant
& list
, wxPGPropArg defaultCategory
= wxNullProperty
)
819 SetPropertyValues(list
.GetList(),defaultCategory
);
822 /** Associates the help string with property.
824 By default, text is shown either in the manager's "description"
825 text box or in the status bar. If extra window style wxPG_EX_HELP_AS_TOOLTIPS
826 is used, then the text will appear as a tooltip.
828 void SetPropertyHelpString( wxPGPropArg id
, const wxString
& helpString
)
830 wxPG_PROP_ARG_CALL_PROLOG()
831 p
->SetHelpString(helpString
);
834 /** Set wxBitmap in front of the value.
836 - Bitmap will be scaled to a size returned by wxPropertyGrid::GetImageSize();
838 void SetPropertyImage( wxPGPropArg id
, wxBitmap
& bmp
)
840 wxPG_PROP_ARG_CALL_PROLOG()
841 p
->SetValueImage(bmp
);
845 /** Sets max length of property's text.
847 bool SetPropertyMaxLength( wxPGPropArg id
, int maxLen
);
849 /** Sets validator of a property.
851 void SetPropertyValidator( wxPGPropArg id
, const wxValidator
& validator
)
853 wxPG_PROP_ARG_CALL_PROLOG()
854 p
->SetValidator(validator
);
857 /** Sets value (long integer) of a property.
859 void SetPropertyValue( wxPGPropArg id
, long value
)
865 /** Sets value (integer) of a property.
867 void SetPropertyValue( wxPGPropArg id
, int value
)
869 wxVariant
v((long)value
);
872 /** Sets value (floating point) of a property.
874 void SetPropertyValue( wxPGPropArg id
, double value
)
879 /** Sets value (bool) of a property.
881 void SetPropertyValue( wxPGPropArg id
, bool value
)
886 void SetPropertyValue( wxPGPropArg id
, const wxChar
* value
)
888 SetPropertyValueString( id
, wxString(value
) );
890 void SetPropertyValue( wxPGPropArg id
, const wxString
& value
)
892 SetPropertyValueString( id
, value
);
895 /** Sets value (wxArrayString) of a property.
897 void SetPropertyValue( wxPGPropArg id
, const wxArrayString
& value
)
903 void SetPropertyValue( wxPGPropArg id
, const wxDateTime
& value
)
909 /** Sets value (wxObject*) of a property.
911 void SetPropertyValue( wxPGPropArg id
, wxObject
* value
)
917 void SetPropertyValue( wxPGPropArg id
, wxObject
& value
)
923 /** Sets value (wxPoint&) of a property.
925 void SetPropertyValue( wxPGPropArg id
, const wxPoint
& value
)
927 wxVariant v
= WXVARIANT(value
);
930 /** Sets value (wxSize&) of a property.
932 void SetPropertyValue( wxPGPropArg id
, const wxSize
& value
)
934 wxVariant v
= WXVARIANT(value
);
937 /** Sets value (wxLongLong&) of a property.
939 void SetPropertyValue( wxPGPropArg id
, wxLongLong_t value
)
941 wxVariant v
= WXVARIANT(wxLongLong(value
));
944 /** Sets value (wxULongLong&) of a property.
946 void SetPropertyValue( wxPGPropArg id
, wxULongLong_t value
)
948 wxVariant v
= WXVARIANT(wxULongLong(value
));
951 /** Sets value (wxArrayInt&) of a property.
953 void SetPropertyValue( wxPGPropArg id
, const wxArrayInt
& value
)
955 wxVariant v
= WXVARIANT(value
);
959 /** Sets value (wxString) of a property.
962 This method uses wxPGProperty::SetValueFromString, which all properties
963 should implement. This means that there should not be a type error,
964 and instead the string is converted to property's actual value type.
966 void SetPropertyValueString( wxPGPropArg id
, const wxString
& value
);
968 /** Sets value (wxVariant&) of a property.
971 Use wxPropertyGrid::ChangePropertyValue() instead if you need to run through
972 validation process and send property change event.
974 void SetPropertyValue( wxPGPropArg id
, wxVariant value
)
976 SetPropVal( id
, value
);
979 /** Adjusts how wxPropertyGrid behaves when invalid value is entered
982 See @link vfbflags list of valid flags values@endlink
984 void SetValidationFailureBehavior( int vfbFlags
);
986 // GetPropertyByName With nice assertion error message.
987 wxPGProperty
* GetPropertyByNameA( const wxString
& name
) const;
989 static wxPGEditor
* GetEditorByName( const wxString
& editorName
);
991 virtual void RefreshProperty( wxPGProperty
* p
) = 0;