Use standard container to store dedicated keys in wxPropertyGrid

Dedicated keys can be stored in std::unordered_set
instead of wxPGHashSetInt.
This commit is contained in:
Artur Wieczorek 2023-01-06 17:50:23 +02:00
parent 959ebb2fcb
commit 6d9e362b1f
3 changed files with 3 additions and 40 deletions

View file

@ -23,6 +23,7 @@
#include "wx/propgrid/propgridiface.h"
#include <unordered_map>
#include <unordered_set>
#ifndef SWIG
extern WXDLLIMPEXP_DATA_PROPGRID(const char) wxPropertyGridNameStr[];
@ -667,12 +668,7 @@ public:
// control.
void DedicateKey( int keycode )
{
#if WXWIN_COMPATIBILITY_3_0
// Deprecated: use a hash set instead.
m_dedicatedKeys.push_back(keycode);
#else
m_dedicatedKeys.insert(keycode);
#endif
}
// This static function enables or disables automatic use of
@ -1543,12 +1539,7 @@ protected:
#endif
// List of key codes that will not be handed over to editor controls.
#if WXWIN_COMPATIBILITY_3_0
// Deprecated: use a hash set instead.
wxVector<int> m_dedicatedKeys;
#else
wxPGHashSetInt m_dedicatedKeys;
#endif
std::unordered_set<int> m_dedicatedKeys;
//
// Temporary values

View file

@ -274,12 +274,6 @@ WX_DECLARE_STRING_HASH_MAP_WITH_DECL(wxString,
wxPGHashMapS2S,
class WXDLLIMPEXP_PROPGRID);
WX_DECLARE_HASH_SET_WITH_DECL(int,
wxIntegerHash,
wxIntegerEqual,
wxPGHashSetInt,
class WXDLLIMPEXP_PROPGRID);
#if WXWIN_COMPATIBILITY_3_0
WX_DEFINE_TYPEARRAY_WITH_DECL_PTR(wxObject*, wxArrayPGObject,
wxBaseArrayPtrVoid,
@ -676,22 +670,6 @@ protected:
// -----------------------------------------------------------------------
// wxVector utilities
// Utility to check if specific item is in a vector.
template<typename T>
inline bool wxPGItemExistsInVector(const wxVector<T>& vector, const T& item)
{
#if wxUSE_STL
return std::find(vector.begin(), vector.end(), item) != vector.end();
#else
for (typename wxVector<T>::const_iterator it = vector.begin(); it != vector.end(); ++it)
{
if ( *it == item )
return true;
}
return false;
#endif // wxUSE_STL/!wxUSE_STL
}
// Utility to determine the index of the item in the vector.
template<typename T>
inline int wxPGItemIndexInVector(const wxVector<T>& vector, const T& item)

View file

@ -5676,13 +5676,7 @@ void wxPropertyGrid::HandleKeyEvent( wxKeyEvent &event, bool fromChild )
// Except for TAB, ESC, and any keys specifically dedicated to
// wxPropertyGrid itself, handle child control events in child control.
if ( fromChild &&
#if WXWIN_COMPATIBILITY_3_0
// Deprecated: use a hash set instead.
!wxPGItemExistsInVector<int>(m_dedicatedKeys, keycode) )
#else
m_dedicatedKeys.find(keycode) == m_dedicatedKeys.end() )
#endif
if ( fromChild && m_dedicatedKeys.count(keycode) == 0 )
{
// Only propagate event if it had modifiers
if ( !event.HasModifiers() )