]>
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; | |
be13a6af | 447 | item.SetMask(0xFFFF); |
14afa2cb RD |
448 | if (self->GetColumn(col, item)) |
449 | return new wxListItem(item); | |
450 | else | |
451 | return NULL; | |
452 | } | |
e4ed5de1 | 453 | } // The OOR typemaps don't know what to do with the %new, so fix it up. |
14afa2cb | 454 | %pragma(python) addtoclass = " |
e4ed5de1 | 455 | def GetColumn(self, *_args, **_kwargs): |
14afa2cb RD |
456 | val = apply(controls2c.wxListCtrl_GetColumn,(self,) + _args, _kwargs) |
457 | if val is not None: val.thisown = 1 | |
458 | return val | |
459 | " | |
c7e7022c RD |
460 | |
461 | // Sets information about this column | |
462 | bool SetColumn(int col, wxListItem& item) ; | |
463 | ||
464 | // Gets the column width | |
465 | int GetColumnWidth(int col) const; | |
466 | ||
467 | // Sets the column width | |
468 | bool SetColumnWidth(int col, int width) ; | |
469 | ||
470 | // Gets the number of items that can fit vertically in the | |
471 | // visible area of the list control (list or report view) | |
472 | // or the total number of items in the list control (icon | |
473 | // or small icon view) | |
474 | int GetCountPerPage() const; | |
475 | ||
cd096152 | 476 | #ifdef __WXMSW__ |
c7e7022c RD |
477 | // Gets the edit control for editing labels. |
478 | wxTextCtrl* GetEditControl() const; | |
cd096152 | 479 | #endif |
c7e7022c RD |
480 | |
481 | //bool GetItem(wxListItem& info) const ; | |
7bf85405 | 482 | %addmethods { |
c7e7022c | 483 | // Gets information about the item |
e166644c | 484 | %new wxListItem* GetItem(long itemId, int col=0) { |
7bf85405 | 485 | wxListItem* info = new wxListItem; |
0699c864 | 486 | info->m_itemId = itemId; |
e166644c | 487 | info->m_col = col; |
f17fee68 | 488 | info->m_mask = 0xFFFF; |
7bf85405 RD |
489 | self->GetItem(*info); |
490 | return info; | |
491 | } | |
5597b61e RD |
492 | } // The OOR typemaps don't know what to do with the %new, so fix it up. |
493 | %pragma(python) addtoclass = " | |
494 | def GetItem(self, *_args, **_kwargs): | |
495 | val = apply(controls2c.wxListCtrl_GetItem,(self,) + _args, _kwargs) | |
e4ed5de1 | 496 | if val is not None: val.thisown = 1 |
5597b61e RD |
497 | return val |
498 | " | |
499 | ||
c7e7022c RD |
500 | |
501 | // Sets information about the item | |
502 | bool SetItem(wxListItem& info) ; | |
503 | ||
504 | // Sets a string field at a particular column | |
505 | %name(SetStringItem)long SetItem(long index, int col, const wxString& label, int imageId = -1); | |
506 | ||
507 | // Gets the item state | |
508 | int GetItemState(long item, long stateMask) const ; | |
509 | ||
510 | // Sets the item state | |
511 | bool SetItemState(long item, long state, long stateMask) ; | |
512 | ||
513 | // Sets the item image | |
514 | bool SetItemImage(long item, int image, int selImage) ; | |
515 | ||
516 | // Gets the item text | |
517 | wxString GetItemText(long item) const ; | |
518 | ||
519 | // Sets the item text | |
520 | void SetItemText(long item, const wxString& str) ; | |
521 | ||
522 | // Gets the item data | |
523 | long GetItemData(long item) const ; | |
524 | ||
525 | // Sets the item data | |
526 | bool SetItemData(long item, long data) ; | |
527 | ||
528 | ||
529 | //bool GetItemRect(long item, wxRect& rect, int code = wxLIST_RECT_BOUNDS) const ; | |
530 | //bool GetItemPosition(long item, wxPoint& pos) const ; | |
00b6c4e3 RD |
531 | |
532 | // Gets the item position | |
5597b61e | 533 | %addmethods { |
7bf85405 RD |
534 | %new wxPoint* GetItemPosition(long item) { |
535 | wxPoint* pos = new wxPoint; | |
536 | self->GetItemPosition(item, *pos); | |
537 | return pos; | |
538 | } | |
c7e7022c | 539 | // Gets the item rectangle |
7bf85405 RD |
540 | %new wxRect* GetItemRect(long item, int code = wxLIST_RECT_BOUNDS) { |
541 | wxRect* rect= new wxRect; | |
542 | self->GetItemRect(item, *rect, code); | |
543 | return rect; | |
544 | } | |
545 | } | |
546 | ||
c7e7022c RD |
547 | |
548 | // Sets the item position | |
549 | bool SetItemPosition(long item, const wxPoint& pos) ; | |
550 | ||
551 | // Gets the number of items in the list control | |
552 | int GetItemCount() const; | |
553 | ||
554 | // Gets the number of columns in the list control | |
9d37f964 | 555 | int GetColumnCount() const; |
c7e7022c RD |
556 | |
557 | // Retrieves the spacing between icons in pixels. | |
558 | // If small is TRUE, gets the spacing for the small icon | |
559 | // view, otherwise the large icon view. | |
560 | int GetItemSpacing(bool isSmall) const; | |
561 | ||
562 | // Gets the number of selected items in the list control | |
563 | int GetSelectedItemCount() const; | |
564 | ||
565 | // Gets the text colour of the listview | |
566 | wxColour GetTextColour() const; | |
567 | ||
568 | // Sets the text colour of the listview | |
4f22cf8d | 569 | void SetTextColour(const wxColour& col); |
c7e7022c RD |
570 | |
571 | // Gets the index of the topmost visible item when in | |
572 | // list or report view | |
573 | long GetTopItem() const ; | |
574 | ||
575 | // Add or remove a single window style | |
576 | void SetSingleStyle(long style, bool add = TRUE) ; | |
577 | ||
578 | // Set the whole window style | |
579 | void SetWindowStyleFlag(long style) ; | |
580 | ||
581 | // Searches for an item, starting from 'item'. | |
582 | // item can be -1 to find the first item that matches the | |
583 | // specified flags. | |
584 | // Returns the item or -1 if unsuccessful. | |
585 | long GetNextItem(long item, int geometry = wxLIST_NEXT_ALL, int state = wxLIST_STATE_DONTCARE) const ; | |
586 | ||
587 | // Gets one of the three image lists | |
588 | wxImageList *GetImageList(int which) const ; | |
589 | ||
590 | // Sets the image list | |
591 | void SetImageList(wxImageList *imageList, int which) ; | |
592 | void AssignImageList(wxImageList *imageList, int which) ; | |
593 | %pragma(python) addtomethod = "AssignImageList:_args[0].thisown = 0" | |
594 | ||
595 | // returns true if it is a virtual list control | |
596 | bool IsVirtual() const; | |
597 | ||
598 | // refresh items selectively (only useful for virtual list controls) | |
599 | void RefreshItem(long item); | |
600 | void RefreshItems(long itemFrom, long itemTo); | |
601 | ||
c7e7022c RD |
602 | // Arranges the items |
603 | bool Arrange(int flag = wxLIST_ALIGN_DEFAULT); | |
604 | ||
605 | // Deletes an item | |
606 | bool DeleteItem(long item); | |
607 | ||
608 | // Deletes all items | |
609 | bool DeleteAllItems() ; | |
610 | ||
611 | // Deletes a column | |
612 | bool DeleteColumn(int col); | |
613 | ||
614 | // Deletes all columns | |
615 | bool DeleteAllColumns(); | |
616 | ||
617 | // Clears items, and columns if there are any. | |
618 | void ClearAll(); | |
619 | ||
cd096152 | 620 | #ifdef __WXMSW__ |
c7e7022c RD |
621 | // Edit the label |
622 | wxTextCtrl* EditLabel(long item /*, wxClassInfo* textControlClass = CLASSINFO(wxTextCtrl)*/); | |
623 | ||
624 | // End label editing, optionally cancelling the edit | |
625 | bool EndEditLabel(bool cancel); | |
cd096152 | 626 | #endif |
c7e7022c RD |
627 | |
628 | // Ensures this item is visible | |
629 | bool EnsureVisible(long item) ; | |
630 | ||
631 | // Find an item whose label matches this string, starting from the item after 'start' | |
632 | // or the beginning if 'start' is -1. | |
633 | long FindItem(long start, const wxString& str, bool partial = FALSE); | |
634 | ||
635 | // Find an item whose data matches this data, starting from the item after 'start' | |
636 | // or the beginning if 'start' is -1. | |
637 | %name(FindItemData)long FindItem(long start, long data); | |
638 | ||
639 | // Find an item nearest this position in the specified direction, starting from | |
640 | // the item after 'start' or the beginning if 'start' is -1. | |
641 | %name(FindItemAtPos)long FindItem(long start, const wxPoint& pt, int direction); | |
642 | ||
643 | // Determines which item (if any) is at the specified point, | |
644 | // giving details in the second return value (see wxLIST_HITTEST_... flags above) | |
7bf85405 | 645 | long HitTest(const wxPoint& point, int& OUTPUT); |
c7e7022c RD |
646 | |
647 | // Inserts an item, returning the index of the new item if successful, | |
648 | // -1 otherwise. | |
649 | long InsertItem(wxListItem& info); | |
650 | ||
651 | // Insert a string item | |
652 | %name(InsertStringItem)long InsertItem(long index, const wxString& label); | |
653 | ||
654 | // Insert an image item | |
655 | %name(InsertImageItem)long InsertItem(long index, int imageIndex); | |
656 | ||
657 | // Insert an image/string item | |
658 | %name(InsertImageStringItem)long InsertItem(long index, const wxString& label, int imageIndex); | |
659 | ||
660 | // For list view mode (only), inserts a column. | |
c368d904 | 661 | %name(InsertColumnInfo)long InsertColumn(long col, wxListItem& info); |
c7e7022c RD |
662 | |
663 | long InsertColumn(long col, | |
664 | const wxString& heading, | |
7bf85405 RD |
665 | int format = wxLIST_FORMAT_LEFT, |
666 | int width = -1); | |
667 | ||
c7e7022c RD |
668 | // set the number of items in a virtual list control |
669 | void SetItemCount(long count); | |
7bf85405 | 670 | |
c7e7022c RD |
671 | // Scrolls the list control. If in icon, small icon or report view mode, |
672 | // x specifies the number of pixels to scroll. If in list view mode, x | |
673 | // specifies the number of columns to scroll. | |
674 | // If in icon, small icon or list view mode, y specifies the number of pixels | |
675 | // to scroll. If in report view mode, y specifies the number of lines to scroll. | |
7bf85405 | 676 | bool ScrollList(int dx, int dy); |
dcd38683 | 677 | |
3bd1e033 RD |
678 | void SetItemTextColour( long item, const wxColour& col); |
679 | wxColour GetItemTextColour( long item ) const; | |
680 | void SetItemBackgroundColour( long item, const wxColour &col); | |
681 | wxColour GetItemBackgroundColour( long item ) const; | |
682 | ||
c7e7022c | 683 | |
6d19860f RD |
684 | %pragma(python) addtoclass = " |
685 | # Some helpers... | |
686 | ||
43097598 | 687 | def Select(self, idx, on=1): |
6d19860f RD |
688 | '''[de]select an item''' |
689 | if on: state = wxLIST_STATE_SELECTED | |
690 | else: state = 0 | |
691 | self.SetItemState(idx, state, wxLIST_STATE_SELECTED) | |
692 | ||
693 | def Focus(self, idx): | |
694 | '''Focus and show the given item''' | |
695 | self.SetItemState(idx, wxLIST_STATE_FOCUSED, wxLIST_STATE_FOCUSED) | |
696 | self.EnsureVisible(idx) | |
697 | ||
698 | def GetFocusedItem(self): | |
699 | '''get the currently focused item or -1 if none''' | |
700 | return self.GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_FOCUSED) | |
701 | ||
702 | def IsSelected(self, idx): | |
703 | '''return TRUE if the item is selected''' | |
704 | return self.GetItemState(idx, wxLIST_STATE_SELECTED) != 0 | |
705 | ||
706 | def SetColumnImage(self, col, image): | |
707 | item = wxListItem() | |
708 | item.SetMask(wxLIST_MASK_IMAGE) | |
709 | item.SetImage(image) | |
710 | self.SetColumn(col, item) | |
711 | ||
712 | def ClearColumnImage(self, col): | |
713 | self.SetColumnImage(col, -1) | |
44536514 RD |
714 | |
715 | def Append(self, entry): | |
716 | '''Append an item to the list control. The entry parameter should be a | |
717 | sequence with an item for each column''' | |
718 | if len(entry): | |
719 | pos = self.GetItemCount() | |
720 | self.InsertStringItem(pos, str(entry[0])) | |
721 | for i in range(1, len(entry)): | |
722 | self.SetStringItem(pos, i, str(entry[i])) | |
723 | return pos | |
6d19860f | 724 | " |
3bd1e033 RD |
725 | |
726 | ||
727 | // bool SortItems(wxListCtrlCompare fn, long data); | |
728 | %addmethods { | |
729 | // Sort items. | |
730 | // func is a function which takes 2 long arguments: item1, item2. | |
731 | // item1 is the long data associated with a first item (NOT the index). | |
732 | // item2 is the long data associated with a second item (NOT the index). | |
733 | // The return value is a negative number if the first item should precede the second | |
734 | // item, a positive number of the second item should precede the first, | |
735 | // or zero if the two items are equivalent. | |
736 | bool SortItems(PyObject* func) { | |
737 | if (!PyCallable_Check(func)) | |
738 | return FALSE; | |
739 | return self->SortItems(wxPyListCtrl_SortItems, (long)func); | |
740 | } | |
741 | } | |
7bf85405 RD |
742 | }; |
743 | ||
c7e7022c RD |
744 | |
745 | ||
6d19860f | 746 | %{ // Python aware sorting function for wxPyListCtrl |
f6bcfd97 | 747 | int wxCALLBACK wxPyListCtrl_SortItems(long item1, long item2, long funcPtr) { |
dcd38683 RD |
748 | int retval = 0; |
749 | PyObject* func = (PyObject*)funcPtr; | |
4268f798 | 750 | wxPyBeginBlockThreads(); |
7bf85405 | 751 | |
dcd38683 RD |
752 | PyObject* args = Py_BuildValue("(ii)", item1, item2); |
753 | PyObject* result = PyEval_CallObject(func, args); | |
754 | Py_DECREF(args); | |
755 | if (result) { | |
756 | retval = PyInt_AsLong(result); | |
757 | Py_DECREF(result); | |
758 | } | |
759 | ||
4268f798 | 760 | wxPyEndBlockThreads(); |
dcd38683 RD |
761 | return retval; |
762 | } | |
763 | ||
764 | %} | |
7bf85405 | 765 | |
6d19860f RD |
766 | //---------------------------------------------------------------------- |
767 | ||
768 | class wxListView : public wxPyListCtrl | |
769 | { | |
770 | public: | |
771 | wxListView( wxWindow *parent, | |
772 | wxWindowID id = -1, | |
773 | const wxPoint& pos = wxDefaultPosition, | |
774 | const wxSize& size = wxDefaultSize, | |
775 | long style = wxLC_REPORT, | |
776 | const wxValidator& validator = wxDefaultValidator, | |
137b5242 | 777 | const wxString& name = wxPyListCtrlNameStr); |
6d19860f RD |
778 | %name(wxPreListView)wxListView(); |
779 | ||
780 | bool Create( wxWindow *parent, | |
781 | wxWindowID id = -1, | |
782 | const wxPoint& pos = wxDefaultPosition, | |
783 | const wxSize& size = wxDefaultSize, | |
784 | long style = wxLC_REPORT, | |
785 | const wxValidator& validator = wxDefaultValidator, | |
137b5242 | 786 | const wxString& name = wxPyListCtrlNameStr); |
6d19860f | 787 | |
0122b7e3 | 788 | %pragma(python) addtomethod = "__init__:self._setOORInfo(self)" |
17c0e08c | 789 | %pragma(python) addtomethod = "wxPreListView:val._setOORInfo(val)" |
6d19860f RD |
790 | |
791 | // [de]select an item | |
792 | void Select(long n, bool on = TRUE); | |
793 | ||
794 | // focus and show the given item | |
795 | void Focus(long index); | |
796 | ||
797 | // get the currently focused item or -1 if none | |
798 | long GetFocusedItem() const; | |
799 | ||
800 | // get first and subsequent selected items, return -1 when no more | |
801 | long GetNextSelected(long item) const; | |
802 | long GetFirstSelected() const; | |
803 | ||
804 | // return TRUE if the item is selected | |
805 | bool IsSelected(long index); | |
806 | ||
807 | void SetColumnImage(int col, int image); | |
808 | void ClearColumnImage(int col); | |
809 | }; | |
810 | ||
811 | ||
7bf85405 RD |
812 | //---------------------------------------------------------------------- |
813 | ||
00b6c4e3 RD |
814 | // wxTreeCtrl flags |
815 | enum { | |
816 | wxTR_NO_BUTTONS, | |
817 | wxTR_HAS_BUTTONS, | |
818 | wxTR_TWIST_BUTTONS, | |
819 | wxTR_NO_LINES, | |
820 | wxTR_MAC_BUTTONS, | |
b5a5d647 | 821 | wxTR_AQUA_BUTTONS, |
00b6c4e3 RD |
822 | |
823 | wxTR_SINGLE, | |
824 | wxTR_MULTIPLE, | |
825 | wxTR_EXTENDED, | |
b5a5d647 | 826 | wxTR_FULL_ROW_HIGHLIGHT, |
00b6c4e3 RD |
827 | |
828 | wxTR_EDIT_LABELS, | |
829 | wxTR_LINES_AT_ROOT, | |
830 | wxTR_HIDE_ROOT, | |
831 | wxTR_ROW_LINES, | |
832 | wxTR_HAS_VARIABLE_ROW_HEIGHT, | |
833 | ||
834 | wxTR_DEFAULT_STYLE, | |
835 | }; | |
836 | ||
694759cf RD |
837 | enum wxTreeItemIcon |
838 | { | |
839 | wxTreeItemIcon_Normal, // not selected, not expanded | |
840 | wxTreeItemIcon_Selected, // selected, not expanded | |
841 | wxTreeItemIcon_Expanded, // not selected, expanded | |
842 | wxTreeItemIcon_SelectedExpanded, // selected, expanded | |
843 | wxTreeItemIcon_Max | |
844 | }; | |
845 | ||
7bf85405 | 846 | |
164b735b RD |
847 | // constants for HitTest |
848 | enum { | |
849 | wxTREE_HITTEST_ABOVE, | |
850 | wxTREE_HITTEST_BELOW, | |
851 | wxTREE_HITTEST_NOWHERE, | |
852 | wxTREE_HITTEST_ONITEMBUTTON, | |
853 | wxTREE_HITTEST_ONITEMICON, | |
854 | wxTREE_HITTEST_ONITEMINDENT, | |
855 | wxTREE_HITTEST_ONITEMLABEL, | |
856 | wxTREE_HITTEST_ONITEMRIGHT, | |
857 | wxTREE_HITTEST_ONITEMSTATEICON, | |
858 | wxTREE_HITTEST_TOLEFT, | |
859 | wxTREE_HITTEST_TORIGHT, | |
860 | wxTREE_HITTEST_ONITEMUPPERPART, | |
861 | wxTREE_HITTEST_ONITEMLOWERPART, | |
862 | wxTREE_HITTEST_ONITEM | |
863 | }; | |
864 | ||
865 | ||
1b62f00d RD |
866 | enum { |
867 | /* Tree control event types */ | |
868 | wxEVT_COMMAND_TREE_BEGIN_DRAG, | |
869 | wxEVT_COMMAND_TREE_BEGIN_RDRAG, | |
870 | wxEVT_COMMAND_TREE_BEGIN_LABEL_EDIT, | |
871 | wxEVT_COMMAND_TREE_END_LABEL_EDIT, | |
872 | wxEVT_COMMAND_TREE_DELETE_ITEM, | |
873 | wxEVT_COMMAND_TREE_GET_INFO, | |
874 | wxEVT_COMMAND_TREE_SET_INFO, | |
875 | wxEVT_COMMAND_TREE_ITEM_EXPANDED, | |
876 | wxEVT_COMMAND_TREE_ITEM_EXPANDING, | |
877 | wxEVT_COMMAND_TREE_ITEM_COLLAPSED, | |
878 | wxEVT_COMMAND_TREE_ITEM_COLLAPSING, | |
879 | wxEVT_COMMAND_TREE_SEL_CHANGED, | |
880 | wxEVT_COMMAND_TREE_SEL_CHANGING, | |
881 | wxEVT_COMMAND_TREE_KEY_DOWN, | |
882 | wxEVT_COMMAND_TREE_ITEM_ACTIVATED, | |
883 | wxEVT_COMMAND_TREE_ITEM_RIGHT_CLICK, | |
884 | wxEVT_COMMAND_TREE_ITEM_MIDDLE_CLICK, | |
d1679124 | 885 | wxEVT_COMMAND_TREE_END_DRAG, |
1b62f00d RD |
886 | }; |
887 | ||
888 | ||
00b6c4e3 RD |
889 | %pragma(python) code = " |
890 | # wxTreeCtrl events | |
891 | def EVT_TREE_BEGIN_DRAG(win, id, func): | |
892 | win.Connect(id, -1, wxEVT_COMMAND_TREE_BEGIN_DRAG, func) | |
893 | ||
894 | def EVT_TREE_BEGIN_RDRAG(win, id, func): | |
895 | win.Connect(id, -1, wxEVT_COMMAND_TREE_BEGIN_RDRAG, func) | |
896 | ||
897 | def EVT_TREE_END_DRAG(win, id, func): | |
898 | win.Connect(id, -1, wxEVT_COMMAND_TREE_END_DRAG, func) | |
899 | ||
900 | def EVT_TREE_BEGIN_LABEL_EDIT(win, id, func): | |
901 | win.Connect(id, -1, wxEVT_COMMAND_TREE_BEGIN_LABEL_EDIT, func) | |
902 | ||
903 | def EVT_TREE_END_LABEL_EDIT(win, id, func): | |
904 | win.Connect(id, -1, wxEVT_COMMAND_TREE_END_LABEL_EDIT, func) | |
905 | ||
906 | def EVT_TREE_GET_INFO(win, id, func): | |
907 | win.Connect(id, -1, wxEVT_COMMAND_TREE_GET_INFO, func) | |
908 | ||
909 | def EVT_TREE_SET_INFO(win, id, func): | |
910 | win.Connect(id, -1, wxEVT_COMMAND_TREE_SET_INFO, func) | |
911 | ||
912 | def EVT_TREE_ITEM_EXPANDED(win, id, func): | |
913 | win.Connect(id, -1, wxEVT_COMMAND_TREE_ITEM_EXPANDED, func) | |
914 | ||
915 | def EVT_TREE_ITEM_EXPANDING(win, id, func): | |
916 | win.Connect(id, -1, wxEVT_COMMAND_TREE_ITEM_EXPANDING, func) | |
917 | ||
918 | def EVT_TREE_ITEM_COLLAPSED(win, id, func): | |
919 | win.Connect(id, -1, wxEVT_COMMAND_TREE_ITEM_COLLAPSED, func) | |
920 | ||
921 | def EVT_TREE_ITEM_COLLAPSING(win, id, func): | |
922 | win.Connect(id, -1, wxEVT_COMMAND_TREE_ITEM_COLLAPSING, func) | |
923 | ||
924 | def EVT_TREE_SEL_CHANGED(win, id, func): | |
925 | win.Connect(id, -1, wxEVT_COMMAND_TREE_SEL_CHANGED, func) | |
926 | ||
927 | def EVT_TREE_SEL_CHANGING(win, id, func): | |
928 | win.Connect(id, -1, wxEVT_COMMAND_TREE_SEL_CHANGING, func) | |
929 | ||
930 | def EVT_TREE_KEY_DOWN(win, id, func): | |
931 | win.Connect(id, -1, wxEVT_COMMAND_TREE_KEY_DOWN, func) | |
932 | ||
933 | def EVT_TREE_DELETE_ITEM(win, id, func): | |
934 | win.Connect(id, -1, wxEVT_COMMAND_TREE_DELETE_ITEM, func) | |
935 | ||
936 | def EVT_TREE_ITEM_ACTIVATED(win, id, func): | |
937 | win.Connect(id, -1, wxEVT_COMMAND_TREE_ITEM_ACTIVATED, func) | |
938 | ||
939 | def EVT_TREE_ITEM_RIGHT_CLICK(win, id, func): | |
940 | win.Connect(id, -1, wxEVT_COMMAND_TREE_ITEM_RIGHT_CLICK, func) | |
941 | ||
942 | def EVT_TREE_ITEM_MIDDLE_CLICK(win, id, func): | |
943 | win.Connect(id, -1, wxEVT_COMMAND_TREE_ITEM_MIDDLE_CLICK, func) | |
944 | " | |
945 | ||
946 | ||
947 | class wxTreeItemAttr | |
948 | { | |
949 | public: | |
950 | // ctors | |
951 | //wxTreeItemAttr() { } | |
952 | wxTreeItemAttr(const wxColour& colText = wxNullColour, | |
953 | const wxColour& colBack = wxNullColour, | |
954 | const wxFont& font = wxNullFont); | |
955 | ||
956 | // setters | |
957 | void SetTextColour(const wxColour& colText); | |
958 | void SetBackgroundColour(const wxColour& colBack); | |
959 | void SetFont(const wxFont& font); | |
960 | ||
961 | // accessors | |
962 | bool HasTextColour(); | |
963 | bool HasBackgroundColour(); | |
964 | bool HasFont(); | |
965 | ||
c5943253 RD |
966 | wxColour GetTextColour(); |
967 | wxColour GetBackgroundColour(); | |
968 | wxFont GetFont(); | |
00b6c4e3 RD |
969 | }; |
970 | ||
971 | ||
d5c9047a RD |
972 | class wxTreeItemId { |
973 | public: | |
974 | wxTreeItemId(); | |
975 | ~wxTreeItemId(); | |
bb0054cd | 976 | bool IsOk(); |
78e8819c | 977 | %pragma(python) addtoclass = "Ok = IsOk" |
d5c9047a | 978 | |
f6bcfd97 BP |
979 | %addmethods { |
980 | int __cmp__(wxTreeItemId* other) { | |
c368d904 | 981 | if (! other) return -1; |
f6bcfd97 BP |
982 | return *self != *other; |
983 | } | |
984 | } | |
d5c9047a RD |
985 | }; |
986 | ||
987 | ||
988 | ||
cf694132 RD |
989 | %{ |
990 | class wxPyTreeItemData : public wxTreeItemData { | |
d5c9047a | 991 | public: |
cf694132 | 992 | wxPyTreeItemData(PyObject* obj = NULL) { |
c368d904 | 993 | if (obj == NULL) |
cf694132 | 994 | obj = Py_None; |
c368d904 RD |
995 | Py_INCREF(obj); |
996 | m_obj = obj; | |
cf694132 | 997 | } |
d5c9047a | 998 | |
cf694132 | 999 | ~wxPyTreeItemData() { |
4268f798 | 1000 | wxPyBeginBlockThreads(); |
c368d904 | 1001 | Py_DECREF(m_obj); |
4268f798 | 1002 | wxPyEndBlockThreads(); |
cf694132 RD |
1003 | } |
1004 | ||
1005 | PyObject* GetData() { | |
1006 | Py_INCREF(m_obj); | |
1007 | return m_obj; | |
1008 | } | |
1009 | ||
1010 | void SetData(PyObject* obj) { | |
4268f798 | 1011 | wxPyBeginBlockThreads(); |
cf694132 | 1012 | Py_DECREF(m_obj); |
4268f798 | 1013 | wxPyEndBlockThreads(); |
cf694132 RD |
1014 | m_obj = obj; |
1015 | Py_INCREF(obj); | |
1016 | } | |
1017 | ||
1018 | PyObject* m_obj; | |
d5c9047a | 1019 | }; |
cf694132 | 1020 | %} |
d5c9047a RD |
1021 | |
1022 | ||
1023 | ||
9416aa89 | 1024 | %name(wxTreeItemData) class wxPyTreeItemData : public wxObject { |
cf694132 RD |
1025 | public: |
1026 | wxPyTreeItemData(PyObject* obj = NULL); | |
1027 | ||
1028 | PyObject* GetData(); | |
1029 | void SetData(PyObject* obj); | |
1030 | ||
1031 | const wxTreeItemId& GetId(); | |
1032 | void SetId(const wxTreeItemId& id); | |
1033 | }; | |
1034 | ||
1035 | ||
d5c9047a | 1036 | |
8bf5d46e | 1037 | class wxTreeEvent : public wxNotifyEvent { |
d5c9047a | 1038 | public: |
00b6c4e3 RD |
1039 | wxTreeEvent(wxEventType commandType = wxEVT_NULL, int id = 0); |
1040 | ||
d5c9047a RD |
1041 | wxTreeItemId GetItem(); |
1042 | wxTreeItemId GetOldItem(); | |
1043 | wxPoint GetPoint(); | |
ecc08ead | 1044 | const wxKeyEvent& GetKeyEvent(); |
d5c9047a | 1045 | int GetCode(); |
8bf5d46e | 1046 | const wxString& GetLabel(); |
d5c9047a RD |
1047 | }; |
1048 | ||
1049 | ||
f6bcfd97 | 1050 | |
09f3d4e6 | 1051 | %{ // C++ version of Python aware wxTreeCtrl |
f6bcfd97 | 1052 | class wxPyTreeCtrl : public wxTreeCtrl { |
3b36695d | 1053 | DECLARE_ABSTRACT_CLASS(wxPyTreeCtrl); |
f6bcfd97 | 1054 | public: |
09f3d4e6 | 1055 | wxPyTreeCtrl() : wxTreeCtrl() {} |
f6bcfd97 BP |
1056 | wxPyTreeCtrl(wxWindow *parent, wxWindowID id, |
1057 | const wxPoint& pos, | |
1058 | const wxSize& size, | |
1059 | long style, | |
1060 | const wxValidator& validator, | |
137b5242 | 1061 | const wxString& name) : |
f6bcfd97 BP |
1062 | wxTreeCtrl(parent, id, pos, size, style, validator, name) {} |
1063 | ||
09f3d4e6 RD |
1064 | bool Create(wxWindow *parent, wxWindowID id, |
1065 | const wxPoint& pos, | |
1066 | const wxSize& size, | |
1067 | long style, | |
1068 | const wxValidator& validator, | |
137b5242 | 1069 | const wxString& name) { |
09f3d4e6 RD |
1070 | return wxTreeCtrl::Create(parent, id, pos, size, style, validator, name); |
1071 | } | |
1072 | ||
1073 | ||
f6bcfd97 BP |
1074 | int OnCompareItems(const wxTreeItemId& item1, |
1075 | const wxTreeItemId& item2) { | |
1076 | int rval = 0; | |
19a97bd6 | 1077 | bool found; |
4268f798 | 1078 | wxPyBeginBlockThreads(); |
a66212dc RD |
1079 | if ((found = m_myInst.findCallback("OnCompareItems"))) { |
1080 | PyObject *o1 = wxPyConstructObject((void*)&item1, "wxTreeItemId"); | |
1081 | PyObject *o2 = wxPyConstructObject((void*)&item2, "wxTreeItemId"); | |
1082 | rval = m_myInst.callCallback(Py_BuildValue("(OO)",o1,o2)); | |
1083 | Py_DECREF(o1); | |
1084 | Py_DECREF(o2); | |
1085 | } | |
4268f798 | 1086 | wxPyEndBlockThreads(); |
19a97bd6 | 1087 | if (! found) |
f6bcfd97 | 1088 | rval = wxTreeCtrl::OnCompareItems(item1, item2); |
f6bcfd97 BP |
1089 | return rval; |
1090 | } | |
1091 | PYPRIVATE; | |
1092 | }; | |
1093 | ||
3b36695d RD |
1094 | IMPLEMENT_ABSTRACT_CLASS(wxPyTreeCtrl, wxTreeCtrl); |
1095 | ||
f6bcfd97 BP |
1096 | %} |
1097 | ||
d5c9047a RD |
1098 | // These are for the GetFirstChild/GetNextChild methods below |
1099 | %typemap(python, in) long& INOUT = long* INOUT; | |
1100 | %typemap(python, argout) long& INOUT = long* INOUT; | |
1101 | ||
1102 | ||
f6bcfd97 | 1103 | %name(wxTreeCtrl)class wxPyTreeCtrl : public wxControl { |
d5c9047a | 1104 | public: |
f6bcfd97 | 1105 | wxPyTreeCtrl(wxWindow *parent, wxWindowID id = -1, |
b68dc582 RD |
1106 | const wxPoint& pos = wxDefaultPosition, |
1107 | const wxSize& size = wxDefaultSize, | |
d5c9047a | 1108 | long style = wxTR_HAS_BUTTONS | wxTR_LINES_AT_ROOT, |
b68dc582 | 1109 | const wxValidator& validator = wxDefaultValidator, |
137b5242 | 1110 | const wxString& name = wxPy_TreeCtrlNameStr); |
09f3d4e6 RD |
1111 | %name(wxPreTreeCtrl)wxPyTreeCtrl(); |
1112 | ||
1113 | bool Create(wxWindow *parent, wxWindowID id = -1, | |
1114 | const wxPoint& pos = wxDefaultPosition, | |
1115 | const wxSize& size = wxDefaultSize, | |
1116 | long style = wxTR_HAS_BUTTONS | wxTR_LINES_AT_ROOT, | |
1117 | const wxValidator& validator = wxDefaultValidator, | |
137b5242 | 1118 | const wxString& name = wxPy_TreeCtrlNameStr); |
d5c9047a | 1119 | |
0122b7e3 RD |
1120 | void _setCallbackInfo(PyObject* self, PyObject* _class); |
1121 | %pragma(python) addtomethod = "__init__:self._setCallbackInfo(self, wxTreeCtrl)" | |
1122 | ||
1123 | %pragma(python) addtomethod = "__init__:self._setOORInfo(self)" | |
17c0e08c | 1124 | %pragma(python) addtomethod = "wxPreTreeCtrl:val._setOORInfo(val)" |
d5c9047a RD |
1125 | |
1126 | size_t GetCount(); | |
1127 | unsigned int GetIndent(); | |
1128 | void SetIndent(unsigned int indent); | |
1129 | wxImageList *GetImageList(); | |
1130 | wxImageList *GetStateImageList(); | |
1b62f00d | 1131 | void SetImageList(wxImageList *imageList); |
d5c9047a | 1132 | void SetStateImageList(wxImageList *imageList); |
00b6c4e3 RD |
1133 | void AssignImageList(wxImageList* imageList); |
1134 | %pragma(python) addtomethod = "AssignImageList:_args[0].thisown = 0" | |
1135 | void AssignStateImageList(wxImageList* imageList); | |
1136 | %pragma(python) addtomethod = "AssignStateImageList:_args[0].thisown = 0" | |
d5c9047a | 1137 | |
b1462dfa RD |
1138 | unsigned int GetSpacing(); |
1139 | void SetSpacing(unsigned int spacing); | |
1140 | ||
d5c9047a | 1141 | wxString GetItemText(const wxTreeItemId& item); |
694759cf RD |
1142 | int GetItemImage(const wxTreeItemId& item, |
1143 | wxTreeItemIcon which = wxTreeItemIcon_Normal); | |
d5c9047a | 1144 | int GetItemSelectedImage(const wxTreeItemId& item); |
d5c9047a RD |
1145 | |
1146 | void SetItemText(const wxTreeItemId& item, const wxString& text); | |
694759cf RD |
1147 | void SetItemImage(const wxTreeItemId& item, int image, |
1148 | wxTreeItemIcon which = wxTreeItemIcon_Normal); | |
d5c9047a | 1149 | void SetItemSelectedImage(const wxTreeItemId& item, int image); |
08127323 | 1150 | void SetItemHasChildren(const wxTreeItemId& item, bool hasChildren = TRUE); |
d5c9047a | 1151 | |
cf694132 | 1152 | %addmethods { |
c368d904 RD |
1153 | // [Get|Set]ItemData substitutes. Automatically create wxPyTreeItemData |
1154 | // if needed. | |
cf694132 RD |
1155 | wxPyTreeItemData* GetItemData(const wxTreeItemId& item) { |
1156 | wxPyTreeItemData* data = (wxPyTreeItemData*)self->GetItemData(item); | |
1157 | if (data == NULL) { | |
1158 | data = new wxPyTreeItemData(); | |
f6bcfd97 | 1159 | data->SetId(item); // set the id |
cf694132 RD |
1160 | self->SetItemData(item, data); |
1161 | } | |
1162 | return data; | |
1163 | } | |
1164 | ||
1165 | void SetItemData(const wxTreeItemId& item, wxPyTreeItemData* data) { | |
f6bcfd97 BP |
1166 | data->SetId(item); // set the id |
1167 | self->SetItemData(item, data); | |
c368d904 | 1168 | } |
cf694132 | 1169 | |
c368d904 RD |
1170 | // [Get|Set]PyData are short-cuts. Also made somewhat crash-proof by |
1171 | // automatically creating data classes. | |
1172 | PyObject* GetPyData(const wxTreeItemId& item) { | |
cf694132 RD |
1173 | wxPyTreeItemData* data = (wxPyTreeItemData*)self->GetItemData(item); |
1174 | if (data == NULL) { | |
1175 | data = new wxPyTreeItemData(); | |
f6bcfd97 | 1176 | data->SetId(item); // set the id |
cf694132 RD |
1177 | self->SetItemData(item, data); |
1178 | } | |
1179 | return data->GetData(); | |
c368d904 | 1180 | } |
cf694132 RD |
1181 | |
1182 | void SetPyData(const wxTreeItemId& item, PyObject* obj) { | |
1183 | wxPyTreeItemData* data = (wxPyTreeItemData*)self->GetItemData(item); | |
1184 | if (data == NULL) { | |
1185 | data = new wxPyTreeItemData(obj); | |
f6bcfd97 | 1186 | data->SetId(item); // set the id |
cf694132 RD |
1187 | self->SetItemData(item, data); |
1188 | } else | |
1189 | data->SetData(obj); | |
c368d904 | 1190 | } |
cf694132 RD |
1191 | } |
1192 | ||
1193 | ||
d5c9047a RD |
1194 | bool IsVisible(const wxTreeItemId& item); |
1195 | bool ItemHasChildren(const wxTreeItemId& item); | |
1196 | bool IsExpanded(const wxTreeItemId& item); | |
1197 | bool IsSelected(const wxTreeItemId& item); | |
1198 | ||
1199 | wxTreeItemId GetRootItem(); | |
1200 | wxTreeItemId GetSelection(); | |
eb715945 | 1201 | %name(GetItemParent) wxTreeItemId GetParent(const wxTreeItemId& item); |
d426c97e RD |
1202 | //size_t GetSelections(wxArrayTreeItemIds& selection); |
1203 | %addmethods { | |
1204 | PyObject* GetSelections() { | |
4268f798 | 1205 | wxPyBeginBlockThreads(); |
d426c97e RD |
1206 | PyObject* rval = PyList_New(0); |
1207 | wxArrayTreeItemIds array; | |
1208 | size_t num, x; | |
1209 | num = self->GetSelections(array); | |
1210 | for (x=0; x < num; x++) { | |
c368d904 RD |
1211 | wxTreeItemId *tii = new wxTreeItemId(array.Item(x)); |
1212 | PyObject* item = wxPyConstructObject((void*)tii, "wxTreeItemId", TRUE); | |
d426c97e RD |
1213 | PyList_Append(rval, item); |
1214 | } | |
4268f798 | 1215 | wxPyEndBlockThreads(); |
d426c97e RD |
1216 | return rval; |
1217 | } | |
1218 | } | |
1219 | ||
1220 | ||
d5c9047a | 1221 | |
bb0054cd RD |
1222 | size_t GetChildrenCount(const wxTreeItemId& item, bool recursively = TRUE); |
1223 | ||
0815db26 | 1224 | wxTreeItemId GetFirstChild(const wxTreeItemId& item, long& INOUT = longzero); |
d5c9047a RD |
1225 | wxTreeItemId GetNextChild(const wxTreeItemId& item, long& INOUT); |
1226 | wxTreeItemId GetNextSibling(const wxTreeItemId& item); | |
1227 | wxTreeItemId GetPrevSibling(const wxTreeItemId& item); | |
1228 | wxTreeItemId GetFirstVisibleItem(); | |
1229 | wxTreeItemId GetNextVisible(const wxTreeItemId& item); | |
1230 | wxTreeItemId GetPrevVisible(const wxTreeItemId& item); | |
d426c97e RD |
1231 | wxTreeItemId GetLastChild(const wxTreeItemId& item); |
1232 | ||
d5c9047a RD |
1233 | |
1234 | ||
1235 | wxTreeItemId AddRoot(const wxString& text, | |
1236 | int image = -1, int selectedImage = -1, | |
cf694132 | 1237 | wxPyTreeItemData *data = NULL); |
d5c9047a RD |
1238 | wxTreeItemId PrependItem(const wxTreeItemId& parent, |
1239 | const wxString& text, | |
1240 | int image = -1, int selectedImage = -1, | |
cf694132 | 1241 | wxPyTreeItemData *data = NULL); |
d5c9047a RD |
1242 | wxTreeItemId InsertItem(const wxTreeItemId& parent, |
1243 | const wxTreeItemId& idPrevious, | |
1244 | const wxString& text, | |
1245 | int image = -1, int selectedImage = -1, | |
cf694132 | 1246 | wxPyTreeItemData *data = NULL); |
f6bcfd97 BP |
1247 | %name(InsertItemBefore) |
1248 | wxTreeItemId InsertItem(const wxTreeItemId& parent, | |
1249 | size_t before, | |
1250 | const wxString& text, | |
1251 | int image = -1, int selectedImage = -1, | |
3999941a | 1252 | wxPyTreeItemData *data = NULL); |
d5c9047a RD |
1253 | wxTreeItemId AppendItem(const wxTreeItemId& parent, |
1254 | const wxString& text, | |
1255 | int image = -1, int selectedImage = -1, | |
cf694132 | 1256 | wxPyTreeItemData *data = NULL); |
d5c9047a RD |
1257 | |
1258 | void Delete(const wxTreeItemId& item); | |
08127323 | 1259 | void DeleteChildren(const wxTreeItemId& item); |
d5c9047a RD |
1260 | void DeleteAllItems(); |
1261 | ||
1262 | void Expand(const wxTreeItemId& item); | |
1263 | void Collapse(const wxTreeItemId& item); | |
1264 | void CollapseAndReset(const wxTreeItemId& item); | |
1265 | void Toggle(const wxTreeItemId& item); | |
1266 | ||
1267 | void Unselect(); | |
8bf5d46e | 1268 | void UnselectAll(); |
d5c9047a RD |
1269 | void SelectItem(const wxTreeItemId& item); |
1270 | void EnsureVisible(const wxTreeItemId& item); | |
1271 | void ScrollTo(const wxTreeItemId& item); | |
8bf5d46e | 1272 | #ifdef __WXMSW__ |
d5c9047a | 1273 | wxTextCtrl* EditLabel(const wxTreeItemId& item); |
d5c9047a | 1274 | wxTextCtrl* GetEditControl(); |
b1462dfa | 1275 | void EndEditLabel(const wxTreeItemId& item, int discardChanges = FALSE); |
8bf5d46e RD |
1276 | #else |
1277 | void EditLabel(const wxTreeItemId& item); | |
1278 | #endif | |
d5c9047a | 1279 | |
d426c97e | 1280 | void SortChildren(const wxTreeItemId& item); |
d5c9047a | 1281 | |
b1462dfa | 1282 | void SetItemBold(const wxTreeItemId& item, int bold = TRUE); |
b8b8dda7 | 1283 | bool IsBold(const wxTreeItemId& item) const; |
164b735b | 1284 | wxTreeItemId HitTest(const wxPoint& point, int& OUTPUT); |
c127177f | 1285 | |
f6bcfd97 BP |
1286 | |
1287 | ||
b7e72427 RD |
1288 | void SetItemTextColour(const wxTreeItemId& item, const wxColour& col); |
1289 | void SetItemBackgroundColour(const wxTreeItemId& item, const wxColour& col); | |
1290 | void SetItemFont(const wxTreeItemId& item, const wxFont& font); | |
1291 | ||
4120ef2b | 1292 | #ifdef __WXMSW__ |
b1462dfa | 1293 | void SetItemDropHighlight(const wxTreeItemId& item, int highlight = TRUE); |
74bcba0e | 1294 | #endif |
b1462dfa | 1295 | |
d426c97e RD |
1296 | //bool GetBoundingRect(const wxTreeItemId& item, wxRect& rect, int textOnly = FALSE) |
1297 | %addmethods { | |
1298 | PyObject* GetBoundingRect(const wxTreeItemId& item, int textOnly = FALSE) { | |
1299 | wxRect rect; | |
164b735b | 1300 | if (self->GetBoundingRect(item, rect, textOnly)) { |
4268f798 | 1301 | wxPyBeginBlockThreads(); |
164b735b RD |
1302 | wxRect* r = new wxRect(rect); |
1303 | PyObject* val = wxPyConstructObject((void*)r, "wxRect"); | |
4268f798 | 1304 | wxPyEndBlockThreads(); |
164b735b RD |
1305 | return val; |
1306 | } | |
d426c97e RD |
1307 | else { |
1308 | Py_INCREF(Py_None); | |
1309 | return Py_None; | |
1310 | } | |
1311 | } | |
1312 | } | |
74bcba0e | 1313 | |
d426c97e | 1314 | |
c127177f | 1315 | %pragma(python) addtoclass = " |
f6bcfd97 BP |
1316 | # Redefine some methods that SWIG gets a bit confused on... |
1317 | def GetFirstChild(self, *_args, **_kwargs): | |
1318 | val1,val2 = apply(controls2c.wxTreeCtrl_GetFirstChild,(self,) + _args, _kwargs) | |
1319 | val1 = wxTreeItemIdPtr(val1) | |
1320 | val1.thisown = 1 | |
1321 | return (val1,val2) | |
1322 | def GetNextChild(self, *_args, **_kwargs): | |
1323 | val1,val2 = apply(controls2c.wxTreeCtrl_GetNextChild,(self,) + _args, _kwargs) | |
c127177f RD |
1324 | val1 = wxTreeItemIdPtr(val1) |
1325 | val1.thisown = 1 | |
1326 | return (val1,val2) | |
f6bcfd97 BP |
1327 | def HitTest(self, *_args, **_kwargs): |
1328 | val1, val2 = apply(controls2c.wxTreeCtrl_HitTest,(self,) + _args, _kwargs) | |
c127177f RD |
1329 | val1 = wxTreeItemIdPtr(val1) |
1330 | val1.thisown = 1 | |
1331 | return (val1,val2) | |
1332 | " | |
74bcba0e | 1333 | |
d5c9047a RD |
1334 | }; |
1335 | ||
d5c9047a | 1336 | |
7bf85405 RD |
1337 | //---------------------------------------------------------------------- |
1338 | ||
68320e40 RD |
1339 | |
1340 | enum { | |
1341 | wxDIRCTRL_DIR_ONLY, | |
1342 | wxDIRCTRL_SELECT_FIRST, | |
1343 | wxDIRCTRL_SHOW_FILTERS, | |
1344 | wxDIRCTRL_3D_INTERNAL, | |
7cdaed0b | 1345 | wxDIRCTRL_EDIT_LABELS, |
db0ff83e RD |
1346 | |
1347 | wxID_TREECTRL, | |
1348 | wxID_FILTERLISTCTRL, | |
68320e40 RD |
1349 | }; |
1350 | ||
1351 | ||
1352 | class wxDirItemData : public wxObject // wxTreeItemData | |
1353 | { | |
1354 | public: | |
1355 | wxDirItemData(const wxString& path, const wxString& name, bool isDir); | |
1356 | // ~wxDirItemDataEx(); | |
1357 | void SetNewDirName( wxString path ); | |
1358 | wxString m_path, m_name; | |
1359 | bool m_isHidden; | |
1360 | bool m_isExpanded; | |
1361 | bool m_isDir; | |
1362 | }; | |
1363 | ||
1364 | ||
1365 | class wxGenericDirCtrl: public wxControl | |
1366 | { | |
1367 | public: | |
1368 | wxGenericDirCtrl(wxWindow *parent, const wxWindowID id = -1, | |
137b5242 | 1369 | const wxString& dir = wxPyDirDialogDefaultFolderStr, |
68320e40 RD |
1370 | const wxPoint& pos = wxDefaultPosition, |
1371 | const wxSize& size = wxDefaultSize, | |
1372 | long style = wxDIRCTRL_3D_INTERNAL|wxSUNKEN_BORDER, | |
137b5242 | 1373 | const wxString& filter = wxPyEmptyString, |
68320e40 | 1374 | int defaultFilter = 0, |
137b5242 | 1375 | const wxString& name = wxPy_TreeCtrlNameStr); |
68320e40 RD |
1376 | %name(wxPreGenericDirCtrl)wxGenericDirCtrl(); |
1377 | ||
1378 | %pragma(python) addtomethod = "__init__:self._setOORInfo(self)" | |
1379 | %pragma(python) addtomethod = "wxPreGenericDirCtrl:val._setOORInfo(val)" | |
1380 | ||
1381 | bool Create(wxWindow *parent, const wxWindowID id = -1, | |
137b5242 | 1382 | const wxString& dir = wxPyDirDialogDefaultFolderStr, |
68320e40 RD |
1383 | const wxPoint& pos = wxDefaultPosition, |
1384 | const wxSize& size = wxDefaultSize, | |
1385 | long style = wxDIRCTRL_3D_INTERNAL|wxSUNKEN_BORDER, | |
137b5242 | 1386 | const wxString& filter = wxPyEmptyString, |
68320e40 | 1387 | int defaultFilter = 0, |
137b5242 | 1388 | const wxString& name = wxPy_TreeCtrlNameStr); |
68320e40 RD |
1389 | |
1390 | ||
1391 | // Try to expand as much of the given path as possible. | |
1392 | bool ExpandPath(const wxString& path); | |
1393 | ||
1394 | // Accessors | |
1395 | ||
1396 | inline wxString GetDefaultPath() const; | |
1397 | void SetDefaultPath(const wxString& path); | |
1398 | ||
1399 | // Get dir or filename | |
1400 | wxString GetPath() const ; | |
1401 | ||
1402 | // Get selected filename path only (else empty string). | |
1403 | // I.e. don't count a directory as a selection | |
1404 | wxString GetFilePath() const ; | |
1405 | void SetPath(const wxString& path) ; | |
1406 | ||
1407 | void ShowHidden( bool show ); | |
1408 | bool GetShowHidden(); | |
1409 | ||
1410 | wxString GetFilter() const; | |
1411 | void SetFilter(const wxString& filter); | |
1412 | ||
1413 | int GetFilterIndex() const; | |
1414 | void SetFilterIndex(int n) ; | |
1415 | ||
1416 | wxTreeItemId GetRootId(); | |
1417 | ||
1418 | wxTreeCtrl* GetTreeCtrl() const; | |
1419 | wxDirFilterListCtrl* GetFilterListCtrl() const; | |
1420 | ||
1421 | // //// Helpers | |
1422 | // void SetupSections(); | |
1423 | // // Parse the filter into an array of filters and an array of descriptions | |
1424 | // int ParseFilter(const wxString& filterStr, wxArrayString& filters, wxArrayString& descriptions); | |
1425 | // // Find the child that matches the first part of 'path'. | |
1426 | // // E.g. if a child path is "/usr" and 'path' is "/usr/include" | |
1427 | // // then the child for /usr is returned. | |
1428 | // // If the path string has been used (we're at the leaf), done is set to TRUE | |
1429 | // wxTreeItemId FindChild(wxTreeItemId parentId, const wxString& path, bool& done); | |
1430 | }; | |
1431 | ||
1432 | ||
1433 | class wxDirFilterListCtrl: public wxChoice | |
1434 | { | |
1435 | public: | |
1436 | wxDirFilterListCtrl(wxGenericDirCtrl* parent, const wxWindowID id = -1, | |
1437 | const wxPoint& pos = wxDefaultPosition, | |
1438 | const wxSize& size = wxDefaultSize, | |
1439 | long style = 0); | |
1440 | %name(wxPreDirFilterListCtrl)wxDirFilterListCtrl(); | |
1441 | ||
1442 | %pragma(python) addtomethod = "__init__:self._setOORInfo(self)" | |
1443 | %pragma(python) addtomethod = "wxPreDirFilterListCtrl:val._setOORInfo(val)" | |
1444 | ||
1445 | bool Create(wxGenericDirCtrl* parent, const wxWindowID id = -1, | |
1446 | const wxPoint& pos = wxDefaultPosition, | |
1447 | const wxSize& size = wxDefaultSize, | |
1448 | long style = 0); | |
1449 | ||
1450 | //// Operations | |
1451 | void FillFilterList(const wxString& filter, int defaultFilter); | |
1452 | }; | |
1453 | ||
1454 | ||
1455 | //---------------------------------------------------------------------- | |
1456 | //---------------------------------------------------------------------- | |
1457 | ||
9416aa89 | 1458 | %init %{ |
a3fbed81 | 1459 | // Map renamed classes back to their common name for OOR |
9416aa89 RD |
1460 | wxPyPtrTypeMap_Add("wxTreeItemData", "wxPyTreeItemData"); |
1461 | wxPyPtrTypeMap_Add("wxTreeCtrl", "wxPyTreeCtrl"); | |
a3fbed81 | 1462 | wxPyPtrTypeMap_Add("wxListCtrl", "wxPyListCtrl"); |
9416aa89 RD |
1463 | %} |
1464 | ||
1465 | //---------------------------------------------------------------------- | |
1466 | ||
7bf85405 | 1467 |