]> git.saurik.com Git - wxWidgets.git/blob - utils/wxPython/src/controls2.i
Changes needed to enable wxGTK compatibility.
[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 %}
20
21 //----------------------------------------------------------------------
22
23 %include typemaps.i
24 %include my_typemaps.i
25
26 // Import some definitions of other classes, etc.
27 %import _defs.i
28 %import misc.i
29 %import windows.i
30 %import gdi.i
31 %import events.i
32 %import controls.i
33
34 %pragma(python) code = "import wx"
35
36 //----------------------------------------------------------------------
37
38 %{
39 extern wxValidator wxPyDefaultValidator;
40 %}
41
42 //----------------------------------------------------------------------
43
44 enum {
45 wxLIST_MASK_TEXT,
46 wxLIST_MASK_IMAGE,
47 wxLIST_MASK_DATA,
48 wxLIST_MASK_WIDTH,
49 wxLIST_MASK_FORMAT,
50 wxLIST_STATE_DONTCARE,
51 wxLIST_STATE_DROPHILITED,
52 wxLIST_STATE_FOCUSED,
53 wxLIST_STATE_SELECTED,
54 wxLIST_STATE_CUT,
55 wxLIST_HITTEST_ABOVE,
56 wxLIST_HITTEST_BELOW,
57 wxLIST_HITTEST_NOWHERE,
58 wxLIST_HITTEST_ONITEMICON,
59 wxLIST_HITTEST_ONITEMLABEL,
60 wxLIST_HITTEST_ONITEMRIGHT,
61 wxLIST_HITTEST_ONITEMSTATEICON,
62 wxLIST_HITTEST_TOLEFT,
63 wxLIST_HITTEST_TORIGHT,
64 wxLIST_HITTEST_ONITEM,
65 wxLIST_NEXT_ABOVE,
66 wxLIST_NEXT_ALL,
67 wxLIST_NEXT_BELOW,
68 wxLIST_NEXT_LEFT,
69 wxLIST_NEXT_RIGHT,
70 wxLIST_ALIGN_DEFAULT,
71 wxLIST_ALIGN_LEFT,
72 wxLIST_ALIGN_TOP,
73 wxLIST_ALIGN_SNAP_TO_GRID,
74 wxLIST_FORMAT_LEFT,
75 wxLIST_FORMAT_RIGHT,
76 wxLIST_FORMAT_CENTRE,
77 wxLIST_FORMAT_CENTER,
78 wxLIST_AUTOSIZE,
79 wxLIST_AUTOSIZE_USEHEADER,
80 wxLIST_RECT_BOUNDS,
81 wxLIST_RECT_ICON,
82 wxLIST_RECT_LABEL,
83 wxLIST_FIND_UP,
84 wxLIST_FIND_DOWN,
85 wxLIST_FIND_LEFT,
86 wxLIST_FIND_RIGHT,
87 };
88
89
90 class wxListItem {
91 public:
92 long m_mask; // Indicates what fields are valid
93 long m_itemId; // The zero-based item position
94 int m_col; // Zero-based column, if in report mode
95 long m_state; // The state of the item
96 long m_stateMask; // Which flags of m_state are valid (uses same flags)
97 wxString m_text; // The label/header text
98 int m_image; // The zero-based index into an image list
99 long m_data; // App-defined data
100 // wxColour *m_colour; // only wxGLC, not supported by Windows ;->
101
102 // For columns only
103 int m_format; // left, right, centre
104 int m_width; // width of column
105
106 wxListItem();
107 ~wxListItem();
108 };
109
110 class wxListEvent: public wxCommandEvent {
111 public:
112 int m_code;
113 long m_itemIndex;
114 long m_oldItemIndex;
115 int m_col;
116 bool m_cancelled;
117 wxPoint m_pointDrag;
118 wxListItem m_item;
119 };
120
121
122
123
124 class wxListCtrl : public wxControl {
125 public:
126 wxListCtrl(wxWindow* parent, wxWindowID id,
127 const wxPoint& pos = wxPyDefaultPosition,
128 const wxSize& size = wxPyDefaultSize,
129 long style = wxLC_ICON,
130 const wxValidator& validator = wxPyDefaultValidator,
131 char* name = "listCtrl");
132
133 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
134
135 bool Arrange(int flag = wxLIST_ALIGN_DEFAULT);
136 bool DeleteItem(long item);
137 bool DeleteAllItems();
138 bool DeleteColumn(int col);
139 bool DeleteAllColumns(void);
140 void ClearAll(void);
141 #ifdef __WXMSW__
142 wxTextCtrl* EditLabel(long item);
143 bool EndEditLabel(bool cancel);
144 wxTextCtrl* GetEditControl();
145 #endif
146 bool EnsureVisible(long item);
147 long FindItem(long start, const wxString& str, bool partial = FALSE);
148 %name(FindItemData)long FindItem(long start, long data);
149 %name(FindItemAtPos)long FindItem(long start, const wxPoint& pt,
150 int direction);
151 bool GetColumn(int col, wxListItem& item);
152 int GetColumnWidth(int col);
153 int GetCountPerPage();
154 wxImageList* GetImageList(int which);
155 long GetItemData(long item);
156
157 %addmethods {
158 %new wxListItem* GetItem() {
159 wxListItem* info = new wxListItem;
160 self->GetItem(*info);
161 return info;
162 }
163 %new wxPoint* GetItemPosition(long item) {
164 wxPoint* pos = new wxPoint;
165 self->GetItemPosition(item, *pos);
166 return pos;
167 }
168 %new wxRect* GetItemRect(long item, int code = wxLIST_RECT_BOUNDS) {
169 wxRect* rect= new wxRect;
170 self->GetItemRect(item, *rect, code);
171 return rect;
172 }
173 }
174
175 int GetItemState(long item, long stateMask);
176 int GetItemCount();
177 int GetItemSpacing(bool isSmall);
178 wxString GetItemText(long item);
179 long GetNextItem(long item,
180 int geometry = wxLIST_NEXT_ALL,
181 int state = wxLIST_STATE_DONTCARE);
182 int GetSelectedItemCount();
183 #ifdef __WXMSW__
184 wxColour GetTextColour();
185 void SetTextColour(const wxColour& col);
186 #endif
187 long GetTopItem();
188 long HitTest(const wxPoint& point, int& OUTPUT);
189 %name(InsertColumnWithInfo)long InsertColumn(long col, wxListItem& info);
190 long InsertColumn(long col, const wxString& heading,
191 int format = wxLIST_FORMAT_LEFT,
192 int width = -1);
193
194 long InsertItem(wxListItem& info);
195 %name(InsertStringItem) long InsertItem(long index, const wxString& label);
196 %name(InsertImageItem) long InsertItem(long index, int imageIndex);
197 %name(InsertImageStringItem)long InsertItem(long index, const wxString& label,
198 int imageIndex);
199
200 bool ScrollList(int dx, int dy);
201 void SetBackgroundColour(const wxColour& col);
202 bool SetColumn(int col, wxListItem& item);
203 bool SetColumnWidth(int col, int width);
204 void SetImageList(wxImageList* imageList, int which);
205
206 bool SetItem(wxListItem& info);
207 %name(SetStringItem)long SetItem(long index, int col, const wxString& label,
208 int imageId = -1);
209
210 bool SetItemData(long item, long data);
211 bool SetItemImage(long item, int image, int selImage);
212 bool SetItemPosition(long item, const wxPoint& pos);
213 bool SetItemState(long item, long state, long stateMask);
214 void SetItemText(long item, const wxString& text);
215 void SetSingleStyle(long style, bool add = TRUE);
216 void SetWindowStyleFlag(long style);
217 // TODO: bool SortItems(wxListCtrlCompare fn, long data);
218 };
219
220
221
222 //----------------------------------------------------------------------
223
224
225 class wxTreeItemId {
226 public:
227 wxTreeItemId();
228 ~wxTreeItemId();
229 bool IsOk() const { return m_itemId != 0; }
230
231 // %addmethods {
232 // long GetId() { return (long)(*self); }
233 // }
234 };
235
236
237
238 // **** This isn't very useful yet. This needs to be specialized to enable
239 // derived Python classes...
240 class wxTreeItemData {
241 public:
242 wxTreeItemData();
243 ~wxTreeItemData();
244
245 const wxTreeItemId& GetId();
246 void SetId(const wxTreeItemId& id);
247 };
248
249
250
251
252 class wxTreeEvent : public wxCommandEvent {
253 public:
254 wxTreeItemId GetItem();
255 wxTreeItemId GetOldItem();
256 wxPoint GetPoint();
257 int GetCode();
258 void Veto();
259 };
260
261
262 // These are for the GetFirstChild/GetNextChild methods below
263 %typemap(python, in) long& INOUT = long* INOUT;
264 %typemap(python, argout) long& INOUT = long* INOUT;
265
266
267 class wxTreeCtrl : public wxControl {
268 public:
269 wxTreeCtrl(wxWindow *parent, wxWindowID id = -1,
270 const wxPoint& pos = wxPyDefaultPosition,
271 const wxSize& size = wxPyDefaultSize,
272 long style = wxTR_HAS_BUTTONS | wxTR_LINES_AT_ROOT,
273 const wxValidator& validator = wxPyDefaultValidator,
274 char* name = "wxTreeCtrl");
275
276 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
277
278 size_t GetCount();
279 unsigned int GetIndent();
280 void SetIndent(unsigned int indent);
281 wxImageList *GetImageList();
282 wxImageList *GetStateImageList();
283 void SetImageList(wxImageList *imageList);
284 void SetStateImageList(wxImageList *imageList);
285
286 wxString GetItemText(const wxTreeItemId& item);
287 int GetItemImage(const wxTreeItemId& item);
288 int GetItemSelectedImage(const wxTreeItemId& item);
289 wxTreeItemData *GetItemData(const wxTreeItemId& item);
290
291 void SetItemText(const wxTreeItemId& item, const wxString& text);
292 void SetItemImage(const wxTreeItemId& item, int image);
293 void SetItemSelectedImage(const wxTreeItemId& item, int image);
294 void SetItemData(const wxTreeItemId& item, wxTreeItemData *data);
295 void SetItemHasChildren(const wxTreeItemId& item, bool hasChildren = TRUE);
296
297 bool IsVisible(const wxTreeItemId& item);
298 bool ItemHasChildren(const wxTreeItemId& item);
299 bool IsExpanded(const wxTreeItemId& item);
300 bool IsSelected(const wxTreeItemId& item);
301
302 wxTreeItemId GetRootItem();
303 wxTreeItemId GetSelection();
304 wxTreeItemId GetParent(const wxTreeItemId& item);
305
306 wxTreeItemId GetFirstChild(const wxTreeItemId& item, long& INOUT);
307 wxTreeItemId GetNextChild(const wxTreeItemId& item, long& INOUT);
308 wxTreeItemId GetNextSibling(const wxTreeItemId& item);
309 wxTreeItemId GetPrevSibling(const wxTreeItemId& item);
310 wxTreeItemId GetFirstVisibleItem();
311 wxTreeItemId GetNextVisible(const wxTreeItemId& item);
312 wxTreeItemId GetPrevVisible(const wxTreeItemId& item);
313
314
315 wxTreeItemId AddRoot(const wxString& text,
316 int image = -1, int selectedImage = -1,
317 wxTreeItemData *data = NULL);
318 wxTreeItemId PrependItem(const wxTreeItemId& parent,
319 const wxString& text,
320 int image = -1, int selectedImage = -1,
321 wxTreeItemData *data = NULL);
322 wxTreeItemId InsertItem(const wxTreeItemId& parent,
323 const wxTreeItemId& idPrevious,
324 const wxString& text,
325 int image = -1, int selectedImage = -1,
326 wxTreeItemData *data = NULL);
327 wxTreeItemId AppendItem(const wxTreeItemId& parent,
328 const wxString& text,
329 int image = -1, int selectedImage = -1,
330 wxTreeItemData *data = NULL);
331
332 void Delete(const wxTreeItemId& item);
333 void DeleteChildren(const wxTreeItemId& item);
334 void DeleteAllItems();
335
336 void Expand(const wxTreeItemId& item);
337 void Collapse(const wxTreeItemId& item);
338 void CollapseAndReset(const wxTreeItemId& item);
339 void Toggle(const wxTreeItemId& item);
340
341 void Unselect();
342 void SelectItem(const wxTreeItemId& item);
343 void EnsureVisible(const wxTreeItemId& item);
344 void ScrollTo(const wxTreeItemId& item);
345
346 wxTextCtrl* EditLabel(const wxTreeItemId& item);
347 // **** figure out how to do this
348 // wxClassInfo* textCtrlClass = CLASSINFO(wxTextCtrl));
349 wxTextCtrl* GetEditControl();
350 void EndEditLabel(const wxTreeItemId& item, bool discardChanges = FALSE);
351
352 // void SortChildren(const wxTreeItemId& item);
353 // **** And this too
354 // wxTreeItemCmpFunc *cmpFunction = NULL);
355
356 void SetItemBold(const wxTreeItemId& item, bool bold = TRUE);
357 bool IsBold(const wxTreeItemId& item) const;
358 wxTreeItemId HitTest(const wxPoint& point);
359 };
360
361
362 //----------------------------------------------------------------------
363
364 #ifdef SKIPTHIS
365 #ifdef __WXMSW__
366 class wxTabEvent : public wxCommandEvent {
367 public:
368 };
369
370
371
372 class wxTabCtrl : public wxControl {
373 public:
374 wxTabCtrl(wxWindow* parent, wxWindowID id,
375 const wxPoint& pos = wxPyDefaultPosition,
376 const wxSize& size = wxPyDefaultSize,
377 long style = 0,
378 char* name = "tabCtrl");
379
380 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
381
382 bool DeleteAllItems();
383 bool DeleteItem(int item);
384 wxImageList* GetImageList();
385 int GetItemCount();
386 // TODO: void* GetItemData();
387 int GetItemImage(int item);
388
389 %addmethods {
390 %new wxRect* GetItemRect(int item) {
391 wxRect* rect = new wxRect;
392 self->GetItemRect(item, *rect);
393 return rect;
394 }
395 }
396
397 wxString GetItemText(int item);
398 bool GetRowCount();
399 int GetSelection();
400 int HitTest(const wxPoint& pt, long& OUTPUT);
401 void InsertItem(int item, const wxString& text,
402 int imageId = -1, void* clientData = NULL);
403 // TODO: bool SetItemData(int item, void* data);
404 bool SetItemImage(int item, int image);
405 void SetImageList(wxImageList* imageList);
406 void SetItemSize(const wxSize& size);
407 bool SetItemText(int item, const wxString& text);
408 void SetPadding(const wxSize& padding);
409 int SetSelection(int item);
410
411 };
412
413 #endif
414 #endif
415
416 //----------------------------------------------------------------------
417
418
419 /////////////////////////////////////////////////////////////////////////////
420 //
421 // $Log$
422 // Revision 1.15 1999/02/20 09:02:56 RD
423 // Added wxWindow_FromHWND(hWnd) for wxMSW to construct a wxWindow from a
424 // window handle. If you can get the window handle into the python code,
425 // it should just work... More news on this later.
426 //
427 // Added wxImageList, wxToolTip.
428 //
429 // Re-enabled wxConfig.DeleteAll() since it is reportedly fixed for the
430 // wxRegConfig class.
431 //
432 // As usual, some bug fixes, tweaks, etc.
433 //
434 // Revision 1.14 1999/01/30 07:30:10 RD
435 //
436 // Added wxSashWindow, wxSashEvent, wxLayoutAlgorithm, etc.
437 //
438 // Various cleanup, tweaks, minor additions, etc. to maintain
439 // compatibility with the current wxWindows.
440 //
441 // Revision 1.13 1998/12/17 14:07:34 RR
442 //
443 // Removed minor differences between wxMSW and wxGTK
444 //
445 // Revision 1.12 1998/12/16 22:10:52 RD
446 //
447 // Tweaks needed to be able to build wxPython with wxGTK.
448 //
449 // Revision 1.11 1998/12/15 20:41:16 RD
450 // Changed the import semantics from "from wxPython import *" to "from
451 // wxPython.wx import *" This is for people who are worried about
452 // namespace pollution, they can use "from wxPython import wx" and then
453 // prefix all the wxPython identifiers with "wx."
454 //
455 // Added wxTaskbarIcon for wxMSW.
456 //
457 // Made the events work for wxGrid.
458 //
459 // Added wxConfig.
460 //
461 // Added wxMiniFrame for wxGTK, (untested.)
462 //
463 // Changed many of the args and return values that were pointers to gdi
464 // objects to references to reflect changes in the wxWindows API.
465 //
466 // Other assorted fixes and additions.
467 //
468 // Revision 1.10 1998/11/25 08:45:23 RD
469 //
470 // Added wxPalette, wxRegion, wxRegionIterator, wxTaskbarIcon
471 // Added events for wxGrid
472 // Other various fixes and additions
473 //
474 // Revision 1.9 1998/11/16 00:00:54 RD
475 // Generic treectrl for wxPython/GTK compiles...
476 //
477 // Revision 1.8 1998/11/11 04:40:20 RD
478 // wxTreeCtrl now works (sort of) for wxPython-GTK. This is the new
479 // TreeCtrl in src/gtk/treectrl.cpp not the old generic one.
480 //
481 // Revision 1.7 1998/11/11 03:12:25 RD
482 //
483 // Additions for wxTreeCtrl
484 //
485 // Revision 1.6 1998/10/20 06:43:55 RD
486 // New wxTreeCtrl wrappers (untested)
487 // some changes in helpers
488 // etc.
489 //
490 // Revision 1.5 1998/10/07 07:34:33 RD
491 // Version 0.4.1 for wxGTK
492 //
493 // Revision 1.4 1998/10/02 06:40:36 RD
494 //
495 // Version 0.4 of wxPython for MSW.
496 //
497 // Revision 1.3 1998/08/18 19:48:15 RD
498 // more wxGTK compatibility things.
499 //
500 // It builds now but there are serious runtime problems...
501 //
502 // Revision 1.2 1998/08/15 07:36:30 RD
503 // - Moved the header in the .i files out of the code that gets put into
504 // the .cpp files. It caused CVS conflicts because of the RCS ID being
505 // different each time.
506 //
507 // - A few minor fixes.
508 //
509 // Revision 1.1 1998/08/09 08:25:49 RD
510 // Initial version
511 //
512 //