wxTreeEvent is declared in one header, not 3 of them
[wxWidgets.git] / include / wx / treectrl.h
1 #ifndef _WX_TREECTRL_H_BASE_
2 #define _WX_TREECTRL_H_BASE_
3
4 // ----------------------------------------------------------------------------
5 // headers
6 // ----------------------------------------------------------------------------
7
8 #include "wx/control.h"
9 #include "wx/event.h"
10
11 // ----------------------------------------------------------------------------
12 // include the platform-dependent wxTreeCtrl class
13 // ----------------------------------------------------------------------------
14
15 #if defined(__WXMSW__)
16 #ifdef __WIN16__
17 #include "wx/generic/treectrl.h"
18 #else
19 #include "wx/msw/treectrl.h"
20 #endif
21 #elif defined(__WXMOTIF__)
22 #include "wx/generic/treectrl.h"
23 #elif defined(__WXGTK__)
24 #include "wx/generic/treectrl.h"
25 #elif defined(__WXQT__)
26 #include "wx/qt/treectrl.h"
27 #elif defined(__WXMAC__)
28 #include "wx/generic/treectrl.h"
29 #elif defined(__WXSTUBS__)
30 #include "wx/generic/treectrl.h"
31 #endif
32
33 // ----------------------------------------------------------------------------
34 // wxTreeEvent is a special class for all events associated with tree controls
35 //
36 // NB: note that not all accessors make sense for all events, see the event
37 // descriptions below
38 // ----------------------------------------------------------------------------
39
40 class WXDLLEXPORT wxTreeEvent : public wxNotifyEvent
41 {
42 friend wxTreeCtrl;
43 public:
44 wxTreeEvent(wxEventType commandType = wxEVT_NULL, int id = 0);
45
46 // accessors
47 // get the item on which the operation was performed or the newly
48 // selected item for wxEVT_COMMAND_TREE_SEL_CHANGED/ING events
49 wxTreeItemId GetItem() const { return m_item; }
50
51 // for wxEVT_COMMAND_TREE_SEL_CHANGED/ING events, get the previously
52 // selected item
53 wxTreeItemId GetOldItem() const { return m_itemOld; }
54
55 // the point where the mouse was when the drag operation started (for
56 // wxEVT_COMMAND_TREE_BEGIN_(R)DRAG events only)
57 wxPoint GetPoint() const { return m_pointDrag; }
58
59 // keyboard code (for wxEVT_COMMAND_TREE_KEY_DOWN only)
60 int GetCode() const { return m_code; }
61
62 // label (for EVT_TREE_{BEGIN|END}_LABEL_EDIT only)
63 const wxString& GetLabel() const { return m_label; }
64
65 private:
66 // TODO we could save some space by using union here
67 int m_code;
68 wxTreeItemId m_item,
69 m_itemOld;
70 wxPoint m_pointDrag;
71 wxString m_label;
72
73 DECLARE_DYNAMIC_CLASS(wxTreeEvent)
74 };
75
76 typedef void (wxEvtHandler::*wxTreeEventFunction)(wxTreeEvent&);
77
78 // ----------------------------------------------------------------------------
79 // macros for handling tree control events
80 // ----------------------------------------------------------------------------
81
82 // GetItem() returns the item being dragged, GetPoint() the mouse coords
83 #define EVT_TREE_BEGIN_DRAG(id, fn) { wxEVT_COMMAND_TREE_BEGIN_DRAG, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn, (wxObject *) NULL },
84 #define EVT_TREE_BEGIN_RDRAG(id, fn) { wxEVT_COMMAND_TREE_BEGIN_RDRAG, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn, (wxObject *) NULL },
85
86 // GetItem() returns the itme whose label is being edited, GetLabel() returns
87 // the current item label for BEGIN and the would be new one for END.
88 //
89 // Vetoing BEGIN event means that label editing won't happen at all,
90 // vetoing END means that the new value is discarded and the old one kept
91 #define EVT_TREE_BEGIN_LABEL_EDIT(id, fn) { wxEVT_COMMAND_TREE_BEGIN_LABEL_EDIT, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn, (wxObject *) NULL },
92 #define EVT_TREE_END_LABEL_EDIT(id, fn) { wxEVT_COMMAND_TREE_END_LABEL_EDIT, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn, (wxObject *) NULL },
93
94 // provide/update information about GetItem() item
95 #define EVT_TREE_GET_INFO(id, fn) { wxEVT_COMMAND_TREE_GET_INFO, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn, (wxObject *) NULL },
96 #define EVT_TREE_SET_INFO(id, fn) { wxEVT_COMMAND_TREE_SET_INFO, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn, (wxObject *) NULL },
97
98 // GetItem() is the item being expanded/collapsed, the "ING" versions can use
99 #define EVT_TREE_ITEM_EXPANDED(id, fn) { wxEVT_COMMAND_TREE_ITEM_EXPANDED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn, (wxObject *) NULL },
100 #define EVT_TREE_ITEM_EXPANDING(id, fn) { wxEVT_COMMAND_TREE_ITEM_EXPANDING, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn, (wxObject *) NULL },
101 #define EVT_TREE_ITEM_COLLAPSED(id, fn) { wxEVT_COMMAND_TREE_ITEM_COLLAPSED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn, (wxObject *) NULL },
102 #define EVT_TREE_ITEM_COLLAPSING(id, fn) { wxEVT_COMMAND_TREE_ITEM_COLLAPSING, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn, NULL },
103
104 // GetOldItem() is the item which had the selection previously, GetItem() is
105 // the item which acquires selection
106 #define EVT_TREE_SEL_CHANGED(id, fn) { wxEVT_COMMAND_TREE_SEL_CHANGED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn, NULL },
107 #define EVT_TREE_SEL_CHANGING(id, fn) { wxEVT_COMMAND_TREE_SEL_CHANGING, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn, NULL },
108
109 // GetCode() returns the key code
110 // NB: this is the only message for which GetItem() is invalid (you may get the
111 // item from GetSelection())
112 #define EVT_TREE_KEY_DOWN(id, fn) { wxEVT_COMMAND_TREE_KEY_DOWN, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn, NULL },
113
114 // GetItem() returns the item being deleted, the associated data (if any) will
115 // be deleted just after the return of this event handler (if any)
116 #define EVT_TREE_DELETE_ITEM(id, fn) { wxEVT_COMMAND_TREE_DELETE_ITEM, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn, (wxObject *) NULL },
117
118 // GetItem() returns the item that was activated (double click, enter, space)
119 #define EVT_TREE_ITEM_ACTIVATED(id, fn) { wxEVT_COMMAND_TREE_ITEM_ACTIVATED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn, NULL },
120
121 #endif
122 // _WX_TREECTRL_H_BASE_