From 9955f6fd8658382fb822e227a64385ee5966c018 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 29 Dec 2013 00:01:28 +0000 Subject: [PATCH] Prevent wxGrid rows/columns from becoming too small on double click. The minimal size wasn't respected when auto-sizing rows/columns in Set{Row,Col}Size() which was called in response to double clicking the separator line, which resulted in clearly wrong behaviour as the user was prevented from resizing the row/column to a smaller size by dragging them but not by double clicking, so fix this to respect the minimal size as well. Closes #15627. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@75446 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/generic/grid.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/generic/grid.cpp b/src/generic/grid.cpp index 31f9297c63..572ed18815 100644 --- a/src/generic/grid.cpp +++ b/src/generic/grid.cpp @@ -8169,8 +8169,9 @@ void wxGrid::SetRowSize( int row, int height ) dc.SetFont(GetLabelFont()); StringToLines(GetRowLabelValue( row ), lines); GetTextBoxSize( dc, lines, &w, &h ); - //check that it is not less than the minimal height - height = wxMax(h, GetRowMinimalAcceptableHeight()); + + // As with the columns, don't make the row smaller than minimal height. + height = wxMax(h, GetRowMinimalHeight(row)); } DoSetRowSize(row, height); @@ -8250,8 +8251,14 @@ void wxGrid::SetColSize( int col, int width ) else GetTextBoxSize( dc, lines, &h, &w ); width = w + 6; - //check that it is not less than the minimal width - width = wxMax(width, GetColMinimalAcceptableWidth()); + + // Check that it is not less than the minimal width and do use the + // possibly greater than minimal-acceptable-width minimal-width itself + // here as we shouldn't become too small when auto-sizing, otherwise + // the column could be resized to be too small by double clicking its + // divider line (which ends up in a call to this function) even though + // it couldn't be resized to this size by dragging it. + width = wxMax(width, GetColMinimalWidth(col)); } DoSetColSize(col, width);