]>
Commit | Line | Data |
---|---|---|
56873923 VZ |
1 | /////////////////////////////////////////////////////////////////////////////// |
2 | // Name: src/common/headerctrlcmn.cpp | |
3 | // Purpose: implementation of wxHeaderCtrlBase | |
4 | // Author: Vadim Zeitlin | |
5 | // Created: 2008-12-02 | |
6 | // RCS-ID: $Id$ | |
7 | // Copyright: (c) 2008 Vadim Zeitlin <vadim@wxwidgets.org> | |
8 | // Licence: wxWindows licence | |
9 | /////////////////////////////////////////////////////////////////////////////// | |
10 | ||
11 | // ============================================================================ | |
12 | // declarations | |
13 | // ============================================================================ | |
14 | ||
15 | // ---------------------------------------------------------------------------- | |
16 | // headers | |
17 | // ---------------------------------------------------------------------------- | |
18 | ||
19 | // for compilers that support precompilation, includes "wx.h". | |
20 | #include "wx/wxprec.h" | |
21 | ||
22 | #ifdef __BORLANDC__ | |
23 | #pragma hdrstop | |
24 | #endif | |
25 | ||
26 | #ifndef WX_PRECOMP | |
27 | #endif // WX_PRECOMP | |
28 | ||
29 | #include "wx/headerctrl.h" | |
30 | ||
e2bfe673 VZ |
31 | // ---------------------------------------------------------------------------- |
32 | // constants | |
33 | // ---------------------------------------------------------------------------- | |
34 | ||
35 | namespace | |
36 | { | |
37 | ||
38 | const unsigned int wxNO_COLUMN = static_cast<unsigned>(-1); | |
39 | ||
40 | } // anonymous namespace | |
41 | ||
56873923 VZ |
42 | // ============================================================================ |
43 | // wxHeaderCtrlBase implementation | |
44 | // ============================================================================ | |
45 | ||
9a382f1f | 46 | extern WXDLLIMPEXP_DATA_CORE(const char) wxHeaderCtrlNameStr[] = "wxHeaderCtrl"; |
56873923 | 47 | |
d8fc3398 VZ |
48 | void wxHeaderCtrlBase::ScrollWindow(int dx, |
49 | int WXUNUSED_UNLESS_DEBUG(dy), | |
50 | const wxRect * WXUNUSED_UNLESS_DEBUG(rect)) | |
51 | ||
52 | { | |
53 | // this doesn't make sense at all | |
54 | wxASSERT_MSG( !dy, "header window can't be scrolled vertically" ); | |
55 | ||
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" ); | |
59 | ||
60 | DoScrollHorz(dx); | |
61 | } | |
62 | ||
e2bfe673 VZ |
63 | // ============================================================================ |
64 | // wxHeaderCtrlSimple implementation | |
65 | // ============================================================================ | |
66 | ||
67 | void wxHeaderCtrlSimple::Init() | |
68 | { | |
69 | m_sortKey = wxNO_COLUMN; | |
70 | } | |
71 | ||
72 | wxHeaderColumnBase& wxHeaderCtrlSimple::GetColumn(unsigned int idx) | |
73 | { | |
74 | return m_cols[idx]; | |
75 | } | |
76 | ||
77 | void wxHeaderCtrlSimple::DoInsert(const wxHeaderColumnSimple& col, unsigned int idx) | |
78 | { | |
79 | m_cols.insert(m_cols.begin() + idx, col); | |
80 | ||
81 | UpdateColumnCount(); | |
82 | } | |
83 | ||
84 | void wxHeaderCtrlSimple::DoDelete(unsigned int idx) | |
85 | { | |
86 | m_cols.erase(m_cols.begin() + idx); | |
87 | if ( idx == m_sortKey ) | |
88 | m_sortKey = wxNO_COLUMN; | |
89 | ||
90 | UpdateColumnCount(); | |
91 | } | |
92 | ||
93 | void wxHeaderCtrlSimple::DeleteAllColumns() | |
94 | { | |
95 | m_cols.clear(); | |
96 | m_sortKey = wxNO_COLUMN; | |
97 | ||
98 | UpdateColumnCount(); | |
99 | } | |
100 | ||
101 | ||
102 | void wxHeaderCtrlSimple::DoShowColumn(unsigned int idx, bool show) | |
103 | { | |
104 | if ( show != m_cols[idx].IsShown() ) | |
105 | { | |
106 | m_cols[idx].SetHidden(!show); | |
107 | ||
108 | UpdateColumn(idx); | |
109 | } | |
110 | } | |
111 | ||
112 | void wxHeaderCtrlSimple::DoShowSortIndicator(unsigned int idx, bool ascending) | |
113 | { | |
114 | RemoveSortIndicator(); | |
115 | ||
116 | m_cols[idx].SetAsSortKey(ascending); | |
117 | m_sortKey = idx; | |
118 | ||
119 | UpdateColumn(idx); | |
120 | } | |
121 | ||
122 | void wxHeaderCtrlSimple::RemoveSortIndicator() | |
123 | { | |
124 | if ( m_sortKey != wxNO_COLUMN ) | |
125 | { | |
126 | const unsigned sortOld = m_sortKey; | |
127 | m_sortKey = wxNO_COLUMN; | |
128 | ||
129 | m_cols[sortOld].UnsetAsSortKey(); | |
130 | ||
131 | UpdateColumn(sortOld); | |
132 | } | |
133 | } | |
134 | ||
fa3d4aaf VZ |
135 | // ============================================================================ |
136 | // wxHeaderCtrlEvent implementation | |
137 | // ============================================================================ | |
138 | ||
139 | IMPLEMENT_DYNAMIC_CLASS(wxHeaderCtrlEvent, wxNotifyEvent) | |
140 | ||
141 | const wxEventType wxEVT_COMMAND_HEADER_CLICK = wxNewEventType(); | |
142 | const wxEventType wxEVT_COMMAND_HEADER_RIGHT_CLICK = wxNewEventType(); | |
143 | const wxEventType wxEVT_COMMAND_HEADER_MIDDLE_CLICK = wxNewEventType(); | |
144 | ||
145 | const wxEventType wxEVT_COMMAND_HEADER_DCLICK = wxNewEventType(); | |
146 | const wxEventType wxEVT_COMMAND_HEADER_RIGHT_DCLICK = wxNewEventType(); | |
147 | const wxEventType wxEVT_COMMAND_HEADER_MIDDLE_DCLICK = wxNewEventType(); |