]> git.saurik.com Git - wxWidgets.git/blame - include/wx/treectrl.h
Added UpdateAttrRows/Cols to change the row/column info in attributes as
[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:
23f681ec 152 // we could probably save some space by using union here
c193b707
VZ
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
23f681ec
VZ
169//
170// if you call event.Allow(), the drag operation will start and a
171// EVT_TREE_END_DRAG event will be sent when the drag is over.
c193b707
VZ
172#define EVT_TREE_BEGIN_DRAG(id, fn) { wxEVT_COMMAND_TREE_BEGIN_DRAG, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn, (wxObject *) NULL },
173#define EVT_TREE_BEGIN_RDRAG(id, fn) { wxEVT_COMMAND_TREE_BEGIN_RDRAG, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn, (wxObject *) NULL },
174
23f681ec
VZ
175// GetItem() is the item on which the drop occured (if any) and GetPoint() the
176// current mouse coords
177#define EVT_TREE_END_DRAG(id, fn) { wxEVT_COMMAND_TREE_END_DRAG, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn, (wxObject *) NULL },
178
c193b707
VZ
179// GetItem() returns the itme whose label is being edited, GetLabel() returns
180// the current item label for BEGIN and the would be new one for END.
181//
182// Vetoing BEGIN event means that label editing won't happen at all,
183// vetoing END means that the new value is discarded and the old one kept
184#define EVT_TREE_BEGIN_LABEL_EDIT(id, fn) { wxEVT_COMMAND_TREE_BEGIN_LABEL_EDIT, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn, (wxObject *) NULL },
185#define EVT_TREE_END_LABEL_EDIT(id, fn) { wxEVT_COMMAND_TREE_END_LABEL_EDIT, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn, (wxObject *) NULL },
186
187// provide/update information about GetItem() item
188#define EVT_TREE_GET_INFO(id, fn) { wxEVT_COMMAND_TREE_GET_INFO, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn, (wxObject *) NULL },
189#define EVT_TREE_SET_INFO(id, fn) { wxEVT_COMMAND_TREE_SET_INFO, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn, (wxObject *) NULL },
190
d90895ac 191// GetItem() is the item being expanded/collapsed, the "ING" versions can use
c193b707
VZ
192#define EVT_TREE_ITEM_EXPANDED(id, fn) { wxEVT_COMMAND_TREE_ITEM_EXPANDED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn, (wxObject *) NULL },
193#define EVT_TREE_ITEM_EXPANDING(id, fn) { wxEVT_COMMAND_TREE_ITEM_EXPANDING, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn, (wxObject *) NULL },
194#define EVT_TREE_ITEM_COLLAPSED(id, fn) { wxEVT_COMMAND_TREE_ITEM_COLLAPSED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn, (wxObject *) NULL },
195#define EVT_TREE_ITEM_COLLAPSING(id, fn) { wxEVT_COMMAND_TREE_ITEM_COLLAPSING, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn, NULL },
196
197// GetOldItem() is the item which had the selection previously, GetItem() is
198// the item which acquires selection
199#define EVT_TREE_SEL_CHANGED(id, fn) { wxEVT_COMMAND_TREE_SEL_CHANGED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn, NULL },
200#define EVT_TREE_SEL_CHANGING(id, fn) { wxEVT_COMMAND_TREE_SEL_CHANGING, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn, NULL },
201
202// GetCode() returns the key code
203// NB: this is the only message for which GetItem() is invalid (you may get the
204// item from GetSelection())
205#define EVT_TREE_KEY_DOWN(id, fn) { wxEVT_COMMAND_TREE_KEY_DOWN, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn, NULL },
206
207// GetItem() returns the item being deleted, the associated data (if any) will
208// be deleted just after the return of this event handler (if any)
209#define EVT_TREE_DELETE_ITEM(id, fn) { wxEVT_COMMAND_TREE_DELETE_ITEM, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn, (wxObject *) NULL },
210
211// GetItem() returns the item that was activated (double click, enter, space)
212#define EVT_TREE_ITEM_ACTIVATED(id, fn) { wxEVT_COMMAND_TREE_ITEM_ACTIVATED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn, NULL },
213
aad0fe4b
UC
214// GetItem() returns the item that was clicked on
215#define EVT_TREE_ITEM_RIGHT_CLICK(id, fn) { wxEVT_COMMAND_TREE_ITEM_RIGHT_CLICK, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn, NULL },
216#define EVT_TREE_ITEM_MIDDLE_CLICK(id, fn) { wxEVT_COMMAND_TREE_ITEM_MIDDLE_CLICK, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn, NULL },
217
c801d85f 218#endif
34138703 219 // _WX_TREECTRL_H_BASE_
aad0fe4b
UC
220
221