correct GetBestSize() to return correct best size, i.e. the same size as AutoSize() would give to the control since the fix in 1.407

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@43979 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2006-12-15 01:09:06 +00:00
parent d8bfd72731
commit dc4689ef73

View File

@@ -10652,46 +10652,22 @@ void wxGrid::AutoSizeColLabelSize( int col )
wxSize wxGrid::DoGetBestSize() const wxSize wxGrid::DoGetBestSize() const
{ {
// don't set sizes, only calculate them
wxGrid *self = (wxGrid *)this; // const_cast wxGrid *self = (wxGrid *)this; // const_cast
int width, height; // we do the same as in AutoSize() here with the exception that we don't
width = self->SetOrCalcColumnSizes(true); // change the column/row sizes, only calculate them
height = self->SetOrCalcRowSizes(true); wxSize size(self->SetOrCalcColumnSizes(true) - m_rowLabelWidth + m_extraWidth,
self->SetOrCalcRowSizes(true) - m_colLabelHeight + m_extraHeight);
if (!width) wxSize sizeFit(GetScrollX(size.x) * GetScrollLineX(),
width = 100; GetScrollY(size.y) * GetScrollLineY());
if (!height)
height = 80;
// Round up to a multiple the scroll rate
// NOTE: this still doesn't get rid of the scrollbars;
// is there any magic incantation for that?
int xpu, ypu;
GetScrollPixelsPerUnit(&xpu, &ypu);
if (xpu)
width += 1 + xpu - (width % xpu);
if (ypu)
height += 1 + ypu - (height % ypu);
// limit to 1/4 of the screen size
int maxwidth, maxheight;
wxDisplaySize( &maxwidth, &maxheight );
maxwidth /= 2;
maxheight /= 2;
if ( width > maxwidth )
width = maxwidth;
if ( height > maxheight )
height = maxheight;
wxSize best(width, height);
// NOTE: This size should be cached, but first we need to add calls to // NOTE: This size should be cached, but first we need to add calls to
// InvalidateBestSize everywhere that could change the results of this // InvalidateBestSize everywhere that could change the results of this
// calculation. // calculation.
// CacheBestSize(size); // CacheBestSize(size);
return best; return wxSize(sizeFit.x + m_rowLabelWidth, sizeFit.y + m_colLabelHeight)
+ GetWindowBorderSize();
} }
void wxGrid::Fit() void wxGrid::Fit()