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