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