]> git.saurik.com Git - wxWidgets.git/blob - include/wx/headerctrl.h
f47df31917a652538f426628a95169fa682bee60
[wxWidgets.git] / include / wx / headerctrl.h
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: wx/headerctrl.h
3 // Purpose: wxHeaderCtrlBase class: interface of wxHeaderCtrl
4 // Author: Vadim Zeitlin
5 // Created: 2008-12-01
6 // RCS-ID: $Id$
7 // Copyright: (c) 2008 Vadim Zeitlin <vadim@wxwidgets.org>
8 // Licence: wxWindows licence
9 ///////////////////////////////////////////////////////////////////////////////
10
11 #ifndef _WX_HEADERCTRL_H_
12 #define _WX_HEADERCTRL_H_
13
14 #include "wx/control.h"
15
16 #include "wx/headercol.h"
17
18 // notice that the classes in this header are defined in the core library even
19 // although currently they're only used by wxGrid which is in wxAdv because we
20 // plan to use it in wxListCtrl which is in core too in the future
21
22 // ----------------------------------------------------------------------------
23 // constants
24 // ----------------------------------------------------------------------------
25
26 enum
27 {
28 // allow column drag and drop
29 wxHD_DRAGDROP = 0x0001,
30
31 // style used by default when creating the control
32 wxHD_DEFAULT_STYLE = wxHD_DRAGDROP
33 };
34
35 extern WXDLLIMPEXP_DATA_CORE(const char) wxHeaderCtrlNameStr[];
36
37 class WXDLLIMPEXP_FWD_CORE wxHeaderColumn;
38
39 // ----------------------------------------------------------------------------
40 // wxHeaderCtrlBase defines the interface of a header control
41 // ----------------------------------------------------------------------------
42
43 class WXDLLIMPEXP_CORE wxHeaderCtrlBase : public wxControl
44 {
45 public:
46 /*
47 Derived classes must provide default ctor as well as a ctor and
48 Create() function with the following signatures:
49
50 wxHeaderCtrl(wxWindow *parent,
51 wxWindowID winid = wxID_ANY,
52 const wxPoint& pos = wxDefaultPosition,
53 const wxSize& size = wxDefaultSize,
54 long style = 0,
55 const wxString& name = wxHeaderCtrlNameStr);
56
57 bool Create(wxWindow *parent,
58 wxWindowID winid = wxID_ANY,
59 const wxPoint& pos = wxDefaultPosition,
60 const wxSize& size = wxDefaultSize,
61 long style = 0,
62 const wxString& name = wxHeaderCtrlNameStr);
63 */
64
65 // managing the columns
66 // --------------------
67
68 // return the number of columns in the control
69 unsigned int GetColumnCount() const { return DoGetCount(); }
70
71 // return whether the control has any columns
72 bool IsEmpty() const { return GetColumnCount() == 0; }
73
74 // insert the column at the given position, using GetColumnCount() as
75 // position appends it at the end
76 void InsertColumn(const wxHeaderColumn& col, unsigned int idx)
77 {
78 wxCHECK_RET( idx <= GetColumnCount(), "invalid column index" );
79
80 DoInsert(col, idx);
81 }
82
83 // append the column to the end of the control
84 void AppendColumn(const wxHeaderColumn& col)
85 {
86 DoInsert(col, GetColumnCount());
87 }
88
89 // delete the column at the given index
90 void DeleteColumn(unsigned int idx)
91 {
92 wxCHECK_RET( idx < GetColumnCount(), "invalid column index" );
93
94 DoDelete(idx);
95 }
96
97 // delete all the existing columns
98 void DeleteAllColumns();
99
100
101 // modifying columns
102 // -----------------
103
104 // indicate that the column is used for sorting in ascending order if
105 // sortOrder is true, for sorting in descending order if it is false or not
106 // used for sorting at all if it is -1
107 void ShowSortIndicator(unsigned int idx, int sortOrder)
108 {
109 wxCHECK_RET( sortOrder == 0 || sortOrder == 1 || sortOrder == -1,
110 "invalid sort order value" );
111
112 DoShowSortIndicator(idx, sortOrder);
113 }
114
115 // remove the sort indicator from the given column
116 void RemoveSortIndicator(unsigned int idx)
117 {
118 DoShowSortIndicator(idx, -1);
119 }
120
121
122 // implementation only from now on
123 // -------------------------------
124
125 // the user doesn't need to TAB to this control
126 virtual bool AcceptsFocusFromKeyboard() const { return false; }
127
128 private:
129 virtual unsigned int DoGetCount() const = 0;
130 virtual void DoInsert(const wxHeaderColumn& col, unsigned int idx) = 0;
131 virtual void DoDelete(unsigned int idx) = 0;
132 virtual void DoShowSortIndicator(unsigned int idx, int sortOrder) = 0;
133 };
134
135 #if defined(__WXMSW__) && !defined(__WXUNIVERSAL__)
136 #include "wx/msw/headerctrl.h"
137 #elif 0 // TODO
138 #define wxHAS_GENERIC_HEADERCTRL
139 #include "wx/generic/headerctrl.h"
140 #endif // platform
141
142 #endif // _WX_HEADERCTRL_H_