- Rewrite wxHeaderCtrl to be virtual-like: even if we don't need an infinite
number of columns in it, it turns out that getting column information from the associated control is much easier than copying it into the control. - Provide wxHeaderCtrlSimple derived class which can be used easily if callback approach of wxHeaderCtrl is not needed. - Because of wxHeaderCtrl virtualization, port-specific implementations of wxHeaderColumn are not needed any more and were removed. - Use wxHeaderCtrl in the generic wxDataViewCtrl: this means that column events are broken right now in it as they haven't been implemented by wxHeaderCtrl yet, this will be fixed a.s.a.p. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@57161 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -28,20 +28,23 @@
|
||||
|
||||
#include "wx/headerctrl.h"
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// constants
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
const unsigned int wxNO_COLUMN = static_cast<unsigned>(-1);
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
// ============================================================================
|
||||
// wxHeaderCtrlBase implementation
|
||||
// ============================================================================
|
||||
|
||||
extern WXDLLIMPEXP_DATA_CORE(const char) wxHeaderCtrlNameStr[] = "wxHeaderCtrl";
|
||||
|
||||
void wxHeaderCtrlBase::DeleteAllColumns()
|
||||
{
|
||||
const unsigned count = GetColumnCount();
|
||||
for ( unsigned n = 0; n < count; n++ )
|
||||
DeleteColumn(0);
|
||||
}
|
||||
|
||||
|
||||
void wxHeaderCtrlBase::ScrollWindow(int dx,
|
||||
int WXUNUSED_UNLESS_DEBUG(dy),
|
||||
const wxRect * WXUNUSED_UNLESS_DEBUG(rect))
|
||||
@@ -57,3 +60,75 @@ void wxHeaderCtrlBase::ScrollWindow(int dx,
|
||||
DoScrollHorz(dx);
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// wxHeaderCtrlSimple implementation
|
||||
// ============================================================================
|
||||
|
||||
void wxHeaderCtrlSimple::Init()
|
||||
{
|
||||
m_sortKey = wxNO_COLUMN;
|
||||
}
|
||||
|
||||
wxHeaderColumnBase& wxHeaderCtrlSimple::GetColumn(unsigned int idx)
|
||||
{
|
||||
return m_cols[idx];
|
||||
}
|
||||
|
||||
void wxHeaderCtrlSimple::DoInsert(const wxHeaderColumnSimple& col, unsigned int idx)
|
||||
{
|
||||
m_cols.insert(m_cols.begin() + idx, col);
|
||||
|
||||
UpdateColumnCount();
|
||||
}
|
||||
|
||||
void wxHeaderCtrlSimple::DoDelete(unsigned int idx)
|
||||
{
|
||||
m_cols.erase(m_cols.begin() + idx);
|
||||
if ( idx == m_sortKey )
|
||||
m_sortKey = wxNO_COLUMN;
|
||||
|
||||
UpdateColumnCount();
|
||||
}
|
||||
|
||||
void wxHeaderCtrlSimple::DeleteAllColumns()
|
||||
{
|
||||
m_cols.clear();
|
||||
m_sortKey = wxNO_COLUMN;
|
||||
|
||||
UpdateColumnCount();
|
||||
}
|
||||
|
||||
|
||||
void wxHeaderCtrlSimple::DoShowColumn(unsigned int idx, bool show)
|
||||
{
|
||||
if ( show != m_cols[idx].IsShown() )
|
||||
{
|
||||
m_cols[idx].SetHidden(!show);
|
||||
|
||||
UpdateColumn(idx);
|
||||
}
|
||||
}
|
||||
|
||||
void wxHeaderCtrlSimple::DoShowSortIndicator(unsigned int idx, bool ascending)
|
||||
{
|
||||
RemoveSortIndicator();
|
||||
|
||||
m_cols[idx].SetAsSortKey(ascending);
|
||||
m_sortKey = idx;
|
||||
|
||||
UpdateColumn(idx);
|
||||
}
|
||||
|
||||
void wxHeaderCtrlSimple::RemoveSortIndicator()
|
||||
{
|
||||
if ( m_sortKey != wxNO_COLUMN )
|
||||
{
|
||||
const unsigned sortOld = m_sortKey;
|
||||
m_sortKey = wxNO_COLUMN;
|
||||
|
||||
m_cols[sortOld].UnsetAsSortKey();
|
||||
|
||||
UpdateColumn(sortOld);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user