]> git.saurik.com Git - wxWidgets.git/blob - utils/wxPython/src/controls2.i
no message
[wxWidgets.git] / utils / wxPython / src / controls2.i
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
13 %module controls2
14
15 %{
16 #include "helpers.h"
17 #include <wx/listctrl.h>
18 #include <wx/treectrl.h>
19 #if 0
20 #include <wx/tabctrl.h>
21 #endif
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
37 %pragma(python) code = "import wxp"
38
39 //----------------------------------------------------------------------
40
41 %{
42 extern wxValidator wxPyDefaultValidator;
43 %}
44
45 //----------------------------------------------------------------------
46
47 class wxListItem {
48 public:
49 long m_mask; // Indicates what fields are valid
50 long m_itemId; // The zero-based item position
51 int m_col; // Zero-based column, if in report mode
52 long m_state; // The state of the item
53 long m_stateMask; // Which flags of m_state are valid (uses same flags)
54 wxString m_text; // The label/header text
55 int m_image; // The zero-based index into an image list
56 long m_data; // App-defined data
57 // wxColour *m_colour; // only wxGLC, not supported by Windows ;->
58
59 // For columns only
60 int m_format; // left, right, centre
61 int m_width; // width of column
62
63 wxListItem();
64 ~wxListItem();
65 };
66
67 class wxListEvent: public wxCommandEvent {
68 public:
69 int m_code;
70 long m_itemIndex;
71 long m_oldItemIndex;
72 int m_col;
73 bool m_cancelled;
74 wxPoint m_pointDrag;
75 wxListItem m_item;
76 };
77
78
79
80
81 class wxListCtrl : public wxControl {
82 public:
83 #ifdef __WXMSW__
84 wxListCtrl(wxWindow* parent, wxWindowID id,
85 const wxPoint& pos = wxPyDefaultPosition,
86 const wxSize& size = wxPyDefaultSize,
87 long style = wxLC_ICON,
88 const wxValidator& validator = wxPyDefaultValidator,
89 char* name = "listCtrl");
90 #else
91 wxListCtrl(wxWindow* parent, wxWindowID id,
92 const wxPoint& pos = wxPyDefaultPosition,
93 const wxSize& size = wxPyDefaultSize,
94 long style = wxLC_ICON,
95 char* name = "listctrl");
96 #endif
97
98 %pragma(python) addtomethod = "__init__:wxp._StdWindowCallbacks(self)"
99
100 bool Arrange(int flag = wxLIST_ALIGN_DEFAULT);
101 bool DeleteItem(long item);
102 bool DeleteAllItems();
103 bool DeleteColumn(int col);
104 #ifdef __WXMSW__
105 bool DeleteAllColumns(void);
106 void ClearAll(void);
107 wxTextCtrl* EditLabel(long item);
108 bool EndEditLabel(bool cancel);
109 #endif
110 bool EnsureVisible(long item);
111 long FindItem(long start, const wxString& str, bool partial = FALSE);
112 %name(FindItemData)long FindItem(long start, long data);
113 %name(FindItemAtPos)long FindItem(long start, const wxPoint& pt,
114 int direction);
115 bool GetColumn(int col, wxListItem& item);
116 int GetColumnWidth(int col);
117 int GetCountPerPage();
118 #ifdef __WXMSW__
119 wxTextCtrl* GetEditControl();
120 #endif
121 wxImageList* GetImageList(int which);
122 long GetItemData(long item);
123
124 %addmethods {
125 %new wxListItem* GetItem() {
126 wxListItem* info = new wxListItem;
127 self->GetItem(*info);
128 return info;
129 }
130 %new wxPoint* GetItemPosition(long item) {
131 wxPoint* pos = new wxPoint;
132 self->GetItemPosition(item, *pos);
133 return pos;
134 }
135 %new wxRect* GetItemRect(long item, int code = wxLIST_RECT_BOUNDS) {
136 wxRect* rect= new wxRect;
137 self->GetItemRect(item, *rect, code);
138 return rect;
139 }
140 }
141
142 int GetItemState(long item, long stateMask);
143 int GetItemCount();
144 int GetItemSpacing(bool isSmall);
145 wxString GetItemText(long item);
146 long GetNextItem(long item,
147 int geometry = wxLIST_NEXT_ALL,
148 int state = wxLIST_STATE_DONTCARE);
149 int GetSelectedItemCount();
150 #ifdef __WXMSW__
151 wxColour GetTextColour();
152 #endif
153 long GetTopItem();
154 long HitTest(const wxPoint& point, int& OUTPUT);
155 %name(InsertColumnWithInfo)long InsertColumn(long col, wxListItem& info);
156 long InsertColumn(long col, const wxString& heading,
157 int format = wxLIST_FORMAT_LEFT,
158 int width = -1);
159
160 long InsertItem(wxListItem& info);
161 %name(InsertStringItem) long InsertItem(long index, const wxString& label);
162 %name(InsertImageItem) long InsertItem(long index, int imageIndex);
163 %name(InsertImageStringItem)long InsertItem(long index, const wxString& label,
164 int imageIndex);
165
166 bool ScrollList(int dx, int dy);
167 void SetBackgroundColour(const wxColour& col);
168 bool SetColumn(int col, wxListItem& item);
169 bool SetColumnWidth(int col, int width);
170 void SetImageList(wxImageList* imageList, int which);
171 bool SetItem(wxListItem& info);
172 %name(SetItemString)long SetItem(long index, int col, const wxString& label,
173 int imageId = -1);
174 bool SetItemData(long item, long data);
175 bool SetItemImage(long item, int image, int selImage);
176 bool SetItemPosition(long item, const wxPoint& pos);
177 bool SetItemState(long item, long state, long stateMask);
178 void SetItemText(long item, const wxString& text);
179 void SetSingleStyle(long style, bool add = TRUE);
180 #ifdef __WXMSW__
181 void SetTextColour(const wxColour& col);
182 #endif
183 void SetWindowStyleFlag(long style);
184 // TODO: bool SortItems(wxListCtrlCompare fn, long data);
185 };
186
187
188
189 //----------------------------------------------------------------------
190
191
192 #ifdef SKIPTHIS
193
194
195 enum {
196 wxTREE_MASK_HANDLE,
197 wxTREE_MASK_STATE,
198 wxTREE_MASK_TEXT,
199 wxTREE_MASK_IMAGE,
200 wxTREE_MASK_SELECTED_IMAGE,
201 wxTREE_MASK_CHILDREN,
202 wxTREE_MASK_DATA,
203
204 wxTREE_STATE_BOLD,
205 wxTREE_STATE_DROPHILITED,
206 wxTREE_STATE_EXPANDED,
207 wxTREE_STATE_EXPANDEDONCE,
208 wxTREE_STATE_FOCUSED,
209 wxTREE_STATE_SELECTED,
210 wxTREE_STATE_CUT,
211
212 wxTREE_HITTEST_ABOVE,
213 wxTREE_HITTEST_BELOW,
214 wxTREE_HITTEST_NOWHERE,
215 wxTREE_HITTEST_ONITEMBUTTON,
216 wxTREE_HITTEST_ONITEMICON,
217 wxTREE_HITTEST_ONITEMINDENT,
218 wxTREE_HITTEST_ONITEMLABEL,
219 wxTREE_HITTEST_ONITEMRIGHT,
220 wxTREE_HITTEST_ONITEMSTATEICON,
221 wxTREE_HITTEST_TOLEFT,
222 wxTREE_HITTEST_TORIGHT,
223 wxTREE_HITTEST_ONITEM,
224 };
225
226
227 enum {
228 wxTREE_NEXT_CARET,
229 wxTREE_NEXT_CHILD,
230 wxTREE_NEXT_DROPHILITE,
231 wxTREE_NEXT_FIRSTVISIBLE,
232 wxTREE_NEXT_NEXT,
233 wxTREE_NEXT_NEXTVISIBLE,
234 wxTREE_NEXT_PARENT,
235 wxTREE_NEXT_PREVIOUS,
236 wxTREE_NEXT_PREVIOUSVISIBLE,
237 wxTREE_NEXT_ROOT
238 };
239
240 enum {
241 wxTREE_EXPAND_EXPAND,
242 wxTREE_EXPAND_COLLAPSE,
243 wxTREE_EXPAND_COLLAPSE_RESET,
244 wxTREE_EXPAND_TOGGLE
245 };
246
247 enum {
248 wxTREE_INSERT_LAST,
249 wxTREE_INSERT_FIRST,
250 wxTREE_INSERT_SORT,
251 };
252
253
254
255
256 class wxTreeItem {
257 public:
258 long m_mask;
259 long m_itemId;
260 long m_state;
261 long m_stateMask;
262 wxString m_text;
263 int m_image;
264 int m_selectedImage;
265 int m_children;
266 long m_data;
267
268 wxTreeItem();
269 ~wxTreeItem();
270 };
271
272
273
274 class wxTreeEvent : public wxCommandEvent {
275 public:
276 int m_code;
277 wxTreeItem m_item;
278 long m_oldItem;
279 wxPoint m_pointDrag;
280 };
281
282
283
284
285 class wxTreeCtrl : public wxControl {
286 public:
287 wxTreeCtrl(wxWindow *parent, wxWindowID id = -1,
288 const wxPoint& pos = wxPyDefaultPosition,
289 const wxSize& size = wxPyDefaultSize,
290 long style = wxTR_HAS_BUTTONS,
291 const wxValidator& validator = wxPyDefaultValidator,
292 char* name = "wxTreeCtrl");
293
294 %pragma(python) addtomethod = "__init__:wxp._StdWindowCallbacks(self)"
295
296 bool DeleteAllItems();
297 #ifdef __WXMSW__
298 bool DeleteItem(long item);
299 #else
300 void DeleteItem(long item);
301 #endif
302 #ifdef __WXMSW__
303 wxTextCtrl* EditLabel(long item);
304 bool EnsureVisible(long item);
305 bool ExpandItem(long item, int action);
306 long GetChild(long item);
307 #endif
308 int GetCount();
309 #ifdef __WXMSW__
310 wxTextCtrl* GetEditControl();
311 long GetFirstVisibleItem();
312 #endif
313 wxImageList* GetImageList(int which = wxIMAGE_LIST_NORMAL);
314 int GetIndent();
315 long GetItemData(long item);
316
317 %addmethods {
318 %new wxTreeItem* GetItem() {
319 wxTreeItem* info = new wxTreeItem;
320 self->GetItem(*info);
321 return info;
322 }
323 #ifdef __WXMSW__
324 %new wxRect* GetItemRect(long item, int textOnly = FALSE) {
325 wxRect* rect = new wxRect;
326 self->GetItemRect(item, *rect, textOnly);
327 return rect;
328 }
329 #endif
330 }
331
332 #ifdef __WXMSW__
333 int GetItemState(long item, long stateMask);
334 #endif
335 wxString GetItemText(long item);
336 #ifdef __WXMSW__
337 long GetNextItem(long item, int code);
338 long GetNextVisibleItem(long item);
339 #endif
340 long GetParent(long item);
341 long GetRootItem();
342 long GetSelection();
343 long HitTest(const wxPoint& point, int& OUTPUT); // *** check this
344 long InsertItem(long parent, wxTreeItem& info,
345 long insertAfter = wxTREE_INSERT_LAST);
346 %name(InsertItemString)
347 long InsertItem(long parent, const wxString& label,
348 int image = -1, int selImage = -1,
349 long insertAfter = wxTREE_INSERT_LAST);
350 bool ItemHasChildren(long item);
351 #ifdef __WXMSW__
352 bool ScrollTo(long item);
353 #endif
354 bool SelectItem(long item);
355 void SetIndent(int indent);
356 void SetImageList(wxImageList* imageList, int which = wxIMAGE_LIST_NORMAL);
357 bool SetItem(wxTreeItem& info);
358 #ifdef __WXMSW__
359 bool SetItemImage(long item, int image, int selImage);
360 #else
361 void SetItemImage(long item, int image, int selImage);
362 #endif
363 #ifdef __WXMSW__
364 bool SetItemState(long item, long state, long stateMask);
365 #endif
366 void SetItemText(long item, const wxString& text);
367 bool SetItemData(long item, long data);
368 #ifdef __WXMSW__
369 bool SortChildren(long item);
370 #endif
371 };
372
373 #endif
374
375
376 //----------------------------------------------------------------------
377
378 #ifdef __WXMSW__
379 class wxTreeItemId {
380 public:
381 wxTreeItemId();
382 ~wxTreeItemId();
383 bool IsOk() const { return m_itemId != 0; }
384
385 %addmethods {
386 long GetId() { return (long)(*self); }
387 }
388 };
389
390
391
392 // **** This isn't very useful yet. This needs to be specialized to enable
393 // derived Python classes...
394 class wxTreeItemData {
395 public:
396 wxTreeItemData();
397 ~wxTreeItemData();
398
399 const wxTreeItemId& GetItemId();
400 };
401
402
403
404
405 class wxTreeEvent : public wxCommandEvent {
406 public:
407 wxTreeItemId GetItem();
408 wxTreeItemId GetOldItem();
409 wxPoint GetPoint();
410 int GetCode();
411 void Veto();
412 };
413
414
415 // These are for the GetFirstChild/GetNextChild methods below
416 %typemap(python, in) long& INOUT = long* INOUT;
417 %typemap(python, argout) long& INOUT = long* INOUT;
418
419
420 class wxTreeCtrl : public wxControl {
421 public:
422 wxTreeCtrl(wxWindow *parent, wxWindowID id = -1,
423 const wxPoint& pos = wxPyDefaultPosition,
424 const wxSize& size = wxPyDefaultSize,
425 long style = wxTR_HAS_BUTTONS | wxTR_LINES_AT_ROOT,
426 const wxValidator& validator = wxPyDefaultValidator,
427 char* name = "wxTreeCtrl");
428
429 %pragma(python) addtomethod = "__init__:wxp._StdWindowCallbacks(self)"
430
431 size_t GetCount();
432 unsigned int GetIndent();
433 void SetIndent(unsigned int indent);
434 wxImageList *GetImageList();
435 wxImageList *GetStateImageList();
436 void SetImageList(wxImageList *imageList);
437 void SetStateImageList(wxImageList *imageList);
438
439 wxString GetItemText(const wxTreeItemId& item);
440 int GetItemImage(const wxTreeItemId& item);
441 int GetItemSelectedImage(const wxTreeItemId& item);
442 wxTreeItemData *GetItemData(const wxTreeItemId& item);
443
444 void SetItemText(const wxTreeItemId& item, const wxString& text);
445 void SetItemImage(const wxTreeItemId& item, int image);
446 void SetItemSelectedImage(const wxTreeItemId& item, int image);
447 void SetItemData(const wxTreeItemId& item, wxTreeItemData *data);
448
449 bool IsVisible(const wxTreeItemId& item);
450 bool ItemHasChildren(const wxTreeItemId& item);
451 bool IsExpanded(const wxTreeItemId& item);
452 bool IsSelected(const wxTreeItemId& item);
453
454 wxTreeItemId GetRootItem();
455 wxTreeItemId GetSelection();
456 wxTreeItemId GetParent(const wxTreeItemId& item);
457
458 wxTreeItemId GetFirstChild(const wxTreeItemId& item, long& INOUT);
459 wxTreeItemId GetNextChild(const wxTreeItemId& item, long& INOUT);
460 wxTreeItemId GetNextSibling(const wxTreeItemId& item);
461 wxTreeItemId GetPrevSibling(const wxTreeItemId& item);
462 wxTreeItemId GetFirstVisibleItem();
463 wxTreeItemId GetNextVisible(const wxTreeItemId& item);
464 wxTreeItemId GetPrevVisible(const wxTreeItemId& item);
465
466
467 wxTreeItemId AddRoot(const wxString& text,
468 int image = -1, int selectedImage = -1,
469 wxTreeItemData *data = NULL);
470 wxTreeItemId PrependItem(const wxTreeItemId& parent,
471 const wxString& text,
472 int image = -1, int selectedImage = -1,
473 wxTreeItemData *data = NULL);
474 wxTreeItemId InsertItem(const wxTreeItemId& parent,
475 const wxTreeItemId& idPrevious,
476 const wxString& text,
477 int image = -1, int selectedImage = -1,
478 wxTreeItemData *data = NULL);
479 wxTreeItemId AppendItem(const wxTreeItemId& parent,
480 const wxString& text,
481 int image = -1, int selectedImage = -1,
482 wxTreeItemData *data = NULL);
483
484 void Delete(const wxTreeItemId& item);
485 void DeleteAllItems();
486
487 void Expand(const wxTreeItemId& item);
488 void Collapse(const wxTreeItemId& item);
489 void CollapseAndReset(const wxTreeItemId& item);
490 void Toggle(const wxTreeItemId& item);
491
492 void Unselect();
493 void SelectItem(const wxTreeItemId& item);
494 void EnsureVisible(const wxTreeItemId& item);
495 void ScrollTo(const wxTreeItemId& item);
496
497 wxTextCtrl* EditLabel(const wxTreeItemId& item);
498 // **** figure out how to do this
499 // wxClassInfo* textCtrlClass = CLASSINFO(wxTextCtrl));
500 wxTextCtrl* GetEditControl();
501 void EndEditLabel(const wxTreeItemId& item, bool discardChanges = FALSE);
502
503 void SortChildren(const wxTreeItemId& item);
504 // **** And this too
505 // wxTreeItemCmpFunc *cmpFunction = NULL);
506
507 };
508
509 #endif
510
511 //----------------------------------------------------------------------
512
513 #ifdef SKIPTHIS
514 #ifdef __WXMSW__
515 class wxTabEvent : public wxCommandEvent {
516 public:
517 };
518
519
520
521 class wxTabCtrl : public wxControl {
522 public:
523 wxTabCtrl(wxWindow* parent, wxWindowID id,
524 const wxPoint& pos = wxPyDefaultPosition,
525 const wxSize& size = wxPyDefaultSize,
526 long style = 0,
527 char* name = "tabCtrl");
528
529 %pragma(python) addtomethod = "__init__:wxp._StdWindowCallbacks(self)"
530
531 bool DeleteAllItems();
532 bool DeleteItem(int item);
533 wxImageList* GetImageList();
534 int GetItemCount();
535 // TODO: void* GetItemData();
536 int GetItemImage(int item);
537
538 %addmethods {
539 %new wxRect* GetItemRect(int item) {
540 wxRect* rect = new wxRect;
541 self->GetItemRect(item, *rect);
542 return rect;
543 }
544 }
545
546 wxString GetItemText(int item);
547 bool GetRowCount();
548 int GetSelection();
549 int HitTest(const wxPoint& pt, long& OUTPUT);
550 void InsertItem(int item, const wxString& text,
551 int imageId = -1, void* clientData = NULL);
552 // TODO: bool SetItemData(int item, void* data);
553 bool SetItemImage(int item, int image);
554 void SetImageList(wxImageList* imageList);
555 void SetItemSize(const wxSize& size);
556 bool SetItemText(int item, const wxString& text);
557 void SetPadding(const wxSize& padding);
558 int SetSelection(int item);
559
560 };
561
562 #endif
563 #endif
564
565 //----------------------------------------------------------------------
566
567
568 /////////////////////////////////////////////////////////////////////////////
569 //
570 // $Log$
571 // Revision 1.6 1998/10/20 06:43:55 RD
572 // New wxTreeCtrl wrappers (untested)
573 // some changes in helpers
574 // etc.
575 //
576 // Revision 1.5 1998/10/07 07:34:33 RD
577 // Version 0.4.1 for wxGTK
578 //
579 // Revision 1.4 1998/10/02 06:40:36 RD
580 //
581 // Version 0.4 of wxPython for MSW.
582 //
583 // Revision 1.3 1998/08/18 19:48:15 RD
584 // more wxGTK compatibility things.
585 //
586 // It builds now but there are serious runtime problems...
587 //
588 // Revision 1.2 1998/08/15 07:36:30 RD
589 // - Moved the header in the .i files out of the code that gets put into
590 // the .cpp files. It caused CVS conflicts because of the RCS ID being
591 // different each time.
592 //
593 // - A few minor fixes.
594 //
595 // Revision 1.1 1998/08/09 08:25:49 RD
596 // Initial version
597 //
598 //