]>
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> | |
7bf85405 RD |
22 | %} |
23 | ||
24 | //---------------------------------------------------------------------- | |
25 | ||
26 | %include typemaps.i | |
27 | %include my_typemaps.i | |
28 | ||
29 | // Import some definitions of other classes, etc. | |
30 | %import _defs.i | |
31 | %import misc.i | |
32 | %import windows.i | |
33 | %import gdi.i | |
34 | %import events.i | |
35 | %import controls.i | |
36 | ||
b8b8dda7 | 37 | %pragma(python) code = "import wx" |
9c039d08 | 38 | |
7bf85405 RD |
39 | //---------------------------------------------------------------------- |
40 | ||
41 | %{ | |
42 | extern wxValidator wxPyDefaultValidator; | |
43 | %} | |
44 | ||
45 | //---------------------------------------------------------------------- | |
46 | ||
af309447 RD |
47 | enum { |
48 | wxLIST_MASK_TEXT, | |
49 | wxLIST_MASK_IMAGE, | |
50 | wxLIST_MASK_DATA, | |
51 | wxLIST_MASK_WIDTH, | |
52 | wxLIST_MASK_FORMAT, | |
bb0054cd | 53 | wxLIST_MASK_STATE, |
af309447 RD |
54 | wxLIST_STATE_DONTCARE, |
55 | wxLIST_STATE_DROPHILITED, | |
56 | wxLIST_STATE_FOCUSED, | |
57 | wxLIST_STATE_SELECTED, | |
58 | wxLIST_STATE_CUT, | |
59 | wxLIST_HITTEST_ABOVE, | |
60 | wxLIST_HITTEST_BELOW, | |
61 | wxLIST_HITTEST_NOWHERE, | |
62 | wxLIST_HITTEST_ONITEMICON, | |
63 | wxLIST_HITTEST_ONITEMLABEL, | |
64 | wxLIST_HITTEST_ONITEMRIGHT, | |
65 | wxLIST_HITTEST_ONITEMSTATEICON, | |
66 | wxLIST_HITTEST_TOLEFT, | |
67 | wxLIST_HITTEST_TORIGHT, | |
68 | wxLIST_HITTEST_ONITEM, | |
69 | wxLIST_NEXT_ABOVE, | |
70 | wxLIST_NEXT_ALL, | |
71 | wxLIST_NEXT_BELOW, | |
72 | wxLIST_NEXT_LEFT, | |
73 | wxLIST_NEXT_RIGHT, | |
74 | wxLIST_ALIGN_DEFAULT, | |
75 | wxLIST_ALIGN_LEFT, | |
76 | wxLIST_ALIGN_TOP, | |
77 | wxLIST_ALIGN_SNAP_TO_GRID, | |
78 | wxLIST_FORMAT_LEFT, | |
79 | wxLIST_FORMAT_RIGHT, | |
80 | wxLIST_FORMAT_CENTRE, | |
81 | wxLIST_FORMAT_CENTER, | |
82 | wxLIST_AUTOSIZE, | |
83 | wxLIST_AUTOSIZE_USEHEADER, | |
84 | wxLIST_RECT_BOUNDS, | |
85 | wxLIST_RECT_ICON, | |
86 | wxLIST_RECT_LABEL, | |
87 | wxLIST_FIND_UP, | |
88 | wxLIST_FIND_DOWN, | |
89 | wxLIST_FIND_LEFT, | |
90 | wxLIST_FIND_RIGHT, | |
91 | }; | |
92 | ||
93 | ||
7bf85405 RD |
94 | class wxListItem { |
95 | public: | |
96 | long m_mask; // Indicates what fields are valid | |
97 | long m_itemId; // The zero-based item position | |
98 | int m_col; // Zero-based column, if in report mode | |
99 | long m_state; // The state of the item | |
100 | long m_stateMask; // Which flags of m_state are valid (uses same flags) | |
101 | wxString m_text; // The label/header text | |
102 | int m_image; // The zero-based index into an image list | |
103 | long m_data; // App-defined data | |
104 | // wxColour *m_colour; // only wxGLC, not supported by Windows ;-> | |
105 | ||
106 | // For columns only | |
107 | int m_format; // left, right, centre | |
108 | int m_width; // width of column | |
109 | ||
110 | wxListItem(); | |
111 | ~wxListItem(); | |
112 | }; | |
113 | ||
114 | class wxListEvent: public wxCommandEvent { | |
115 | public: | |
116 | int m_code; | |
117 | long m_itemIndex; | |
118 | long m_oldItemIndex; | |
119 | int m_col; | |
120 | bool m_cancelled; | |
121 | wxPoint m_pointDrag; | |
122 | wxListItem m_item; | |
123 | }; | |
124 | ||
125 | ||
126 | ||
127 | ||
128 | class wxListCtrl : public wxControl { | |
129 | public: | |
130 | wxListCtrl(wxWindow* parent, wxWindowID id, | |
131 | const wxPoint& pos = wxPyDefaultPosition, | |
132 | const wxSize& size = wxPyDefaultSize, | |
133 | long style = wxLC_ICON, | |
134 | const wxValidator& validator = wxPyDefaultValidator, | |
135 | char* name = "listCtrl"); | |
136 | ||
b8b8dda7 | 137 | %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)" |
9c039d08 | 138 | |
7bf85405 RD |
139 | bool Arrange(int flag = wxLIST_ALIGN_DEFAULT); |
140 | bool DeleteItem(long item); | |
141 | bool DeleteAllItems(); | |
142 | bool DeleteColumn(int col); | |
143 | bool DeleteAllColumns(void); | |
144 | void ClearAll(void); | |
4f22cf8d | 145 | #ifdef __WXMSW__ |
7bf85405 RD |
146 | wxTextCtrl* EditLabel(long item); |
147 | bool EndEditLabel(bool cancel); | |
4f22cf8d | 148 | wxTextCtrl* GetEditControl(); |
8bf5d46e RD |
149 | #else |
150 | void EditLabel(long item); | |
fb5e0af0 | 151 | #endif |
7bf85405 RD |
152 | bool EnsureVisible(long item); |
153 | long FindItem(long start, const wxString& str, bool partial = FALSE); | |
154 | %name(FindItemData)long FindItem(long start, long data); | |
155 | %name(FindItemAtPos)long FindItem(long start, const wxPoint& pt, | |
156 | int direction); | |
157 | bool GetColumn(int col, wxListItem& item); | |
158 | int GetColumnWidth(int col); | |
159 | int GetCountPerPage(); | |
7bf85405 RD |
160 | wxImageList* GetImageList(int which); |
161 | long GetItemData(long item); | |
162 | ||
163 | %addmethods { | |
e166644c | 164 | %new wxListItem* GetItem(long itemId, int col=0) { |
7bf85405 | 165 | wxListItem* info = new wxListItem; |
0699c864 | 166 | info->m_itemId = itemId; |
e166644c | 167 | info->m_col = col; |
f17fee68 | 168 | info->m_mask = 0xFFFF; |
7bf85405 RD |
169 | self->GetItem(*info); |
170 | return info; | |
171 | } | |
172 | %new wxPoint* GetItemPosition(long item) { | |
173 | wxPoint* pos = new wxPoint; | |
174 | self->GetItemPosition(item, *pos); | |
175 | return pos; | |
176 | } | |
177 | %new wxRect* GetItemRect(long item, int code = wxLIST_RECT_BOUNDS) { | |
178 | wxRect* rect= new wxRect; | |
179 | self->GetItemRect(item, *rect, code); | |
180 | return rect; | |
181 | } | |
182 | } | |
183 | ||
184 | int GetItemState(long item, long stateMask); | |
185 | int GetItemCount(); | |
186 | int GetItemSpacing(bool isSmall); | |
187 | wxString GetItemText(long item); | |
188 | long GetNextItem(long item, | |
189 | int geometry = wxLIST_NEXT_ALL, | |
190 | int state = wxLIST_STATE_DONTCARE); | |
191 | int GetSelectedItemCount(); | |
fb5e0af0 | 192 | #ifdef __WXMSW__ |
7bf85405 | 193 | wxColour GetTextColour(); |
4f22cf8d | 194 | void SetTextColour(const wxColour& col); |
fb5e0af0 | 195 | #endif |
7bf85405 RD |
196 | long GetTopItem(); |
197 | long HitTest(const wxPoint& point, int& OUTPUT); | |
0699c864 | 198 | %name(InsertColumnWith)long InsertColumn(long col, wxListItem& info); |
7bf85405 RD |
199 | long InsertColumn(long col, const wxString& heading, |
200 | int format = wxLIST_FORMAT_LEFT, | |
201 | int width = -1); | |
202 | ||
203 | long InsertItem(wxListItem& info); | |
204 | %name(InsertStringItem) long InsertItem(long index, const wxString& label); | |
205 | %name(InsertImageItem) long InsertItem(long index, int imageIndex); | |
206 | %name(InsertImageStringItem)long InsertItem(long index, const wxString& label, | |
207 | int imageIndex); | |
208 | ||
209 | bool ScrollList(int dx, int dy); | |
210 | void SetBackgroundColour(const wxColour& col); | |
211 | bool SetColumn(int col, wxListItem& item); | |
212 | bool SetColumnWidth(int col, int width); | |
213 | void SetImageList(wxImageList* imageList, int which); | |
af309447 | 214 | |
7bf85405 | 215 | bool SetItem(wxListItem& info); |
af309447 | 216 | %name(SetStringItem)long SetItem(long index, int col, const wxString& label, |
7bf85405 | 217 | int imageId = -1); |
af309447 | 218 | |
7bf85405 RD |
219 | bool SetItemData(long item, long data); |
220 | bool SetItemImage(long item, int image, int selImage); | |
221 | bool SetItemPosition(long item, const wxPoint& pos); | |
222 | bool SetItemState(long item, long state, long stateMask); | |
223 | void SetItemText(long item, const wxString& text); | |
224 | void SetSingleStyle(long style, bool add = TRUE); | |
7bf85405 RD |
225 | void SetWindowStyleFlag(long style); |
226 | // TODO: bool SortItems(wxListCtrlCompare fn, long data); | |
227 | }; | |
228 | ||
229 | ||
230 | ||
231 | //---------------------------------------------------------------------- | |
232 | ||
694759cf RD |
233 | enum wxTreeItemIcon |
234 | { | |
235 | wxTreeItemIcon_Normal, // not selected, not expanded | |
236 | wxTreeItemIcon_Selected, // selected, not expanded | |
237 | wxTreeItemIcon_Expanded, // not selected, expanded | |
238 | wxTreeItemIcon_SelectedExpanded, // selected, expanded | |
239 | wxTreeItemIcon_Max | |
240 | }; | |
241 | ||
7bf85405 | 242 | |
164b735b RD |
243 | // constants for HitTest |
244 | enum { | |
245 | wxTREE_HITTEST_ABOVE, | |
246 | wxTREE_HITTEST_BELOW, | |
247 | wxTREE_HITTEST_NOWHERE, | |
248 | wxTREE_HITTEST_ONITEMBUTTON, | |
249 | wxTREE_HITTEST_ONITEMICON, | |
250 | wxTREE_HITTEST_ONITEMINDENT, | |
251 | wxTREE_HITTEST_ONITEMLABEL, | |
252 | wxTREE_HITTEST_ONITEMRIGHT, | |
253 | wxTREE_HITTEST_ONITEMSTATEICON, | |
254 | wxTREE_HITTEST_TOLEFT, | |
255 | wxTREE_HITTEST_TORIGHT, | |
256 | wxTREE_HITTEST_ONITEMUPPERPART, | |
257 | wxTREE_HITTEST_ONITEMLOWERPART, | |
258 | wxTREE_HITTEST_ONITEM | |
259 | }; | |
260 | ||
261 | ||
d5c9047a RD |
262 | class wxTreeItemId { |
263 | public: | |
264 | wxTreeItemId(); | |
265 | ~wxTreeItemId(); | |
bb0054cd | 266 | bool IsOk(); |
d5c9047a | 267 | |
d5c9047a RD |
268 | }; |
269 | ||
270 | ||
271 | ||
cf694132 RD |
272 | %{ |
273 | class wxPyTreeItemData : public wxTreeItemData { | |
d5c9047a | 274 | public: |
cf694132 RD |
275 | wxPyTreeItemData(PyObject* obj = NULL) { |
276 | if (obj == NULL) | |
277 | obj = Py_None; | |
278 | Py_INCREF(obj); | |
279 | m_obj = obj; | |
280 | } | |
d5c9047a | 281 | |
cf694132 | 282 | ~wxPyTreeItemData() { |
1afc06c2 | 283 | bool doSave = wxPyRestoreThread(); |
cf694132 | 284 | Py_DECREF(m_obj); |
1afc06c2 | 285 | wxPySaveThread(doSave); |
cf694132 RD |
286 | } |
287 | ||
288 | PyObject* GetData() { | |
289 | Py_INCREF(m_obj); | |
290 | return m_obj; | |
291 | } | |
292 | ||
293 | void SetData(PyObject* obj) { | |
294 | Py_DECREF(m_obj); | |
295 | m_obj = obj; | |
296 | Py_INCREF(obj); | |
297 | } | |
298 | ||
299 | PyObject* m_obj; | |
d5c9047a | 300 | }; |
cf694132 | 301 | %} |
d5c9047a RD |
302 | |
303 | ||
304 | ||
cf694132 RD |
305 | %name(wxTreeItemData) class wxPyTreeItemData { |
306 | public: | |
307 | wxPyTreeItemData(PyObject* obj = NULL); | |
308 | ||
309 | PyObject* GetData(); | |
310 | void SetData(PyObject* obj); | |
311 | ||
312 | const wxTreeItemId& GetId(); | |
313 | void SetId(const wxTreeItemId& id); | |
314 | }; | |
315 | ||
316 | ||
d5c9047a | 317 | |
8bf5d46e | 318 | class wxTreeEvent : public wxNotifyEvent { |
d5c9047a RD |
319 | public: |
320 | wxTreeItemId GetItem(); | |
321 | wxTreeItemId GetOldItem(); | |
322 | wxPoint GetPoint(); | |
323 | int GetCode(); | |
8bf5d46e | 324 | const wxString& GetLabel(); |
d5c9047a RD |
325 | }; |
326 | ||
327 | ||
328 | // These are for the GetFirstChild/GetNextChild methods below | |
329 | %typemap(python, in) long& INOUT = long* INOUT; | |
330 | %typemap(python, argout) long& INOUT = long* INOUT; | |
331 | ||
332 | ||
333 | class wxTreeCtrl : public wxControl { | |
334 | public: | |
335 | wxTreeCtrl(wxWindow *parent, wxWindowID id = -1, | |
336 | const wxPoint& pos = wxPyDefaultPosition, | |
337 | const wxSize& size = wxPyDefaultSize, | |
338 | long style = wxTR_HAS_BUTTONS | wxTR_LINES_AT_ROOT, | |
339 | const wxValidator& validator = wxPyDefaultValidator, | |
340 | char* name = "wxTreeCtrl"); | |
341 | ||
b8b8dda7 | 342 | %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)" |
d5c9047a RD |
343 | |
344 | size_t GetCount(); | |
345 | unsigned int GetIndent(); | |
346 | void SetIndent(unsigned int indent); | |
347 | wxImageList *GetImageList(); | |
348 | wxImageList *GetStateImageList(); | |
694759cf | 349 | void SetImageList(wxImageList *imageList/*, int which = wxIMAGE_LIST_NORMAL*/); |
d5c9047a RD |
350 | void SetStateImageList(wxImageList *imageList); |
351 | ||
b1462dfa RD |
352 | unsigned int GetSpacing(); |
353 | void SetSpacing(unsigned int spacing); | |
354 | ||
d5c9047a | 355 | wxString GetItemText(const wxTreeItemId& item); |
694759cf RD |
356 | int GetItemImage(const wxTreeItemId& item, |
357 | wxTreeItemIcon which = wxTreeItemIcon_Normal); | |
d5c9047a | 358 | int GetItemSelectedImage(const wxTreeItemId& item); |
d5c9047a RD |
359 | |
360 | void SetItemText(const wxTreeItemId& item, const wxString& text); | |
694759cf RD |
361 | void SetItemImage(const wxTreeItemId& item, int image, |
362 | wxTreeItemIcon which = wxTreeItemIcon_Normal); | |
d5c9047a | 363 | void SetItemSelectedImage(const wxTreeItemId& item, int image); |
08127323 | 364 | void SetItemHasChildren(const wxTreeItemId& item, bool hasChildren = TRUE); |
d5c9047a | 365 | |
cf694132 RD |
366 | %addmethods { |
367 | // [Get|Set]ItemData substitutes. Automatically create wxPyTreeItemData | |
368 | // if needed. | |
369 | wxPyTreeItemData* GetItemData(const wxTreeItemId& item) { | |
370 | wxPyTreeItemData* data = (wxPyTreeItemData*)self->GetItemData(item); | |
371 | if (data == NULL) { | |
372 | data = new wxPyTreeItemData(); | |
373 | self->SetItemData(item, data); | |
374 | } | |
375 | return data; | |
376 | } | |
377 | ||
378 | void SetItemData(const wxTreeItemId& item, wxPyTreeItemData* data) { | |
379 | self->SetItemData(item, data); | |
380 | } | |
381 | ||
382 | // [Get|Set]PyData are short-cuts. Also made somewhat crash-proof by | |
383 | // automatically creating data classes. | |
384 | PyObject* GetPyData(const wxTreeItemId& item) { | |
385 | wxPyTreeItemData* data = (wxPyTreeItemData*)self->GetItemData(item); | |
386 | if (data == NULL) { | |
387 | data = new wxPyTreeItemData(); | |
388 | self->SetItemData(item, data); | |
389 | } | |
390 | return data->GetData(); | |
391 | } | |
392 | ||
393 | void SetPyData(const wxTreeItemId& item, PyObject* obj) { | |
394 | wxPyTreeItemData* data = (wxPyTreeItemData*)self->GetItemData(item); | |
395 | if (data == NULL) { | |
396 | data = new wxPyTreeItemData(obj); | |
397 | self->SetItemData(item, data); | |
398 | } else | |
399 | data->SetData(obj); | |
400 | } | |
401 | } | |
402 | ||
403 | ||
d5c9047a RD |
404 | bool IsVisible(const wxTreeItemId& item); |
405 | bool ItemHasChildren(const wxTreeItemId& item); | |
406 | bool IsExpanded(const wxTreeItemId& item); | |
407 | bool IsSelected(const wxTreeItemId& item); | |
408 | ||
409 | wxTreeItemId GetRootItem(); | |
410 | wxTreeItemId GetSelection(); | |
eb715945 | 411 | %name(GetItemParent) wxTreeItemId GetParent(const wxTreeItemId& item); |
d426c97e RD |
412 | //size_t GetSelections(wxArrayTreeItemIds& selection); |
413 | %addmethods { | |
414 | PyObject* GetSelections() { | |
26b9cf27 | 415 | bool doSave = wxPyRestoreThread(); |
d426c97e RD |
416 | PyObject* rval = PyList_New(0); |
417 | wxArrayTreeItemIds array; | |
418 | size_t num, x; | |
419 | num = self->GetSelections(array); | |
420 | for (x=0; x < num; x++) { | |
421 | PyObject* item = wxPyConstructObject((void*)&array.Item(x), | |
422 | "wxTreeItemId"); | |
423 | PyList_Append(rval, item); | |
424 | } | |
26b9cf27 | 425 | wxPySaveThread(doSave); |
d426c97e RD |
426 | return rval; |
427 | } | |
428 | } | |
429 | ||
430 | ||
d5c9047a | 431 | |
bb0054cd RD |
432 | size_t GetChildrenCount(const wxTreeItemId& item, bool recursively = TRUE); |
433 | ||
d5c9047a RD |
434 | wxTreeItemId GetFirstChild(const wxTreeItemId& item, long& INOUT); |
435 | wxTreeItemId GetNextChild(const wxTreeItemId& item, long& INOUT); | |
436 | wxTreeItemId GetNextSibling(const wxTreeItemId& item); | |
437 | wxTreeItemId GetPrevSibling(const wxTreeItemId& item); | |
438 | wxTreeItemId GetFirstVisibleItem(); | |
439 | wxTreeItemId GetNextVisible(const wxTreeItemId& item); | |
440 | wxTreeItemId GetPrevVisible(const wxTreeItemId& item); | |
d426c97e RD |
441 | wxTreeItemId GetLastChild(const wxTreeItemId& item); |
442 | ||
d5c9047a RD |
443 | |
444 | ||
445 | wxTreeItemId AddRoot(const wxString& text, | |
446 | int image = -1, int selectedImage = -1, | |
cf694132 | 447 | wxPyTreeItemData *data = NULL); |
d5c9047a RD |
448 | wxTreeItemId PrependItem(const wxTreeItemId& parent, |
449 | const wxString& text, | |
450 | int image = -1, int selectedImage = -1, | |
cf694132 | 451 | wxPyTreeItemData *data = NULL); |
d5c9047a RD |
452 | wxTreeItemId InsertItem(const wxTreeItemId& parent, |
453 | const wxTreeItemId& idPrevious, | |
454 | const wxString& text, | |
455 | int image = -1, int selectedImage = -1, | |
cf694132 | 456 | wxPyTreeItemData *data = NULL); |
d5c9047a RD |
457 | wxTreeItemId AppendItem(const wxTreeItemId& parent, |
458 | const wxString& text, | |
459 | int image = -1, int selectedImage = -1, | |
cf694132 | 460 | wxPyTreeItemData *data = NULL); |
d5c9047a RD |
461 | |
462 | void Delete(const wxTreeItemId& item); | |
08127323 | 463 | void DeleteChildren(const wxTreeItemId& item); |
d5c9047a RD |
464 | void DeleteAllItems(); |
465 | ||
466 | void Expand(const wxTreeItemId& item); | |
467 | void Collapse(const wxTreeItemId& item); | |
468 | void CollapseAndReset(const wxTreeItemId& item); | |
469 | void Toggle(const wxTreeItemId& item); | |
470 | ||
471 | void Unselect(); | |
8bf5d46e | 472 | void UnselectAll(); |
d5c9047a RD |
473 | void SelectItem(const wxTreeItemId& item); |
474 | void EnsureVisible(const wxTreeItemId& item); | |
475 | void ScrollTo(const wxTreeItemId& item); | |
8bf5d46e | 476 | #ifdef __WXMSW__ |
d5c9047a | 477 | wxTextCtrl* EditLabel(const wxTreeItemId& item); |
d5c9047a | 478 | wxTextCtrl* GetEditControl(); |
b1462dfa | 479 | void EndEditLabel(const wxTreeItemId& item, int discardChanges = FALSE); |
8bf5d46e RD |
480 | #else |
481 | void EditLabel(const wxTreeItemId& item); | |
482 | #endif | |
d5c9047a | 483 | |
d426c97e | 484 | void SortChildren(const wxTreeItemId& item); |
d5c9047a | 485 | |
b1462dfa | 486 | void SetItemBold(const wxTreeItemId& item, int bold = TRUE); |
b8b8dda7 | 487 | bool IsBold(const wxTreeItemId& item) const; |
164b735b | 488 | wxTreeItemId HitTest(const wxPoint& point, int& OUTPUT); |
c127177f | 489 | |
b7e72427 RD |
490 | void SetItemTextColour(const wxTreeItemId& item, const wxColour& col); |
491 | void SetItemBackgroundColour(const wxTreeItemId& item, const wxColour& col); | |
492 | void SetItemFont(const wxTreeItemId& item, const wxFont& font); | |
493 | ||
4120ef2b | 494 | #ifdef __WXMSW__ |
b1462dfa RD |
495 | void SetItemDropHighlight(const wxTreeItemId& item, int highlight = TRUE); |
496 | ||
d426c97e RD |
497 | //bool GetBoundingRect(const wxTreeItemId& item, wxRect& rect, int textOnly = FALSE) |
498 | %addmethods { | |
499 | PyObject* GetBoundingRect(const wxTreeItemId& item, int textOnly = FALSE) { | |
500 | wxRect rect; | |
164b735b RD |
501 | if (self->GetBoundingRect(item, rect, textOnly)) { |
502 | bool doSave = wxPyRestoreThread(); | |
503 | wxRect* r = new wxRect(rect); | |
504 | PyObject* val = wxPyConstructObject((void*)r, "wxRect"); | |
505 | wxPySaveThread(doSave); | |
506 | return val; | |
507 | } | |
d426c97e RD |
508 | else { |
509 | Py_INCREF(Py_None); | |
510 | return Py_None; | |
511 | } | |
512 | } | |
513 | } | |
761a9d2b | 514 | #endif |
d426c97e | 515 | |
c127177f RD |
516 | %pragma(python) addtoclass = " |
517 | # Redefine a couple methods that SWIG gets a bit confused on... | |
518 | def GetFirstChild(self,arg0,arg1): | |
519 | val1, val2 = controls2c.wxTreeCtrl_GetFirstChild(self.this,arg0.this,arg1) | |
520 | val1 = wxTreeItemIdPtr(val1) | |
521 | val1.thisown = 1 | |
522 | return (val1,val2) | |
523 | def GetNextChild(self,arg0,arg1): | |
bb0054cd | 524 | val1, val2 = controls2c.wxTreeCtrl_GetNextChild(self.this,arg0.this,arg1) |
c127177f RD |
525 | val1 = wxTreeItemIdPtr(val1) |
526 | val1.thisown = 1 | |
527 | return (val1,val2) | |
528 | " | |
d5c9047a RD |
529 | }; |
530 | ||
d5c9047a | 531 | |
7bf85405 RD |
532 | //---------------------------------------------------------------------- |
533 | ||
9c039d08 | 534 | #ifdef SKIPTHIS |
fb5e0af0 | 535 | #ifdef __WXMSW__ |
7bf85405 RD |
536 | class wxTabEvent : public wxCommandEvent { |
537 | public: | |
538 | }; | |
539 | ||
540 | ||
541 | ||
542 | class wxTabCtrl : public wxControl { | |
543 | public: | |
544 | wxTabCtrl(wxWindow* parent, wxWindowID id, | |
545 | const wxPoint& pos = wxPyDefaultPosition, | |
546 | const wxSize& size = wxPyDefaultSize, | |
547 | long style = 0, | |
548 | char* name = "tabCtrl"); | |
549 | ||
b8b8dda7 | 550 | %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)" |
9c039d08 | 551 | |
7bf85405 RD |
552 | bool DeleteAllItems(); |
553 | bool DeleteItem(int item); | |
554 | wxImageList* GetImageList(); | |
555 | int GetItemCount(); | |
556 | // TODO: void* GetItemData(); | |
557 | int GetItemImage(int item); | |
558 | ||
559 | %addmethods { | |
560 | %new wxRect* GetItemRect(int item) { | |
561 | wxRect* rect = new wxRect; | |
562 | self->GetItemRect(item, *rect); | |
563 | return rect; | |
564 | } | |
565 | } | |
566 | ||
567 | wxString GetItemText(int item); | |
568 | bool GetRowCount(); | |
569 | int GetSelection(); | |
570 | int HitTest(const wxPoint& pt, long& OUTPUT); | |
571 | void InsertItem(int item, const wxString& text, | |
572 | int imageId = -1, void* clientData = NULL); | |
573 | // TODO: bool SetItemData(int item, void* data); | |
574 | bool SetItemImage(int item, int image); | |
575 | void SetImageList(wxImageList* imageList); | |
576 | void SetItemSize(const wxSize& size); | |
577 | bool SetItemText(int item, const wxString& text); | |
578 | void SetPadding(const wxSize& padding); | |
579 | int SetSelection(int item); | |
580 | ||
581 | }; | |
582 | ||
9c039d08 | 583 | #endif |
fb5e0af0 RD |
584 | #endif |
585 | ||
7bf85405 RD |
586 | //---------------------------------------------------------------------- |
587 | ||
588 |