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