]>
git.saurik.com Git - wxWidgets.git/blob - src/common/headerctrlcmn.cpp
b91f3fc7d8ca0d059bd041a6691f98b1a0d43e8e
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: src/common/headerctrlcmn.cpp
3 // Purpose: implementation of wxHeaderCtrlBase
4 // Author: Vadim Zeitlin
7 // Copyright: (c) 2008 Vadim Zeitlin <vadim@wxwidgets.org>
8 // Licence: wxWindows licence
9 ///////////////////////////////////////////////////////////////////////////////
11 // ============================================================================
13 // ============================================================================
15 // ----------------------------------------------------------------------------
17 // ----------------------------------------------------------------------------
19 // for compilers that support precompilation, includes "wx.h".
20 #include "wx/wxprec.h"
29 #include "wx/headerctrl.h"
31 // ----------------------------------------------------------------------------
33 // ----------------------------------------------------------------------------
38 const unsigned int wxNO_COLUMN
= static_cast<unsigned>(-1);
40 } // anonymous namespace
42 // ============================================================================
43 // wxHeaderCtrlBase implementation
44 // ============================================================================
46 extern WXDLLIMPEXP_DATA_CORE(const char) wxHeaderCtrlNameStr
[] = "wxHeaderCtrl";
48 void wxHeaderCtrlBase::ScrollWindow(int dx
,
49 int WXUNUSED_UNLESS_DEBUG(dy
),
50 const wxRect
* WXUNUSED_UNLESS_DEBUG(rect
))
53 // this doesn't make sense at all
54 wxASSERT_MSG( !dy
, "header window can't be scrolled vertically" );
56 // this would actually be nice to support for "frozen" headers but it isn't
57 // supported currently
58 wxASSERT_MSG( !rect
, "header window can't be scrolled partially" );
63 // ============================================================================
64 // wxHeaderCtrlSimple implementation
65 // ============================================================================
67 void wxHeaderCtrlSimple::Init()
69 m_sortKey
= wxNO_COLUMN
;
72 wxHeaderColumnBase
& wxHeaderCtrlSimple::GetColumn(unsigned int idx
)
77 void wxHeaderCtrlSimple::DoInsert(const wxHeaderColumnSimple
& col
, unsigned int idx
)
79 m_cols
.insert(m_cols
.begin() + idx
, col
);
84 void wxHeaderCtrlSimple::DoDelete(unsigned int idx
)
86 m_cols
.erase(m_cols
.begin() + idx
);
87 if ( idx
== m_sortKey
)
88 m_sortKey
= wxNO_COLUMN
;
93 void wxHeaderCtrlSimple::DeleteAllColumns()
96 m_sortKey
= wxNO_COLUMN
;
102 void wxHeaderCtrlSimple::DoShowColumn(unsigned int idx
, bool show
)
104 if ( show
!= m_cols
[idx
].IsShown() )
106 m_cols
[idx
].SetHidden(!show
);
112 void wxHeaderCtrlSimple::DoShowSortIndicator(unsigned int idx
, bool ascending
)
114 RemoveSortIndicator();
116 m_cols
[idx
].SetAsSortKey(ascending
);
122 void wxHeaderCtrlSimple::RemoveSortIndicator()
124 if ( m_sortKey
!= wxNO_COLUMN
)
126 const unsigned sortOld
= m_sortKey
;
127 m_sortKey
= wxNO_COLUMN
;
129 m_cols
[sortOld
].UnsetAsSortKey();
131 UpdateColumn(sortOld
);