X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/18415eb5ca44bad29ab72db4607ed92cc6f456e4..937d5b6075db060b98daa0f0fadbaa528bc85554:/include/wx/propgrid/property.h?ds=sidebyside diff --git a/include/wx/propgrid/property.h b/include/wx/propgrid/property.h index be9739e6fc..99027163b7 100644 --- a/include/wx/propgrid/property.h +++ b/include/wx/propgrid/property.h @@ -64,12 +64,12 @@ struct wxPGPaintData Base class for wxPropertyGrid cell renderers. */ -class WXDLLIMPEXP_PROPGRID wxPGCellRenderer +class WXDLLIMPEXP_PROPGRID wxPGCellRenderer : public wxObjectRefData { public: - wxPGCellRenderer( unsigned int refCount = 1 ) - : m_refCount(refCount) { } + wxPGCellRenderer() + : wxObjectRefData() { } virtual ~wxPGCellRenderer() { } // Render flags @@ -98,7 +98,11 @@ public: DontUseCellBgCol }; - virtual void Render( wxDC& dc, + /** + Returns @true if rendered something in the foreground (text or + bitmap. + */ + virtual bool Render( wxDC& dc, const wxRect& rect, const wxPropertyGrid* propertyGrid, wxPGProperty* property, @@ -137,30 +141,53 @@ public: wxPGProperty* property, const wxPGEditor* editor ) const; - /** Utility to render cell bitmap and set text colour plus bg brush colour. + /** Utility to render cell bitmap and set text colour plus bg brush + colour. - Returns image width that, for instance, can be passed to DrawText. + @return Returns image width, which, for instance, can be passed to + DrawText. */ int PreDrawCell( wxDC& dc, const wxRect& rect, const wxPGCell& cell, int flags ) const; - void IncRef() - { - m_refCount++; - } + /** + Utility to be called after drawing is done, to revert whatever + changes PreDrawCell() did. - void DecRef() - { - m_refCount--; - if ( !m_refCount ) - delete this; - } -protected: + @param flags + Same as those passed to PreDrawCell(). + */ + void PostDrawCell( wxDC& dc, + const wxPropertyGrid* propGrid, + const wxPGCell& cell, + int flags ) const; +}; -private: - unsigned int m_refCount; + +/** + @class wxPGDefaultRenderer + + Default cell renderer, that can handles the common + scenarios. +*/ +class WXDLLIMPEXP_PROPGRID wxPGDefaultRenderer : public wxPGCellRenderer +{ +public: + virtual bool Render( wxDC& dc, + const wxRect& rect, + const wxPropertyGrid* propertyGrid, + wxPGProperty* property, + int column, + int item, + int flags ) const; + + virtual wxSize GetImageSize( const wxPGProperty* property, + int column, + int item ) const; + +protected: }; @@ -178,6 +205,7 @@ public: void SetBitmap( const wxBitmap& bitmap ) { m_bitmap = bitmap; } void SetFgCol( const wxColour& col ) { m_fgCol = col; } void SetBgCol( const wxColour& col ) { m_bgCol = col; } + void SetFont( const wxFont& font ) { m_font = font; } protected: virtual ~wxPGCellData() { } @@ -186,14 +214,18 @@ protected: wxBitmap m_bitmap; wxColour m_fgCol; wxColour m_bgCol; + wxFont m_font; // True if m_text is valid and specified bool m_hasValidText; }; -/** @class wxPGCell +#endif // !SWIG + +/** + @class wxPGCell - Base class for simple wxPropertyGrid cell information. + Base class for wxPropertyGrid cell information. */ class WXDLLIMPEXP_PROPGRID wxPGCell : public wxObject { @@ -226,6 +258,11 @@ public: return (m_refData && GetData()->m_hasValidText); } + /** + Sets empty but valid data to this cell object. + */ + void SetEmptyData(); + /** Merges valid data from srcCell into this. */ @@ -234,11 +271,32 @@ public: void SetText( const wxString& text ); void SetBitmap( const wxBitmap& bitmap ); void SetFgCol( const wxColour& col ); + + /** + Sets font of the cell. + + @remarks Because wxPropertyGrid does not support rows of + different height, it makes little sense to change + size of the font. Therefore it is recommended + to use return value of wxPropertyGrid::GetFont() + or wxPropertyGrid::GetCaptionFont() as a basis + for the font that, after modifications, is passed + to this member function. + */ + void SetFont( const wxFont& font ); + void SetBgCol( const wxColour& col ); const wxString& GetText() const { return GetData()->m_text; } const wxBitmap& GetBitmap() const { return GetData()->m_bitmap; } const wxColour& GetFgCol() const { return GetData()->m_fgCol; } + + /** + Returns font of the cell. If no specific font is set for this + cell, then the font will be invalid. + */ + const wxFont& GetFont() const { return GetData()->m_font; } + const wxColour& GetBgCol() const { return GetData()->m_bgCol; } wxPGCell& operator=( const wxPGCell& other ) @@ -250,39 +308,17 @@ public: return *this; } -protected: +private: virtual wxObjectRefData *CreateRefData() const { return new wxPGCellData(); } virtual wxObjectRefData *CloneRefData(const wxObjectRefData *data) const; }; - -/** @class wxPGDefaultRenderer - - Default cell renderer, that can handles the common - scenarios. -*/ -class WXDLLIMPEXP_PROPGRID wxPGDefaultRenderer : public wxPGCellRenderer -{ -public: - virtual void Render( wxDC& dc, - const wxRect& rect, - const wxPropertyGrid* propertyGrid, - wxPGProperty* property, - int column, - int item, - int flags ) const; - - virtual wxSize GetImageSize( const wxPGProperty* property, - int column, - int item ) const; - -protected: -}; - // ----------------------------------------------------------------------- +#ifndef SWIG + /** @class wxPGAttributeStorage wxPGAttributeStorage is somewhat optimized storage for @@ -322,7 +358,7 @@ public: data->IncRef(); variant.SetData(data); variant.SetName(it->first); - it++; + ++it; return true; } @@ -451,7 +487,11 @@ wxPG_PROP_CLASS_SPECIFIC_1 = 0x00080000, /** Indicates the bit useable by derived properties. */ -wxPG_PROP_CLASS_SPECIFIC_2 = 0x00100000 +wxPG_PROP_CLASS_SPECIFIC_2 = 0x00100000, + +/** Indicates that the property is being deleted and should be ignored. +*/ +wxPG_PROP_BEING_DELETED = 0x00200000 }; @@ -510,18 +550,40 @@ wxPG_PROP_CLASS_SPECIFIC_2 = 0x00100000 */ #define wxPG_ATTR_UNITS wxS("Units") -/** Universal, string. When set, will be shown in property's value cell - when displayed value string is empty, or value is unspecified. +/** When set, will be shown as 'greyed' text in property's value cell when + the actual displayed value is blank. +*/ +#define wxPG_ATTR_HINT wxS("Hint") + +#if wxPG_COMPATIBILITY_1_4 +/** + @deprecated Use "Hint" (wxPG_ATTR_HINT) instead. */ #define wxPG_ATTR_INLINE_HELP wxS("InlineHelp") +#endif + +/** Universal, wxArrayString. Set to enable auto-completion in any + wxTextCtrl-based property editor. +*/ +#define wxPG_ATTR_AUTOCOMPLETE wxS("AutoComplete") -/** wxBoolProperty specific, int, default 0. When 1 sets bool property to - use checkbox instead of choice. +/** wxBoolProperty and wxFlagsProperty specific. Value type is bool. + Default value is False. + + When set to True, bool property will use check box instead of a + combo box as its editor control. If you set this attribute + for a wxFlagsProperty, it is automatically applied to child + bool properties. */ #define wxPG_BOOL_USE_CHECKBOX wxS("UseCheckbox") -/** wxBoolProperty specific, int, default 0. When 1 sets bool property value - to cycle on double click (instead of showing the popup listbox). +/** wxBoolProperty and wxFlagsProperty specific. Value type is bool. + Default value is False. + + Set to True for the bool property to cycle value on double click + (instead of showing the popup listbox). If you set this attribute + for a wxFlagsProperty, it is automatically applied to child + bool properties. */ #define wxPG_BOOL_USE_DOUBLE_CLICK_CYCLING wxS("UseDClickCycling") @@ -624,14 +686,20 @@ wxPG_PROP_CLASS_SPECIFIC_2 = 0x00100000 */ // Redefine attribute macros to use cached strings +#undef wxPG_ATTR_DEFAULT_VALUE +#define wxPG_ATTR_DEFAULT_VALUE wxPGGlobalVars->m_strDefaultValue #undef wxPG_ATTR_MIN #define wxPG_ATTR_MIN wxPGGlobalVars->m_strMin #undef wxPG_ATTR_MAX #define wxPG_ATTR_MAX wxPGGlobalVars->m_strMax #undef wxPG_ATTR_UNITS #define wxPG_ATTR_UNITS wxPGGlobalVars->m_strUnits +#undef wxPG_ATTR_HINT +#define wxPG_ATTR_HINT wxPGGlobalVars->m_strHint +#if wxPG_COMPATIBILITY_1_4 #undef wxPG_ATTR_INLINE_HELP #define wxPG_ATTR_INLINE_HELP wxPGGlobalVars->m_strInlineHelp +#endif #endif // !SWIG @@ -680,7 +748,7 @@ protected: typedef void* wxPGChoicesId; -class WXDLLIMPEXP_PROPGRID wxPGChoicesData +class WXDLLIMPEXP_PROPGRID wxPGChoicesData : public wxObjectRefData { friend class wxPGChoices; public: @@ -711,20 +779,9 @@ public: return m_items[i]; } - void DecRef() - { - m_refCount--; - wxASSERT( m_refCount >= 0 ); - if ( m_refCount == 0 ) - delete this; - } - private: wxVector m_items; - // So that multiple properties can use the same set - int m_refCount; - virtual ~wxPGChoicesData(); }; @@ -738,6 +795,11 @@ private: Each entry can have label, value, bitmap, text colour, and background colour. + wxPGChoices uses reference counting, similar to other wxWidgets classes. + This means that assignment operator and copy constructor only copy the + reference and not the actual data. Use Copy() member function to create a + real copy. + @remarks If you do not specify value for entry, index is used. @library{wxpropgrid} @@ -754,13 +816,16 @@ public: Init(); } - /** Copy constructor. */ + /** + Copy constructor, uses reference counting. To create a real copy, + use Copy() member function instead. + */ wxPGChoices( const wxPGChoices& a ) { if ( a.m_data != wxPGChoicesEmptyData ) { m_data = a.m_data; - m_data->m_refCount++; + m_data->IncRef(); } } @@ -773,7 +838,7 @@ public: @param values Values for choices. If NULL, indexes are used. */ - wxPGChoices( const wxChar** labels, const long* values = NULL ) + wxPGChoices( const wxChar* const* labels, const long* values = NULL ) { Init(); Set(labels,values); @@ -800,7 +865,7 @@ public: { wxASSERT(data); m_data = data; - data->m_refCount++; + data->IncRef(); } /** Destructor. */ @@ -821,7 +886,7 @@ public: @param values Values for added choices. If empty, relevant entry indexes are used. */ - void Add( const wxChar** labels, const ValArrItem* values = NULL ); + void Add( const wxChar* const* labels, const ValArrItem* values = NULL ); /** Version that works with wxArrayString and wxArrayInt. */ void Add( const wxArrayString& arr, const wxArrayInt& arrint = wxArrayInt() ); @@ -853,6 +918,10 @@ public: wxPGChoiceEntry& AddAsSorted( const wxString& label, int value = wxPG_INVALID_VALUE ); + /** + Assigns choices data, using reference counting. To create a real copy, + use Copy() member function instead. + */ void Assign( const wxPGChoices& a ) { AssignData(a.m_data); @@ -861,10 +930,17 @@ public: void AssignData( wxPGChoicesData* data ); /** Delete all choices. */ - void Clear() + void Clear(); + + /** + Returns a real copy of the choices. + */ + wxPGChoices Copy() const { - if ( m_data != wxPGChoicesEmptyData ) - m_data->Clear(); + wxPGChoices dst; + dst.EnsureData(); + dst.m_data->CopyDataFrom(m_data); + return dst; } void EnsureData() @@ -938,7 +1014,7 @@ public: #ifndef SWIG /** Does not create copies for itself. */ - void Set( const wxChar** labels, const long* values = NULL ) + void Set( const wxChar* const* labels, const long* values = NULL ) { Free(); Add(labels,values); @@ -957,22 +1033,13 @@ public: } // Creates exclusive copy of current choices - void SetExclusive() - { - if ( m_data->m_refCount != 1 ) - { - wxPGChoicesData* data = new wxPGChoicesData(); - data->CopyDataFrom(m_data); - Free(); - m_data = data; - } - } + void AllocExclusive(); // Returns data, increases refcount. wxPGChoicesData* GetData() { - wxASSERT( m_data->m_refCount != 0xFFFFFFF ); - m_data->m_refCount++; + wxASSERT( m_data->GetRefCount() != -1 ); + m_data->IncRef(); return m_data; } @@ -992,7 +1059,8 @@ public: #ifndef SWIG void operator= (const wxPGChoices& a) { - AssignData(a.m_data); + if (this != &a) + AssignData(a.m_data); } wxPGChoiceEntry& operator[](unsigned int i) @@ -1032,43 +1100,21 @@ class WXDLLIMPEXP_PROPGRID wxPGProperty : public wxObject friend class wxPropertyGridPageState; friend class wxPropertyGridPopulator; friend class wxStringProperty; // Proper "" support requires this -#ifndef SWIG + DECLARE_ABSTRACT_CLASS(wxPGProperty) -#endif public: typedef wxUint32 FlagType; - /** Basic constructor. + /** + Default constructor. */ wxPGProperty(); - /** Constructor. - Non-abstract property classes should have constructor of this style: - - @code - - // If T is a class, then it should be a constant reference - // (e.g. const T& ) instead. - MyProperty( const wxString& label, const wxString& name, T value ) - : wxPGProperty() - { - // Generally recommended way to set the initial value - // (as it should work in pretty much 100% of cases). - wxVariant variant; - variant << value; - SetValue(variant); - - // If has private child properties then create them here. Also - // set flag that indicates presence of private children. E.g.: - // - // SetParentalType(wxPG_PROP_AGGREGATE); - // - // AddChild( new wxStringProperty( "Subprop 1", - // wxPG_LABEL, - // value.GetSubProp1() ) ); - } + /** + Constructor. - @endcode + All non-abstract property classes should have a constructor with + the same first two arguments as this one. */ wxPGProperty( const wxString& label, const wxString& name ); @@ -1249,17 +1295,21 @@ public: wxEvent& event ); /** - Called after value of a child property has been altered. + Called after value of a child property has been altered. Must return + new value of the whole property (after any alterations warrented by + child's new value). Note that this function is usually called at the time that value of - this property, or given child property, is still pending for change. + this property, or given child property, is still pending for change, + and as such, result of GetValue() or m_value should not be relied + on. Sample pseudo-code implementation: @code - void MyProperty::ChildChanged( wxVariant& thisValue, - int childIndex, - wxVariant& childValue ) const + wxVariant MyProperty::ChildChanged( wxVariant& thisValue, + int childIndex, + wxVariant& childValue ) const { // Acquire reference to actual type of data stored in variant // (TFromVariant only exists if wxPropertyGrid's wxVariant-macros @@ -1277,19 +1327,28 @@ public: break; ... } + + // Return altered data + return data; } @endcode @param thisValue - Value of this property, that should be altered. + Value of this property. Changed value should be returned (in + previous versions of wxPropertyGrid it was only necessary to + write value back to this argument). @param childIndex - Index of child changed (you can use Item(childIndex) to get). + Index of child changed (you can use Item(childIndex) to get + child property). @param childValue - Value of the child property. + (Pending) value of the child property. + + @return + Modified value of the whole property. */ - virtual void ChildChanged( wxVariant& thisValue, - int childIndex, - wxVariant& childValue ) const; + virtual wxVariant ChildChanged( wxVariant& thisValue, + int childIndex, + wxVariant& childValue ) const; /** Returns pointer to an instance of used editor. */ @@ -1397,12 +1456,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 ); @@ -1422,6 +1485,15 @@ public: */ virtual wxPGEditorDialogAdapter* GetEditorDialog() const; + /** + Called whenever validation has failed with given pending value. + + @remarks If you implement this in your custom property class, please + remember to call the baser implementation as well, since they + may use it to revert property into pre-change state. + */ + virtual void OnValidationFailure( wxVariant& pendingValue ); + /** Append a new choice to property's list of choices. */ int AddChoice( const wxString& label, int value = wxPG_INVALID_VALUE ) @@ -1442,6 +1514,11 @@ public: return false; } + /** + Deletes children of the property. + */ + void DeleteChildren(); + /** Removes entry from property's wxPGChoices and editor control (if it is active). @@ -1502,7 +1579,6 @@ public: return DoGetValue(); } -#ifndef SWIG /** Returns reference to the internal stored value. GetValue is preferred way to get the actual value, since GetValueRef ignores DoGetValue, which may override stored value. @@ -1516,7 +1592,13 @@ public: { return m_value; } -#endif + + // Helper function (for wxPython bindings and such) for settings protected + // m_value. + wxVariant GetValuePlain() const + { + return m_value; + } /** Returns text representation of property's value. @@ -1544,14 +1626,27 @@ public: */ wxDEPRECATED( wxString GetValueString( int argFlags = 0 ) const ); - void UpdateControl( wxWindow* primary ); - /** Returns wxPGCell of given column. + + @remarks const version of this member function returns 'default' + wxPGCell object if the property itself didn't hold + cell data. */ const wxPGCell& GetCell( unsigned int column ) const; - wxPGCell& GetCell( unsigned int column ); + /** + Returns wxPGCell of given column, creating one if necessary. + */ + wxPGCell& GetCell( unsigned int column ) + { + return GetOrCreateCell(column); + } + + /** + Returns wxPGCell of given column, creating one if necessary. + */ + wxPGCell& GetOrCreateCell( unsigned int column ); /** Return number of displayed common values for this property. */ @@ -1562,6 +1657,11 @@ public: return GetValueAsString(0); } + /** + Returns property's hint text (shown in empty value cell). + */ + inline wxString GetHintText() const; + /** Returns property grid where property lies. */ wxPropertyGrid* GetGrid() const; @@ -1643,6 +1743,19 @@ public: */ bool HasVisibleChildren() const; + /** + Use this member function to add independent (ie. regular) children to + a property. + + @return Inserted childProperty. + + @remarks wxPropertyGrid is not automatically refreshed by this + function. + + @see AddPrivateChild() + */ + wxPGProperty* InsertChild( int index, wxPGProperty* childProperty ); + /** Inserts a new choice to property's list of choices. */ int InsertChoice( const wxString& label, int index, int value = wxPG_INVALID_VALUE ); @@ -1786,12 +1899,13 @@ public: @param colour Background colour to use. - @param recursively - If @true, children are affected recursively, and any categories - are not. + @param flags + Default is wxPG_RECURSE which causes colour to be set recursively. + Omit this flag to only set colour for the property in question + and not any of its children. */ void SetBackgroundColour( const wxColour& colour, - bool recursively = false ); + int flags = wxPG_RECURSE ); /** Sets property's text colour. @@ -1799,12 +1913,21 @@ public: @param colour Text colour to use. - @param recursively - If @true, children are affected recursively, and any categories - are not. + @param flags + Default is wxPG_RECURSE which causes colour to be set recursively. + Omit this flag to only set colour for the property in question + and not any of its children. */ void SetTextColour( const wxColour& colour, - bool recursively = false ); + int flags = wxPG_RECURSE ); + + /** Set default value of a property. Synonymous to + + @code + SetAttribute("DefaultValue", value); + @endcode + */ + void SetDefaultValue( wxVariant& value ); #ifndef SWIG /** Sets editor for a property. @@ -1874,26 +1997,21 @@ public: SetValueInEvent() instead. @param pList - Pointer to list variant that contains child values. Used to indicate - which children should be marked as modified. + Pointer to list variant that contains child values. Used to + indicate which children should be marked as modified. + @param flags - Various flags (for instance, wxPG_SETVAL_REFRESH_EDITOR). + Various flags (for instance, wxPG_SETVAL_REFRESH_EDITOR, which is + enabled by default). */ - void SetValue( wxVariant value, wxVariant* pList = NULL, int flags = 0 ); + void SetValue( wxVariant value, wxVariant* pList = NULL, + int flags = wxPG_SETVAL_REFRESH_EDITOR ); /** Set wxBitmap in front of the value. This bitmap may be ignored by custom cell renderers. */ void SetValueImage( wxBitmap& bmp ); - /** If property has choices and they are not yet exclusive, new such copy - of them will be created. - */ - void SetChoicesExclusive() - { - m_choices.SetExclusive(); - } - /** Sets selected choice and changes property value. Tries to retain value type, although currently if it is not string, @@ -1907,8 +2025,22 @@ public: else m_flags &= ~wxPG_PROP_COLLAPSED; } + /** + Sets given property flag(s). + */ void SetFlag( FlagType flag ) { m_flags |= flag; } + /** + Sets or clears given property flag(s). + */ + void ChangeFlag( FlagType flag, bool set ) + { + if ( set ) + m_flags |= flag; + else + m_flags &= ~flag; + } + void SetFlagRecursively( FlagType flag, bool set ); void SetHelpString( const wxString& helpString ) @@ -1918,22 +2050,18 @@ public: void SetLabel( const wxString& label ) { m_label = label; } - inline void SetName( const wxString& newName ); + void SetName( const wxString& newName ); /** Changes what sort of parent this property is for its children. @param flag - Use one of the following values: wxPG_PROP_MISC_PARENT (for generic - parents), wxPG_PROP_CATEGORY (for categories), or + Use one of the following values: wxPG_PROP_MISC_PARENT (for + generic parents), wxPG_PROP_CATEGORY (for categories), or wxPG_PROP_AGGREGATE (for derived property classes with private children). - @remarks You only need to call this if you use AddChild() to add - child properties. Adding properties with - wxPropertyGridInterface::Insert() or - wxPropertyGridInterface::AppendIn() will automatically set - property to use wxPG_PROP_MISC_PARENT style. + @remarks You generally do not need to call this function. */ void SetParentalType( int flag ) { @@ -1944,7 +2072,14 @@ public: void SetValueToUnspecified() { wxVariant val; // Create NULL variant - SetValue(val); + SetValue(val, NULL, wxPG_SETVAL_REFRESH_EDITOR); + } + + // Helper function (for wxPython bindings and such) for settings protected + // m_value. + void SetValuePlain( wxVariant value ) + { + m_value = value; } #if wxUSE_VALIDATORS @@ -1961,7 +2096,7 @@ public: return m_validator; return DoGetValidator(); } -#endif // #if wxUSE_VALIDATORS +#endif // wxUSE_VALIDATORS #ifndef SWIG /** Returns client data (void*) of a property. @@ -2029,24 +2164,33 @@ public: */ void AdaptListToValue( wxVariant& list, wxVariant* value ) const; +#if wxPG_COMPATIBILITY_1_4 /** - Adds a child property. If you use this instead of + Adds a private child property. + + @deprecated Use AddPrivateChild() instead. + + @see AddPrivateChild() + */ + wxDEPRECATED( void AddChild( wxPGProperty* prop ) ); +#endif + + /** + Adds a private child property. If you use this instead of wxPropertyGridInterface::Insert() or - wxPropertyGridInterface::AppendIn(), then you must set up - property's parental type before making the call. To do this, - call property's SetParentalType() function with either - wxPG_PROP_MISC_PARENT (normal, public children) or with - wxPG_PROP_AGGREGATE (private children for subclassed property). - For instance: + wxPropertyGridInterface::AppendIn(), then property's parental + type will automatically be set up to wxPG_PROP_AGGREGATE. In other + words, all properties of this property will become private. + */ + void AddPrivateChild( wxPGProperty* prop ); - @code - wxPGProperty* prop = new wxStringProperty(wxS("Property")); - prop->SetParentalType(wxPG_PROP_MISC_PARENT); - wxPGProperty* prop2 = new wxStringProperty(wxS("Property2")); - prop->AddChild(prop2); - @endcode + /** + Appends a new child property. */ - void AddChild( wxPGProperty* prop ); + wxPGProperty* AppendChild( wxPGProperty* prop ) + { + return InsertChild(-1, prop); + } /** Returns height of children, recursively, and by taking expanded/collapsed status into account. @@ -2072,53 +2216,33 @@ public: /** Returns index of given child property. */ int Index( const wxPGProperty* p ) const; - /** Deletes all sub-properties. */ - void Empty(); - // Puts correct indexes to children void FixIndicesOfChildren( unsigned int starthere = 0 ); + /** + Converts image width into full image offset, with margins. + */ + 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. + */ + wxPGProperty* GetItemAtY( unsigned int y ) const; /** Returns (direct) child property with given name (or NULL if not found). */ wxPGProperty* GetPropertyByName( const wxString& name ) const; -#ifdef SWIG - %extend { - DocStr(GetClientData, - "Returns the client data object for a property", ""); - PyObject* GetClientData() { - wxPyClientData* data = (wxPyClientData*)self->GetClientObject(); - if (data) { - Py_INCREF(data->m_obj); - return data->m_obj; - } else { - Py_INCREF(Py_None); - return Py_None; - } - } - - DocStr(SetClientData, - "Associate the given client data.", ""); - void SetClientData(PyObject* clientData) { - wxPyClientData* data = new wxPyClientData(clientData); - self->SetClientObject(data); - } - } - %pythoncode { - GetClientObject = GetClientData - SetClientObject = SetClientData - } -#endif - #ifndef SWIG // Returns various display-related information for given column @@ -2193,9 +2317,9 @@ protected: unsigned int hintIndex ) const; /** This is used by Insert etc. */ - void AddChild2( wxPGProperty* prop, - int index = -1, - bool correct_mode = true ); + void DoAddChild( wxPGProperty* prop, + int index = -1, + bool correct_mode = true ); void DoGenerateComposedValue( wxString& text, int argFlags = wxPG_VALUE_IS_CURRENT, @@ -2204,12 +2328,24 @@ protected: void DoSetName(const wxString& str) { m_name = str; } + /** Deletes all sub-properties. */ + void Empty(); + + bool HasCell( unsigned int column ) const + { + if ( m_cells.size() > column ) + return true; + return false; + } + void InitAfterAdded( wxPropertyGridPageState* pageState, wxPropertyGrid* propgrid ); // Removes child property with given pointer. Does not delete it. void RemoveChild( wxPGProperty* p ); + void DoPreAddChild( int index, wxPGProperty* prop ); + void SetParentState( wxPropertyGridPageState* pstate ) { m_parentState = pstate; } @@ -2322,7 +2458,7 @@ public: public: /** Constructor. */ - wxPGRootProperty(); + wxPGRootProperty( const wxString& name = wxS("") ); virtual ~wxPGRootProperty(); virtual bool StringToValue( wxVariant&, const wxString&, int ) const @@ -2355,9 +2491,10 @@ public: int GetTextExtent( const wxWindow* wnd, const wxFont& font ) const; -protected: virtual wxString ValueToString( wxVariant& value, int argFlags ) const; + virtual wxString GetValueAsString( int argFlags = 0 ) const; +protected: void SetTextColIndex( unsigned int colInd ) { m_capFgColIndex = (wxByte) colInd; } unsigned int GetTextColIndex() const