1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/propgrid/propgridiface.h
3 // Purpose: wxPropertyGridInterface class
4 // Author: Jaakko Salli
8 // Copyright: (c) Jaakko Salli
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef __WX_PROPGRID_PROPGRIDIFACE_H__
13 #define __WX_PROPGRID_PROPGRIDIFACE_H__
19 #include "wx/propgrid/property.h"
20 #include "wx/propgrid/propgridpagestate.h"
22 // -----------------------------------------------------------------------
24 /** @section wxPGPropArgCls
26 Most property grid functions have this type as their argument, as it can
27 convey a property by either a pointer or name.
29 class WXDLLIMPEXP_PROPGRID wxPGPropArgCls
32 wxPGPropArgCls( const wxPGProperty
* property
)
34 m_ptr
.property
= (wxPGProperty
*) property
;
37 wxPGPropArgCls( const wxString
& str
)
39 m_ptr
.stringName
= &str
;
42 wxPGPropArgCls( const wxPGPropArgCls
& id
)
47 // This is only needed for wxPython bindings
48 wxPGPropArgCls( wxString
* str
, bool WXUNUSED(deallocPtr
) )
50 m_ptr
.stringName
= str
;
51 m_flags
= IsWxString
| OwnsWxString
;
55 if ( m_flags
& OwnsWxString
)
56 delete m_ptr
.stringName
;
58 wxPGProperty
* GetPtr() const
60 wxCHECK( m_flags
== IsProperty
, NULL
);
61 return m_ptr
.property
;
63 wxPGPropArgCls( const char* str
)
68 wxPGPropArgCls( const wchar_t* str
)
70 m_ptr
.wcharName
= str
;
73 /** This constructor is required for NULL. */
76 m_ptr
.property
= NULL
;
79 wxPGProperty
* GetPtr( wxPropertyGridInterface
* iface
) const;
80 wxPGProperty
* GetPtr( const wxPropertyGridInterface
* iface
) const
82 return GetPtr((wxPropertyGridInterface
*)iface
);
84 wxPGProperty
* GetPtr0() const { return m_ptr
.property
; }
85 bool HasName() const { return (m_flags
!= IsProperty
); }
86 const wxString
& GetName() const { return *m_ptr
.stringName
; }
100 wxPGProperty
* property
;
101 const char* charName
;
102 const wchar_t* wcharName
;
103 const wxString
* stringName
;
105 unsigned char m_flags
;
108 typedef const wxPGPropArgCls
& wxPGPropArg
;
110 // -----------------------------------------------------------------------
113 void wxPGTypeOperationFailed( const wxPGProperty
* p
,
114 const wxString
& typestr
,
115 const wxString
& op
);
117 void wxPGGetFailed( const wxPGProperty
* p
, const wxString
& typestr
);
119 // -----------------------------------------------------------------------
121 // Helper macro that does necessary preparations when calling
122 // some wxPGProperty's member function.
123 #define wxPG_PROP_ARG_CALL_PROLOG_0(PROPERTY) \
124 PROPERTY *p = (PROPERTY*)id.GetPtr(this); \
127 #define wxPG_PROP_ARG_CALL_PROLOG_RETVAL_0(PROPERTY, RETVAL) \
128 PROPERTY *p = (PROPERTY*)id.GetPtr(this); \
129 if ( !p ) return RETVAL;
131 #define wxPG_PROP_ARG_CALL_PROLOG() \
132 wxPG_PROP_ARG_CALL_PROLOG_0(wxPGProperty)
134 #define wxPG_PROP_ARG_CALL_PROLOG_RETVAL(RVAL) \
135 wxPG_PROP_ARG_CALL_PROLOG_RETVAL_0(wxPGProperty, RVAL)
137 #define wxPG_PROP_ID_CONST_CALL_PROLOG() \
138 wxPG_PROP_ARG_CALL_PROLOG_0(const wxPGProperty)
140 #define wxPG_PROP_ID_CONST_CALL_PROLOG_RETVAL(RVAL) \
141 wxPG_PROP_ARG_CALL_PROLOG_RETVAL_0(const wxPGProperty, RVAL)
143 // -----------------------------------------------------------------------
146 /** @class wxPropertyGridInterface
148 Most of the shared property manipulation interface shared by wxPropertyGrid,
149 wxPropertyGridPage, and wxPropertyGridManager is defined in this class.
152 - In separate wxPropertyGrid component this class was known as
153 wxPropertyContainerMethods.
158 class WXDLLIMPEXP_PROPGRID wxPropertyGridInterface
163 virtual ~wxPropertyGridInterface() { }
166 Appends property to the list.
168 wxPropertyGrid assumes ownership of the object.
169 Becomes child of most recently added category.
171 - wxPropertyGrid takes the ownership of the property pointer.
172 - If appending a category with name identical to a category already in
173 the wxPropertyGrid, then newly created category is deleted, and most
174 recently added category (under which properties are appended) is set
175 to the one with same name. This allows easier adding of items to same
176 categories in multiple passes.
177 - Does not automatically redraw the control, so you may need to call
178 Refresh when calling this function after control has been shown for
181 wxPGProperty
* Append( wxPGProperty
* property
);
183 wxPGProperty
* AppendIn( wxPGPropArg id
, wxPGProperty
* newproperty
);
186 In order to add new items into a property with fixed children (for
187 instance, wxFlagsProperty), you need to call this method. After
188 populating has been finished, you need to call EndAddChildren.
190 void BeginAddChildren( wxPGPropArg id
);
192 /** Deletes all properties.
194 virtual void Clear() = 0;
197 Clears current selection, if any.
200 If set to @false, deselecting the property will always work,
201 even if its editor had invalid value in it.
203 @return Returns @true if successful or if there was no selection. May
204 fail if validation was enabled and active editor had invalid
207 @remarks In wxPropertyGrid 1.4, this member function used to send
208 wxPG_EVT_SELECTED. In wxWidgets 2.9 and later, it no longer
211 bool ClearSelection( bool validation
= false );
213 /** Resets modified status of all properties.
215 void ClearModifiedStatus();
217 /** Collapses given category or property with children.
218 Returns true if actually collapses.
220 bool Collapse( wxPGPropArg id
);
222 /** Collapses all items that can be collapsed.
225 Return false if failed (may fail if editor value cannot be validated).
227 bool CollapseAll() { return ExpandAll(false); }
230 Changes value of a property, as if from an editor.
231 Use this instead of SetPropertyValue() if you need the value to run
232 through validation process, and also send the property change event.
235 Returns true if value was successfully changed.
237 bool ChangePropertyValue( wxPGPropArg id
, wxVariant newValue
);
240 Removes and deletes a property and any children.
243 Pointer or name of a property.
245 @remarks If you delete a property in a wxPropertyGrid event
246 handler, the actual deletion is postponed until the next
249 This functions deselects selected property, if any.
250 Validation failure option wxPG_VFB_STAY_IN_PROPERTY is not
251 respected, ie. selection is cleared even if editor had
254 void DeleteProperty( wxPGPropArg id
);
257 Removes a property. Does not delete the property object, but
261 Pointer or name of a property.
263 @remarks Removed property cannot have any children.
265 Also, if you remove property in a wxPropertyGrid event
266 handler, the actual removal is postponed until the next
269 wxPGProperty
* RemoveProperty( wxPGPropArg id
);
274 @see EnableProperty(), wxPGProperty::Enable()
276 bool DisableProperty( wxPGPropArg id
) { return EnableProperty(id
,false); }
279 Returns true if all property grid data changes have been committed.
281 Usually only returns false if value in active editor has been
282 invalidated by a wxValidator.
284 bool EditorValidate();
287 Enables or disables property, depending on whether enable is true or
288 false. Disabled property usually appears as having grey text.
291 Name or pointer to a property.
293 If @false, property is disabled instead.
295 @see wxPGProperty::Enable()
297 bool EnableProperty( wxPGPropArg id
, bool enable
= true );
299 /** Called after population of property with fixed children has finished.
301 void EndAddChildren( wxPGPropArg id
);
303 /** Expands given category or property with children.
304 Returns true if actually expands.
306 bool Expand( wxPGPropArg id
);
308 /** Expands all items that can be expanded.
310 bool ExpandAll( bool expand
= true );
312 /** Returns id of first child of given property.
314 Does not return sub-properties!
316 wxPGProperty
* GetFirstChild( wxPGPropArg id
)
318 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(wxNullProperty
)
320 if ( !p
->GetChildCount() || p
->HasFlag(wxPG_PROP_AGGREGATE
) )
321 return wxNullProperty
;
327 /** Returns iterator class instance.
329 See @ref propgrid_iterator_flags. Value wxPG_ITERATE_DEFAULT causes
330 iteration over everything except private child properties.
332 Property to start iteration from. If NULL, then first child of root
335 Either wxTOP or wxBOTTOM. wxTOP will indicate that iterations start
336 from the first property from the top, and wxBOTTOM means that the
337 iteration will instead begin from bottommost valid item.
339 wxPropertyGridIterator
GetIterator( int flags
= wxPG_ITERATE_DEFAULT
,
340 wxPGProperty
* firstProp
= NULL
)
342 return wxPropertyGridIterator( m_pState
, flags
, firstProp
);
345 wxPropertyGridConstIterator
346 GetIterator( int flags
= wxPG_ITERATE_DEFAULT
,
347 wxPGProperty
* firstProp
= NULL
) const
349 return wxPropertyGridConstIterator( m_pState
, flags
, firstProp
);
352 wxPropertyGridIterator
GetIterator( int flags
, int startPos
)
354 return wxPropertyGridIterator( m_pState
, flags
, startPos
);
357 wxPropertyGridConstIterator
GetIterator( int flags
, int startPos
) const
359 return wxPropertyGridConstIterator( m_pState
, flags
, startPos
);
363 /** Returns id of first item, whether it is a category or property.
365 @link iteratorflags List of iterator flags@endlink
367 wxPGProperty
* GetFirst( int flags
= wxPG_ITERATE_ALL
)
369 wxPropertyGridIterator
it( m_pState
, flags
, wxNullProperty
, 1 );
373 const wxPGProperty
* GetFirst( int flags
= wxPG_ITERATE_ALL
) const
375 return ((wxPropertyGridInterface
*)this)->GetFirst(flags
);
379 Returns pointer to a property with given name (case-sensitive).
380 If there is no property with such name, @NULL pointer is returned.
382 @remarks Properties which have non-category, non-root parent
383 cannot be accessed globally by their name. Instead, use
384 "<property>.<subproperty>" instead of "<subproperty>".
386 wxPGProperty
* GetProperty( const wxString
& name
) const
388 return GetPropertyByName(name
);
391 /** Returns map-like storage of property's attributes.
393 Note that if extra style wxPG_EX_WRITEONLY_BUILTIN_ATTRIBUTES is set,
394 then builtin-attributes are not included in the storage.
396 const wxPGAttributeStorage
& GetPropertyAttributes( wxPGPropArg id
) const
398 // If 'id' refers to invalid property, then we will return dummy
399 // attributes (ie. root property's attributes, which contents should
400 // should always be empty and of no consequence).
401 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(m_pState
->DoGetRoot()->GetAttributes());
402 return p
->GetAttributes();
405 /** Adds to 'targetArr' pointers to properties that have given
406 flags 'flags' set. However, if 'inverse' is set to true, then
407 only properties without given flags are stored.
409 Property flags to use.
411 Iterator flags to use. Default is everything expect private children.
413 void GetPropertiesWithFlag( wxArrayPGProperty
* targetArr
,
414 wxPGProperty::FlagType flags
,
415 bool inverse
= false,
416 int iterFlags
= wxPG_ITERATE_PROPERTIES
|
417 wxPG_ITERATE_HIDDEN
|
418 wxPG_ITERATE_CATEGORIES
) const;
420 /** Returns value of given attribute. If none found, returns NULL-variant.
422 wxVariant
GetPropertyAttribute( wxPGPropArg id
,
423 const wxString
& attrName
) const
425 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(wxNullVariant
)
426 return p
->GetAttribute(attrName
);
429 /** Returns pointer of property's nearest parent category. If no category
432 wxPropertyCategory
* GetPropertyCategory( wxPGPropArg id
) const
434 wxPG_PROP_ID_CONST_CALL_PROLOG_RETVAL(NULL
)
435 return m_pState
->GetPropertyCategory(p
);
438 /** Returns client data (void*) of a property. */
439 void* GetPropertyClientData( wxPGPropArg id
) const
441 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(NULL
)
442 return p
->GetClientData();
446 Returns first property which label matches given string.
448 NULL if none found. Note that this operation is extremely slow when
449 compared to GetPropertyByName().
451 wxPGProperty
* GetPropertyByLabel( const wxString
& label
) const;
453 /** Returns property with given name. NULL if none found.
455 wxPGProperty
* GetPropertyByName( const wxString
& name
) const;
457 /** Returns child property 'subname' of property 'name'. Same as
458 calling GetPropertyByName("name.subname"), albeit slightly faster.
460 wxPGProperty
* GetPropertyByName( const wxString
& name
,
461 const wxString
& subname
) const;
463 /** Returns property's editor. */
464 const wxPGEditor
* GetPropertyEditor( wxPGPropArg id
) const
466 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(NULL
)
467 return p
->GetEditorClass();
470 /** Returns help string associated with a property. */
471 wxString
GetPropertyHelpString( wxPGPropArg id
) const
473 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(m_emptyString
)
474 return p
->GetHelpString();
477 /** Returns property's custom value image (NULL of none). */
478 wxBitmap
* GetPropertyImage( wxPGPropArg id
) const
480 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(NULL
)
481 return p
->GetValueImage();
484 /** Returns label of a property. */
485 const wxString
& GetPropertyLabel( wxPGPropArg id
)
487 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(m_emptyString
)
488 return p
->GetLabel();
491 /** Returns name of a property, by which it is globally accessible. */
492 wxString
GetPropertyName( wxPGProperty
* property
)
494 return property
->GetName();
497 /** Returns parent item of a property. */
498 wxPGProperty
* GetPropertyParent( wxPGPropArg id
)
500 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(wxNullProperty
)
501 return p
->GetParent();
505 /** Returns validator of a property as a reference, which you
506 can pass to any number of SetPropertyValidator.
508 wxValidator
* GetPropertyValidator( wxPGPropArg id
)
510 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(NULL
)
511 return p
->GetValidator();
515 /** Returns value as wxVariant. To get wxObject pointer from it,
516 you will have to use WX_PG_VARIANT_TO_WXOBJECT(VARIANT,CLASSNAME) macro.
518 If property value is unspecified, Null variant is returned.
520 wxVariant
GetPropertyValue( wxPGPropArg id
)
522 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(wxVariant())
523 return p
->GetValue();
526 wxString
GetPropertyValueAsString( wxPGPropArg id
) const;
527 long GetPropertyValueAsLong( wxPGPropArg id
) const;
528 unsigned long GetPropertyValueAsULong( wxPGPropArg id
) const
530 return (unsigned long) GetPropertyValueAsLong(id
);
532 int GetPropertyValueAsInt( wxPGPropArg id
) const
533 { return (int)GetPropertyValueAsLong(id
); }
534 bool GetPropertyValueAsBool( wxPGPropArg id
) const;
535 double GetPropertyValueAsDouble( wxPGPropArg id
) const;
537 #define wxPG_PROP_ID_GETPROPVAL_CALL_PROLOG_RETVAL(TYPENAME, DEFVAL) \
538 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(DEFVAL) \
539 wxString typeName(wxS(TYPENAME)); \
540 wxVariant value = p->GetValue(); \
541 if ( value.GetType() != typeName ) \
543 wxPGGetFailed(p, typeName); \
547 #define wxPG_PROP_ID_GETPROPVAL_CALL_PROLOG_RETVAL_WFALLBACK(TYPENAME, DEFVAL) \
548 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(DEFVAL) \
549 wxVariant value = p->GetValue(); \
550 if ( value.GetType() != wxS(TYPENAME) ) \
553 wxArrayString GetPropertyValueAsArrayString( wxPGPropArg id ) const
555 wxPG_PROP_ID_GETPROPVAL_CALL_PROLOG_RETVAL("arrstring",
557 return value
.GetArrayString();
561 wxLongLong_t
GetPropertyValueAsLongLong( wxPGPropArg id
) const
563 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(0)
564 return p
->GetValue().GetLongLong().GetValue();
567 wxULongLong_t
GetPropertyValueAsULongLong( wxPGPropArg id
) const
569 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(0)
570 return p
->GetValue().GetULongLong().GetValue();
574 wxArrayInt
GetPropertyValueAsArrayInt( wxPGPropArg id
) const
576 wxPG_PROP_ID_GETPROPVAL_CALL_PROLOG_RETVAL("wxArrayInt",
584 wxDateTime
GetPropertyValueAsDateTime( wxPGPropArg id
) const
586 wxPG_PROP_ID_GETPROPVAL_CALL_PROLOG_RETVAL("datetime",
588 return value
.GetDateTime();
592 /** Returns a wxVariant list containing wxVariant versions of all
593 property values. Order is not guaranteed.
595 Use wxPG_KEEP_STRUCTURE to retain category structure; each sub
596 category will be its own wxVariantList of wxVariant.
597 Use wxPG_INC_ATTRIBUTES to include property attributes as well.
598 Each attribute will be stored as list variant named
599 "@@<propname>@@attr."
602 wxVariant
GetPropertyValues( const wxString
& listname
= wxEmptyString
,
603 wxPGProperty
* baseparent
= NULL
, long flags
= 0 ) const
605 return m_pState
->DoGetPropertyValues(listname
, baseparent
, flags
);
609 Returns currently selected property. NULL if none.
611 @remarks When wxPG_EX_MULTIPLE_SELECTION extra style is used, this
612 member function returns the focused property, that is the
613 one which can have active editor.
615 wxPGProperty
* GetSelection() const;
618 Returns list of currently selected properties.
620 @remarks wxArrayPGProperty should be compatible with std::vector API.
622 const wxArrayPGProperty
& GetSelectedProperties() const
624 return m_pState
->m_selection
;
627 wxPropertyGridPageState
* GetState() const { return m_pState
; }
629 /** Similar to GetIterator(), but instead returns wxPGVIterator instance,
630 which can be useful for forward-iterating through arbitrary property
634 See @ref propgrid_iterator_flags.
636 virtual wxPGVIterator
GetVIterator( int flags
) const;
638 /** Hides or reveals a property.
640 If true, hides property, otherwise reveals it.
642 By default changes are applied recursively. Set this paramter
643 wxPG_DONT_RECURSE to prevent this.
645 bool HideProperty( wxPGPropArg id
,
647 int flags
= wxPG_RECURSE
);
649 #if wxPG_INCLUDE_ADVPROPS
650 /** Initializes *all* property types. Causes references to most object
651 files in the library, so calling this may cause significant increase
652 in executable size when linking with static library.
654 static void InitAllTypeHandlers();
656 static void InitAllTypeHandlers() { }
660 /** Inserts property to the property container.
663 New property is inserted just prior to this. Available only
664 in the first variant. There are two versions of this function
665 to allow this parameter to be either an id or name to
669 Pointer to the inserted property. wxPropertyGrid will take
670 ownership of this object.
673 New property is inserted under this category. Available only
674 in the second variant. There are two versions of this function
675 to allow this parameter to be either an id or name to
679 Index under category. Available only in the second variant.
680 If index is < 0, property is appended in category.
683 Returns id for the property,
687 - wxPropertyGrid takes the ownership of the property pointer.
689 - While Append may be faster way to add items, make note that when
690 both types of data storage (categoric and
691 non-categoric) are active, Insert becomes even more slow. This is
692 especially true if current mode is non-categoric.
699 wxPGProperty* my_cat_id = propertygrid->Append(
700 new wxPropertyCategory("My Category") );
704 // insert into category - using second variant
705 wxPGProperty* my_item_id_1 = propertygrid->Insert(
706 my_cat_id, 0, new wxStringProperty("My String 1") );
708 // insert before to first item - using first variant
709 wxPGProperty* my_item_id_2 = propertygrid->Insert(
710 my_item_id, new wxStringProperty("My String 2") );
715 wxPGProperty
* Insert( wxPGPropArg priorThis
, wxPGProperty
* newproperty
);
716 wxPGProperty
* Insert( wxPGPropArg parent
,
718 wxPGProperty
* newproperty
);
721 /** Returns true if property is a category. */
722 bool IsPropertyCategory( wxPGPropArg id
) const
724 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(false)
725 return p
->IsCategory();
728 /** Returns true if property is enabled. */
729 bool IsPropertyEnabled( wxPGPropArg id
) const
731 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(false)
732 return (!(p
->GetFlags() & wxPG_PROP_DISABLED
))?true:false;
736 Returns true if given property is expanded.
738 Naturally, always returns false for properties that cannot be expanded.
740 bool IsPropertyExpanded( wxPGPropArg id
) const;
743 Returns true if property has been modified after value set or modify
744 flag clear by software.
746 bool IsPropertyModified( wxPGPropArg id
) const
748 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(false)
749 return ( (p
->GetFlags() & wxPG_PROP_MODIFIED
) ? true : false );
753 Returns true if property is selected.
755 bool IsPropertySelected( wxPGPropArg id
) const
757 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(false)
758 return m_pState
->DoIsPropertySelected(p
);
762 Returns true if property is shown (ie hideproperty with true not
765 bool IsPropertyShown( wxPGPropArg id
) const
767 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(false)
768 return (!(p
->GetFlags() & wxPG_PROP_HIDDEN
))?true:false;
771 /** Returns true if property value is set to unspecified.
773 bool IsPropertyValueUnspecified( wxPGPropArg id
) const
775 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(false)
776 return p
->IsValueUnspecified();
780 Disables (limit = true) or enables (limit = false) wxTextCtrl editor of
781 a property, if it is not the sole mean to edit the value.
783 void LimitPropertyEditing( wxPGPropArg id
, bool limit
= true );
785 /** If state is shown in it's grid, refresh it now.
787 virtual void RefreshGrid( wxPropertyGridPageState
* state
= NULL
);
789 #if wxPG_INCLUDE_ADVPROPS
791 Initializes additional property editors (SpinCtrl etc.). Causes
792 references to most object files in the library, so calling this may
793 cause significant increase in executable size when linking with static
796 static void RegisterAdditionalEditors();
798 static void RegisterAdditionalEditors() { }
801 /** Replaces property with id with newly created property. For example,
802 this code replaces existing property named "Flags" with one that
803 will have different set of items:
805 pg->ReplaceProperty("Flags",
806 wxFlagsProperty("Flags", wxPG_LABEL, newItems))
808 For more info, see wxPropertyGrid::Insert.
810 wxPGProperty
* ReplaceProperty( wxPGPropArg id
, wxPGProperty
* property
);
812 /** @anchor propgridinterface_editablestate_flags
814 Flags for wxPropertyGridInterface::SaveEditableState() and
815 wxPropertyGridInterface::RestoreEditableState().
817 enum EditableStateFlags
819 /** Include selected property. */
820 SelectionState
= 0x01,
821 /** Include expanded/collapsed property information. */
822 ExpandedState
= 0x02,
823 /** Include scrolled position. */
824 ScrollPosState
= 0x04,
825 /** Include selected page information.
826 Only applies to wxPropertyGridManager. */
828 /** Include splitter position. Stored for each page. */
829 SplitterPosState
= 0x10,
830 /** Include description box size.
831 Only applies to wxPropertyGridManager. */
835 Include all supported user editable state information.
836 This is usually the default value. */
837 AllStates
= SelectionState
|
846 Restores user-editable state.
848 See also wxPropertyGridInterface::SaveEditableState().
851 String generated by SaveEditableState.
854 Which parts to restore from source string. See @ref
855 propgridinterface_editablestate_flags "list of editable state
859 False if there was problem reading the string.
862 If some parts of state (such as scrolled or splitter position) fail to
863 restore correctly, please make sure that you call this function after
864 wxPropertyGrid size has been set (this may sometimes be tricky when
867 bool RestoreEditableState( const wxString
& src
,
868 int restoreStates
= AllStates
);
871 Used to acquire user-editable state (selected property, expanded
872 properties, scrolled position, splitter positions).
874 @param includedStates
875 Which parts of state to include. See @ref
876 propgridinterface_editablestate_flags "list of editable state flags".
878 wxString
SaveEditableState( int includedStates
= AllStates
) const;
881 Lets user set the strings listed in the choice dropdown of a
882 wxBoolProperty. Defaults are "True" and "False", so changing them to,
883 say, "Yes" and "No" may be useful in some less technical applications.
885 static void SetBoolChoices( const wxString
& trueChoice
,
886 const wxString
& falseChoice
);
889 Set proportion of a auto-stretchable column. wxPG_SPLITTER_AUTO_CENTER
890 window style needs to be used to indicate that columns are auto-
893 @returns Returns @false on failure.
895 @remarks You should call this for individual pages of
896 wxPropertyGridManager (if used).
898 @see GetColumnProportion()
900 bool SetColumnProportion( unsigned int column
, int proportion
);
903 Returns auto-resize proportion of the given column.
905 @see SetColumnProportion()
907 int GetColumnProportion( unsigned int column
) const
909 return m_pState
->DoGetColumnProportion(column
);
912 /** Sets an attribute for this property.
914 Text identifier of attribute. See @ref propgrid_property_attributes.
918 Optional. Use wxPG_RECURSE to set the attribute to child properties
921 void SetPropertyAttribute( wxPGPropArg id
,
922 const wxString
& attrName
,
926 DoSetPropertyAttribute(id
,attrName
,value
,argFlags
);
929 /** Sets property attribute for all applicapple properties.
930 Be sure to use this method only after all properties have been
933 void SetPropertyAttributeAll( const wxString
& attrName
, wxVariant value
);
936 Sets background colour of a property.
939 Property name or pointer.
942 New background colour.
945 Default is wxPG_RECURSE which causes colour to be set recursively.
946 Omit this flag to only set colour for the property in question
947 and not any of its children.
949 void SetPropertyBackgroundColour( wxPGPropArg id
,
950 const wxColour
& colour
,
951 int flags
= wxPG_RECURSE
);
953 /** Resets text and background colours of given property.
955 void SetPropertyColoursToDefault( wxPGPropArg id
);
958 Sets text colour of a property.
961 Property name or pointer.
964 New background colour.
967 Default is wxPG_RECURSE which causes colour to be set recursively.
968 Omit this flag to only set colour for the property in question
969 and not any of its children.
971 void SetPropertyTextColour( wxPGPropArg id
,
973 int flags
= wxPG_RECURSE
);
976 Returns background colour of first cell of a property.
978 wxColour
GetPropertyBackgroundColour( wxPGPropArg id
) const
980 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(wxColour())
981 return p
->GetCell(0).GetBgCol();
985 Returns text colour of first cell of a property.
987 wxColour
GetPropertyTextColour( wxPGPropArg id
) const
989 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(wxColour())
990 return p
->GetCell(0).GetFgCol();
993 /** Sets text, bitmap, and colours for given column's cell.
996 - You can set label cell by setting column to 0.
997 - You can use wxPG_LABEL as text to use default text for column.
999 void SetPropertyCell( wxPGPropArg id
,
1001 const wxString
& text
= wxEmptyString
,
1002 const wxBitmap
& bitmap
= wxNullBitmap
,
1003 const wxColour
& fgCol
= wxNullColour
,
1004 const wxColour
& bgCol
= wxNullColour
);
1006 /** Sets client data (void*) of a property.
1008 This untyped client data has to be deleted manually.
1010 void SetPropertyClientData( wxPGPropArg id
, void* clientData
)
1012 wxPG_PROP_ARG_CALL_PROLOG()
1013 p
->SetClientData(clientData
);
1016 /** Sets editor for a property.
1019 For builtin editors, use wxPGEditor_X, where X is builtin editor's
1020 name (TextCtrl, Choice, etc. see wxPGEditor documentation for full
1023 For custom editors, use pointer you received from
1024 wxPropertyGrid::RegisterEditorClass().
1026 void SetPropertyEditor( wxPGPropArg id
, const wxPGEditor
* editor
)
1028 wxPG_PROP_ARG_CALL_PROLOG()
1029 wxCHECK_RET( editor
, wxT("unknown/NULL editor") );
1030 p
->SetEditor(editor
);
1034 /** Sets editor control of a property. As editor argument, use
1035 editor name string, such as "TextCtrl" or "Choice".
1037 void SetPropertyEditor( wxPGPropArg id
, const wxString
& editorName
)
1039 SetPropertyEditor(id
,GetEditorByName(editorName
));
1042 /** Sets label of a property.
1044 void SetPropertyLabel( wxPGPropArg id
, const wxString
& newproplabel
);
1047 Sets name of a property.
1050 Name or pointer of property which name to change.
1053 New name for property.
1055 void SetPropertyName( wxPGPropArg id
, const wxString
& newName
)
1057 wxPG_PROP_ARG_CALL_PROLOG()
1058 m_pState
->DoSetPropertyName( p
, newName
);
1062 Sets property (and, recursively, its children) to have read-only value.
1063 In other words, user cannot change the value in the editor, but they
1066 This is mainly for use with textctrl editor. Not all other editors fully
1069 By default changes are applied recursively. Set this paramter
1070 wxPG_DONT_RECURSE to prevent this.
1072 void SetPropertyReadOnly( wxPGPropArg id
,
1074 int flags
= wxPG_RECURSE
)
1076 wxPG_PROP_ARG_CALL_PROLOG()
1077 if ( flags
& wxPG_RECURSE
)
1078 p
->SetFlagRecursively(wxPG_PROP_READONLY
, set
);
1080 p
->ChangeFlag(wxPG_PROP_READONLY
, set
);
1083 /** Sets property's value to unspecified.
1084 If it has children (it may be category), then the same thing is done to
1087 void SetPropertyValueUnspecified( wxPGPropArg id
)
1089 wxPG_PROP_ARG_CALL_PROLOG()
1090 p
->SetValueToUnspecified();
1094 Sets property values from a list of wxVariants.
1096 void SetPropertyValues( const wxVariantList
& list
,
1097 wxPGPropArg defaultCategory
= wxNullProperty
)
1100 if ( defaultCategory
.HasName() ) p
= defaultCategory
.GetPtr(this);
1101 else p
= defaultCategory
.GetPtr0();
1102 m_pState
->DoSetPropertyValues(list
, p
);
1106 Sets property values from a list of wxVariants.
1108 void SetPropertyValues( const wxVariant
& list
,
1109 wxPGPropArg defaultCategory
= wxNullProperty
)
1111 SetPropertyValues(list
.GetList(),defaultCategory
);
1114 /** Associates the help string with property.
1116 By default, text is shown either in the manager's "description"
1117 text box or in the status bar. If extra window style
1118 wxPG_EX_HELP_AS_TOOLTIPS is used, then the text will appear as a
1121 void SetPropertyHelpString( wxPGPropArg id
, const wxString
& helpString
)
1123 wxPG_PROP_ARG_CALL_PROLOG()
1124 p
->SetHelpString(helpString
);
1127 /** Set wxBitmap in front of the value.
1129 - Bitmap will be scaled to a size returned by
1130 wxPropertyGrid::GetImageSize();
1132 void SetPropertyImage( wxPGPropArg id
, wxBitmap
& bmp
)
1134 wxPG_PROP_ARG_CALL_PROLOG()
1135 p
->SetValueImage(bmp
);
1139 /** Sets max length of property's text.
1141 bool SetPropertyMaxLength( wxPGPropArg id
, int maxLen
);
1143 #if wxUSE_VALIDATORS
1144 /** Sets validator of a property.
1146 void SetPropertyValidator( wxPGPropArg id
, const wxValidator
& validator
)
1148 wxPG_PROP_ARG_CALL_PROLOG()
1149 p
->SetValidator(validator
);
1153 /** Sets value (long integer) of a property.
1155 void SetPropertyValue( wxPGPropArg id
, long value
)
1158 SetPropVal( id
, v
);
1161 /** Sets value (integer) of a property.
1163 void SetPropertyValue( wxPGPropArg id
, int value
)
1165 wxVariant
v((long)value
);
1166 SetPropVal( id
, v
);
1168 /** Sets value (floating point) of a property.
1170 void SetPropertyValue( wxPGPropArg id
, double value
)
1173 SetPropVal( id
, v
);
1175 /** Sets value (bool) of a property.
1177 void SetPropertyValue( wxPGPropArg id
, bool value
)
1180 SetPropVal( id
, v
);
1182 void SetPropertyValue( wxPGPropArg id
, const wchar_t* value
)
1184 SetPropertyValueString( id
, wxString(value
) );
1186 void SetPropertyValue( wxPGPropArg id
, const char* value
)
1188 SetPropertyValueString( id
, wxString(value
) );
1190 void SetPropertyValue( wxPGPropArg id
, const wxString
& value
)
1192 SetPropertyValueString( id
, value
);
1195 /** Sets value (wxArrayString) of a property.
1197 void SetPropertyValue( wxPGPropArg id
, const wxArrayString
& value
)
1200 SetPropVal( id
, v
);
1204 void SetPropertyValue( wxPGPropArg id
, const wxDateTime
& value
)
1207 SetPropVal( id
, v
);
1211 /** Sets value (wxObject*) of a property.
1213 void SetPropertyValue( wxPGPropArg id
, wxObject
* value
)
1216 SetPropVal( id
, v
);
1219 void SetPropertyValue( wxPGPropArg id
, wxObject
& value
)
1221 wxVariant
v(&value
);
1222 SetPropVal( id
, v
);
1226 /** Sets value (wxLongLong&) of a property.
1228 void SetPropertyValue( wxPGPropArg id
, wxLongLong_t value
)
1230 wxVariant v
= WXVARIANT(wxLongLong(value
));
1231 SetPropVal( id
, v
);
1233 /** Sets value (wxULongLong&) of a property.
1235 void SetPropertyValue( wxPGPropArg id
, wxULongLong_t value
)
1237 wxVariant v
= WXVARIANT(wxULongLong(value
));
1238 SetPropVal( id
, v
);
1242 /** Sets value (wxArrayInt&) of a property.
1244 void SetPropertyValue( wxPGPropArg id
, const wxArrayInt
& value
)
1246 wxVariant v
= WXVARIANT(value
);
1247 SetPropVal( id
, v
);
1250 /** Sets value (wxString) of a property.
1253 This method uses wxPGProperty::SetValueFromString, which all properties
1254 should implement. This means that there should not be a type error,
1255 and instead the string is converted to property's actual value type.
1257 void SetPropertyValueString( wxPGPropArg id
, const wxString
& value
);
1259 /** Sets value (wxVariant&) of a property.
1262 Use wxPropertyGrid::ChangePropertyValue() instead if you need to run
1263 through validation process and send property change event.
1265 void SetPropertyValue( wxPGPropArg id
, wxVariant value
)
1267 SetPropVal( id
, value
);
1270 /** Sets value (wxVariant&) of a property. Same as SetPropertyValue, but
1271 accepts reference. */
1272 void SetPropVal( wxPGPropArg id
, wxVariant
& value
);
1274 /** Adjusts how wxPropertyGrid behaves when invalid value is entered
1277 See @link vfbflags list of valid flags values@endlink
1279 void SetValidationFailureBehavior( int vfbFlags
);
1282 Sorts all properties recursively.
1285 This can contain any of the following options:
1286 wxPG_SORT_TOP_LEVEL_ONLY: Only sort categories and their
1287 immediate children. Sorting done by wxPG_AUTO_SORT option
1290 @see SortChildren, wxPropertyGrid::SetSortFunction
1292 void Sort( int flags
= 0 );
1295 Sorts children of a property.
1298 Name or pointer to a property.
1301 This can contain any of the following options:
1302 wxPG_RECURSE: Sorts recursively.
1304 @see Sort, wxPropertyGrid::SetSortFunction
1306 void SortChildren( wxPGPropArg id
, int flags
= 0 )
1308 wxPG_PROP_ARG_CALL_PROLOG()
1309 m_pState
->DoSortChildren(p
, flags
);
1312 // GetPropertyByName With nice assertion error message.
1313 wxPGProperty
* GetPropertyByNameA( const wxString
& name
) const;
1315 static wxPGEditor
* GetEditorByName( const wxString
& editorName
);
1317 // NOTE: This function reselects the property and may cause
1318 // excess flicker, so to just call Refresh() on a rect
1319 // of single property, call DrawItem() instead.
1320 virtual void RefreshProperty( wxPGProperty
* p
) = 0;
1324 bool DoClearSelection( bool validation
= false,
1328 In derived class, implement to set editable state component with
1329 given name to given value.
1331 virtual bool SetEditableStateItem( const wxString
& name
, wxVariant value
)
1339 In derived class, implement to return editable state component with
1342 virtual wxVariant
GetEditableStateItem( const wxString
& name
) const
1345 return wxNullVariant
;
1348 // Returns page state data for given (sub) page (-1 means current page).
1349 virtual wxPropertyGridPageState
* GetPageState( int pageIndex
) const
1351 if ( pageIndex
<= 0 )
1356 virtual bool DoSelectPage( int WXUNUSED(index
) ) { return true; }
1358 // Default call's m_pState's BaseGetPropertyByName
1359 virtual wxPGProperty
* DoGetPropertyByName( const wxString
& name
) const;
1361 // Deriving classes must set this (it must be only or current page).
1362 wxPropertyGridPageState
* m_pState
;
1364 // Intermediate version needed due to wxVariant copying inefficiency
1365 void DoSetPropertyAttribute( wxPGPropArg id
,
1366 const wxString
& name
,
1367 wxVariant
& value
, long argFlags
);
1369 // Empty string object to return from member functions returning const
1371 wxString m_emptyString
;
1374 // Cannot be GetGrid() due to ambiguity issues.
1375 wxPropertyGrid
* GetPropertyGrid()
1379 return m_pState
->GetGrid();
1382 // Cannot be GetGrid() due to ambiguity issues.
1383 const wxPropertyGrid
* GetPropertyGrid() const
1388 return m_pState
->GetGrid();
1391 friend class wxPropertyGrid
;
1392 friend class wxPropertyGridManager
;
1395 #endif // wxUSE_PROPGRID
1397 #endif // __WX_PROPGRID_PROPGRIDIFACE_H__