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