]> git.saurik.com Git - wxWidgets.git/blame - include/wx/treectrl.h
removed platform specific #ifdefs around wxComboBox
[wxWidgets.git] / include / wx / treectrl.h
CommitLineData
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
16enum 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
9ec64fa7
VZ
25
26// values for the `flags' parameter of wxTreeCtrl::HitTest() which determine
27// where exactly the specified point is situated:
28
29static const int wxTREE_HITTEST_ABOVE = 0x0001;
30static const int wxTREE_HITTEST_BELOW = 0x0002;
31static const int wxTREE_HITTEST_NOWHERE = 0x0004;
32 // on the button associated with an item.
33static const int wxTREE_HITTEST_ONITEMBUTTON = 0x0008;
34 // on the bitmap associated with an item.
35static const int wxTREE_HITTEST_ONITEMICON = 0x0010;
696e1ea0
VZ
36 // on the indent associated with an item.
37static const int wxTREE_HITTEST_ONITEMINDENT = 0x0020;
9ec64fa7
VZ
38 // on the label (string) associated with an item.
39static const int wxTREE_HITTEST_ONITEMLABEL = 0x0040;
40 // on the right of the label associated with an item.
41static const int wxTREE_HITTEST_ONITEMRIGHT = 0x0080;
42 // on the label (string) associated with an item.
696e1ea0 43static const int wxTREE_HITTEST_ONITEMSTATEICON = 0x0100;
9ec64fa7
VZ
44 // on the left of the wxTreeCtrl.
45static const int wxTREE_HITTEST_TOLEFT = 0x0200;
46 // on the right of the wxTreeCtrl.
47static const int wxTREE_HITTEST_TORIGHT = 0x0400;
48 // on the upper part (first half) of the item.
49static const int wxTREE_HITTEST_ONITEMUPPERPART = 0x0800;
50 // on the lower part (second half) of the item.
51static const int wxTREE_HITTEST_ONITEMLOWERPART = 0x1000;
52
53 // anywhere on the item
54static const int wxTREE_HITTEST_ONITEM = wxTREE_HITTEST_ONITEMICON |
55 wxTREE_HITTEST_ONITEMLABEL;
56
74b31181 57// tree ctrl default name
9ec64fa7
VZ
58WXDLLEXPORT_DATA(extern const char*) wxTreeCtrlNameStr;
59
60// ----------------------------------------------------------------------------
61// wxTreeItemAttr: a structure containing the visual attributes of an item
62// ----------------------------------------------------------------------------
63
64class WXDLLEXPORT wxTreeItemAttr
65{
66public:
67 // ctors
68 wxTreeItemAttr() { }
69 wxTreeItemAttr(const wxColour& colText,
70 const wxColour& colBack,
71 const wxFont& font)
72 : m_colText(colText), m_colBack(colBack), m_font(font) { }
73
74 // setters
75 void SetTextColour(const wxColour& colText) { m_colText = colText; }
76 void SetBackgroundColour(const wxColour& colBack) { m_colBack = colBack; }
77 void SetFont(const wxFont& font) { m_font = font; }
78
79 // accessors
80 bool HasTextColour() const { return m_colText.Ok(); }
81 bool HasBackgroundColour() const { return m_colBack.Ok(); }
82 bool HasFont() const { return m_font.Ok(); }
83
84 const wxColour& GetTextColour() const { return m_colText; }
85 const wxColour& GetBackgroundColour() const { return m_colBack; }
86 const wxFont& GetFont() const { return m_font; }
87
88private:
89 wxColour m_colText,
90 m_colBack;
91 wxFont m_font;
92};
1044a386 93
c193b707
VZ
94// ----------------------------------------------------------------------------
95// include the platform-dependent wxTreeCtrl class
96// ----------------------------------------------------------------------------
97
2049ba38 98#if defined(__WXMSW__)
c193b707
VZ
99 #ifdef __WIN16__
100 #include "wx/generic/treectrl.h"
101 #else
102 #include "wx/msw/treectrl.h"
103 #endif
2049ba38 104#elif defined(__WXMOTIF__)
c193b707 105 #include "wx/generic/treectrl.h"
2049ba38 106#elif defined(__WXGTK__)
c193b707 107 #include "wx/generic/treectrl.h"
34138703 108#elif defined(__WXQT__)
c193b707 109 #include "wx/qt/treectrl.h"
34138703 110#elif defined(__WXMAC__)
c193b707 111 #include "wx/generic/treectrl.h"
1777b9bb 112#elif defined(__WXPM__)
e6ebb514 113 #include "wx/generic/treectrl.h"
34138703 114#elif defined(__WXSTUBS__)
c193b707 115 #include "wx/generic/treectrl.h"
c801d85f
KB
116#endif
117
c193b707
VZ
118// ----------------------------------------------------------------------------
119// wxTreeEvent is a special class for all events associated with tree controls
120//
121// NB: note that not all accessors make sense for all events, see the event
122// descriptions below
123// ----------------------------------------------------------------------------
124
125class WXDLLEXPORT wxTreeEvent : public wxNotifyEvent
126{
d5a07b9e 127 friend class WXDLLEXPORT wxTreeCtrl;
585ae8cb 128
c193b707
VZ
129public:
130 wxTreeEvent(wxEventType commandType = wxEVT_NULL, int id = 0);
131
132 // accessors
133 // get the item on which the operation was performed or the newly
134 // selected item for wxEVT_COMMAND_TREE_SEL_CHANGED/ING events
135 wxTreeItemId GetItem() const { return m_item; }
136
137 // for wxEVT_COMMAND_TREE_SEL_CHANGED/ING events, get the previously
138 // selected item
139 wxTreeItemId GetOldItem() const { return m_itemOld; }
140
141 // the point where the mouse was when the drag operation started (for
142 // wxEVT_COMMAND_TREE_BEGIN_(R)DRAG events only)
143 wxPoint GetPoint() const { return m_pointDrag; }
144
145 // keyboard code (for wxEVT_COMMAND_TREE_KEY_DOWN only)
146 int GetCode() const { return m_code; }
147
148 // label (for EVT_TREE_{BEGIN|END}_LABEL_EDIT only)
149 const wxString& GetLabel() const { return m_label; }
150
151private:
152 // TODO we could save some space by using union here
153 int m_code;
154 wxTreeItemId m_item,
155 m_itemOld;
156 wxPoint m_pointDrag;
157 wxString m_label;
158
159 DECLARE_DYNAMIC_CLASS(wxTreeEvent)
160};
161
162typedef void (wxEvtHandler::*wxTreeEventFunction)(wxTreeEvent&);
163
164// ----------------------------------------------------------------------------
165// macros for handling tree control events
166// ----------------------------------------------------------------------------
167
168// GetItem() returns the item being dragged, GetPoint() the mouse coords
169#define EVT_TREE_BEGIN_DRAG(id, fn) { wxEVT_COMMAND_TREE_BEGIN_DRAG, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn, (wxObject *) NULL },
170#define EVT_TREE_BEGIN_RDRAG(id, fn) { wxEVT_COMMAND_TREE_BEGIN_RDRAG, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn, (wxObject *) NULL },
171
172// GetItem() returns the itme whose label is being edited, GetLabel() returns
173// the current item label for BEGIN and the would be new one for END.
174//
175// Vetoing BEGIN event means that label editing won't happen at all,
176// vetoing END means that the new value is discarded and the old one kept
177#define EVT_TREE_BEGIN_LABEL_EDIT(id, fn) { wxEVT_COMMAND_TREE_BEGIN_LABEL_EDIT, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn, (wxObject *) NULL },
178#define EVT_TREE_END_LABEL_EDIT(id, fn) { wxEVT_COMMAND_TREE_END_LABEL_EDIT, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn, (wxObject *) NULL },
179
180// provide/update information about GetItem() item
181#define EVT_TREE_GET_INFO(id, fn) { wxEVT_COMMAND_TREE_GET_INFO, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn, (wxObject *) NULL },
182#define EVT_TREE_SET_INFO(id, fn) { wxEVT_COMMAND_TREE_SET_INFO, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn, (wxObject *) NULL },
183
d90895ac 184// GetItem() is the item being expanded/collapsed, the "ING" versions can use
c193b707
VZ
185#define EVT_TREE_ITEM_EXPANDED(id, fn) { wxEVT_COMMAND_TREE_ITEM_EXPANDED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn, (wxObject *) NULL },
186#define EVT_TREE_ITEM_EXPANDING(id, fn) { wxEVT_COMMAND_TREE_ITEM_EXPANDING, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn, (wxObject *) NULL },
187#define EVT_TREE_ITEM_COLLAPSED(id, fn) { wxEVT_COMMAND_TREE_ITEM_COLLAPSED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn, (wxObject *) NULL },
188#define EVT_TREE_ITEM_COLLAPSING(id, fn) { wxEVT_COMMAND_TREE_ITEM_COLLAPSING, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn, NULL },
189
190// GetOldItem() is the item which had the selection previously, GetItem() is
191// the item which acquires selection
192#define EVT_TREE_SEL_CHANGED(id, fn) { wxEVT_COMMAND_TREE_SEL_CHANGED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn, NULL },
193#define EVT_TREE_SEL_CHANGING(id, fn) { wxEVT_COMMAND_TREE_SEL_CHANGING, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn, NULL },
194
195// GetCode() returns the key code
196// NB: this is the only message for which GetItem() is invalid (you may get the
197// item from GetSelection())
198#define EVT_TREE_KEY_DOWN(id, fn) { wxEVT_COMMAND_TREE_KEY_DOWN, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn, NULL },
199
200// GetItem() returns the item being deleted, the associated data (if any) will
201// be deleted just after the return of this event handler (if any)
202#define EVT_TREE_DELETE_ITEM(id, fn) { wxEVT_COMMAND_TREE_DELETE_ITEM, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn, (wxObject *) NULL },
203
204// GetItem() returns the item that was activated (double click, enter, space)
205#define EVT_TREE_ITEM_ACTIVATED(id, fn) { wxEVT_COMMAND_TREE_ITEM_ACTIVATED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn, NULL },
206
aad0fe4b
UC
207// GetItem() returns the item that was clicked on
208#define EVT_TREE_ITEM_RIGHT_CLICK(id, fn) { wxEVT_COMMAND_TREE_ITEM_RIGHT_CLICK, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn, NULL },
209#define EVT_TREE_ITEM_MIDDLE_CLICK(id, fn) { wxEVT_COMMAND_TREE_ITEM_MIDDLE_CLICK, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn, NULL },
210
c801d85f 211#endif
34138703 212 // _WX_TREECTRL_H_BASE_
aad0fe4b
UC
213
214