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