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