From 502ede23ab8ce5756840cfbb750e2787229bf11c Mon Sep 17 00:00:00 2001 From: Artur Wieczorek Date: Fri, 27 May 2022 18:37:46 +0200 Subject: [PATCH] Don't expose internal wxPropertyGridPageState functions Functions designed for internal use shouldn't be exposed as public ones to avoid calling them directly from the user code by mistake. --- docs/changes.txt | 4 + include/wx/propgrid/propgridpagestate.h | 154 +++++++++++----------- interface/wx/propgrid/propgridpagestate.h | 67 +--------- samples/propgrid/tests.cpp | 2 +- 4 files changed, 85 insertions(+), 142 deletions(-) diff --git a/docs/changes.txt b/docs/changes.txt index cbc267d63b..0c7f84305b 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -240,6 +240,10 @@ INCOMPATIBLE CHANGES SINCE 3.1.6: They were not intended for the public API. m_image variable represents cached image now. +- wxPropertyGridPageState funtions intended for internal use are no longer + public. Corresponding functions in wxPropertyGridInterface, wxPropertyGrid, + wxPropertyGridPage, and wxPropertyGridManager should be used instead. + NOTE: This file is updated only before the release, please use diff --git a/include/wx/propgrid/propgridpagestate.h b/include/wx/propgrid/propgridpagestate.h index c6816de859..75ce1d257b 100644 --- a/include/wx/propgrid/propgridpagestate.h +++ b/include/wx/propgrid/propgridpagestate.h @@ -332,6 +332,9 @@ class WXDLLIMPEXP_PROPGRID wxPropertyGridPageState friend class wxPropertyGridInterface; friend class wxPropertyGridPage; friend class wxPropertyGridManager; + friend class wxPGProperty; + friend class wxFlagsProperty; + friend class wxPropertyGridIteratorBase; public: // Default constructor. @@ -347,10 +350,6 @@ public: // deletion. virtual void DoDelete( wxPGProperty* item, bool doDelete = true ); - wxSize DoFitColumns( bool allowGridResize = false ); - - wxPGProperty* DoGetItemAtY( int y ) const; - // Override this member function to add custom behaviour on property // insertion. virtual wxPGProperty* DoInsert( wxPGProperty* parent, @@ -421,27 +420,6 @@ public: return m_selection.empty()? NULL: m_selection[0]; } - void DoSetSelection( wxPGProperty* prop ) - { - m_selection.clear(); - if ( prop ) - m_selection.push_back(prop); - } - - bool DoClearSelection() - { - return DoSelectProperty(NULL); - } - - void DoRemoveFromSelection( wxPGProperty* prop ); - - void DoSetColumnProportion( unsigned int column, int proportion ); - - int DoGetColumnProportion( unsigned int column ) const - { - return m_columnProportions[column]; - } - void ResetColumnSizes( int setSplitterFlags ); wxPropertyCategory* GetPropertyCategory( const wxPGProperty* p ) const; @@ -452,14 +430,6 @@ public: wxPGProperty* parent = NULL ) const; #endif // WXWIN_COMPATIBILITY_3_0 - wxVariant DoGetPropertyValues( const wxString& listname, - wxPGProperty* baseparent, - long flags ) const; - - wxPGProperty* DoGetRoot() const { return m_properties; } - - void DoSetPropertyName( wxPGProperty* p, const wxString& newName ); - // Returns combined width of margin and all the columns int GetVirtualWidth() const { @@ -487,18 +457,6 @@ public: bool IsInNonCatMode() const { return m_properties == m_abcArray; } - void DoLimitPropertyEditing( wxPGProperty* p, bool limit = true ) - { - p->SetFlagRecursively(wxPG_PROP_NOEDITOR, limit); - } - - bool DoSelectProperty( wxPGProperty* p, unsigned int flags = 0 ); - - // widthChange is non-client. - void OnClientWidthChange( int newWidth, - int widthChange, - bool fromOnResize = false ); - // Recalculates m_virtualHeight. void RecalculateVirtualHeight() { @@ -507,26 +465,11 @@ public: void SetColumnCount( int colCount ); - void PropagateColSizeDec( int column, int decrease, int dir ); - - bool DoHideProperty( wxPGProperty* p, bool hide, int flags = wxPG_RECURSE ); - - bool DoSetPropertyValueString( wxPGProperty* p, const wxString& value ); - - bool DoSetPropertyValue( wxPGProperty* p, wxVariant& value ); - - bool DoSetPropertyValueWxObjectPtr( wxPGProperty* p, wxObject* value ); - void DoSetPropertyValues( const wxVariantList& list, - wxPGProperty* default_category ); - void SetSplitterLeft( bool subProps = false ); // Set virtual width for this particular page. void SetVirtualWidth( int width ); - void DoSortChildren( wxPGProperty* p, int flags = 0 ); - void DoSort( int flags = 0 ); - bool PrepareAfterItemsAdded(); // Called after virtual height needs to be recalculated. @@ -535,24 +478,39 @@ public: m_vhCalcPending = true; } - // Base append. - wxPGProperty* DoAppend( wxPGProperty* property ); - - // Returns property by its name. - wxPGProperty* BaseGetPropertyByName( const wxString& name ) const; - - // Called in, for example, wxPropertyGrid::Clear. - void DoClear(); - - bool DoIsPropertySelected( wxPGProperty* prop ) const; - - bool DoCollapse( wxPGProperty* p ); - - bool DoExpand( wxPGProperty* p ); - - void CalculateFontAndBitmapStuff( int vspacing ); - protected: + wxSize DoFitColumns(bool allowGridResize = false); + + wxPGProperty* DoGetItemAtY(int y) const; + + void DoSetSelection(wxPGProperty* prop) + { + m_selection.clear(); + if (prop) + m_selection.push_back(prop); + } + + bool DoClearSelection() + { + return DoSelectProperty(NULL); + } + + void DoRemoveFromSelection(wxPGProperty* prop); + + void DoSetColumnProportion(unsigned int column, int proportion); + + int DoGetColumnProportion(unsigned int column) const + { + return m_columnProportions[column]; + } + + wxVariant DoGetPropertyValues(const wxString& listname, + wxPGProperty* baseparent, + long flags) const; + + wxPGProperty* DoGetRoot() const { return m_properties; } + + void DoSetPropertyName(wxPGProperty* p, const wxString& newName); // Utility to check if two properties are visibly next to each other bool ArePropertiesAdjacent( wxPGProperty* prop1, @@ -561,6 +519,25 @@ protected: int DoGetSplitterPosition( int splitterIndex = 0 ) const; + void DoLimitPropertyEditing(wxPGProperty* p, bool limit = true) + { + p->SetFlagRecursively(wxPG_PROP_NOEDITOR, limit); + } + + bool DoSelectProperty(wxPGProperty* p, unsigned int flags = 0); + + // Base append. + wxPGProperty* DoAppend(wxPGProperty* property); + + // Called in, for example, wxPropertyGrid::Clear. + void DoClear(); + + bool DoIsPropertySelected(wxPGProperty* prop) const; + + bool DoCollapse(wxPGProperty* p); + + bool DoExpand(wxPGProperty* p); + // Returns column at x coordinate (in GetGrid()->GetPanel()). // pSplitterHit - Give pointer to int that receives index to splitter that is at x. // pSplitterHitOffset - Distance from said splitter. @@ -588,10 +565,33 @@ protected: // so it won't remain in the way of the user code. void DoInvalidateChildrenNames(wxPGProperty* p, bool recursive); + bool DoHideProperty(wxPGProperty* p, bool hide, int flags = wxPG_RECURSE); + + bool DoSetPropertyValueString(wxPGProperty* p, const wxString& value); + + bool DoSetPropertyValue(wxPGProperty* p, wxVariant& value); + + bool DoSetPropertyValueWxObjectPtr(wxPGProperty* p, wxObject* value); + void DoSetPropertyValues(const wxVariantList& list, + wxPGProperty* default_category); + + void DoSortChildren(wxPGProperty* p, int flags = 0); + void DoSort(int flags = 0); + + // widthChange is non-client. + void OnClientWidthChange(int newWidth, int widthChange, bool fromOnResize = false); + // Check if property contains given sub-category. bool IsChildCategory(wxPGProperty* p, wxPropertyCategory* cat, bool recursive); + void PropagateColSizeDec(int column, int decrease, int dir); + + void CalculateFontAndBitmapStuff(int vspacing); + + // Returns property by its name. + wxPGProperty* BaseGetPropertyByName(const wxString& name) const; + // If visible, then this is pointer to wxPropertyGrid. // This shall *never* be NULL to indicate that this state is not visible. wxPropertyGrid* m_pPropGrid; diff --git a/interface/wx/propgrid/propgridpagestate.h b/interface/wx/propgrid/propgridpagestate.h index 46cb5341d4..377ef7565d 100644 --- a/interface/wx/propgrid/propgridpagestate.h +++ b/interface/wx/propgrid/propgridpagestate.h @@ -309,6 +309,9 @@ class wxPropertyGridPageState friend class wxPropertyGridInterface; friend class wxPropertyGridPage; friend class wxPropertyGridManager; + friend class wxPGProperty; + friend class wxFlagsProperty; + friend class wxPropertyGridIteratorBase; public: /** @@ -332,10 +335,6 @@ public: */ virtual void DoDelete( wxPGProperty* item, bool doDelete = true ); - wxSize DoFitColumns( bool allowGridResize = false ); - - wxPGProperty* DoGetItemAtY( int y ) const; - /** Override this member function to add custom behaviour on property insertion. @@ -398,28 +397,10 @@ public: */ wxPGProperty* GetSelection() const; - void DoSetSelection( wxPGProperty* prop ); - - bool DoClearSelection(); - - void DoRemoveFromSelection( wxPGProperty* prop ); - - void DoSetColumnProportion( unsigned int column, int proportion ); - - int DoGetColumnProportion( unsigned int column ) const; - void ResetColumnSizes( int setSplitterFlags ); wxPropertyCategory* GetPropertyCategory( const wxPGProperty* p ) const; - wxVariant DoGetPropertyValues( const wxString& listname, - wxPGProperty* baseparent, - long flags ) const; - - wxPGProperty* DoGetRoot() const; - - void DoSetPropertyName( wxPGProperty* p, const wxString& newName ); - /** Returns combined width of margin and all the columns. */ @@ -455,10 +436,6 @@ public: bool IsInNonCatMode() const; - void DoLimitPropertyEditing( wxPGProperty* p, bool limit = true ); - - bool DoSelectProperty( wxPGProperty* p, unsigned int flags = 0 ); - /** widthChange is non-client. */ @@ -473,18 +450,6 @@ public: void SetColumnCount( int colCount ); - void PropagateColSizeDec( int column, int decrease, int dir ); - - bool DoHideProperty( wxPGProperty* p, bool hide, int flags = wxPG_RECURSE ); - - bool DoSetPropertyValueString( wxPGProperty* p, const wxString& value ); - - bool DoSetPropertyValue( wxPGProperty* p, wxVariant& value ); - - bool DoSetPropertyValueWxObjectPtr( wxPGProperty* p, wxObject* value ); - void DoSetPropertyValues( const wxVariantList& list, - wxPGProperty* default_category ); - void SetSplitterLeft( bool subProps = false ); /** @@ -492,36 +457,10 @@ public: */ void SetVirtualWidth( int width ); - void DoSortChildren( wxPGProperty* p, int flags = 0 ); - void DoSort( int flags = 0 ); - bool PrepareAfterItemsAdded(); /** Called after virtual height needs to be recalculated. */ void VirtualHeightChanged(); - - /** - Base append. - */ - wxPGProperty* DoAppend( wxPGProperty* property ); - - /** - Returns property by its name. - */ - wxPGProperty* BaseGetPropertyByName( const wxString& name ) const; - - /** - Called in, for example, wxPropertyGrid::Clear. - */ - void DoClear(); - - bool DoIsPropertySelected( wxPGProperty* prop ) const; - - bool DoCollapse( wxPGProperty* p ); - - bool DoExpand( wxPGProperty* p ); - - void CalculateFontAndBitmapStuff( int vspacing ); }; diff --git a/samples/propgrid/tests.cpp b/samples/propgrid/tests.cpp index cb921c2148..da9995e8f6 100644 --- a/samples/propgrid/tests.cpp +++ b/samples/propgrid/tests.cpp @@ -413,7 +413,7 @@ bool FormMain::RunTests( bool fullTest, bool interactive ) it.Next() ) { wxPGProperty* p = it.GetProperty(); - if ( (p->GetParent() != p->GetParentState()->DoGetRoot() && !p->GetParent()->IsExpanded()) ) + if ( (p->GetParent() != p->GetGrid()->GetRoot() && !p->GetParent()->IsExpanded()) ) RT_FAILURE_MSG(wxString::Format("'%s' had collapsed parent (only visible properties expected)",p->GetLabel())) else if ( p->HasFlag(wxPG_PROP_HIDDEN) ) RT_FAILURE_MSG(wxString::Format("'%s' was hidden (only visible properties expected)",p->GetLabel()))