1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/propgeid/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__
17 #include "wx/propgrid/property.h"
18 #include "wx/propgrid/propgridpagestate.h"
20 // -----------------------------------------------------------------------
22 /** @section wxPGPropArgCls
24 Most property grid functions have this type as their argument, as it can
25 convey a property by either a pointer or name.
27 class WXDLLIMPEXP_PROPGRID wxPGPropArgCls
31 wxPGPropArgCls( const wxPGProperty
* property
)
33 m_ptr
.property
= (wxPGProperty
*) property
;
36 wxPGPropArgCls( const wxString
& str
)
38 m_ptr
.stringName
= &str
;
41 wxPGPropArgCls( const wxPGPropArgCls
& id
)
46 // This is only needed for wxPython bindings
47 wxPGPropArgCls( wxString
* str
, bool WXUNUSED(deallocPtr
) )
49 m_ptr
.stringName
= str
;
50 m_flags
= IsWxString
| OwnsWxString
;
54 if ( m_flags
& OwnsWxString
)
55 delete m_ptr
.stringName
;
57 wxPGProperty
* GetPtr() const
59 wxCHECK( m_flags
== IsProperty
, NULL
);
60 return m_ptr
.property
;
62 wxPGPropArgCls( const char* str
)
67 wxPGPropArgCls( const wchar_t* str
)
69 m_ptr
.wcharName
= str
;
72 /** This constructor is required for NULL. */
75 m_ptr
.property
= NULL
;
78 wxPGProperty
* GetPtr( wxPropertyGridInterface
* iface
) const;
79 wxPGProperty
* GetPtr( const wxPropertyGridInterface
* iface
) const
81 return GetPtr((wxPropertyGridInterface
*)iface
);
83 wxPGProperty
* GetPtr0() const { return m_ptr
.property
; }
84 bool HasName() const { return (m_flags
!= IsProperty
); }
85 const wxString
& GetName() const { return *m_ptr
.stringName
; }
99 wxPGProperty
* property
;
100 const char* charName
;
101 const wchar_t* wcharName
;
102 const wxString
* stringName
;
104 unsigned char m_flags
;
107 typedef const wxPGPropArgCls
& wxPGPropArg
;
109 // -----------------------------------------------------------------------
112 void wxPGTypeOperationFailed( const wxPGProperty
* p
,
113 const wxString
& typestr
,
114 const wxString
& op
);
116 void wxPGGetFailed( const wxPGProperty
* p
, const wxString
& typestr
);
118 // -----------------------------------------------------------------------
120 // Helper macro that does necessary preparations when calling
121 // some wxPGProperty's member function.
122 #define wxPG_PROP_ARG_CALL_PROLOG_0(PROPERTY) \
123 PROPERTY *p = (PROPERTY*)id.GetPtr(this); \
126 #define wxPG_PROP_ARG_CALL_PROLOG_RETVAL_0(PROPERTY, RETVAL) \
127 PROPERTY *p = (PROPERTY*)id.GetPtr(this); \
128 if ( !p ) return RETVAL;
130 #define wxPG_PROP_ARG_CALL_PROLOG() \
131 wxPG_PROP_ARG_CALL_PROLOG_0(wxPGProperty)
133 #define wxPG_PROP_ARG_CALL_PROLOG_RETVAL(RVAL) \
134 wxPG_PROP_ARG_CALL_PROLOG_RETVAL_0(wxPGProperty, RVAL)
136 #define wxPG_PROP_ID_CONST_CALL_PROLOG() \
137 wxPG_PROP_ARG_CALL_PROLOG_0(const wxPGProperty)
139 #define wxPG_PROP_ID_CONST_CALL_PROLOG_RETVAL(RVAL) \
140 wxPG_PROP_ARG_CALL_PROLOG_RETVAL_0(const wxPGProperty, RVAL)
142 // -----------------------------------------------------------------------
145 /** @class wxPropertyGridInterface
147 Most of the shared property manipulation interface shared by wxPropertyGrid,
148 wxPropertyGridPage, and wxPropertyGridManager is defined in this class.
151 - In separate wxPropertyGrid component this class was known as
152 wxPropertyContainerMethods.
157 class WXDLLIMPEXP_PROPGRID wxPropertyGridInterface
162 virtual ~wxPropertyGridInterface() { }
165 Appends property to the list.
167 wxPropertyGrid assumes ownership of the object.
168 Becomes child of most recently added category.
170 - wxPropertyGrid takes the ownership of the property pointer.
171 - If appending a category with name identical to a category already in
172 the wxPropertyGrid, then newly created category is deleted, and most
173 recently added category (under which properties are appended) is set
174 to the one with same name. This allows easier adding of items to same
175 categories in multiple passes.
176 - Does not automatically redraw the control, so you may need to call
177 Refresh when calling this function after control has been shown for
180 wxPGProperty
* Append( wxPGProperty
* property
);
182 wxPGProperty
* AppendIn( wxPGPropArg id
, wxPGProperty
* newproperty
);
185 In order to add new items into a property with fixed children (for
186 instance, wxFlagsProperty), you need to call this method. After
187 populating has been finished, you need to call EndAddChildren.
189 void BeginAddChildren( wxPGPropArg id
);
191 /** Deletes all properties.
193 virtual void Clear() = 0;
196 Clears current selection, if any.
199 If set to @false, deselecting the property will always work,
200 even if its editor had invalid value in it.
202 @return Returns @true if successful or if there was no selection. May
203 fail if validation was enabled and active editor had invalid
206 @remarks In wxPropertyGrid 1.4, this member function used to send
207 wxPG_EVT_SELECTED. In wxWidgets 2.9 and later, it no longer
210 bool ClearSelection( bool validation
= false );
212 /** Resets modified status of all properties.
214 void ClearModifiedStatus();
216 /** Collapses given category or property with children.
217 Returns true if actually collapses.
219 bool Collapse( wxPGPropArg id
);
221 /** Collapses all items that can be collapsed.
224 Return false if failed (may fail if editor value cannot be validated).
226 bool CollapseAll() { return ExpandAll(false); }
229 Changes value of a property, as if from an editor.
230 Use this instead of SetPropertyValue() if you need the value to run
231 through validation process, and also send the property change event.
234 Returns true if value was successfully changed.
236 bool ChangePropertyValue( wxPGPropArg id
, wxVariant newValue
);
239 Removes and deletes a property and any children.
242 Pointer or name of a property.
244 @remarks If you delete a property in a wxPropertyGrid event
245 handler, the actual deletion is postponed until the next
248 This functions deselects selected property, if any.
249 Validation failure option wxPG_VFB_STAY_IN_PROPERTY is not
250 respected, ie. selection is cleared even if editor had
253 void DeleteProperty( wxPGPropArg id
);
256 Removes a property. Does not delete the property object, but
260 Pointer or name of a property.
262 @remarks Removed property cannot have any children.
264 Also, if you remove property in a wxPropertyGrid event
265 handler, the actual removal is postponed until the next
268 wxPGProperty
* RemoveProperty( wxPGPropArg id
);
273 @see EnableProperty(), wxPGProperty::Enable()
275 bool DisableProperty( wxPGPropArg id
) { return EnableProperty(id
,false); }
278 Returns true if all property grid data changes have been committed.
280 Usually only returns false if value in active editor has been
281 invalidated by a wxValidator.
283 bool EditorValidate();
286 Enables or disables property, depending on whether enable is true or
287 false. Disabled property usually appears as having grey text.
290 Name or pointer to a property.
292 If @false, property is disabled instead.
294 @see wxPGProperty::Enable()
296 bool EnableProperty( wxPGPropArg id
, bool enable
= true );
298 /** Called after population of property with fixed children has finished.
300 void EndAddChildren( wxPGPropArg id
);
302 /** Expands given category or property with children.
303 Returns true if actually expands.
305 bool Expand( wxPGPropArg id
);
307 /** Expands all items that can be expanded.
309 bool ExpandAll( bool expand
= true );
311 /** Returns id of first child of given property.
313 Does not return sub-properties!
315 wxPGProperty
* GetFirstChild( wxPGPropArg id
)
317 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(wxNullProperty
)
319 if ( !p
->GetChildCount() || p
->HasFlag(wxPG_PROP_AGGREGATE
) )
320 return wxNullProperty
;
326 /** Returns iterator class instance.
328 See @ref propgrid_iterator_flags. Value wxPG_ITERATE_DEFAULT causes
329 iteration over everything except private child properties.
331 Property to start iteration from. If NULL, then first child of root
334 Either wxTOP or wxBOTTOM. wxTOP will indicate that iterations start
335 from the first property from the top, and wxBOTTOM means that the
336 iteration will instead begin from bottommost valid item.
338 wxPropertyGridIterator
GetIterator( int flags
= wxPG_ITERATE_DEFAULT
,
339 wxPGProperty
* firstProp
= NULL
)
341 return wxPropertyGridIterator( m_pState
, flags
, firstProp
);
344 wxPropertyGridConstIterator
345 GetIterator( int flags
= wxPG_ITERATE_DEFAULT
,
346 wxPGProperty
* firstProp
= NULL
) const
348 return wxPropertyGridConstIterator( m_pState
, flags
, firstProp
);
351 wxPropertyGridIterator
GetIterator( int flags
, int startPos
)
353 return wxPropertyGridIterator( m_pState
, flags
, startPos
);
356 wxPropertyGridConstIterator
GetIterator( int flags
, int startPos
) const
358 return wxPropertyGridConstIterator( m_pState
, flags
, startPos
);
362 /** Returns id of first item, whether it is a category or property.
364 @link iteratorflags List of iterator flags@endlink
366 wxPGProperty
* GetFirst( int flags
= wxPG_ITERATE_ALL
)
368 wxPropertyGridIterator
it( m_pState
, flags
, wxNullProperty
, 1 );
372 const wxPGProperty
* GetFirst( int flags
= wxPG_ITERATE_ALL
) const
374 return ((wxPropertyGridInterface
*)this)->GetFirst(flags
);
378 Returns pointer to a property with given name (case-sensitive).
379 If there is no property with such name, @NULL pointer is returned.
381 @remarks Properties which have non-category, non-root parent
382 can not be accessed globally by their name. Instead, use
383 "<property>.<subproperty>" instead of "<subproperty>".
385 wxPGProperty
* GetProperty( const wxString
& name
) const
387 return GetPropertyByName(name
);
390 /** Returns map-like storage of property's attributes.
392 Note that if extra style wxPG_EX_WRITEONLY_BUILTIN_ATTRIBUTES is set,
393 then builtin-attributes are not included in the storage.
395 const wxPGAttributeStorage
& GetPropertyAttributes( wxPGPropArg id
) const
397 // If 'id' refers to invalid property, then we will return dummy
398 // attributes (ie. root property's attributes, which contents should
399 // should always be empty and of no consequence).
400 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(m_pState
->DoGetRoot()->GetAttributes());
401 return p
->GetAttributes();
404 /** Adds to 'targetArr' pointers to properties that have given
405 flags 'flags' set. However, if 'inverse' is set to true, then
406 only properties without given flags are stored.
408 Property flags to use.
410 Iterator flags to use. Default is everything expect private children.
412 void GetPropertiesWithFlag( wxArrayPGProperty
* targetArr
,
413 wxPGProperty::FlagType flags
,
414 bool inverse
= false,
415 int iterFlags
= wxPG_ITERATE_PROPERTIES
|
416 wxPG_ITERATE_HIDDEN
|
417 wxPG_ITERATE_CATEGORIES
) const;
419 /** Returns value of given attribute. If none found, returns NULL-variant.
421 wxVariant
GetPropertyAttribute( wxPGPropArg id
,
422 const wxString
& attrName
) const
424 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(wxNullVariant
)
425 return p
->GetAttribute(attrName
);
428 /** Returns pointer of property's nearest parent category. If no category
431 wxPropertyCategory
* GetPropertyCategory( wxPGPropArg id
) const
433 wxPG_PROP_ID_CONST_CALL_PROLOG_RETVAL(NULL
)
434 return m_pState
->GetPropertyCategory(p
);
437 /** Returns client data (void*) of a property. */
438 void* GetPropertyClientData( wxPGPropArg id
) const
440 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(NULL
)
441 return p
->GetClientData();
445 Returns first property which label matches given string.
447 NULL if none found. Note that this operation is extremely slow when
448 compared to GetPropertyByName().
450 wxPGProperty
* GetPropertyByLabel( const wxString
& label
) const;
452 /** Returns property with given name. NULL if none found.
454 wxPGProperty
* GetPropertyByName( const wxString
& name
) const;
456 /** Returns child property 'subname' of property 'name'. Same as
457 calling GetPropertyByName("name.subname"), albeit slightly faster.
459 wxPGProperty
* GetPropertyByName( const wxString
& name
,
460 const wxString
& subname
) const;
462 /** Returns property's editor. */
463 const wxPGEditor
* GetPropertyEditor( wxPGPropArg id
) const
465 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(NULL
)
466 return p
->GetEditorClass();
469 /** Returns help string associated with a property. */
470 wxString
GetPropertyHelpString( wxPGPropArg id
) const
472 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(m_emptyString
)
473 return p
->GetHelpString();
476 /** Returns property's custom value image (NULL of none). */
477 wxBitmap
* GetPropertyImage( wxPGPropArg id
) const
479 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(NULL
)
480 return p
->GetValueImage();
483 /** Returns label of a property. */
484 const wxString
& GetPropertyLabel( wxPGPropArg id
)
486 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(m_emptyString
)
487 return p
->GetLabel();
490 /** Returns name of a property, by which it is globally accessible. */
491 wxString
GetPropertyName( wxPGProperty
* property
)
493 return property
->GetName();
496 /** Returns parent item of a property. */
497 wxPGProperty
* GetPropertyParent( wxPGPropArg id
)
499 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(wxNullProperty
)
500 return p
->GetParent();
504 /** Returns validator of a property as a reference, which you
505 can pass to any number of SetPropertyValidator.
507 wxValidator
* GetPropertyValidator( wxPGPropArg id
)
509 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(NULL
)
510 return p
->GetValidator();
514 /** Returns value as wxVariant. To get wxObject pointer from it,
515 you will have to use WX_PG_VARIANT_TO_WXOBJECT(VARIANT,CLASSNAME) macro.
517 If property value is unspecified, Null variant is returned.
519 wxVariant
GetPropertyValue( wxPGPropArg id
)
521 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(wxVariant())
522 return p
->GetValue();
525 wxString
GetPropertyValueAsString( wxPGPropArg id
) const;
526 long GetPropertyValueAsLong( wxPGPropArg id
) const;
527 unsigned long GetPropertyValueAsULong( wxPGPropArg id
) const
529 return (unsigned long) GetPropertyValueAsLong(id
);
531 int GetPropertyValueAsInt( wxPGPropArg id
) const
532 { return (int)GetPropertyValueAsLong(id
); }
533 bool GetPropertyValueAsBool( wxPGPropArg id
) const;
534 double GetPropertyValueAsDouble( wxPGPropArg id
) const;
536 #define wxPG_PROP_ID_GETPROPVAL_CALL_PROLOG_RETVAL(TYPENAME, DEFVAL) \
537 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(DEFVAL) \
538 wxString typeName(wxS(TYPENAME)); \
539 wxVariant value = p->GetValue(); \
540 if ( value.GetType() != typeName ) \
542 wxPGGetFailed(p, typeName); \
546 #define wxPG_PROP_ID_GETPROPVAL_CALL_PROLOG_RETVAL_WFALLBACK(TYPENAME, DEFVAL) \
547 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(DEFVAL) \
548 wxVariant value = p->GetValue(); \
549 if ( value.GetType() != wxS(TYPENAME) ) \
552 wxArrayString GetPropertyValueAsArrayString( wxPGPropArg id ) const
554 wxPG_PROP_ID_GETPROPVAL_CALL_PROLOG_RETVAL("arrstring",
556 return value
.GetArrayString();
560 wxLongLong_t
GetPropertyValueAsLongLong( wxPGPropArg id
) const
562 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(0)
563 return p
->GetValue().GetLongLong().GetValue();
566 wxULongLong_t
GetPropertyValueAsULongLong( wxPGPropArg id
) const
568 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(0)
569 return p
->GetValue().GetULongLong().GetValue();
573 wxArrayInt
GetPropertyValueAsArrayInt( wxPGPropArg id
) const
575 wxPG_PROP_ID_GETPROPVAL_CALL_PROLOG_RETVAL("wxArrayInt",
583 wxDateTime
GetPropertyValueAsDateTime( wxPGPropArg id
) const
585 wxPG_PROP_ID_GETPROPVAL_CALL_PROLOG_RETVAL("datetime",
587 return value
.GetDateTime();
591 /** Returns a wxVariant list containing wxVariant versions of all
592 property values. Order is not guaranteed.
594 Use wxPG_KEEP_STRUCTURE to retain category structure; each sub
595 category will be its own wxVariantList of wxVariant.
596 Use wxPG_INC_ATTRIBUTES to include property attributes as well.
597 Each attribute will be stored as list variant named
598 "@@<propname>@@attr."
601 wxVariant
GetPropertyValues( const wxString
& listname
= wxEmptyString
,
602 wxPGProperty
* baseparent
= NULL
, long flags
= 0 ) const
604 return m_pState
->DoGetPropertyValues(listname
, baseparent
, flags
);
608 Returns currently selected property. NULL if none.
610 @remarks When wxPG_EX_MULTIPLE_SELECTION extra style is used, this
611 member function returns the focused property, that is the
612 one which can have active editor.
614 wxPGProperty
* GetSelection() const;
617 Returns list of currently selected properties.
619 @remarks wxArrayPGProperty should be compatible with std::vector API.
621 const wxArrayPGProperty
& GetSelectedProperties() const
623 return m_pState
->m_selection
;
626 wxPropertyGridPageState
* GetState() const { return m_pState
; }
628 /** Similar to GetIterator(), but instead returns wxPGVIterator instance,
629 which can be useful for forward-iterating through arbitrary property
633 See @ref propgrid_iterator_flags.
635 virtual wxPGVIterator
GetVIterator( int flags
) const;
637 /** Hides or reveals a property.
639 If true, hides property, otherwise reveals it.
641 By default changes are applied recursively. Set this paramter
642 wxPG_DONT_RECURSE to prevent this.
644 bool HideProperty( wxPGPropArg id
,
646 int flags
= wxPG_RECURSE
);
648 #if wxPG_INCLUDE_ADVPROPS
649 /** Initializes *all* property types. Causes references to most object
650 files in the library, so calling this may cause significant increase
651 in executable size when linking with static library.
653 static void InitAllTypeHandlers();
655 static void InitAllTypeHandlers() { }
659 /** Inserts property to the property container.
662 New property is inserted just prior to this. Available only
663 in the first variant. There are two versions of this function
664 to allow this parameter to be either an id or name to
668 Pointer to the inserted property. wxPropertyGrid will take
669 ownership of this object.
672 New property is inserted under this category. Available only
673 in the second variant. There are two versions of this function
674 to allow this parameter to be either an id or name to
678 Index under category. Available only in the second variant.
679 If index is < 0, property is appended in category.
682 Returns id for the property,
686 - wxPropertyGrid takes the ownership of the property pointer.
688 - While Append may be faster way to add items, make note that when
689 both types of data storage (categoric and
690 non-categoric) are active, Insert becomes even more slow. This is
691 especially true if current mode is non-categoric.
698 wxPGProperty* my_cat_id = propertygrid->Append(
699 new wxPropertyCategory("My Category") );
703 // insert into category - using second variant
704 wxPGProperty* my_item_id_1 = propertygrid->Insert(
705 my_cat_id, 0, new wxStringProperty("My String 1") );
707 // insert before to first item - using first variant
708 wxPGProperty* my_item_id_2 = propertygrid->Insert(
709 my_item_id, new wxStringProperty("My String 2") );
714 wxPGProperty
* Insert( wxPGPropArg priorThis
, wxPGProperty
* newproperty
);
715 wxPGProperty
* Insert( wxPGPropArg parent
,
717 wxPGProperty
* newproperty
);
720 /** Returns true if property is a category. */
721 bool IsPropertyCategory( wxPGPropArg id
) const
723 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(false)
724 return p
->IsCategory();
727 /** Returns true if property is enabled. */
728 bool IsPropertyEnabled( wxPGPropArg id
) const
730 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(false)
731 return (!(p
->GetFlags() & wxPG_PROP_DISABLED
))?true:false;
735 Returns true if given property is expanded.
737 Naturally, always returns false for properties that cannot be expanded.
739 bool IsPropertyExpanded( wxPGPropArg id
) const;
742 Returns true if property has been modified after value set or modify
743 flag clear by software.
745 bool IsPropertyModified( wxPGPropArg id
) const
747 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(false)
748 return ( (p
->GetFlags() & wxPG_PROP_MODIFIED
) ? true : false );
752 Returns true if property is selected.
754 bool IsPropertySelected( wxPGPropArg id
) const
756 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(false)
757 return m_pState
->DoIsPropertySelected(p
);
761 Returns true if property is shown (ie hideproperty with true not
764 bool IsPropertyShown( wxPGPropArg id
) const
766 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(false)
767 return (!(p
->GetFlags() & wxPG_PROP_HIDDEN
))?true:false;
770 /** Returns true if property value is set to unspecified.
772 bool IsPropertyValueUnspecified( wxPGPropArg id
) const
774 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(false)
775 return p
->IsValueUnspecified();
779 Disables (limit = true) or enables (limit = false) wxTextCtrl editor of
780 a property, if it is not the sole mean to edit the value.
782 void LimitPropertyEditing( wxPGPropArg id
, bool limit
= true );
784 /** If state is shown in it's grid, refresh it now.
786 virtual void RefreshGrid( wxPropertyGridPageState
* state
= NULL
);
788 #if wxPG_INCLUDE_ADVPROPS
790 Initializes additional property editors (SpinCtrl etc.). Causes
791 references to most object files in the library, so calling this may
792 cause significant increase in executable size when linking with static
795 static void RegisterAdditionalEditors();
797 static void RegisterAdditionalEditors() { }
800 /** Replaces property with id with newly created property. For example,
801 this code replaces existing property named "Flags" with one that
802 will have different set of items:
804 pg->ReplaceProperty("Flags",
805 wxFlagsProperty("Flags", wxPG_LABEL, newItems))
807 For more info, see wxPropertyGrid::Insert.
809 wxPGProperty
* ReplaceProperty( wxPGPropArg id
, wxPGProperty
* property
);
811 /** @anchor propgridinterface_editablestate_flags
813 Flags for wxPropertyGridInterface::SaveEditableState() and
814 wxPropertyGridInterface::RestoreEditableState().
816 enum EditableStateFlags
818 /** Include selected property. */
819 SelectionState
= 0x01,
820 /** Include expanded/collapsed property information. */
821 ExpandedState
= 0x02,
822 /** Include scrolled position. */
823 ScrollPosState
= 0x04,
824 /** Include selected page information.
825 Only applies to wxPropertyGridManager. */
827 /** Include splitter position. Stored for each page. */
828 SplitterPosState
= 0x10,
829 /** Include description box size.
830 Only applies to wxPropertyGridManager. */
834 Include all supported user editable state information.
835 This is usually the default value. */
836 AllStates
= SelectionState
|
845 Restores user-editable state.
847 See also wxPropertyGridInterface::SaveEditableState().
850 String generated by SaveEditableState.
853 Which parts to restore from source string. See @ref
854 propgridinterface_editablestate_flags "list of editable state
858 False if there was problem reading the string.
861 If some parts of state (such as scrolled or splitter position) fail to
862 restore correctly, please make sure that you call this function after
863 wxPropertyGrid size has been set (this may sometimes be tricky when
866 bool RestoreEditableState( const wxString
& src
,
867 int restoreStates
= AllStates
);
870 Used to acquire user-editable state (selected property, expanded
871 properties, scrolled position, splitter positions).
873 @param includedStates
874 Which parts of state to include. See @ref
875 propgridinterface_editablestate_flags "list of editable state flags".
877 wxString
SaveEditableState( int includedStates
= AllStates
) const;
880 Lets user to set the strings listed in the choice dropdown of a
881 wxBoolProperty. Defaults are "True" and "False", so changing them to,
882 say, "Yes" and "No" may be useful in some less technical applications.
884 static void SetBoolChoices( const wxString
& trueChoice
,
885 const wxString
& falseChoice
);
888 Set proportion of a auto-stretchable column. wxPG_SPLITTER_AUTO_CENTER
889 window style needs to be used to indicate that columns are auto-
892 @returns Returns @false on failure.
894 @remarks You should call this for individual pages of
895 wxPropertyGridManager (if used).
897 @see GetColumnProportion()
899 bool SetColumnProportion( unsigned int column
, int proportion
);
902 Returns auto-resize proportion of the given column.
904 @see SetColumnProportion()
906 int GetColumnProportion( unsigned int column
) const
908 return m_pState
->DoGetColumnProportion(column
);
911 /** Sets an attribute for this property.
913 Text identifier of attribute. See @ref propgrid_property_attributes.
917 Optional. Use wxPG_RECURSE to set the attribute to child properties
920 void SetPropertyAttribute( wxPGPropArg id
,
921 const wxString
& attrName
,
925 DoSetPropertyAttribute(id
,attrName
,value
,argFlags
);
928 /** Sets property attribute for all applicapple properties.
929 Be sure to use this method only after all properties have been
932 void SetPropertyAttributeAll( const wxString
& attrName
, wxVariant value
);
935 Sets background colour of a property.
938 Property name or pointer.
941 New background colour.
944 Default is wxPG_RECURSE which causes colour to be set recursively.
945 Omit this flag to only set colour for the property in question
946 and not any of its children.
948 void SetPropertyBackgroundColour( wxPGPropArg id
,
949 const wxColour
& colour
,
950 int flags
= wxPG_RECURSE
);
952 /** Resets text and background colours of given property.
954 void SetPropertyColoursToDefault( wxPGPropArg id
);
957 Sets text colour of a property.
960 Property name or pointer.
963 New background colour.
966 Default is wxPG_RECURSE which causes colour to be set recursively.
967 Omit this flag to only set colour for the property in question
968 and not any of its children.
970 void SetPropertyTextColour( wxPGPropArg id
,
972 int flags
= wxPG_RECURSE
);
975 Returns background colour of first cell of a property.
977 wxColour
GetPropertyBackgroundColour( wxPGPropArg id
) const
979 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(wxColour())
980 return p
->GetCell(0).GetBgCol();
984 Returns text colour of first cell of a property.
986 wxColour
GetPropertyTextColour( wxPGPropArg id
) const
988 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(wxColour())
989 return p
->GetCell(0).GetFgCol();
992 /** Sets text, bitmap, and colours for given column's cell.
995 - You can set label cell by setting column to 0.
996 - You can use wxPG_LABEL as text to use default text for column.
998 void SetPropertyCell( wxPGPropArg id
,
1000 const wxString
& text
= wxEmptyString
,
1001 const wxBitmap
& bitmap
= wxNullBitmap
,
1002 const wxColour
& fgCol
= wxNullColour
,
1003 const wxColour
& bgCol
= wxNullColour
);
1005 /** Sets client data (void*) of a property.
1007 This untyped client data has to be deleted manually.
1009 void SetPropertyClientData( wxPGPropArg id
, void* clientData
)
1011 wxPG_PROP_ARG_CALL_PROLOG()
1012 p
->SetClientData(clientData
);
1015 /** Sets editor for a property.
1018 For builtin editors, use wxPGEditor_X, where X is builtin editor's
1019 name (TextCtrl, Choice, etc. see wxPGEditor documentation for full
1022 For custom editors, use pointer you received from
1023 wxPropertyGrid::RegisterEditorClass().
1025 void SetPropertyEditor( wxPGPropArg id
, const wxPGEditor
* editor
)
1027 wxPG_PROP_ARG_CALL_PROLOG()
1028 wxCHECK_RET( editor
, wxT("unknown/NULL editor") );
1029 p
->SetEditor(editor
);
1033 /** Sets editor control of a property. As editor argument, use
1034 editor name string, such as "TextCtrl" or "Choice".
1036 void SetPropertyEditor( wxPGPropArg id
, const wxString
& editorName
)
1038 SetPropertyEditor(id
,GetEditorByName(editorName
));
1041 /** Sets label of a property.
1043 void SetPropertyLabel( wxPGPropArg id
, const wxString
& newproplabel
);
1046 Sets name of a property.
1049 Name or pointer of property which name to change.
1052 New name for property.
1054 void SetPropertyName( wxPGPropArg id
, const wxString
& newName
)
1056 wxPG_PROP_ARG_CALL_PROLOG()
1057 m_pState
->DoSetPropertyName( p
, newName
);
1061 Sets property (and, recursively, its children) to have read-only value.
1062 In other words, user cannot change the value in the editor, but they
1065 This is mainly for use with textctrl editor. Not all other editors fully
1068 By default changes are applied recursively. Set this paramter
1069 wxPG_DONT_RECURSE to prevent this.
1071 void SetPropertyReadOnly( wxPGPropArg id
,
1073 int flags
= wxPG_RECURSE
)
1075 wxPG_PROP_ARG_CALL_PROLOG()
1076 if ( flags
& wxPG_RECURSE
)
1077 p
->SetFlagRecursively(wxPG_PROP_READONLY
, set
);
1079 p
->ChangeFlag(wxPG_PROP_READONLY
, set
);
1082 /** Sets property's value to unspecified.
1083 If it has children (it may be category), then the same thing is done to
1086 void SetPropertyValueUnspecified( wxPGPropArg id
)
1088 wxPG_PROP_ARG_CALL_PROLOG()
1089 p
->SetValueToUnspecified();
1093 Sets property values from a list of wxVariants.
1095 void SetPropertyValues( const wxVariantList
& list
,
1096 wxPGPropArg defaultCategory
= wxNullProperty
)
1099 if ( defaultCategory
.HasName() ) p
= defaultCategory
.GetPtr(this);
1100 else p
= defaultCategory
.GetPtr0();
1101 m_pState
->DoSetPropertyValues(list
, p
);
1105 Sets property values from a list of wxVariants.
1107 void SetPropertyValues( const wxVariant
& list
,
1108 wxPGPropArg defaultCategory
= wxNullProperty
)
1110 SetPropertyValues(list
.GetList(),defaultCategory
);
1113 /** Associates the help string with property.
1115 By default, text is shown either in the manager's "description"
1116 text box or in the status bar. If extra window style
1117 wxPG_EX_HELP_AS_TOOLTIPS is used, then the text will appear as a
1120 void SetPropertyHelpString( wxPGPropArg id
, const wxString
& helpString
)
1122 wxPG_PROP_ARG_CALL_PROLOG()
1123 p
->SetHelpString(helpString
);
1126 /** Set wxBitmap in front of the value.
1128 - Bitmap will be scaled to a size returned by
1129 wxPropertyGrid::GetImageSize();
1131 void SetPropertyImage( wxPGPropArg id
, wxBitmap
& bmp
)
1133 wxPG_PROP_ARG_CALL_PROLOG()
1134 p
->SetValueImage(bmp
);
1138 /** Sets max length of property's text.
1140 bool SetPropertyMaxLength( wxPGPropArg id
, int maxLen
);
1142 #if wxUSE_VALIDATORS
1143 /** Sets validator of a property.
1145 void SetPropertyValidator( wxPGPropArg id
, const wxValidator
& validator
)
1147 wxPG_PROP_ARG_CALL_PROLOG()
1148 p
->SetValidator(validator
);
1152 /** Sets value (long integer) of a property.
1154 void SetPropertyValue( wxPGPropArg id
, long value
)
1157 SetPropVal( id
, v
);
1160 /** Sets value (integer) of a property.
1162 void SetPropertyValue( wxPGPropArg id
, int value
)
1164 wxVariant
v((long)value
);
1165 SetPropVal( id
, v
);
1167 /** Sets value (floating point) of a property.
1169 void SetPropertyValue( wxPGPropArg id
, double value
)
1172 SetPropVal( id
, v
);
1174 /** Sets value (bool) of a property.
1176 void SetPropertyValue( wxPGPropArg id
, bool value
)
1179 SetPropVal( id
, v
);
1181 void SetPropertyValue( wxPGPropArg id
, const wchar_t* value
)
1183 SetPropertyValueString( id
, wxString(value
) );
1185 void SetPropertyValue( wxPGPropArg id
, const char* value
)
1187 SetPropertyValueString( id
, wxString(value
) );
1189 void SetPropertyValue( wxPGPropArg id
, const wxString
& value
)
1191 SetPropertyValueString( id
, value
);
1194 /** Sets value (wxArrayString) of a property.
1196 void SetPropertyValue( wxPGPropArg id
, const wxArrayString
& value
)
1199 SetPropVal( id
, v
);
1203 void SetPropertyValue( wxPGPropArg id
, const wxDateTime
& value
)
1206 SetPropVal( id
, v
);
1210 /** Sets value (wxObject*) of a property.
1212 void SetPropertyValue( wxPGPropArg id
, wxObject
* value
)
1215 SetPropVal( id
, v
);
1218 void SetPropertyValue( wxPGPropArg id
, wxObject
& value
)
1220 wxVariant
v(&value
);
1221 SetPropVal( id
, v
);
1225 /** Sets value (wxLongLong&) of a property.
1227 void SetPropertyValue( wxPGPropArg id
, wxLongLong_t value
)
1229 wxVariant v
= WXVARIANT(wxLongLong(value
));
1230 SetPropVal( id
, v
);
1232 /** Sets value (wxULongLong&) of a property.
1234 void SetPropertyValue( wxPGPropArg id
, wxULongLong_t value
)
1236 wxVariant v
= WXVARIANT(wxULongLong(value
));
1237 SetPropVal( id
, v
);
1241 /** Sets value (wxArrayInt&) of a property.
1243 void SetPropertyValue( wxPGPropArg id
, const wxArrayInt
& value
)
1245 wxVariant v
= WXVARIANT(value
);
1246 SetPropVal( id
, v
);
1249 /** Sets value (wxString) of a property.
1252 This method uses wxPGProperty::SetValueFromString, which all properties
1253 should implement. This means that there should not be a type error,
1254 and instead the string is converted to property's actual value type.
1256 void SetPropertyValueString( wxPGPropArg id
, const wxString
& value
);
1258 /** Sets value (wxVariant&) of a property.
1261 Use wxPropertyGrid::ChangePropertyValue() instead if you need to run
1262 through validation process and send property change event.
1264 void SetPropertyValue( wxPGPropArg id
, wxVariant value
)
1266 SetPropVal( id
, value
);
1269 /** Sets value (wxVariant&) of a property. Same as SetPropertyValue, but
1270 accepts reference. */
1271 void SetPropVal( wxPGPropArg id
, wxVariant
& value
);
1273 /** Adjusts how wxPropertyGrid behaves when invalid value is entered
1276 See @link vfbflags list of valid flags values@endlink
1278 void SetValidationFailureBehavior( int vfbFlags
);
1281 Sorts all properties recursively.
1284 This can contain any of the following options:
1285 wxPG_SORT_TOP_LEVEL_ONLY: Only sort categories and their
1286 immediate children. Sorting done by wxPG_AUTO_SORT option
1289 @see SortChildren, wxPropertyGrid::SetSortFunction
1291 void Sort( int flags
= 0 );
1294 Sorts children of a property.
1297 Name or pointer to a property.
1300 This can contain any of the following options:
1301 wxPG_RECURSE: Sorts recursively.
1303 @see Sort, wxPropertyGrid::SetSortFunction
1305 void SortChildren( wxPGPropArg id
, int flags
= 0 )
1307 wxPG_PROP_ARG_CALL_PROLOG()
1308 m_pState
->DoSortChildren(p
, flags
);
1311 // GetPropertyByName With nice assertion error message.
1312 wxPGProperty
* GetPropertyByNameA( const wxString
& name
) const;
1314 static wxPGEditor
* GetEditorByName( const wxString
& editorName
);
1316 // NOTE: This function reselects the property and may cause
1317 // excess flicker, so to just call Refresh() on a rect
1318 // of single property, call DrawItem() instead.
1319 virtual void RefreshProperty( wxPGProperty
* p
) = 0;
1323 bool DoClearSelection( bool validation
= false,
1327 In derived class, implement to set editable state component with
1328 given name to given value.
1330 virtual bool SetEditableStateItem( const wxString
& name
, wxVariant value
)
1338 In derived class, implement to return editable state component with
1341 virtual wxVariant
GetEditableStateItem( const wxString
& name
) const
1344 return wxNullVariant
;
1347 // Returns page state data for given (sub) page (-1 means current page).
1348 virtual wxPropertyGridPageState
* GetPageState( int pageIndex
) const
1350 if ( pageIndex
<= 0 )
1355 virtual bool DoSelectPage( int WXUNUSED(index
) ) { return true; }
1357 // Default call's m_pState's BaseGetPropertyByName
1358 virtual wxPGProperty
* DoGetPropertyByName( const wxString
& name
) const;
1360 // Deriving classes must set this (it must be only or current page).
1361 wxPropertyGridPageState
* m_pState
;
1363 // Intermediate version needed due to wxVariant copying inefficiency
1364 void DoSetPropertyAttribute( wxPGPropArg id
,
1365 const wxString
& name
,
1366 wxVariant
& value
, long argFlags
);
1368 // Empty string object to return from member functions returning const
1370 wxString m_emptyString
;
1373 // Cannot be GetGrid() due to ambiguity issues.
1374 wxPropertyGrid
* GetPropertyGrid()
1378 return m_pState
->GetGrid();
1381 // Cannot be GetGrid() due to ambiguity issues.
1382 const wxPropertyGrid
* GetPropertyGrid() const
1386 return static_cast<const wxPropertyGrid
*>(m_pState
->GetGrid());
1389 friend class wxPropertyGrid
;
1390 friend class wxPropertyGridManager
;
1393 #endif // wxUSE_PROPGRID
1395 #endif // __WX_PROPGRID_PROPGRIDIFACE_H__