]> git.saurik.com Git - wxWidgets.git/blob - src/stubs/treectrl.cpp
[gtk] fixed bug that caused segfaults in wxYield when wxToolBar has non-button contr...
[wxWidgets.git] / src / stubs / treectrl.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: treectrl.cpp
3 // Purpose: wxTreeCtrl. See also Robert's generic wxTreeCtrl.
4 // Author: AUTHOR
5 // Modified by:
6 // Created: ??/??/98
7 // RCS-ID: $Id$
8 // Copyright: (c) AUTHOR
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifdef __GNUG__
13 #pragma implementation "treectrl.h"
14 #endif
15
16 #include "wx/stubs/textctrl.h"
17 #include "wx/stubs/treectrl.h"
18
19 #if !USE_SHARED_LIBRARY
20 IMPLEMENT_DYNAMIC_CLASS(wxTreeCtrl, wxControl)
21 IMPLEMENT_DYNAMIC_CLASS(wxTreeItem, wxObject)
22
23 #endif
24
25 wxTreeCtrl::wxTreeCtrl()
26 {
27 m_imageListNormal = NULL;
28 m_imageListState = NULL;
29 m_textCtrl = NULL;
30 }
31
32 bool wxTreeCtrl::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size,
33 long style, const wxValidator& validator, const wxString& name)
34 {
35 SetName(name);
36 SetValidator(validator);
37
38 m_imageListNormal = NULL;
39 m_imageListState = NULL;
40 m_textCtrl = NULL;
41
42 m_windowStyle = style;
43
44 SetParent(parent);
45
46 m_windowId = (id == -1) ? NewControlId() : id;
47
48 if (parent) parent->AddChild(this);
49
50 // TODO create tree control
51
52 return FALSE;
53 }
54
55 wxTreeCtrl::~wxTreeCtrl()
56 {
57 if (m_textCtrl)
58 {
59 delete m_textCtrl;
60 }
61 }
62
63 // Attributes
64 int wxTreeCtrl::GetCount() const
65 {
66 // TODO
67 return 0;
68 }
69
70 int wxTreeCtrl::GetIndent() const
71 {
72 // TODO
73 return 0;
74 }
75
76 void wxTreeCtrl::SetIndent(int indent)
77 {
78 // TODO
79 }
80
81 wxImageList *wxTreeCtrl::GetImageList(int which) const
82 {
83 if ( which == wxIMAGE_LIST_NORMAL )
84 {
85 return m_imageListNormal;
86 }
87 else if ( which == wxIMAGE_LIST_STATE )
88 {
89 return m_imageListState;
90 }
91 return NULL;
92 }
93
94 void wxTreeCtrl::SetImageList(wxImageList *imageList, int which)
95 {
96 if ( which == wxIMAGE_LIST_NORMAL )
97 {
98 m_imageListNormal = imageList;
99 }
100 else if ( which == wxIMAGE_LIST_STATE )
101 {
102 m_imageListState = imageList;
103 }
104 // TODO
105 }
106
107 long wxTreeCtrl::GetNextItem(long item, int code) const
108 {
109 // TODO
110 return 0;
111 }
112
113 bool wxTreeCtrl::ItemHasChildren(long item) const
114 {
115 // TODO
116 return FALSE;
117 }
118
119 long wxTreeCtrl::GetChild(long item) const
120 {
121 // TODO
122 return 0;
123 }
124
125 long wxTreeCtrl::GetParent(long item) const
126 {
127 // TODO
128 return 0;
129 }
130
131 long wxTreeCtrl::GetFirstVisibleItem() const
132 {
133 // TODO
134 return 0;
135 }
136
137 long wxTreeCtrl::GetNextVisibleItem(long item) const
138 {
139 // TODO
140 return 0;
141 }
142
143 long wxTreeCtrl::GetSelection() const
144 {
145 // TODO
146 return 0;
147 }
148
149 long wxTreeCtrl::GetRootItem() const
150 {
151 // TODO
152 return 0;
153 }
154
155 bool wxTreeCtrl::GetItem(wxTreeItem& info) const
156 {
157 // TODO
158 return FALSE;
159 }
160
161 bool wxTreeCtrl::SetItem(wxTreeItem& info)
162 {
163 // TODO
164 return FALSE;
165 }
166
167 int wxTreeCtrl::GetItemState(long item, long stateMask) const
168 {
169 wxTreeItem info;
170
171 info.m_mask = wxTREE_MASK_STATE ;
172 info.m_stateMask = stateMask;
173 info.m_itemId = item;
174
175 if (!GetItem(info))
176 return 0;
177
178 return info.m_state;
179 }
180
181 bool wxTreeCtrl::SetItemState(long item, long state, long stateMask)
182 {
183 wxTreeItem info;
184
185 info.m_mask = wxTREE_MASK_STATE ;
186 info.m_state = state;
187 info.m_stateMask = stateMask;
188 info.m_itemId = item;
189
190 return SetItem(info);
191 }
192
193 bool wxTreeCtrl::SetItemImage(long item, int image, int selImage)
194 {
195 wxTreeItem info;
196
197 info.m_mask = wxTREE_MASK_IMAGE ;
198 info.m_image = image;
199 if ( selImage > -1)
200 {
201 info.m_selectedImage = selImage;
202 info.m_mask |= wxTREE_MASK_SELECTED_IMAGE;
203 }
204 info.m_itemId = item;
205
206 return SetItem(info);
207 }
208
209 wxString wxTreeCtrl::GetItemText(long item) const
210 {
211 wxTreeItem info;
212
213 info.m_mask = wxTREE_MASK_TEXT ;
214 info.m_itemId = item;
215
216 if (!GetItem(info))
217 return wxString("");
218 return info.m_text;
219 }
220
221 void wxTreeCtrl::SetItemText(long item, const wxString& str)
222 {
223 wxTreeItem info;
224
225 info.m_mask = wxTREE_MASK_TEXT ;
226 info.m_itemId = item;
227 info.m_text = str;
228
229 SetItem(info);
230 }
231
232 long wxTreeCtrl::GetItemData(long item) const
233 {
234 wxTreeItem info;
235
236 info.m_mask = wxTREE_MASK_DATA ;
237 info.m_itemId = item;
238
239 if (!GetItem(info))
240 return 0;
241 return info.m_data;
242 }
243
244 bool wxTreeCtrl::SetItemData(long item, long data)
245 {
246 wxTreeItem info;
247
248 info.m_mask = wxTREE_MASK_DATA ;
249 info.m_itemId = item;
250 info.m_data = data;
251
252 return SetItem(info);
253 }
254
255 bool wxTreeCtrl::GetItemRect(long item, wxRect& rect, bool textOnly) const
256 {
257 // TODO
258 return FALSE;
259 }
260
261 wxTextCtrl* wxTreeCtrl::GetEditControl() const
262 {
263 return m_textCtrl;
264 }
265
266 // Operations
267 bool wxTreeCtrl::DeleteItem(long item)
268 {
269 // TODO
270 return FALSE;
271 }
272
273 bool wxTreeCtrl::ExpandItem(long item, int action)
274 {
275 // TODO
276 switch ( action )
277 {
278 case wxTREE_EXPAND_EXPAND:
279 break;
280
281 case wxTREE_EXPAND_COLLAPSE:
282 break;
283
284 case wxTREE_EXPAND_COLLAPSE_RESET:
285 break;
286
287 case wxTREE_EXPAND_TOGGLE:
288 break;
289
290 default:
291 wxFAIL_MSG("unknown action in wxTreeCtrl::ExpandItem");
292 }
293
294 bool bOk = FALSE; // TODO expand item
295
296 // May not send messages, so emulate them
297 if ( bOk ) {
298 wxTreeEvent event(wxEVT_NULL, m_windowId);
299 event.m_item.m_itemId = item;
300 event.m_item.m_mask =
301 event.m_item.m_stateMask = 0xffff; // get all
302 GetItem(event.m_item);
303
304 bool bIsExpanded = (event.m_item.m_state & wxTREE_STATE_EXPANDED) != 0;
305
306 event.m_code = action;
307 event.SetEventObject(this);
308
309 // @@@ return values of {EXPAND|COLLAPS}ING event handler is discarded
310 event.SetEventType(bIsExpanded ? wxEVT_COMMAND_TREE_ITEM_EXPANDING
311 : wxEVT_COMMAND_TREE_ITEM_COLLAPSING);
312 GetEventHandler()->ProcessEvent(event);
313
314 event.SetEventType(bIsExpanded ? wxEVT_COMMAND_TREE_ITEM_EXPANDED
315 : wxEVT_COMMAND_TREE_ITEM_COLLAPSED);
316 GetEventHandler()->ProcessEvent(event);
317 }
318
319 return bOk;
320 }
321
322 long wxTreeCtrl::InsertItem(long parent, wxTreeItem& info, long insertAfter)
323 {
324 // TODO
325 return 0;
326 }
327
328 long wxTreeCtrl::InsertItem(long parent, const wxString& label, int image, int selImage,
329 long insertAfter)
330 {
331 wxTreeItem info;
332 info.m_text = label;
333 info.m_mask = wxTREE_MASK_TEXT;
334 if ( image > -1 )
335 {
336 info.m_mask |= wxTREE_MASK_IMAGE | wxTREE_MASK_SELECTED_IMAGE;
337 info.m_image = image;
338 if ( selImage == -1 )
339 info.m_selectedImage = image;
340 else
341 info.m_selectedImage = selImage;
342 }
343
344 return InsertItem(parent, info, insertAfter);
345 }
346
347 bool wxTreeCtrl::SelectItem(long item)
348 {
349 // TODO
350 return FALSE;
351 }
352
353 bool wxTreeCtrl::ScrollTo(long item)
354 {
355 // TODO
356 return FALSE;
357 }
358
359 bool wxTreeCtrl::DeleteAllItems()
360 {
361 // TODO
362 return FALSE;
363 }
364
365 wxTextCtrl* wxTreeCtrl::EditLabel(long item, wxClassInfo* textControlClass)
366 {
367 // TODO
368 return NULL;
369 }
370
371 // End label editing, optionally cancelling the edit
372 bool wxTreeCtrl::EndEditLabel(bool cancel)
373 {
374 // TODO
375 return FALSE;
376 }
377
378 long wxTreeCtrl::HitTest(const wxPoint& point, int& flags)
379 {
380 // TODO
381 return 0;
382 }
383
384 bool wxTreeCtrl::SortChildren(long item)
385 {
386 // TODO
387 return FALSE;
388 }
389
390 bool wxTreeCtrl::EnsureVisible(long item)
391 {
392 // TODO
393 return FALSE;
394 }
395
396 // Tree item structure
397 wxTreeItem::wxTreeItem()
398 {
399 m_mask = 0;
400 m_itemId = 0;
401 m_state = 0;
402 m_stateMask = 0;
403 m_image = -1;
404 m_selectedImage = -1;
405 m_children = 0;
406 m_data = 0;
407 }
408
409 // Tree event
410 IMPLEMENT_DYNAMIC_CLASS(wxTreeEvent, wxCommandEvent)
411
412 wxTreeEvent::wxTreeEvent(wxEventType commandType, int id):
413 wxCommandEvent(commandType, id)
414 {
415 m_code = 0;
416 m_oldItem = 0;
417 }
418