From 1ee5d643f10c63cbf9c904cca96bf383a269b9d6 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 2 Feb 2014 01:15:34 +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/branches/WX_3_0_BRANCH@75766 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/changes.txt | 1 + src/generic/grid.cpp | 15 +++++++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/docs/changes.txt b/docs/changes.txt index 4ae224a4c6..484b7f7fda 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -596,6 +596,7 @@ All (GUI): - Fix crash when Destroy()-ing a TLW with non-TLW parent. - Fix crash in wxAuiToolBar::GetToolBarFits(). - Make wxHTML more efficient when displaying large tables (Kinaou Hervé). +- Prevent wxGrid rows/columns from becoming too small on double click. wxGTK: diff --git a/src/generic/grid.cpp b/src/generic/grid.cpp index 215b818c9b..b19dc1782f 100644 --- a/src/generic/grid.cpp +++ b/src/generic/grid.cpp @@ -8147,8 +8147,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); @@ -8228,8 +8229,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);