X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/e16bff8e6269e0153a22c6b2180fe5adfeb8763a..ed8b46bba32c76a5544e6043a0a6de21eda5a712:/include/wx/propgrid/property.h diff --git a/include/wx/propgrid/property.h b/include/wx/propgrid/property.h index 088f442b7c..f72e352e8f 100644 --- a/include/wx/propgrid/property.h +++ b/include/wx/propgrid/property.h @@ -6,12 +6,14 @@ // Created: 2008-08-23 // RCS-ID: $Id$ // Copyright: (c) Jaakko Salli -// Licence: wxWindows license +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifndef _WX_PROPGRID_PROPERTY_H_ #define _WX_PROPGRID_PROPERTY_H_ +#include "wx/defs.h" + #if wxUSE_PROPGRID #include "wx/propgrid/propgriddefs.h" @@ -47,9 +49,6 @@ struct wxPGPaintData }; -#ifndef SWIG - - // space between vertical sides of a custom image #define wxPG_CUSTOM_IMAGE_SPACINGY 1 @@ -220,7 +219,6 @@ protected: bool m_hasValidText; }; -#endif // !SWIG /** @class wxPGCell @@ -308,6 +306,13 @@ public: return *this; } + // Used mostly internally to figure out if this cell is supposed + // to have default values when attached to a grid. + bool IsInvalid() const + { + return ( m_refData == NULL ); + } + private: virtual wxObjectRefData *CreateRefData() const { return new wxPGCellData(); } @@ -317,8 +322,6 @@ private: // ----------------------------------------------------------------------- -#ifndef SWIG - /** @class wxPGAttributeStorage wxPGAttributeStorage is somewhat optimized storage for @@ -366,7 +369,6 @@ protected: wxPGHashMapS2P m_map; }; -#endif // !SWIG // ----------------------------------------------------------------------- @@ -374,7 +376,7 @@ protected: @{ */ -enum wxPG_PROPERTY_FLAGS +enum wxPGPropertyFlags { /** Indicates bold font. @@ -451,7 +453,9 @@ wxPG_PROP_CATEGORY = 0x2000, */ wxPG_PROP_MISC_PARENT = 0x4000, -/** Property is read-only. Editor is still created. +/** Property is read-only. Editor is still created for wxTextCtrl-based + property editors. For others, editor is not usually created because + they do implement wxTE_READONLY style or equivalent. */ wxPG_PROP_READONLY = 0x8000, @@ -478,6 +482,8 @@ wxPG_PROP_USES_COMMON_VALUE = 0x00020000, @remarks This flag cannot be used with property iterators. + + @see wxPGProperty::SetAutoUnspecified() */ wxPG_PROP_AUTO_UNSPECIFIED = 0x00040000, @@ -504,7 +510,9 @@ wxPG_PROP_BEING_DELETED = 0x00200000 Code should automatically take care of this, however. */ #define wxPG_PROP_PARENTAL_FLAGS \ - (wxPG_PROP_AGGREGATE|wxPG_PROP_CATEGORY|wxPG_PROP_MISC_PARENT) + ((wxPGPropertyFlags)(wxPG_PROP_AGGREGATE | \ + wxPG_PROP_CATEGORY | \ + wxPG_PROP_MISC_PARENT)) /** @} */ @@ -515,8 +523,6 @@ wxPG_PROP_BEING_DELETED = 0x00200000 // ----------------------------------------------------------------------- -#ifndef SWIG - /** @section propgrid_property_attributes wxPropertyGrid Property Attribute Identifiers. @@ -557,7 +563,7 @@ wxPG_PROP_BEING_DELETED = 0x00200000 #if wxPG_COMPATIBILITY_1_4 /** - @deprecated Use "Hint" (wxPG_ATTR_INLINE_HELP) instead. + @deprecated Use "Hint" (wxPG_ATTR_HINT) instead. */ #define wxPG_ATTR_INLINE_HELP wxS("InlineHelp") #endif @@ -649,6 +655,15 @@ wxPG_PROP_BEING_DELETED = 0x00200000 */ #define wxPG_DIR_DIALOG_MESSAGE wxS("DialogMessage") +/** + wxArrayStringProperty's string delimiter character. If this is aquotation + mark or hyphen, then strings will be quoted instead (with given + character). + + Default delimiter is quotation mark. +*/ +#define wxPG_ARRAY_DELIMITER wxS("Delimiter") + /** Sets displayed date format for wxDateProperty. */ #define wxPG_DATE_FORMAT wxS("DateFormat") @@ -701,12 +716,8 @@ wxPG_PROP_BEING_DELETED = 0x00200000 #define wxPG_ATTR_INLINE_HELP wxPGGlobalVars->m_strInlineHelp #endif -#endif // !SWIG - // ----------------------------------------------------------------------- -#ifndef SWIG - /** @class wxPGChoiceEntry Data of a single wxPGChoices choice. */ @@ -787,7 +798,6 @@ private: #define wxPGChoicesEmptyData ((wxPGChoicesData*)NULL) -#endif // SWIG /** @class wxPGChoices @@ -1012,14 +1022,14 @@ public: /** Removes count items starting at position nIndex. */ void RemoveAt(size_t nIndex, size_t count = 1); -#ifndef SWIG - /** Does not create copies for itself. */ + /** Does not create copies for itself. + TODO: Deprecate. + */ void Set( const wxChar* const* labels, const long* values = NULL ) { Free(); Add(labels,values); } -#endif // SWIG /** Version that works with wxArrayString and wxArrayInt. */ void Set( const wxArrayString& labels, @@ -1056,7 +1066,6 @@ public: wxArrayString GetLabels() const; -#ifndef SWIG void operator= (const wxPGChoices& a) { if (this != &a) @@ -1078,7 +1087,6 @@ protected: void Init(); void Free(); -#endif // !SWIG }; // ----------------------------------------------------------------------- @@ -1141,7 +1149,6 @@ public: */ virtual wxVariant DoGetValue() const { return m_value; } -#if !defined(SWIG) || defined(CREATE_VCW) /** Implement this function in derived class to check the value. Return true if it is ok. Returning false prevents property change events from occurring. @@ -1213,7 +1220,7 @@ public: virtual bool IntToValue( wxVariant& value, int number, int argFlags = 0 ) const; -#endif // !defined(SWIG) || defined(CREATE_VCW) + /** Converts property value into a text representation. @@ -1456,12 +1463,16 @@ public: */ virtual void RefreshChildren(); - /** Special handling for attributes of this property. + /** + Reimplement this member function to add special handling for + attributes of this property. - If returns false, then the attribute will be automatically stored in - m_attributes. + @return Return @false to have the attribute automatically stored in + m_attributes. Default implementation simply does that and + nothing else. - Default implementation simply returns false. + @remarks To actually set property attribute values from the + application, use wxPGProperty::SetAttribute() instead. */ virtual bool DoSetAttribute( const wxString& name, wxVariant& value ); @@ -1523,6 +1534,17 @@ public: */ void DeleteChoice( int index ); + /** + Enables or disables the property. Disabled property usually appears + as having grey text. + + @param enable + If @false, property is disabled instead. + + @see wxPropertyGridInterface::EnableProperty() + */ + void Enable( bool enable = true ); + /** Call to enable or disable usage of common value (integer value that can be selected for properties instead of their normal values) for this @@ -1690,7 +1712,12 @@ public: return m_value.IsNull(); } - FlagType HasFlag( FlagType flag ) const + /** + Returns non-zero if property has given flag set. + + @see propgrid_propflags + */ + FlagType HasFlag( wxPGPropertyFlags flag ) const { return ( m_flags & flag ); } @@ -1706,6 +1733,9 @@ public: */ wxVariant GetAttributesAsList() const; + /** + Returns property flags. + */ FlagType GetFlags() const { return m_flags; @@ -1859,7 +1889,7 @@ public: By default changes are applied recursively. Set this paramter wxPG_DONT_RECURSE to prevent this. */ - inline bool Hide( bool hide, int flags = wxPG_RECURSE ); + bool Hide( bool hide, int flags = wxPG_RECURSE ); bool IsExpanded() const { return (!(m_flags & wxPG_PROP_COLLAPSED) && GetChildCount()); } @@ -1889,6 +1919,21 @@ public: void SetAttributes( const wxPGAttributeStorage& attributes ); + /** + Set if user can change the property's value to unspecified by + modifying the value of the editor control (usually by clearing + it). Currently, this can work with following properties: + wxIntProperty, wxUIntProperty, wxFloatProperty, wxEditEnumProperty. + + @param enable + Whether to enable or disable this behavior (it is disabled by + default). + */ + void SetAutoUnspecified( bool enable = true ) + { + ChangeFlag(wxPG_PROP_AUTO_UNSPECIFIED, enable); + } + /** Sets property's background colour. @@ -1925,7 +1970,6 @@ public: */ void SetDefaultValue( wxVariant& value ); -#ifndef SWIG /** Sets editor for a property. @param editor @@ -1940,7 +1984,6 @@ public: { m_customEditor = editor; } -#endif /** Sets editor for a property. */ @@ -2022,14 +2065,16 @@ public: } /** - Sets given property flag(s). - */ - void SetFlag( FlagType flag ) { m_flags |= flag; } + Sets or clears given property flag. Mainly for internal use. - /** - Sets or clears given property flag(s). + @remarks Setting a property flag never has any side-effect, and is + intended almost exclusively for internal use. So, for + example, if you want to disable a property, call + Enable(false) instead of setting wxPG_PROP_DISABLED flag. + + @see HasFlag(), GetFlags() */ - void ChangeFlag( FlagType flag, bool set ) + void ChangeFlag( wxPGPropertyFlags flag, bool set ) { if ( set ) m_flags |= flag; @@ -2037,7 +2082,13 @@ public: m_flags &= ~flag; } - void SetFlagRecursively( FlagType flag, bool set ); + /** + Sets or clears given property flag, recursively. This function is + primarily intended for internal use. + + @see ChangeFlag() + */ + void SetFlagRecursively( wxPGPropertyFlags flag, bool set ); void SetHelpString( const wxString& helpString ) { @@ -2094,7 +2145,6 @@ public: } #endif // wxUSE_VALIDATORS -#ifndef SWIG /** Returns client data (void*) of a property. */ void* GetClientData() const @@ -2122,14 +2172,14 @@ public: /** Sets managed client object of a property. */ wxClientData *GetClientObject() const { return m_clientObject; } -#endif - /** Sets new set of choices for property. + /** + Sets new set of choices for the property. - @remarks - This operation clears the property value. + @remarks This operation deselects the property and clears its + value. */ - bool SetChoices( wxPGChoices& choices ); + bool SetChoices( const wxPGChoices& choices ); /** Set max length of text in text editor. */ @@ -2149,8 +2199,6 @@ public: return m_helpString; } - void ClearFlag( FlagType flag ) { m_flags &= ~(flag); } - // Use, for example, to detect if item is inside collapsed section. bool IsSomeParent( wxPGProperty* candidate_parent ) const; @@ -2220,16 +2268,12 @@ public: */ int GetImageOffset( int imageWidth ) const; -#ifndef SWIG // Returns wxPropertyGridPageState in which this property resides. wxPropertyGridPageState* GetParentState() const { return m_parentState; } -#endif -#ifndef SWIG wxPGProperty* GetItemAtY( unsigned int y, unsigned int lh, unsigned int* nextItemY ) const; -#endif /** Returns property at given virtual y coordinate. */ @@ -2239,8 +2283,6 @@ public: */ wxPGProperty* GetPropertyByName( const wxString& name ) const; -#ifndef SWIG - // Returns various display-related information for given column void GetDisplayInfo( unsigned int column, int choiceIndex, @@ -2322,6 +2364,8 @@ protected: const wxVariantList* valueOverrides = NULL, wxPGHashMapS2S* childResults = NULL ) const; + bool DoHide( bool hide, int flags ); + void DoSetName(const wxString& str) { m_name = str; } /** Deletes all sub-properties. */ @@ -2340,11 +2384,29 @@ protected: // Removes child property with given pointer. Does not delete it. void RemoveChild( wxPGProperty* p ); + void DoEnable( bool enable ); + void DoPreAddChild( int index, wxPGProperty* prop ); void SetParentState( wxPropertyGridPageState* pstate ) { m_parentState = pstate; } + void SetFlag( wxPGPropertyFlags flag ) + { + // + // NB: While using wxPGPropertyFlags here makes it difficult to + // combine different flags, it usefully prevents user from + // using incorrect flags (say, wxWindow styles). + m_flags |= flag; + } + + void ClearFlag( FlagType flag ) { m_flags &= ~(flag); } + + // Called when the property is being removed from the grid and/or + // page state (but *not* when it is also deleted). + void OnDetached(wxPropertyGridPageState* state, + wxPropertyGrid* propgrid); + // Call after fixed sub-properties added/removed after creation. // if oldSelInd >= 0 and < new max items, then selection is // moved to it. @@ -2408,7 +2470,6 @@ private: // Called in constructors. void Init(); void Init( const wxString& label, const wxString& name ); -#endif // #ifndef SWIG }; // ----------------------------------------------------------------------- @@ -2421,14 +2482,12 @@ private: #define WX_PG_DECLARE_DOGETEDITORCLASS \ virtual const wxPGEditor* DoGetEditorClass() const; -#ifndef SWIG +#ifndef WX_PG_DECLARE_PROPERTY_CLASS #define WX_PG_DECLARE_PROPERTY_CLASS(CLASSNAME) \ public: \ DECLARE_DYNAMIC_CLASS(CLASSNAME) \ WX_PG_DECLARE_DOGETEDITORCLASS \ private: -#else - #define WX_PG_DECLARE_PROPERTY_CLASS(CLASSNAME) #endif // Implements sans constructor function. Also, first arg is class name, not @@ -2441,8 +2500,6 @@ const wxPGEditor* PROPNAME::DoGetEditorClass() const \ // ----------------------------------------------------------------------- -#ifndef SWIG - /** @class wxPGRootProperty @ingroup classes Root parent property. @@ -2505,8 +2562,6 @@ private: void Init(); }; -#endif // !SWIG - // ----------------------------------------------------------------------- #endif // wxUSE_PROPGRID