#if wxUSE_HEADERCTRL
#ifndef WX_PRECOMP
+ #include "wx/app.h"
#include "wx/log.h"
#endif // WX_PRECOMP
#include "wx/msw/wrapcctl.h"
#include "wx/msw/private.h"
+#ifndef HDM_SETBITMAPMARGIN
+ #define HDM_SETBITMAPMARGIN 0x1234
+#endif
+
+#ifndef Header_SetBitmapMargin
+ #define Header_SetBitmapMargin(hwnd, margin) \
+ ::SendMessage((hwnd), HDM_SETBITMAPMARGIN, (WPARAM)(margin), 0)
+#endif
+
// from src/msw/listctrl.cpp
extern int WXDLLIMPEXP_CORE wxMSWGetColumnClicked(NMHDR *nmhdr, POINT *ptClick);
if ( !CreateControl(parent, id, pos, size, style, wxDefaultValidator, name) )
return false;
- if ( !MSWCreateControl(WC_HEADER, _T(""), pos, size) )
+ if ( !MSWCreateControl(WC_HEADER, wxT(""), pos, size) )
return false;
+ // special hack for margins when using comctl32.dll v6 or later: the
+ // default margin is too big and results in label truncation when the
+ // column width is just about right to show it together with the sort
+ // indicator, so reduce it to a smaller value (in principle we could even
+ // use 0 here but this starts to look ugly)
+ if ( wxApp::GetComCtl32Version() >= 600 )
+ {
+ Header_SetBitmapMargin(GetHwnd(), ::GetSystemMetrics(SM_CXEDGE));
+ }
+
return true;
}
// the control looks nicer with these styles and there doesn't seem to be
// any reason to not use them so we always do (as for HDS_HORZ it is 0
// anyhow but include it for clarity)
- msStyle |= HDS_HORZ | HDS_BUTTONS | HDS_FLAT | HDS_FULLDRAG | HDS_HOTTRACK;
+ // NOTE: don't use however HDS_FLAT because it makes the control look
+ // non-native when running WinXP in classic mode
+ msStyle |= HDS_HORZ | HDS_BUTTONS | HDS_FULLDRAG | HDS_HOTTRACK;
return msStyle;
}
HDLAYOUT layout = { &rc, &wpos };
if ( !Header_Layout(GetHwnd(), &layout) )
{
- wxLogLastError(_T("Header_Layout"));
+ wxLogLastError(wxT("Header_Layout"));
return wxControl::DoGetBestSize();
}
{
if ( !Header_DeleteItem(GetHwnd(), 0) )
{
- wxLogLastError(_T("Header_DeleteItem"));
+ wxLogLastError(wxT("Header_DeleteItem"));
}
}
if ( col.GetAlignment() != wxALIGN_NOT )
{
- hdi.mask |= HDI_FORMAT;
+ hdi.mask |= HDI_FORMAT | HDF_LEFT;
switch ( col.GetAlignment() )
{
case wxALIGN_LEFT:
if ( ::SendMessage(GetHwnd(), HDM_INSERTITEM,
MSWToNativeIdx(idx), (LPARAM)&hdi) == -1 )
{
- wxLogLastError(_T("Header_InsertItem()"));
+ wxLogLastError(wxT("Header_InsertItem()"));
}
}
if ( !Header_SetOrderArray(GetHwnd(), orderShown.size(), &orderShown[0]) )
{
- wxLogLastError(_T("Header_GetOrderArray"));
+ wxLogLastError(wxT("Header_GetOrderArray"));
}
m_colIndices = order;
if ( idx != wxNOT_FOUND )
{
idx = MSWFromNativeIdx(idx);
- evtType = GetClickEventType(code == NM_RDBLCLK, 1);
+
+ // due to a bug in mingw32 headers NM_RDBLCLK is signed
+ // there so we need a cast to avoid warnings about signed/
+ // unsigned comparison
+ evtType = GetClickEventType(
+ code == static_cast<UINT>(NM_RDBLCLK), 1);
}
//else: ignore clicks outside any column
}