Use std::vector instead of wxVector in wxPropertyGrid
This commit is contained in:
parent
842ca1e8b8
commit
4c463c416d
11 changed files with 39 additions and 87 deletions
|
|
@ -17,6 +17,8 @@
|
|||
|
||||
#include "wx/window.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
class WXDLLIMPEXP_FWD_CORE wxBitmapBundle;
|
||||
class WXDLLIMPEXP_FWD_PROPGRID wxPGCell;
|
||||
class WXDLLIMPEXP_FWD_PROPGRID wxPGProperty;
|
||||
|
|
@ -488,7 +490,7 @@ protected:
|
|||
|
||||
int GenId( int id ) const;
|
||||
|
||||
wxVector<wxWindow*> m_buttons;
|
||||
std::vector<wxWindow*> m_buttons;
|
||||
wxSize m_fullEditorSize;
|
||||
int m_buttonsWidth;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -17,6 +17,8 @@
|
|||
|
||||
#include "wx/propgrid/propgrid.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
#ifndef SWIG
|
||||
|
|
@ -536,7 +538,7 @@ protected:
|
|||
|
||||
wxPropertyGrid* m_pPropGrid;
|
||||
|
||||
wxVector<wxPropertyGridPage*> m_arrPages;
|
||||
std::vector<wxPropertyGridPage*> m_arrPages;
|
||||
|
||||
#if wxUSE_TOOLBAR
|
||||
wxToolBar* m_pToolbar;
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@
|
|||
#include "wx/validate.h"
|
||||
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
|
|
@ -664,7 +665,7 @@ public:
|
|||
}
|
||||
|
||||
private:
|
||||
wxVector<wxPGChoiceEntry> m_items;
|
||||
std::vector<wxPGChoiceEntry> m_items;
|
||||
|
||||
protected:
|
||||
virtual ~wxPGChoicesData();
|
||||
|
|
@ -1990,10 +1991,10 @@ protected:
|
|||
|
||||
wxVariant m_value;
|
||||
wxPGAttributeStorage m_attributes;
|
||||
wxVector<wxPGProperty*> m_children;
|
||||
std::vector<wxPGProperty*> m_children;
|
||||
|
||||
// Extended cell information
|
||||
wxVector<wxPGCell> m_cells;
|
||||
std::vector<wxPGCell> m_cells;
|
||||
|
||||
// Choices shown in drop-down list of editor control.
|
||||
wxPGChoices m_choices;
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@
|
|||
|
||||
#include <unordered_map>
|
||||
#include <unordered_set>
|
||||
#include <vector>
|
||||
|
||||
#ifndef SWIG
|
||||
extern WXDLLIMPEXP_DATA_PROPGRID(const char) wxPropertyGridNameStr[];
|
||||
|
|
@ -62,7 +63,7 @@ public:
|
|||
std::unordered_map<wxString, wxPGEditor*> m_mapEditorClasses;
|
||||
|
||||
#if wxUSE_VALIDATORS
|
||||
wxVector<wxValidator*> m_arrValidators; // These wxValidators need to be freed
|
||||
std::vector<wxValidator*> m_arrValidators; // These wxValidators need to be freed
|
||||
#endif
|
||||
|
||||
wxPGChoices* m_fontFamilyChoices;
|
||||
|
|
@ -1560,7 +1561,7 @@ protected:
|
|||
|
||||
#if !WXWIN_COMPATIBILITY_3_0
|
||||
// List of editors and their event handlers to be deleted in idle event handler.
|
||||
wxVector<wxObject*> m_deletedEditorObjects;
|
||||
std::vector<wxObject*> m_deletedEditorObjects;
|
||||
#endif
|
||||
|
||||
// List of key codes that will not be handed over to editor controls.
|
||||
|
|
@ -1678,15 +1679,15 @@ protected:
|
|||
wxPGCell m_categoryDefaultCell;
|
||||
|
||||
// Backup of selected property's cells
|
||||
wxVector<wxPGCell> m_propCellsBackup;
|
||||
std::vector<wxPGCell> m_propCellsBackup;
|
||||
|
||||
// NB: These *cannot* be moved to globals.
|
||||
|
||||
// labels when properties use common values
|
||||
wxVector<wxPGCommonValue*> m_commonValues;
|
||||
std::vector<wxPGCommonValue*> m_commonValues;
|
||||
|
||||
// array of live events
|
||||
wxVector<wxPropertyGridEvent*> m_liveEvents;
|
||||
std::vector<wxPropertyGridEvent*> m_liveEvents;
|
||||
|
||||
// Which cv selection really sets value to unspecified?
|
||||
int m_cvUnspecified;
|
||||
|
|
@ -2215,7 +2216,7 @@ protected:
|
|||
wxPropertyGridPageState* m_state;
|
||||
|
||||
// Tree-hierarchy of added properties (that can have children).
|
||||
wxVector<wxPGProperty*> m_propHierarchy;
|
||||
std::vector<wxPGProperty*> m_propHierarchy;
|
||||
|
||||
// Hashmap for string-id to wxPGChoicesData mapping.
|
||||
std::unordered_map<wxString, wxPGChoicesData*> m_dictIdChoices;
|
||||
|
|
|
|||
|
|
@ -667,67 +667,6 @@ protected:
|
|||
#define WX_PG_TOKENIZER2_END() \
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
// wxVector utilities
|
||||
|
||||
// Utility to determine the index of the item in the vector.
|
||||
template<typename T>
|
||||
inline int wxPGItemIndexInVector(const wxVector<T>& vector, const T& item)
|
||||
{
|
||||
#if wxUSE_STL
|
||||
typename wxVector<T>::const_iterator it = std::find(vector.begin(), vector.end(), item);
|
||||
if ( it != vector.end() )
|
||||
return (int)(it - vector.begin());
|
||||
|
||||
return wxNOT_FOUND;
|
||||
#else
|
||||
for (typename wxVector<T>::const_iterator it = vector.begin(); it != vector.end(); ++it)
|
||||
{
|
||||
if ( *it == item )
|
||||
return (int)(it - vector.begin());
|
||||
}
|
||||
return wxNOT_FOUND;
|
||||
#endif // wxUSE_STL/!wxUSE_STL
|
||||
}
|
||||
|
||||
// Utility to remove given item from the vector.
|
||||
template<typename T>
|
||||
inline void wxPGRemoveItemFromVector(wxVector<T>& vector, const T& item)
|
||||
{
|
||||
#if wxUSE_STL
|
||||
typename wxVector<T>::iterator it = std::find(vector.begin(), vector.end(), item);
|
||||
if ( it != vector.end() )
|
||||
{
|
||||
vector.erase(it);
|
||||
}
|
||||
#else
|
||||
for (typename wxVector<T>::iterator it = vector.begin(); it != vector.end(); ++it)
|
||||
{
|
||||
if ( *it == item )
|
||||
{
|
||||
vector.erase(it);
|
||||
return;
|
||||
}
|
||||
}
|
||||
#endif // wxUSE_STL/!wxUSE_STL
|
||||
}
|
||||
|
||||
// Utility to calaculate sum of all elements of the vector.
|
||||
template<typename T>
|
||||
inline T wxPGGetSumVectorItems(const wxVector<T>& vector, T init)
|
||||
{
|
||||
#if wxUSE_STD_CONTAINERS
|
||||
return std::accumulate(vector.begin(), vector.end(), init);
|
||||
#else
|
||||
for (typename wxVector<T>::const_iterator it = vector.begin(); it != vector.end(); ++it)
|
||||
init += *it;
|
||||
|
||||
return init;
|
||||
#endif // wxUSE_STD_CONTAINERS/!wxUSE_STD_CONTAINERS
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
#endif // wxUSE_PROPGRID
|
||||
|
||||
#endif // _WX_PROPGRID_PROPGRIDDEFS_H_
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@
|
|||
|
||||
#include <set>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
|
|
@ -614,13 +615,13 @@ protected:
|
|||
std::unordered_map<wxString, wxPGProperty*> m_dictName;
|
||||
|
||||
// List of column widths (first column does not include margin).
|
||||
wxVector<int> m_colWidths;
|
||||
std::vector<int> m_colWidths;
|
||||
|
||||
// List of indices of columns the user can edit by clicking it.
|
||||
std::set<unsigned int> m_editableColumns;
|
||||
|
||||
// Column proportions.
|
||||
wxVector<int> m_columnProportions;
|
||||
std::vector<int> m_columnProportions;
|
||||
|
||||
double m_fSplitterX;
|
||||
|
||||
|
|
|
|||
|
|
@ -562,7 +562,7 @@ private:
|
|||
|
||||
wxPropertyGridManager* m_manager;
|
||||
const wxPropertyGridPage* m_page;
|
||||
wxVector<wxHeaderColumnSimple*> m_columns;
|
||||
std::vector<wxHeaderColumnSimple*> m_columns;
|
||||
};
|
||||
|
||||
#endif // wxUSE_HEADERCTRL
|
||||
|
|
|
|||
|
|
@ -498,7 +498,7 @@ void wxPGChoicesData::CopyDataFrom(wxPGChoicesData* data)
|
|||
wxPGChoiceEntry& wxPGChoicesData::Insert(int index,
|
||||
const wxPGChoiceEntry& item)
|
||||
{
|
||||
wxVector<wxPGChoiceEntry>::iterator it;
|
||||
std::vector<wxPGChoiceEntry>::iterator it;
|
||||
if ( index == -1 )
|
||||
{
|
||||
it = m_items.end();
|
||||
|
|
@ -808,7 +808,8 @@ wxPropertyGrid* wxPGProperty::GetGrid() const
|
|||
|
||||
int wxPGProperty::Index( const wxPGProperty* p ) const
|
||||
{
|
||||
return wxPGItemIndexInVector<wxPGProperty*>(m_children, const_cast<wxPGProperty*>(p));
|
||||
auto it = std::find(m_children.begin(), m_children.end(), p);
|
||||
return it != m_children.end() ? (int)(it - m_children.begin()) : wxNOT_FOUND;
|
||||
}
|
||||
|
||||
bool wxPGProperty::ValidateValue( wxVariant& WXUNUSED(value), wxPGValidationInfo& WXUNUSED(validationInfo) ) const
|
||||
|
|
@ -2380,7 +2381,11 @@ wxPGProperty* wxPGProperty::InsertChild( int index,
|
|||
|
||||
void wxPGProperty::RemoveChild( wxPGProperty* p )
|
||||
{
|
||||
wxPGRemoveItemFromVector<wxPGProperty*>(m_children, p);
|
||||
auto it = std::find(m_children.begin(), m_children.end(), p);
|
||||
if ( it != m_children.end() )
|
||||
{
|
||||
m_children.erase(it);
|
||||
}
|
||||
}
|
||||
|
||||
void wxPGProperty::RemoveChild(unsigned int index)
|
||||
|
|
|
|||
|
|
@ -2112,7 +2112,7 @@ int wxPropertyGrid::DoDrawItems( wxDC& dc,
|
|||
|
||||
const wxPGProperty* firstSelected = GetSelection();
|
||||
const wxPropertyGridPageState* state = m_pState;
|
||||
const wxVector<int>& colWidths = state->m_colWidths;
|
||||
const std::vector<int>& colWidths = state->m_colWidths;
|
||||
const unsigned int colCount = state->GetColumnCount();
|
||||
|
||||
dc.SetFont(normalFont);
|
||||
|
|
@ -2123,7 +2123,7 @@ int wxPropertyGrid::DoDrawItems( wxDC& dc,
|
|||
|
||||
//
|
||||
// Pre-generate list of visible properties.
|
||||
wxVector<wxPGProperty*> visPropArray;
|
||||
std::vector<wxPGProperty*> visPropArray;
|
||||
visPropArray.reserve((m_height/m_lineHeight)+6);
|
||||
|
||||
for ( ; !it.AtEnd(); it.Next() )
|
||||
|
|
@ -2146,7 +2146,7 @@ int wxPropertyGrid::DoDrawItems( wxDC& dc,
|
|||
wxPGProperty* nextP = visPropArray[0];
|
||||
|
||||
// Calculate splitters positions
|
||||
wxVector<int> splitterPos;
|
||||
std::vector<int> splitterPos;
|
||||
splitterPos.reserve(colCount);
|
||||
int sx = x;
|
||||
for ( int cw : colWidths )
|
||||
|
|
@ -6265,9 +6265,9 @@ wxPropertyGridEvent::~wxPropertyGridEvent()
|
|||
|
||||
// Use iterate from the back since it is more likely that the event
|
||||
// being destroyed is at the end of the array.
|
||||
wxVector<wxPropertyGridEvent*>& liveEvents = m_pg->m_liveEvents;
|
||||
std::vector<wxPropertyGridEvent*>& liveEvents = m_pg->m_liveEvents;
|
||||
|
||||
for ( wxVector<wxPropertyGridEvent*>::reverse_iterator rit = liveEvents.rbegin(); rit != liveEvents.rend(); ++rit )
|
||||
for ( std::vector<wxPropertyGridEvent*>::reverse_iterator rit = liveEvents.rbegin(); rit != liveEvents.rend(); ++rit )
|
||||
{
|
||||
if ( *rit == this )
|
||||
{
|
||||
|
|
|
|||
|
|
@ -926,7 +926,7 @@ wxString wxPropertyGridInterface::SaveEditableState( int includedStates ) const
|
|||
|
||||
//
|
||||
// Save state on page basis
|
||||
wxVector<wxPropertyGridPageState*> pageStates;
|
||||
std::vector<wxPropertyGridPageState*> pageStates;
|
||||
unsigned int pageIndex = 0;
|
||||
wxPropertyGridPageState* page;
|
||||
while ( (page = GetPageState(pageIndex)) != nullptr )
|
||||
|
|
|
|||
|
|
@ -31,6 +31,8 @@
|
|||
#include "wx/propgrid/propgridpagestate.h"
|
||||
#include "wx/propgrid/propgrid.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#define wxPG_DEFAULT_SPLITTERX 110
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
|
|
@ -1000,8 +1002,7 @@ void wxPropertyGridPageState::CheckColumnWidths( int widthChange )
|
|||
wxS("ColumnWidthCheck (virtualWidth: %i, clientWidth: %i)"),
|
||||
m_width, clientWidth);
|
||||
|
||||
|
||||
int colsWidth = wxPGGetSumVectorItems<int>(m_colWidths, pg->GetMarginWidth());
|
||||
int colsWidth = std::accumulate(m_colWidths.begin(), m_colWidths.end(), pg->GetMarginWidth());
|
||||
|
||||
wxLogTrace("propgrid",
|
||||
wxS(" HasVirtualWidth: %i colsWidth: %i"),
|
||||
|
|
@ -1128,7 +1129,7 @@ void wxPropertyGridPageState::CheckColumnWidths( int widthChange )
|
|||
void wxPropertyGridPageState::ResetColumnSizes( int setSplitterFlags )
|
||||
{
|
||||
// Calculate sum of proportions
|
||||
int psum = wxPGGetSumVectorItems<int>(m_columnProportions, 0);
|
||||
int psum = std::accumulate(m_columnProportions.begin(), m_columnProportions.end(), 0);
|
||||
int puwid = (m_pPropGrid->m_width*256) / psum;
|
||||
int cpos = 0;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue