From: Václav Slavík Date: Mon, 24 Jan 2011 14:35:33 +0000 (+0000) Subject: Don't allow user to resize non-resizable columns to best size. X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/1acf670a9dbaee6ba2ceec06560c7fa68a48da62 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 --- 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) )