Merge branch 'grid-autosize'
Optimize wxGrid::AutoSizeColumns() for big grids. This includes an optimization of wxDC::GetTextExtent() at the price of slightly reduced precision in wxMSW. See https://github.com/wxWidgets/wxWidgets/pull/1893
This commit is contained in:
@@ -88,6 +88,26 @@ public:
|
||||
virtual int GetBestWidth(wxGrid& grid, wxGridCellAttr& attr, wxDC& dc,
|
||||
int row, int col, int height);
|
||||
|
||||
/**
|
||||
Get the maximum possible size for a cell using this renderer, if
|
||||
possible.
|
||||
|
||||
This function may be overridden in the derived class if it can return
|
||||
the maximum size needed for displaying the cells rendered it without
|
||||
iterating over all cells. The base class version simply returns
|
||||
::wxDefaultSize, indicating that this is infeasible and that
|
||||
GetBestSize() should be called for each cell individually.
|
||||
|
||||
Note that this method will only be used if
|
||||
wxGridTableBase::CanMeasureColUsingSameAttr() is overriden to return
|
||||
@true.
|
||||
|
||||
@since 3.1.4
|
||||
*/
|
||||
virtual wxSize GetMaxBestSize(wxGrid& grid,
|
||||
wxGridCellAttr& attr,
|
||||
wxDC& dc);
|
||||
|
||||
protected:
|
||||
/**
|
||||
The destructor is private because only DecRef() can delete us.
|
||||
@@ -2517,6 +2537,25 @@ public:
|
||||
returns @true.
|
||||
*/
|
||||
virtual bool CanHaveAttributes();
|
||||
|
||||
/**
|
||||
Override to return true if the same attribute can be used for measuring
|
||||
all cells in the given column.
|
||||
|
||||
This function is provided for optimization purposes: it returns @false
|
||||
by default, but can be overridden to return @true when all the cells in
|
||||
the same grid column use sensibly the same attribute, i.e. they use the
|
||||
same renderer (either explicitly, or implicitly, due to their type as
|
||||
returned by GetTypeName()) and the font of the same size.
|
||||
|
||||
Returning @true from this function allows AutoSizeColumns() to skip
|
||||
looking up the attribute and the renderer for each individual cell,
|
||||
which results in very noticeable performance improvements for the grids
|
||||
with many rows.
|
||||
|
||||
@since 3.1.4
|
||||
*/
|
||||
virtual bool CanMeasureColUsingSameAttr(int col) const;
|
||||
};
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user