Fixes to allow DoGetBestSize to work before CreateGrid has been called.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@28977 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robin Dunn 2004-08-31 16:31:39 +00:00
parent 79609e6f24
commit b39a5dc41e

View File

@ -3855,9 +3855,14 @@ wxGrid::wxGrid( wxWindow *parent,
m_colMinWidths(GRID_HASH_SIZE), m_colMinWidths(GRID_HASH_SIZE),
m_rowMinHeights(GRID_HASH_SIZE) m_rowMinHeights(GRID_HASH_SIZE)
{ {
// Can't use SetBestFittingSize here to avoid a crash as CreateGrid hasn't // in order to make sure that a size event is not
// been called yet. // trigerred in a unfinished state
SetMinSize(size); m_cornerLabelWin = NULL ;
m_rowLabelWin = NULL ;
m_colLabelWin = NULL ;
m_gridWin = NULL ;
SetBestFittingSize(size);
Create(); Create();
} }
@ -3872,9 +3877,7 @@ bool wxGrid::Create(wxWindow *parent, wxWindowID id,
m_colMinWidths = wxLongToLongHashMap(GRID_HASH_SIZE) ; m_colMinWidths = wxLongToLongHashMap(GRID_HASH_SIZE) ;
m_rowMinHeights = wxLongToLongHashMap(GRID_HASH_SIZE) ; m_rowMinHeights = wxLongToLongHashMap(GRID_HASH_SIZE) ;
// Can't use SetBestFittingSize here to avoid a crash as CreateGrid hasn't SetBestFittingSize(size);
// been called yet.
SetMinSize(size);
Create() ; Create() ;
return true; return true;
@ -9885,8 +9888,10 @@ wxSize wxGrid::DoGetBestSize() const
// of the scrollbars, is there any magic incantaion for that? // of the scrollbars, is there any magic incantaion for that?
int xpu, ypu; int xpu, ypu;
GetScrollPixelsPerUnit(&xpu, &ypu); GetScrollPixelsPerUnit(&xpu, &ypu);
width += 1 + xpu - (width % xpu); if (xpu)
height += 1 + ypu - (height % ypu); width += 1 + xpu - (width % xpu);
if (ypu)
height += 1 + ypu - (height % ypu);
// limit to 1/4 of the screen size // limit to 1/4 of the screen size
int maxwidth, maxheight; int maxwidth, maxheight;