]>
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 | ||
1044a386 JS |
11 | // ---------------------------------------------------------------------------- |
12 | // constants | |
13 | // ---------------------------------------------------------------------------- | |
14 | ||
74b31181 VZ |
15 | // enum for different images associated with a treectrl item |
16 | enum wxTreeItemIcon | |
17 | { | |
18 | wxTreeItemIcon_Normal, // not selected, not expanded | |
19 | wxTreeItemIcon_Selected, // selected, not expanded | |
20 | wxTreeItemIcon_Expanded, // not selected, expanded | |
21 | wxTreeItemIcon_SelectedExpanded, // selected, expanded | |
22 | wxTreeItemIcon_Max | |
23 | }; | |
24 | ||
25 | // tree ctrl default name | |
1044a386 | 26 | #ifdef __WXMSW__ |
74b31181 | 27 | WXDLLEXPORT_DATA(extern const char*) wxTreeCtrlNameStr; |
1044a386 | 28 | #else |
74b31181 | 29 | #define wxTreeCtrlNameStr "wxTreeCtrl" |
1044a386 JS |
30 | #endif |
31 | ||
c193b707 VZ |
32 | // ---------------------------------------------------------------------------- |
33 | // include the platform-dependent wxTreeCtrl class | |
34 | // ---------------------------------------------------------------------------- | |
35 | ||
2049ba38 | 36 | #if defined(__WXMSW__) |
c193b707 VZ |
37 | #ifdef __WIN16__ |
38 | #include "wx/generic/treectrl.h" | |
39 | #else | |
40 | #include "wx/msw/treectrl.h" | |
41 | #endif | |
2049ba38 | 42 | #elif defined(__WXMOTIF__) |
c193b707 | 43 | #include "wx/generic/treectrl.h" |
2049ba38 | 44 | #elif defined(__WXGTK__) |
c193b707 | 45 | #include "wx/generic/treectrl.h" |
34138703 | 46 | #elif defined(__WXQT__) |
c193b707 | 47 | #include "wx/qt/treectrl.h" |
34138703 | 48 | #elif defined(__WXMAC__) |
c193b707 | 49 | #include "wx/generic/treectrl.h" |
1777b9bb | 50 | #elif defined(__WXPM__) |
d90895ac | 51 | #include "wx/os2/treectrl.h" |
34138703 | 52 | #elif defined(__WXSTUBS__) |
c193b707 | 53 | #include "wx/generic/treectrl.h" |
c801d85f KB |
54 | #endif |
55 | ||
c193b707 VZ |
56 | // ---------------------------------------------------------------------------- |
57 | // wxTreeEvent is a special class for all events associated with tree controls | |
58 | // | |
59 | // NB: note that not all accessors make sense for all events, see the event | |
60 | // descriptions below | |
61 | // ---------------------------------------------------------------------------- | |
62 | ||
63 | class WXDLLEXPORT wxTreeEvent : public wxNotifyEvent | |
64 | { | |
d5a07b9e | 65 | friend class WXDLLEXPORT wxTreeCtrl; |
585ae8cb | 66 | |
c193b707 VZ |
67 | public: |
68 | wxTreeEvent(wxEventType commandType = wxEVT_NULL, int id = 0); | |
69 | ||
70 | // accessors | |
71 | // get the item on which the operation was performed or the newly | |
72 | // selected item for wxEVT_COMMAND_TREE_SEL_CHANGED/ING events | |
73 | wxTreeItemId GetItem() const { return m_item; } | |
74 | ||
75 | // for wxEVT_COMMAND_TREE_SEL_CHANGED/ING events, get the previously | |
76 | // selected item | |
77 | wxTreeItemId GetOldItem() const { return m_itemOld; } | |
78 | ||
79 | // the point where the mouse was when the drag operation started (for | |
80 | // wxEVT_COMMAND_TREE_BEGIN_(R)DRAG events only) | |
81 | wxPoint GetPoint() const { return m_pointDrag; } | |
82 | ||
83 | // keyboard code (for wxEVT_COMMAND_TREE_KEY_DOWN only) | |
84 | int GetCode() const { return m_code; } | |
85 | ||
86 | // label (for EVT_TREE_{BEGIN|END}_LABEL_EDIT only) | |
87 | const wxString& GetLabel() const { return m_label; } | |
88 | ||
89 | private: | |
90 | // TODO we could save some space by using union here | |
91 | int m_code; | |
92 | wxTreeItemId m_item, | |
93 | m_itemOld; | |
94 | wxPoint m_pointDrag; | |
95 | wxString m_label; | |
96 | ||
97 | DECLARE_DYNAMIC_CLASS(wxTreeEvent) | |
98 | }; | |
99 | ||
100 | typedef void (wxEvtHandler::*wxTreeEventFunction)(wxTreeEvent&); | |
101 | ||
102 | // ---------------------------------------------------------------------------- | |
103 | // macros for handling tree control events | |
104 | // ---------------------------------------------------------------------------- | |
105 | ||
106 | // GetItem() returns the item being dragged, GetPoint() the mouse coords | |
107 | #define EVT_TREE_BEGIN_DRAG(id, fn) { wxEVT_COMMAND_TREE_BEGIN_DRAG, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn, (wxObject *) NULL }, | |
108 | #define EVT_TREE_BEGIN_RDRAG(id, fn) { wxEVT_COMMAND_TREE_BEGIN_RDRAG, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn, (wxObject *) NULL }, | |
109 | ||
110 | // GetItem() returns the itme whose label is being edited, GetLabel() returns | |
111 | // the current item label for BEGIN and the would be new one for END. | |
112 | // | |
113 | // Vetoing BEGIN event means that label editing won't happen at all, | |
114 | // vetoing END means that the new value is discarded and the old one kept | |
115 | #define EVT_TREE_BEGIN_LABEL_EDIT(id, fn) { wxEVT_COMMAND_TREE_BEGIN_LABEL_EDIT, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn, (wxObject *) NULL }, | |
116 | #define EVT_TREE_END_LABEL_EDIT(id, fn) { wxEVT_COMMAND_TREE_END_LABEL_EDIT, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn, (wxObject *) NULL }, | |
117 | ||
118 | // provide/update information about GetItem() item | |
119 | #define EVT_TREE_GET_INFO(id, fn) { wxEVT_COMMAND_TREE_GET_INFO, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn, (wxObject *) NULL }, | |
120 | #define EVT_TREE_SET_INFO(id, fn) { wxEVT_COMMAND_TREE_SET_INFO, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn, (wxObject *) NULL }, | |
121 | ||
d90895ac | 122 | // GetItem() is the item being expanded/collapsed, the "ING" versions can use |
c193b707 VZ |
123 | #define EVT_TREE_ITEM_EXPANDED(id, fn) { wxEVT_COMMAND_TREE_ITEM_EXPANDED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn, (wxObject *) NULL }, |
124 | #define EVT_TREE_ITEM_EXPANDING(id, fn) { wxEVT_COMMAND_TREE_ITEM_EXPANDING, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn, (wxObject *) NULL }, | |
125 | #define EVT_TREE_ITEM_COLLAPSED(id, fn) { wxEVT_COMMAND_TREE_ITEM_COLLAPSED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn, (wxObject *) NULL }, | |
126 | #define EVT_TREE_ITEM_COLLAPSING(id, fn) { wxEVT_COMMAND_TREE_ITEM_COLLAPSING, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn, NULL }, | |
127 | ||
128 | // GetOldItem() is the item which had the selection previously, GetItem() is | |
129 | // the item which acquires selection | |
130 | #define EVT_TREE_SEL_CHANGED(id, fn) { wxEVT_COMMAND_TREE_SEL_CHANGED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn, NULL }, | |
131 | #define EVT_TREE_SEL_CHANGING(id, fn) { wxEVT_COMMAND_TREE_SEL_CHANGING, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn, NULL }, | |
132 | ||
133 | // GetCode() returns the key code | |
134 | // NB: this is the only message for which GetItem() is invalid (you may get the | |
135 | // item from GetSelection()) | |
136 | #define EVT_TREE_KEY_DOWN(id, fn) { wxEVT_COMMAND_TREE_KEY_DOWN, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn, NULL }, | |
137 | ||
138 | // GetItem() returns the item being deleted, the associated data (if any) will | |
139 | // be deleted just after the return of this event handler (if any) | |
140 | #define EVT_TREE_DELETE_ITEM(id, fn) { wxEVT_COMMAND_TREE_DELETE_ITEM, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn, (wxObject *) NULL }, | |
141 | ||
142 | // GetItem() returns the item that was activated (double click, enter, space) | |
143 | #define EVT_TREE_ITEM_ACTIVATED(id, fn) { wxEVT_COMMAND_TREE_ITEM_ACTIVATED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn, NULL }, | |
144 | ||
aad0fe4b UC |
145 | // GetItem() returns the item that was clicked on |
146 | #define EVT_TREE_ITEM_RIGHT_CLICK(id, fn) { wxEVT_COMMAND_TREE_ITEM_RIGHT_CLICK, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn, NULL }, | |
147 | #define EVT_TREE_ITEM_MIDDLE_CLICK(id, fn) { wxEVT_COMMAND_TREE_ITEM_MIDDLE_CLICK, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn, NULL }, | |
148 | ||
c801d85f | 149 | #endif |
34138703 | 150 | // _WX_TREECTRL_H_BASE_ |
aad0fe4b UC |
151 | |
152 |