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