Implement wxGridCellNumberRenderer::GetMaxBestSize()

This allows to make computing the best width of numeric columns an O(1)
operation instead of O(number-of-rows), which can make a huge difference
for big grids.
This commit is contained in:
Vadim Zeitlin
2020-06-13 16:31:33 +02:00
parent 96de24d1bb
commit d2a403408f
2 changed files with 46 additions and 1 deletions

View File

@@ -57,6 +57,13 @@ protected:
class WXDLLIMPEXP_ADV wxGridCellNumberRenderer : public wxGridCellStringRenderer
{
public:
explicit wxGridCellNumberRenderer(long minValue = LONG_MIN,
long maxValue = LONG_MAX)
: m_minValue(minValue),
m_maxValue(maxValue)
{
}
// draw the string right aligned
virtual void Draw(wxGrid& grid,
wxGridCellAttr& attr,
@@ -70,11 +77,21 @@ public:
wxDC& dc,
int row, int col) wxOVERRIDE;
virtual wxSize GetMaxBestSize(wxGrid& grid,
wxGridCellAttr& attr,
wxDC& dc) wxOVERRIDE;
// Optional parameters for this renderer are "<min>,<max>".
virtual void SetParameters(const wxString& params) wxOVERRIDE;
virtual wxGridCellRenderer *Clone() const wxOVERRIDE
{ return new wxGridCellNumberRenderer; }
{ return new wxGridCellNumberRenderer(m_minValue, m_maxValue); }
protected:
wxString GetString(const wxGrid& grid, int row, int col);
long m_minValue,
m_maxValue;
};
class WXDLLIMPEXP_ADV wxGridCellFloatRenderer : public wxGridCellStringRenderer