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