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