]> git.saurik.com Git - wxWidgets.git/blame_incremental - include/wx/generic/headerctrlg.h
don't access inexistent column in wxDataViewTreeCtrl::OnSize() (this bug also probabl...
[wxWidgets.git] / include / wx / generic / headerctrlg.h
... / ...
CommitLineData
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"
16
17// ----------------------------------------------------------------------------
18// wxHeaderCtrl
19// ----------------------------------------------------------------------------
20
21class WXDLLIMPEXP_CORE wxHeaderCtrl : public wxHeaderCtrlBase
22{
23public:
24 wxHeaderCtrl()
25 {
26 Init();
27 }
28
29 wxHeaderCtrl(wxWindow *parent,
30 wxWindowID id = wxID_ANY,
31 const wxPoint& pos = wxDefaultPosition,
32 const wxSize& size = wxDefaultSize,
33 long style = wxHD_DEFAULT_STYLE,
34 const wxString& name = wxHeaderCtrlNameStr)
35 {
36 Init();
37
38 Create(parent, id, pos, size, style, name);
39 }
40
41 bool Create(wxWindow *parent,
42 wxWindowID id = wxID_ANY,
43 const wxPoint& pos = wxDefaultPosition,
44 const wxSize& size = wxDefaultSize,
45 long style = wxHD_DEFAULT_STYLE,
46 const wxString& name = wxHeaderCtrlNameStr);
47
48 virtual ~wxHeaderCtrl();
49
50private:
51 // implement base class pure virtuals
52 virtual void DoSetCount(unsigned int count);
53 virtual unsigned int DoGetCount() const;
54 virtual void DoUpdate(unsigned int idx);
55
56 virtual void DoScrollHorz(int dx);
57
58 // override wxWindow methods which must be implemented by a new control
59 virtual wxSize DoGetBestSize() const;
60
61 // common part of all ctors
62 void Init();
63
64 // event handlers
65 void OnPaint(wxPaintEvent& event);
66 void OnMouse(wxMouseEvent& event);
67
68 // return the horizontal start position of the given column
69 int GetColStart(unsigned int idx) const;
70
71 // refresh the given column [only]; idx must be valid
72 void RefreshCol(unsigned int idx);
73
74 // refresh the given column if idx is valid
75 void RefreshColIfNotNone(unsigned int idx);
76
77 // refresh all the controls starting from (and including) the given one
78 void RefreshColsAfter(unsigned int idx);
79
80 // return the column at the given position or -1 if it is beyond the
81 // rightmost column and put true into onSeparator output parameter if the
82 // position is near the divider at the right end of this column (notice
83 // that this means that we return column 0 even if the position is over
84 // column 1 but close enough to the divider separating it from column 0)
85 int FindColumnAtPos(int x, bool& onSeparator) const;
86
87
88 // number of columns in the control currently
89 unsigned int m_numColumns;
90
91 // index of the column under mouse or -1 if none
92 unsigned int m_hover;
93
94 // the horizontal scroll offset
95 int m_scrollOffset;
96
97
98 DECLARE_EVENT_TABLE()
99 DECLARE_NO_COPY_CLASS(wxHeaderCtrl)
100};
101
102#endif // _WX_GENERIC_HEADERCTRLG_H_
103