add Show/HideColumn() methods
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@57132 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -101,6 +101,20 @@ public:
|
|||||||
// modifying columns
|
// 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
|
// 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
|
// sortOrder is true, for sorting in descending order if it is false or not
|
||||||
// used for sorting at all if it is -1
|
// used for sorting at all if it is -1
|
||||||
@@ -109,6 +123,8 @@ public:
|
|||||||
wxCHECK_RET( sortOrder == 0 || sortOrder == 1 || sortOrder == -1,
|
wxCHECK_RET( sortOrder == 0 || sortOrder == 1 || sortOrder == -1,
|
||||||
"invalid sort order value" );
|
"invalid sort order value" );
|
||||||
|
|
||||||
|
wxCHECK_RET( idx < GetColumnCount(), "invalid column index" );
|
||||||
|
|
||||||
DoShowSortIndicator(idx, sortOrder);
|
DoShowSortIndicator(idx, sortOrder);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -129,6 +145,7 @@ private:
|
|||||||
virtual unsigned int DoGetCount() const = 0;
|
virtual unsigned int DoGetCount() const = 0;
|
||||||
virtual void DoInsert(const wxHeaderColumn& col, unsigned int idx) = 0;
|
virtual void DoInsert(const wxHeaderColumn& col, unsigned int idx) = 0;
|
||||||
virtual void DoDelete(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;
|
virtual void DoShowSortIndicator(unsigned int idx, int sortOrder) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -136,7 +153,7 @@ private:
|
|||||||
#include "wx/msw/headerctrl.h"
|
#include "wx/msw/headerctrl.h"
|
||||||
#elif 0 // TODO
|
#elif 0 // TODO
|
||||||
#define wxHAS_GENERIC_HEADERCTRL
|
#define wxHAS_GENERIC_HEADERCTRL
|
||||||
#include "wx/generic/headerctrl.h"
|
#include "wx/generic/headerctrlg.h"
|
||||||
#endif // platform
|
#endif // platform
|
||||||
|
|
||||||
#endif // _WX_HEADERCTRL_H_
|
#endif // _WX_HEADERCTRL_H_
|
||||||
|
@@ -51,6 +51,7 @@ private:
|
|||||||
virtual unsigned int DoGetCount() const;
|
virtual unsigned int DoGetCount() const;
|
||||||
virtual void DoInsert(const wxHeaderColumn& col, unsigned int idx);
|
virtual void DoInsert(const wxHeaderColumn& col, unsigned int idx);
|
||||||
virtual void DoDelete(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);
|
virtual void DoShowSortIndicator(unsigned int idx, int sortOrder);
|
||||||
|
|
||||||
// override wxWindow methods which must be implemented by a new control
|
// override wxWindow methods which must be implemented by a new control
|
||||||
|
@@ -159,6 +159,34 @@ public:
|
|||||||
*/
|
*/
|
||||||
void DeleteColumn(unsigned int idx);
|
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.
|
Update the column sort indicator.
|
||||||
|
|
||||||
|
@@ -145,6 +145,12 @@ void wxHeaderCtrl::DoInsert(const wxHeaderColumn& col, unsigned int idx)
|
|||||||
hdi.iImage = m_imageList->GetImageCount() - 1;
|
hdi.iImage = m_imageList->GetImageCount() - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( col.IsHidden() )
|
||||||
|
{
|
||||||
|
hdi.mask |= HDI_WIDTH;
|
||||||
|
hdi.cxy = 0;
|
||||||
|
}
|
||||||
|
|
||||||
if ( Header_InsertItem(GetHwnd(), idx, &hdi) == -1 )
|
if ( Header_InsertItem(GetHwnd(), idx, &hdi) == -1 )
|
||||||
{
|
{
|
||||||
wxLogLastError(_T("Header_InsertItem"));
|
wxLogLastError(_T("Header_InsertItem"));
|
||||||
@@ -163,6 +169,29 @@ void wxHeaderCtrl::DoDelete(unsigned int idx)
|
|||||||
// wxHeaderCtrl columns attributes
|
// 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)
|
void wxHeaderCtrl::DoShowSortIndicator(unsigned int idx, int sortOrder)
|
||||||
{
|
{
|
||||||
wxHDITEM hdi;
|
wxHDITEM hdi;
|
||||||
@@ -170,7 +199,7 @@ void wxHeaderCtrl::DoShowSortIndicator(unsigned int idx, int sortOrder)
|
|||||||
|
|
||||||
if ( !Header_GetItem(GetHwnd(), idx, &hdi) )
|
if ( !Header_GetItem(GetHwnd(), idx, &hdi) )
|
||||||
{
|
{
|
||||||
wxLogLastError(_T("Header_GetItem"));
|
wxLogLastError(_T("Header_GetItem(HDI_FORMAT)"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -181,7 +210,7 @@ void wxHeaderCtrl::DoShowSortIndicator(unsigned int idx, int sortOrder)
|
|||||||
|
|
||||||
if ( !Header_SetItem(GetHwnd(), idx, &hdi) )
|
if ( !Header_SetItem(GetHwnd(), idx, &hdi) )
|
||||||
{
|
{
|
||||||
wxLogLastError(_T("Header_SetItem"));
|
wxLogLastError(_T("Header_SetItem(HDI_FORMAT)"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user