]>
Commit | Line | Data |
---|---|---|
56873923 VZ |
1 | /////////////////////////////////////////////////////////////////////////////// |
2 | // Name: wx/msw/headerctrl.h | |
3 | // Purpose: wxMSW native 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_MSW_HEADERCTRL_H_ | |
12 | #define _WX_MSW_HEADERCTRL_H_ | |
13 | ||
14 | class WXDLLIMPEXP_FWD_CORE wxImageList; | |
15 | ||
16 | // ---------------------------------------------------------------------------- | |
17 | // wxHeaderCtrl | |
18 | // ---------------------------------------------------------------------------- | |
19 | ||
20 | class WXDLLIMPEXP_CORE wxHeaderCtrl : public wxHeaderCtrlBase | |
21 | { | |
22 | public: | |
23 | wxHeaderCtrl() | |
24 | { | |
25 | Init(); | |
26 | } | |
27 | ||
28 | wxHeaderCtrl(wxWindow *parent, | |
29 | wxWindowID id = wxID_ANY, | |
30 | const wxPoint& pos = wxDefaultPosition, | |
31 | const wxSize& size = wxDefaultSize, | |
32 | long style = wxHD_DEFAULT_STYLE, | |
33 | const wxString& name = wxHeaderCtrlNameStr) | |
34 | { | |
35 | Init(); | |
36 | ||
37 | Create(parent, id, pos, size, style, name); | |
38 | } | |
39 | ||
40 | bool Create(wxWindow *parent, | |
41 | wxWindowID id = wxID_ANY, | |
42 | const wxPoint& pos = wxDefaultPosition, | |
43 | const wxSize& size = wxDefaultSize, | |
44 | long style = wxHD_DEFAULT_STYLE, | |
45 | const wxString& name = wxHeaderCtrlNameStr); | |
46 | ||
47 | virtual ~wxHeaderCtrl(); | |
48 | ||
65fb4b3a RD |
49 | |
50 | protected: | |
51 | // override wxWindow methods which must be implemented by a new control | |
52 | virtual wxSize DoGetBestSize() const; | |
53 | virtual void DoSetSize(int x, int y, | |
54 | int width, int height, | |
55 | int sizeFlags = wxSIZE_AUTO); | |
56 | ||
56873923 VZ |
57 | private: |
58 | // implement base class pure virtuals | |
e2bfe673 | 59 | virtual void DoSetCount(unsigned int count); |
56873923 | 60 | virtual unsigned int DoGetCount() const; |
e2bfe673 VZ |
61 | virtual void DoUpdate(unsigned int idx); |
62 | ||
d8fc3398 | 63 | virtual void DoScrollHorz(int dx); |
56873923 | 64 | |
702f5349 VZ |
65 | virtual void DoSetColumnsOrder(const wxArrayInt& order); |
66 | virtual wxArrayInt DoGetColumnsOrder() const; | |
67 | ||
56873923 VZ |
68 | // override MSW-specific methods needed for new control |
69 | virtual WXDWORD MSWGetStyle(long style, WXDWORD *exstyle) const; | |
fa3d4aaf | 70 | virtual bool MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result); |
56873923 VZ |
71 | |
72 | // common part of all ctors | |
73 | void Init(); | |
74 | ||
040b9528 VZ |
75 | // wrapper around Header_InsertItem(): insert the item using information |
76 | // from the given column at the given index | |
77 | void DoInsertItem(const wxHeaderColumn& col, unsigned int idx); | |
78 | ||
79 | // get the number of currently visible items: this is also the total number | |
80 | // of items contained in the native control | |
81 | int GetShownColumnsCount() const; | |
82 | ||
83 | // due to the discrepancy for the hidden columns which we know about but | |
84 | // the native control does not, there can be a difference between the | |
85 | // column indices we use and the ones used by the native control; these | |
86 | // functions translate between them | |
87 | // | |
88 | // notice that MSWToNativeIdx() shouldn't be called for hidden columns and | |
89 | // MSWFromNativeIdx() always returns an index of a visible column | |
90 | int MSWToNativeIdx(int idx); | |
91 | int MSWFromNativeIdx(int item); | |
92 | ||
93 | // this is the same as above but for order, not index | |
2e733ec7 | 94 | int MSWToNativeOrder(int order); |
040b9528 | 95 | int MSWFromNativeOrder(int order); |
e2bfe673 | 96 | |
aef252d9 VZ |
97 | // get the event type corresponding to a click or double click event |
98 | // (depending on dblclk value) with the specified (using MSW convention) | |
99 | // mouse button | |
100 | wxEventType GetClickEventType(bool dblclk, int button); | |
fa3d4aaf | 101 | |
e2bfe673 | 102 | |
040b9528 VZ |
103 | // the number of columns in the control, including the hidden ones (not |
104 | // taken into account by the native control, see comment in DoGetCount()) | |
105 | unsigned int m_numColumns; | |
106 | ||
107 | // this is a lookup table allowing us to check whether the column with the | |
108 | // given index is currently shown in the native control, in which case the | |
109 | // value of this array element with this index is 0, or hidden | |
110 | // | |
111 | // notice that this may be different from GetColumn(idx).IsHidden() and in | |
112 | // fact we need this array precisely because it will be different from it | |
113 | // in DoUpdate() when the column hidden flag gets toggled and we need it to | |
114 | // handle this transition correctly | |
115 | wxArrayInt m_isHidden; | |
116 | ||
117 | // the order of our columns: this array contains the index of the column | |
118 | // shown at the position n as the n-th element | |
119 | // | |
120 | // this is necessary only to handle the hidden columns: the native control | |
121 | // doesn't know about them and so we can't use Header_GetOrderArray() | |
122 | wxArrayInt m_colIndices; | |
123 | ||
56873923 VZ |
124 | // the image list: initially NULL, created on demand |
125 | wxImageList *m_imageList; | |
126 | ||
38cd07c4 VZ |
127 | // the offset of the window used to emulate scrolling it |
128 | int m_scrollOffset; | |
129 | ||
421a5048 VZ |
130 | // actual column we are dragging or -1 if not dragging anything |
131 | int m_colBeingDragged; | |
132 | ||
c0c133e1 | 133 | wxDECLARE_NO_COPY_CLASS(wxHeaderCtrl); |
56873923 VZ |
134 | }; |
135 | ||
136 | #endif // _WX_MSW_HEADERCTRL_H_ | |
137 |