Make column width calculations in wxDataViewCtrl and wxHeaderCtrl consistent.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@70338 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -31,6 +31,7 @@
|
||||
|
||||
#include "wx/headerctrl.h"
|
||||
#include "wx/rearrangectrl.h"
|
||||
#include "wx/renderer.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
@@ -107,6 +108,21 @@ void wxHeaderCtrlBase::SetColumnCount(unsigned int count)
|
||||
DoSetCount(count);
|
||||
}
|
||||
|
||||
int wxHeaderCtrlBase::GetColumnTitleWidth(const wxHeaderColumn& col)
|
||||
{
|
||||
int w = wxWindowBase::GetTextExtent(col.GetTitle()).x;
|
||||
|
||||
// add some margin:
|
||||
w += wxRendererNative::Get().GetHeaderButtonMargin(this);
|
||||
|
||||
// if a bitmap is used, add space for it and 2px border:
|
||||
wxBitmap bmp = col.GetBitmap();
|
||||
if ( bmp.IsOk() )
|
||||
w += bmp.GetWidth() + 2;
|
||||
|
||||
return w;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxHeaderCtrlBase event handling
|
||||
// ----------------------------------------------------------------------------
|
||||
@@ -122,8 +138,7 @@ void wxHeaderCtrlBase::OnSeparatorDClick(wxHeaderCtrlEvent& event)
|
||||
return;
|
||||
}
|
||||
|
||||
int w = wxWindowBase::GetTextExtent(column.GetTitle()).x;
|
||||
w += 4*GetCharWidth(); // add some arbitrary margins around text
|
||||
int w = GetColumnTitleWidth(column);
|
||||
|
||||
if ( !UpdateColumnWidthToFit(col, w) )
|
||||
event.Skip();
|
||||
|
||||
Reference in New Issue
Block a user