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