]> git.saurik.com Git - wxWidgets.git/blob - src/stubs/treectrl.cpp
Added stubs .cpp files.
[wxWidgets.git] / src / stubs / treectrl.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: treectrl.cpp
3 // Purpose: wxTreeCtrl
4 // Author: AUTHOR
5 // Modified by:
6 // Created: ??/??/98
7 // RCS-ID: $Id$
8 // Copyright: (c) AUTHOR
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifdef __GNUG__
13 #pragma implementation "treectrl.h"
14 #endif
15
16 #include "wx/treectrl.h"
17
18 #if !USE_SHARED_LIBRARY
19 IMPLEMENT_DYNAMIC_CLASS(wxTreeCtrl, wxControl)
20 IMPLEMENT_DYNAMIC_CLASS(wxTreeItem, wxObject)
21
22 #endif
23
24 wxTreeCtrl::wxTreeCtrl()
25 {
26 m_imageListNormal = NULL;
27 m_imageListState = NULL;
28 m_textCtrl = NULL;
29 }
30
31 bool wxTreeCtrl::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size,
32 long style, const wxValidator& validator, const wxString& name)
33 {
34 SetName(name);
35 SetValidator(validator);
36
37 m_imageListNormal = NULL;
38 m_imageListState = NULL;
39 m_textCtrl = NULL;
40
41 m_windowStyle = style;
42
43 SetParent(parent);
44
45 m_windowId = (id == -1) ? NewControlId() : id;
46
47 if (parent) parent->AddChild(this);
48
49 // TODO create tree control
50
51 return FALSE;
52 }
53
54 wxTreeCtrl::~wxTreeCtrl()
55 {
56 if (m_textCtrl)
57 {
58 delete m_textCtrl;
59 }
60 }
61
62 // Attributes
63 int wxTreeCtrl::GetCount() const
64 {
65 // TODO
66 return 0;
67 }
68
69 int wxTreeCtrl::GetIndent() const
70 {
71 // TODO
72 return 0;
73 }
74
75 void wxTreeCtrl::SetIndent(int indent)
76 {
77 // TODO
78 }
79
80 wxImageList *wxTreeCtrl::GetImageList(int which) const
81 {
82 if ( which == wxIMAGE_LIST_NORMAL )
83 {
84 return m_imageListNormal;
85 }
86 else if ( which == wxIMAGE_LIST_STATE )
87 {
88 return m_imageListState;
89 }
90 return NULL;
91 }
92
93 void wxTreeCtrl::SetImageList(wxImageList *imageList, int which)
94 {
95 if ( which == wxIMAGE_LIST_NORMAL )
96 {
97 m_imageListNormal = imageList;
98 }
99 else if ( which == wxIMAGE_LIST_STATE )
100 {
101 m_imageListState = imageList;
102 }
103 // TODO
104 }
105
106 long wxTreeCtrl::GetNextItem(long item, int code) const
107 {
108 // TODO
109 return 0;
110 }
111
112 bool wxTreeCtrl::ItemHasChildren(long item) const
113 {
114 // TODO
115 return FALSE;
116 }
117
118 long wxTreeCtrl::GetChild(long item) const
119 {
120 // TODO
121 return 0;
122 }
123
124 long wxTreeCtrl::GetParent(long item) const
125 {
126 // TODO
127 return 0;
128 }
129
130 long wxTreeCtrl::GetFirstVisibleItem() const
131 {
132 // TODO
133 return 0;
134 }
135
136 long wxTreeCtrl::GetNextVisibleItem(long item) const
137 {
138 // TODO
139 return 0;
140 }
141
142 long wxTreeCtrl::GetSelection() const
143 {
144 // TODO
145 return 0;
146 }
147
148 long wxTreeCtrl::GetRootItem() const
149 {
150 // TODO
151 return 0;
152 }
153
154 bool wxTreeCtrl::GetItem(wxTreeItem& info) const
155 {
156 // TODO
157 return FALSE;
158 }
159
160 bool wxTreeCtrl::SetItem(wxTreeItem& info)
161 {
162 // TODO
163 return FALSE;
164 }
165
166 int wxTreeCtrl::GetItemState(long item, long stateMask) const
167 {
168 wxTreeItem info;
169
170 info.m_mask = wxTREE_MASK_STATE ;
171 info.m_stateMask = stateMask;
172 info.m_itemId = item;
173
174 if (!GetItem(info))
175 return 0;
176
177 return info.m_state;
178 }
179
180 bool wxTreeCtrl::SetItemState(long item, long state, long stateMask)
181 {
182 wxTreeItem info;
183
184 info.m_mask = wxTREE_MASK_STATE ;
185 info.m_state = state;
186 info.m_stateMask = stateMask;
187 info.m_itemId = item;
188
189 return SetItem(info);
190 }
191
192 bool wxTreeCtrl::SetItemImage(long item, int image, int selImage)
193 {
194 wxTreeItem info;
195
196 info.m_mask = wxTREE_MASK_IMAGE ;
197 info.m_image = image;
198 if ( selImage > -1)
199 {
200 info.m_selectedImage = selImage;
201 info.m_mask |= wxTREE_MASK_SELECTED_IMAGE;
202 }
203 info.m_itemId = item;
204
205 return SetItem(info);
206 }
207
208 wxString wxTreeCtrl::GetItemText(long item) const
209 {
210 wxTreeItem info;
211
212 info.m_mask = wxTREE_MASK_TEXT ;
213 info.m_itemId = item;
214
215 if (!GetItem(info))
216 return wxString("");
217 return info.m_text;
218 }
219
220 void wxTreeCtrl::SetItemText(long item, const wxString& str)
221 {
222 wxTreeItem info;
223
224 info.m_mask = wxTREE_MASK_TEXT ;
225 info.m_itemId = item;
226 info.m_text = str;
227
228 SetItem(info);
229 }
230
231 long wxTreeCtrl::GetItemData(long item) const
232 {
233 wxTreeItem info;
234
235 info.m_mask = wxTREE_MASK_DATA ;
236 info.m_itemId = item;
237
238 if (!GetItem(info))
239 return 0;
240 return info.m_data;
241 }
242
243 bool wxTreeCtrl::SetItemData(long item, long data)
244 {
245 wxTreeItem info;
246
247 info.m_mask = wxTREE_MASK_DATA ;
248 info.m_itemId = item;
249 info.m_data = data;
250
251 return SetItem(info);
252 }
253
254 bool wxTreeCtrl::GetItemRect(long item, wxRectangle& rect, bool textOnly) const
255 {
256 // TODO
257 return FALSE;
258 }
259
260 wxTextCtrl* wxTreeCtrl::GetEditControl() const
261 {
262 return m_textCtrl;
263 }
264
265 // Operations
266 bool wxTreeCtrl::DeleteItem(long item)
267 {
268 // TODO
269 return FALSE;
270 }
271
272 bool wxTreeCtrl::ExpandItem(long item, int action)
273 {
274 // TODO
275 switch ( action )
276 {
277 case wxTREE_EXPAND_EXPAND:
278 break;
279
280 case wxTREE_EXPAND_COLLAPSE:
281 break;
282
283 case wxTREE_EXPAND_COLLAPSE_RESET:
284 mswAction = TVE_COLLAPSERESET;
285 break;
286
287 case wxTREE_EXPAND_TOGGLE:
288 mswAction = TVE_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