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__
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
33 wxPGPropArgCls( const wxPGProperty
* property
)
35 m_ptr
.property
= (wxPGProperty
*) property
;
38 wxPGPropArgCls( const wxString
& str
)
40 m_ptr
.stringName
= &str
;
43 wxPGPropArgCls( const wxPGPropArgCls
& id
)
48 // This is only needed for wxPython bindings
49 wxPGPropArgCls( wxString
* str
, bool WXUNUSED(deallocPtr
) )
51 m_ptr
.stringName
= str
;
52 m_flags
= IsWxString
| OwnsWxString
;
56 if ( m_flags
& OwnsWxString
)
57 delete m_ptr
.stringName
;
59 wxPGProperty
* GetPtr() const
61 wxCHECK( m_flags
== IsProperty
, NULL
);
62 return m_ptr
.property
;
64 wxPGPropArgCls( const char* str
)
69 wxPGPropArgCls( const wchar_t* str
)
71 m_ptr
.wcharName
= str
;
74 /** This constructor is required for NULL. */
77 m_ptr
.property
= NULL
;
80 wxPGProperty
* GetPtr( wxPropertyGridInterface
* iface
) const;
81 wxPGProperty
* GetPtr( const wxPropertyGridInterface
* iface
) const
83 return GetPtr((wxPropertyGridInterface
*)iface
);
85 wxPGProperty
* GetPtr0() const { return m_ptr
.property
; }
86 bool HasName() const { return (m_flags
!= IsProperty
); }
87 const wxString
& GetName() const { return *m_ptr
.stringName
; }
101 wxPGProperty
* property
;
102 const char* charName
;
103 const wchar_t* wcharName
;
104 const wxString
* stringName
;
106 unsigned char m_flags
;
109 typedef const wxPGPropArgCls
& wxPGPropArg
;
111 // -----------------------------------------------------------------------
114 void wxPGTypeOperationFailed( const wxPGProperty
* p
,
115 const wxString
& typestr
,
116 const wxString
& op
);
118 void wxPGGetFailed( const wxPGProperty
* p
, const wxString
& typestr
);
120 // -----------------------------------------------------------------------
122 // Helper macro that does necessary preparations when calling
123 // some wxPGProperty's member function.
124 #define wxPG_PROP_ARG_CALL_PROLOG_0(PROPERTY) \
125 PROPERTY *p = (PROPERTY*)id.GetPtr(this); \
128 #define wxPG_PROP_ARG_CALL_PROLOG_RETVAL_0(PROPERTY, RETVAL) \
129 PROPERTY *p = (PROPERTY*)id.GetPtr(this); \
130 if ( !p ) return RETVAL;
132 #define wxPG_PROP_ARG_CALL_PROLOG() \
133 wxPG_PROP_ARG_CALL_PROLOG_0(wxPGProperty)
135 #define wxPG_PROP_ARG_CALL_PROLOG_RETVAL(RVAL) \
136 wxPG_PROP_ARG_CALL_PROLOG_RETVAL_0(wxPGProperty, RVAL)
138 #define wxPG_PROP_ID_CONST_CALL_PROLOG() \
139 wxPG_PROP_ARG_CALL_PROLOG_0(const wxPGProperty)
141 #define wxPG_PROP_ID_CONST_CALL_PROLOG_RETVAL(RVAL) \
142 wxPG_PROP_ARG_CALL_PROLOG_RETVAL_0(const wxPGProperty, RVAL)
144 // -----------------------------------------------------------------------
147 /** @class wxPropertyGridInterface
149 Most of the shared property manipulation interface shared by wxPropertyGrid,
150 wxPropertyGridPage, and wxPropertyGridManager is defined in this class.
153 - In separate wxPropertyGrid component this class was known as
154 wxPropertyContainerMethods.
159 class WXDLLIMPEXP_PROPGRID wxPropertyGridInterface
164 virtual ~wxPropertyGridInterface() { }
167 Appends property to the list.
169 wxPropertyGrid assumes ownership of the object.
170 Becomes child of most recently added category.
172 - wxPropertyGrid takes the ownership of the property pointer.
173 - If appending a category with name identical to a category already in
174 the wxPropertyGrid, then newly created category is deleted, and most
175 recently added category (under which properties are appended) is set
176 to the one with same name. This allows easier adding of items to same
177 categories in multiple passes.
178 - Does not automatically redraw the control, so you may need to call
179 Refresh when calling this function after control has been shown for
182 wxPGProperty
* Append( wxPGProperty
* property
);
184 wxPGProperty
* AppendIn( wxPGPropArg id
, wxPGProperty
* newproperty
);
187 In order to add new items into a property with fixed children (for
188 instance, wxFlagsProperty), you need to call this method. After
189 populating has been finished, you need to call EndAddChildren.
191 void BeginAddChildren( wxPGPropArg id
);
193 /** Deletes all properties.
195 virtual void Clear() = 0;
198 Clears current selection, if any.
201 If set to @false, deselecting the property will always work,
202 even if its editor had invalid value in it.
204 @return Returns @true if successful or if there was no selection. May
205 fail if validation was enabled and active editor had invalid
208 @remarks In wxPropertyGrid 1.4, this member function used to send
209 wxPG_EVT_SELECTED. In wxWidgets 2.9 and later, it no longer
212 bool ClearSelection( bool validation
= false );
214 /** Resets modified status of all properties.
216 void ClearModifiedStatus();
218 /** Collapses given category or property with children.
219 Returns true if actually collapses.
221 bool Collapse( wxPGPropArg id
);
223 /** Collapses all items that can be collapsed.
226 Return false if failed (may fail if editor value cannot be validated).
228 bool CollapseAll() { return ExpandAll(false); }
231 Changes value of a property, as if from an editor.
232 Use this instead of SetPropertyValue() if you need the value to run
233 through validation process, and also send the property change event.
236 Returns true if value was successfully changed.
238 bool ChangePropertyValue( wxPGPropArg id
, wxVariant newValue
);
241 Removes and deletes a property and any children.
244 Pointer or name of a property.
246 @remarks If you delete a property in a wxPropertyGrid event
247 handler, the actual deletion is postponed until the next
250 This functions deselects selected property, if any.
251 Validation failure option wxPG_VFB_STAY_IN_PROPERTY is not
252 respected, ie. selection is cleared even if editor had
255 void DeleteProperty( wxPGPropArg id
);
258 Removes a property. Does not delete the property object, but
262 Pointer or name of a property.
264 @remarks Removed property cannot have any children.
266 Also, if you remove property in a wxPropertyGrid event
267 handler, the actual removal is postponed until the next
270 wxPGProperty
* RemoveProperty( wxPGPropArg id
);
275 @see EnableProperty(), wxPGProperty::Enable()
277 bool DisableProperty( wxPGPropArg id
) { return EnableProperty(id
,false); }
280 Returns true if all property grid data changes have been committed.
282 Usually only returns false if value in active editor has been
283 invalidated by a wxValidator.
285 bool EditorValidate();
288 Enables or disables property, depending on whether enable is true or
289 false. Disabled property usually appears as having grey text.
292 Name or pointer to a property.
294 If @false, property is disabled instead.
296 @see wxPGProperty::Enable()
298 bool EnableProperty( wxPGPropArg id
, bool enable
= true );
300 /** Called after population of property with fixed children has finished.
302 void EndAddChildren( wxPGPropArg id
);
304 /** Expands given category or property with children.
305 Returns true if actually expands.
307 bool Expand( wxPGPropArg id
);
309 /** Expands all items that can be expanded.
311 bool ExpandAll( bool expand
= true );
313 /** Returns id of first child of given property.
315 Does not return sub-properties!
317 wxPGProperty
* GetFirstChild( wxPGPropArg id
)
319 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(wxNullProperty
)
321 if ( !p
->GetChildCount() || p
->HasFlag(wxPG_PROP_AGGREGATE
) )
322 return wxNullProperty
;
328 /** Returns iterator class instance.
330 See @ref propgrid_iterator_flags. Value wxPG_ITERATE_DEFAULT causes
331 iteration over everything except private child properties.
333 Property to start iteration from. If NULL, then first child of root
336 Either wxTOP or wxBOTTOM. wxTOP will indicate that iterations start
337 from the first property from the top, and wxBOTTOM means that the
338 iteration will instead begin from bottommost valid item.
340 wxPropertyGridIterator
GetIterator( int flags
= wxPG_ITERATE_DEFAULT
,
341 wxPGProperty
* firstProp
= NULL
)
343 return wxPropertyGridIterator( m_pState
, flags
, firstProp
);
346 wxPropertyGridConstIterator
347 GetIterator( int flags
= wxPG_ITERATE_DEFAULT
,
348 wxPGProperty
* firstProp
= NULL
) const
350 return wxPropertyGridConstIterator( m_pState
, flags
, firstProp
);
353 wxPropertyGridIterator
GetIterator( int flags
, int startPos
)
355 return wxPropertyGridIterator( m_pState
, flags
, startPos
);
358 wxPropertyGridConstIterator
GetIterator( int flags
, int startPos
) const
360 return wxPropertyGridConstIterator( m_pState
, flags
, startPos
);
364 /** Returns id of first item, whether it is a category or property.
366 @link iteratorflags List of iterator flags@endlink
368 wxPGProperty
* GetFirst( int flags
= wxPG_ITERATE_ALL
)
370 wxPropertyGridIterator
it( m_pState
, flags
, wxNullProperty
, 1 );
374 const wxPGProperty
* GetFirst( int flags
= wxPG_ITERATE_ALL
) const
376 return ((wxPropertyGridInterface
*)this)->GetFirst(flags
);
380 Returns pointer to a property with given name (case-sensitive).
381 If there is no property with such name, @NULL pointer is returned.
383 @remarks Properties which have non-category, non-root parent
384 can not be accessed globally by their name. Instead, use
385 "<property>.<subproperty>" instead of "<subproperty>".
387 wxPGProperty
* GetProperty( const wxString
& name
) const
389 return GetPropertyByName(name
);
392 /** Returns map-like storage of property's attributes.
394 Note that if extra style wxPG_EX_WRITEONLY_BUILTIN_ATTRIBUTES is set,
395 then builtin-attributes are not included in the storage.
397 const wxPGAttributeStorage
& GetPropertyAttributes( wxPGPropArg id
) const
399 // If 'id' refers to invalid property, then we will return dummy
400 // attributes (ie. root property's attributes, which contents should
401 // should always be empty and of no consequence).
402 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(m_pState
->DoGetRoot()->GetAttributes());
403 return p
->GetAttributes();
406 /** Adds to 'targetArr' pointers to properties that have given
407 flags 'flags' set. However, if 'inverse' is set to true, then
408 only properties without given flags are stored.
410 Property flags to use.
412 Iterator flags to use. Default is everything expect private children.
414 void GetPropertiesWithFlag( wxArrayPGProperty
* targetArr
,
415 wxPGProperty::FlagType flags
,
416 bool inverse
= false,
417 int iterFlags
= wxPG_ITERATE_PROPERTIES
|
418 wxPG_ITERATE_HIDDEN
|
419 wxPG_ITERATE_CATEGORIES
) const;
421 /** Returns value of given attribute. If none found, returns NULL-variant.
423 wxVariant
GetPropertyAttribute( wxPGPropArg id
,
424 const wxString
& attrName
) const
426 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(wxNullVariant
)
427 return p
->GetAttribute(attrName
);
430 /** Returns pointer of property's nearest parent category. If no category
433 wxPropertyCategory
* GetPropertyCategory( wxPGPropArg id
) const
435 wxPG_PROP_ID_CONST_CALL_PROLOG_RETVAL(NULL
)
436 return m_pState
->GetPropertyCategory(p
);
439 /** Returns client data (void*) of a property. */
440 void* GetPropertyClientData( wxPGPropArg id
) const
442 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(NULL
)
443 return p
->GetClientData();
447 Returns first property which label matches given string.
449 NULL if none found. Note that this operation is extremely slow when
450 compared to GetPropertyByName().
452 wxPGProperty
* GetPropertyByLabel( const wxString
& label
) const;
454 /** Returns property with given name. NULL if none found.
456 wxPGProperty
* GetPropertyByName( const wxString
& name
) const;
458 /** Returns child property 'subname' of property 'name'. Same as
459 calling GetPropertyByName("name.subname"), albeit slightly faster.
461 wxPGProperty
* GetPropertyByName( const wxString
& name
,
462 const wxString
& subname
) const;
464 /** Returns property's editor. */
465 const wxPGEditor
* GetPropertyEditor( wxPGPropArg id
) const
467 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(NULL
)
468 return p
->GetEditorClass();
471 /** Returns help string associated with a property. */
472 wxString
GetPropertyHelpString( wxPGPropArg id
) const
474 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(m_emptyString
)
475 return p
->GetHelpString();
478 /** Returns property's custom value image (NULL of none). */
479 wxBitmap
* GetPropertyImage( wxPGPropArg id
) const
481 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(NULL
)
482 return p
->GetValueImage();
485 /** Returns label of a property. */
486 const wxString
& GetPropertyLabel( wxPGPropArg id
)
488 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(m_emptyString
)
489 return p
->GetLabel();
492 /** Returns name of a property, by which it is globally accessible. */
493 wxString
GetPropertyName( wxPGProperty
* property
)
495 return property
->GetName();
498 /** Returns parent item of a property. */
499 wxPGProperty
* GetPropertyParent( wxPGPropArg id
)
501 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(wxNullProperty
)
502 return p
->GetParent();
506 /** Returns validator of a property as a reference, which you
507 can pass to any number of SetPropertyValidator.
509 wxValidator
* GetPropertyValidator( wxPGPropArg id
)
511 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(NULL
)
512 return p
->GetValidator();
516 /** Returns value as wxVariant. To get wxObject pointer from it,
517 you will have to use WX_PG_VARIANT_TO_WXOBJECT(VARIANT,CLASSNAME) macro.
519 If property value is unspecified, Null variant is returned.
521 wxVariant
GetPropertyValue( wxPGPropArg id
)
523 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(wxVariant())
524 return p
->GetValue();
527 wxString
GetPropertyValueAsString( wxPGPropArg id
) const;
528 long GetPropertyValueAsLong( wxPGPropArg id
) const;
529 unsigned long GetPropertyValueAsULong( wxPGPropArg id
) const
531 return (unsigned long) GetPropertyValueAsLong(id
);
533 int GetPropertyValueAsInt( wxPGPropArg id
) const
534 { return (int)GetPropertyValueAsLong(id
); }
535 bool GetPropertyValueAsBool( wxPGPropArg id
) const;
536 double GetPropertyValueAsDouble( wxPGPropArg id
) const;
538 #define wxPG_PROP_ID_GETPROPVAL_CALL_PROLOG_RETVAL(TYPENAME, DEFVAL) \
539 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(DEFVAL) \
540 wxString typeName(wxS(TYPENAME)); \
541 wxVariant value = p->GetValue(); \
542 if ( value.GetType() != typeName ) \
544 wxPGGetFailed(p, typeName); \
548 #define wxPG_PROP_ID_GETPROPVAL_CALL_PROLOG_RETVAL_WFALLBACK(TYPENAME, DEFVAL) \
549 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(DEFVAL) \
550 wxVariant value = p->GetValue(); \
551 if ( value.GetType() != wxS(TYPENAME) ) \
554 wxArrayString GetPropertyValueAsArrayString( wxPGPropArg id ) const
556 wxPG_PROP_ID_GETPROPVAL_CALL_PROLOG_RETVAL("arrstring",
558 return value
.GetArrayString();
562 wxLongLong_t
GetPropertyValueAsLongLong( wxPGPropArg id
) const
564 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(0)
565 return p
->GetValue().GetLongLong().GetValue();
568 wxULongLong_t
GetPropertyValueAsULongLong( wxPGPropArg id
) const
570 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(0)
571 return p
->GetValue().GetULongLong().GetValue();
575 wxArrayInt
GetPropertyValueAsArrayInt( wxPGPropArg id
) const
577 wxPG_PROP_ID_GETPROPVAL_CALL_PROLOG_RETVAL("wxArrayInt",
585 wxDateTime
GetPropertyValueAsDateTime( wxPGPropArg id
) const
587 wxPG_PROP_ID_GETPROPVAL_CALL_PROLOG_RETVAL("datetime",
589 return value
.GetDateTime();
593 /** Returns a wxVariant list containing wxVariant versions of all
594 property values. Order is not guaranteed.
596 Use wxPG_KEEP_STRUCTURE to retain category structure; each sub
597 category will be its own wxVariantList of wxVariant.
598 Use wxPG_INC_ATTRIBUTES to include property attributes as well.
599 Each attribute will be stored as list variant named
600 "@@<propname>@@attr."
603 wxVariant
GetPropertyValues( const wxString
& listname
= wxEmptyString
,
604 wxPGProperty
* baseparent
= NULL
, long flags
= 0 ) const
606 return m_pState
->DoGetPropertyValues(listname
, baseparent
, flags
);
610 Returns currently selected property. NULL if none.
612 @remarks When wxPG_EX_MULTIPLE_SELECTION extra style is used, this
613 member function returns the focused property, that is the
614 one which can have active editor.
616 wxPGProperty
* GetSelection() const;
619 Returns list of currently selected properties.
621 @remarks wxArrayPGProperty should be compatible with std::vector API.
623 const wxArrayPGProperty
& GetSelectedProperties() const
625 return m_pState
->m_selection
;
628 wxPropertyGridPageState
* GetState() const { return m_pState
; }
630 /** Similar to GetIterator(), but instead returns wxPGVIterator instance,
631 which can be useful for forward-iterating through arbitrary property
635 See @ref propgrid_iterator_flags.
637 virtual wxPGVIterator
GetVIterator( int flags
) const;
639 /** Hides or reveals a property.
641 If true, hides property, otherwise reveals it.
643 By default changes are applied recursively. Set this paramter
644 wxPG_DONT_RECURSE to prevent this.
646 bool HideProperty( wxPGPropArg id
,
648 int flags
= wxPG_RECURSE
);
650 #if wxPG_INCLUDE_ADVPROPS
651 /** Initializes *all* property types. Causes references to most object
652 files in the library, so calling this may cause significant increase
653 in executable size when linking with static library.
655 static void InitAllTypeHandlers();
657 static void InitAllTypeHandlers() { }
661 /** Inserts property to the property container.
664 New property is inserted just prior to this. Available only
665 in the first variant. There are two versions of this function
666 to allow this parameter to be either an id or name to
670 Pointer to the inserted property. wxPropertyGrid will take
671 ownership of this object.
674 New property is inserted under this category. Available only
675 in the second variant. There are two versions of this function
676 to allow this parameter to be either an id or name to
680 Index under category. Available only in the second variant.
681 If index is < 0, property is appended in category.
684 Returns id for the property,
688 - wxPropertyGrid takes the ownership of the property pointer.
690 - While Append may be faster way to add items, make note that when
691 both types of data storage (categoric and
692 non-categoric) are active, Insert becomes even more slow. This is
693 especially true if current mode is non-categoric.
700 wxPGProperty* my_cat_id = propertygrid->Append(
701 new wxPropertyCategory("My Category") );
705 // insert into category - using second variant
706 wxPGProperty* my_item_id_1 = propertygrid->Insert(
707 my_cat_id, 0, new wxStringProperty("My String 1") );
709 // insert before to first item - using first variant
710 wxPGProperty* my_item_id_2 = propertygrid->Insert(
711 my_item_id, new wxStringProperty("My String 2") );
716 wxPGProperty
* Insert( wxPGPropArg priorThis
, wxPGProperty
* newproperty
);
717 wxPGProperty
* Insert( wxPGPropArg parent
,
719 wxPGProperty
* newproperty
);
722 /** Returns true if property is a category. */
723 bool IsPropertyCategory( wxPGPropArg id
) const
725 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(false)
726 return p
->IsCategory();
729 /** Returns true if property is enabled. */
730 bool IsPropertyEnabled( wxPGPropArg id
) const
732 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(false)
733 return (!(p
->GetFlags() & wxPG_PROP_DISABLED
))?true:false;
737 Returns true if given property is expanded.
739 Naturally, always returns false for properties that cannot be expanded.
741 bool IsPropertyExpanded( wxPGPropArg id
) const;
744 Returns true if property has been modified after value set or modify
745 flag clear by software.
747 bool IsPropertyModified( wxPGPropArg id
) const
749 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(false)
750 return ( (p
->GetFlags() & wxPG_PROP_MODIFIED
) ? true : false );
754 Returns true if property is selected.
756 bool IsPropertySelected( wxPGPropArg id
) const
758 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(false)
759 return m_pState
->DoIsPropertySelected(p
);
763 Returns true if property is shown (ie hideproperty with true not
766 bool IsPropertyShown( wxPGPropArg id
) const
768 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(false)
769 return (!(p
->GetFlags() & wxPG_PROP_HIDDEN
))?true:false;
772 /** Returns true if property value is set to unspecified.
774 bool IsPropertyValueUnspecified( wxPGPropArg id
) const
776 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(false)
777 return p
->IsValueUnspecified();
781 Disables (limit = true) or enables (limit = false) wxTextCtrl editor of
782 a property, if it is not the sole mean to edit the value.
784 void LimitPropertyEditing( wxPGPropArg id
, bool limit
= true );
786 /** If state is shown in it's grid, refresh it now.
788 virtual void RefreshGrid( wxPropertyGridPageState
* state
= NULL
);
790 #if wxPG_INCLUDE_ADVPROPS
792 Initializes additional property editors (SpinCtrl etc.). Causes
793 references to most object files in the library, so calling this may
794 cause significant increase in executable size when linking with static
797 static void RegisterAdditionalEditors();
799 static void RegisterAdditionalEditors() { }
802 /** Replaces property with id with newly created property. For example,
803 this code replaces existing property named "Flags" with one that
804 will have different set of items:
806 pg->ReplaceProperty("Flags",
807 wxFlagsProperty("Flags", wxPG_LABEL, newItems))
809 For more info, see wxPropertyGrid::Insert.
811 wxPGProperty
* ReplaceProperty( wxPGPropArg id
, wxPGProperty
* property
);
813 /** @anchor propgridinterface_editablestate_flags
815 Flags for wxPropertyGridInterface::SaveEditableState() and
816 wxPropertyGridInterface::RestoreEditableState().
818 enum EditableStateFlags
820 /** Include selected property. */
821 SelectionState
= 0x01,
822 /** Include expanded/collapsed property information. */
823 ExpandedState
= 0x02,
824 /** Include scrolled position. */
825 ScrollPosState
= 0x04,
826 /** Include selected page information.
827 Only applies to wxPropertyGridManager. */
829 /** Include splitter position. Stored for each page. */
830 SplitterPosState
= 0x10,
831 /** Include description box size.
832 Only applies to wxPropertyGridManager. */
836 Include all supported user editable state information.
837 This is usually the default value. */
838 AllStates
= SelectionState
|
847 Restores user-editable state.
849 See also wxPropertyGridInterface::SaveEditableState().
852 String generated by SaveEditableState.
855 Which parts to restore from source string. See @ref
856 propgridinterface_editablestate_flags "list of editable state
860 False if there was problem reading the string.
863 If some parts of state (such as scrolled or splitter position) fail to
864 restore correctly, please make sure that you call this function after
865 wxPropertyGrid size has been set (this may sometimes be tricky when
868 bool RestoreEditableState( const wxString
& src
,
869 int restoreStates
= AllStates
);
872 Used to acquire user-editable state (selected property, expanded
873 properties, scrolled position, splitter positions).
875 @param includedStates
876 Which parts of state to include. See @ref
877 propgridinterface_editablestate_flags "list of editable state flags".
879 wxString
SaveEditableState( int includedStates
= AllStates
) const;
882 Lets user to set the strings listed in the choice dropdown of a
883 wxBoolProperty. Defaults are "True" and "False", so changing them to,
884 say, "Yes" and "No" may be useful in some less technical applications.
886 static void SetBoolChoices( const wxString
& trueChoice
,
887 const wxString
& falseChoice
);
890 Set proportion of a auto-stretchable column. wxPG_SPLITTER_AUTO_CENTER
891 window style needs to be used to indicate that columns are auto-
894 @returns Returns @false on failure.
896 @remarks You should call this for individual pages of
897 wxPropertyGridManager (if used).
899 @see GetColumnProportion()
901 bool SetColumnProportion( unsigned int column
, int proportion
);
904 Returns auto-resize proportion of the given column.
906 @see SetColumnProportion()
908 int GetColumnProportion( unsigned int column
) const
910 return m_pState
->DoGetColumnProportion(column
);
913 /** Sets an attribute for this property.
915 Text identifier of attribute. See @ref propgrid_property_attributes.
919 Optional. Use wxPG_RECURSE to set the attribute to child properties
922 void SetPropertyAttribute( wxPGPropArg id
,
923 const wxString
& attrName
,
927 DoSetPropertyAttribute(id
,attrName
,value
,argFlags
);
930 /** Sets property attribute for all applicapple properties.
931 Be sure to use this method only after all properties have been
934 void SetPropertyAttributeAll( const wxString
& attrName
, wxVariant value
);
937 Sets background colour of a property.
940 Property name or pointer.
943 New background colour.
946 Default is wxPG_RECURSE which causes colour to be set recursively.
947 Omit this flag to only set colour for the property in question
948 and not any of its children.
950 void SetPropertyBackgroundColour( wxPGPropArg id
,
951 const wxColour
& colour
,
952 int flags
= wxPG_RECURSE
);
954 /** Resets text and background colours of given property.
956 void SetPropertyColoursToDefault( wxPGPropArg id
);
959 Sets text colour of a property.
962 Property name or pointer.
965 New background colour.
968 Default is wxPG_RECURSE which causes colour to be set recursively.
969 Omit this flag to only set colour for the property in question
970 and not any of its children.
972 void SetPropertyTextColour( wxPGPropArg id
,
974 int flags
= wxPG_RECURSE
);
977 Returns background colour of first cell of a property.
979 wxColour
GetPropertyBackgroundColour( wxPGPropArg id
) const
981 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(wxColour())
982 return p
->GetCell(0).GetBgCol();
986 Returns text colour of first cell of a property.
988 wxColour
GetPropertyTextColour( wxPGPropArg id
) const
990 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(wxColour())
991 return p
->GetCell(0).GetFgCol();
994 /** Sets text, bitmap, and colours for given column's cell.
997 - You can set label cell by setting column to 0.
998 - You can use wxPG_LABEL as text to use default text for column.
1000 void SetPropertyCell( wxPGPropArg id
,
1002 const wxString
& text
= wxEmptyString
,
1003 const wxBitmap
& bitmap
= wxNullBitmap
,
1004 const wxColour
& fgCol
= wxNullColour
,
1005 const wxColour
& bgCol
= wxNullColour
);
1007 /** Sets client data (void*) of a property.
1009 This untyped client data has to be deleted manually.
1011 void SetPropertyClientData( wxPGPropArg id
, void* clientData
)
1013 wxPG_PROP_ARG_CALL_PROLOG()
1014 p
->SetClientData(clientData
);
1017 /** Sets editor for a property.
1020 For builtin editors, use wxPGEditor_X, where X is builtin editor's
1021 name (TextCtrl, Choice, etc. see wxPGEditor documentation for full
1024 For custom editors, use pointer you received from
1025 wxPropertyGrid::RegisterEditorClass().
1027 void SetPropertyEditor( wxPGPropArg id
, const wxPGEditor
* editor
)
1029 wxPG_PROP_ARG_CALL_PROLOG()
1030 wxCHECK_RET( editor
, wxT("unknown/NULL editor") );
1031 p
->SetEditor(editor
);
1035 /** Sets editor control of a property. As editor argument, use
1036 editor name string, such as "TextCtrl" or "Choice".
1038 void SetPropertyEditor( wxPGPropArg id
, const wxString
& editorName
)
1040 SetPropertyEditor(id
,GetEditorByName(editorName
));
1043 /** Sets label of a property.
1045 void SetPropertyLabel( wxPGPropArg id
, const wxString
& newproplabel
);
1048 Sets name of a property.
1051 Name or pointer of property which name to change.
1054 New name for property.
1056 void SetPropertyName( wxPGPropArg id
, const wxString
& newName
)
1058 wxPG_PROP_ARG_CALL_PROLOG()
1059 m_pState
->DoSetPropertyName( p
, newName
);
1063 Sets property (and, recursively, its children) to have read-only value.
1064 In other words, user cannot change the value in the editor, but they
1067 This is mainly for use with textctrl editor. Not all other editors fully
1070 By default changes are applied recursively. Set this paramter
1071 wxPG_DONT_RECURSE to prevent this.
1073 void SetPropertyReadOnly( wxPGPropArg id
,
1075 int flags
= wxPG_RECURSE
)
1077 wxPG_PROP_ARG_CALL_PROLOG()
1078 if ( flags
& wxPG_RECURSE
)
1079 p
->SetFlagRecursively(wxPG_PROP_READONLY
, set
);
1081 p
->ChangeFlag(wxPG_PROP_READONLY
, set
);
1084 /** Sets property's value to unspecified.
1085 If it has children (it may be category), then the same thing is done to
1088 void SetPropertyValueUnspecified( wxPGPropArg id
)
1090 wxPG_PROP_ARG_CALL_PROLOG()
1091 p
->SetValueToUnspecified();
1095 Sets property values from a list of wxVariants.
1097 void SetPropertyValues( const wxVariantList
& list
,
1098 wxPGPropArg defaultCategory
= wxNullProperty
)
1101 if ( defaultCategory
.HasName() ) p
= defaultCategory
.GetPtr(this);
1102 else p
= defaultCategory
.GetPtr0();
1103 m_pState
->DoSetPropertyValues(list
, p
);
1107 Sets property values from a list of wxVariants.
1109 void SetPropertyValues( const wxVariant
& list
,
1110 wxPGPropArg defaultCategory
= wxNullProperty
)
1112 SetPropertyValues(list
.GetList(),defaultCategory
);
1115 /** Associates the help string with property.
1117 By default, text is shown either in the manager's "description"
1118 text box or in the status bar. If extra window style
1119 wxPG_EX_HELP_AS_TOOLTIPS is used, then the text will appear as a
1122 void SetPropertyHelpString( wxPGPropArg id
, const wxString
& helpString
)
1124 wxPG_PROP_ARG_CALL_PROLOG()
1125 p
->SetHelpString(helpString
);
1128 /** Set wxBitmap in front of the value.
1130 - Bitmap will be scaled to a size returned by
1131 wxPropertyGrid::GetImageSize();
1133 void SetPropertyImage( wxPGPropArg id
, wxBitmap
& bmp
)
1135 wxPG_PROP_ARG_CALL_PROLOG()
1136 p
->SetValueImage(bmp
);
1140 /** Sets max length of property's text.
1142 bool SetPropertyMaxLength( wxPGPropArg id
, int maxLen
);
1144 #if wxUSE_VALIDATORS
1145 /** Sets validator of a property.
1147 void SetPropertyValidator( wxPGPropArg id
, const wxValidator
& validator
)
1149 wxPG_PROP_ARG_CALL_PROLOG()
1150 p
->SetValidator(validator
);
1154 /** Sets value (long integer) of a property.
1156 void SetPropertyValue( wxPGPropArg id
, long value
)
1159 SetPropVal( id
, v
);
1162 /** Sets value (integer) of a property.
1164 void SetPropertyValue( wxPGPropArg id
, int value
)
1166 wxVariant
v((long)value
);
1167 SetPropVal( id
, v
);
1169 /** Sets value (floating point) of a property.
1171 void SetPropertyValue( wxPGPropArg id
, double value
)
1174 SetPropVal( id
, v
);
1176 /** Sets value (bool) of a property.
1178 void SetPropertyValue( wxPGPropArg id
, bool value
)
1181 SetPropVal( id
, v
);
1183 void SetPropertyValue( wxPGPropArg id
, const wchar_t* value
)
1185 SetPropertyValueString( id
, wxString(value
) );
1187 void SetPropertyValue( wxPGPropArg id
, const char* value
)
1189 SetPropertyValueString( id
, wxString(value
) );
1191 void SetPropertyValue( wxPGPropArg id
, const wxString
& value
)
1193 SetPropertyValueString( id
, value
);
1196 /** Sets value (wxArrayString) of a property.
1198 void SetPropertyValue( wxPGPropArg id
, const wxArrayString
& value
)
1201 SetPropVal( id
, v
);
1205 void SetPropertyValue( wxPGPropArg id
, const wxDateTime
& value
)
1208 SetPropVal( id
, v
);
1212 /** Sets value (wxObject*) of a property.
1214 void SetPropertyValue( wxPGPropArg id
, wxObject
* value
)
1217 SetPropVal( id
, v
);
1220 void SetPropertyValue( wxPGPropArg id
, wxObject
& value
)
1222 wxVariant
v(&value
);
1223 SetPropVal( id
, v
);
1227 /** Sets value (wxLongLong&) of a property.
1229 void SetPropertyValue( wxPGPropArg id
, wxLongLong_t value
)
1231 wxVariant v
= WXVARIANT(wxLongLong(value
));
1232 SetPropVal( id
, v
);
1234 /** Sets value (wxULongLong&) of a property.
1236 void SetPropertyValue( wxPGPropArg id
, wxULongLong_t value
)
1238 wxVariant v
= WXVARIANT(wxULongLong(value
));
1239 SetPropVal( id
, v
);
1243 /** Sets value (wxArrayInt&) of a property.
1245 void SetPropertyValue( wxPGPropArg id
, const wxArrayInt
& value
)
1247 wxVariant v
= WXVARIANT(value
);
1248 SetPropVal( id
, v
);
1251 /** Sets value (wxString) of a property.
1254 This method uses wxPGProperty::SetValueFromString, which all properties
1255 should implement. This means that there should not be a type error,
1256 and instead the string is converted to property's actual value type.
1258 void SetPropertyValueString( wxPGPropArg id
, const wxString
& value
);
1260 /** Sets value (wxVariant&) of a property.
1263 Use wxPropertyGrid::ChangePropertyValue() instead if you need to run
1264 through validation process and send property change event.
1266 void SetPropertyValue( wxPGPropArg id
, wxVariant value
)
1268 SetPropVal( id
, value
);
1271 /** Sets value (wxVariant&) of a property. Same as SetPropertyValue, but
1272 accepts reference. */
1273 void SetPropVal( wxPGPropArg id
, wxVariant
& value
);
1275 /** Adjusts how wxPropertyGrid behaves when invalid value is entered
1278 See @link vfbflags list of valid flags values@endlink
1280 void SetValidationFailureBehavior( int vfbFlags
);
1283 Sorts all properties recursively.
1286 This can contain any of the following options:
1287 wxPG_SORT_TOP_LEVEL_ONLY: Only sort categories and their
1288 immediate children. Sorting done by wxPG_AUTO_SORT option
1291 @see SortChildren, wxPropertyGrid::SetSortFunction
1293 void Sort( int flags
= 0 );
1296 Sorts children of a property.
1299 Name or pointer to a property.
1302 This can contain any of the following options:
1303 wxPG_RECURSE: Sorts recursively.
1305 @see Sort, wxPropertyGrid::SetSortFunction
1307 void SortChildren( wxPGPropArg id
, int flags
= 0 )
1309 wxPG_PROP_ARG_CALL_PROLOG()
1310 m_pState
->DoSortChildren(p
, flags
);
1313 // GetPropertyByName With nice assertion error message.
1314 wxPGProperty
* GetPropertyByNameA( const wxString
& name
) const;
1316 static wxPGEditor
* GetEditorByName( const wxString
& editorName
);
1318 // NOTE: This function reselects the property and may cause
1319 // excess flicker, so to just call Refresh() on a rect
1320 // of single property, call DrawItem() instead.
1321 virtual void RefreshProperty( wxPGProperty
* p
) = 0;
1325 bool DoClearSelection( bool validation
= false,
1329 In derived class, implement to set editable state component with
1330 given name to given value.
1332 virtual bool SetEditableStateItem( const wxString
& name
, wxVariant value
)
1340 In derived class, implement to return editable state component with
1343 virtual wxVariant
GetEditableStateItem( const wxString
& name
) const
1346 return wxNullVariant
;
1349 // Returns page state data for given (sub) page (-1 means current page).
1350 virtual wxPropertyGridPageState
* GetPageState( int pageIndex
) const
1352 if ( pageIndex
<= 0 )
1357 virtual bool DoSelectPage( int WXUNUSED(index
) ) { return true; }
1359 // Default call's m_pState's BaseGetPropertyByName
1360 virtual wxPGProperty
* DoGetPropertyByName( const wxString
& name
) const;
1362 // Deriving classes must set this (it must be only or current page).
1363 wxPropertyGridPageState
* m_pState
;
1365 // Intermediate version needed due to wxVariant copying inefficiency
1366 void DoSetPropertyAttribute( wxPGPropArg id
,
1367 const wxString
& name
,
1368 wxVariant
& value
, long argFlags
);
1370 // Empty string object to return from member functions returning const
1372 wxString m_emptyString
;
1375 // Cannot be GetGrid() due to ambiguity issues.
1376 wxPropertyGrid
* GetPropertyGrid()
1380 return m_pState
->GetGrid();
1383 // Cannot be GetGrid() due to ambiguity issues.
1384 const wxPropertyGrid
* GetPropertyGrid() const
1388 return static_cast<const wxPropertyGrid
*>(m_pState
->GetGrid());
1391 friend class wxPropertyGrid
;
1392 friend class wxPropertyGridManager
;
1395 #endif // wxUSE_PROPGRID
1397 #endif // __WX_PROPGRID_PROPGRIDIFACE_H__