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