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.
355 If property value is unspecified, Null variant is returned.
357 wxVariant
GetPropertyValue( wxPGPropArg id
)
359 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(wxVariant())
360 return p
->GetValue();
363 wxString
GetPropertyValueAsString( wxPGPropArg id
) const;
364 long GetPropertyValueAsLong( wxPGPropArg id
) const;
365 unsigned long GetPropertyValueAsULong( wxPGPropArg id
) const
367 return (unsigned long) GetPropertyValueAsLong(id
);
369 int GetPropertyValueAsInt( wxPGPropArg id
) const { return (int)GetPropertyValueAsLong(id
); }
370 bool GetPropertyValueAsBool( wxPGPropArg id
) const;
371 double GetPropertyValueAsDouble( wxPGPropArg id
) const;
372 void* GetPropertyValueAsVoidPtr( wxPGPropArg id
) const;
374 wxArrayString
GetPropertyValueAsArrayString( wxPGPropArg id
) const
376 wxPG_PROP_ID_GETPROPVAL_CALL_PROLOG_RETVAL(wxT("arrstring"), wxArrayString())
377 return p
->m_value
.GetArrayString();
380 wxPoint
GetPropertyValueAsPoint( wxPGPropArg id
) const
382 wxPG_PROP_ID_GETPROPVAL_CALL_PROLOG_RETVAL(wxT("wxPoint"), wxPoint())
383 return WX_PG_VARIANT_GETVALUEREF(p
->GetValue(), wxPoint
);
386 wxSize
GetPropertyValueAsSize( wxPGPropArg id
) const
388 wxPG_PROP_ID_GETPROPVAL_CALL_PROLOG_RETVAL(wxT("wxSize"), wxSize())
389 return WX_PG_VARIANT_GETVALUEREF(p
->GetValue(), wxSize
);
392 wxLongLong_t
GetPropertyValueAsLongLong( wxPGPropArg id
) const
394 wxPG_PROP_ID_GETPROPVAL_CALL_PROLOG_RETVAL_WFALLBACK(wxT("wxLongLong"), (long) GetPropertyValueAsLong(id
))
395 return WX_PG_VARIANT_GETVALUEREF(p
->GetValue(), wxLongLong
).GetValue();
398 wxULongLong_t
GetPropertyValueAsULongLong( wxPGPropArg id
) const
400 wxPG_PROP_ID_GETPROPVAL_CALL_PROLOG_RETVAL_WFALLBACK(wxT("wxULongLong"), (unsigned long) GetPropertyValueAsULong(id
))
401 return WX_PG_VARIANT_GETVALUEREF(p
->GetValue(), wxULongLong
).GetValue();
404 wxArrayInt
GetPropertyValueAsArrayInt( wxPGPropArg id
) const
406 wxPG_PROP_ID_GETPROPVAL_CALL_PROLOG_RETVAL(wxT("wxArrayInt"), wxArrayInt())
407 wxArrayInt arr
= WX_PG_VARIANT_GETVALUEREF(p
->GetValue(), wxArrayInt
);
411 wxDateTime
GetPropertyValueAsDateTime( wxPGPropArg id
) const
413 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(wxDateTime())
415 if ( wxStrcmp(p
->m_value
.GetType(), wxT("datetime")) != 0 )
417 wxPGGetFailed(p
, wxT("datetime"));
420 return p
->m_value
.GetDateTime();
423 /** Returns a wxVariant list containing wxVariant versions of all
424 property values. Order is not guaranteed.
426 Use wxPG_KEEP_STRUCTURE to retain category structure; each sub
427 category will be its own wxVariantList of wxVariant.
428 Use wxPG_INC_ATTRIBUTES to include property attributes as well.
429 Each attribute will be stored as list variant named "@@<propname>@@attr."
432 wxVariant
GetPropertyValues( const wxString
& listname
= wxEmptyString
,
433 wxPGProperty
* baseparent
= NULL
, long flags
= 0 ) const
435 return m_pState
->DoGetPropertyValues(listname
, baseparent
, flags
);
438 wxString
GetPropertyValueType( wxPGPropArg id
)
440 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(m_emptyString
)
441 return p
->GetValueType();
444 /** Returns currently selected property. */
445 wxPGProperty
* GetSelection() const
447 return m_pState
->GetSelection();
450 /** Similar to GetIterator(), but instead returns wxPGVIterator instance,
451 which can be useful for forward-iterating through arbitrary property
455 See @ref propgrid_iterator_flags.
457 virtual wxPGVIterator
GetVIterator( int flags
) const;
459 /** Hides or reveals a property.
461 If true, hides property, otherwise reveals it.
463 By default changes are applied recursively. Set this paramter wxPG_DONT_RECURSE to prevent this.
465 bool HideProperty( wxPGPropArg id
, bool hide
= true, int flags
= wxPG_RECURSE
);
467 /** Initializes *all* property types. Causes references to most object
468 files in the library, so calling this may cause significant increase
469 in executable size when linking with static library.
471 static void InitAllTypeHandlers();
474 /** Inserts property to the property container.
477 New property is inserted just prior to this. Available only
478 in the first variant. There are two versions of this function
479 to allow this parameter to be either an id or name to
483 Pointer to the inserted property. wxPropertyGrid will take
484 ownership of this object.
487 New property is inserted under this category. Available only
488 in the second variant. There are two versions of this function
489 to allow this parameter to be either an id or name to
493 Index under category. Available only in the second variant.
494 If index is < 0, property is appended in category.
497 Returns id for the property,
501 - wxPropertyGrid takes the ownership of the property pointer.
503 - While Append may be faster way to add items, make note that when
504 both types of data storage (categoric and
505 non-categoric) are active, Insert becomes even more slow. This is
506 especially true if current mode is non-categoric.
513 wxPGProperty* my_cat_id = propertygrid->Append( new wxPropertyCategory("My Category") );
517 // insert into category - using second variant
518 wxPGProperty* my_item_id_1 = propertygrid->Insert( my_cat_id, 0, new wxStringProperty("My String 1") );
520 // insert before to first item - using first variant
521 wxPGProperty* my_item_id_2 = propertygrid->Insert( my_item_id, new wxStringProperty("My String 2") );
526 wxPGProperty
* Insert( wxPGPropArg priorThis
, wxPGProperty
* newproperty
);
527 wxPGProperty
* Insert( wxPGPropArg parent
, int index
, wxPGProperty
* newproperty
);
530 /** Returns true if property is a category. */
531 bool IsPropertyCategory( wxPGPropArg id
) const
533 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(false)
534 return p
->IsCategory();
537 /** Inserts choice to a property that can accept one.
539 See AddPropertyChoice for more details.
541 void InsertPropertyChoice( wxPGPropArg id
, const wxString
& label
, int index
, int value
= wxPG_INVALID_VALUE
);
543 /** Returns true if property is enabled. */
544 bool IsPropertyEnabled( wxPGPropArg id
) const
546 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(false)
547 return (!(p
->GetFlags() & wxPG_PROP_DISABLED
))?true:false;
550 /** Returns true if given property is expanded. Naturally, always returns false
551 for properties that cannot be expanded.
553 bool IsPropertyExpanded( wxPGPropArg id
) const;
555 /** Returns true if property has been modified after value set or modify flag
558 bool IsPropertyModified( wxPGPropArg id
) const
560 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(false)
561 return ( (p
->GetFlags() & wxPG_PROP_MODIFIED
) ? true : false );
564 /** Returns true if property is shown (ie. hideproperty with true not called for it). */
565 bool IsPropertyShown( wxPGPropArg id
) const
567 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(false)
568 return (!(p
->GetFlags() & wxPG_PROP_HIDDEN
))?true:false;
571 /** Returns true if property value is set to unspecified.
573 bool IsPropertyValueUnspecified( wxPGPropArg id
) const
575 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(false)
576 return p
->IsValueUnspecified();
579 /** Disables (limit = true) or enables (limit = false) wxTextCtrl editor of a property,
580 if it is not the sole mean to edit the value.
582 void LimitPropertyEditing( wxPGPropArg id
, bool limit
= true );
584 /** If state is shown in it's grid, refresh it now.
586 virtual void RefreshGrid();
588 /** Initializes additional property editors (SpinCtrl etc.). Causes references
589 to most object files in the library, so calling this may cause significant increase
590 in executable size when linking with static library.
592 static void RegisterAdditionalEditors();
594 /** Replaces property with id with newly created property. For example,
595 this code replaces existing property named "Flags" with one that
596 will have different set of items:
598 pg->ReplaceProperty("Flags",
599 wxFlagsProperty("Flags", wxPG_LABEL, newItems))
601 For more info, see wxPropertyGrid::Insert.
603 wxPGProperty
* ReplaceProperty( wxPGPropArg id
, wxPGProperty
* property
);
606 /** @anchor propgridinterface_editablestate_flags
608 Flags for wxPropertyGridInterface::SaveEditableState() and
609 wxPropertyGridInterface::RestoreEditableState().
611 enum EditableStateFlags
613 /** Include selected property. */
614 SelectionState
= 0x01,
615 /** Include expanded/collapsed property information. */
616 ExpandedState
= 0x02,
617 /** Include scrolled position. */
618 ScrollPosState
= 0x04,
619 /** Include selected page information. Only applies to wxPropertyGridManager. */
621 /** Include splitter position. Stored for each page. */
622 SplitterPosState
= 0x10,
624 /** Include all supported user editable state information. This is usually the default value. */
625 AllStates
= SelectionState
| ExpandedState
| ScrollPosState
| PageState
| SplitterPosState
628 /** Restores user-editable state. See also wxPropertyGridInterface::SaveEditableState().
631 String generated by SaveEditableState.
634 Which parts to restore from source string. See @ref propgridinterface_editablestate_flags
635 "list of editable state flags".
638 False if there was problem reading the string.
641 If some parts of state (such as scrolled or splitter position) fail to restore correctly,
642 please make sure that you call this function after wxPropertyGrid size has been set
643 (this may sometimes be tricky when sizers are used).
645 bool RestoreEditableState( const wxString
& src
,
646 int restoreStates
= AllStates
);
648 /** Used to acquire user-editable state (selected property, expanded properties, scrolled position,
651 @param includedStates
652 Which parts of state to include. See @ref propgridinterface_editablestate_flags
653 "list of editable state flags".
655 wxString
SaveEditableState( int includedStates
= AllStates
) const;
657 /** Lets user to set the strings listed in the choice dropdown of a wxBoolProperty.
658 Defaults are "True" and "False", so changing them to, say, "Yes" and "No" may
659 be useful in some less technical applications.
661 static void SetBoolChoices( const wxString
& trueChoice
, const wxString
& falseChoice
);
663 /** Sets or clears flag(s) of all properties in given array.
665 Property flags to set or clear.
667 Set to true if you want to clear flag instead of setting them.
669 void SetPropertiesFlag( const wxArrayPGProperty
& srcArr
, wxPGProperty::FlagType flags
,
670 bool inverse
= false );
672 /** Sets an attribute for this property.
674 Text identifier of attribute. See @ref propgrid_property_attributes.
678 Optional. Use wxPG_RECURSE to set the attribute to child properties recursively.
680 void SetPropertyAttribute( wxPGPropArg id
, const wxString
& attrName
, wxVariant value
, long argFlags
= 0 )
682 DoSetPropertyAttribute(id
,attrName
,value
,argFlags
);
685 /** Sets attributes from a wxPGAttributeStorage.
687 void SetPropertyAttributes( wxPGPropArg id
, const wxPGAttributeStorage
& attributes
)
689 wxPG_PROP_ARG_CALL_PROLOG()
690 p
->SetAttributes(attributes
);
693 /** Sets text, bitmap, and colours for given column's cell.
696 - You can set label cell by setting column to 0.
697 - You can use wxPG_LABEL as text to use default text for column.
699 void SetPropertyCell( wxPGPropArg id
,
701 const wxString
& text
= wxEmptyString
,
702 const wxBitmap
& bitmap
= wxNullBitmap
,
703 const wxColour
& fgCol
= wxNullColour
,
704 const wxColour
& bgCol
= wxNullColour
)
706 wxPG_PROP_ARG_CALL_PROLOG()
707 p
->SetCell( column
, new wxPGCell(text
, bitmap
, fgCol
, bgCol
) );
710 /** Set choices of a property to specified set of labels and values.
713 This operation clears the property value.
715 void SetPropertyChoices( wxPGPropArg id
, wxPGChoices
& choices
)
717 wxPG_PROP_ARG_CALL_PROLOG()
718 p
->SetChoices(choices
);
722 /** If property's set of choices is shared, then calling this method converts
725 void SetPropertyChoicesExclusive( wxPGPropArg id
)
727 wxPG_PROP_ARG_CALL_PROLOG()
728 p
->SetChoicesExclusive();
731 /** Sets client data (void*) of a property.
733 This untyped client data has to be deleted manually.
735 void SetPropertyClientData( wxPGPropArg id
, void* clientData
)
737 wxPG_PROP_ARG_CALL_PROLOG()
738 p
->SetClientData(clientData
);
741 /** Sets editor for a property.
744 For builtin editors, use wxPGEditor_X, where X is builtin editor's
745 name (TextCtrl, Choice, etc. see wxPGEditor documentation for full list).
747 For custom editors, use pointer you received from wxPropertyGrid::RegisterEditorClass().
749 void SetPropertyEditor( wxPGPropArg id
, const wxPGEditor
* editor
)
751 wxPG_PROP_ARG_CALL_PROLOG()
752 wxCHECK_RET( editor
, wxT("unknown/NULL editor") );
753 p
->SetEditor(editor
);
757 /** Sets editor control of a property. As editor argument, use
758 editor name string, such as "TextCtrl" or "Choice".
760 void SetPropertyEditor( wxPGPropArg id
, const wxString
& editorName
)
762 SetPropertyEditor(id
,GetEditorByName(editorName
));
765 /** Sets label of a property.
768 - Properties under same parent may have same labels. However,
769 property names must still remain unique.
771 void SetPropertyLabel( wxPGPropArg id
, const wxString
& newproplabel
);
773 /** Set modified status of a property and all its children.
775 void SetPropertyModifiedStatus( wxPGPropArg id
, bool modified
)
777 wxPG_PROP_ARG_CALL_PROLOG()
778 p
->SetModifiedStatus(modified
);
781 /** Sets property (and, recursively, its children) to have read-only value. In other words,
782 user cannot change the value in the editor, but they can still copy it.
784 This is mainly for use with textctrl editor. Not all other editors fully
787 By default changes are applied recursively. Set this paramter wxPG_DONT_RECURSE to prevent this.
789 void SetPropertyReadOnly( wxPGPropArg id
, bool set
= true, int flags
= wxPG_RECURSE
)
791 wxPG_PROP_ARG_CALL_PROLOG()
792 if ( flags
& wxPG_RECURSE
)
793 p
->SetFlagRecursively(wxPG_PROP_READONLY
, set
);
795 p
->SetFlag(wxPG_PROP_READONLY
);
798 /** Sets property's value to unspecified. If it has children (it may be category),
799 then the same thing is done to them.
801 void SetPropertyValueUnspecified( wxPGPropArg id
);
803 /** Sets various property values from a list of wxVariants. If property with
804 name is missing from the grid, new property is created under given default
805 category (or root if omitted).
807 void SetPropertyValues( const wxVariantList
& list
, wxPGPropArg defaultCategory
= wxNullProperty
)
810 if ( defaultCategory
.HasName() ) p
= defaultCategory
.GetPtr(this);
811 else p
= defaultCategory
.GetPtr0();
812 m_pState
->DoSetPropertyValues(list
, p
);
815 void SetPropertyValues( const wxVariant
& list
, wxPGPropArg defaultCategory
= wxNullProperty
)
817 SetPropertyValues(list
.GetList(),defaultCategory
);
820 /** Associates the help string with property.
822 By default, text is shown either in the manager's "description"
823 text box or in the status bar. If extra window style wxPG_EX_HELP_AS_TOOLTIPS
824 is used, then the text will appear as a tooltip.
826 void SetPropertyHelpString( wxPGPropArg id
, const wxString
& helpString
)
828 wxPG_PROP_ARG_CALL_PROLOG()
829 p
->SetHelpString(helpString
);
832 /** Set wxBitmap in front of the value.
834 - Bitmap will be scaled to a size returned by wxPropertyGrid::GetImageSize();
836 void SetPropertyImage( wxPGPropArg id
, wxBitmap
& bmp
)
838 wxPG_PROP_ARG_CALL_PROLOG()
839 p
->SetValueImage(bmp
);
843 /** Sets max length of property's text.
845 bool SetPropertyMaxLength( wxPGPropArg id
, int maxLen
);
847 /** Sets validator of a property.
849 void SetPropertyValidator( wxPGPropArg id
, const wxValidator
& validator
)
851 wxPG_PROP_ARG_CALL_PROLOG()
852 p
->SetValidator(validator
);
855 /** Sets value (long integer) of a property.
857 void SetPropertyValue( wxPGPropArg id
, long value
)
863 /** Sets value (integer) of a property.
865 void SetPropertyValue( wxPGPropArg id
, int value
)
867 wxVariant
v((long)value
);
870 /** Sets value (floating point) of a property.
872 void SetPropertyValue( wxPGPropArg id
, double value
)
877 /** Sets value (bool) of a property.
879 void SetPropertyValue( wxPGPropArg id
, bool value
)
884 void SetPropertyValue( wxPGPropArg id
, const wxChar
* value
)
886 SetPropertyValueString( id
, wxString(value
) );
888 void SetPropertyValue( wxPGPropArg id
, const wxString
& value
)
890 SetPropertyValueString( id
, value
);
893 /** Sets value (wxArrayString) of a property.
895 void SetPropertyValue( wxPGPropArg id
, const wxArrayString
& value
)
901 void SetPropertyValue( wxPGPropArg id
, const wxDateTime
& value
)
907 /** Sets value (wxObject*) of a property.
909 void SetPropertyValue( wxPGPropArg id
, wxObject
* value
)
915 void SetPropertyValue( wxPGPropArg id
, wxObject
& value
)
921 /** Sets value (wxPoint&) of a property.
923 void SetPropertyValue( wxPGPropArg id
, const wxPoint
& value
)
925 wxVariant v
= WXVARIANT(value
);
928 /** Sets value (wxSize&) of a property.
930 void SetPropertyValue( wxPGPropArg id
, const wxSize
& value
)
932 wxVariant v
= WXVARIANT(value
);
935 /** Sets value (wxLongLong&) of a property.
937 void SetPropertyValue( wxPGPropArg id
, wxLongLong_t value
)
939 wxVariant v
= WXVARIANT(wxLongLong(value
));
942 /** Sets value (wxULongLong&) of a property.
944 void SetPropertyValue( wxPGPropArg id
, wxULongLong_t value
)
946 wxVariant v
= WXVARIANT(wxULongLong(value
));
949 /** Sets value (wxArrayInt&) of a property.
951 void SetPropertyValue( wxPGPropArg id
, const wxArrayInt
& value
)
953 wxVariant v
= WXVARIANT(value
);
957 /** Sets value (wxString) of a property.
960 This method uses wxPGProperty::SetValueFromString, which all properties
961 should implement. This means that there should not be a type error,
962 and instead the string is converted to property's actual value type.
964 void SetPropertyValueString( wxPGPropArg id
, const wxString
& value
);
966 /** Sets value (wxVariant&) of a property.
969 Use wxPropertyGrid::ChangePropertyValue() instead if you need to run through
970 validation process and send property change event.
972 void SetPropertyValue( wxPGPropArg id
, wxVariant value
)
974 SetPropVal( id
, value
);
977 /** Adjusts how wxPropertyGrid behaves when invalid value is entered
980 See @link vfbflags list of valid flags values@endlink
982 void SetValidationFailureBehavior( int vfbFlags
);
984 // GetPropertyByName With nice assertion error message.
985 wxPGProperty
* GetPropertyByNameA( const wxString
& name
) const;
987 static wxPGEditor
* GetEditorByName( const wxString
& editorName
);
989 virtual void RefreshProperty( wxPGProperty
* p
) = 0;