]> git.saurik.com Git - wxWidgets.git/blob - wxPython/src/controls2.i
forgotten method declaration
[wxWidgets.git] / wxPython / src / controls2.i
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: controls2.i
3 // Purpose: More control (widget) classes for wxPython
4 //
5 // Author: Robin Dunn
6 //
7 // Created: 6/10/98
8 // RCS-ID: $Id$
9 // Copyright: (c) 1998 by Total Control Software
10 // Licence: wxWindows license
11 /////////////////////////////////////////////////////////////////////////////
12
13 %module controls2
14
15 %{
16 #include "helpers.h"
17 #ifdef __WXMSW__
18 #include <windows.h>
19 #endif
20 #include <wx/listctrl.h>
21 #include <wx/treectrl.h>
22 #include <wx/imaglist.h>
23 %}
24
25 //----------------------------------------------------------------------
26
27 %include typemaps.i
28 %include my_typemaps.i
29
30 // Import some definitions of other classes, etc.
31 %import _defs.i
32 %import misc.i
33 %import windows.i
34 %import gdi.i
35 %import events.i
36 %import controls.i
37
38 %pragma(python) code = "import wx"
39
40 //----------------------------------------------------------------------
41
42
43 enum {
44 wxLIST_MASK_TEXT,
45 wxLIST_MASK_IMAGE,
46 wxLIST_MASK_DATA,
47 wxLIST_MASK_WIDTH,
48 wxLIST_MASK_FORMAT,
49 wxLIST_MASK_STATE,
50 wxLIST_STATE_DONTCARE,
51 wxLIST_STATE_DROPHILITED,
52 wxLIST_STATE_FOCUSED,
53 wxLIST_STATE_SELECTED,
54 wxLIST_STATE_CUT,
55 wxLIST_HITTEST_ABOVE,
56 wxLIST_HITTEST_BELOW,
57 wxLIST_HITTEST_NOWHERE,
58 wxLIST_HITTEST_ONITEMICON,
59 wxLIST_HITTEST_ONITEMLABEL,
60 wxLIST_HITTEST_ONITEMRIGHT,
61 wxLIST_HITTEST_ONITEMSTATEICON,
62 wxLIST_HITTEST_TOLEFT,
63 wxLIST_HITTEST_TORIGHT,
64 wxLIST_HITTEST_ONITEM,
65 wxLIST_NEXT_ABOVE,
66 wxLIST_NEXT_ALL,
67 wxLIST_NEXT_BELOW,
68 wxLIST_NEXT_LEFT,
69 wxLIST_NEXT_RIGHT,
70 wxLIST_ALIGN_DEFAULT,
71 wxLIST_ALIGN_LEFT,
72 wxLIST_ALIGN_TOP,
73 wxLIST_ALIGN_SNAP_TO_GRID,
74 wxLIST_AUTOSIZE,
75 wxLIST_AUTOSIZE_USEHEADER,
76 wxLIST_RECT_BOUNDS,
77 wxLIST_RECT_ICON,
78 wxLIST_RECT_LABEL,
79 wxLIST_FIND_UP,
80 wxLIST_FIND_DOWN,
81 wxLIST_FIND_LEFT,
82 wxLIST_FIND_RIGHT,
83 };
84
85
86 enum wxListColumnFormat
87 {
88 wxLIST_FORMAT_LEFT,
89 wxLIST_FORMAT_RIGHT,
90 wxLIST_FORMAT_CENTRE,
91 wxLIST_FORMAT_CENTER = wxLIST_FORMAT_CENTRE
92 };
93
94
95 enum {
96 /* List control event types */
97 wxEVT_COMMAND_LIST_BEGIN_DRAG,
98 wxEVT_COMMAND_LIST_BEGIN_RDRAG,
99 wxEVT_COMMAND_LIST_BEGIN_LABEL_EDIT,
100 wxEVT_COMMAND_LIST_END_LABEL_EDIT,
101 wxEVT_COMMAND_LIST_DELETE_ITEM,
102 wxEVT_COMMAND_LIST_DELETE_ALL_ITEMS,
103 wxEVT_COMMAND_LIST_GET_INFO,
104 wxEVT_COMMAND_LIST_SET_INFO,
105 wxEVT_COMMAND_LIST_ITEM_SELECTED,
106 wxEVT_COMMAND_LIST_ITEM_DESELECTED,
107 wxEVT_COMMAND_LIST_KEY_DOWN,
108 wxEVT_COMMAND_LIST_INSERT_ITEM,
109 wxEVT_COMMAND_LIST_COL_CLICK,
110 wxEVT_COMMAND_LIST_ITEM_ACTIVATED,
111 wxEVT_COMMAND_LIST_ITEM_RIGHT_CLICK,
112 wxEVT_COMMAND_LIST_ITEM_MIDDLE_CLICK,
113 };
114
115 enum {
116 /* Style flags */
117 wxLC_ICON,
118 wxLC_SMALL_ICON,
119 wxLC_LIST,
120 wxLC_REPORT,
121 wxLC_ALIGN_TOP,
122 wxLC_ALIGN_LEFT,
123 wxLC_AUTOARRANGE,
124 wxLC_USER_TEXT,
125 wxLC_EDIT_LABELS,
126 wxLC_NO_HEADER,
127 wxLC_NO_SORT_HEADER,
128 wxLC_SINGLE_SEL,
129 wxLC_SORT_ASCENDING,
130 wxLC_SORT_DESCENDING,
131 wxLC_MASK_TYPE,
132 wxLC_MASK_ALIGN,
133 wxLC_MASK_SORT,
134 wxLC_HRULES,
135 wxLC_VRULES,
136 wxLC_VIRTUAL,
137 };
138
139
140
141 class wxListItemAttr
142 {
143 public:
144 // ctors
145 wxListItemAttr();
146 //wxListItemAttr(const wxColour& colText,
147 // const wxColour& colBack,
148 // const wxFont& font)
149 // : m_colText(colText), m_colBack(colBack), m_font(font) { }
150
151 // setters
152 void SetTextColour(const wxColour& colText);
153 void SetBackgroundColour(const wxColour& colBack);
154 void SetFont(const wxFont& font);
155
156 // accessors
157 bool HasTextColour();
158 bool HasBackgroundColour();
159 bool HasFont();
160
161 const wxColour& GetTextColour();
162 const wxColour& GetBackgroundColour();
163 const wxFont& GetFont();
164 };
165
166
167 class wxListItem : public wxObject {
168 public:
169 wxListItem();
170 ~wxListItem();
171
172 // resetting
173 void Clear();
174 void ClearAttributes();
175
176 // setters
177 void SetMask(long mask);
178 void SetId(long id);
179 void SetColumn(int col);
180 void SetState(long state);
181 void SetStateMask(long stateMask);
182 void SetText(const wxString& text);
183 void SetImage(int image);
184 void SetData(long data);
185
186 void SetWidth(int width);
187 void SetAlign(wxListColumnFormat align);
188
189 void SetTextColour(const wxColour& colText);
190 void SetBackgroundColour(const wxColour& colBack);
191 void SetFont(const wxFont& font);
192
193 // accessors
194 long GetMask();
195 long GetId();
196 int GetColumn();
197 long GetState();
198 const wxString& GetText();
199 int GetImage();
200 long GetData();
201
202 int GetWidth();
203 wxListColumnFormat GetAlign();
204
205 wxListItemAttr *GetAttributes();
206 bool HasAttributes();
207
208 wxColour GetTextColour() const;
209 wxColour GetBackgroundColour() const;
210 wxFont GetFont() const;
211
212 // these members are public for compatibility
213 long m_mask; // Indicates what fields are valid
214 long m_itemId; // The zero-based item position
215 int m_col; // Zero-based column, if in report mode
216 long m_state; // The state of the item
217 long m_stateMask;// Which flags of m_state are valid (uses same flags)
218 wxString m_text; // The label/header text
219 int m_image; // The zero-based index into an image list
220 long m_data; // App-defined data
221
222 // For columns only
223 int m_format; // left, right, centre
224 int m_width; // width of column
225
226 };
227
228
229 class wxListEvent: public wxNotifyEvent {
230 public:
231 int m_code;
232 long m_itemIndex;
233 long m_oldItemIndex;
234 int m_col;
235 bool m_cancelled;
236 wxPoint m_pointDrag;
237 wxListItem m_item;
238
239 int GetCode();
240 long GetIndex();
241 long GetOldIndex();
242 long GetOldItem();
243 int GetColumn();
244 bool Cancelled();
245 wxPoint GetPoint();
246 const wxString& GetLabel();
247 const wxString& GetText();
248 int GetImage();
249 long GetData();
250 long GetMask();
251 const wxListItem& GetItem();
252 };
253
254
255
256 class wxListCtrl : public wxControl {
257 public:
258 wxListCtrl(wxWindow* parent, wxWindowID id,
259 const wxPoint& pos = wxDefaultPosition,
260 const wxSize& size = wxDefaultSize,
261 long style = wxLC_ICON,
262 const wxValidator& validator = wxDefaultValidator,
263 char* name = "listCtrl");
264
265 %pragma(python) addtomethod = "__init__:#wx._StdWindowCallbacks(self)"
266
267 bool Arrange(int flag = wxLIST_ALIGN_DEFAULT);
268 void AssignImageList(wxImageList* imageList, int which);
269 %pragma(python) addtomethod = "AssignImageList:_args[0].thisown = 0"
270 bool DeleteItem(long item);
271 bool DeleteAllItems();
272 bool DeleteColumn(int col);
273 bool DeleteAllColumns(void);
274 void ClearAll(void);
275 #ifdef __WXMSW__
276 wxTextCtrl* EditLabel(long item);
277 bool EndEditLabel(bool cancel);
278 wxTextCtrl* GetEditControl();
279 #else
280 void EditLabel(long item);
281 #endif
282 bool EnsureVisible(long item);
283 long FindItem(long start, const wxString& str, bool partial = FALSE);
284 %name(FindItemData)long FindItem(long start, long data);
285 %name(FindItemAtPos)long FindItem(long start, const wxPoint& pt,
286 int direction);
287 bool GetColumn(int col, wxListItem& item);
288 int GetColumnWidth(int col);
289 int GetCountPerPage();
290 wxImageList* GetImageList(int which);
291 long GetItemData(long item);
292
293 %addmethods {
294 %new wxListItem* GetItem(long itemId, int col=0) {
295 wxListItem* info = new wxListItem;
296 info->m_itemId = itemId;
297 info->m_col = col;
298 info->m_mask = 0xFFFF;
299 self->GetItem(*info);
300 return info;
301 }
302 %new wxPoint* GetItemPosition(long item) {
303 wxPoint* pos = new wxPoint;
304 self->GetItemPosition(item, *pos);
305 return pos;
306 }
307 %new wxRect* GetItemRect(long item, int code = wxLIST_RECT_BOUNDS) {
308 wxRect* rect= new wxRect;
309 self->GetItemRect(item, *rect, code);
310 return rect;
311 }
312 }
313
314 int GetItemState(long item, long stateMask);
315 int GetItemCount();
316 int GetItemSpacing(bool isSmall);
317 wxString GetItemText(long item);
318 long GetNextItem(long item,
319 int geometry = wxLIST_NEXT_ALL,
320 int state = wxLIST_STATE_DONTCARE);
321 int GetSelectedItemCount();
322 #ifdef __WXMSW__
323 wxColour GetTextColour();
324 void SetTextColour(const wxColour& col);
325 #endif
326 long GetTopItem();
327 long HitTest(const wxPoint& point, int& OUTPUT);
328 %name(InsertColumnInfo)long InsertColumn(long col, wxListItem& info);
329 long InsertColumn(long col, const wxString& heading,
330 int format = wxLIST_FORMAT_LEFT,
331 int width = -1);
332
333 long InsertItem(wxListItem& info);
334 %name(InsertStringItem) long InsertItem(long index, const wxString& label);
335 %name(InsertImageItem) long InsertItem(long index, int imageIndex);
336 %name(InsertImageStringItem)long InsertItem(long index, const wxString& label,
337 int imageIndex);
338
339 bool ScrollList(int dx, int dy);
340 void SetBackgroundColour(const wxColour& col);
341 bool SetColumn(int col, wxListItem& item);
342 bool SetColumnWidth(int col, int width);
343 void SetImageList(wxImageList* imageList, int which);
344
345 bool SetItem(wxListItem& info);
346 %name(SetStringItem)long SetItem(long index, int col, const wxString& label,
347 int imageId = -1);
348
349 bool SetItemData(long item, long data);
350 bool SetItemImage(long item, int image, int selImage);
351 bool SetItemPosition(long item, const wxPoint& pos);
352 bool SetItemState(long item, long state, long stateMask);
353 void SetItemText(long item, const wxString& text);
354 void SetSingleStyle(long style, bool add = TRUE);
355 void SetWindowStyleFlag(long style);
356
357 // bool SortItems(wxListCtrlCompare fn, long data);
358 %addmethods {
359 bool SortItems(PyObject* func) {
360 if (!PyCallable_Check(func))
361 return FALSE;
362
363 return self->SortItems(wxPyListCtrl_SortItems, (long)func);
364 }
365 }
366 };
367
368 %{
369 int wxCALLBACK wxPyListCtrl_SortItems(long item1, long item2, long funcPtr) {
370 int retval = 0;
371 PyObject* func = (PyObject*)funcPtr;
372 bool doSave = wxPyRestoreThread();
373
374 PyObject* args = Py_BuildValue("(ii)", item1, item2);
375 PyObject* result = PyEval_CallObject(func, args);
376 Py_DECREF(args);
377 if (result) {
378 retval = PyInt_AsLong(result);
379 Py_DECREF(result);
380 }
381
382 wxPySaveThread(doSave);
383 return retval;
384 }
385
386 %}
387
388 //----------------------------------------------------------------------
389
390 enum wxTreeItemIcon
391 {
392 wxTreeItemIcon_Normal, // not selected, not expanded
393 wxTreeItemIcon_Selected, // selected, not expanded
394 wxTreeItemIcon_Expanded, // not selected, expanded
395 wxTreeItemIcon_SelectedExpanded, // selected, expanded
396 wxTreeItemIcon_Max
397 };
398
399
400 // constants for HitTest
401 enum {
402 wxTREE_HITTEST_ABOVE,
403 wxTREE_HITTEST_BELOW,
404 wxTREE_HITTEST_NOWHERE,
405 wxTREE_HITTEST_ONITEMBUTTON,
406 wxTREE_HITTEST_ONITEMICON,
407 wxTREE_HITTEST_ONITEMINDENT,
408 wxTREE_HITTEST_ONITEMLABEL,
409 wxTREE_HITTEST_ONITEMRIGHT,
410 wxTREE_HITTEST_ONITEMSTATEICON,
411 wxTREE_HITTEST_TOLEFT,
412 wxTREE_HITTEST_TORIGHT,
413 wxTREE_HITTEST_ONITEMUPPERPART,
414 wxTREE_HITTEST_ONITEMLOWERPART,
415 wxTREE_HITTEST_ONITEM
416 };
417
418
419 enum {
420 /* Tree control event types */
421 wxEVT_COMMAND_TREE_BEGIN_DRAG,
422 wxEVT_COMMAND_TREE_BEGIN_RDRAG,
423 wxEVT_COMMAND_TREE_BEGIN_LABEL_EDIT,
424 wxEVT_COMMAND_TREE_END_LABEL_EDIT,
425 wxEVT_COMMAND_TREE_DELETE_ITEM,
426 wxEVT_COMMAND_TREE_GET_INFO,
427 wxEVT_COMMAND_TREE_SET_INFO,
428 wxEVT_COMMAND_TREE_ITEM_EXPANDED,
429 wxEVT_COMMAND_TREE_ITEM_EXPANDING,
430 wxEVT_COMMAND_TREE_ITEM_COLLAPSED,
431 wxEVT_COMMAND_TREE_ITEM_COLLAPSING,
432 wxEVT_COMMAND_TREE_SEL_CHANGED,
433 wxEVT_COMMAND_TREE_SEL_CHANGING,
434 wxEVT_COMMAND_TREE_KEY_DOWN,
435 wxEVT_COMMAND_TREE_ITEM_ACTIVATED,
436 wxEVT_COMMAND_TREE_ITEM_RIGHT_CLICK,
437 wxEVT_COMMAND_TREE_ITEM_MIDDLE_CLICK,
438 wxEVT_COMMAND_TREE_END_DRAG,
439 };
440
441
442 class wxTreeItemId {
443 public:
444 wxTreeItemId();
445 ~wxTreeItemId();
446 bool IsOk();
447
448 %addmethods {
449 int __cmp__(wxTreeItemId* other) {
450 if (! other) return -1;
451 return *self != *other;
452 }
453 }
454 };
455
456
457
458 %{
459 class wxPyTreeItemData : public wxTreeItemData {
460 public:
461 wxPyTreeItemData(PyObject* obj = NULL) {
462 if (obj == NULL)
463 obj = Py_None;
464 Py_INCREF(obj);
465 m_obj = obj;
466 }
467
468 ~wxPyTreeItemData() {
469 bool doSave = wxPyRestoreThread();
470 Py_DECREF(m_obj);
471 wxPySaveThread(doSave);
472 }
473
474 PyObject* GetData() {
475 Py_INCREF(m_obj);
476 return m_obj;
477 }
478
479 void SetData(PyObject* obj) {
480 bool doSave = wxPyRestoreThread();
481 Py_DECREF(m_obj);
482 wxPySaveThread(doSave);
483 m_obj = obj;
484 Py_INCREF(obj);
485 }
486
487 PyObject* m_obj;
488 };
489 %}
490
491
492
493 %name(wxTreeItemData) class wxPyTreeItemData : public wxObject {
494 public:
495 wxPyTreeItemData(PyObject* obj = NULL);
496
497 PyObject* GetData();
498 void SetData(PyObject* obj);
499
500 const wxTreeItemId& GetId();
501 void SetId(const wxTreeItemId& id);
502 };
503
504
505
506 class wxTreeEvent : public wxNotifyEvent {
507 public:
508 wxTreeItemId GetItem();
509 wxTreeItemId GetOldItem();
510 wxPoint GetPoint();
511 int GetCode();
512 const wxString& GetLabel();
513 };
514
515
516
517 %{
518 class wxPyTreeCtrl : public wxTreeCtrl {
519 DECLARE_ABSTRACT_CLASS(wxPyTreeCtrl);
520 public:
521 wxPyTreeCtrl(wxWindow *parent, wxWindowID id,
522 const wxPoint& pos,
523 const wxSize& size,
524 long style,
525 const wxValidator& validator,
526 char* name) :
527 wxTreeCtrl(parent, id, pos, size, style, validator, name) {}
528
529 int OnCompareItems(const wxTreeItemId& item1,
530 const wxTreeItemId& item2) {
531 int rval = 0;
532 bool doSave = wxPyRestoreThread();
533 if (m_myInst.findCallback("OnCompareItems"))
534 rval = m_myInst.callCallback(Py_BuildValue(
535 "(OO)",
536 wxPyConstructObject((void*)&item1, "wxTreeItemId"),
537 wxPyConstructObject((void*)&item2, "wxTreeItemId")));
538 else
539 rval = wxTreeCtrl::OnCompareItems(item1, item2);
540 wxPySaveThread(doSave);
541 return rval;
542 }
543 PYPRIVATE;
544 };
545
546 IMPLEMENT_ABSTRACT_CLASS(wxPyTreeCtrl, wxTreeCtrl);
547
548 %}
549
550 // These are for the GetFirstChild/GetNextChild methods below
551 %typemap(python, in) long& INOUT = long* INOUT;
552 %typemap(python, argout) long& INOUT = long* INOUT;
553
554
555 %name(wxTreeCtrl)class wxPyTreeCtrl : public wxControl {
556 public:
557 wxPyTreeCtrl(wxWindow *parent, wxWindowID id = -1,
558 const wxPoint& pos = wxDefaultPosition,
559 const wxSize& size = wxDefaultSize,
560 long style = wxTR_HAS_BUTTONS | wxTR_LINES_AT_ROOT,
561 const wxValidator& validator = wxDefaultValidator,
562 char* name = "wxTreeCtrl");
563
564 void _setSelf(PyObject* self, PyObject* _class);
565 %pragma(python) addtomethod = "__init__:#wx._StdWindowCallbacks(self)"
566 %pragma(python) addtomethod = "__init__:self._setSelf(self, wxTreeCtrl)"
567
568 void AssignImageList(wxImageList* imageList);
569 %pragma(python) addtomethod = "AssignImageList:_args[0].thisown = 0"
570 size_t GetCount();
571 unsigned int GetIndent();
572 void SetIndent(unsigned int indent);
573 wxImageList *GetImageList();
574 wxImageList *GetStateImageList();
575 void SetImageList(wxImageList *imageList);
576 void SetStateImageList(wxImageList *imageList);
577
578 unsigned int GetSpacing();
579 void SetSpacing(unsigned int spacing);
580
581 wxString GetItemText(const wxTreeItemId& item);
582 int GetItemImage(const wxTreeItemId& item,
583 wxTreeItemIcon which = wxTreeItemIcon_Normal);
584 int GetItemSelectedImage(const wxTreeItemId& item);
585
586 void SetItemText(const wxTreeItemId& item, const wxString& text);
587 void SetItemImage(const wxTreeItemId& item, int image,
588 wxTreeItemIcon which = wxTreeItemIcon_Normal);
589 void SetItemSelectedImage(const wxTreeItemId& item, int image);
590 void SetItemHasChildren(const wxTreeItemId& item, bool hasChildren = TRUE);
591
592 %addmethods {
593 // [Get|Set]ItemData substitutes. Automatically create wxPyTreeItemData
594 // if needed.
595 wxPyTreeItemData* GetItemData(const wxTreeItemId& item) {
596 wxPyTreeItemData* data = (wxPyTreeItemData*)self->GetItemData(item);
597 if (data == NULL) {
598 data = new wxPyTreeItemData();
599 data->SetId(item); // set the id
600 self->SetItemData(item, data);
601 }
602 return data;
603 }
604
605 void SetItemData(const wxTreeItemId& item, wxPyTreeItemData* data) {
606 data->SetId(item); // set the id
607 self->SetItemData(item, data);
608 }
609
610 // [Get|Set]PyData are short-cuts. Also made somewhat crash-proof by
611 // automatically creating data classes.
612 PyObject* GetPyData(const wxTreeItemId& item) {
613 wxPyTreeItemData* data = (wxPyTreeItemData*)self->GetItemData(item);
614 if (data == NULL) {
615 data = new wxPyTreeItemData();
616 data->SetId(item); // set the id
617 self->SetItemData(item, data);
618 }
619 return data->GetData();
620 }
621
622 void SetPyData(const wxTreeItemId& item, PyObject* obj) {
623 wxPyTreeItemData* data = (wxPyTreeItemData*)self->GetItemData(item);
624 if (data == NULL) {
625 data = new wxPyTreeItemData(obj);
626 data->SetId(item); // set the id
627 self->SetItemData(item, data);
628 } else
629 data->SetData(obj);
630 }
631 }
632
633
634 bool IsVisible(const wxTreeItemId& item);
635 bool ItemHasChildren(const wxTreeItemId& item);
636 bool IsExpanded(const wxTreeItemId& item);
637 bool IsSelected(const wxTreeItemId& item);
638
639 wxTreeItemId GetRootItem();
640 wxTreeItemId GetSelection();
641 %name(GetItemParent) wxTreeItemId GetParent(const wxTreeItemId& item);
642 //size_t GetSelections(wxArrayTreeItemIds& selection);
643 %addmethods {
644 PyObject* GetSelections() {
645 bool doSave = wxPyRestoreThread();
646 PyObject* rval = PyList_New(0);
647 wxArrayTreeItemIds array;
648 size_t num, x;
649 num = self->GetSelections(array);
650 for (x=0; x < num; x++) {
651 wxTreeItemId *tii = new wxTreeItemId(array.Item(x));
652 PyObject* item = wxPyConstructObject((void*)tii, "wxTreeItemId", TRUE);
653 PyList_Append(rval, item);
654 }
655 wxPySaveThread(doSave);
656 return rval;
657 }
658 }
659
660
661
662 size_t GetChildrenCount(const wxTreeItemId& item, bool recursively = TRUE);
663
664 wxTreeItemId GetFirstChild(const wxTreeItemId& item, long& INOUT);
665 wxTreeItemId GetNextChild(const wxTreeItemId& item, long& INOUT);
666 wxTreeItemId GetNextSibling(const wxTreeItemId& item);
667 wxTreeItemId GetPrevSibling(const wxTreeItemId& item);
668 wxTreeItemId GetFirstVisibleItem();
669 wxTreeItemId GetNextVisible(const wxTreeItemId& item);
670 wxTreeItemId GetPrevVisible(const wxTreeItemId& item);
671 wxTreeItemId GetLastChild(const wxTreeItemId& item);
672
673
674
675 wxTreeItemId AddRoot(const wxString& text,
676 int image = -1, int selectedImage = -1,
677 wxPyTreeItemData *data = NULL);
678 wxTreeItemId PrependItem(const wxTreeItemId& parent,
679 const wxString& text,
680 int image = -1, int selectedImage = -1,
681 wxPyTreeItemData *data = NULL);
682 wxTreeItemId InsertItem(const wxTreeItemId& parent,
683 const wxTreeItemId& idPrevious,
684 const wxString& text,
685 int image = -1, int selectedImage = -1,
686 wxPyTreeItemData *data = NULL);
687 %name(InsertItemBefore)
688 wxTreeItemId InsertItem(const wxTreeItemId& parent,
689 size_t before,
690 const wxString& text,
691 int image = -1, int selectedImage = -1,
692 wxTreeItemData *data = NULL);
693 wxTreeItemId AppendItem(const wxTreeItemId& parent,
694 const wxString& text,
695 int image = -1, int selectedImage = -1,
696 wxPyTreeItemData *data = NULL);
697
698 void Delete(const wxTreeItemId& item);
699 void DeleteChildren(const wxTreeItemId& item);
700 void DeleteAllItems();
701
702 void Expand(const wxTreeItemId& item);
703 void Collapse(const wxTreeItemId& item);
704 void CollapseAndReset(const wxTreeItemId& item);
705 void Toggle(const wxTreeItemId& item);
706
707 void Unselect();
708 void UnselectAll();
709 void SelectItem(const wxTreeItemId& item);
710 void EnsureVisible(const wxTreeItemId& item);
711 void ScrollTo(const wxTreeItemId& item);
712 #ifdef __WXMSW__
713 wxTextCtrl* EditLabel(const wxTreeItemId& item);
714 wxTextCtrl* GetEditControl();
715 void EndEditLabel(const wxTreeItemId& item, int discardChanges = FALSE);
716 #else
717 void EditLabel(const wxTreeItemId& item);
718 #endif
719
720 void SortChildren(const wxTreeItemId& item);
721
722 void SetItemBold(const wxTreeItemId& item, int bold = TRUE);
723 bool IsBold(const wxTreeItemId& item) const;
724 wxTreeItemId HitTest(const wxPoint& point, int& OUTPUT);
725
726
727
728 void SetItemTextColour(const wxTreeItemId& item, const wxColour& col);
729 void SetItemBackgroundColour(const wxTreeItemId& item, const wxColour& col);
730 void SetItemFont(const wxTreeItemId& item, const wxFont& font);
731
732 #ifdef __WXMSW__
733 void SetItemDropHighlight(const wxTreeItemId& item, int highlight = TRUE);
734
735 //bool GetBoundingRect(const wxTreeItemId& item, wxRect& rect, int textOnly = FALSE)
736 %addmethods {
737 PyObject* GetBoundingRect(const wxTreeItemId& item, int textOnly = FALSE) {
738 wxRect rect;
739 if (self->GetBoundingRect(item, rect, textOnly)) {
740 bool doSave = wxPyRestoreThread();
741 wxRect* r = new wxRect(rect);
742 PyObject* val = wxPyConstructObject((void*)r, "wxRect");
743 wxPySaveThread(doSave);
744 return val;
745 }
746 else {
747 Py_INCREF(Py_None);
748 return Py_None;
749 }
750 }
751 }
752 #endif
753
754 %pragma(python) addtoclass = "
755 # Redefine some methods that SWIG gets a bit confused on...
756 def GetFirstChild(self, *_args, **_kwargs):
757 val1,val2 = apply(controls2c.wxTreeCtrl_GetFirstChild,(self,) + _args, _kwargs)
758 val1 = wxTreeItemIdPtr(val1)
759 val1.thisown = 1
760 return (val1,val2)
761 def GetNextChild(self, *_args, **_kwargs):
762 val1,val2 = apply(controls2c.wxTreeCtrl_GetNextChild,(self,) + _args, _kwargs)
763 val1 = wxTreeItemIdPtr(val1)
764 val1.thisown = 1
765 return (val1,val2)
766 def HitTest(self, *_args, **_kwargs):
767 val1, val2 = apply(controls2c.wxTreeCtrl_HitTest,(self,) + _args, _kwargs)
768 val1 = wxTreeItemIdPtr(val1)
769 val1.thisown = 1
770 return (val1,val2)
771 "
772 };
773
774
775 //----------------------------------------------------------------------
776
777 #ifdef SKIPTHIS
778 #ifdef __WXMSW__
779
780
781 enum {
782 /* tab control event types */
783 wxEVT_COMMAND_TAB_SEL_CHANGED,
784 wxEVT_COMMAND_TAB_SEL_CHANGING,
785 };
786
787
788 class wxTabEvent : public wxCommandEvent {
789 public:
790 };
791
792
793
794 class wxTabCtrl : public wxControl {
795 public:
796 wxTabCtrl(wxWindow* parent, wxWindowID id,
797 const wxPoint& pos = wxDefaultPosition,
798 const wxSize& size = wxDefaultSize,
799 long style = 0,
800 char* name = "tabCtrl");
801
802 %pragma(python) addtomethod = "__init__:#wx._StdWindowCallbacks(self)"
803
804 bool DeleteAllItems();
805 bool DeleteItem(int item);
806 wxImageList* GetImageList();
807 int GetItemCount();
808 // TODO: void* GetItemData();
809 int GetItemImage(int item);
810
811 %addmethods {
812 %new wxRect* GetItemRect(int item) {
813 wxRect* rect = new wxRect;
814 self->GetItemRect(item, *rect);
815 return rect;
816 }
817 }
818
819 wxString GetItemText(int item);
820 bool GetRowCount();
821 int GetSelection();
822 int HitTest(const wxPoint& pt, long& OUTPUT);
823 void InsertItem(int item, const wxString& text,
824 int imageId = -1, void* clientData = NULL);
825 // TODO: bool SetItemData(int item, void* data);
826 bool SetItemImage(int item, int image);
827 void SetImageList(wxImageList* imageList);
828 void SetItemSize(const wxSize& size);
829 bool SetItemText(int item, const wxString& text);
830 void SetPadding(const wxSize& padding);
831 int SetSelection(int item);
832
833 };
834
835 #endif
836 #endif
837
838 //----------------------------------------------------------------------
839
840 %init %{
841 wxPyPtrTypeMap_Add("wxTreeItemData", "wxPyTreeItemData");
842 wxPyPtrTypeMap_Add("wxTreeCtrl", "wxPyTreeCtrl");
843 %}
844
845 //----------------------------------------------------------------------
846
847