Add wxGridCellRenderer::GetBest{Height,Width}() and use them in wxGrid.

Allow the renderer to specify the best height at the given width (or vice
versa) instead of the best size in both direction which is not defined for
e.g. wxGridCellAutoWrapStringRenderer.

Closes #15943.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@76451 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2014-05-04 22:12:42 +00:00
parent 02f5b809bd
commit 2e8988c3d6
6 changed files with 120 additions and 13 deletions

View File

@@ -174,6 +174,30 @@ public:
wxDC& dc,
int row, int col) = 0;
// Get the preferred height for a given width. Override this method if the
// renderer computes height as function of its width, as is the case of the
// standard wxGridCellAutoWrapStringRenderer, for example.
// and vice versa
virtual int GetBestHeight(wxGrid& grid,
wxGridCellAttr& attr,
wxDC& dc,
int row, int col,
int WXUNUSED(width))
{
return GetBestSize(grid, attr, dc, row, col).GetHeight();
}
// Get the preferred width for a given height, this is the symmetric
// version of GetBestHeight().
virtual int GetBestWidth(wxGrid& grid,
wxGridCellAttr& attr,
wxDC& dc,
int row, int col,
int WXUNUSED(height))
{
return GetBestSize(grid, attr, dc, row, col).GetWidth();
}
// create a new object which is the copy of this one
virtual wxGridCellRenderer *Clone() const = 0;
};