]> git.saurik.com Git - wxWidgets.git/blame - wxPython/contrib/gizmos/gizmos.i
Set the mouse pos for the drag events
[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);
1b8c7ba6 153 %RenameCtor(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
1b8c7ba6
RD
308%rename(TreeCompanionWindow) wxPyTreeCompanionWindow;
309class wxPyTreeCompanionWindow: public wxWindow
611dc22c
RD
310{
311public:
2b9048c5
RD
312 %pythonAppend wxPyTreeCompanionWindow "self._setOORInfo(self);self._setCallbackInfo(self, TreeCompanionWindow)"
313 %pythonAppend wxPyTreeCompanionWindow() ""
d14a1e28 314
611dc22c
RD
315 wxPyTreeCompanionWindow(wxWindow* parent, wxWindowID id = -1,
316 const wxPoint& pos = wxDefaultPosition,
317 const wxSize& size = wxDefaultSize,
318 long style = 0);
319 void _setCallbackInfo(PyObject* self, PyObject* _class);
611dc22c
RD
320
321 wxRemotelyScrolledTreeCtrl* GetTreeCtrl() const;
322 void SetTreeCtrl(wxRemotelyScrolledTreeCtrl* treeCtrl);
323};
324
325
326
327/*
328 * wxThinSplitterWindow
329 *
330 * Implements a splitter with a less obvious sash
331 * than the usual one.
332 */
333
ab1f7d2a
RD
334MustHaveApp(wxThinSplitterWindow);
335
611dc22c
RD
336class wxThinSplitterWindow: public wxSplitterWindow
337{
338public:
2b9048c5
RD
339 %pythonAppend wxThinSplitterWindow "self._setOORInfo(self)"
340 %pythonAppend wxThinSplitterWindow() ""
d14a1e28 341
611dc22c
RD
342 wxThinSplitterWindow(wxWindow* parent, wxWindowID id = -1,
343 const wxPoint& pos = wxDefaultPosition,
344 const wxSize& size = wxDefaultSize,
345 long style = wxSP_3D | wxCLIP_CHILDREN);
611dc22c
RD
346};
347
348
d14a1e28 349
611dc22c
RD
350/*
351 * wxSplitterScrolledWindow
352 *
353 * This scrolled window is aware of the fact that one of its
354 * children is a splitter window. It passes on its scroll events
355 * (after some processing) to both splitter children for them
356 * scroll appropriately.
357 */
358
ab1f7d2a
RD
359MustHaveApp(wxSplitterScrolledWindow);
360
611dc22c
RD
361class wxSplitterScrolledWindow: public wxScrolledWindow
362{
363public:
2b9048c5
RD
364 %pythonAppend wxSplitterScrolledWindow "self._setOORInfo(self)"
365 %pythonAppend wxSplitterScrolledWindow() ""
d14a1e28 366
611dc22c
RD
367 wxSplitterScrolledWindow(wxWindow* parent, wxWindowID id = -1,
368 const wxPoint& pos = wxDefaultPosition,
369 const wxSize& size = wxDefaultSize,
370 long style = 0);
611dc22c
RD
371};
372
373
d14a1e28
RD
374//---------------------------------------------------------------------------
375//---------------------------------------------------------------------------
950e7faf
RD
376
377
378enum wxLEDValueAlign
379{
380 wxLED_ALIGN_LEFT,
381 wxLED_ALIGN_RIGHT,
382 wxLED_ALIGN_CENTER,
383
384 wxLED_ALIGN_MASK,
385
386 wxLED_DRAW_FADED,
387};
388
389
ab1f7d2a
RD
390MustHaveApp(wxLEDNumberCtrl);
391
950e7faf
RD
392class wxLEDNumberCtrl : public wxControl
393{
394public:
2b9048c5
RD
395 %pythonAppend wxLEDNumberCtrl "self._setOORInfo(self)"
396 %pythonAppend wxLEDNumberCtrl() ""
d14a1e28 397
950e7faf
RD
398 wxLEDNumberCtrl(wxWindow *parent, wxWindowID id = -1,
399 const wxPoint& pos = wxDefaultPosition,
400 const wxSize& size = wxDefaultSize,
401 long style = wxLED_ALIGN_LEFT | wxLED_DRAW_FADED);
1b8c7ba6 402 %RenameCtor(PreLEDNumberCtrl, wxLEDNumberCtrl());
950e7faf 403
950e7faf
RD
404 bool Create(wxWindow *parent, wxWindowID id = -1,
405 const wxPoint& pos = wxDefaultPosition,
406 const wxSize& size = wxDefaultSize,
407 long style = wxLED_ALIGN_LEFT | wxLED_DRAW_FADED);
408
d14a1e28
RD
409 wxLEDValueAlign GetAlignment() const;
410 bool GetDrawFaded() const;
411 const wxString &GetValue() const;
950e7faf
RD
412
413 void SetAlignment(wxLEDValueAlign Alignment, bool Redraw = true);
414 void SetDrawFaded(bool DrawFaded, bool Redraw = true);
415 void SetValue(const wxString &Value, bool Redraw = true);
416
417};
418
1fded56b
RD
419
420
421//----------------------------------------------------------------------------
422// wxTreeListCtrl - the multicolumn tree control
423//----------------------------------------------------------------------------
424
425enum wxTreeListColumnAlign {
426 wxTL_ALIGN_LEFT,
427 wxTL_ALIGN_RIGHT,
428 wxTL_ALIGN_CENTER
429};
430
431
432
433enum {
434 wxTREE_HITTEST_ONITEMCOLUMN
435};
436
437
28eab81f
RD
438enum {
439 // flags for FindItem
440 wxTL_SEARCH_VISIBLE,
441 wxTL_SEARCH_LEVEL,
442 wxTL_SEARCH_FULL,
443 wxTL_SEARCH_PARTIAL,
444 wxTL_SEARCH_NOCASE
445};
446
648d396c
RD
447enum {
448 // extra tree styles
449 wxTR_DONT_ADJUST_MAC
450};
451%pythoncode { wx.TR_DONT_ADJUST_MAC = TR_DONT_ADJUST_MAC }
1fded56b
RD
452
453
454class wxTreeListColumnInfo: public wxObject {
455public:
456 wxTreeListColumnInfo(const wxString& text = wxPyEmptyString,
457 int image = -1,
458 size_t width = 100,
a72f4631 459 bool shown = true,
1fded56b
RD
460 wxTreeListColumnAlign alignment = wxTL_ALIGN_LEFT);
461
28eab81f 462 bool GetShown() const;
1fded56b
RD
463 wxTreeListColumnAlign GetAlignment() const;
464 wxString GetText() const;
465 int GetImage() const;
466 int GetSelectedImage() const;
467 size_t GetWidth() const;
468
28eab81f
RD
469 // TODO: These all actually return wxTreeListColumnInfo&, any problem with doing it for Python too?
470 void SetShown(bool shown);
1fded56b
RD
471 void SetAlignment(wxTreeListColumnAlign alignment);
472 void SetText(const wxString& text);
473 void SetImage(int image);
474 void SetSelectedImage(int image);
475 void SetWidth(size_t with);
476};
477
478
479
480
481%{ // C++ version of Python aware control
482class wxPyTreeListCtrl : public wxTreeListCtrl {
483 DECLARE_ABSTRACT_CLASS(wxPyTreeListCtrl);
484public:
485 wxPyTreeListCtrl() : wxTreeListCtrl() {}
486 wxPyTreeListCtrl(wxWindow *parent, wxWindowID id,
487 const wxPoint& pos,
488 const wxSize& size,
489 long style,
490 const wxValidator &validator,
491 const wxString& name) :
492 wxTreeListCtrl(parent, id, pos, size, style, validator, name) {}
493
494 int OnCompareItems(const wxTreeItemId& item1,
495 const wxTreeItemId& item2) {
496 int rval = 0;
497 bool found;
da32eb53 498 bool blocked = wxPyBeginBlockThreads();
1fded56b
RD
499 if ((found = wxPyCBH_findCallback(m_myInst, "OnCompareItems"))) {
500 PyObject *o1 = wxPyConstructObject((void*)&item1, wxT("wxTreeItemId"), 0);
501 PyObject *o2 = wxPyConstructObject((void*)&item2, wxT("wxTreeItemId"), 0);
502 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OO)",o1,o2));
503 Py_DECREF(o1);
504 Py_DECREF(o2);
505 }
da32eb53 506 wxPyEndBlockThreads(blocked);
1fded56b
RD
507 if (! found)
508 rval = wxTreeListCtrl::OnCompareItems(item1, item2);
509 return rval;
510 }
511 PYPRIVATE;
512};
513
514IMPLEMENT_ABSTRACT_CLASS(wxPyTreeListCtrl, wxTreeListCtrl)
515
516%}
517
518
519
520
1fded56b
RD
521
522
ab1f7d2a
RD
523MustHaveApp(wxPyTreeListCtrl);
524
1b8c7ba6
RD
525%rename(TreeListCtrl) wxPyTreeListCtrl;
526class wxPyTreeListCtrl : public wxControl
1fded56b
RD
527{
528public:
2b9048c5
RD
529 %pythonAppend wxPyTreeListCtrl "self._setOORInfo(self);self._setCallbackInfo(self, TreeListCtrl)"
530 %pythonAppend wxPyTreeListCtrl() ""
d14a1e28 531
1fded56b
RD
532 wxPyTreeListCtrl(wxWindow *parent, wxWindowID id = -1,
533 const wxPoint& pos = wxDefaultPosition,
534 const wxSize& size = wxDefaultSize,
535 long style = wxTR_DEFAULT_STYLE,
536 const wxValidator &validator = wxDefaultValidator,
537 const wxString& name = wxPyTreeListCtrlNameStr );
1b8c7ba6 538 %RenameCtor(PreTreeListCtrl, wxPyTreeListCtrl());
1fded56b
RD
539
540 bool Create(wxWindow *parent, wxWindowID id = -1,
541 const wxPoint& pos = wxDefaultPosition,
542 const wxSize& size = wxDefaultSize,
543 long style = wxTR_DEFAULT_STYLE,
544 const wxValidator &validator = wxDefaultValidator,
545 const wxString& name = wxPyTreeListCtrlNameStr );
546
547 void _setCallbackInfo(PyObject* self, PyObject* _class);
1fded56b 548
28eab81f 549
1fded56b
RD
550 // get the total number of items in the control
551 size_t GetCount() const;
552
553 // indent is the number of pixels the children are indented relative to
554 // the parents position. SetIndent() also redraws the control
555 // immediately.
556 unsigned int GetIndent() const;
557 void SetIndent(unsigned int indent);
558
1fded56b
RD
559 // line spacing is the space above and below the text on each line
560 unsigned int GetLineSpacing() const;
561 void SetLineSpacing(unsigned int spacing);
562
563 // image list: these functions allow to associate an image list with
564 // the control and retrieve it. Note that when assigned with
565 // SetImageList, the control does _not_ delete
566 // the associated image list when it's deleted in order to allow image
567 // lists to be shared between different controls. If you use
568 // AssignImageList, the control _does_ delete the image list.
569 //
570 // The normal image list is for the icons which correspond to the
571 // normal tree item state (whether it is selected or not).
572 // Additionally, the application might choose to show a state icon
573 // which corresponds to an app-defined item state (for example,
574 // checked/unchecked) which are taken from the state image list.
575 wxImageList *GetImageList() const;
576 wxImageList *GetStateImageList() const;
577 wxImageList *GetButtonsImageList() const;
578
579 void SetImageList(wxImageList *imageList);
580 void SetStateImageList(wxImageList *imageList);
581 void SetButtonsImageList(wxImageList *imageList);
15d9a04c 582
45da8bb7 583 %apply SWIGTYPE *DISOWN { wxImageList *imageList };
1fded56b
RD
584 void AssignImageList(wxImageList *imageList);
585 void AssignStateImageList(wxImageList *imageList);
586 void AssignButtonsImageList(wxImageList *imageList);
45da8bb7 587 %clear wxImageList *imageList;
1fded56b
RD
588
589
590 // adds a column
591 void AddColumn(const wxString& text);
28eab81f
RD
592// void AddColumn(const wxString& text,
593// size_t width,
594// wxTreeListColumnAlign alignment = wxTL_ALIGN_LEFT);
1b8c7ba6 595 %Rename(AddColumnInfo, void, AddColumn(const wxTreeListColumnInfo& col));
1fded56b
RD
596
597 // inserts a column before the given one
598 void InsertColumn(size_t before, const wxString& text);
1b8c7ba6 599 %Rename(InsertColumnInfo, void, InsertColumn(size_t before, const wxTreeListColumnInfo& col));
1fded56b
RD
600
601 // deletes the given column - does not delete the corresponding column
602 // of each item
603 void RemoveColumn(size_t column);
604
605 // returns the number of columns in the ctrl
606 size_t GetColumnCount() const;
607
608 void SetColumnWidth(size_t column, size_t width);
609 int GetColumnWidth(size_t column) const;
610
611 // tells which column is the "main" one, i.e. the "threaded" one
612 void SetMainColumn(size_t column);
613 size_t GetMainColumn() const;
614
615 void SetColumnText(size_t column, const wxString& text);
616 wxString GetColumnText(size_t column) const;
617
618 void SetColumn(size_t column, const wxTreeListColumnInfo& info);
619 wxTreeListColumnInfo& GetColumn(size_t column);
620
621 // other column-related methods
622 void SetColumnAlignment(size_t column, wxTreeListColumnAlign align);
623 wxTreeListColumnAlign GetColumnAlignment(size_t column) const;
624
625 void SetColumnImage(size_t column, int image);
626 int GetColumnImage(size_t column) const;
627
28eab81f
RD
628 void ShowColumn(size_t column, bool shown);
629 bool IsColumnShown(size_t column) const;
1fded56b 630
d14a1e28 631 %extend {
1fded56b
RD
632 // retrieves item's label of the given column (main column by default)
633 wxString GetItemText(const wxTreeItemId& item, int column = -1) {
634 if (column < 0) column = self->GetMainColumn();
635 return self->GetItemText(item, column);
636 }
637
638 // get one of the images associated with the item (normal by default)
639 int GetItemImage(const wxTreeItemId& item, int column = -1,
640 wxTreeItemIcon which = wxTreeItemIcon_Normal) {
641 if (column < 0) column = self->GetMainColumn();
642 return self->GetItemImage(item, column, which);
643 }
644
645 // set item's label (main column by default)
646 void SetItemText(const wxTreeItemId& item, const wxString& text, int column = -1) {
647 if (column < 0) column = self->GetMainColumn();
648 self->SetItemText(item, column, text);
649 }
650
651 // set one of the images associated with the item (normal by default)
652 // the which parameter is ignored for all columns but the main one
653 void SetItemImage(const wxTreeItemId& item, int image, int column = -1,
654 wxTreeItemIcon which = wxTreeItemIcon_Normal) {
655 if (column < 0) column = self->GetMainColumn();
656 self->SetItemImage(item, column, image, which);
657 }
658
659
660 // [Get|Set]ItemData substitutes. Automatically create wxPyTreeItemData
661 // if needed.
662 wxPyTreeItemData* GetItemData(const wxTreeItemId& item) {
663 wxPyTreeItemData* data = (wxPyTreeItemData*)self->GetItemData(item);
664 if (data == NULL) {
665 data = new wxPyTreeItemData();
666 data->SetId(item); // set the id
667 self->SetItemData(item, data);
668 }
669 return data;
670 }
671
672 void SetItemData(const wxTreeItemId& item, wxPyTreeItemData* data) {
673 data->SetId(item); // set the id
674 self->SetItemData(item, data);
675 }
676
d14a1e28 677 // [Get|Set]ItemPyData are short-cuts. Also made somewhat crash-proof by
1fded56b 678 // automatically creating data classes.
d14a1e28 679 PyObject* GetItemPyData(const wxTreeItemId& item) {
1fded56b
RD
680 wxPyTreeItemData* data = (wxPyTreeItemData*)self->GetItemData(item);
681 if (data == NULL) {
682 data = new wxPyTreeItemData();
683 data->SetId(item); // set the id
684 self->SetItemData(item, data);
685 }
686 return data->GetData();
687 }
688
d14a1e28 689 void SetItemPyData(const wxTreeItemId& item, PyObject* obj) {
1fded56b
RD
690 wxPyTreeItemData* data = (wxPyTreeItemData*)self->GetItemData(item);
691 if (data == NULL) {
692 data = new wxPyTreeItemData(obj);
693 data->SetId(item); // set the id
694 self->SetItemData(item, data);
695 } else
696 data->SetData(obj);
697 }
698 }
4e0b6696
RD
699 %pythoncode { GetPyData = GetItemPyData }
700 %pythoncode { SetPyData = SetItemPyData }
1fded56b
RD
701
702
703 // force appearance of [+] button near the item. This is useful to
704 // allow the user to expand the items which don't have any children now
705 // - but instead add them only when needed, thus minimizing memory
706 // usage and loading time.
a72f4631 707 void SetItemHasChildren(const wxTreeItemId& item, bool has = true);
1fded56b
RD
708
709 // the item will be shown in bold
a72f4631 710 void SetItemBold(const wxTreeItemId& item, bool bold = true);
1fded56b
RD
711
712 // set the item's text colour
28eab81f 713 void SetItemTextColour(const wxTreeItemId& item, const wxColour& colour);
1fded56b
RD
714
715 // set the item's background colour
716 void SetItemBackgroundColour(const wxTreeItemId& item,
28eab81f 717 const wxColour& colour);
1fded56b
RD
718
719 // set the item's font (should be of the same height for all items)
720 void SetItemFont(const wxTreeItemId& item, const wxFont& font);
721
722
723 bool GetItemBold(const wxTreeItemId& item) const;
724 wxColour GetItemTextColour(const wxTreeItemId& item) const;
725 wxColour GetItemBackgroundColour(const wxTreeItemId& item) const;
726 wxFont GetItemFont(const wxTreeItemId& item) const;
727
728 // is the item visible (it might be outside the view or not expanded)?
729 bool IsVisible(const wxTreeItemId& item) const;
730
731 // does the item has any children?
732 bool ItemHasChildren(const wxTreeItemId& item) const;
733
734 // is the item expanded (only makes sense if HasChildren())?
735 bool IsExpanded(const wxTreeItemId& item) const;
736
737 // is this item currently selected (the same as has focus)?
738 bool IsSelected(const wxTreeItemId& item) const;
739
740 // is item text in bold font?
741 bool IsBold(const wxTreeItemId& item) const;
742
dd9f7fea 743 // if 'recursively' is False, only immediate children count, otherwise
1fded56b 744 // the returned number is the number of all items in this branch
a72f4631 745 size_t GetChildrenCount(const wxTreeItemId& item, bool recursively = true);
1fded56b
RD
746
747
dd9f7fea 748 // wxTreeItemId.IsOk() will return False if there is no such item
1fded56b
RD
749
750 // get the root tree item
751 wxTreeItemId GetRootItem() const;
752
753 // get the item currently selected (may return NULL if no selection)
754 wxTreeItemId GetSelection() const;
755
756 // get the items currently selected, return the number of such item
757 //size_t GetSelections(wxArrayTreeItemIds&) const;
d14a1e28 758 %extend {
1fded56b 759 PyObject* GetSelections() {
da32eb53 760 bool blocked = wxPyBeginBlockThreads();
1fded56b
RD
761 PyObject* rval = PyList_New(0);
762 wxArrayTreeItemIds array;
763 size_t num, x;
764 num = self->GetSelections(array);
765 for (x=0; x < num; x++) {
766 wxTreeItemId *tii = new wxTreeItemId(array.Item(x));
a72f4631 767 PyObject* item = wxPyConstructObject((void*)tii, wxT("wxTreeItemId"), true);
1fded56b
RD
768 PyList_Append(rval, item);
769 }
da32eb53 770 wxPyEndBlockThreads(blocked);
1fded56b
RD
771 return rval;
772 }
773 }
774
775
776 // get the parent of this item (may return NULL if root)
28eab81f 777 wxTreeItemId GetItemParent(const wxTreeItemId& item) const;
1fded56b
RD
778
779 // for this enumeration function you must pass in a "cookie" parameter
780 // which is opaque for the application but is necessary for the library
781 // to make these functions reentrant (i.e. allow more than one
782 // enumeration on one and the same object simultaneously). Of course,
783 // the "cookie" passed to GetFirstChild() and GetNextChild() should be
784 // the same!
785
1fded56b 786
28eab81f
RD
787 // NOTE: These are a copy of the same methods in _treectrl.i, be sure to
788 // update both at the same time. (Or find a good way to refactor!)
d14a1e28
RD
789 %extend {
790 // Get the first child of this item. Returns a wxTreeItemId and an
791 // opaque "cookie" value that should be passed to GetNextChild in
792 // order to continue the search.
793 PyObject* GetFirstChild(const wxTreeItemId& item) {
28eab81f 794 void* cookie = 0;
61136550 795 wxTreeItemId* ritem = new wxTreeItemId(self->GetFirstChild(item, cookie));
da32eb53 796 bool blocked = wxPyBeginBlockThreads();
d14a1e28 797 PyObject* tup = PyTuple_New(2);
a72f4631 798 PyTuple_SET_ITEM(tup, 0, wxPyConstructObject(ritem, wxT("wxTreeItemId"), true));
28eab81f 799 PyTuple_SET_ITEM(tup, 1, wxPyMakeSwigPtr(cookie, wxT("void")));
da32eb53 800 wxPyEndBlockThreads(blocked);
d14a1e28
RD
801 return tup;
802 }
803
804
805 // Get the next child of this item. The cookie parameter is the 2nd
806 // value returned from GetFirstChild or the previous GetNextChild.
807 // Returns a wxTreeItemId and an opaque "cookie" value that should be
808 // passed to GetNextChild in order to continue the search.
28eab81f 809 PyObject* GetNextChild(const wxTreeItemId& item, void* cookie) {
61136550 810 wxTreeItemId* ritem = new wxTreeItemId(self->GetNextChild(item, cookie));
da32eb53 811 bool blocked = wxPyBeginBlockThreads();
d14a1e28 812 PyObject* tup = PyTuple_New(2);
a72f4631 813 PyTuple_SET_ITEM(tup, 0, wxPyConstructObject(ritem, wxT("wxTreeItemId"), true));
28eab81f 814 PyTuple_SET_ITEM(tup, 1, wxPyMakeSwigPtr(cookie, wxT("void")));
da32eb53 815 wxPyEndBlockThreads(blocked);
d14a1e28 816 return tup;
28eab81f
RD
817 }
818
819
820 // TODO: GetPrevChild
821
d14a1e28 822 }
1fded56b
RD
823
824 // get the last child of this item - this method doesn't use cookies
825 wxTreeItemId GetLastChild(const wxTreeItemId& item) const;
826
827 // get the next sibling of this item
828 wxTreeItemId GetNextSibling(const wxTreeItemId& item) const;
829
830 // get the previous sibling
831 wxTreeItemId GetPrevSibling(const wxTreeItemId& item) const;
832
833 // get first visible item
834 wxTreeItemId GetFirstVisibleItem() const;
835
836 // get the next visible item: item must be visible itself!
837 // see IsVisible() and wxTreeCtrl::GetFirstVisibleItem()
838 wxTreeItemId GetNextVisible(const wxTreeItemId& item) const;
839
840 // get the previous visible item: item must be visible itself!
841 wxTreeItemId GetPrevVisible(const wxTreeItemId& item) const;
842
843 // Only for internal use right now, but should probably be public
844 wxTreeItemId GetNext(const wxTreeItemId& item) const;
845
846
847 // add the root node to the tree
848 wxTreeItemId AddRoot(const wxString& text,
849 int image = -1, int selectedImage = -1,
850 wxPyTreeItemData *data = NULL);
851
852 // insert a new item in as the first child of the parent
853 wxTreeItemId PrependItem(const wxTreeItemId& parent,
854 const wxString& text,
855 int image = -1, int selectedImage = -1,
856 wxPyTreeItemData *data = NULL);
857
858 // insert a new item after a given one
859 wxTreeItemId InsertItem(const wxTreeItemId& parent,
860 const wxTreeItemId& idPrevious,
861 const wxString& text,
862 int image = -1, int selectedImage = -1,
863 wxPyTreeItemData *data = NULL);
864
865 // insert a new item before the one with the given index
1b8c7ba6
RD
866 %Rename(InsertItemBefore,
867 wxTreeItemId, InsertItem(const wxTreeItemId& parent,
1fded56b
RD
868 size_t index,
869 const wxString& text,
870 int image = -1, int selectedImage = -1,
1b8c7ba6 871 wxPyTreeItemData *data = NULL));
1fded56b
RD
872
873 // insert a new item in as the last child of the parent
874 wxTreeItemId AppendItem(const wxTreeItemId& parent,
875 const wxString& text,
876 int image = -1, int selectedImage = -1,
877 wxPyTreeItemData *data = NULL);
878
879 // delete this item and associated data if any
880 void Delete(const wxTreeItemId& item);
881
882 // delete all children (but don't delete the item itself)
883 // NB: this won't send wxEVT_COMMAND_TREE_ITEM_DELETED events
884 void DeleteChildren(const wxTreeItemId& item);
885
886 // delete all items from the tree
887 // NB: this won't send wxEVT_COMMAND_TREE_ITEM_DELETED events
888 void DeleteAllItems();
889
890 // expand this item
891 void Expand(const wxTreeItemId& item);
892
893 // expand this item and all subitems recursively
894 void ExpandAll(const wxTreeItemId& item);
895
896 // collapse the item without removing its children
897 void Collapse(const wxTreeItemId& item);
898
899 // collapse the item and remove all children
900 void CollapseAndReset(const wxTreeItemId& item);
901
902 // toggles the current state
903 void Toggle(const wxTreeItemId& item);
904
905 // remove the selection from currently selected item (if any)
906 void Unselect();
907 void UnselectAll();
908
909 // select this item
a72f4631
RD
910 void SelectItem(const wxTreeItemId& item, bool unselect_others=true,
911 bool extended_select=false);
1fded56b 912
a72f4631 913 void SelectAll(bool extended_select=false);
28eab81f 914
1fded56b
RD
915 // make sure this item is visible (expanding the parent item and/or
916 // scrolling to this item if necessary)
917 void EnsureVisible(const wxTreeItemId& item);
918
919 // scroll to this item (but don't expand its parent)
920 void ScrollTo(const wxTreeItemId& item);
921
922 // Returns wxTreeItemId, flags, and column
923 wxTreeItemId HitTest(const wxPoint& point, int& OUTPUT, int& OUTPUT);
924
d14a1e28 925 %extend {
1fded56b 926 // get the bounding rectangle of the item (or of its label only)
a72f4631 927 PyObject* GetBoundingRect(const wxTreeItemId& item, bool textOnly = false) {
1fded56b
RD
928 wxRect rect;
929 if (self->GetBoundingRect(item, rect, textOnly)) {
da32eb53 930 bool blocked = wxPyBeginBlockThreads();
1fded56b
RD
931 wxRect* r = new wxRect(rect);
932 PyObject* val = wxPyConstructObject((void*)r, wxT("wxRect"), 1);
da32eb53 933 wxPyEndBlockThreads(blocked);
1fded56b
RD
934 return val;
935 }
936 else {
d14a1e28 937 RETURN_NONE();
1fded56b
RD
938 }
939 }
940 }
941
942
943 // Start editing the item label: this (temporarily) replaces the item
944 // with a one line edit control. The item will be selected if it hadn't
945 // been before.
946 void EditLabel( const wxTreeItemId& item );
947 void Edit( const wxTreeItemId& item );
948
949 // sort the children of this item using OnCompareItems
950 void SortChildren(const wxTreeItemId& item);
951
28eab81f
RD
952 // searching
953 wxTreeItemId FindItem (const wxTreeItemId& item, const wxString& str, int flags = 0);
1fded56b
RD
954
955 wxWindow* GetHeaderWindow() const;
6d450e1a 956 wxScrolledWindow* GetMainWindow() const;
1fded56b 957
1fded56b
RD
958};
959
960
961
962
950e7faf 963//----------------------------------------------------------------------
ebf4302c
RD
964//----------------------------------------------------------------------
965
966%init %{
967
611dc22c 968 wxPyPtrTypeMap_Add("wxTreeCompanionWindow", "wxPyTreeCompanionWindow");
1fded56b 969 wxPyPtrTypeMap_Add("wxTreeListCtrl", "wxPyTreeListCtrl");
ebf4302c
RD
970%}
971
972
ebf4302c
RD
973%pragma(python) include="_gizmoextras.py";
974
975//----------------------------------------------------------------------
976//----------------------------------------------------------------------
977