]> git.saurik.com Git - wxWidgets.git/blame - wxPython/contrib/gizmos/gizmos.i
reSWIGged
[wxWidgets.git] / wxPython / contrib / gizmos / gizmos.i
CommitLineData
ebf4302c
RD
1/////////////////////////////////////////////////////////////////////////////
2// Name: gizmos.i
3// Purpose: Wrappers for the "gizmo" classes in wx/contrib
4//
5// Author: Robin Dunn
6//
7// Created: 23-Nov-2001
8// RCS-ID: $Id$
9// Copyright: (c) 2001 by Total Control Software
10// Licence: wxWindows license
11/////////////////////////////////////////////////////////////////////////////
12
c8fac2b6
RD
13%define DOCSTRING
14"Various *gizmo* classes: `DynamicSashWindow`, `EditableListBox`,
15`LEDNumberCtrl`, `TreeListCtrl`, etc."
16%enddef
17
b2eb030f 18%module(package="wx", docstring=DOCSTRING) gizmos
ebf4302c
RD
19
20
21%{
d14a1e28
RD
22#include "wx/wxPython/wxPython.h"
23#include "wx/wxPython/pyclasses.h"
28eab81f 24
611dc22c
RD
25#include <wx/gizmos/dynamicsash.h>
26#include <wx/gizmos/editlbox.h>
27#include <wx/gizmos/splittree.h>
950e7faf 28#include <wx/gizmos/ledctrl.h>
1fded56b 29
7c379a20 30#include <wx/listctrl.h>
1fded56b
RD
31#include <wx/treectrl.h>
32#include <wx/imaglist.h>
28eab81f
RD
33
34#include "wx/treelistctrl.h"
d14a1e28 35#include "wx/wxPython/pytree.h"
ebf4302c 36
137b5242
RD
37%}
38
d14a1e28
RD
39//---------------------------------------------------------------------------
40
41%import windows.i
42%import controls.i
648d396c
RD
43%pythoncode { import wx }
44%pythoncode { __docfilter__ = wx._core.__DocFilter(globals()) }
d14a1e28 45
b2dc1044 46
089142a5
RD
47MAKE_CONST_WXSTRING2(DynamicSashNameStr, wxT("dynamicSashWindow"));
48MAKE_CONST_WXSTRING2(EditableListBoxNameStr, wxT("editableListBox"));
49MAKE_CONST_WXSTRING2(TreeListCtrlNameStr, wxT("treelistctrl"));
b2dc1044
RD
50
51MAKE_CONST_WXSTRING_NOSWIG(EmptyString);
52
53
d14a1e28
RD
54%include _gizmos_rename.i
55
56//---------------------------------------------------------------------------
137b5242 57
ebf4302c
RD
58enum {
59 wxEVT_DYNAMIC_SASH_SPLIT,
60 wxEVT_DYNAMIC_SASH_UNIFY,
61
62 wxDS_MANAGE_SCROLLBARS,
63 wxDS_DRAG_CORNER,
64};
65
66
67/*
68 wxDynamicSashSplitEvents are sent to your view by wxDynamicSashWindow
69 whenever your view is being split by the user. It is your
70 responsibility to handle this event by creating a new view window as
71 a child of the wxDynamicSashWindow. wxDynamicSashWindow will
72 automatically reparent it to the proper place in its window hierarchy.
73*/
74class wxDynamicSashSplitEvent : public wxCommandEvent {
75public:
76 wxDynamicSashSplitEvent(wxObject *target);
77};
78
79
80/*
81 wxDynamicSashUnifyEvents are sent to your view by wxDynamicSashWindow
82 whenever the sash which splits your view and its sibling is being
83 reunified such that your view is expanding to replace its sibling.
84 You needn't do anything with this event if you are allowing
85 wxDynamicSashWindow to manage your view's scrollbars, but it is useful
86 if you are managing the scrollbars yourself so that you can keep
87 the scrollbars' event handlers connected to your view's event handler
88 class.
89*/
90class wxDynamicSashUnifyEvent : public wxCommandEvent {
91public:
92 wxDynamicSashUnifyEvent(wxObject *target);
93};
94
95
96
97/*
98
99 wxDynamicSashWindow
100
101 wxDynamicSashWindow widgets manages the way other widgets are viewed.
102 When a wxDynamicSashWindow is first shown, it will contain one child
103 view, a viewport for that child, and a pair of scrollbars to allow the
104 user to navigate the child view area. Next to each scrollbar is a small
105 tab. By clicking on either tab and dragging to the appropriate spot, a
106 user can split the view area into two smaller views separated by a
107 draggable sash. Later, when the user wishes to reunify the two subviews,
108 the user simply drags the sash to the side of the window.
109 wxDynamicSashWindow will automatically reparent the appropriate child
110 view back up the window hierarchy, and the wxDynamicSashWindow will have
111 only one child view once again.
112
113 As an application developer, you will simply create a wxDynamicSashWindow
114 using either the Create() function or the more complex constructor
611dc22c 115 provided below, and then create a view window whose parent is the
ebf4302c
RD
116 wxDynamicSashWindow. The child should respond to
117 wxDynamicSashSplitEvents -- perhaps with an OnSplit() event handler -- by
118 constructing a new view window whose parent is also the
119 wxDynamicSashWindow. That's it! Now your users can dynamically split
120 and reunify the view you provided.
121
122 If you wish to handle the scrollbar events for your view, rather than
123 allowing wxDynamicSashWindow to do it for you, things are a bit more
124 complex. (You might want to handle scrollbar events yourself, if,
125 for instance, you wish to scroll a subwindow of the view you add to
126 your wxDynamicSashWindow object, rather than scrolling the whole view.)
611dc22c 127 In this case, you will need to construct your wxDynamicSashWindow without
ebf4302c
RD
128 the wxDS_MANAGE_SCROLLBARS style and you will need to use the
129 GetHScrollBar() and GetVScrollBar() methods to retrieve the scrollbar
130 controls and call SetEventHanler() on them to redirect the scrolling
131 events whenever your window is reparented by wxDyanmicSashWindow.
132 You will need to set the scrollbars' event handler at three times:
133
134 * When your view is created
135 * When your view receives a wxDynamicSashSplitEvent
136 * When your view receives a wxDynamicSashUnifyEvent
137
138 See the dynsash_switch sample application for an example which does this.
139
140*/
141
ab1f7d2a
RD
142MustHaveApp(wxDynamicSashWindow);
143
ebf4302c
RD
144class wxDynamicSashWindow : public wxWindow {
145public:
2b9048c5
RD
146 %pythonAppend wxDynamicSashWindow "self._setOORInfo(self)"
147 %pythonAppend wxDynamicSashWindow() ""
d14a1e28 148
d5573410 149 wxDynamicSashWindow(wxWindow *parent, wxWindowID id=-1,
ebf4302c
RD
150 const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
151 long style = wxCLIP_CHILDREN | wxDS_MANAGE_SCROLLBARS | wxDS_DRAG_CORNER,
137b5242 152 const wxString& name = wxPyDynamicSashNameStr);
d14a1e28 153 %name(PreDynamicSashWindow)wxDynamicSashWindow();
ebf4302c 154
d5573410 155 bool Create(wxWindow *parent, wxWindowID id=-1,
ebf4302c
RD
156 const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
157 long style = wxCLIP_CHILDREN | wxDS_MANAGE_SCROLLBARS | wxDS_DRAG_CORNER,
137b5242 158 const wxString& name = wxPyDynamicSashNameStr);
ebf4302c 159
ebf4302c
RD
160 wxScrollBar *GetHScrollBar(const wxWindow *child) const;
161 wxScrollBar *GetVScrollBar(const wxWindow *child) const;
162};
163
164
165
d14a1e28
RD
166%pythoncode {
167EVT_DYNAMIC_SASH_SPLIT = wx.PyEventBinder( wxEVT_DYNAMIC_SASH_SPLIT, 1 )
168EVT_DYNAMIC_SASH_UNIFY = wx.PyEventBinder( wxEVT_DYNAMIC_SASH_UNIFY, 1 )
169}
ebf4302c 170
d14a1e28
RD
171//---------------------------------------------------------------------------
172//---------------------------------------------------------------------------
7b7ac0ab 173
6187ec8f
RD
174enum {
175 wxEL_ALLOW_NEW,
176 wxEL_ALLOW_EDIT,
177 wxEL_ALLOW_DELETE,
178};
7b7ac0ab
RD
179
180// This class provides a composite control that lets the
181// user easily enter list of strings
ab1f7d2a 182MustHaveApp(wxEditableListBox);
7b7ac0ab
RD
183class wxEditableListBox : public wxPanel
184{
185public:
2b9048c5
RD
186 %pythonAppend wxEditableListBox "self._setOORInfo(self)"
187 %pythonAppend wxEditableListBox() ""
d14a1e28 188
d5573410
RD
189 wxEditableListBox(wxWindow *parent, wxWindowID id=-1,
190 const wxString& label = wxPyEmptyString,
7b7ac0ab
RD
191 const wxPoint& pos = wxDefaultPosition,
192 const wxSize& size = wxDefaultSize,
6187ec8f 193 long style = wxEL_ALLOW_NEW | wxEL_ALLOW_EDIT | wxEL_ALLOW_DELETE,
137b5242 194 const wxString& name = wxPyEditableListBoxNameStr);
7b7ac0ab 195
611dc22c 196
7b7ac0ab
RD
197 void SetStrings(const wxArrayString& strings);
198
199 //void GetStrings(wxArrayString& strings);
d14a1e28 200 %extend {
7b7ac0ab
RD
201 PyObject* GetStrings() {
202 wxArrayString strings;
203 self->GetStrings(strings);
204 return wxArrayString2PyList_helper(strings);
205 }
206 }
366d7bd6 207
15f80007 208 wxPyListCtrl* GetListCtrl();
d14a1e28
RD
209 wxBitmapButton* GetDelButton();
210 wxBitmapButton* GetNewButton();
211 wxBitmapButton* GetUpButton();
212 wxBitmapButton* GetDownButton();
213 wxBitmapButton* GetEditButton();
7b7ac0ab
RD
214};
215
216
217
d14a1e28 218//---------------------------------------------------------------------------
611dc22c
RD
219
220
221/*
222 * wxRemotelyScrolledTreeCtrl
223 *
224 * This tree control disables its vertical scrollbar and catches scroll
225 * events passed by a scrolled window higher in the hierarchy.
226 * It also updates the scrolled window vertical scrollbar as appropriate.
227 */
228
229%{
230 typedef wxTreeCtrl wxPyTreeCtrl;
231%}
232
ab1f7d2a
RD
233MustHaveApp(wxRemotelyScrolledTreeCtrl);
234
611dc22c
RD
235class wxRemotelyScrolledTreeCtrl: public wxPyTreeCtrl
236{
237public:
2b9048c5
RD
238 %pythonAppend wxRemotelyScrolledTreeCtrl "self._setOORInfo(self)"
239 %pythonAppend wxRemotelyScrolledTreeCtrl() ""
d14a1e28 240
611dc22c
RD
241 wxRemotelyScrolledTreeCtrl(wxWindow* parent, wxWindowID id,
242 const wxPoint& pos = wxDefaultPosition,
243 const wxSize& size = wxDefaultSize,
244 long style = wxTR_HAS_BUTTONS);
611dc22c
RD
245
246
247 void HideVScrollbar();
248
249 // Adjust the containing wxScrolledWindow's scrollbars appropriately
250 void AdjustRemoteScrollbars();
251
252 // Find the scrolled window that contains this control
253 wxScrolledWindow* GetScrolledWindow() const;
254
255 // Scroll to the given line (in scroll units where each unit is
256 // the height of an item)
257 void ScrollToLine(int posHoriz, int posVert);
258
259 // The companion window is one which will get notified when certain
260 // events happen such as node expansion
261 void SetCompanionWindow(wxWindow* companion);
262 wxWindow* GetCompanionWindow() const;
263};
264
265
266
267/*
268 * wxTreeCompanionWindow
269 *
270 * A window displaying values associated with tree control items.
271 */
272
273%{
274class wxPyTreeCompanionWindow: public wxTreeCompanionWindow
275{
276public:
277 wxPyTreeCompanionWindow(wxWindow* parent, wxWindowID id = -1,
278 const wxPoint& pos = wxDefaultPosition,
279 const wxSize& size = wxDefaultSize,
280 long style = 0)
281 : wxTreeCompanionWindow(parent, id, pos, size, style) {}
282
283
284 virtual void DrawItem(wxDC& dc, wxTreeItemId id, const wxRect& rect) {
285 bool found;
da32eb53 286 bool blocked = wxPyBeginBlockThreads();
611dc22c 287 if ((found = wxPyCBH_findCallback(m_myInst, "DrawItem"))) {
6d450e1a 288 PyObject* dcobj = wxPyMake_wxObject(&dc,false);
a72f4631
RD
289 PyObject* idobj = wxPyConstructObject((void*)&id, wxT("wxTreeItemId"), false);
290 PyObject* recobj= wxPyConstructObject((void*)&rect, wxT("wxRect"), false);
611dc22c
RD
291 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OOO)", dcobj, idobj, recobj));
292 Py_DECREF(dcobj);
293 Py_DECREF(idobj);
294 Py_DECREF(recobj);
295 }
da32eb53 296 wxPyEndBlockThreads(blocked);
611dc22c
RD
297 if (! found)
298 wxTreeCompanionWindow::DrawItem(dc, id, rect);
299 }
300
301 PYPRIVATE;
302};
303%}
304
305
ab1f7d2a
RD
306MustHaveApp(wxPyTreeCompanionWindow);
307
d14a1e28 308%name(TreeCompanionWindow) class wxPyTreeCompanionWindow: public wxWindow
611dc22c
RD
309{
310public:
2b9048c5
RD
311 %pythonAppend wxPyTreeCompanionWindow "self._setOORInfo(self);self._setCallbackInfo(self, TreeCompanionWindow)"
312 %pythonAppend wxPyTreeCompanionWindow() ""
d14a1e28 313
611dc22c
RD
314 wxPyTreeCompanionWindow(wxWindow* parent, wxWindowID id = -1,
315 const wxPoint& pos = wxDefaultPosition,
316 const wxSize& size = wxDefaultSize,
317 long style = 0);
318 void _setCallbackInfo(PyObject* self, PyObject* _class);
611dc22c
RD
319
320 wxRemotelyScrolledTreeCtrl* GetTreeCtrl() const;
321 void SetTreeCtrl(wxRemotelyScrolledTreeCtrl* treeCtrl);
322};
323
324
325
326/*
327 * wxThinSplitterWindow
328 *
329 * Implements a splitter with a less obvious sash
330 * than the usual one.
331 */
332
ab1f7d2a
RD
333MustHaveApp(wxThinSplitterWindow);
334
611dc22c
RD
335class wxThinSplitterWindow: public wxSplitterWindow
336{
337public:
2b9048c5
RD
338 %pythonAppend wxThinSplitterWindow "self._setOORInfo(self)"
339 %pythonAppend wxThinSplitterWindow() ""
d14a1e28 340
611dc22c
RD
341 wxThinSplitterWindow(wxWindow* parent, wxWindowID id = -1,
342 const wxPoint& pos = wxDefaultPosition,
343 const wxSize& size = wxDefaultSize,
344 long style = wxSP_3D | wxCLIP_CHILDREN);
611dc22c
RD
345};
346
347
d14a1e28 348
611dc22c
RD
349/*
350 * wxSplitterScrolledWindow
351 *
352 * This scrolled window is aware of the fact that one of its
353 * children is a splitter window. It passes on its scroll events
354 * (after some processing) to both splitter children for them
355 * scroll appropriately.
356 */
357
ab1f7d2a
RD
358MustHaveApp(wxSplitterScrolledWindow);
359
611dc22c
RD
360class wxSplitterScrolledWindow: public wxScrolledWindow
361{
362public:
2b9048c5
RD
363 %pythonAppend wxSplitterScrolledWindow "self._setOORInfo(self)"
364 %pythonAppend wxSplitterScrolledWindow() ""
d14a1e28 365
611dc22c
RD
366 wxSplitterScrolledWindow(wxWindow* parent, wxWindowID id = -1,
367 const wxPoint& pos = wxDefaultPosition,
368 const wxSize& size = wxDefaultSize,
369 long style = 0);
611dc22c
RD
370};
371
372
d14a1e28
RD
373//---------------------------------------------------------------------------
374//---------------------------------------------------------------------------
950e7faf
RD
375
376
377enum wxLEDValueAlign
378{
379 wxLED_ALIGN_LEFT,
380 wxLED_ALIGN_RIGHT,
381 wxLED_ALIGN_CENTER,
382
383 wxLED_ALIGN_MASK,
384
385 wxLED_DRAW_FADED,
386};
387
388
ab1f7d2a
RD
389MustHaveApp(wxLEDNumberCtrl);
390
950e7faf
RD
391class wxLEDNumberCtrl : public wxControl
392{
393public:
2b9048c5
RD
394 %pythonAppend wxLEDNumberCtrl "self._setOORInfo(self)"
395 %pythonAppend wxLEDNumberCtrl() ""
d14a1e28 396
950e7faf
RD
397 wxLEDNumberCtrl(wxWindow *parent, wxWindowID id = -1,
398 const wxPoint& pos = wxDefaultPosition,
399 const wxSize& size = wxDefaultSize,
400 long style = wxLED_ALIGN_LEFT | wxLED_DRAW_FADED);
d14a1e28 401 %name(PreLEDNumberCtrl) wxLEDNumberCtrl();
950e7faf 402
950e7faf
RD
403 bool Create(wxWindow *parent, wxWindowID id = -1,
404 const wxPoint& pos = wxDefaultPosition,
405 const wxSize& size = wxDefaultSize,
406 long style = wxLED_ALIGN_LEFT | wxLED_DRAW_FADED);
407
d14a1e28
RD
408 wxLEDValueAlign GetAlignment() const;
409 bool GetDrawFaded() const;
410 const wxString &GetValue() const;
950e7faf
RD
411
412 void SetAlignment(wxLEDValueAlign Alignment, bool Redraw = true);
413 void SetDrawFaded(bool DrawFaded, bool Redraw = true);
414 void SetValue(const wxString &Value, bool Redraw = true);
415
416};
417
1fded56b
RD
418
419
420//----------------------------------------------------------------------------
421// wxTreeListCtrl - the multicolumn tree control
422//----------------------------------------------------------------------------
423
424enum wxTreeListColumnAlign {
425 wxTL_ALIGN_LEFT,
426 wxTL_ALIGN_RIGHT,
427 wxTL_ALIGN_CENTER
428};
429
430
431
432enum {
433 wxTREE_HITTEST_ONITEMCOLUMN
434};
435
436
28eab81f
RD
437enum {
438 // flags for FindItem
439 wxTL_SEARCH_VISIBLE,
440 wxTL_SEARCH_LEVEL,
441 wxTL_SEARCH_FULL,
442 wxTL_SEARCH_PARTIAL,
443 wxTL_SEARCH_NOCASE
444};
445
648d396c
RD
446enum {
447 // extra tree styles
448 wxTR_DONT_ADJUST_MAC
449};
450%pythoncode { wx.TR_DONT_ADJUST_MAC = TR_DONT_ADJUST_MAC }
1fded56b
RD
451
452
453class wxTreeListColumnInfo: public wxObject {
454public:
455 wxTreeListColumnInfo(const wxString& text = wxPyEmptyString,
456 int image = -1,
457 size_t width = 100,
a72f4631 458 bool shown = true,
1fded56b
RD
459 wxTreeListColumnAlign alignment = wxTL_ALIGN_LEFT);
460
28eab81f 461 bool GetShown() const;
1fded56b
RD
462 wxTreeListColumnAlign GetAlignment() const;
463 wxString GetText() const;
464 int GetImage() const;
465 int GetSelectedImage() const;
466 size_t GetWidth() const;
467
28eab81f
RD
468 // TODO: These all actually return wxTreeListColumnInfo&, any problem with doing it for Python too?
469 void SetShown(bool shown);
1fded56b
RD
470 void SetAlignment(wxTreeListColumnAlign alignment);
471 void SetText(const wxString& text);
472 void SetImage(int image);
473 void SetSelectedImage(int image);
474 void SetWidth(size_t with);
475};
476
477
478
479
480%{ // C++ version of Python aware control
481class wxPyTreeListCtrl : public wxTreeListCtrl {
482 DECLARE_ABSTRACT_CLASS(wxPyTreeListCtrl);
483public:
484 wxPyTreeListCtrl() : wxTreeListCtrl() {}
485 wxPyTreeListCtrl(wxWindow *parent, wxWindowID id,
486 const wxPoint& pos,
487 const wxSize& size,
488 long style,
489 const wxValidator &validator,
490 const wxString& name) :
491 wxTreeListCtrl(parent, id, pos, size, style, validator, name) {}
492
493 int OnCompareItems(const wxTreeItemId& item1,
494 const wxTreeItemId& item2) {
495 int rval = 0;
496 bool found;
da32eb53 497 bool blocked = wxPyBeginBlockThreads();
1fded56b
RD
498 if ((found = wxPyCBH_findCallback(m_myInst, "OnCompareItems"))) {
499 PyObject *o1 = wxPyConstructObject((void*)&item1, wxT("wxTreeItemId"), 0);
500 PyObject *o2 = wxPyConstructObject((void*)&item2, wxT("wxTreeItemId"), 0);
501 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OO)",o1,o2));
502 Py_DECREF(o1);
503 Py_DECREF(o2);
504 }
da32eb53 505 wxPyEndBlockThreads(blocked);
1fded56b
RD
506 if (! found)
507 rval = wxTreeListCtrl::OnCompareItems(item1, item2);
508 return rval;
509 }
510 PYPRIVATE;
511};
512
513IMPLEMENT_ABSTRACT_CLASS(wxPyTreeListCtrl, wxTreeListCtrl)
514
515%}
516
517
518
519
1fded56b
RD
520
521
ab1f7d2a
RD
522MustHaveApp(wxPyTreeListCtrl);
523
d14a1e28 524%name(TreeListCtrl) class wxPyTreeListCtrl : public wxControl
1fded56b
RD
525{
526public:
2b9048c5
RD
527 %pythonAppend wxPyTreeListCtrl "self._setOORInfo(self);self._setCallbackInfo(self, TreeListCtrl)"
528 %pythonAppend wxPyTreeListCtrl() ""
d14a1e28 529
1fded56b
RD
530 wxPyTreeListCtrl(wxWindow *parent, wxWindowID id = -1,
531 const wxPoint& pos = wxDefaultPosition,
532 const wxSize& size = wxDefaultSize,
533 long style = wxTR_DEFAULT_STYLE,
534 const wxValidator &validator = wxDefaultValidator,
535 const wxString& name = wxPyTreeListCtrlNameStr );
d14a1e28 536 %name(PreTreeListCtrl)wxPyTreeListCtrl();
1fded56b
RD
537
538 bool Create(wxWindow *parent, wxWindowID id = -1,
539 const wxPoint& pos = wxDefaultPosition,
540 const wxSize& size = wxDefaultSize,
541 long style = wxTR_DEFAULT_STYLE,
542 const wxValidator &validator = wxDefaultValidator,
543 const wxString& name = wxPyTreeListCtrlNameStr );
544
545 void _setCallbackInfo(PyObject* self, PyObject* _class);
1fded56b 546
28eab81f 547
1fded56b
RD
548 // get the total number of items in the control
549 size_t GetCount() const;
550
551 // indent is the number of pixels the children are indented relative to
552 // the parents position. SetIndent() also redraws the control
553 // immediately.
554 unsigned int GetIndent() const;
555 void SetIndent(unsigned int indent);
556
1fded56b
RD
557 // line spacing is the space above and below the text on each line
558 unsigned int GetLineSpacing() const;
559 void SetLineSpacing(unsigned int spacing);
560
561 // image list: these functions allow to associate an image list with
562 // the control and retrieve it. Note that when assigned with
563 // SetImageList, the control does _not_ delete
564 // the associated image list when it's deleted in order to allow image
565 // lists to be shared between different controls. If you use
566 // AssignImageList, the control _does_ delete the image list.
567 //
568 // The normal image list is for the icons which correspond to the
569 // normal tree item state (whether it is selected or not).
570 // Additionally, the application might choose to show a state icon
571 // which corresponds to an app-defined item state (for example,
572 // checked/unchecked) which are taken from the state image list.
573 wxImageList *GetImageList() const;
574 wxImageList *GetStateImageList() const;
575 wxImageList *GetButtonsImageList() const;
576
577 void SetImageList(wxImageList *imageList);
578 void SetStateImageList(wxImageList *imageList);
579 void SetButtonsImageList(wxImageList *imageList);
15d9a04c 580
45da8bb7 581 %apply SWIGTYPE *DISOWN { wxImageList *imageList };
1fded56b
RD
582 void AssignImageList(wxImageList *imageList);
583 void AssignStateImageList(wxImageList *imageList);
584 void AssignButtonsImageList(wxImageList *imageList);
45da8bb7 585 %clear wxImageList *imageList;
1fded56b
RD
586
587
588 // adds a column
589 void AddColumn(const wxString& text);
28eab81f
RD
590// void AddColumn(const wxString& text,
591// size_t width,
592// wxTreeListColumnAlign alignment = wxTL_ALIGN_LEFT);
1fded56b
RD
593 %name(AddColumnInfo) void AddColumn(const wxTreeListColumnInfo& col);
594
595 // inserts a column before the given one
596 void InsertColumn(size_t before, const wxString& text);
597 %name(InsertColumnInfo) void InsertColumn(size_t before, const wxTreeListColumnInfo& col);
598
599 // deletes the given column - does not delete the corresponding column
600 // of each item
601 void RemoveColumn(size_t column);
602
603 // returns the number of columns in the ctrl
604 size_t GetColumnCount() const;
605
606 void SetColumnWidth(size_t column, size_t width);
607 int GetColumnWidth(size_t column) const;
608
609 // tells which column is the "main" one, i.e. the "threaded" one
610 void SetMainColumn(size_t column);
611 size_t GetMainColumn() const;
612
613 void SetColumnText(size_t column, const wxString& text);
614 wxString GetColumnText(size_t column) const;
615
616 void SetColumn(size_t column, const wxTreeListColumnInfo& info);
617 wxTreeListColumnInfo& GetColumn(size_t column);
618
619 // other column-related methods
620 void SetColumnAlignment(size_t column, wxTreeListColumnAlign align);
621 wxTreeListColumnAlign GetColumnAlignment(size_t column) const;
622
623 void SetColumnImage(size_t column, int image);
624 int GetColumnImage(size_t column) const;
625
28eab81f
RD
626 void ShowColumn(size_t column, bool shown);
627 bool IsColumnShown(size_t column) const;
1fded56b 628
d14a1e28 629 %extend {
1fded56b
RD
630 // retrieves item's label of the given column (main column by default)
631 wxString GetItemText(const wxTreeItemId& item, int column = -1) {
632 if (column < 0) column = self->GetMainColumn();
633 return self->GetItemText(item, column);
634 }
635
636 // get one of the images associated with the item (normal by default)
637 int GetItemImage(const wxTreeItemId& item, int column = -1,
638 wxTreeItemIcon which = wxTreeItemIcon_Normal) {
639 if (column < 0) column = self->GetMainColumn();
640 return self->GetItemImage(item, column, which);
641 }
642
643 // set item's label (main column by default)
644 void SetItemText(const wxTreeItemId& item, const wxString& text, int column = -1) {
645 if (column < 0) column = self->GetMainColumn();
646 self->SetItemText(item, column, text);
647 }
648
649 // set one of the images associated with the item (normal by default)
650 // the which parameter is ignored for all columns but the main one
651 void SetItemImage(const wxTreeItemId& item, int image, int column = -1,
652 wxTreeItemIcon which = wxTreeItemIcon_Normal) {
653 if (column < 0) column = self->GetMainColumn();
654 self->SetItemImage(item, column, image, which);
655 }
656
657
658 // [Get|Set]ItemData substitutes. Automatically create wxPyTreeItemData
659 // if needed.
660 wxPyTreeItemData* GetItemData(const wxTreeItemId& item) {
661 wxPyTreeItemData* data = (wxPyTreeItemData*)self->GetItemData(item);
662 if (data == NULL) {
663 data = new wxPyTreeItemData();
664 data->SetId(item); // set the id
665 self->SetItemData(item, data);
666 }
667 return data;
668 }
669
670 void SetItemData(const wxTreeItemId& item, wxPyTreeItemData* data) {
671 data->SetId(item); // set the id
672 self->SetItemData(item, data);
673 }
674
d14a1e28 675 // [Get|Set]ItemPyData are short-cuts. Also made somewhat crash-proof by
1fded56b 676 // automatically creating data classes.
d14a1e28 677 PyObject* GetItemPyData(const wxTreeItemId& item) {
1fded56b
RD
678 wxPyTreeItemData* data = (wxPyTreeItemData*)self->GetItemData(item);
679 if (data == NULL) {
680 data = new wxPyTreeItemData();
681 data->SetId(item); // set the id
682 self->SetItemData(item, data);
683 }
684 return data->GetData();
685 }
686
d14a1e28 687 void SetItemPyData(const wxTreeItemId& item, PyObject* obj) {
1fded56b
RD
688 wxPyTreeItemData* data = (wxPyTreeItemData*)self->GetItemData(item);
689 if (data == NULL) {
690 data = new wxPyTreeItemData(obj);
691 data->SetId(item); // set the id
692 self->SetItemData(item, data);
693 } else
694 data->SetData(obj);
695 }
696 }
4e0b6696
RD
697 %pythoncode { GetPyData = GetItemPyData }
698 %pythoncode { SetPyData = SetItemPyData }
1fded56b
RD
699
700
701 // force appearance of [+] button near the item. This is useful to
702 // allow the user to expand the items which don't have any children now
703 // - but instead add them only when needed, thus minimizing memory
704 // usage and loading time.
a72f4631 705 void SetItemHasChildren(const wxTreeItemId& item, bool has = true);
1fded56b
RD
706
707 // the item will be shown in bold
a72f4631 708 void SetItemBold(const wxTreeItemId& item, bool bold = true);
1fded56b
RD
709
710 // set the item's text colour
28eab81f 711 void SetItemTextColour(const wxTreeItemId& item, const wxColour& colour);
1fded56b
RD
712
713 // set the item's background colour
714 void SetItemBackgroundColour(const wxTreeItemId& item,
28eab81f 715 const wxColour& colour);
1fded56b
RD
716
717 // set the item's font (should be of the same height for all items)
718 void SetItemFont(const wxTreeItemId& item, const wxFont& font);
719
720
721 bool GetItemBold(const wxTreeItemId& item) const;
722 wxColour GetItemTextColour(const wxTreeItemId& item) const;
723 wxColour GetItemBackgroundColour(const wxTreeItemId& item) const;
724 wxFont GetItemFont(const wxTreeItemId& item) const;
725
726 // is the item visible (it might be outside the view or not expanded)?
727 bool IsVisible(const wxTreeItemId& item) const;
728
729 // does the item has any children?
730 bool ItemHasChildren(const wxTreeItemId& item) const;
731
732 // is the item expanded (only makes sense if HasChildren())?
733 bool IsExpanded(const wxTreeItemId& item) const;
734
735 // is this item currently selected (the same as has focus)?
736 bool IsSelected(const wxTreeItemId& item) const;
737
738 // is item text in bold font?
739 bool IsBold(const wxTreeItemId& item) const;
740
dd9f7fea 741 // if 'recursively' is False, only immediate children count, otherwise
1fded56b 742 // the returned number is the number of all items in this branch
a72f4631 743 size_t GetChildrenCount(const wxTreeItemId& item, bool recursively = true);
1fded56b
RD
744
745
dd9f7fea 746 // wxTreeItemId.IsOk() will return False if there is no such item
1fded56b
RD
747
748 // get the root tree item
749 wxTreeItemId GetRootItem() const;
750
751 // get the item currently selected (may return NULL if no selection)
752 wxTreeItemId GetSelection() const;
753
754 // get the items currently selected, return the number of such item
755 //size_t GetSelections(wxArrayTreeItemIds&) const;
d14a1e28 756 %extend {
1fded56b 757 PyObject* GetSelections() {
da32eb53 758 bool blocked = wxPyBeginBlockThreads();
1fded56b
RD
759 PyObject* rval = PyList_New(0);
760 wxArrayTreeItemIds array;
761 size_t num, x;
762 num = self->GetSelections(array);
763 for (x=0; x < num; x++) {
764 wxTreeItemId *tii = new wxTreeItemId(array.Item(x));
a72f4631 765 PyObject* item = wxPyConstructObject((void*)tii, wxT("wxTreeItemId"), true);
1fded56b
RD
766 PyList_Append(rval, item);
767 }
da32eb53 768 wxPyEndBlockThreads(blocked);
1fded56b
RD
769 return rval;
770 }
771 }
772
773
774 // get the parent of this item (may return NULL if root)
28eab81f 775 wxTreeItemId GetItemParent(const wxTreeItemId& item) const;
1fded56b
RD
776
777 // for this enumeration function you must pass in a "cookie" parameter
778 // which is opaque for the application but is necessary for the library
779 // to make these functions reentrant (i.e. allow more than one
780 // enumeration on one and the same object simultaneously). Of course,
781 // the "cookie" passed to GetFirstChild() and GetNextChild() should be
782 // the same!
783
1fded56b 784
28eab81f
RD
785 // NOTE: These are a copy of the same methods in _treectrl.i, be sure to
786 // update both at the same time. (Or find a good way to refactor!)
d14a1e28
RD
787 %extend {
788 // Get the first child of this item. Returns a wxTreeItemId and an
789 // opaque "cookie" value that should be passed to GetNextChild in
790 // order to continue the search.
791 PyObject* GetFirstChild(const wxTreeItemId& item) {
28eab81f 792 void* cookie = 0;
61136550 793 wxTreeItemId* ritem = new wxTreeItemId(self->GetFirstChild(item, cookie));
da32eb53 794 bool blocked = wxPyBeginBlockThreads();
d14a1e28 795 PyObject* tup = PyTuple_New(2);
a72f4631 796 PyTuple_SET_ITEM(tup, 0, wxPyConstructObject(ritem, wxT("wxTreeItemId"), true));
28eab81f 797 PyTuple_SET_ITEM(tup, 1, wxPyMakeSwigPtr(cookie, wxT("void")));
da32eb53 798 wxPyEndBlockThreads(blocked);
d14a1e28
RD
799 return tup;
800 }
801
802
803 // Get the next child of this item. The cookie parameter is the 2nd
804 // value returned from GetFirstChild or the previous GetNextChild.
805 // Returns a wxTreeItemId and an opaque "cookie" value that should be
806 // passed to GetNextChild in order to continue the search.
28eab81f 807 PyObject* GetNextChild(const wxTreeItemId& item, void* cookie) {
61136550 808 wxTreeItemId* ritem = new wxTreeItemId(self->GetNextChild(item, cookie));
da32eb53 809 bool blocked = wxPyBeginBlockThreads();
d14a1e28 810 PyObject* tup = PyTuple_New(2);
a72f4631 811 PyTuple_SET_ITEM(tup, 0, wxPyConstructObject(ritem, wxT("wxTreeItemId"), true));
28eab81f 812 PyTuple_SET_ITEM(tup, 1, wxPyMakeSwigPtr(cookie, wxT("void")));
da32eb53 813 wxPyEndBlockThreads(blocked);
d14a1e28 814 return tup;
28eab81f
RD
815 }
816
817
818 // TODO: GetPrevChild
819
d14a1e28 820 }
1fded56b
RD
821
822 // get the last child of this item - this method doesn't use cookies
823 wxTreeItemId GetLastChild(const wxTreeItemId& item) const;
824
825 // get the next sibling of this item
826 wxTreeItemId GetNextSibling(const wxTreeItemId& item) const;
827
828 // get the previous sibling
829 wxTreeItemId GetPrevSibling(const wxTreeItemId& item) const;
830
831 // get first visible item
832 wxTreeItemId GetFirstVisibleItem() const;
833
834 // get the next visible item: item must be visible itself!
835 // see IsVisible() and wxTreeCtrl::GetFirstVisibleItem()
836 wxTreeItemId GetNextVisible(const wxTreeItemId& item) const;
837
838 // get the previous visible item: item must be visible itself!
839 wxTreeItemId GetPrevVisible(const wxTreeItemId& item) const;
840
841 // Only for internal use right now, but should probably be public
842 wxTreeItemId GetNext(const wxTreeItemId& item) const;
843
844
845 // add the root node to the tree
846 wxTreeItemId AddRoot(const wxString& text,
847 int image = -1, int selectedImage = -1,
848 wxPyTreeItemData *data = NULL);
849
850 // insert a new item in as the first child of the parent
851 wxTreeItemId PrependItem(const wxTreeItemId& parent,
852 const wxString& text,
853 int image = -1, int selectedImage = -1,
854 wxPyTreeItemData *data = NULL);
855
856 // insert a new item after a given one
857 wxTreeItemId InsertItem(const wxTreeItemId& parent,
858 const wxTreeItemId& idPrevious,
859 const wxString& text,
860 int image = -1, int selectedImage = -1,
861 wxPyTreeItemData *data = NULL);
862
863 // insert a new item before the one with the given index
864 %name(InsertItemBefore)
865 wxTreeItemId InsertItem(const wxTreeItemId& parent,
866 size_t index,
867 const wxString& text,
868 int image = -1, int selectedImage = -1,
869 wxPyTreeItemData *data = NULL);
870
871 // insert a new item in as the last child of the parent
872 wxTreeItemId AppendItem(const wxTreeItemId& parent,
873 const wxString& text,
874 int image = -1, int selectedImage = -1,
875 wxPyTreeItemData *data = NULL);
876
877 // delete this item and associated data if any
878 void Delete(const wxTreeItemId& item);
879
880 // delete all children (but don't delete the item itself)
881 // NB: this won't send wxEVT_COMMAND_TREE_ITEM_DELETED events
882 void DeleteChildren(const wxTreeItemId& item);
883
884 // delete all items from the tree
885 // NB: this won't send wxEVT_COMMAND_TREE_ITEM_DELETED events
886 void DeleteAllItems();
887
888 // expand this item
889 void Expand(const wxTreeItemId& item);
890
891 // expand this item and all subitems recursively
892 void ExpandAll(const wxTreeItemId& item);
893
894 // collapse the item without removing its children
895 void Collapse(const wxTreeItemId& item);
896
897 // collapse the item and remove all children
898 void CollapseAndReset(const wxTreeItemId& item);
899
900 // toggles the current state
901 void Toggle(const wxTreeItemId& item);
902
903 // remove the selection from currently selected item (if any)
904 void Unselect();
905 void UnselectAll();
906
907 // select this item
a72f4631
RD
908 void SelectItem(const wxTreeItemId& item, bool unselect_others=true,
909 bool extended_select=false);
1fded56b 910
a72f4631 911 void SelectAll(bool extended_select=false);
28eab81f 912
1fded56b
RD
913 // make sure this item is visible (expanding the parent item and/or
914 // scrolling to this item if necessary)
915 void EnsureVisible(const wxTreeItemId& item);
916
917 // scroll to this item (but don't expand its parent)
918 void ScrollTo(const wxTreeItemId& item);
919
920 // Returns wxTreeItemId, flags, and column
921 wxTreeItemId HitTest(const wxPoint& point, int& OUTPUT, int& OUTPUT);
922
d14a1e28 923 %extend {
1fded56b 924 // get the bounding rectangle of the item (or of its label only)
a72f4631 925 PyObject* GetBoundingRect(const wxTreeItemId& item, bool textOnly = false) {
1fded56b
RD
926 wxRect rect;
927 if (self->GetBoundingRect(item, rect, textOnly)) {
da32eb53 928 bool blocked = wxPyBeginBlockThreads();
1fded56b
RD
929 wxRect* r = new wxRect(rect);
930 PyObject* val = wxPyConstructObject((void*)r, wxT("wxRect"), 1);
da32eb53 931 wxPyEndBlockThreads(blocked);
1fded56b
RD
932 return val;
933 }
934 else {
d14a1e28 935 RETURN_NONE();
1fded56b
RD
936 }
937 }
938 }
939
940
941 // Start editing the item label: this (temporarily) replaces the item
942 // with a one line edit control. The item will be selected if it hadn't
943 // been before.
944 void EditLabel( const wxTreeItemId& item );
945 void Edit( const wxTreeItemId& item );
946
947 // sort the children of this item using OnCompareItems
948 void SortChildren(const wxTreeItemId& item);
949
28eab81f
RD
950 // searching
951 wxTreeItemId FindItem (const wxTreeItemId& item, const wxString& str, int flags = 0);
1fded56b
RD
952
953 wxWindow* GetHeaderWindow() const;
6d450e1a 954 wxScrolledWindow* GetMainWindow() const;
1fded56b 955
1fded56b
RD
956};
957
958
959
960
950e7faf 961//----------------------------------------------------------------------
ebf4302c
RD
962//----------------------------------------------------------------------
963
964%init %{
965
611dc22c 966 wxPyPtrTypeMap_Add("wxTreeCompanionWindow", "wxPyTreeCompanionWindow");
1fded56b 967 wxPyPtrTypeMap_Add("wxTreeListCtrl", "wxPyTreeListCtrl");
ebf4302c
RD
968%}
969
970
ebf4302c
RD
971%pragma(python) include="_gizmoextras.py";
972
973//----------------------------------------------------------------------
974//----------------------------------------------------------------------
975