1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: wx/generic/headerctrlg.h
3 // Purpose: Generic wxHeaderCtrl implementation
4 // Author: Vadim Zeitlin
7 // Copyright: (c) 2008 Vadim Zeitlin <vadim@wxwidgets.org>
8 // Licence: wxWindows licence
9 ///////////////////////////////////////////////////////////////////////////////
11 #ifndef _WX_GENERIC_HEADERCTRLG_H_
12 #define _WX_GENERIC_HEADERCTRLG_H_
15 #include "wx/vector.h"
16 #include "wx/overlay.h"
18 // ----------------------------------------------------------------------------
20 // ----------------------------------------------------------------------------
22 class WXDLLIMPEXP_CORE wxHeaderCtrl
: public wxHeaderCtrlBase
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
)
39 Create(parent
, id
, pos
, size
, style
, name
);
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
);
49 virtual ~wxHeaderCtrl();
52 // implement base class pure virtuals
53 virtual void DoSetCount(unsigned int count
);
54 virtual unsigned int DoGetCount() const;
55 virtual void DoUpdate(unsigned int idx
);
57 virtual void DoScrollHorz(int dx
);
59 // override wxWindow methods which must be implemented by a new control
60 virtual wxSize
DoGetBestSize() const;
62 // common part of all ctors
66 void OnPaint(wxPaintEvent
& event
);
67 void OnMouse(wxMouseEvent
& event
);
68 void OnCaptureLost(wxMouseCaptureLostEvent
& event
);
70 // return the horizontal start position of the given column
71 int GetColStart(unsigned int idx
) const;
73 // refresh the given column [only]; idx must be valid
74 void RefreshCol(unsigned int idx
);
76 // refresh the given column if idx is valid
77 void RefreshColIfNotNone(unsigned int idx
);
79 // refresh all the controls starting from (and including) the given one
80 void RefreshColsAfter(unsigned int idx
);
82 // return the column at the given position or -1 if it is beyond the
83 // rightmost column and put true into onSeparator output parameter if the
84 // position is near the divider at the right end of this column (notice
85 // that this means that we return column 0 even if the position is over
86 // column 1 but close enough to the divider separating it from column 0)
87 int FindColumnAtPos(int x
, bool& onSeparator
) const;
89 // end any drag operation currently in progress (resizing or reordering)
92 // and the resizing operation currently in progress and generate an event
93 // about it with its cancelled flag set if width is -1
94 void EndResizing(int width
);
96 // update the current position of the resizing marker if xPhysical is a
97 // valid physical coordinate value or remove it entirely if it is -1
98 void UpdateResizingMarker(int xPhysical
);
101 // number of columns in the control currently
102 unsigned int m_numColumns
;
104 // index of the column under mouse or -1 if none
105 unsigned int m_hover
;
107 // the column being resized or -1 if there is no resizing operation in
109 unsigned int m_colBeingResized
;
111 // the horizontal scroll offset
114 // the overlay display used during the dragging operations
118 DECLARE_EVENT_TABLE()
119 DECLARE_NO_COPY_CLASS(wxHeaderCtrl
)
122 #endif // _WX_GENERIC_HEADERCTRLG_H_