]> git.saurik.com Git - wxWidgets.git/blame - include/wx/generic/headerctrlg.h
get rid of the wxListString class in wxStatusBar code; introduce a wxStatusBarPane...
[wxWidgets.git] / include / wx / generic / headerctrlg.h
CommitLineData
b63f9a33
VZ
1///////////////////////////////////////////////////////////////////////////////
2// Name: wx/generic/headerctrlg.h
3// Purpose: Generic wxHeaderCtrl implementation
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_GENERIC_HEADERCTRLG_H_
12#define _WX_GENERIC_HEADERCTRLG_H_
13
14#include "wx/event.h"
15#include "wx/vector.h"
aef252d9 16#include "wx/overlay.h"
b63f9a33
VZ
17
18// ----------------------------------------------------------------------------
19// wxHeaderCtrl
20// ----------------------------------------------------------------------------
21
22class WXDLLIMPEXP_CORE wxHeaderCtrl : public wxHeaderCtrlBase
23{
24public:
25 wxHeaderCtrl()
26 {
27 Init();
28 }
29
30 wxHeaderCtrl(wxWindow *parent,
31 wxWindowID id = wxID_ANY,
32 const wxPoint& pos = wxDefaultPosition,
33 const wxSize& size = wxDefaultSize,
34 long style = wxHD_DEFAULT_STYLE,
35 const wxString& name = wxHeaderCtrlNameStr)
36 {
37 Init();
38
39 Create(parent, id, pos, size, style, name);
40 }
41
42 bool Create(wxWindow *parent,
43 wxWindowID id = wxID_ANY,
44 const wxPoint& pos = wxDefaultPosition,
45 const wxSize& size = wxDefaultSize,
46 long style = wxHD_DEFAULT_STYLE,
47 const wxString& name = wxHeaderCtrlNameStr);
48
49 virtual ~wxHeaderCtrl();
50
51private:
52 // implement base class pure virtuals
40dc2ae6 53 virtual void DoSetCount(unsigned int count);
b63f9a33 54 virtual unsigned int DoGetCount() const;
40dc2ae6
VZ
55 virtual void DoUpdate(unsigned int idx);
56
b63f9a33
VZ
57 virtual void DoScrollHorz(int dx);
58
20db5469
VZ
59 virtual void DoSetColumnsOrder(const wxArrayInt& order);
60 virtual wxArrayInt DoGetColumnsOrder() const;
61
b63f9a33
VZ
62 // override wxWindow methods which must be implemented by a new control
63 virtual wxSize DoGetBestSize() const;
64
65 // common part of all ctors
66 void Init();
67
68 // event handlers
69 void OnPaint(wxPaintEvent& event);
70 void OnMouse(wxMouseEvent& event);
e36dcd10 71 void OnKeyDown(wxKeyEvent& event);
aef252d9 72 void OnCaptureLost(wxMouseCaptureLostEvent& event);
b63f9a33 73
6327cdd5
VZ
74 // move the column with given idx at given position (this doesn't generate
75 // any events but does refresh the display)
76 void DoMoveCol(unsigned int idx, unsigned int pos);
77
8fad69b0
VZ
78 // return the horizontal start position of the given column in physical
79 // coordinates
b63f9a33
VZ
80 int GetColStart(unsigned int idx) const;
81
6327cdd5
VZ
82 // and the end position
83 int GetColEnd(unsigned int idx) const;
84
3bfaa5a7 85 // refresh the given column [only]; idx must be valid
b63f9a33
VZ
86 void RefreshCol(unsigned int idx);
87
3bfaa5a7
VZ
88 // refresh the given column if idx is valid
89 void RefreshColIfNotNone(unsigned int idx);
90
b63f9a33
VZ
91 // refresh all the controls starting from (and including) the given one
92 void RefreshColsAfter(unsigned int idx);
93
fa3d4aaf
VZ
94 // return the column at the given position or -1 if it is beyond the
95 // rightmost column and put true into onSeparator output parameter if the
96 // position is near the divider at the right end of this column (notice
97 // that this means that we return column 0 even if the position is over
98 // column 1 but close enough to the divider separating it from column 0)
6327cdd5 99 unsigned int FindColumnAtPoint(int x, bool *onSeparator = NULL) const;
e36dcd10
VZ
100
101 // return true if a drag resizing operation is currently in progress
102 bool IsResizing() const;
fa3d4aaf 103
6327cdd5
VZ
104 // return true if a drag reordering operation is currently in progress
105 bool IsReordering() const;
106
107 // return true if any drag operation is currently in progress
108 bool IsDragging() const { return IsResizing() || IsReordering(); }
109
aef252d9
VZ
110 // end any drag operation currently in progress (resizing or reordering)
111 void EndDragging();
112
6327cdd5
VZ
113 // cancel the drag operation currently in progress and generate an event
114 // about it
115 void CancelDragging();
116
a45caa71
VZ
117 // start (if m_colBeingResized is -1) or continue resizing the column
118 //
119 // this generates wxEVT_COMMAND_HEADER_BEGIN_RESIZE/RESIZING events and can
120 // cancel the operation if the user handler decides so
121 void StartOrContinueResizing(unsigned int col, int xPhysical);
122
123 // end the resizing operation currently in progress and generate an event
124 // about it with its cancelled flag set if xPhysical is -1
125 void EndResizing(int xPhysical);
126
6327cdd5
VZ
127 // same functions as above but for column moving/reordering instead of
128 // resizing
129 void StartReordering(unsigned int col, int xPhysical);
59704b49
VZ
130
131 // returns true if we did drag the column somewhere else or false if we
132 // didn't really move it -- in this case we consider that no reordering
133 // took place and that a normal column click event should be generated
134 bool EndReordering(int xPhysical);
6327cdd5 135
a45caa71
VZ
136 // constrain the given position to be larger than the start position of the
137 // given column plus its minimal width and return the effective width
138 int ConstrainByMinWidth(unsigned int col, int& xPhysical);
aef252d9 139
6327cdd5 140 // update the current position of the resizing marker
aef252d9
VZ
141 void UpdateResizingMarker(int xPhysical);
142
6327cdd5
VZ
143 // update the information displayed while a column is being moved around
144 void UpdateReorderingMarker(int xPhysical);
145
146 // clear any overlaid markers
147 void ClearMarkers();
148
fa3d4aaf 149
40dc2ae6
VZ
150 // number of columns in the control currently
151 unsigned int m_numColumns;
152
b63f9a33
VZ
153 // index of the column under mouse or -1 if none
154 unsigned int m_hover;
155
aef252d9
VZ
156 // the column being resized or -1 if there is no resizing operation in
157 // progress
158 unsigned int m_colBeingResized;
159
6327cdd5
VZ
160 // the column being moved or -1 if there is no reordering operation in
161 // progress
162 unsigned int m_colBeingReordered;
163
164 // the distance from the start of m_colBeingReordered and the mouse
165 // position when the user started to drag it
166 int m_dragOffset;
167
b63f9a33
VZ
168 // the horizontal scroll offset
169 int m_scrollOffset;
170
aef252d9
VZ
171 // the overlay display used during the dragging operations
172 wxOverlay m_overlay;
173
20db5469
VZ
174 // the indices of the column appearing at the given position on the display
175 // (its size is always m_numColumns)
176 wxArrayInt m_colIndices;
177
b63f9a33
VZ
178
179 DECLARE_EVENT_TABLE()
180 DECLARE_NO_COPY_CLASS(wxHeaderCtrl)
181};
182
183#endif // _WX_GENERIC_HEADERCTRLG_H_
184