]> git.saurik.com Git - wxWidgets.git/blame - include/wx/generic/headerctrlg.h
fix wxOS2 build where OpenGL headers are available but there's no wxGlCanvas implemen...
[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
59 // override wxWindow methods which must be implemented by a new control
60 virtual wxSize DoGetBestSize() const;
61
62 // common part of all ctors
63 void Init();
64
65 // event handlers
66 void OnPaint(wxPaintEvent& event);
67 void OnMouse(wxMouseEvent& event);
e36dcd10 68 void OnKeyDown(wxKeyEvent& event);
aef252d9 69 void OnCaptureLost(wxMouseCaptureLostEvent& event);
b63f9a33 70
8fad69b0
VZ
71 // return the horizontal start position of the given column in physical
72 // coordinates
b63f9a33
VZ
73 int GetColStart(unsigned int idx) const;
74
3bfaa5a7 75 // refresh the given column [only]; idx must be valid
b63f9a33
VZ
76 void RefreshCol(unsigned int idx);
77
3bfaa5a7
VZ
78 // refresh the given column if idx is valid
79 void RefreshColIfNotNone(unsigned int idx);
80
b63f9a33
VZ
81 // refresh all the controls starting from (and including) the given one
82 void RefreshColsAfter(unsigned int idx);
83
fa3d4aaf
VZ
84 // return the column at the given position or -1 if it is beyond the
85 // rightmost column and put true into onSeparator output parameter if the
86 // position is near the divider at the right end of this column (notice
87 // that this means that we return column 0 even if the position is over
88 // column 1 but close enough to the divider separating it from column 0)
89 int FindColumnAtPos(int x, bool& onSeparator) const;
e36dcd10
VZ
90
91 // return true if a drag resizing operation is currently in progress
92 bool IsResizing() const;
fa3d4aaf 93
aef252d9
VZ
94 // end any drag operation currently in progress (resizing or reordering)
95 void EndDragging();
96
a45caa71
VZ
97 // start (if m_colBeingResized is -1) or continue resizing the column
98 //
99 // this generates wxEVT_COMMAND_HEADER_BEGIN_RESIZE/RESIZING events and can
100 // cancel the operation if the user handler decides so
101 void StartOrContinueResizing(unsigned int col, int xPhysical);
102
103 // end the resizing operation currently in progress and generate an event
104 // about it with its cancelled flag set if xPhysical is -1
105 void EndResizing(int xPhysical);
106
107 // constrain the given position to be larger than the start position of the
108 // given column plus its minimal width and return the effective width
109 int ConstrainByMinWidth(unsigned int col, int& xPhysical);
aef252d9
VZ
110
111 // update the current position of the resizing marker if xPhysical is a
112 // valid physical coordinate value or remove it entirely if it is -1
113 void UpdateResizingMarker(int xPhysical);
114
fa3d4aaf 115
40dc2ae6
VZ
116 // number of columns in the control currently
117 unsigned int m_numColumns;
118
b63f9a33
VZ
119 // index of the column under mouse or -1 if none
120 unsigned int m_hover;
121
aef252d9
VZ
122 // the column being resized or -1 if there is no resizing operation in
123 // progress
124 unsigned int m_colBeingResized;
125
b63f9a33
VZ
126 // the horizontal scroll offset
127 int m_scrollOffset;
128
aef252d9
VZ
129 // the overlay display used during the dragging operations
130 wxOverlay m_overlay;
131
b63f9a33
VZ
132
133 DECLARE_EVENT_TABLE()
134 DECLARE_NO_COPY_CLASS(wxHeaderCtrl)
135};
136
137#endif // _WX_GENERIC_HEADERCTRLG_H_
138