1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: wx/headerctrl.h
3 // Purpose: wxHeaderCtrlBase class: interface of wxHeaderCtrl
4 // Author: Vadim Zeitlin
7 // Copyright: (c) 2008 Vadim Zeitlin <vadim@wxwidgets.org>
8 // Licence: wxWindows licence
9 ///////////////////////////////////////////////////////////////////////////////
11 #ifndef _WX_HEADERCTRL_H_
12 #define _WX_HEADERCTRL_H_
14 #include "wx/control.h"
16 #include "wx/headercol.h"
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
22 // ----------------------------------------------------------------------------
24 // ----------------------------------------------------------------------------
28 // allow column drag and drop
29 wxHD_DRAGDROP
= 0x0001,
31 // style used by default when creating the control
32 wxHD_DEFAULT_STYLE
= wxHD_DRAGDROP
35 extern WXDLLIMPEXP_DATA_CORE(const char) wxHeaderCtrlNameStr
[];
37 class WXDLLIMPEXP_FWD_CORE wxHeaderColumn
;
39 // ----------------------------------------------------------------------------
40 // wxHeaderCtrlBase defines the interface of a header control
41 // ----------------------------------------------------------------------------
43 class WXDLLIMPEXP_CORE wxHeaderCtrlBase
: public wxControl
47 Derived classes must provide default ctor as well as a ctor and
48 Create() function with the following signatures:
50 wxHeaderCtrl(wxWindow *parent,
51 wxWindowID winid = wxID_ANY,
52 const wxPoint& pos = wxDefaultPosition,
53 const wxSize& size = wxDefaultSize,
55 const wxString& name = wxHeaderCtrlNameStr);
57 bool Create(wxWindow *parent,
58 wxWindowID winid = wxID_ANY,
59 const wxPoint& pos = wxDefaultPosition,
60 const wxSize& size = wxDefaultSize,
62 const wxString& name = wxHeaderCtrlNameStr);
65 // managing the columns
66 // --------------------
68 // return the number of columns in the control
69 unsigned int GetColumnCount() const { return DoGetCount(); }
71 // return whether the control has any columns
72 bool IsEmpty() const { return GetColumnCount() == 0; }
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
)
78 wxCHECK_RET( idx
<= GetColumnCount(), "invalid column index" );
83 // append the column to the end of the control
84 void AppendColumn(const wxHeaderColumn
& col
)
86 DoInsert(col
, GetColumnCount());
89 // delete the column at the given index
90 void DeleteColumn(unsigned int idx
)
92 wxCHECK_RET( idx
< GetColumnCount(), "invalid column index" );
97 // delete all the existing columns
98 void DeleteAllColumns();
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
)
109 wxCHECK_RET( sortOrder
== 0 || sortOrder
== 1 || sortOrder
== -1,
110 "invalid sort order value" );
112 DoShowSortIndicator(idx
, sortOrder
);
115 // remove the sort indicator from the given column
116 void RemoveSortIndicator(unsigned int idx
)
118 DoShowSortIndicator(idx
, -1);
122 // implementation only from now on
123 // -------------------------------
125 // the user doesn't need to TAB to this control
126 virtual bool AcceptsFocusFromKeyboard() const { return false; }
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;
135 #if defined(__WXMSW__) && !defined(__WXUNIVERSAL__)
136 #include "wx/msw/headerctrl.h"
138 #define wxHAS_GENERIC_HEADERCTRL
139 #include "wx/generic/headerctrl.h"
142 #endif // _WX_HEADERCTRL_H_