git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@70338
c3d73ce0-8a6f-49c7-b76d-
6d57e0e08775
// specified) and if the control has wxHD_ALLOW_REORDER style as well
bool ShowCustomizeDialog();
// specified) and if the control has wxHD_ALLOW_REORDER style as well
bool ShowCustomizeDialog();
+ // compute column title width
+ int GetColumnTitleWidth(const wxHeaderColumn& col);
// implementation only from now on
// -------------------------------
// implementation only from now on
// -------------------------------
*/
bool ShowCustomizeDialog();
*/
bool ShowCustomizeDialog();
+ /**
+ Returns width needed for given column's title.
+
+ @since 2.9.4
+ */
+ int GetColumnTitleWidth(const wxHeaderColumn& col);
+
protected:
/**
Method to be implemented by the derived classes to return the
protected:
/**
Method to be implemented by the derived classes to return the
#include "wx/headerctrl.h"
#include "wx/rearrangectrl.h"
#include "wx/headerctrl.h"
#include "wx/rearrangectrl.h"
+#include "wx/renderer.h"
+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
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
// wxHeaderCtrlBase event handling
// ----------------------------------------------------------------------------
- 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();
if ( !UpdateColumnWidthToFit(col, w) )
event.Skip();
m_clientArea->GetRowHeight());
if ( m_headerArea )
m_clientArea->GetRowHeight());
if ( m_headerArea )
- {
- int header_width = m_headerArea->GetTextExtent(column->GetTitle()).x;
- // Labels on native MSW header are indented on both sides
- header_width +=
- wxRendererNative::Get().GetHeaderButtonMargin(m_headerArea);
- calculator.UpdateWithWidth(header_width);
- }
+ calculator.UpdateWithWidth(m_headerArea->GetColumnTitleWidth(*column));
// The code below deserves some explanation. For very large controls, we
// simply can't afford to calculate sizes for all items, it takes too
// The code below deserves some explanation. For very large controls, we
// simply can't afford to calculate sizes for all items, it takes too