Declare array explicitly as a wxVector instead of using wxArrayPGProperty alias
This commit is contained in:
@@ -1572,8 +1572,8 @@ protected:
|
|||||||
wxPGCell m_unspecifiedAppearance;
|
wxPGCell m_unspecifiedAppearance;
|
||||||
|
|
||||||
// List of properties to be deleted/removed in idle event handler.
|
// List of properties to be deleted/removed in idle event handler.
|
||||||
wxArrayPGProperty m_deletedProperties;
|
wxVector<wxPGProperty*> m_deletedProperties;
|
||||||
wxArrayPGProperty m_removedProperties;
|
wxVector<wxPGProperty*> m_removedProperties;
|
||||||
|
|
||||||
#if !WXWIN_COMPATIBILITY_3_0
|
#if !WXWIN_COMPATIBILITY_3_0
|
||||||
// List of editors and their event handlers to be deleted in idle event handler.
|
// List of editors and their event handlers to be deleted in idle event handler.
|
||||||
@@ -2280,7 +2280,7 @@ public:
|
|||||||
// added.
|
// added.
|
||||||
wxPGProperty* GetCurParent() const
|
wxPGProperty* GetCurParent() const
|
||||||
{
|
{
|
||||||
return (wxPGProperty*) m_propHierarchy[m_propHierarchy.size()-1];
|
return m_propHierarchy.back();
|
||||||
}
|
}
|
||||||
|
|
||||||
wxPropertyGridPageState* GetState() { return m_state; }
|
wxPropertyGridPageState* GetState() { return m_state; }
|
||||||
@@ -2309,7 +2309,7 @@ protected:
|
|||||||
wxPropertyGridPageState* m_state;
|
wxPropertyGridPageState* m_state;
|
||||||
|
|
||||||
// Tree-hierarchy of added properties (that can have children).
|
// Tree-hierarchy of added properties (that can have children).
|
||||||
wxArrayPGProperty m_propHierarchy;
|
wxVector<wxPGProperty*> m_propHierarchy;
|
||||||
|
|
||||||
// Hashmap for string-id to wxPGChoicesData mapping.
|
// Hashmap for string-id to wxPGChoicesData mapping.
|
||||||
wxPGHashMapS2P m_dictIdChoices;
|
wxPGHashMapS2P m_dictIdChoices;
|
||||||
|
@@ -5588,17 +5588,20 @@ void wxPropertyGrid::ClearActionTriggers( int action )
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if WXWIN_COMPATIBILITY_3_0
|
#if WXWIN_COMPATIBILITY_3_0
|
||||||
// Utility to find if specific item is in a vector. Returns index to
|
// Utility to check if specific item is in a vector.
|
||||||
// the item, or wxNOT_FOUND if not present.
|
template<typename T>
|
||||||
template<typename CONTAINER, typename T>
|
static bool wxPGItemExistsInVector(const wxVector<T>& vector, const T& item)
|
||||||
int wxPGFindInVector( CONTAINER vector, const T& item )
|
|
||||||
{
|
{
|
||||||
for ( unsigned int i=0; i<vector.size(); i++ )
|
#if wxUSE_STL
|
||||||
|
return std::find(vector.begin(), vector.end(), item) != vector.end();
|
||||||
|
#else
|
||||||
|
for (wxVector<T>::const_iterator it = vector.begin(); it != vector.end(); ++it)
|
||||||
{
|
{
|
||||||
if ( vector[i] == item )
|
if ( *it == item )
|
||||||
return (int) i;
|
return true;
|
||||||
}
|
}
|
||||||
return wxNOT_FOUND;
|
return false;
|
||||||
|
#endif // wxUSE_STL/!wxUSE_STL
|
||||||
}
|
}
|
||||||
#endif // WXWIN_COMPATIBILITY_3_0
|
#endif // WXWIN_COMPATIBILITY_3_0
|
||||||
|
|
||||||
@@ -5706,7 +5709,7 @@ void wxPropertyGrid::HandleKeyEvent( wxKeyEvent &event, bool fromChild )
|
|||||||
if ( fromChild &&
|
if ( fromChild &&
|
||||||
#if WXWIN_COMPATIBILITY_3_0
|
#if WXWIN_COMPATIBILITY_3_0
|
||||||
// Deprecated: use a hash set instead.
|
// Deprecated: use a hash set instead.
|
||||||
wxPGFindInVector(m_dedicatedKeys, keycode) == wxNOT_FOUND )
|
!wxPGItemExistsInVector<int>(m_dedicatedKeys, keycode) )
|
||||||
#else
|
#else
|
||||||
m_dedicatedKeys.find(keycode) == m_dedicatedKeys.end() )
|
m_dedicatedKeys.find(keycode) == m_dedicatedKeys.end() )
|
||||||
#endif
|
#endif
|
||||||
@@ -6602,11 +6605,10 @@ bool wxPropertyGridPopulator::AddAttribute( const wxString& name,
|
|||||||
const wxString& type,
|
const wxString& type,
|
||||||
const wxString& value )
|
const wxString& value )
|
||||||
{
|
{
|
||||||
int l = m_propHierarchy.size();
|
if ( m_propHierarchy.empty() )
|
||||||
if ( !l )
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
wxPGProperty* p = m_propHierarchy[l-1];
|
wxPGProperty* p = m_propHierarchy.back();
|
||||||
wxString valuel = value.Lower();
|
wxString valuel = value.Lower();
|
||||||
wxVariant variant;
|
wxVariant variant;
|
||||||
|
|
||||||
|
@@ -43,6 +43,43 @@
|
|||||||
|
|
||||||
#define wxPG_DEFAULT_SPLITTERX 110
|
#define wxPG_DEFAULT_SPLITTERX 110
|
||||||
|
|
||||||
|
// Utility to remove given item from the vector.
|
||||||
|
template<typename T>
|
||||||
|
static void wxPGRemoveItemFromVector(wxVector<T>& vector, const T& item)
|
||||||
|
{
|
||||||
|
#if wxUSE_STL
|
||||||
|
wxVector<T>::iterator it = std::find(vector.begin(), vector.end(), item);
|
||||||
|
if ( it != vector.end() )
|
||||||
|
{
|
||||||
|
vector.erase(it);
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
for (wxVector<T>::iterator it = vector.begin(); it != vector.end(); ++it)
|
||||||
|
{
|
||||||
|
if ( *it == item )
|
||||||
|
{
|
||||||
|
vector.erase(it);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif // wxUSE_STL/!wxUSE_STL
|
||||||
|
}
|
||||||
|
|
||||||
|
// Utility to check if specific item is in a vector.
|
||||||
|
template<typename T>
|
||||||
|
static bool wxPGItemExistsInVector(const wxVector<T>& vector, const T& item)
|
||||||
|
{
|
||||||
|
#if wxUSE_STL
|
||||||
|
return std::find(vector.begin(), vector.end(), item) != vector.end();
|
||||||
|
#else
|
||||||
|
for (wxVector<T>::const_iterator it = vector.begin(); it != vector.end(); ++it)
|
||||||
|
{
|
||||||
|
if ( *it == item )
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
#endif // wxUSE_STL/!wxUSE_STL
|
||||||
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------
|
// -----------------------------------------------------------------------
|
||||||
// wxPropertyGridIterator
|
// wxPropertyGridIterator
|
||||||
@@ -303,16 +340,8 @@ void wxPropertyGridPageState::DoClear()
|
|||||||
for (unsigned int i = 0; i < m_regularArray.GetChildCount(); i++)
|
for (unsigned int i = 0; i < m_regularArray.GetChildCount(); i++)
|
||||||
{
|
{
|
||||||
wxPGProperty* p = m_regularArray.Item(i);
|
wxPGProperty* p = m_regularArray.Item(i);
|
||||||
int index = m_pPropGrid->m_deletedProperties.Index(p);
|
wxPGRemoveItemFromVector<wxPGProperty*>(m_pPropGrid->m_deletedProperties, p);
|
||||||
if (index != wxNOT_FOUND)
|
wxPGRemoveItemFromVector<wxPGProperty*>(m_pPropGrid->m_removedProperties, p);
|
||||||
{
|
|
||||||
m_pPropGrid->m_deletedProperties.RemoveAt(index);
|
|
||||||
}
|
|
||||||
index = m_pPropGrid->m_removedProperties.Index(p);
|
|
||||||
if (index != wxNOT_FOUND)
|
|
||||||
{
|
|
||||||
m_pPropGrid->m_removedProperties.RemoveAt(index);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
m_regularArray.Empty();
|
m_regularArray.Empty();
|
||||||
@@ -2004,14 +2033,14 @@ void wxPropertyGridPageState::DoDelete( wxPGProperty* item, bool doDelete )
|
|||||||
// Prevent adding duplicates to the lists.
|
// Prevent adding duplicates to the lists.
|
||||||
if ( doDelete )
|
if ( doDelete )
|
||||||
{
|
{
|
||||||
if ( pg->m_deletedProperties.Index(item) != wxNOT_FOUND )
|
if ( wxPGItemExistsInVector<wxPGProperty*>(pg->m_deletedProperties, item) )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
pg->m_deletedProperties.push_back(item);
|
pg->m_deletedProperties.push_back(item);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ( pg->m_removedProperties.Index(item) != wxNOT_FOUND )
|
if ( wxPGItemExistsInVector<wxPGProperty*>(pg->m_removedProperties, item) )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
pg->m_removedProperties.push_back(item);
|
pg->m_removedProperties.push_back(item);
|
||||||
@@ -2112,20 +2141,12 @@ void wxPropertyGridPageState::DoDelete( wxPGProperty* item, bool doDelete )
|
|||||||
{
|
{
|
||||||
// Remove the item from both lists of pending operations.
|
// Remove the item from both lists of pending operations.
|
||||||
// (Deleted item cannot be also the subject of further removal.)
|
// (Deleted item cannot be also the subject of further removal.)
|
||||||
int index = pg->m_deletedProperties.Index(item);
|
wxPGRemoveItemFromVector<wxPGProperty*>(pg->m_deletedProperties, item);
|
||||||
if ( index != wxNOT_FOUND )
|
wxASSERT_MSG( !wxPGItemExistsInVector<wxPGProperty*>(pg->m_deletedProperties, item),
|
||||||
{
|
|
||||||
pg->m_deletedProperties.RemoveAt(index);
|
|
||||||
}
|
|
||||||
wxASSERT_MSG( pg->m_deletedProperties.Index(item) == wxNOT_FOUND,
|
|
||||||
wxS("Too many occurrences of the item"));
|
wxS("Too many occurrences of the item"));
|
||||||
|
|
||||||
index = pg->m_removedProperties.Index(item);
|
wxPGRemoveItemFromVector<wxPGProperty*>(pg->m_removedProperties, item);
|
||||||
if ( index != wxNOT_FOUND )
|
wxASSERT_MSG( !wxPGItemExistsInVector<wxPGProperty*>(pg->m_removedProperties, item),
|
||||||
{
|
|
||||||
pg->m_removedProperties.RemoveAt(index);
|
|
||||||
}
|
|
||||||
wxASSERT_MSG( pg->m_removedProperties.Index(item) == wxNOT_FOUND,
|
|
||||||
wxS("Too many occurrences of the item"));
|
wxS("Too many occurrences of the item"));
|
||||||
|
|
||||||
delete item;
|
delete item;
|
||||||
@@ -2133,12 +2154,8 @@ void wxPropertyGridPageState::DoDelete( wxPGProperty* item, bool doDelete )
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Remove the item from the list of pending removals.
|
// Remove the item from the list of pending removals.
|
||||||
int index = pg->m_removedProperties.Index(item);
|
wxPGRemoveItemFromVector<wxPGProperty*>(pg->m_removedProperties, item);
|
||||||
if ( index != wxNOT_FOUND )
|
wxASSERT_MSG( !wxPGItemExistsInVector<wxPGProperty*>(pg->m_removedProperties, item),
|
||||||
{
|
|
||||||
pg->m_removedProperties.RemoveAt(index);
|
|
||||||
}
|
|
||||||
wxASSERT_MSG( pg->m_removedProperties.Index(item) == wxNOT_FOUND,
|
|
||||||
wxS("Too many occurrences of the item"));
|
wxS("Too many occurrences of the item"));
|
||||||
|
|
||||||
item->OnDetached(this, pg);
|
item->OnDetached(this, pg);
|
||||||
|
Reference in New Issue
Block a user