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