]>
Commit | Line | Data |
---|---|---|
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> | |
9416aa89 | 22 | #include <wx/imaglist.h> |
68320e40 | 23 | #include <wx/dirctrl.h> |
7bf85405 RD |
24 | %} |
25 | ||
26 | //---------------------------------------------------------------------- | |
27 | ||
28 | %include typemaps.i | |
29 | %include my_typemaps.i | |
30 | ||
31 | // Import some definitions of other classes, etc. | |
32 | %import _defs.i | |
33 | %import misc.i | |
34 | %import windows.i | |
35 | %import gdi.i | |
36 | %import events.i | |
37 | %import controls.i | |
38 | ||
b8b8dda7 | 39 | %pragma(python) code = "import wx" |
9c039d08 | 40 | |
c7e7022c RD |
41 | |
42 | //---------------------------------------------------------------------- | |
137b5242 RD |
43 | %{ |
44 | // Put some wx default wxChar* values into wxStrings. | |
45 | const wxChar* wxListCtrlNameStr = _T("wxListCtrl"); | |
46 | DECLARE_DEF_STRING(ListCtrlNameStr); | |
47 | ||
9a74fcaf | 48 | const wxChar* wx_TreeCtrlNameStr = _T("wxTreeCtrl"); |
137b5242 RD |
49 | DECLARE_DEF_STRING(_TreeCtrlNameStr); |
50 | DECLARE_DEF_STRING(DirDialogDefaultFolderStr); | |
51 | ||
52 | static const wxString wxPyEmptyString(wxT("")); | |
53 | %} | |
54 | ||
0815db26 RD |
55 | |
56 | %{ | |
57 | static const long longzero = 0; | |
58 | %} | |
59 | ||
7bf85405 RD |
60 | //---------------------------------------------------------------------- |
61 | ||
c7e7022c RD |
62 | enum { |
63 | /* List control event types */ | |
64 | wxEVT_COMMAND_LIST_BEGIN_DRAG, | |
65 | wxEVT_COMMAND_LIST_BEGIN_RDRAG, | |
66 | wxEVT_COMMAND_LIST_BEGIN_LABEL_EDIT, | |
67 | wxEVT_COMMAND_LIST_END_LABEL_EDIT, | |
68 | wxEVT_COMMAND_LIST_DELETE_ITEM, | |
69 | wxEVT_COMMAND_LIST_DELETE_ALL_ITEMS, | |
70 | wxEVT_COMMAND_LIST_GET_INFO, | |
71 | wxEVT_COMMAND_LIST_SET_INFO, | |
72 | wxEVT_COMMAND_LIST_ITEM_SELECTED, | |
73 | wxEVT_COMMAND_LIST_ITEM_DESELECTED, | |
74 | wxEVT_COMMAND_LIST_KEY_DOWN, | |
75 | wxEVT_COMMAND_LIST_INSERT_ITEM, | |
76 | wxEVT_COMMAND_LIST_COL_CLICK, | |
77 | wxEVT_COMMAND_LIST_ITEM_RIGHT_CLICK, | |
78 | wxEVT_COMMAND_LIST_ITEM_MIDDLE_CLICK, | |
79 | wxEVT_COMMAND_LIST_ITEM_ACTIVATED, | |
80 | wxEVT_COMMAND_LIST_CACHE_HINT, | |
6d19860f RD |
81 | wxEVT_COMMAND_LIST_COL_RIGHT_CLICK, |
82 | wxEVT_COMMAND_LIST_COL_BEGIN_DRAG, | |
83 | wxEVT_COMMAND_LIST_COL_DRAGGING, | |
84 | wxEVT_COMMAND_LIST_COL_END_DRAG, | |
d8200036 | 85 | wxEVT_COMMAND_LIST_ITEM_FOCUSED, |
c7e7022c RD |
86 | }; |
87 | ||
88 | ||
89 | %pragma(python) code = " | |
90 | def EVT_LIST_BEGIN_DRAG(win, id, func): | |
91 | win.Connect(id, -1, wxEVT_COMMAND_LIST_BEGIN_DRAG, func) | |
92 | ||
93 | def EVT_LIST_BEGIN_RDRAG(win, id, func): | |
94 | win.Connect(id, -1, wxEVT_COMMAND_LIST_BEGIN_RDRAG, func) | |
95 | ||
96 | def EVT_LIST_BEGIN_LABEL_EDIT(win, id, func): | |
97 | win.Connect(id, -1, wxEVT_COMMAND_LIST_BEGIN_LABEL_EDIT, func) | |
98 | ||
99 | def EVT_LIST_END_LABEL_EDIT(win, id, func): | |
100 | win.Connect(id, -1, wxEVT_COMMAND_LIST_END_LABEL_EDIT, func) | |
101 | ||
102 | def EVT_LIST_DELETE_ITEM(win, id, func): | |
103 | win.Connect(id, -1, wxEVT_COMMAND_LIST_DELETE_ITEM, func) | |
104 | ||
105 | def EVT_LIST_DELETE_ALL_ITEMS(win, id, func): | |
106 | win.Connect(id, -1, wxEVT_COMMAND_LIST_DELETE_ALL_ITEMS, func) | |
107 | ||
108 | def EVT_LIST_GET_INFO(win, id, func): | |
109 | win.Connect(id, -1, wxEVT_COMMAND_LIST_GET_INFO, func) | |
110 | ||
111 | def EVT_LIST_SET_INFO(win, id, func): | |
112 | win.Connect(id, -1, wxEVT_COMMAND_LIST_SET_INFO, func) | |
113 | ||
114 | def EVT_LIST_ITEM_SELECTED(win, id, func): | |
115 | win.Connect(id, -1, wxEVT_COMMAND_LIST_ITEM_SELECTED, func) | |
116 | ||
117 | def EVT_LIST_ITEM_DESELECTED(win, id, func): | |
118 | win.Connect(id, -1, wxEVT_COMMAND_LIST_ITEM_DESELECTED, func) | |
119 | ||
120 | def EVT_LIST_KEY_DOWN(win, id, func): | |
121 | win.Connect(id, -1, wxEVT_COMMAND_LIST_KEY_DOWN, func) | |
122 | ||
123 | def EVT_LIST_INSERT_ITEM(win, id, func): | |
124 | win.Connect(id, -1, wxEVT_COMMAND_LIST_INSERT_ITEM, func) | |
125 | ||
126 | def EVT_LIST_COL_CLICK(win, id, func): | |
127 | win.Connect(id, -1, wxEVT_COMMAND_LIST_COL_CLICK, func) | |
128 | ||
6d19860f RD |
129 | def EVT_LIST_COL_RIGHT_CLICK(win, id, func): |
130 | win.Connect(id, -1, wxEVT_COMMAND_LIST_COL_RIGHT_CLICK, func) | |
131 | ||
132 | def EVT_LIST_COL_BEGIN_DRAG(win, id, func): | |
133 | win.Connect(id, -1, wxEVT_COMMAND_LIST_COL_BEGIN_DRAG, func) | |
134 | ||
135 | def EVT_LIST_COL_DRAGGING(win, id, func): | |
136 | win.Connect(id, -1, wxEVT_COMMAND_LIST_COL_DRAGGING, func) | |
137 | ||
138 | def EVT_LIST_COL_END_DRAG(win, id, func): | |
139 | win.Connect(id, -1, wxEVT_COMMAND_LIST_COL_END_DRAG, func) | |
140 | ||
c7e7022c RD |
141 | def EVT_LIST_ITEM_RIGHT_CLICK(win, id, func): |
142 | win.Connect(id, -1, wxEVT_COMMAND_LIST_ITEM_RIGHT_CLICK, func) | |
143 | ||
144 | def EVT_LIST_ITEM_MIDDLE_CLICK(win, id, func): | |
145 | win.Connect(id, -1, wxEVT_COMMAND_LIST_ITEM_MIDDLE_CLICK, func) | |
146 | ||
147 | def EVT_LIST_ITEM_ACTIVATED(win, id, func): | |
148 | win.Connect(id, -1, wxEVT_COMMAND_LIST_ITEM_ACTIVATED, func) | |
149 | ||
150 | def EVT_LIST_CACHE_HINT(win, id, func): | |
151 | win.Connect(id, -1, wxEVT_COMMAND_LIST_CACHE_HINT, func) | |
d8200036 RD |
152 | |
153 | def EVT_LIST_ITEM_FOCUSED(win, id, func): | |
154 | win.Connect(id, -1, wxEVT_COMMAND_LIST_ITEM_FOCUSED, func) | |
c7e7022c RD |
155 | " |
156 | ||
7bf85405 | 157 | |
af309447 | 158 | enum { |
c7e7022c RD |
159 | /* Style flags */ |
160 | wxLC_VRULES, | |
161 | wxLC_HRULES, | |
162 | ||
163 | wxLC_ICON, | |
164 | wxLC_SMALL_ICON, | |
165 | wxLC_LIST, | |
166 | wxLC_REPORT, | |
167 | ||
168 | wxLC_ALIGN_TOP, | |
169 | wxLC_ALIGN_LEFT, | |
170 | wxLC_AUTOARRANGE, | |
171 | wxLC_VIRTUAL, | |
172 | wxLC_EDIT_LABELS, | |
173 | wxLC_NO_HEADER, | |
174 | wxLC_NO_SORT_HEADER, | |
175 | wxLC_SINGLE_SEL, | |
176 | wxLC_SORT_ASCENDING, | |
177 | wxLC_SORT_DESCENDING, | |
178 | ||
179 | wxLC_MASK_TYPE, | |
180 | wxLC_MASK_ALIGN, | |
181 | wxLC_MASK_SORT, | |
182 | ||
6d19860f | 183 | wxLC_USER_TEXT, |
c7e7022c RD |
184 | }; |
185 | ||
186 | ||
187 | enum { | |
188 | // Mask flags | |
189 | wxLIST_MASK_STATE, | |
af309447 RD |
190 | wxLIST_MASK_TEXT, |
191 | wxLIST_MASK_IMAGE, | |
192 | wxLIST_MASK_DATA, | |
c7e7022c | 193 | wxLIST_SET_ITEM, |
af309447 RD |
194 | wxLIST_MASK_WIDTH, |
195 | wxLIST_MASK_FORMAT, | |
c7e7022c RD |
196 | |
197 | // State flags | |
af309447 RD |
198 | wxLIST_STATE_DONTCARE, |
199 | wxLIST_STATE_DROPHILITED, | |
200 | wxLIST_STATE_FOCUSED, | |
201 | wxLIST_STATE_SELECTED, | |
202 | wxLIST_STATE_CUT, | |
c7e7022c RD |
203 | |
204 | // Hit test flags | |
af309447 RD |
205 | wxLIST_HITTEST_ABOVE, |
206 | wxLIST_HITTEST_BELOW, | |
207 | wxLIST_HITTEST_NOWHERE, | |
208 | wxLIST_HITTEST_ONITEMICON, | |
209 | wxLIST_HITTEST_ONITEMLABEL, | |
210 | wxLIST_HITTEST_ONITEMRIGHT, | |
211 | wxLIST_HITTEST_ONITEMSTATEICON, | |
212 | wxLIST_HITTEST_TOLEFT, | |
213 | wxLIST_HITTEST_TORIGHT, | |
214 | wxLIST_HITTEST_ONITEM, | |
c7e7022c RD |
215 | |
216 | // Flags for GetNextItem | |
af309447 RD |
217 | wxLIST_NEXT_ABOVE, |
218 | wxLIST_NEXT_ALL, | |
219 | wxLIST_NEXT_BELOW, | |
220 | wxLIST_NEXT_LEFT, | |
221 | wxLIST_NEXT_RIGHT, | |
c7e7022c RD |
222 | |
223 | // Alignment flags | |
af309447 RD |
224 | wxLIST_ALIGN_DEFAULT, |
225 | wxLIST_ALIGN_LEFT, | |
226 | wxLIST_ALIGN_TOP, | |
227 | wxLIST_ALIGN_SNAP_TO_GRID, | |
c7e7022c RD |
228 | |
229 | // Autosize values for SetColumnWidth | |
230 | wxLIST_AUTOSIZE = -1, | |
231 | wxLIST_AUTOSIZE_USEHEADER = -2, | |
232 | ||
233 | // Flag values for GetItemRect | |
af309447 RD |
234 | wxLIST_RECT_BOUNDS, |
235 | wxLIST_RECT_ICON, | |
236 | wxLIST_RECT_LABEL, | |
c7e7022c RD |
237 | |
238 | // Flag values for FindItem (MSW only) | |
af309447 RD |
239 | wxLIST_FIND_UP, |
240 | wxLIST_FIND_DOWN, | |
241 | wxLIST_FIND_LEFT, | |
242 | wxLIST_FIND_RIGHT, | |
c7e7022c RD |
243 | |
244 | ||
af309447 RD |
245 | }; |
246 | ||
247 | ||
c7e7022c | 248 | |
f6bcfd97 BP |
249 | enum wxListColumnFormat |
250 | { | |
251 | wxLIST_FORMAT_LEFT, | |
252 | wxLIST_FORMAT_RIGHT, | |
253 | wxLIST_FORMAT_CENTRE, | |
254 | wxLIST_FORMAT_CENTER = wxLIST_FORMAT_CENTRE | |
255 | }; | |
256 | ||
257 | ||
1b62f00d RD |
258 | |
259 | ||
f6bcfd97 BP |
260 | class wxListItemAttr |
261 | { | |
262 | public: | |
263 | // ctors | |
c7e7022c RD |
264 | //wxListItemAttr(); |
265 | wxListItemAttr(const wxColour& colText = wxNullColour, | |
266 | const wxColour& colBack = wxNullColour, | |
267 | const wxFont& font = wxNullFont); | |
268 | ||
f6bcfd97 BP |
269 | |
270 | // setters | |
271 | void SetTextColour(const wxColour& colText); | |
272 | void SetBackgroundColour(const wxColour& colBack); | |
273 | void SetFont(const wxFont& font); | |
274 | ||
275 | // accessors | |
276 | bool HasTextColour(); | |
277 | bool HasBackgroundColour(); | |
278 | bool HasFont(); | |
279 | ||
c5943253 RD |
280 | wxColour GetTextColour(); |
281 | wxColour GetBackgroundColour(); | |
282 | wxFont GetFont(); | |
f6bcfd97 BP |
283 | }; |
284 | ||
285 | ||
9416aa89 | 286 | class wxListItem : public wxObject { |
7bf85405 | 287 | public: |
f6bcfd97 BP |
288 | wxListItem(); |
289 | ~wxListItem(); | |
290 | ||
291 | // resetting | |
292 | void Clear(); | |
293 | void ClearAttributes(); | |
294 | ||
295 | // setters | |
296 | void SetMask(long mask); | |
297 | void SetId(long id); | |
298 | void SetColumn(int col); | |
299 | void SetState(long state); | |
300 | void SetStateMask(long stateMask); | |
301 | void SetText(const wxString& text); | |
302 | void SetImage(int image); | |
303 | void SetData(long data); | |
304 | ||
305 | void SetWidth(int width); | |
306 | void SetAlign(wxListColumnFormat align); | |
307 | ||
308 | void SetTextColour(const wxColour& colText); | |
309 | void SetBackgroundColour(const wxColour& colBack); | |
310 | void SetFont(const wxFont& font); | |
311 | ||
312 | // accessors | |
313 | long GetMask(); | |
314 | long GetId(); | |
315 | int GetColumn(); | |
316 | long GetState(); | |
317 | const wxString& GetText(); | |
318 | int GetImage(); | |
319 | long GetData(); | |
320 | ||
321 | int GetWidth(); | |
322 | wxListColumnFormat GetAlign(); | |
323 | ||
324 | wxListItemAttr *GetAttributes(); | |
325 | bool HasAttributes(); | |
326 | ||
327 | wxColour GetTextColour() const; | |
328 | wxColour GetBackgroundColour() const; | |
329 | wxFont GetFont() const; | |
330 | ||
331 | // these members are public for compatibility | |
7bf85405 RD |
332 | long m_mask; // Indicates what fields are valid |
333 | long m_itemId; // The zero-based item position | |
334 | int m_col; // Zero-based column, if in report mode | |
335 | long m_state; // The state of the item | |
f6bcfd97 | 336 | long m_stateMask;// Which flags of m_state are valid (uses same flags) |
7bf85405 RD |
337 | wxString m_text; // The label/header text |
338 | int m_image; // The zero-based index into an image list | |
339 | long m_data; // App-defined data | |
7bf85405 RD |
340 | |
341 | // For columns only | |
342 | int m_format; // left, right, centre | |
343 | int m_width; // width of column | |
344 | ||
7bf85405 RD |
345 | }; |
346 | ||
f6bcfd97 | 347 | |
c368d904 | 348 | class wxListEvent: public wxNotifyEvent { |
7bf85405 | 349 | public: |
6d19860f RD |
350 | wxListEvent(wxEventType commandType = wxEVT_NULL, int id = 0); |
351 | ||
b7fc54be | 352 | %readonly |
7bf85405 | 353 | int m_code; |
ebf4302c | 354 | long m_oldItemIndex; |
7bf85405 | 355 | long m_itemIndex; |
7bf85405 | 356 | int m_col; |
7bf85405 RD |
357 | wxPoint m_pointDrag; |
358 | wxListItem m_item; | |
b7fc54be | 359 | %readwrite |
7bf85405 | 360 | |
f6bcfd97 BP |
361 | int GetCode(); |
362 | long GetIndex(); | |
f6bcfd97 | 363 | int GetColumn(); |
f6bcfd97 BP |
364 | wxPoint GetPoint(); |
365 | const wxString& GetLabel(); | |
366 | const wxString& GetText(); | |
367 | int GetImage(); | |
368 | long GetData(); | |
369 | long GetMask(); | |
370 | const wxListItem& GetItem(); | |
6d19860f RD |
371 | |
372 | long GetCacheFrom(); | |
373 | long GetCacheTo(); | |
f6bcfd97 | 374 | }; |
7bf85405 RD |
375 | |
376 | ||
09f3d4e6 | 377 | %{ // C++ Version of a Python aware class |
c7e7022c RD |
378 | class wxPyListCtrl : public wxListCtrl { |
379 | DECLARE_ABSTRACT_CLASS(wxPyListCtrl); | |
7bf85405 | 380 | public: |
09f3d4e6 | 381 | wxPyListCtrl() : wxListCtrl() {} |
c7e7022c RD |
382 | wxPyListCtrl(wxWindow* parent, wxWindowID id, |
383 | const wxPoint& pos, | |
384 | const wxSize& size, | |
385 | long style, | |
386 | const wxValidator& validator, | |
137b5242 | 387 | const wxString& name) : |
c7e7022c RD |
388 | wxListCtrl(parent, id, pos, size, style, validator, name) {} |
389 | ||
09f3d4e6 RD |
390 | bool Create(wxWindow* parent, wxWindowID id, |
391 | const wxPoint& pos, | |
392 | const wxSize& size, | |
393 | long style, | |
394 | const wxValidator& validator, | |
137b5242 | 395 | const wxString& name) { |
09f3d4e6 RD |
396 | return wxListCtrl::Create(parent, id, pos, size, style, validator, name); |
397 | } | |
398 | ||
c7e7022c RD |
399 | DEC_PYCALLBACK_STRING_LONGLONG(OnGetItemText); |
400 | DEC_PYCALLBACK_INT_LONG(OnGetItemImage); | |
401 | DEC_PYCALLBACK_LISTATTR_LONG(OnGetItemAttr); | |
402 | ||
403 | PYPRIVATE; | |
404 | }; | |
405 | ||
406 | IMPLEMENT_ABSTRACT_CLASS(wxPyListCtrl, wxListCtrl); | |
7bf85405 | 407 | |
c7e7022c RD |
408 | IMP_PYCALLBACK_STRING_LONGLONG(wxPyListCtrl, wxListCtrl, OnGetItemText); |
409 | IMP_PYCALLBACK_INT_LONG(wxPyListCtrl, wxListCtrl, OnGetItemImage); | |
410 | IMP_PYCALLBACK_LISTATTR_LONG(wxPyListCtrl, wxListCtrl, OnGetItemAttr); | |
411 | %} | |
412 | ||
413 | ||
cdf14688 | 414 | |
c7e7022c RD |
415 | %name(wxListCtrl)class wxPyListCtrl : public wxControl { |
416 | public: | |
417 | wxPyListCtrl(wxWindow* parent, wxWindowID id = -1, | |
418 | const wxPoint& pos = wxDefaultPosition, | |
419 | const wxSize& size = wxDefaultSize, | |
420 | long style = wxLC_ICON, | |
421 | const wxValidator& validator = wxDefaultValidator, | |
137b5242 | 422 | const wxString& name = wxPyListCtrlNameStr); |
09f3d4e6 RD |
423 | %name(wxPreListCtrl)wxPyListCtrl(); |
424 | ||
425 | bool Create(wxWindow* parent, wxWindowID id = -1, | |
426 | const wxPoint& pos = wxDefaultPosition, | |
427 | const wxSize& size = wxDefaultSize, | |
428 | long style = wxLC_ICON, | |
429 | const wxValidator& validator = wxDefaultValidator, | |
137b5242 | 430 | const wxString& name = wxPyListCtrlNameStr); |
c7e7022c | 431 | |
0122b7e3 RD |
432 | void _setCallbackInfo(PyObject* self, PyObject* _class); |
433 | %pragma(python) addtomethod = "__init__:self._setCallbackInfo(self, wxListCtrl)" | |
9c039d08 | 434 | |
0122b7e3 | 435 | %pragma(python) addtomethod = "__init__:self._setOORInfo(self)" |
17c0e08c | 436 | %pragma(python) addtomethod = "wxPreListCtrl:val._setOORInfo(val)" |
7bf85405 | 437 | |
c7e7022c RD |
438 | // Set the control colours |
439 | bool SetForegroundColour(const wxColour& col); | |
440 | bool SetBackgroundColour(const wxColour& col); | |
441 | ||
442 | // Gets information about this column | |
14afa2cb RD |
443 | // bool GetColumn(int col, wxListItem& item) const; |
444 | %addmethods { | |
445 | %new wxListItem* GetColumn(int col) { | |
446 | wxListItem item; | |
447 | if (self->GetColumn(col, item)) | |
448 | return new wxListItem(item); | |
449 | else | |
450 | return NULL; | |
451 | } | |
452 | } // The OOR typemaps don't know what to do with the %new, so fix it up. | |
453 | %pragma(python) addtoclass = " | |
454 | def GetItem(self, *_args, **_kwargs): | |
455 | val = apply(controls2c.wxListCtrl_GetColumn,(self,) + _args, _kwargs) | |
456 | if val is not None: val.thisown = 1 | |
457 | return val | |
458 | " | |
c7e7022c RD |
459 | |
460 | // Sets information about this column | |
461 | bool SetColumn(int col, wxListItem& item) ; | |
462 | ||
463 | // Gets the column width | |
464 | int GetColumnWidth(int col) const; | |
465 | ||
466 | // Sets the column width | |
467 | bool SetColumnWidth(int col, int width) ; | |
468 | ||
469 | // Gets the number of items that can fit vertically in the | |
470 | // visible area of the list control (list or report view) | |
471 | // or the total number of items in the list control (icon | |
472 | // or small icon view) | |
473 | int GetCountPerPage() const; | |
474 | ||
cd096152 | 475 | #ifdef __WXMSW__ |
c7e7022c RD |
476 | // Gets the edit control for editing labels. |
477 | wxTextCtrl* GetEditControl() const; | |
cd096152 | 478 | #endif |
c7e7022c RD |
479 | |
480 | //bool GetItem(wxListItem& info) const ; | |
7bf85405 | 481 | %addmethods { |
c7e7022c | 482 | // Gets information about the item |
e166644c | 483 | %new wxListItem* GetItem(long itemId, int col=0) { |
7bf85405 | 484 | wxListItem* info = new wxListItem; |
0699c864 | 485 | info->m_itemId = itemId; |
e166644c | 486 | info->m_col = col; |
f17fee68 | 487 | info->m_mask = 0xFFFF; |
7bf85405 RD |
488 | self->GetItem(*info); |
489 | return info; | |
490 | } | |
5597b61e RD |
491 | } // The OOR typemaps don't know what to do with the %new, so fix it up. |
492 | %pragma(python) addtoclass = " | |
493 | def GetItem(self, *_args, **_kwargs): | |
494 | val = apply(controls2c.wxListCtrl_GetItem,(self,) + _args, _kwargs) | |
495 | val.thisown = 1 | |
496 | return val | |
497 | " | |
498 | ||
c7e7022c RD |
499 | |
500 | // Sets information about the item | |
501 | bool SetItem(wxListItem& info) ; | |
502 | ||
503 | // Sets a string field at a particular column | |
504 | %name(SetStringItem)long SetItem(long index, int col, const wxString& label, int imageId = -1); | |
505 | ||
506 | // Gets the item state | |
507 | int GetItemState(long item, long stateMask) const ; | |
508 | ||
509 | // Sets the item state | |
510 | bool SetItemState(long item, long state, long stateMask) ; | |
511 | ||
512 | // Sets the item image | |
513 | bool SetItemImage(long item, int image, int selImage) ; | |
514 | ||
515 | // Gets the item text | |
516 | wxString GetItemText(long item) const ; | |
517 | ||
518 | // Sets the item text | |
519 | void SetItemText(long item, const wxString& str) ; | |
520 | ||
521 | // Gets the item data | |
522 | long GetItemData(long item) const ; | |
523 | ||
524 | // Sets the item data | |
525 | bool SetItemData(long item, long data) ; | |
526 | ||
527 | ||
528 | //bool GetItemRect(long item, wxRect& rect, int code = wxLIST_RECT_BOUNDS) const ; | |
529 | //bool GetItemPosition(long item, wxPoint& pos) const ; | |
00b6c4e3 RD |
530 | |
531 | // Gets the item position | |
5597b61e | 532 | %addmethods { |
7bf85405 RD |
533 | %new wxPoint* GetItemPosition(long item) { |
534 | wxPoint* pos = new wxPoint; | |
535 | self->GetItemPosition(item, *pos); | |
536 | return pos; | |
537 | } | |
c7e7022c | 538 | // Gets the item rectangle |
7bf85405 RD |
539 | %new wxRect* GetItemRect(long item, int code = wxLIST_RECT_BOUNDS) { |
540 | wxRect* rect= new wxRect; | |
541 | self->GetItemRect(item, *rect, code); | |
542 | return rect; | |
543 | } | |
544 | } | |
545 | ||
c7e7022c RD |
546 | |
547 | // Sets the item position | |
548 | bool SetItemPosition(long item, const wxPoint& pos) ; | |
549 | ||
550 | // Gets the number of items in the list control | |
551 | int GetItemCount() const; | |
552 | ||
553 | // Gets the number of columns in the list control | |
9d37f964 | 554 | int GetColumnCount() const; |
c7e7022c RD |
555 | |
556 | // Retrieves the spacing between icons in pixels. | |
557 | // If small is TRUE, gets the spacing for the small icon | |
558 | // view, otherwise the large icon view. | |
559 | int GetItemSpacing(bool isSmall) const; | |
560 | ||
561 | // Gets the number of selected items in the list control | |
562 | int GetSelectedItemCount() const; | |
563 | ||
564 | // Gets the text colour of the listview | |
565 | wxColour GetTextColour() const; | |
566 | ||
567 | // Sets the text colour of the listview | |
4f22cf8d | 568 | void SetTextColour(const wxColour& col); |
c7e7022c RD |
569 | |
570 | // Gets the index of the topmost visible item when in | |
571 | // list or report view | |
572 | long GetTopItem() const ; | |
573 | ||
574 | // Add or remove a single window style | |
575 | void SetSingleStyle(long style, bool add = TRUE) ; | |
576 | ||
577 | // Set the whole window style | |
578 | void SetWindowStyleFlag(long style) ; | |
579 | ||
580 | // Searches for an item, starting from 'item'. | |
581 | // item can be -1 to find the first item that matches the | |
582 | // specified flags. | |
583 | // Returns the item or -1 if unsuccessful. | |
584 | long GetNextItem(long item, int geometry = wxLIST_NEXT_ALL, int state = wxLIST_STATE_DONTCARE) const ; | |
585 | ||
586 | // Gets one of the three image lists | |
587 | wxImageList *GetImageList(int which) const ; | |
588 | ||
589 | // Sets the image list | |
590 | void SetImageList(wxImageList *imageList, int which) ; | |
591 | void AssignImageList(wxImageList *imageList, int which) ; | |
592 | %pragma(python) addtomethod = "AssignImageList:_args[0].thisown = 0" | |
593 | ||
594 | // returns true if it is a virtual list control | |
595 | bool IsVirtual() const; | |
596 | ||
597 | // refresh items selectively (only useful for virtual list controls) | |
598 | void RefreshItem(long item); | |
599 | void RefreshItems(long itemFrom, long itemTo); | |
600 | ||
c7e7022c RD |
601 | // Arranges the items |
602 | bool Arrange(int flag = wxLIST_ALIGN_DEFAULT); | |
603 | ||
604 | // Deletes an item | |
605 | bool DeleteItem(long item); | |
606 | ||
607 | // Deletes all items | |
608 | bool DeleteAllItems() ; | |
609 | ||
610 | // Deletes a column | |
611 | bool DeleteColumn(int col); | |
612 | ||
613 | // Deletes all columns | |
614 | bool DeleteAllColumns(); | |
615 | ||
616 | // Clears items, and columns if there are any. | |
617 | void ClearAll(); | |
618 | ||
cd096152 | 619 | #ifdef __WXMSW__ |
c7e7022c RD |
620 | // Edit the label |
621 | wxTextCtrl* EditLabel(long item /*, wxClassInfo* textControlClass = CLASSINFO(wxTextCtrl)*/); | |
622 | ||
623 | // End label editing, optionally cancelling the edit | |
624 | bool EndEditLabel(bool cancel); | |
cd096152 | 625 | #endif |
c7e7022c RD |
626 | |
627 | // Ensures this item is visible | |
628 | bool EnsureVisible(long item) ; | |
629 | ||
630 | // Find an item whose label matches this string, starting from the item after 'start' | |
631 | // or the beginning if 'start' is -1. | |
632 | long FindItem(long start, const wxString& str, bool partial = FALSE); | |
633 | ||
634 | // Find an item whose data matches this data, starting from the item after 'start' | |
635 | // or the beginning if 'start' is -1. | |
636 | %name(FindItemData)long FindItem(long start, long data); | |
637 | ||
638 | // Find an item nearest this position in the specified direction, starting from | |
639 | // the item after 'start' or the beginning if 'start' is -1. | |
640 | %name(FindItemAtPos)long FindItem(long start, const wxPoint& pt, int direction); | |
641 | ||
642 | // Determines which item (if any) is at the specified point, | |
643 | // giving details in the second return value (see wxLIST_HITTEST_... flags above) | |
7bf85405 | 644 | long HitTest(const wxPoint& point, int& OUTPUT); |
c7e7022c RD |
645 | |
646 | // Inserts an item, returning the index of the new item if successful, | |
647 | // -1 otherwise. | |
648 | long InsertItem(wxListItem& info); | |
649 | ||
650 | // Insert a string item | |
651 | %name(InsertStringItem)long InsertItem(long index, const wxString& label); | |
652 | ||
653 | // Insert an image item | |
654 | %name(InsertImageItem)long InsertItem(long index, int imageIndex); | |
655 | ||
656 | // Insert an image/string item | |
657 | %name(InsertImageStringItem)long InsertItem(long index, const wxString& label, int imageIndex); | |
658 | ||
659 | // For list view mode (only), inserts a column. | |
c368d904 | 660 | %name(InsertColumnInfo)long InsertColumn(long col, wxListItem& info); |
c7e7022c RD |
661 | |
662 | long InsertColumn(long col, | |
663 | const wxString& heading, | |
7bf85405 RD |
664 | int format = wxLIST_FORMAT_LEFT, |
665 | int width = -1); | |
666 | ||
c7e7022c RD |
667 | // set the number of items in a virtual list control |
668 | void SetItemCount(long count); | |
7bf85405 | 669 | |
c7e7022c RD |
670 | // Scrolls the list control. If in icon, small icon or report view mode, |
671 | // x specifies the number of pixels to scroll. If in list view mode, x | |
672 | // specifies the number of columns to scroll. | |
673 | // If in icon, small icon or list view mode, y specifies the number of pixels | |
674 | // to scroll. If in report view mode, y specifies the number of lines to scroll. | |
7bf85405 | 675 | bool ScrollList(int dx, int dy); |
dcd38683 | 676 | |
3bd1e033 RD |
677 | void SetItemTextColour( long item, const wxColour& col); |
678 | wxColour GetItemTextColour( long item ) const; | |
679 | void SetItemBackgroundColour( long item, const wxColour &col); | |
680 | wxColour GetItemBackgroundColour( long item ) const; | |
681 | ||
c7e7022c | 682 | |
6d19860f RD |
683 | %pragma(python) addtoclass = " |
684 | # Some helpers... | |
685 | ||
43097598 | 686 | def Select(self, idx, on=1): |
6d19860f RD |
687 | '''[de]select an item''' |
688 | if on: state = wxLIST_STATE_SELECTED | |
689 | else: state = 0 | |
690 | self.SetItemState(idx, state, wxLIST_STATE_SELECTED) | |
691 | ||
692 | def Focus(self, idx): | |
693 | '''Focus and show the given item''' | |
694 | self.SetItemState(idx, wxLIST_STATE_FOCUSED, wxLIST_STATE_FOCUSED) | |
695 | self.EnsureVisible(idx) | |
696 | ||
697 | def GetFocusedItem(self): | |
698 | '''get the currently focused item or -1 if none''' | |
699 | return self.GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_FOCUSED) | |
700 | ||
701 | def IsSelected(self, idx): | |
702 | '''return TRUE if the item is selected''' | |
703 | return self.GetItemState(idx, wxLIST_STATE_SELECTED) != 0 | |
704 | ||
705 | def SetColumnImage(self, col, image): | |
706 | item = wxListItem() | |
707 | item.SetMask(wxLIST_MASK_IMAGE) | |
708 | item.SetImage(image) | |
709 | self.SetColumn(col, item) | |
710 | ||
711 | def ClearColumnImage(self, col): | |
712 | self.SetColumnImage(col, -1) | |
44536514 RD |
713 | |
714 | def Append(self, entry): | |
715 | '''Append an item to the list control. The entry parameter should be a | |
716 | sequence with an item for each column''' | |
717 | if len(entry): | |
718 | pos = self.GetItemCount() | |
719 | self.InsertStringItem(pos, str(entry[0])) | |
720 | for i in range(1, len(entry)): | |
721 | self.SetStringItem(pos, i, str(entry[i])) | |
722 | return pos | |
6d19860f | 723 | " |
3bd1e033 RD |
724 | |
725 | ||
726 | // bool SortItems(wxListCtrlCompare fn, long data); | |
727 | %addmethods { | |
728 | // Sort items. | |
729 | // func is a function which takes 2 long arguments: item1, item2. | |
730 | // item1 is the long data associated with a first item (NOT the index). | |
731 | // item2 is the long data associated with a second item (NOT the index). | |
732 | // The return value is a negative number if the first item should precede the second | |
733 | // item, a positive number of the second item should precede the first, | |
734 | // or zero if the two items are equivalent. | |
735 | bool SortItems(PyObject* func) { | |
736 | if (!PyCallable_Check(func)) | |
737 | return FALSE; | |
738 | return self->SortItems(wxPyListCtrl_SortItems, (long)func); | |
739 | } | |
740 | } | |
7bf85405 RD |
741 | }; |
742 | ||
c7e7022c RD |
743 | |
744 | ||
6d19860f | 745 | %{ // Python aware sorting function for wxPyListCtrl |
f6bcfd97 | 746 | int wxCALLBACK wxPyListCtrl_SortItems(long item1, long item2, long funcPtr) { |
dcd38683 RD |
747 | int retval = 0; |
748 | PyObject* func = (PyObject*)funcPtr; | |
4268f798 | 749 | wxPyBeginBlockThreads(); |
7bf85405 | 750 | |
dcd38683 RD |
751 | PyObject* args = Py_BuildValue("(ii)", item1, item2); |
752 | PyObject* result = PyEval_CallObject(func, args); | |
753 | Py_DECREF(args); | |
754 | if (result) { | |
755 | retval = PyInt_AsLong(result); | |
756 | Py_DECREF(result); | |
757 | } | |
758 | ||
4268f798 | 759 | wxPyEndBlockThreads(); |
dcd38683 RD |
760 | return retval; |
761 | } | |
762 | ||
763 | %} | |
7bf85405 | 764 | |
6d19860f RD |
765 | //---------------------------------------------------------------------- |
766 | ||
767 | class wxListView : public wxPyListCtrl | |
768 | { | |
769 | public: | |
770 | wxListView( wxWindow *parent, | |
771 | wxWindowID id = -1, | |
772 | const wxPoint& pos = wxDefaultPosition, | |
773 | const wxSize& size = wxDefaultSize, | |
774 | long style = wxLC_REPORT, | |
775 | const wxValidator& validator = wxDefaultValidator, | |
137b5242 | 776 | const wxString& name = wxPyListCtrlNameStr); |
6d19860f RD |
777 | %name(wxPreListView)wxListView(); |
778 | ||
779 | bool Create( wxWindow *parent, | |
780 | wxWindowID id = -1, | |
781 | const wxPoint& pos = wxDefaultPosition, | |
782 | const wxSize& size = wxDefaultSize, | |
783 | long style = wxLC_REPORT, | |
784 | const wxValidator& validator = wxDefaultValidator, | |
137b5242 | 785 | const wxString& name = wxPyListCtrlNameStr); |
6d19860f | 786 | |
0122b7e3 | 787 | %pragma(python) addtomethod = "__init__:self._setOORInfo(self)" |
17c0e08c | 788 | %pragma(python) addtomethod = "wxPreListView:val._setOORInfo(val)" |
6d19860f RD |
789 | |
790 | // [de]select an item | |
791 | void Select(long n, bool on = TRUE); | |
792 | ||
793 | // focus and show the given item | |
794 | void Focus(long index); | |
795 | ||
796 | // get the currently focused item or -1 if none | |
797 | long GetFocusedItem() const; | |
798 | ||
799 | // get first and subsequent selected items, return -1 when no more | |
800 | long GetNextSelected(long item) const; | |
801 | long GetFirstSelected() const; | |
802 | ||
803 | // return TRUE if the item is selected | |
804 | bool IsSelected(long index); | |
805 | ||
806 | void SetColumnImage(int col, int image); | |
807 | void ClearColumnImage(int col); | |
808 | }; | |
809 | ||
810 | ||
7bf85405 RD |
811 | //---------------------------------------------------------------------- |
812 | ||
00b6c4e3 RD |
813 | // wxTreeCtrl flags |
814 | enum { | |
815 | wxTR_NO_BUTTONS, | |
816 | wxTR_HAS_BUTTONS, | |
817 | wxTR_TWIST_BUTTONS, | |
818 | wxTR_NO_LINES, | |
819 | wxTR_MAC_BUTTONS, | |
b5a5d647 | 820 | wxTR_AQUA_BUTTONS, |
00b6c4e3 RD |
821 | |
822 | wxTR_SINGLE, | |
823 | wxTR_MULTIPLE, | |
824 | wxTR_EXTENDED, | |
b5a5d647 | 825 | wxTR_FULL_ROW_HIGHLIGHT, |
00b6c4e3 RD |
826 | |
827 | wxTR_EDIT_LABELS, | |
828 | wxTR_LINES_AT_ROOT, | |
829 | wxTR_HIDE_ROOT, | |
830 | wxTR_ROW_LINES, | |
831 | wxTR_HAS_VARIABLE_ROW_HEIGHT, | |
832 | ||
833 | wxTR_DEFAULT_STYLE, | |
834 | }; | |
835 | ||
694759cf RD |
836 | enum wxTreeItemIcon |
837 | { | |
838 | wxTreeItemIcon_Normal, // not selected, not expanded | |
839 | wxTreeItemIcon_Selected, // selected, not expanded | |
840 | wxTreeItemIcon_Expanded, // not selected, expanded | |
841 | wxTreeItemIcon_SelectedExpanded, // selected, expanded | |
842 | wxTreeItemIcon_Max | |
843 | }; | |
844 | ||
7bf85405 | 845 | |
164b735b RD |
846 | // constants for HitTest |
847 | enum { | |
848 | wxTREE_HITTEST_ABOVE, | |
849 | wxTREE_HITTEST_BELOW, | |
850 | wxTREE_HITTEST_NOWHERE, | |
851 | wxTREE_HITTEST_ONITEMBUTTON, | |
852 | wxTREE_HITTEST_ONITEMICON, | |
853 | wxTREE_HITTEST_ONITEMINDENT, | |
854 | wxTREE_HITTEST_ONITEMLABEL, | |
855 | wxTREE_HITTEST_ONITEMRIGHT, | |
856 | wxTREE_HITTEST_ONITEMSTATEICON, | |
857 | wxTREE_HITTEST_TOLEFT, | |
858 | wxTREE_HITTEST_TORIGHT, | |
859 | wxTREE_HITTEST_ONITEMUPPERPART, | |
860 | wxTREE_HITTEST_ONITEMLOWERPART, | |
861 | wxTREE_HITTEST_ONITEM | |
862 | }; | |
863 | ||
864 | ||
1b62f00d RD |
865 | enum { |
866 | /* Tree control event types */ | |
867 | wxEVT_COMMAND_TREE_BEGIN_DRAG, | |
868 | wxEVT_COMMAND_TREE_BEGIN_RDRAG, | |
869 | wxEVT_COMMAND_TREE_BEGIN_LABEL_EDIT, | |
870 | wxEVT_COMMAND_TREE_END_LABEL_EDIT, | |
871 | wxEVT_COMMAND_TREE_DELETE_ITEM, | |
872 | wxEVT_COMMAND_TREE_GET_INFO, | |
873 | wxEVT_COMMAND_TREE_SET_INFO, | |
874 | wxEVT_COMMAND_TREE_ITEM_EXPANDED, | |
875 | wxEVT_COMMAND_TREE_ITEM_EXPANDING, | |
876 | wxEVT_COMMAND_TREE_ITEM_COLLAPSED, | |
877 | wxEVT_COMMAND_TREE_ITEM_COLLAPSING, | |
878 | wxEVT_COMMAND_TREE_SEL_CHANGED, | |
879 | wxEVT_COMMAND_TREE_SEL_CHANGING, | |
880 | wxEVT_COMMAND_TREE_KEY_DOWN, | |
881 | wxEVT_COMMAND_TREE_ITEM_ACTIVATED, | |
882 | wxEVT_COMMAND_TREE_ITEM_RIGHT_CLICK, | |
883 | wxEVT_COMMAND_TREE_ITEM_MIDDLE_CLICK, | |
d1679124 | 884 | wxEVT_COMMAND_TREE_END_DRAG, |
1b62f00d RD |
885 | }; |
886 | ||
887 | ||
00b6c4e3 RD |
888 | %pragma(python) code = " |
889 | # wxTreeCtrl events | |
890 | def EVT_TREE_BEGIN_DRAG(win, id, func): | |
891 | win.Connect(id, -1, wxEVT_COMMAND_TREE_BEGIN_DRAG, func) | |
892 | ||
893 | def EVT_TREE_BEGIN_RDRAG(win, id, func): | |
894 | win.Connect(id, -1, wxEVT_COMMAND_TREE_BEGIN_RDRAG, func) | |
895 | ||
896 | def EVT_TREE_END_DRAG(win, id, func): | |
897 | win.Connect(id, -1, wxEVT_COMMAND_TREE_END_DRAG, func) | |
898 | ||
899 | def EVT_TREE_BEGIN_LABEL_EDIT(win, id, func): | |
900 | win.Connect(id, -1, wxEVT_COMMAND_TREE_BEGIN_LABEL_EDIT, func) | |
901 | ||
902 | def EVT_TREE_END_LABEL_EDIT(win, id, func): | |
903 | win.Connect(id, -1, wxEVT_COMMAND_TREE_END_LABEL_EDIT, func) | |
904 | ||
905 | def EVT_TREE_GET_INFO(win, id, func): | |
906 | win.Connect(id, -1, wxEVT_COMMAND_TREE_GET_INFO, func) | |
907 | ||
908 | def EVT_TREE_SET_INFO(win, id, func): | |
909 | win.Connect(id, -1, wxEVT_COMMAND_TREE_SET_INFO, func) | |
910 | ||
911 | def EVT_TREE_ITEM_EXPANDED(win, id, func): | |
912 | win.Connect(id, -1, wxEVT_COMMAND_TREE_ITEM_EXPANDED, func) | |
913 | ||
914 | def EVT_TREE_ITEM_EXPANDING(win, id, func): | |
915 | win.Connect(id, -1, wxEVT_COMMAND_TREE_ITEM_EXPANDING, func) | |
916 | ||
917 | def EVT_TREE_ITEM_COLLAPSED(win, id, func): | |
918 | win.Connect(id, -1, wxEVT_COMMAND_TREE_ITEM_COLLAPSED, func) | |
919 | ||
920 | def EVT_TREE_ITEM_COLLAPSING(win, id, func): | |
921 | win.Connect(id, -1, wxEVT_COMMAND_TREE_ITEM_COLLAPSING, func) | |
922 | ||
923 | def EVT_TREE_SEL_CHANGED(win, id, func): | |
924 | win.Connect(id, -1, wxEVT_COMMAND_TREE_SEL_CHANGED, func) | |
925 | ||
926 | def EVT_TREE_SEL_CHANGING(win, id, func): | |
927 | win.Connect(id, -1, wxEVT_COMMAND_TREE_SEL_CHANGING, func) | |
928 | ||
929 | def EVT_TREE_KEY_DOWN(win, id, func): | |
930 | win.Connect(id, -1, wxEVT_COMMAND_TREE_KEY_DOWN, func) | |
931 | ||
932 | def EVT_TREE_DELETE_ITEM(win, id, func): | |
933 | win.Connect(id, -1, wxEVT_COMMAND_TREE_DELETE_ITEM, func) | |
934 | ||
935 | def EVT_TREE_ITEM_ACTIVATED(win, id, func): | |
936 | win.Connect(id, -1, wxEVT_COMMAND_TREE_ITEM_ACTIVATED, func) | |
937 | ||
938 | def EVT_TREE_ITEM_RIGHT_CLICK(win, id, func): | |
939 | win.Connect(id, -1, wxEVT_COMMAND_TREE_ITEM_RIGHT_CLICK, func) | |
940 | ||
941 | def EVT_TREE_ITEM_MIDDLE_CLICK(win, id, func): | |
942 | win.Connect(id, -1, wxEVT_COMMAND_TREE_ITEM_MIDDLE_CLICK, func) | |
943 | " | |
944 | ||
945 | ||
946 | class wxTreeItemAttr | |
947 | { | |
948 | public: | |
949 | // ctors | |
950 | //wxTreeItemAttr() { } | |
951 | wxTreeItemAttr(const wxColour& colText = wxNullColour, | |
952 | const wxColour& colBack = wxNullColour, | |
953 | const wxFont& font = wxNullFont); | |
954 | ||
955 | // setters | |
956 | void SetTextColour(const wxColour& colText); | |
957 | void SetBackgroundColour(const wxColour& colBack); | |
958 | void SetFont(const wxFont& font); | |
959 | ||
960 | // accessors | |
961 | bool HasTextColour(); | |
962 | bool HasBackgroundColour(); | |
963 | bool HasFont(); | |
964 | ||
c5943253 RD |
965 | wxColour GetTextColour(); |
966 | wxColour GetBackgroundColour(); | |
967 | wxFont GetFont(); | |
00b6c4e3 RD |
968 | }; |
969 | ||
970 | ||
d5c9047a RD |
971 | class wxTreeItemId { |
972 | public: | |
973 | wxTreeItemId(); | |
974 | ~wxTreeItemId(); | |
bb0054cd | 975 | bool IsOk(); |
78e8819c | 976 | %pragma(python) addtoclass = "Ok = IsOk" |
d5c9047a | 977 | |
f6bcfd97 BP |
978 | %addmethods { |
979 | int __cmp__(wxTreeItemId* other) { | |
c368d904 | 980 | if (! other) return -1; |
f6bcfd97 BP |
981 | return *self != *other; |
982 | } | |
983 | } | |
d5c9047a RD |
984 | }; |
985 | ||
986 | ||
987 | ||
cf694132 RD |
988 | %{ |
989 | class wxPyTreeItemData : public wxTreeItemData { | |
d5c9047a | 990 | public: |
cf694132 | 991 | wxPyTreeItemData(PyObject* obj = NULL) { |
c368d904 | 992 | if (obj == NULL) |
cf694132 | 993 | obj = Py_None; |
c368d904 RD |
994 | Py_INCREF(obj); |
995 | m_obj = obj; | |
cf694132 | 996 | } |
d5c9047a | 997 | |
cf694132 | 998 | ~wxPyTreeItemData() { |
4268f798 | 999 | wxPyBeginBlockThreads(); |
c368d904 | 1000 | Py_DECREF(m_obj); |
4268f798 | 1001 | wxPyEndBlockThreads(); |
cf694132 RD |
1002 | } |
1003 | ||
1004 | PyObject* GetData() { | |
1005 | Py_INCREF(m_obj); | |
1006 | return m_obj; | |
1007 | } | |
1008 | ||
1009 | void SetData(PyObject* obj) { | |
4268f798 | 1010 | wxPyBeginBlockThreads(); |
cf694132 | 1011 | Py_DECREF(m_obj); |
4268f798 | 1012 | wxPyEndBlockThreads(); |
cf694132 RD |
1013 | m_obj = obj; |
1014 | Py_INCREF(obj); | |
1015 | } | |
1016 | ||
1017 | PyObject* m_obj; | |
d5c9047a | 1018 | }; |
cf694132 | 1019 | %} |
d5c9047a RD |
1020 | |
1021 | ||
1022 | ||
9416aa89 | 1023 | %name(wxTreeItemData) class wxPyTreeItemData : public wxObject { |
cf694132 RD |
1024 | public: |
1025 | wxPyTreeItemData(PyObject* obj = NULL); | |
1026 | ||
1027 | PyObject* GetData(); | |
1028 | void SetData(PyObject* obj); | |
1029 | ||
1030 | const wxTreeItemId& GetId(); | |
1031 | void SetId(const wxTreeItemId& id); | |
1032 | }; | |
1033 | ||
1034 | ||
d5c9047a | 1035 | |
8bf5d46e | 1036 | class wxTreeEvent : public wxNotifyEvent { |
d5c9047a | 1037 | public: |
00b6c4e3 RD |
1038 | wxTreeEvent(wxEventType commandType = wxEVT_NULL, int id = 0); |
1039 | ||
d5c9047a RD |
1040 | wxTreeItemId GetItem(); |
1041 | wxTreeItemId GetOldItem(); | |
1042 | wxPoint GetPoint(); | |
ecc08ead | 1043 | const wxKeyEvent& GetKeyEvent(); |
d5c9047a | 1044 | int GetCode(); |
8bf5d46e | 1045 | const wxString& GetLabel(); |
d5c9047a RD |
1046 | }; |
1047 | ||
1048 | ||
f6bcfd97 | 1049 | |
09f3d4e6 | 1050 | %{ // C++ version of Python aware wxTreeCtrl |
f6bcfd97 | 1051 | class wxPyTreeCtrl : public wxTreeCtrl { |
3b36695d | 1052 | DECLARE_ABSTRACT_CLASS(wxPyTreeCtrl); |
f6bcfd97 | 1053 | public: |
09f3d4e6 | 1054 | wxPyTreeCtrl() : wxTreeCtrl() {} |
f6bcfd97 BP |
1055 | wxPyTreeCtrl(wxWindow *parent, wxWindowID id, |
1056 | const wxPoint& pos, | |
1057 | const wxSize& size, | |
1058 | long style, | |
1059 | const wxValidator& validator, | |
137b5242 | 1060 | const wxString& name) : |
f6bcfd97 BP |
1061 | wxTreeCtrl(parent, id, pos, size, style, validator, name) {} |
1062 | ||
09f3d4e6 RD |
1063 | bool Create(wxWindow *parent, wxWindowID id, |
1064 | const wxPoint& pos, | |
1065 | const wxSize& size, | |
1066 | long style, | |
1067 | const wxValidator& validator, | |
137b5242 | 1068 | const wxString& name) { |
09f3d4e6 RD |
1069 | return wxTreeCtrl::Create(parent, id, pos, size, style, validator, name); |
1070 | } | |
1071 | ||
1072 | ||
f6bcfd97 BP |
1073 | int OnCompareItems(const wxTreeItemId& item1, |
1074 | const wxTreeItemId& item2) { | |
1075 | int rval = 0; | |
19a97bd6 | 1076 | bool found; |
4268f798 | 1077 | wxPyBeginBlockThreads(); |
a66212dc RD |
1078 | if ((found = m_myInst.findCallback("OnCompareItems"))) { |
1079 | PyObject *o1 = wxPyConstructObject((void*)&item1, "wxTreeItemId"); | |
1080 | PyObject *o2 = wxPyConstructObject((void*)&item2, "wxTreeItemId"); | |
1081 | rval = m_myInst.callCallback(Py_BuildValue("(OO)",o1,o2)); | |
1082 | Py_DECREF(o1); | |
1083 | Py_DECREF(o2); | |
1084 | } | |
4268f798 | 1085 | wxPyEndBlockThreads(); |
19a97bd6 | 1086 | if (! found) |
f6bcfd97 | 1087 | rval = wxTreeCtrl::OnCompareItems(item1, item2); |
f6bcfd97 BP |
1088 | return rval; |
1089 | } | |
1090 | PYPRIVATE; | |
1091 | }; | |
1092 | ||
3b36695d RD |
1093 | IMPLEMENT_ABSTRACT_CLASS(wxPyTreeCtrl, wxTreeCtrl); |
1094 | ||
f6bcfd97 BP |
1095 | %} |
1096 | ||
d5c9047a RD |
1097 | // These are for the GetFirstChild/GetNextChild methods below |
1098 | %typemap(python, in) long& INOUT = long* INOUT; | |
1099 | %typemap(python, argout) long& INOUT = long* INOUT; | |
1100 | ||
1101 | ||
f6bcfd97 | 1102 | %name(wxTreeCtrl)class wxPyTreeCtrl : public wxControl { |
d5c9047a | 1103 | public: |
f6bcfd97 | 1104 | wxPyTreeCtrl(wxWindow *parent, wxWindowID id = -1, |
b68dc582 RD |
1105 | const wxPoint& pos = wxDefaultPosition, |
1106 | const wxSize& size = wxDefaultSize, | |
d5c9047a | 1107 | long style = wxTR_HAS_BUTTONS | wxTR_LINES_AT_ROOT, |
b68dc582 | 1108 | const wxValidator& validator = wxDefaultValidator, |
137b5242 | 1109 | const wxString& name = wxPy_TreeCtrlNameStr); |
09f3d4e6 RD |
1110 | %name(wxPreTreeCtrl)wxPyTreeCtrl(); |
1111 | ||
1112 | bool Create(wxWindow *parent, wxWindowID id = -1, | |
1113 | const wxPoint& pos = wxDefaultPosition, | |
1114 | const wxSize& size = wxDefaultSize, | |
1115 | long style = wxTR_HAS_BUTTONS | wxTR_LINES_AT_ROOT, | |
1116 | const wxValidator& validator = wxDefaultValidator, | |
137b5242 | 1117 | const wxString& name = wxPy_TreeCtrlNameStr); |
d5c9047a | 1118 | |
0122b7e3 RD |
1119 | void _setCallbackInfo(PyObject* self, PyObject* _class); |
1120 | %pragma(python) addtomethod = "__init__:self._setCallbackInfo(self, wxTreeCtrl)" | |
1121 | ||
1122 | %pragma(python) addtomethod = "__init__:self._setOORInfo(self)" | |
17c0e08c | 1123 | %pragma(python) addtomethod = "wxPreTreeCtrl:val._setOORInfo(val)" |
d5c9047a RD |
1124 | |
1125 | size_t GetCount(); | |
1126 | unsigned int GetIndent(); | |
1127 | void SetIndent(unsigned int indent); | |
1128 | wxImageList *GetImageList(); | |
1129 | wxImageList *GetStateImageList(); | |
1b62f00d | 1130 | void SetImageList(wxImageList *imageList); |
d5c9047a | 1131 | void SetStateImageList(wxImageList *imageList); |
00b6c4e3 RD |
1132 | void AssignImageList(wxImageList* imageList); |
1133 | %pragma(python) addtomethod = "AssignImageList:_args[0].thisown = 0" | |
1134 | void AssignStateImageList(wxImageList* imageList); | |
1135 | %pragma(python) addtomethod = "AssignStateImageList:_args[0].thisown = 0" | |
d5c9047a | 1136 | |
b1462dfa RD |
1137 | unsigned int GetSpacing(); |
1138 | void SetSpacing(unsigned int spacing); | |
1139 | ||
d5c9047a | 1140 | wxString GetItemText(const wxTreeItemId& item); |
694759cf RD |
1141 | int GetItemImage(const wxTreeItemId& item, |
1142 | wxTreeItemIcon which = wxTreeItemIcon_Normal); | |
d5c9047a | 1143 | int GetItemSelectedImage(const wxTreeItemId& item); |
d5c9047a RD |
1144 | |
1145 | void SetItemText(const wxTreeItemId& item, const wxString& text); | |
694759cf RD |
1146 | void SetItemImage(const wxTreeItemId& item, int image, |
1147 | wxTreeItemIcon which = wxTreeItemIcon_Normal); | |
d5c9047a | 1148 | void SetItemSelectedImage(const wxTreeItemId& item, int image); |
08127323 | 1149 | void SetItemHasChildren(const wxTreeItemId& item, bool hasChildren = TRUE); |
d5c9047a | 1150 | |
cf694132 | 1151 | %addmethods { |
c368d904 RD |
1152 | // [Get|Set]ItemData substitutes. Automatically create wxPyTreeItemData |
1153 | // if needed. | |
cf694132 RD |
1154 | wxPyTreeItemData* GetItemData(const wxTreeItemId& item) { |
1155 | wxPyTreeItemData* data = (wxPyTreeItemData*)self->GetItemData(item); | |
1156 | if (data == NULL) { | |
1157 | data = new wxPyTreeItemData(); | |
f6bcfd97 | 1158 | data->SetId(item); // set the id |
cf694132 RD |
1159 | self->SetItemData(item, data); |
1160 | } | |
1161 | return data; | |
1162 | } | |
1163 | ||
1164 | void SetItemData(const wxTreeItemId& item, wxPyTreeItemData* data) { | |
f6bcfd97 BP |
1165 | data->SetId(item); // set the id |
1166 | self->SetItemData(item, data); | |
c368d904 | 1167 | } |
cf694132 | 1168 | |
c368d904 RD |
1169 | // [Get|Set]PyData are short-cuts. Also made somewhat crash-proof by |
1170 | // automatically creating data classes. | |
1171 | PyObject* GetPyData(const wxTreeItemId& item) { | |
cf694132 RD |
1172 | wxPyTreeItemData* data = (wxPyTreeItemData*)self->GetItemData(item); |
1173 | if (data == NULL) { | |
1174 | data = new wxPyTreeItemData(); | |
f6bcfd97 | 1175 | data->SetId(item); // set the id |
cf694132 RD |
1176 | self->SetItemData(item, data); |
1177 | } | |
1178 | return data->GetData(); | |
c368d904 | 1179 | } |
cf694132 RD |
1180 | |
1181 | void SetPyData(const wxTreeItemId& item, PyObject* obj) { | |
1182 | wxPyTreeItemData* data = (wxPyTreeItemData*)self->GetItemData(item); | |
1183 | if (data == NULL) { | |
1184 | data = new wxPyTreeItemData(obj); | |
f6bcfd97 | 1185 | data->SetId(item); // set the id |
cf694132 RD |
1186 | self->SetItemData(item, data); |
1187 | } else | |
1188 | data->SetData(obj); | |
c368d904 | 1189 | } |
cf694132 RD |
1190 | } |
1191 | ||
1192 | ||
d5c9047a RD |
1193 | bool IsVisible(const wxTreeItemId& item); |
1194 | bool ItemHasChildren(const wxTreeItemId& item); | |
1195 | bool IsExpanded(const wxTreeItemId& item); | |
1196 | bool IsSelected(const wxTreeItemId& item); | |
1197 | ||
1198 | wxTreeItemId GetRootItem(); | |
1199 | wxTreeItemId GetSelection(); | |
eb715945 | 1200 | %name(GetItemParent) wxTreeItemId GetParent(const wxTreeItemId& item); |
d426c97e RD |
1201 | //size_t GetSelections(wxArrayTreeItemIds& selection); |
1202 | %addmethods { | |
1203 | PyObject* GetSelections() { | |
4268f798 | 1204 | wxPyBeginBlockThreads(); |
d426c97e RD |
1205 | PyObject* rval = PyList_New(0); |
1206 | wxArrayTreeItemIds array; | |
1207 | size_t num, x; | |
1208 | num = self->GetSelections(array); | |
1209 | for (x=0; x < num; x++) { | |
c368d904 RD |
1210 | wxTreeItemId *tii = new wxTreeItemId(array.Item(x)); |
1211 | PyObject* item = wxPyConstructObject((void*)tii, "wxTreeItemId", TRUE); | |
d426c97e RD |
1212 | PyList_Append(rval, item); |
1213 | } | |
4268f798 | 1214 | wxPyEndBlockThreads(); |
d426c97e RD |
1215 | return rval; |
1216 | } | |
1217 | } | |
1218 | ||
1219 | ||
d5c9047a | 1220 | |
bb0054cd RD |
1221 | size_t GetChildrenCount(const wxTreeItemId& item, bool recursively = TRUE); |
1222 | ||
0815db26 | 1223 | wxTreeItemId GetFirstChild(const wxTreeItemId& item, long& INOUT = longzero); |
d5c9047a RD |
1224 | wxTreeItemId GetNextChild(const wxTreeItemId& item, long& INOUT); |
1225 | wxTreeItemId GetNextSibling(const wxTreeItemId& item); | |
1226 | wxTreeItemId GetPrevSibling(const wxTreeItemId& item); | |
1227 | wxTreeItemId GetFirstVisibleItem(); | |
1228 | wxTreeItemId GetNextVisible(const wxTreeItemId& item); | |
1229 | wxTreeItemId GetPrevVisible(const wxTreeItemId& item); | |
d426c97e RD |
1230 | wxTreeItemId GetLastChild(const wxTreeItemId& item); |
1231 | ||
d5c9047a RD |
1232 | |
1233 | ||
1234 | wxTreeItemId AddRoot(const wxString& text, | |
1235 | int image = -1, int selectedImage = -1, | |
cf694132 | 1236 | wxPyTreeItemData *data = NULL); |
d5c9047a RD |
1237 | wxTreeItemId PrependItem(const wxTreeItemId& parent, |
1238 | const wxString& text, | |
1239 | int image = -1, int selectedImage = -1, | |
cf694132 | 1240 | wxPyTreeItemData *data = NULL); |
d5c9047a RD |
1241 | wxTreeItemId InsertItem(const wxTreeItemId& parent, |
1242 | const wxTreeItemId& idPrevious, | |
1243 | const wxString& text, | |
1244 | int image = -1, int selectedImage = -1, | |
cf694132 | 1245 | wxPyTreeItemData *data = NULL); |
f6bcfd97 BP |
1246 | %name(InsertItemBefore) |
1247 | wxTreeItemId InsertItem(const wxTreeItemId& parent, | |
1248 | size_t before, | |
1249 | const wxString& text, | |
1250 | int image = -1, int selectedImage = -1, | |
3999941a | 1251 | wxPyTreeItemData *data = NULL); |
d5c9047a RD |
1252 | wxTreeItemId AppendItem(const wxTreeItemId& parent, |
1253 | const wxString& text, | |
1254 | int image = -1, int selectedImage = -1, | |
cf694132 | 1255 | wxPyTreeItemData *data = NULL); |
d5c9047a RD |
1256 | |
1257 | void Delete(const wxTreeItemId& item); | |
08127323 | 1258 | void DeleteChildren(const wxTreeItemId& item); |
d5c9047a RD |
1259 | void DeleteAllItems(); |
1260 | ||
1261 | void Expand(const wxTreeItemId& item); | |
1262 | void Collapse(const wxTreeItemId& item); | |
1263 | void CollapseAndReset(const wxTreeItemId& item); | |
1264 | void Toggle(const wxTreeItemId& item); | |
1265 | ||
1266 | void Unselect(); | |
8bf5d46e | 1267 | void UnselectAll(); |
d5c9047a RD |
1268 | void SelectItem(const wxTreeItemId& item); |
1269 | void EnsureVisible(const wxTreeItemId& item); | |
1270 | void ScrollTo(const wxTreeItemId& item); | |
8bf5d46e | 1271 | #ifdef __WXMSW__ |
d5c9047a | 1272 | wxTextCtrl* EditLabel(const wxTreeItemId& item); |
d5c9047a | 1273 | wxTextCtrl* GetEditControl(); |
b1462dfa | 1274 | void EndEditLabel(const wxTreeItemId& item, int discardChanges = FALSE); |
8bf5d46e RD |
1275 | #else |
1276 | void EditLabel(const wxTreeItemId& item); | |
1277 | #endif | |
d5c9047a | 1278 | |
d426c97e | 1279 | void SortChildren(const wxTreeItemId& item); |
d5c9047a | 1280 | |
b1462dfa | 1281 | void SetItemBold(const wxTreeItemId& item, int bold = TRUE); |
b8b8dda7 | 1282 | bool IsBold(const wxTreeItemId& item) const; |
164b735b | 1283 | wxTreeItemId HitTest(const wxPoint& point, int& OUTPUT); |
c127177f | 1284 | |
f6bcfd97 BP |
1285 | |
1286 | ||
b7e72427 RD |
1287 | void SetItemTextColour(const wxTreeItemId& item, const wxColour& col); |
1288 | void SetItemBackgroundColour(const wxTreeItemId& item, const wxColour& col); | |
1289 | void SetItemFont(const wxTreeItemId& item, const wxFont& font); | |
1290 | ||
4120ef2b | 1291 | #ifdef __WXMSW__ |
b1462dfa | 1292 | void SetItemDropHighlight(const wxTreeItemId& item, int highlight = TRUE); |
74bcba0e | 1293 | #endif |
b1462dfa | 1294 | |
d426c97e RD |
1295 | //bool GetBoundingRect(const wxTreeItemId& item, wxRect& rect, int textOnly = FALSE) |
1296 | %addmethods { | |
1297 | PyObject* GetBoundingRect(const wxTreeItemId& item, int textOnly = FALSE) { | |
1298 | wxRect rect; | |
164b735b | 1299 | if (self->GetBoundingRect(item, rect, textOnly)) { |
4268f798 | 1300 | wxPyBeginBlockThreads(); |
164b735b RD |
1301 | wxRect* r = new wxRect(rect); |
1302 | PyObject* val = wxPyConstructObject((void*)r, "wxRect"); | |
4268f798 | 1303 | wxPyEndBlockThreads(); |
164b735b RD |
1304 | return val; |
1305 | } | |
d426c97e RD |
1306 | else { |
1307 | Py_INCREF(Py_None); | |
1308 | return Py_None; | |
1309 | } | |
1310 | } | |
1311 | } | |
74bcba0e | 1312 | |
d426c97e | 1313 | |
c127177f | 1314 | %pragma(python) addtoclass = " |
f6bcfd97 BP |
1315 | # Redefine some methods that SWIG gets a bit confused on... |
1316 | def GetFirstChild(self, *_args, **_kwargs): | |
1317 | val1,val2 = apply(controls2c.wxTreeCtrl_GetFirstChild,(self,) + _args, _kwargs) | |
1318 | val1 = wxTreeItemIdPtr(val1) | |
1319 | val1.thisown = 1 | |
1320 | return (val1,val2) | |
1321 | def GetNextChild(self, *_args, **_kwargs): | |
1322 | val1,val2 = apply(controls2c.wxTreeCtrl_GetNextChild,(self,) + _args, _kwargs) | |
c127177f RD |
1323 | val1 = wxTreeItemIdPtr(val1) |
1324 | val1.thisown = 1 | |
1325 | return (val1,val2) | |
f6bcfd97 BP |
1326 | def HitTest(self, *_args, **_kwargs): |
1327 | val1, val2 = apply(controls2c.wxTreeCtrl_HitTest,(self,) + _args, _kwargs) | |
c127177f RD |
1328 | val1 = wxTreeItemIdPtr(val1) |
1329 | val1.thisown = 1 | |
1330 | return (val1,val2) | |
1331 | " | |
74bcba0e | 1332 | |
d5c9047a RD |
1333 | }; |
1334 | ||
d5c9047a | 1335 | |
7bf85405 RD |
1336 | //---------------------------------------------------------------------- |
1337 | ||
68320e40 RD |
1338 | |
1339 | enum { | |
1340 | wxDIRCTRL_DIR_ONLY, | |
1341 | wxDIRCTRL_SELECT_FIRST, | |
1342 | wxDIRCTRL_SHOW_FILTERS, | |
1343 | wxDIRCTRL_3D_INTERNAL, | |
7cdaed0b | 1344 | wxDIRCTRL_EDIT_LABELS, |
db0ff83e RD |
1345 | |
1346 | wxID_TREECTRL, | |
1347 | wxID_FILTERLISTCTRL, | |
68320e40 RD |
1348 | }; |
1349 | ||
1350 | ||
1351 | class wxDirItemData : public wxObject // wxTreeItemData | |
1352 | { | |
1353 | public: | |
1354 | wxDirItemData(const wxString& path, const wxString& name, bool isDir); | |
1355 | // ~wxDirItemDataEx(); | |
1356 | void SetNewDirName( wxString path ); | |
1357 | wxString m_path, m_name; | |
1358 | bool m_isHidden; | |
1359 | bool m_isExpanded; | |
1360 | bool m_isDir; | |
1361 | }; | |
1362 | ||
1363 | ||
1364 | class wxGenericDirCtrl: public wxControl | |
1365 | { | |
1366 | public: | |
1367 | wxGenericDirCtrl(wxWindow *parent, const wxWindowID id = -1, | |
137b5242 | 1368 | const wxString& dir = wxPyDirDialogDefaultFolderStr, |
68320e40 RD |
1369 | const wxPoint& pos = wxDefaultPosition, |
1370 | const wxSize& size = wxDefaultSize, | |
1371 | long style = wxDIRCTRL_3D_INTERNAL|wxSUNKEN_BORDER, | |
137b5242 | 1372 | const wxString& filter = wxPyEmptyString, |
68320e40 | 1373 | int defaultFilter = 0, |
137b5242 | 1374 | const wxString& name = wxPy_TreeCtrlNameStr); |
68320e40 RD |
1375 | %name(wxPreGenericDirCtrl)wxGenericDirCtrl(); |
1376 | ||
1377 | %pragma(python) addtomethod = "__init__:self._setOORInfo(self)" | |
1378 | %pragma(python) addtomethod = "wxPreGenericDirCtrl:val._setOORInfo(val)" | |
1379 | ||
1380 | bool Create(wxWindow *parent, const wxWindowID id = -1, | |
137b5242 | 1381 | const wxString& dir = wxPyDirDialogDefaultFolderStr, |
68320e40 RD |
1382 | const wxPoint& pos = wxDefaultPosition, |
1383 | const wxSize& size = wxDefaultSize, | |
1384 | long style = wxDIRCTRL_3D_INTERNAL|wxSUNKEN_BORDER, | |
137b5242 | 1385 | const wxString& filter = wxPyEmptyString, |
68320e40 | 1386 | int defaultFilter = 0, |
137b5242 | 1387 | const wxString& name = wxPy_TreeCtrlNameStr); |
68320e40 RD |
1388 | |
1389 | ||
1390 | // Try to expand as much of the given path as possible. | |
1391 | bool ExpandPath(const wxString& path); | |
1392 | ||
1393 | // Accessors | |
1394 | ||
1395 | inline wxString GetDefaultPath() const; | |
1396 | void SetDefaultPath(const wxString& path); | |
1397 | ||
1398 | // Get dir or filename | |
1399 | wxString GetPath() const ; | |
1400 | ||
1401 | // Get selected filename path only (else empty string). | |
1402 | // I.e. don't count a directory as a selection | |
1403 | wxString GetFilePath() const ; | |
1404 | void SetPath(const wxString& path) ; | |
1405 | ||
1406 | void ShowHidden( bool show ); | |
1407 | bool GetShowHidden(); | |
1408 | ||
1409 | wxString GetFilter() const; | |
1410 | void SetFilter(const wxString& filter); | |
1411 | ||
1412 | int GetFilterIndex() const; | |
1413 | void SetFilterIndex(int n) ; | |
1414 | ||
1415 | wxTreeItemId GetRootId(); | |
1416 | ||
1417 | wxTreeCtrl* GetTreeCtrl() const; | |
1418 | wxDirFilterListCtrl* GetFilterListCtrl() const; | |
1419 | ||
1420 | // //// Helpers | |
1421 | // void SetupSections(); | |
1422 | // // Parse the filter into an array of filters and an array of descriptions | |
1423 | // int ParseFilter(const wxString& filterStr, wxArrayString& filters, wxArrayString& descriptions); | |
1424 | // // Find the child that matches the first part of 'path'. | |
1425 | // // E.g. if a child path is "/usr" and 'path' is "/usr/include" | |
1426 | // // then the child for /usr is returned. | |
1427 | // // If the path string has been used (we're at the leaf), done is set to TRUE | |
1428 | // wxTreeItemId FindChild(wxTreeItemId parentId, const wxString& path, bool& done); | |
1429 | }; | |
1430 | ||
1431 | ||
1432 | class wxDirFilterListCtrl: public wxChoice | |
1433 | { | |
1434 | public: | |
1435 | wxDirFilterListCtrl(wxGenericDirCtrl* parent, const wxWindowID id = -1, | |
1436 | const wxPoint& pos = wxDefaultPosition, | |
1437 | const wxSize& size = wxDefaultSize, | |
1438 | long style = 0); | |
1439 | %name(wxPreDirFilterListCtrl)wxDirFilterListCtrl(); | |
1440 | ||
1441 | %pragma(python) addtomethod = "__init__:self._setOORInfo(self)" | |
1442 | %pragma(python) addtomethod = "wxPreDirFilterListCtrl:val._setOORInfo(val)" | |
1443 | ||
1444 | bool Create(wxGenericDirCtrl* parent, const wxWindowID id = -1, | |
1445 | const wxPoint& pos = wxDefaultPosition, | |
1446 | const wxSize& size = wxDefaultSize, | |
1447 | long style = 0); | |
1448 | ||
1449 | //// Operations | |
1450 | void FillFilterList(const wxString& filter, int defaultFilter); | |
1451 | }; | |
1452 | ||
1453 | ||
1454 | //---------------------------------------------------------------------- | |
1455 | //---------------------------------------------------------------------- | |
1456 | ||
9416aa89 | 1457 | %init %{ |
a3fbed81 | 1458 | // Map renamed classes back to their common name for OOR |
9416aa89 RD |
1459 | wxPyPtrTypeMap_Add("wxTreeItemData", "wxPyTreeItemData"); |
1460 | wxPyPtrTypeMap_Add("wxTreeCtrl", "wxPyTreeCtrl"); | |
a3fbed81 | 1461 | wxPyPtrTypeMap_Add("wxListCtrl", "wxPyListCtrl"); |
9416aa89 RD |
1462 | %} |
1463 | ||
1464 | //---------------------------------------------------------------------- | |
1465 | ||
7bf85405 | 1466 |