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