// modifying columns
// -----------------
+ // show or hide the column, notice that even when a column is hidden we
+ // still account for it when using indices
+ void ShowColumn(unsigned int idx, bool show = true)
+ {
+ wxCHECK_RET( idx < GetColumnCount(), "invalid column index" );
+
+ DoShowColumn(idx, show);
+ }
+
+ void HideColumn(unsigned int idx)
+ {
+ ShowColumn(idx, false);
+ }
+
// indicate that the column is used for sorting in ascending order if
// sortOrder is true, for sorting in descending order if it is false or not
// used for sorting at all if it is -1
wxCHECK_RET( sortOrder == 0 || sortOrder == 1 || sortOrder == -1,
"invalid sort order value" );
+ wxCHECK_RET( idx < GetColumnCount(), "invalid column index" );
+
DoShowSortIndicator(idx, sortOrder);
}
virtual unsigned int DoGetCount() const = 0;
virtual void DoInsert(const wxHeaderColumn& col, unsigned int idx) = 0;
virtual void DoDelete(unsigned int idx) = 0;
+ virtual void DoShowColumn(unsigned int idx, bool show) = 0;
virtual void DoShowSortIndicator(unsigned int idx, int sortOrder) = 0;
};
#include "wx/msw/headerctrl.h"
#elif 0 // TODO
#define wxHAS_GENERIC_HEADERCTRL
- #include "wx/generic/headerctrl.h"
+ #include "wx/generic/headerctrlg.h"
#endif // platform
#endif // _WX_HEADERCTRL_H_
virtual unsigned int DoGetCount() const;
virtual void DoInsert(const wxHeaderColumn& col, unsigned int idx);
virtual void DoDelete(unsigned int idx);
+ virtual void DoShowColumn(unsigned int idx, bool show);
virtual void DoShowSortIndicator(unsigned int idx, int sortOrder);
// override wxWindow methods which must be implemented by a new control
*/
void DeleteColumn(unsigned int idx);
+ /**
+ Show or hide the column.
+
+ Initially the column is shown by default or hidden if it was added with
+ wxCOL_HIDDEN flag set.
+
+ When a column is hidden, it doesn't appear at all on the screen but its
+ index is still taken into account when working with other columns. E.g.
+ if there are three columns 0, 1 and 2 and the column 1 is hidden you
+ still need to use index 2 to refer to the last visible column.
+
+ @param idx
+ The index of the column to show or hide, from 0 to GetColumnCount().
+ @param show
+ Indicates whether the column should be shown (default) or hidden.
+ */
+ void ShowColumn(unsigned int idx, bool show = true);
+
+ /**
+ Hide the column with the given index.
+
+ This is the same as calling @code ShowColumn(idx, false) @endcode.
+
+ @param idx
+ The index of the column to show or hide, from 0 to GetColumnCount().
+ */
+ void HideColumn(unsigned int idx);
+
/**
Update the column sort indicator.
hdi.iImage = m_imageList->GetImageCount() - 1;
}
+ if ( col.IsHidden() )
+ {
+ hdi.mask |= HDI_WIDTH;
+ hdi.cxy = 0;
+ }
+
if ( Header_InsertItem(GetHwnd(), idx, &hdi) == -1 )
{
wxLogLastError(_T("Header_InsertItem"));
// wxHeaderCtrl columns attributes
// ----------------------------------------------------------------------------
+void wxHeaderCtrl::DoShowColumn(unsigned int idx, bool show)
+{
+ wxHDITEM hdi;
+ hdi.mask = HDI_WIDTH;
+
+ if ( !Header_GetItem(GetHwnd(), idx, &hdi) )
+ {
+ wxLogLastError(_T("Header_GetItem(HDI_WIDTH)"));
+ return;
+ }
+
+ if ( show )
+ hdi.cxy = 80; // FIXME: we don't have the column width here any more
+ else
+ hdi.cxy = 0;
+
+ if ( !Header_SetItem(GetHwnd(), idx, &hdi) )
+ {
+ wxLogLastError(_T("Header_SetItem(HDI_WIDTH)"));
+ return;
+ }
+}
+
void wxHeaderCtrl::DoShowSortIndicator(unsigned int idx, int sortOrder)
{
wxHDITEM hdi;
if ( !Header_GetItem(GetHwnd(), idx, &hdi) )
{
- wxLogLastError(_T("Header_GetItem"));
+ wxLogLastError(_T("Header_GetItem(HDI_FORMAT)"));
return;
}
if ( !Header_SetItem(GetHwnd(), idx, &hdi) )
{
- wxLogLastError(_T("Header_SetItem"));
+ wxLogLastError(_T("Header_SetItem(HDI_FORMAT)"));
}
}