From 1acf670a9dbaee6ba2ceec06560c7fa68a48da62 Mon Sep 17 00:00:00 2001 From: =?utf8?q?V=C3=A1clav=20Slav=C3=ADk?= Date: Mon, 24 Jan 2011 14:35:33 +0000 Subject: [PATCH] Don't allow user to resize non-resizable columns to best size. Double-clicking columns separator resizes the column to the best width for its content. This should only be done for resizeable columns, though. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@66740 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/common/headerctrlcmn.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/common/headerctrlcmn.cpp b/src/common/headerctrlcmn.cpp index 270e124bd2..4e32625c6b 100644 --- a/src/common/headerctrlcmn.cpp +++ b/src/common/headerctrlcmn.cpp @@ -114,8 +114,15 @@ void wxHeaderCtrlBase::SetColumnCount(unsigned int count) void wxHeaderCtrlBase::OnSeparatorDClick(wxHeaderCtrlEvent& event) { const unsigned col = event.GetColumn(); + const wxHeaderColumn& column = GetColumn(col); - int w = wxWindowBase::GetTextExtent(GetColumn(col).GetTitle()).x; + if ( !column.IsResizeable() ) + { + event.Skip(); + return; + } + + int w = wxWindowBase::GetTextExtent(column.GetTitle()).x; w += 4*GetCharWidth(); // add some arbitrary margins around text if ( !UpdateColumnWidthToFit(col, w) ) -- 2.45.2