]>
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> |
7bf85405 RD |
23 | %} |
24 | ||
25 | //---------------------------------------------------------------------- | |
26 | ||
27 | %include typemaps.i | |
28 | %include my_typemaps.i | |
29 | ||
30 | // Import some definitions of other classes, etc. | |
31 | %import _defs.i | |
32 | %import misc.i | |
33 | %import windows.i | |
34 | %import gdi.i | |
35 | %import events.i | |
36 | %import controls.i | |
37 | ||
b8b8dda7 | 38 | %pragma(python) code = "import wx" |
9c039d08 | 39 | |
c7e7022c RD |
40 | |
41 | //---------------------------------------------------------------------- | |
7bf85405 RD |
42 | //---------------------------------------------------------------------- |
43 | ||
c7e7022c RD |
44 | enum { |
45 | /* List control event types */ | |
46 | wxEVT_COMMAND_LIST_BEGIN_DRAG, | |
47 | wxEVT_COMMAND_LIST_BEGIN_RDRAG, | |
48 | wxEVT_COMMAND_LIST_BEGIN_LABEL_EDIT, | |
49 | wxEVT_COMMAND_LIST_END_LABEL_EDIT, | |
50 | wxEVT_COMMAND_LIST_DELETE_ITEM, | |
51 | wxEVT_COMMAND_LIST_DELETE_ALL_ITEMS, | |
52 | wxEVT_COMMAND_LIST_GET_INFO, | |
53 | wxEVT_COMMAND_LIST_SET_INFO, | |
54 | wxEVT_COMMAND_LIST_ITEM_SELECTED, | |
55 | wxEVT_COMMAND_LIST_ITEM_DESELECTED, | |
56 | wxEVT_COMMAND_LIST_KEY_DOWN, | |
57 | wxEVT_COMMAND_LIST_INSERT_ITEM, | |
58 | wxEVT_COMMAND_LIST_COL_CLICK, | |
59 | wxEVT_COMMAND_LIST_ITEM_RIGHT_CLICK, | |
60 | wxEVT_COMMAND_LIST_ITEM_MIDDLE_CLICK, | |
61 | wxEVT_COMMAND_LIST_ITEM_ACTIVATED, | |
62 | wxEVT_COMMAND_LIST_CACHE_HINT, | |
63 | }; | |
64 | ||
65 | ||
66 | %pragma(python) code = " | |
67 | def EVT_LIST_BEGIN_DRAG(win, id, func): | |
68 | win.Connect(id, -1, wxEVT_COMMAND_LIST_BEGIN_DRAG, func) | |
69 | ||
70 | def EVT_LIST_BEGIN_RDRAG(win, id, func): | |
71 | win.Connect(id, -1, wxEVT_COMMAND_LIST_BEGIN_RDRAG, func) | |
72 | ||
73 | def EVT_LIST_BEGIN_LABEL_EDIT(win, id, func): | |
74 | win.Connect(id, -1, wxEVT_COMMAND_LIST_BEGIN_LABEL_EDIT, func) | |
75 | ||
76 | def EVT_LIST_END_LABEL_EDIT(win, id, func): | |
77 | win.Connect(id, -1, wxEVT_COMMAND_LIST_END_LABEL_EDIT, func) | |
78 | ||
79 | def EVT_LIST_DELETE_ITEM(win, id, func): | |
80 | win.Connect(id, -1, wxEVT_COMMAND_LIST_DELETE_ITEM, func) | |
81 | ||
82 | def EVT_LIST_DELETE_ALL_ITEMS(win, id, func): | |
83 | win.Connect(id, -1, wxEVT_COMMAND_LIST_DELETE_ALL_ITEMS, func) | |
84 | ||
85 | def EVT_LIST_GET_INFO(win, id, func): | |
86 | win.Connect(id, -1, wxEVT_COMMAND_LIST_GET_INFO, func) | |
87 | ||
88 | def EVT_LIST_SET_INFO(win, id, func): | |
89 | win.Connect(id, -1, wxEVT_COMMAND_LIST_SET_INFO, func) | |
90 | ||
91 | def EVT_LIST_ITEM_SELECTED(win, id, func): | |
92 | win.Connect(id, -1, wxEVT_COMMAND_LIST_ITEM_SELECTED, func) | |
93 | ||
94 | def EVT_LIST_ITEM_DESELECTED(win, id, func): | |
95 | win.Connect(id, -1, wxEVT_COMMAND_LIST_ITEM_DESELECTED, func) | |
96 | ||
97 | def EVT_LIST_KEY_DOWN(win, id, func): | |
98 | win.Connect(id, -1, wxEVT_COMMAND_LIST_KEY_DOWN, func) | |
99 | ||
100 | def EVT_LIST_INSERT_ITEM(win, id, func): | |
101 | win.Connect(id, -1, wxEVT_COMMAND_LIST_INSERT_ITEM, func) | |
102 | ||
103 | def EVT_LIST_COL_CLICK(win, id, func): | |
104 | win.Connect(id, -1, wxEVT_COMMAND_LIST_COL_CLICK, func) | |
105 | ||
106 | def EVT_LIST_ITEM_RIGHT_CLICK(win, id, func): | |
107 | win.Connect(id, -1, wxEVT_COMMAND_LIST_ITEM_RIGHT_CLICK, func) | |
108 | ||
109 | def EVT_LIST_ITEM_MIDDLE_CLICK(win, id, func): | |
110 | win.Connect(id, -1, wxEVT_COMMAND_LIST_ITEM_MIDDLE_CLICK, func) | |
111 | ||
112 | def EVT_LIST_ITEM_ACTIVATED(win, id, func): | |
113 | win.Connect(id, -1, wxEVT_COMMAND_LIST_ITEM_ACTIVATED, func) | |
114 | ||
115 | def EVT_LIST_CACHE_HINT(win, id, func): | |
116 | win.Connect(id, -1, wxEVT_COMMAND_LIST_CACHE_HINT, func) | |
117 | " | |
118 | ||
7bf85405 | 119 | |
af309447 | 120 | enum { |
c7e7022c RD |
121 | /* Style flags */ |
122 | wxLC_VRULES, | |
123 | wxLC_HRULES, | |
124 | ||
125 | wxLC_ICON, | |
126 | wxLC_SMALL_ICON, | |
127 | wxLC_LIST, | |
128 | wxLC_REPORT, | |
129 | ||
130 | wxLC_ALIGN_TOP, | |
131 | wxLC_ALIGN_LEFT, | |
132 | wxLC_AUTOARRANGE, | |
133 | wxLC_VIRTUAL, | |
134 | wxLC_EDIT_LABELS, | |
135 | wxLC_NO_HEADER, | |
136 | wxLC_NO_SORT_HEADER, | |
137 | wxLC_SINGLE_SEL, | |
138 | wxLC_SORT_ASCENDING, | |
139 | wxLC_SORT_DESCENDING, | |
140 | ||
141 | wxLC_MASK_TYPE, | |
142 | wxLC_MASK_ALIGN, | |
143 | wxLC_MASK_SORT, | |
144 | ||
145 | }; | |
146 | ||
147 | ||
148 | enum { | |
149 | // Mask flags | |
150 | wxLIST_MASK_STATE, | |
af309447 RD |
151 | wxLIST_MASK_TEXT, |
152 | wxLIST_MASK_IMAGE, | |
153 | wxLIST_MASK_DATA, | |
c7e7022c | 154 | wxLIST_SET_ITEM, |
af309447 RD |
155 | wxLIST_MASK_WIDTH, |
156 | wxLIST_MASK_FORMAT, | |
c7e7022c RD |
157 | |
158 | // State flags | |
af309447 RD |
159 | wxLIST_STATE_DONTCARE, |
160 | wxLIST_STATE_DROPHILITED, | |
161 | wxLIST_STATE_FOCUSED, | |
162 | wxLIST_STATE_SELECTED, | |
163 | wxLIST_STATE_CUT, | |
c7e7022c RD |
164 | |
165 | // Hit test flags | |
af309447 RD |
166 | wxLIST_HITTEST_ABOVE, |
167 | wxLIST_HITTEST_BELOW, | |
168 | wxLIST_HITTEST_NOWHERE, | |
169 | wxLIST_HITTEST_ONITEMICON, | |
170 | wxLIST_HITTEST_ONITEMLABEL, | |
171 | wxLIST_HITTEST_ONITEMRIGHT, | |
172 | wxLIST_HITTEST_ONITEMSTATEICON, | |
173 | wxLIST_HITTEST_TOLEFT, | |
174 | wxLIST_HITTEST_TORIGHT, | |
175 | wxLIST_HITTEST_ONITEM, | |
c7e7022c RD |
176 | |
177 | // Flags for GetNextItem | |
af309447 RD |
178 | wxLIST_NEXT_ABOVE, |
179 | wxLIST_NEXT_ALL, | |
180 | wxLIST_NEXT_BELOW, | |
181 | wxLIST_NEXT_LEFT, | |
182 | wxLIST_NEXT_RIGHT, | |
c7e7022c RD |
183 | |
184 | // Alignment flags | |
af309447 RD |
185 | wxLIST_ALIGN_DEFAULT, |
186 | wxLIST_ALIGN_LEFT, | |
187 | wxLIST_ALIGN_TOP, | |
188 | wxLIST_ALIGN_SNAP_TO_GRID, | |
c7e7022c RD |
189 | |
190 | // Autosize values for SetColumnWidth | |
191 | wxLIST_AUTOSIZE = -1, | |
192 | wxLIST_AUTOSIZE_USEHEADER = -2, | |
193 | ||
194 | // Flag values for GetItemRect | |
af309447 RD |
195 | wxLIST_RECT_BOUNDS, |
196 | wxLIST_RECT_ICON, | |
197 | wxLIST_RECT_LABEL, | |
c7e7022c RD |
198 | |
199 | // Flag values for FindItem (MSW only) | |
af309447 RD |
200 | wxLIST_FIND_UP, |
201 | wxLIST_FIND_DOWN, | |
202 | wxLIST_FIND_LEFT, | |
203 | wxLIST_FIND_RIGHT, | |
c7e7022c RD |
204 | |
205 | ||
af309447 RD |
206 | }; |
207 | ||
208 | ||
c7e7022c | 209 | |
f6bcfd97 BP |
210 | enum wxListColumnFormat |
211 | { | |
212 | wxLIST_FORMAT_LEFT, | |
213 | wxLIST_FORMAT_RIGHT, | |
214 | wxLIST_FORMAT_CENTRE, | |
215 | wxLIST_FORMAT_CENTER = wxLIST_FORMAT_CENTRE | |
216 | }; | |
217 | ||
218 | ||
1b62f00d RD |
219 | |
220 | ||
f6bcfd97 BP |
221 | class wxListItemAttr |
222 | { | |
223 | public: | |
224 | // ctors | |
c7e7022c RD |
225 | //wxListItemAttr(); |
226 | wxListItemAttr(const wxColour& colText = wxNullColour, | |
227 | const wxColour& colBack = wxNullColour, | |
228 | const wxFont& font = wxNullFont); | |
229 | ||
f6bcfd97 BP |
230 | |
231 | // setters | |
232 | void SetTextColour(const wxColour& colText); | |
233 | void SetBackgroundColour(const wxColour& colBack); | |
234 | void SetFont(const wxFont& font); | |
235 | ||
236 | // accessors | |
237 | bool HasTextColour(); | |
238 | bool HasBackgroundColour(); | |
239 | bool HasFont(); | |
240 | ||
241 | const wxColour& GetTextColour(); | |
242 | const wxColour& GetBackgroundColour(); | |
243 | const wxFont& GetFont(); | |
244 | }; | |
245 | ||
246 | ||
9416aa89 | 247 | class wxListItem : public wxObject { |
7bf85405 | 248 | public: |
f6bcfd97 BP |
249 | wxListItem(); |
250 | ~wxListItem(); | |
251 | ||
252 | // resetting | |
253 | void Clear(); | |
254 | void ClearAttributes(); | |
255 | ||
256 | // setters | |
257 | void SetMask(long mask); | |
258 | void SetId(long id); | |
259 | void SetColumn(int col); | |
260 | void SetState(long state); | |
261 | void SetStateMask(long stateMask); | |
262 | void SetText(const wxString& text); | |
263 | void SetImage(int image); | |
264 | void SetData(long data); | |
265 | ||
266 | void SetWidth(int width); | |
267 | void SetAlign(wxListColumnFormat align); | |
268 | ||
269 | void SetTextColour(const wxColour& colText); | |
270 | void SetBackgroundColour(const wxColour& colBack); | |
271 | void SetFont(const wxFont& font); | |
272 | ||
273 | // accessors | |
274 | long GetMask(); | |
275 | long GetId(); | |
276 | int GetColumn(); | |
277 | long GetState(); | |
278 | const wxString& GetText(); | |
279 | int GetImage(); | |
280 | long GetData(); | |
281 | ||
282 | int GetWidth(); | |
283 | wxListColumnFormat GetAlign(); | |
284 | ||
285 | wxListItemAttr *GetAttributes(); | |
286 | bool HasAttributes(); | |
287 | ||
288 | wxColour GetTextColour() const; | |
289 | wxColour GetBackgroundColour() const; | |
290 | wxFont GetFont() const; | |
291 | ||
292 | // these members are public for compatibility | |
7bf85405 RD |
293 | long m_mask; // Indicates what fields are valid |
294 | long m_itemId; // The zero-based item position | |
295 | int m_col; // Zero-based column, if in report mode | |
296 | long m_state; // The state of the item | |
f6bcfd97 | 297 | long m_stateMask;// Which flags of m_state are valid (uses same flags) |
7bf85405 RD |
298 | wxString m_text; // The label/header text |
299 | int m_image; // The zero-based index into an image list | |
300 | long m_data; // App-defined data | |
7bf85405 RD |
301 | |
302 | // For columns only | |
303 | int m_format; // left, right, centre | |
304 | int m_width; // width of column | |
305 | ||
7bf85405 RD |
306 | }; |
307 | ||
f6bcfd97 | 308 | |
c368d904 | 309 | class wxListEvent: public wxNotifyEvent { |
7bf85405 RD |
310 | public: |
311 | int m_code; | |
312 | long m_itemIndex; | |
313 | long m_oldItemIndex; | |
314 | int m_col; | |
315 | bool m_cancelled; | |
316 | wxPoint m_pointDrag; | |
317 | wxListItem m_item; | |
7bf85405 | 318 | |
f6bcfd97 BP |
319 | int GetCode(); |
320 | long GetIndex(); | |
321 | long GetOldIndex(); | |
322 | long GetOldItem(); | |
323 | int GetColumn(); | |
324 | bool Cancelled(); | |
325 | wxPoint GetPoint(); | |
326 | const wxString& GetLabel(); | |
327 | const wxString& GetText(); | |
328 | int GetImage(); | |
329 | long GetData(); | |
330 | long GetMask(); | |
331 | const wxListItem& GetItem(); | |
332 | }; | |
7bf85405 RD |
333 | |
334 | ||
c7e7022c RD |
335 | %{ |
336 | class wxPyListCtrl : public wxListCtrl { | |
337 | DECLARE_ABSTRACT_CLASS(wxPyListCtrl); | |
7bf85405 | 338 | public: |
c7e7022c RD |
339 | wxPyListCtrl(wxWindow* parent, wxWindowID id, |
340 | const wxPoint& pos, | |
341 | const wxSize& size, | |
342 | long style, | |
343 | const wxValidator& validator, | |
344 | char* name) : | |
345 | wxListCtrl(parent, id, pos, size, style, validator, name) {} | |
346 | ||
347 | DEC_PYCALLBACK_STRING_LONGLONG(OnGetItemText); | |
348 | DEC_PYCALLBACK_INT_LONG(OnGetItemImage); | |
349 | DEC_PYCALLBACK_LISTATTR_LONG(OnGetItemAttr); | |
350 | ||
351 | PYPRIVATE; | |
352 | }; | |
353 | ||
354 | IMPLEMENT_ABSTRACT_CLASS(wxPyListCtrl, wxListCtrl); | |
7bf85405 | 355 | |
c7e7022c RD |
356 | IMP_PYCALLBACK_STRING_LONGLONG(wxPyListCtrl, wxListCtrl, OnGetItemText); |
357 | IMP_PYCALLBACK_INT_LONG(wxPyListCtrl, wxListCtrl, OnGetItemImage); | |
358 | IMP_PYCALLBACK_LISTATTR_LONG(wxPyListCtrl, wxListCtrl, OnGetItemAttr); | |
359 | %} | |
360 | ||
361 | ||
362 | %name(wxListCtrl)class wxPyListCtrl : public wxControl { | |
363 | public: | |
364 | wxPyListCtrl(wxWindow* parent, wxWindowID id = -1, | |
365 | const wxPoint& pos = wxDefaultPosition, | |
366 | const wxSize& size = wxDefaultSize, | |
367 | long style = wxLC_ICON, | |
368 | const wxValidator& validator = wxDefaultValidator, | |
369 | char* name = "listCtrl"); | |
370 | ||
371 | void _setSelf(PyObject* self, PyObject* _class); | |
f6bcfd97 | 372 | %pragma(python) addtomethod = "__init__:#wx._StdWindowCallbacks(self)" |
c7e7022c | 373 | %pragma(python) addtomethod = "__init__:self._setSelf(self, wxListCtrl)" |
9c039d08 | 374 | |
7bf85405 | 375 | |
c7e7022c RD |
376 | // Set the control colours |
377 | bool SetForegroundColour(const wxColour& col); | |
378 | bool SetBackgroundColour(const wxColour& col); | |
379 | ||
380 | // Gets information about this column | |
381 | bool GetColumn(int col, wxListItem& item) const; | |
382 | ||
383 | // Sets information about this column | |
384 | bool SetColumn(int col, wxListItem& item) ; | |
385 | ||
386 | // Gets the column width | |
387 | int GetColumnWidth(int col) const; | |
388 | ||
389 | // Sets the column width | |
390 | bool SetColumnWidth(int col, int width) ; | |
391 | ||
392 | // Gets the number of items that can fit vertically in the | |
393 | // visible area of the list control (list or report view) | |
394 | // or the total number of items in the list control (icon | |
395 | // or small icon view) | |
396 | int GetCountPerPage() const; | |
397 | ||
cd096152 | 398 | #ifdef __WXMSW__ |
c7e7022c RD |
399 | // Gets the edit control for editing labels. |
400 | wxTextCtrl* GetEditControl() const; | |
cd096152 | 401 | #endif |
c7e7022c RD |
402 | |
403 | //bool GetItem(wxListItem& info) const ; | |
7bf85405 | 404 | %addmethods { |
c7e7022c | 405 | // Gets information about the item |
e166644c | 406 | %new wxListItem* GetItem(long itemId, int col=0) { |
7bf85405 | 407 | wxListItem* info = new wxListItem; |
0699c864 | 408 | info->m_itemId = itemId; |
e166644c | 409 | info->m_col = col; |
f17fee68 | 410 | info->m_mask = 0xFFFF; |
7bf85405 RD |
411 | self->GetItem(*info); |
412 | return info; | |
413 | } | |
5597b61e RD |
414 | } // The OOR typemaps don't know what to do with the %new, so fix it up. |
415 | %pragma(python) addtoclass = " | |
416 | def GetItem(self, *_args, **_kwargs): | |
417 | val = apply(controls2c.wxListCtrl_GetItem,(self,) + _args, _kwargs) | |
418 | val.thisown = 1 | |
419 | return val | |
420 | " | |
421 | ||
c7e7022c RD |
422 | |
423 | // Sets information about the item | |
424 | bool SetItem(wxListItem& info) ; | |
425 | ||
426 | // Sets a string field at a particular column | |
427 | %name(SetStringItem)long SetItem(long index, int col, const wxString& label, int imageId = -1); | |
428 | ||
429 | // Gets the item state | |
430 | int GetItemState(long item, long stateMask) const ; | |
431 | ||
432 | // Sets the item state | |
433 | bool SetItemState(long item, long state, long stateMask) ; | |
434 | ||
435 | // Sets the item image | |
436 | bool SetItemImage(long item, int image, int selImage) ; | |
437 | ||
438 | // Gets the item text | |
439 | wxString GetItemText(long item) const ; | |
440 | ||
441 | // Sets the item text | |
442 | void SetItemText(long item, const wxString& str) ; | |
443 | ||
444 | // Gets the item data | |
445 | long GetItemData(long item) const ; | |
446 | ||
447 | // Sets the item data | |
448 | bool SetItemData(long item, long data) ; | |
449 | ||
450 | ||
451 | //bool GetItemRect(long item, wxRect& rect, int code = wxLIST_RECT_BOUNDS) const ; | |
452 | //bool GetItemPosition(long item, wxPoint& pos) const ; | |
5597b61e | 453 | %addmethods { |
c7e7022c | 454 | // Gets the item position |
7bf85405 RD |
455 | %new wxPoint* GetItemPosition(long item) { |
456 | wxPoint* pos = new wxPoint; | |
457 | self->GetItemPosition(item, *pos); | |
458 | return pos; | |
459 | } | |
c7e7022c | 460 | // Gets the item rectangle |
7bf85405 RD |
461 | %new wxRect* GetItemRect(long item, int code = wxLIST_RECT_BOUNDS) { |
462 | wxRect* rect= new wxRect; | |
463 | self->GetItemRect(item, *rect, code); | |
464 | return rect; | |
465 | } | |
466 | } | |
467 | ||
c7e7022c RD |
468 | |
469 | // Sets the item position | |
470 | bool SetItemPosition(long item, const wxPoint& pos) ; | |
471 | ||
472 | // Gets the number of items in the list control | |
473 | int GetItemCount() const; | |
474 | ||
475 | // Gets the number of columns in the list control | |
476 | int GetColumnCount() const { return m_colCount; } | |
477 | ||
478 | // Retrieves the spacing between icons in pixels. | |
479 | // If small is TRUE, gets the spacing for the small icon | |
480 | // view, otherwise the large icon view. | |
481 | int GetItemSpacing(bool isSmall) const; | |
482 | ||
483 | // Gets the number of selected items in the list control | |
484 | int GetSelectedItemCount() const; | |
485 | ||
486 | // Gets the text colour of the listview | |
487 | wxColour GetTextColour() const; | |
488 | ||
489 | // Sets the text colour of the listview | |
4f22cf8d | 490 | void SetTextColour(const wxColour& col); |
c7e7022c RD |
491 | |
492 | // Gets the index of the topmost visible item when in | |
493 | // list or report view | |
494 | long GetTopItem() const ; | |
495 | ||
496 | // Add or remove a single window style | |
497 | void SetSingleStyle(long style, bool add = TRUE) ; | |
498 | ||
499 | // Set the whole window style | |
500 | void SetWindowStyleFlag(long style) ; | |
501 | ||
502 | // Searches for an item, starting from 'item'. | |
503 | // item can be -1 to find the first item that matches the | |
504 | // specified flags. | |
505 | // Returns the item or -1 if unsuccessful. | |
506 | long GetNextItem(long item, int geometry = wxLIST_NEXT_ALL, int state = wxLIST_STATE_DONTCARE) const ; | |
507 | ||
508 | // Gets one of the three image lists | |
509 | wxImageList *GetImageList(int which) const ; | |
510 | ||
511 | // Sets the image list | |
512 | void SetImageList(wxImageList *imageList, int which) ; | |
513 | void AssignImageList(wxImageList *imageList, int which) ; | |
514 | %pragma(python) addtomethod = "AssignImageList:_args[0].thisown = 0" | |
515 | ||
516 | // returns true if it is a virtual list control | |
517 | bool IsVirtual() const; | |
518 | ||
519 | // refresh items selectively (only useful for virtual list controls) | |
520 | void RefreshItem(long item); | |
521 | void RefreshItems(long itemFrom, long itemTo); | |
522 | ||
523 | ||
524 | ||
525 | ||
526 | // Arranges the items | |
527 | bool Arrange(int flag = wxLIST_ALIGN_DEFAULT); | |
528 | ||
529 | // Deletes an item | |
530 | bool DeleteItem(long item); | |
531 | ||
532 | // Deletes all items | |
533 | bool DeleteAllItems() ; | |
534 | ||
535 | // Deletes a column | |
536 | bool DeleteColumn(int col); | |
537 | ||
538 | // Deletes all columns | |
539 | bool DeleteAllColumns(); | |
540 | ||
541 | // Clears items, and columns if there are any. | |
542 | void ClearAll(); | |
543 | ||
cd096152 | 544 | #ifdef __WXMSW__ |
c7e7022c RD |
545 | // Edit the label |
546 | wxTextCtrl* EditLabel(long item /*, wxClassInfo* textControlClass = CLASSINFO(wxTextCtrl)*/); | |
547 | ||
548 | // End label editing, optionally cancelling the edit | |
549 | bool EndEditLabel(bool cancel); | |
cd096152 | 550 | #endif |
c7e7022c RD |
551 | |
552 | // Ensures this item is visible | |
553 | bool EnsureVisible(long item) ; | |
554 | ||
555 | // Find an item whose label matches this string, starting from the item after 'start' | |
556 | // or the beginning if 'start' is -1. | |
557 | long FindItem(long start, const wxString& str, bool partial = FALSE); | |
558 | ||
559 | // Find an item whose data matches this data, starting from the item after 'start' | |
560 | // or the beginning if 'start' is -1. | |
561 | %name(FindItemData)long FindItem(long start, long data); | |
562 | ||
563 | // Find an item nearest this position in the specified direction, starting from | |
564 | // the item after 'start' or the beginning if 'start' is -1. | |
565 | %name(FindItemAtPos)long FindItem(long start, const wxPoint& pt, int direction); | |
566 | ||
567 | // Determines which item (if any) is at the specified point, | |
568 | // giving details in the second return value (see wxLIST_HITTEST_... flags above) | |
7bf85405 | 569 | long HitTest(const wxPoint& point, int& OUTPUT); |
c7e7022c RD |
570 | |
571 | // Inserts an item, returning the index of the new item if successful, | |
572 | // -1 otherwise. | |
573 | long InsertItem(wxListItem& info); | |
574 | ||
575 | // Insert a string item | |
576 | %name(InsertStringItem)long InsertItem(long index, const wxString& label); | |
577 | ||
578 | // Insert an image item | |
579 | %name(InsertImageItem)long InsertItem(long index, int imageIndex); | |
580 | ||
581 | // Insert an image/string item | |
582 | %name(InsertImageStringItem)long InsertItem(long index, const wxString& label, int imageIndex); | |
583 | ||
584 | // For list view mode (only), inserts a column. | |
c368d904 | 585 | %name(InsertColumnInfo)long InsertColumn(long col, wxListItem& info); |
c7e7022c RD |
586 | |
587 | long InsertColumn(long col, | |
588 | const wxString& heading, | |
7bf85405 RD |
589 | int format = wxLIST_FORMAT_LEFT, |
590 | int width = -1); | |
591 | ||
c7e7022c RD |
592 | // set the number of items in a virtual list control |
593 | void SetItemCount(long count); | |
7bf85405 | 594 | |
c7e7022c RD |
595 | // Scrolls the list control. If in icon, small icon or report view mode, |
596 | // x specifies the number of pixels to scroll. If in list view mode, x | |
597 | // specifies the number of columns to scroll. | |
598 | // If in icon, small icon or list view mode, y specifies the number of pixels | |
599 | // to scroll. If in report view mode, y specifies the number of lines to scroll. | |
7bf85405 | 600 | bool ScrollList(int dx, int dy); |
dcd38683 RD |
601 | |
602 | // bool SortItems(wxListCtrlCompare fn, long data); | |
603 | %addmethods { | |
c7e7022c RD |
604 | // Sort items. |
605 | // func is a function which takes 2 long arguments: item1, item2. | |
606 | // item1 is the long data associated with a first item (NOT the index). | |
607 | // item2 is the long data associated with a second item (NOT the index). | |
608 | // The return value is a negative number if the first item should precede the second | |
609 | // item, a positive number of the second item should precede the first, | |
610 | // or zero if the two items are equivalent. | |
dcd38683 RD |
611 | bool SortItems(PyObject* func) { |
612 | if (!PyCallable_Check(func)) | |
613 | return FALSE; | |
f6bcfd97 | 614 | return self->SortItems(wxPyListCtrl_SortItems, (long)func); |
dcd38683 RD |
615 | } |
616 | } | |
c7e7022c | 617 | |
7bf85405 RD |
618 | }; |
619 | ||
c7e7022c RD |
620 | |
621 | ||
dcd38683 | 622 | %{ |
f6bcfd97 | 623 | int wxCALLBACK wxPyListCtrl_SortItems(long item1, long item2, long funcPtr) { |
dcd38683 RD |
624 | int retval = 0; |
625 | PyObject* func = (PyObject*)funcPtr; | |
626 | bool doSave = wxPyRestoreThread(); | |
7bf85405 | 627 | |
dcd38683 RD |
628 | PyObject* args = Py_BuildValue("(ii)", item1, item2); |
629 | PyObject* result = PyEval_CallObject(func, args); | |
630 | Py_DECREF(args); | |
631 | if (result) { | |
632 | retval = PyInt_AsLong(result); | |
633 | Py_DECREF(result); | |
634 | } | |
635 | ||
636 | wxPySaveThread(doSave); | |
637 | return retval; | |
638 | } | |
639 | ||
640 | %} | |
7bf85405 RD |
641 | |
642 | //---------------------------------------------------------------------- | |
643 | ||
694759cf RD |
644 | enum wxTreeItemIcon |
645 | { | |
646 | wxTreeItemIcon_Normal, // not selected, not expanded | |
647 | wxTreeItemIcon_Selected, // selected, not expanded | |
648 | wxTreeItemIcon_Expanded, // not selected, expanded | |
649 | wxTreeItemIcon_SelectedExpanded, // selected, expanded | |
650 | wxTreeItemIcon_Max | |
651 | }; | |
652 | ||
7bf85405 | 653 | |
164b735b RD |
654 | // constants for HitTest |
655 | enum { | |
656 | wxTREE_HITTEST_ABOVE, | |
657 | wxTREE_HITTEST_BELOW, | |
658 | wxTREE_HITTEST_NOWHERE, | |
659 | wxTREE_HITTEST_ONITEMBUTTON, | |
660 | wxTREE_HITTEST_ONITEMICON, | |
661 | wxTREE_HITTEST_ONITEMINDENT, | |
662 | wxTREE_HITTEST_ONITEMLABEL, | |
663 | wxTREE_HITTEST_ONITEMRIGHT, | |
664 | wxTREE_HITTEST_ONITEMSTATEICON, | |
665 | wxTREE_HITTEST_TOLEFT, | |
666 | wxTREE_HITTEST_TORIGHT, | |
667 | wxTREE_HITTEST_ONITEMUPPERPART, | |
668 | wxTREE_HITTEST_ONITEMLOWERPART, | |
669 | wxTREE_HITTEST_ONITEM | |
670 | }; | |
671 | ||
672 | ||
1b62f00d RD |
673 | enum { |
674 | /* Tree control event types */ | |
675 | wxEVT_COMMAND_TREE_BEGIN_DRAG, | |
676 | wxEVT_COMMAND_TREE_BEGIN_RDRAG, | |
677 | wxEVT_COMMAND_TREE_BEGIN_LABEL_EDIT, | |
678 | wxEVT_COMMAND_TREE_END_LABEL_EDIT, | |
679 | wxEVT_COMMAND_TREE_DELETE_ITEM, | |
680 | wxEVT_COMMAND_TREE_GET_INFO, | |
681 | wxEVT_COMMAND_TREE_SET_INFO, | |
682 | wxEVT_COMMAND_TREE_ITEM_EXPANDED, | |
683 | wxEVT_COMMAND_TREE_ITEM_EXPANDING, | |
684 | wxEVT_COMMAND_TREE_ITEM_COLLAPSED, | |
685 | wxEVT_COMMAND_TREE_ITEM_COLLAPSING, | |
686 | wxEVT_COMMAND_TREE_SEL_CHANGED, | |
687 | wxEVT_COMMAND_TREE_SEL_CHANGING, | |
688 | wxEVT_COMMAND_TREE_KEY_DOWN, | |
689 | wxEVT_COMMAND_TREE_ITEM_ACTIVATED, | |
690 | wxEVT_COMMAND_TREE_ITEM_RIGHT_CLICK, | |
691 | wxEVT_COMMAND_TREE_ITEM_MIDDLE_CLICK, | |
d1679124 | 692 | wxEVT_COMMAND_TREE_END_DRAG, |
1b62f00d RD |
693 | }; |
694 | ||
695 | ||
d5c9047a RD |
696 | class wxTreeItemId { |
697 | public: | |
698 | wxTreeItemId(); | |
699 | ~wxTreeItemId(); | |
bb0054cd | 700 | bool IsOk(); |
d5c9047a | 701 | |
f6bcfd97 BP |
702 | %addmethods { |
703 | int __cmp__(wxTreeItemId* other) { | |
c368d904 | 704 | if (! other) return -1; |
f6bcfd97 BP |
705 | return *self != *other; |
706 | } | |
707 | } | |
d5c9047a RD |
708 | }; |
709 | ||
710 | ||
711 | ||
cf694132 RD |
712 | %{ |
713 | class wxPyTreeItemData : public wxTreeItemData { | |
d5c9047a | 714 | public: |
cf694132 | 715 | wxPyTreeItemData(PyObject* obj = NULL) { |
c368d904 | 716 | if (obj == NULL) |
cf694132 | 717 | obj = Py_None; |
c368d904 RD |
718 | Py_INCREF(obj); |
719 | m_obj = obj; | |
cf694132 | 720 | } |
d5c9047a | 721 | |
cf694132 | 722 | ~wxPyTreeItemData() { |
1afc06c2 | 723 | bool doSave = wxPyRestoreThread(); |
c368d904 | 724 | Py_DECREF(m_obj); |
1afc06c2 | 725 | wxPySaveThread(doSave); |
cf694132 RD |
726 | } |
727 | ||
728 | PyObject* GetData() { | |
729 | Py_INCREF(m_obj); | |
730 | return m_obj; | |
731 | } | |
732 | ||
733 | void SetData(PyObject* obj) { | |
c368d904 | 734 | bool doSave = wxPyRestoreThread(); |
cf694132 | 735 | Py_DECREF(m_obj); |
c368d904 | 736 | wxPySaveThread(doSave); |
cf694132 RD |
737 | m_obj = obj; |
738 | Py_INCREF(obj); | |
739 | } | |
740 | ||
741 | PyObject* m_obj; | |
d5c9047a | 742 | }; |
cf694132 | 743 | %} |
d5c9047a RD |
744 | |
745 | ||
746 | ||
9416aa89 | 747 | %name(wxTreeItemData) class wxPyTreeItemData : public wxObject { |
cf694132 RD |
748 | public: |
749 | wxPyTreeItemData(PyObject* obj = NULL); | |
750 | ||
751 | PyObject* GetData(); | |
752 | void SetData(PyObject* obj); | |
753 | ||
754 | const wxTreeItemId& GetId(); | |
755 | void SetId(const wxTreeItemId& id); | |
756 | }; | |
757 | ||
758 | ||
d5c9047a | 759 | |
8bf5d46e | 760 | class wxTreeEvent : public wxNotifyEvent { |
d5c9047a RD |
761 | public: |
762 | wxTreeItemId GetItem(); | |
763 | wxTreeItemId GetOldItem(); | |
764 | wxPoint GetPoint(); | |
765 | int GetCode(); | |
8bf5d46e | 766 | const wxString& GetLabel(); |
d5c9047a RD |
767 | }; |
768 | ||
769 | ||
f6bcfd97 BP |
770 | |
771 | %{ | |
772 | class wxPyTreeCtrl : public wxTreeCtrl { | |
3b36695d | 773 | DECLARE_ABSTRACT_CLASS(wxPyTreeCtrl); |
f6bcfd97 BP |
774 | public: |
775 | wxPyTreeCtrl(wxWindow *parent, wxWindowID id, | |
776 | const wxPoint& pos, | |
777 | const wxSize& size, | |
778 | long style, | |
779 | const wxValidator& validator, | |
780 | char* name) : | |
781 | wxTreeCtrl(parent, id, pos, size, style, validator, name) {} | |
782 | ||
f6bcfd97 BP |
783 | int OnCompareItems(const wxTreeItemId& item1, |
784 | const wxTreeItemId& item2) { | |
785 | int rval = 0; | |
786 | bool doSave = wxPyRestoreThread(); | |
787 | if (m_myInst.findCallback("OnCompareItems")) | |
788 | rval = m_myInst.callCallback(Py_BuildValue( | |
789 | "(OO)", | |
790 | wxPyConstructObject((void*)&item1, "wxTreeItemId"), | |
791 | wxPyConstructObject((void*)&item2, "wxTreeItemId"))); | |
792 | else | |
793 | rval = wxTreeCtrl::OnCompareItems(item1, item2); | |
794 | wxPySaveThread(doSave); | |
795 | return rval; | |
796 | } | |
797 | PYPRIVATE; | |
798 | }; | |
799 | ||
3b36695d RD |
800 | IMPLEMENT_ABSTRACT_CLASS(wxPyTreeCtrl, wxTreeCtrl); |
801 | ||
f6bcfd97 BP |
802 | %} |
803 | ||
d5c9047a RD |
804 | // These are for the GetFirstChild/GetNextChild methods below |
805 | %typemap(python, in) long& INOUT = long* INOUT; | |
806 | %typemap(python, argout) long& INOUT = long* INOUT; | |
807 | ||
808 | ||
f6bcfd97 | 809 | %name(wxTreeCtrl)class wxPyTreeCtrl : public wxControl { |
d5c9047a | 810 | public: |
f6bcfd97 | 811 | wxPyTreeCtrl(wxWindow *parent, wxWindowID id = -1, |
b68dc582 RD |
812 | const wxPoint& pos = wxDefaultPosition, |
813 | const wxSize& size = wxDefaultSize, | |
d5c9047a | 814 | long style = wxTR_HAS_BUTTONS | wxTR_LINES_AT_ROOT, |
b68dc582 | 815 | const wxValidator& validator = wxDefaultValidator, |
d5c9047a RD |
816 | char* name = "wxTreeCtrl"); |
817 | ||
f6bcfd97 BP |
818 | void _setSelf(PyObject* self, PyObject* _class); |
819 | %pragma(python) addtomethod = "__init__:#wx._StdWindowCallbacks(self)" | |
820 | %pragma(python) addtomethod = "__init__:self._setSelf(self, wxTreeCtrl)" | |
d5c9047a | 821 | |
1b62f00d | 822 | void AssignImageList(wxImageList* imageList); |
9416aa89 | 823 | %pragma(python) addtomethod = "AssignImageList:_args[0].thisown = 0" |
d5c9047a RD |
824 | size_t GetCount(); |
825 | unsigned int GetIndent(); | |
826 | void SetIndent(unsigned int indent); | |
827 | wxImageList *GetImageList(); | |
828 | wxImageList *GetStateImageList(); | |
1b62f00d | 829 | void SetImageList(wxImageList *imageList); |
d5c9047a RD |
830 | void SetStateImageList(wxImageList *imageList); |
831 | ||
b1462dfa RD |
832 | unsigned int GetSpacing(); |
833 | void SetSpacing(unsigned int spacing); | |
834 | ||
d5c9047a | 835 | wxString GetItemText(const wxTreeItemId& item); |
694759cf RD |
836 | int GetItemImage(const wxTreeItemId& item, |
837 | wxTreeItemIcon which = wxTreeItemIcon_Normal); | |
d5c9047a | 838 | int GetItemSelectedImage(const wxTreeItemId& item); |
d5c9047a RD |
839 | |
840 | void SetItemText(const wxTreeItemId& item, const wxString& text); | |
694759cf RD |
841 | void SetItemImage(const wxTreeItemId& item, int image, |
842 | wxTreeItemIcon which = wxTreeItemIcon_Normal); | |
d5c9047a | 843 | void SetItemSelectedImage(const wxTreeItemId& item, int image); |
08127323 | 844 | void SetItemHasChildren(const wxTreeItemId& item, bool hasChildren = TRUE); |
d5c9047a | 845 | |
cf694132 | 846 | %addmethods { |
c368d904 RD |
847 | // [Get|Set]ItemData substitutes. Automatically create wxPyTreeItemData |
848 | // if needed. | |
cf694132 RD |
849 | wxPyTreeItemData* GetItemData(const wxTreeItemId& item) { |
850 | wxPyTreeItemData* data = (wxPyTreeItemData*)self->GetItemData(item); | |
851 | if (data == NULL) { | |
852 | data = new wxPyTreeItemData(); | |
f6bcfd97 | 853 | data->SetId(item); // set the id |
cf694132 RD |
854 | self->SetItemData(item, data); |
855 | } | |
856 | return data; | |
857 | } | |
858 | ||
859 | void SetItemData(const wxTreeItemId& item, wxPyTreeItemData* data) { | |
f6bcfd97 BP |
860 | data->SetId(item); // set the id |
861 | self->SetItemData(item, data); | |
c368d904 | 862 | } |
cf694132 | 863 | |
c368d904 RD |
864 | // [Get|Set]PyData are short-cuts. Also made somewhat crash-proof by |
865 | // automatically creating data classes. | |
866 | PyObject* GetPyData(const wxTreeItemId& item) { | |
cf694132 RD |
867 | wxPyTreeItemData* data = (wxPyTreeItemData*)self->GetItemData(item); |
868 | if (data == NULL) { | |
869 | data = new wxPyTreeItemData(); | |
f6bcfd97 | 870 | data->SetId(item); // set the id |
cf694132 RD |
871 | self->SetItemData(item, data); |
872 | } | |
873 | return data->GetData(); | |
c368d904 | 874 | } |
cf694132 RD |
875 | |
876 | void SetPyData(const wxTreeItemId& item, PyObject* obj) { | |
877 | wxPyTreeItemData* data = (wxPyTreeItemData*)self->GetItemData(item); | |
878 | if (data == NULL) { | |
879 | data = new wxPyTreeItemData(obj); | |
f6bcfd97 | 880 | data->SetId(item); // set the id |
cf694132 RD |
881 | self->SetItemData(item, data); |
882 | } else | |
883 | data->SetData(obj); | |
c368d904 | 884 | } |
cf694132 RD |
885 | } |
886 | ||
887 | ||
d5c9047a RD |
888 | bool IsVisible(const wxTreeItemId& item); |
889 | bool ItemHasChildren(const wxTreeItemId& item); | |
890 | bool IsExpanded(const wxTreeItemId& item); | |
891 | bool IsSelected(const wxTreeItemId& item); | |
892 | ||
893 | wxTreeItemId GetRootItem(); | |
894 | wxTreeItemId GetSelection(); | |
eb715945 | 895 | %name(GetItemParent) wxTreeItemId GetParent(const wxTreeItemId& item); |
d426c97e RD |
896 | //size_t GetSelections(wxArrayTreeItemIds& selection); |
897 | %addmethods { | |
898 | PyObject* GetSelections() { | |
26b9cf27 | 899 | bool doSave = wxPyRestoreThread(); |
d426c97e RD |
900 | PyObject* rval = PyList_New(0); |
901 | wxArrayTreeItemIds array; | |
902 | size_t num, x; | |
903 | num = self->GetSelections(array); | |
904 | for (x=0; x < num; x++) { | |
c368d904 RD |
905 | wxTreeItemId *tii = new wxTreeItemId(array.Item(x)); |
906 | PyObject* item = wxPyConstructObject((void*)tii, "wxTreeItemId", TRUE); | |
d426c97e RD |
907 | PyList_Append(rval, item); |
908 | } | |
26b9cf27 | 909 | wxPySaveThread(doSave); |
d426c97e RD |
910 | return rval; |
911 | } | |
912 | } | |
913 | ||
914 | ||
d5c9047a | 915 | |
bb0054cd RD |
916 | size_t GetChildrenCount(const wxTreeItemId& item, bool recursively = TRUE); |
917 | ||
d5c9047a RD |
918 | wxTreeItemId GetFirstChild(const wxTreeItemId& item, long& INOUT); |
919 | wxTreeItemId GetNextChild(const wxTreeItemId& item, long& INOUT); | |
920 | wxTreeItemId GetNextSibling(const wxTreeItemId& item); | |
921 | wxTreeItemId GetPrevSibling(const wxTreeItemId& item); | |
922 | wxTreeItemId GetFirstVisibleItem(); | |
923 | wxTreeItemId GetNextVisible(const wxTreeItemId& item); | |
924 | wxTreeItemId GetPrevVisible(const wxTreeItemId& item); | |
d426c97e RD |
925 | wxTreeItemId GetLastChild(const wxTreeItemId& item); |
926 | ||
d5c9047a RD |
927 | |
928 | ||
929 | wxTreeItemId AddRoot(const wxString& text, | |
930 | int image = -1, int selectedImage = -1, | |
cf694132 | 931 | wxPyTreeItemData *data = NULL); |
d5c9047a RD |
932 | wxTreeItemId PrependItem(const wxTreeItemId& parent, |
933 | const wxString& text, | |
934 | int image = -1, int selectedImage = -1, | |
cf694132 | 935 | wxPyTreeItemData *data = NULL); |
d5c9047a RD |
936 | wxTreeItemId InsertItem(const wxTreeItemId& parent, |
937 | const wxTreeItemId& idPrevious, | |
938 | const wxString& text, | |
939 | int image = -1, int selectedImage = -1, | |
cf694132 | 940 | wxPyTreeItemData *data = NULL); |
f6bcfd97 BP |
941 | %name(InsertItemBefore) |
942 | wxTreeItemId InsertItem(const wxTreeItemId& parent, | |
943 | size_t before, | |
944 | const wxString& text, | |
945 | int image = -1, int selectedImage = -1, | |
946 | wxTreeItemData *data = NULL); | |
d5c9047a RD |
947 | wxTreeItemId AppendItem(const wxTreeItemId& parent, |
948 | const wxString& text, | |
949 | int image = -1, int selectedImage = -1, | |
cf694132 | 950 | wxPyTreeItemData *data = NULL); |
d5c9047a RD |
951 | |
952 | void Delete(const wxTreeItemId& item); | |
08127323 | 953 | void DeleteChildren(const wxTreeItemId& item); |
d5c9047a RD |
954 | void DeleteAllItems(); |
955 | ||
956 | void Expand(const wxTreeItemId& item); | |
957 | void Collapse(const wxTreeItemId& item); | |
958 | void CollapseAndReset(const wxTreeItemId& item); | |
959 | void Toggle(const wxTreeItemId& item); | |
960 | ||
961 | void Unselect(); | |
8bf5d46e | 962 | void UnselectAll(); |
d5c9047a RD |
963 | void SelectItem(const wxTreeItemId& item); |
964 | void EnsureVisible(const wxTreeItemId& item); | |
965 | void ScrollTo(const wxTreeItemId& item); | |
8bf5d46e | 966 | #ifdef __WXMSW__ |
d5c9047a | 967 | wxTextCtrl* EditLabel(const wxTreeItemId& item); |
d5c9047a | 968 | wxTextCtrl* GetEditControl(); |
b1462dfa | 969 | void EndEditLabel(const wxTreeItemId& item, int discardChanges = FALSE); |
8bf5d46e RD |
970 | #else |
971 | void EditLabel(const wxTreeItemId& item); | |
972 | #endif | |
d5c9047a | 973 | |
d426c97e | 974 | void SortChildren(const wxTreeItemId& item); |
d5c9047a | 975 | |
b1462dfa | 976 | void SetItemBold(const wxTreeItemId& item, int bold = TRUE); |
b8b8dda7 | 977 | bool IsBold(const wxTreeItemId& item) const; |
164b735b | 978 | wxTreeItemId HitTest(const wxPoint& point, int& OUTPUT); |
c127177f | 979 | |
f6bcfd97 BP |
980 | |
981 | ||
b7e72427 RD |
982 | void SetItemTextColour(const wxTreeItemId& item, const wxColour& col); |
983 | void SetItemBackgroundColour(const wxTreeItemId& item, const wxColour& col); | |
984 | void SetItemFont(const wxTreeItemId& item, const wxFont& font); | |
985 | ||
4120ef2b | 986 | #ifdef __WXMSW__ |
b1462dfa RD |
987 | void SetItemDropHighlight(const wxTreeItemId& item, int highlight = TRUE); |
988 | ||
d426c97e RD |
989 | //bool GetBoundingRect(const wxTreeItemId& item, wxRect& rect, int textOnly = FALSE) |
990 | %addmethods { | |
991 | PyObject* GetBoundingRect(const wxTreeItemId& item, int textOnly = FALSE) { | |
992 | wxRect rect; | |
164b735b RD |
993 | if (self->GetBoundingRect(item, rect, textOnly)) { |
994 | bool doSave = wxPyRestoreThread(); | |
995 | wxRect* r = new wxRect(rect); | |
996 | PyObject* val = wxPyConstructObject((void*)r, "wxRect"); | |
997 | wxPySaveThread(doSave); | |
998 | return val; | |
999 | } | |
d426c97e RD |
1000 | else { |
1001 | Py_INCREF(Py_None); | |
1002 | return Py_None; | |
1003 | } | |
1004 | } | |
1005 | } | |
761a9d2b | 1006 | #endif |
d426c97e | 1007 | |
c127177f | 1008 | %pragma(python) addtoclass = " |
f6bcfd97 BP |
1009 | # Redefine some methods that SWIG gets a bit confused on... |
1010 | def GetFirstChild(self, *_args, **_kwargs): | |
1011 | val1,val2 = apply(controls2c.wxTreeCtrl_GetFirstChild,(self,) + _args, _kwargs) | |
1012 | val1 = wxTreeItemIdPtr(val1) | |
1013 | val1.thisown = 1 | |
1014 | return (val1,val2) | |
1015 | def GetNextChild(self, *_args, **_kwargs): | |
1016 | val1,val2 = apply(controls2c.wxTreeCtrl_GetNextChild,(self,) + _args, _kwargs) | |
c127177f RD |
1017 | val1 = wxTreeItemIdPtr(val1) |
1018 | val1.thisown = 1 | |
1019 | return (val1,val2) | |
f6bcfd97 BP |
1020 | def HitTest(self, *_args, **_kwargs): |
1021 | val1, val2 = apply(controls2c.wxTreeCtrl_HitTest,(self,) + _args, _kwargs) | |
c127177f RD |
1022 | val1 = wxTreeItemIdPtr(val1) |
1023 | val1.thisown = 1 | |
1024 | return (val1,val2) | |
1025 | " | |
d5c9047a RD |
1026 | }; |
1027 | ||
d5c9047a | 1028 | |
7bf85405 RD |
1029 | //---------------------------------------------------------------------- |
1030 | ||
9c039d08 | 1031 | #ifdef SKIPTHIS |
fb5e0af0 | 1032 | #ifdef __WXMSW__ |
1b62f00d RD |
1033 | |
1034 | ||
1035 | enum { | |
1036 | /* tab control event types */ | |
1037 | wxEVT_COMMAND_TAB_SEL_CHANGED, | |
1038 | wxEVT_COMMAND_TAB_SEL_CHANGING, | |
1039 | }; | |
1040 | ||
1041 | ||
7bf85405 RD |
1042 | class wxTabEvent : public wxCommandEvent { |
1043 | public: | |
1044 | }; | |
1045 | ||
1046 | ||
1047 | ||
1048 | class wxTabCtrl : public wxControl { | |
1049 | public: | |
1050 | wxTabCtrl(wxWindow* parent, wxWindowID id, | |
b68dc582 RD |
1051 | const wxPoint& pos = wxDefaultPosition, |
1052 | const wxSize& size = wxDefaultSize, | |
7bf85405 RD |
1053 | long style = 0, |
1054 | char* name = "tabCtrl"); | |
1055 | ||
f6bcfd97 | 1056 | %pragma(python) addtomethod = "__init__:#wx._StdWindowCallbacks(self)" |
9c039d08 | 1057 | |
7bf85405 RD |
1058 | bool DeleteAllItems(); |
1059 | bool DeleteItem(int item); | |
1060 | wxImageList* GetImageList(); | |
1061 | int GetItemCount(); | |
1062 | // TODO: void* GetItemData(); | |
1063 | int GetItemImage(int item); | |
1064 | ||
1065 | %addmethods { | |
1066 | %new wxRect* GetItemRect(int item) { | |
1067 | wxRect* rect = new wxRect; | |
1068 | self->GetItemRect(item, *rect); | |
1069 | return rect; | |
1070 | } | |
1071 | } | |
1072 | ||
1073 | wxString GetItemText(int item); | |
1074 | bool GetRowCount(); | |
1075 | int GetSelection(); | |
1076 | int HitTest(const wxPoint& pt, long& OUTPUT); | |
1077 | void InsertItem(int item, const wxString& text, | |
1078 | int imageId = -1, void* clientData = NULL); | |
1079 | // TODO: bool SetItemData(int item, void* data); | |
1080 | bool SetItemImage(int item, int image); | |
1081 | void SetImageList(wxImageList* imageList); | |
1082 | void SetItemSize(const wxSize& size); | |
1083 | bool SetItemText(int item, const wxString& text); | |
1084 | void SetPadding(const wxSize& padding); | |
1085 | int SetSelection(int item); | |
1086 | ||
1087 | }; | |
1088 | ||
9c039d08 | 1089 | #endif |
fb5e0af0 RD |
1090 | #endif |
1091 | ||
7bf85405 RD |
1092 | //---------------------------------------------------------------------- |
1093 | ||
9416aa89 RD |
1094 | %init %{ |
1095 | wxPyPtrTypeMap_Add("wxTreeItemData", "wxPyTreeItemData"); | |
1096 | wxPyPtrTypeMap_Add("wxTreeCtrl", "wxPyTreeCtrl"); | |
1097 | %} | |
1098 | ||
1099 | //---------------------------------------------------------------------- | |
1100 | ||
7bf85405 | 1101 |