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